forked from mirror/openmw-tes3mp
Merge remote-tracking branch 'upstream/master' into windowsPinning
Conflicts: apps/openmw/mwgui/window_manager.cpp (keep both changes)actorid
commit
bdbb8a8d84
@ -0,0 +1,122 @@
|
|||||||
|
#ifdef OPENMW_USE_AUDIERE
|
||||||
|
|
||||||
|
#include <stdexcept>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
#include "audiere_decoder.hpp"
|
||||||
|
|
||||||
|
|
||||||
|
static void fail(const std::string &msg)
|
||||||
|
{ throw std::runtime_error("Audiere exception: "+msg); }
|
||||||
|
|
||||||
|
namespace MWSound
|
||||||
|
{
|
||||||
|
|
||||||
|
class OgreFile : public audiere::File
|
||||||
|
{
|
||||||
|
Ogre::DataStreamPtr mStream;
|
||||||
|
|
||||||
|
ADR_METHOD(int) read(void* buffer, int size)
|
||||||
|
{
|
||||||
|
return mStream->read(buffer, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
ADR_METHOD(bool) seek(int position, SeekMode mode)
|
||||||
|
{
|
||||||
|
if(mode == CURRENT)
|
||||||
|
mStream->seek(mStream->tell()+position);
|
||||||
|
else if(mode == BEGIN)
|
||||||
|
mStream->seek(position);
|
||||||
|
else if(mode == END)
|
||||||
|
mStream->seek(mStream->size()+position);
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
ADR_METHOD(int) tell()
|
||||||
|
{
|
||||||
|
return mStream->tell();
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t refs;
|
||||||
|
virtual void ref() { ++refs; }
|
||||||
|
virtual void unref()
|
||||||
|
{
|
||||||
|
if(--refs == 0)
|
||||||
|
delete this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public:
|
||||||
|
OgreFile(const Ogre::DataStreamPtr &stream)
|
||||||
|
: mStream(stream), refs(1)
|
||||||
|
{ }
|
||||||
|
virtual ~OgreFile() { }
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
void Audiere_Decoder::open(const std::string &fname)
|
||||||
|
{
|
||||||
|
close();
|
||||||
|
|
||||||
|
audiere::FilePtr file(new OgreFile(mResourceMgr.openResource(fname)));
|
||||||
|
mSoundSource = audiere::OpenSampleSource(file);
|
||||||
|
|
||||||
|
int channels, srate;
|
||||||
|
audiere::SampleFormat format;
|
||||||
|
|
||||||
|
mSoundSource->getFormat(channels, srate, format);
|
||||||
|
if(format == audiere::SF_S16)
|
||||||
|
mSampleType = SampleType_Int16;
|
||||||
|
else if(format == audiere::SF_U8)
|
||||||
|
mSampleType = SampleType_UInt8;
|
||||||
|
else
|
||||||
|
fail("Unsupported sample type");
|
||||||
|
|
||||||
|
if(channels == 1)
|
||||||
|
mChannelConfig = ChannelConfig_Mono;
|
||||||
|
else if(channels == 2)
|
||||||
|
mChannelConfig = ChannelConfig_Stereo;
|
||||||
|
else
|
||||||
|
fail("Unsupported channel count");
|
||||||
|
|
||||||
|
mSampleRate = srate;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Audiere_Decoder::close()
|
||||||
|
{
|
||||||
|
mSoundSource = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Audiere_Decoder::getInfo(int *samplerate, ChannelConfig *chans, SampleType *type)
|
||||||
|
{
|
||||||
|
*samplerate = mSampleRate;
|
||||||
|
*chans = mChannelConfig;
|
||||||
|
*type = mSampleType;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t Audiere_Decoder::read(char *buffer, size_t bytes)
|
||||||
|
{
|
||||||
|
int size = bytesToFrames(bytes, mChannelConfig, mSampleType);
|
||||||
|
size = mSoundSource->read(size, buffer);
|
||||||
|
return framesToBytes(size, mChannelConfig, mSampleType);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Audiere_Decoder::rewind()
|
||||||
|
{
|
||||||
|
mSoundSource->reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
Audiere_Decoder::Audiere_Decoder()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
Audiere_Decoder::~Audiere_Decoder()
|
||||||
|
{
|
||||||
|
close();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
@ -0,0 +1,42 @@
|
|||||||
|
#ifndef GAME_SOUND_AUDIERE_DECODER_H
|
||||||
|
#define GAME_SOUND_AUDIERE_DECODER_H
|
||||||
|
|
||||||
|
#include <OgreDataStream.h>
|
||||||
|
|
||||||
|
#include "audiere.h"
|
||||||
|
|
||||||
|
#include "sound_decoder.hpp"
|
||||||
|
|
||||||
|
|
||||||
|
namespace MWSound
|
||||||
|
{
|
||||||
|
class Audiere_Decoder : public Sound_Decoder
|
||||||
|
{
|
||||||
|
audiere::SampleSourcePtr mSoundSource;
|
||||||
|
int mSampleRate;
|
||||||
|
SampleType mSampleType;
|
||||||
|
ChannelConfig mChannelConfig;
|
||||||
|
|
||||||
|
virtual void open(const std::string &fname);
|
||||||
|
virtual void close();
|
||||||
|
|
||||||
|
virtual void getInfo(int *samplerate, ChannelConfig *chans, SampleType *type);
|
||||||
|
|
||||||
|
virtual size_t read(char *buffer, size_t bytes);
|
||||||
|
virtual void rewind();
|
||||||
|
|
||||||
|
Audiere_Decoder& operator=(const Audiere_Decoder &rhs);
|
||||||
|
Audiere_Decoder(const Audiere_Decoder &rhs);
|
||||||
|
|
||||||
|
Audiere_Decoder();
|
||||||
|
public:
|
||||||
|
virtual ~Audiere_Decoder();
|
||||||
|
|
||||||
|
friend class SoundManager;
|
||||||
|
};
|
||||||
|
#ifndef DEFAULT_DECODER
|
||||||
|
#define DEFAULT_DECODER (::MWSound::Audiere_Decoder)
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
@ -0,0 +1,158 @@
|
|||||||
|
#include "settings.hpp"
|
||||||
|
|
||||||
|
#include <fstream>
|
||||||
|
|
||||||
|
#include <OgreResourceGroupManager.h>
|
||||||
|
#include <OgreStringConverter.h>
|
||||||
|
|
||||||
|
using namespace Settings;
|
||||||
|
|
||||||
|
Ogre::ConfigFile Manager::mFile = Ogre::ConfigFile();
|
||||||
|
Ogre::ConfigFile Manager::mDefaultFile = Ogre::ConfigFile();
|
||||||
|
CategorySettingVector Manager::mChangedSettings = CategorySettingVector();
|
||||||
|
CategorySettingValueMap Manager::mNewSettings = CategorySettingValueMap();
|
||||||
|
|
||||||
|
void Manager::loadUser (const std::string& file)
|
||||||
|
{
|
||||||
|
mFile.load(file);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Manager::loadDefault (const std::string& file)
|
||||||
|
{
|
||||||
|
mDefaultFile.load(file);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Manager::saveUser(const std::string& file)
|
||||||
|
{
|
||||||
|
std::fstream fout(file.c_str(), std::ios::out);
|
||||||
|
|
||||||
|
Ogre::ConfigFile::SectionIterator seci = mFile.getSectionIterator();
|
||||||
|
|
||||||
|
while (seci.hasMoreElements())
|
||||||
|
{
|
||||||
|
Ogre::String sectionName = seci.peekNextKey();
|
||||||
|
|
||||||
|
if (sectionName.length() > 0)
|
||||||
|
fout << '\n' << '[' << seci.peekNextKey() << ']' << '\n';
|
||||||
|
|
||||||
|
Ogre::ConfigFile::SettingsMultiMap *settings = seci.getNext();
|
||||||
|
Ogre::ConfigFile::SettingsMultiMap::iterator i;
|
||||||
|
for (i = settings->begin(); i != settings->end(); ++i)
|
||||||
|
{
|
||||||
|
fout << i->first.c_str() << " = " << i->second.c_str() << '\n';
|
||||||
|
}
|
||||||
|
|
||||||
|
CategorySettingValueMap::iterator it = mNewSettings.begin();
|
||||||
|
while (it != mNewSettings.end())
|
||||||
|
{
|
||||||
|
if (it->first.first == sectionName)
|
||||||
|
{
|
||||||
|
fout << it->first.second << " = " << it->second << '\n';
|
||||||
|
mNewSettings.erase(it++);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
++it;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string category = "";
|
||||||
|
for (CategorySettingValueMap::iterator it = mNewSettings.begin();
|
||||||
|
it != mNewSettings.end(); ++it)
|
||||||
|
{
|
||||||
|
if (category != it->first.first)
|
||||||
|
{
|
||||||
|
category = it->first.first;
|
||||||
|
fout << '\n' << '[' << category << ']' << '\n';
|
||||||
|
}
|
||||||
|
fout << it->first.second << " = " << it->second << '\n';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::string Manager::getString (const std::string& setting, const std::string& category)
|
||||||
|
{
|
||||||
|
if (mNewSettings.find(std::make_pair(category, setting)) != mNewSettings.end())
|
||||||
|
return mNewSettings[std::make_pair(category, setting)];
|
||||||
|
|
||||||
|
std::string defaultval = mDefaultFile.getSetting(setting, category);
|
||||||
|
return mFile.getSetting(setting, category, defaultval);
|
||||||
|
}
|
||||||
|
|
||||||
|
const float Manager::getFloat (const std::string& setting, const std::string& category)
|
||||||
|
{
|
||||||
|
return Ogre::StringConverter::parseReal( getString(setting, category) );
|
||||||
|
}
|
||||||
|
|
||||||
|
const int Manager::getInt (const std::string& setting, const std::string& category)
|
||||||
|
{
|
||||||
|
return Ogre::StringConverter::parseInt( getString(setting, category) );
|
||||||
|
}
|
||||||
|
|
||||||
|
const bool Manager::getBool (const std::string& setting, const std::string& category)
|
||||||
|
{
|
||||||
|
return Ogre::StringConverter::parseBool( getString(setting, category) );
|
||||||
|
}
|
||||||
|
|
||||||
|
void Manager::setString (const std::string& setting, const std::string& category, const std::string& value)
|
||||||
|
{
|
||||||
|
CategorySetting s = std::make_pair(category, setting);
|
||||||
|
|
||||||
|
bool found=false;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Ogre::ConfigFile::SettingsIterator it = mFile.getSettingsIterator(category);
|
||||||
|
while (it.hasMoreElements())
|
||||||
|
{
|
||||||
|
Ogre::ConfigFile::SettingsMultiMap::iterator i = it.current();
|
||||||
|
|
||||||
|
if ((*i).first == setting)
|
||||||
|
{
|
||||||
|
if ((*i).second != value)
|
||||||
|
{
|
||||||
|
mChangedSettings.push_back(std::make_pair(category, setting));
|
||||||
|
(*i).second = value;
|
||||||
|
}
|
||||||
|
found = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
it.getNext();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Ogre::Exception&)
|
||||||
|
{}
|
||||||
|
|
||||||
|
if (!found)
|
||||||
|
{
|
||||||
|
if (mNewSettings.find(s) != mNewSettings.end())
|
||||||
|
{
|
||||||
|
if (mNewSettings[s] != value)
|
||||||
|
{
|
||||||
|
mChangedSettings.push_back(std::make_pair(category, setting));
|
||||||
|
mNewSettings[s] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
mNewSettings[s] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Manager::setInt (const std::string& setting, const std::string& category, const int value)
|
||||||
|
{
|
||||||
|
setString(setting, category, Ogre::StringConverter::toString(value));
|
||||||
|
}
|
||||||
|
|
||||||
|
void Manager::setFloat (const std::string& setting, const std::string& category, const float value)
|
||||||
|
{
|
||||||
|
setString(setting, category, Ogre::StringConverter::toString(value));
|
||||||
|
}
|
||||||
|
|
||||||
|
void Manager::setBool (const std::string& setting, const std::string& category, const bool value)
|
||||||
|
{
|
||||||
|
setString(setting, category, Ogre::StringConverter::toString(value));
|
||||||
|
}
|
||||||
|
|
||||||
|
const CategorySettingVector Manager::apply()
|
||||||
|
{
|
||||||
|
CategorySettingVector vec = mChangedSettings;
|
||||||
|
mChangedSettings.clear();
|
||||||
|
return vec;
|
||||||
|
}
|
@ -0,0 +1,52 @@
|
|||||||
|
#ifndef _COMPONENTS_SETTINGS_H
|
||||||
|
#define _COMPONENTS_SETTINGS_H
|
||||||
|
|
||||||
|
#include <OgreConfigFile.h>
|
||||||
|
|
||||||
|
namespace Settings
|
||||||
|
{
|
||||||
|
typedef std::pair < std::string, std::string > CategorySetting;
|
||||||
|
typedef std::vector< std::pair<std::string, std::string> > CategorySettingVector;
|
||||||
|
typedef std::map < CategorySetting, std::string > CategorySettingValueMap;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// \brief Settings management (can change during runtime)
|
||||||
|
///
|
||||||
|
class Manager
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static Ogre::ConfigFile mFile;
|
||||||
|
static Ogre::ConfigFile mDefaultFile;
|
||||||
|
|
||||||
|
static CategorySettingVector mChangedSettings;
|
||||||
|
///< tracks all the settings that were changed since the last apply() call
|
||||||
|
|
||||||
|
static CategorySettingValueMap mNewSettings;
|
||||||
|
///< tracks all the settings that are in the default file, but not in user file yet
|
||||||
|
|
||||||
|
void loadDefault (const std::string& file);
|
||||||
|
///< load file as the default settings (can be overridden by user settings)
|
||||||
|
|
||||||
|
void loadUser (const std::string& file);
|
||||||
|
///< load file as user settings
|
||||||
|
|
||||||
|
void saveUser (const std::string& file);
|
||||||
|
///< save user settings to file
|
||||||
|
|
||||||
|
static const CategorySettingVector apply();
|
||||||
|
///< returns the list of changed settings and then clears it
|
||||||
|
|
||||||
|
static const int getInt (const std::string& setting, const std::string& category);
|
||||||
|
static const float getFloat (const std::string& setting, const std::string& category);
|
||||||
|
static const std::string getString (const std::string& setting, const std::string& category);
|
||||||
|
static const bool getBool (const std::string& setting, const std::string& category);
|
||||||
|
|
||||||
|
static void setInt (const std::string& setting, const std::string& category, const int value);
|
||||||
|
static void setFloat (const std::string& setting, const std::string& category, const float value);
|
||||||
|
static void setString (const std::string& setting, const std::string& category, const std::string& value);
|
||||||
|
static void setBool (const std::string& setting, const std::string& category, const bool value);
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // _COMPONENTS_SETTINGS_H
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,55 @@
|
|||||||
|
[General]
|
||||||
|
# Camera field of view
|
||||||
|
field of view = 55
|
||||||
|
|
||||||
|
# Texture filtering mode. valid values:
|
||||||
|
# anisotropic
|
||||||
|
# bilinear
|
||||||
|
# trilinear
|
||||||
|
texture filtering = anisotropic
|
||||||
|
|
||||||
|
# Has no effect when texture filtering is not anisotropic
|
||||||
|
anisotropy = 4
|
||||||
|
|
||||||
|
# Number of texture mipmaps to generate
|
||||||
|
num mipmaps = 5
|
||||||
|
|
||||||
|
[HUD]
|
||||||
|
# FPS counter
|
||||||
|
# 0: not visible
|
||||||
|
# 1: basic FPS display
|
||||||
|
# 2: advanced FPS display (batches, triangles)
|
||||||
|
fps = 0
|
||||||
|
|
||||||
|
[Objects]
|
||||||
|
shaders = true
|
||||||
|
|
||||||
|
# Max. number of lights that affect objects. Setting to 1 will only reflect sunlight
|
||||||
|
# Note: has no effect when shaders are turned off
|
||||||
|
num lights = 8
|
||||||
|
|
||||||
|
# Use static geometry for static objects. Improves rendering speed.
|
||||||
|
use static geometry = true
|
||||||
|
|
||||||
|
[Viewing distance]
|
||||||
|
# Limit the rendering distance of small objects
|
||||||
|
limit small object distance = false
|
||||||
|
|
||||||
|
# Size below which an object is considered as small
|
||||||
|
small object size = 250
|
||||||
|
|
||||||
|
# Rendering distance for small objects
|
||||||
|
small object distance = 3500
|
||||||
|
|
||||||
|
# Max viewing distance at clear weather conditions
|
||||||
|
max viewing distance = 5600
|
||||||
|
|
||||||
|
# Distance at which fog starts (proportional to viewing distance)
|
||||||
|
fog start factor = 0.5
|
||||||
|
|
||||||
|
# Distance at which fog ends (proportional to viewing distance)
|
||||||
|
fog end factor = 1.0
|
||||||
|
|
||||||
|
[Terrain]
|
||||||
|
# Max. number of lights that affect the terrain. Setting to 1 will only reflect sunlight
|
||||||
|
num lights = 8
|
Loading…
Reference in New Issue