Merge branch 'master' of https://github.com/zinnschlag/openmw.git into Factions2
Conflicts: apps/openmw/mwscript/docs/vmformat.txt apps/openmw/mwworld/player.cpp apps/openmw/mwworld/player.hppactorid
commit
0553227ee1
@ -0,0 +1,106 @@
|
||||
#include "map_window.hpp"
|
||||
#include "window_manager.hpp"
|
||||
/*
|
||||
#include "../mwmechanics/mechanicsmanager.hpp"
|
||||
|
||||
#include <cmath>
|
||||
#include <algorithm>
|
||||
#include <iterator>
|
||||
|
||||
#undef min
|
||||
#undef max
|
||||
*/
|
||||
using namespace MWGui;
|
||||
|
||||
MapWindow::MapWindow(WindowManager& parWindowManager) :
|
||||
MWGui::WindowPinnableBase("openmw_map_window_layout.xml", parWindowManager),
|
||||
mGlobal(false)
|
||||
{
|
||||
setCoord(500,0,320,300);
|
||||
setText("WorldButton", "World");
|
||||
setImage("Compass", "textures\\compass.dds");
|
||||
|
||||
// Obviously you should override this later on
|
||||
setCellName("No Cell Loaded");
|
||||
|
||||
getWidget(mLocalMap, "LocalMap");
|
||||
getWidget(mGlobalMap, "GlobalMap");
|
||||
getWidget(mPlayerArrow, "Compass");
|
||||
|
||||
getWidget(mButton, "WorldButton");
|
||||
mButton->eventMouseButtonClick += MyGUI::newDelegate(this, &MapWindow::onWorldButtonClicked);
|
||||
|
||||
MyGUI::Button* eventbox;
|
||||
getWidget(eventbox, "EventBox");
|
||||
eventbox->eventMouseDrag += MyGUI::newDelegate(this, &MapWindow::onMouseDrag);
|
||||
eventbox->eventMouseButtonPressed += MyGUI::newDelegate(this, &MapWindow::onDragStart);
|
||||
|
||||
LocalMapBase::init(mLocalMap, this);
|
||||
}
|
||||
|
||||
void MapWindow::setCellName(const std::string& cellName)
|
||||
{
|
||||
static_cast<MyGUI::Window*>(mMainWidget)->setCaption(cellName);
|
||||
adjustWindowCaption();
|
||||
}
|
||||
|
||||
void MapWindow::setPlayerPos(const float x, const float y)
|
||||
{
|
||||
if (mGlobal || !mVisible || (x == mLastPositionX && y == mLastPositionY)) return;
|
||||
MyGUI::IntSize size = mLocalMap->getCanvasSize();
|
||||
MyGUI::IntPoint middle = MyGUI::IntPoint((1/3.f + x/3.f)*size.width,(1/3.f + y/3.f)*size.height);
|
||||
MyGUI::IntCoord viewsize = mLocalMap->getCoord();
|
||||
MyGUI::IntPoint pos(0.5*viewsize.width - middle.left, 0.5*viewsize.height - middle.top);
|
||||
mLocalMap->setViewOffset(pos);
|
||||
|
||||
mPlayerArrow->setPosition(MyGUI::IntPoint(x*512-16, y*512-16));
|
||||
mLastPositionX = x;
|
||||
mLastPositionY = y;
|
||||
}
|
||||
|
||||
void MapWindow::setPlayerDir(const float x, const float y)
|
||||
{
|
||||
if (!mVisible || (x == mLastDirectionX && y == mLastDirectionY)) return;
|
||||
MyGUI::ISubWidget* main = mPlayerArrow->getSubWidgetMain();
|
||||
MyGUI::RotatingSkin* rotatingSubskin = main->castType<MyGUI::RotatingSkin>();
|
||||
rotatingSubskin->setCenter(MyGUI::IntPoint(16,16));
|
||||
float angle = std::atan2(x,y);
|
||||
rotatingSubskin->setAngle(angle);
|
||||
|
||||
mLastDirectionX = x;
|
||||
mLastDirectionY = y;
|
||||
}
|
||||
|
||||
void MapWindow::onDragStart(MyGUI::Widget* _sender, int _left, int _top, MyGUI::MouseButton _id)
|
||||
{
|
||||
if (_id!=MyGUI::MouseButton::Left) return;
|
||||
if (!mGlobal)
|
||||
mLastDragPos = MyGUI::IntPoint(_left, _top);
|
||||
}
|
||||
|
||||
void MapWindow::onMouseDrag(MyGUI::Widget* _sender, int _left, int _top, MyGUI::MouseButton _id)
|
||||
{
|
||||
if (_id!=MyGUI::MouseButton::Left) return;
|
||||
|
||||
if (!mGlobal)
|
||||
{
|
||||
MyGUI::IntPoint diff = MyGUI::IntPoint(_left, _top) - mLastDragPos;
|
||||
mLocalMap->setViewOffset( mLocalMap->getViewOffset() + diff );
|
||||
|
||||
mLastDragPos = MyGUI::IntPoint(_left, _top);
|
||||
}
|
||||
}
|
||||
|
||||
void MapWindow::onWorldButtonClicked(MyGUI::Widget* _sender)
|
||||
{
|
||||
mGlobal = !mGlobal;
|
||||
mGlobalMap->setVisible(mGlobal);
|
||||
mLocalMap->setVisible(!mGlobal);
|
||||
|
||||
mButton->setCaption( mGlobal ? "Local" : "World" );
|
||||
}
|
||||
|
||||
void MapWindow::onPinToggled()
|
||||
{
|
||||
mWindowManager.setMinimapVisibility(!mPinned);
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
#ifndef MWGUI_MAPWINDOW_H
|
||||
#define MWGUI_MAPWINDOW_H
|
||||
|
||||
#include "layouts.hpp"
|
||||
#include "window_pinnable_base.hpp"
|
||||
|
||||
namespace MWGui
|
||||
{
|
||||
class MapWindow : public MWGui::WindowPinnableBase, public LocalMapBase
|
||||
{
|
||||
public:
|
||||
MapWindow(WindowManager& parWindowManager);
|
||||
virtual ~MapWindow(){}
|
||||
|
||||
void setPlayerPos(const float x, const float y);
|
||||
void setPlayerDir(const float x, const float y);
|
||||
void setCellName(const std::string& cellName);
|
||||
|
||||
private:
|
||||
void onDragStart(MyGUI::Widget* _sender, int _left, int _top, MyGUI::MouseButton _id);
|
||||
void onMouseDrag(MyGUI::Widget* _sender, int _left, int _top, MyGUI::MouseButton _id);
|
||||
void onWorldButtonClicked(MyGUI::Widget* _sender);
|
||||
|
||||
MyGUI::ScrollView* mGlobalMap;
|
||||
MyGUI::ImageBox* mPlayerArrow;
|
||||
MyGUI::Button* mButton;
|
||||
MyGUI::IntPoint mLastDragPos;
|
||||
bool mGlobal;
|
||||
|
||||
protected:
|
||||
virtual void onPinToggled();
|
||||
};
|
||||
}
|
||||
#endif
|
@ -0,0 +1,33 @@
|
||||
#include "window_pinnable_base.hpp"
|
||||
#include "window_manager.hpp"
|
||||
|
||||
using namespace MWGui;
|
||||
|
||||
WindowPinnableBase::WindowPinnableBase(const std::string& parLayout, WindowManager& parWindowManager)
|
||||
: WindowBase(parLayout, parWindowManager), mPinned(false), mVisible(false)
|
||||
{
|
||||
MyGUI::WindowPtr t = static_cast<MyGUI::WindowPtr>(mMainWidget);
|
||||
t->eventWindowButtonPressed += MyGUI::newDelegate(this, &WindowPinnableBase::onWindowButtonPressed);
|
||||
}
|
||||
|
||||
void WindowPinnableBase::setVisible(bool b)
|
||||
{
|
||||
// Pinned windows can not be hidden
|
||||
if (mPinned && !b)
|
||||
return;
|
||||
|
||||
WindowBase::setVisible(b);
|
||||
mVisible = b;
|
||||
}
|
||||
|
||||
void WindowPinnableBase::onWindowButtonPressed(MyGUI::Window* sender, const std::string& eventName)
|
||||
{
|
||||
if ("PinToggle" == eventName)
|
||||
{
|
||||
mPinned = !mPinned;
|
||||
onPinToggled();
|
||||
}
|
||||
|
||||
eventDone(this);
|
||||
}
|
||||
|
@ -0,0 +1,28 @@
|
||||
#ifndef MWGUI_WINDOW_PINNABLE_BASE_H
|
||||
#define MWGUI_WINDOW_PINNABLE_BASE_H
|
||||
|
||||
#include "window_base.hpp"
|
||||
|
||||
namespace MWGui
|
||||
{
|
||||
class WindowManager;
|
||||
|
||||
class WindowPinnableBase: public WindowBase
|
||||
{
|
||||
public:
|
||||
WindowPinnableBase(const std::string& parLayout, WindowManager& parWindowManager);
|
||||
void setVisible(bool b);
|
||||
|
||||
private:
|
||||
void onWindowButtonPressed(MyGUI::Window* sender, const std::string& eventName);
|
||||
|
||||
protected:
|
||||
virtual void onPinToggled() = 0;
|
||||
|
||||
bool mPinned;
|
||||
bool mVisible;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -0,0 +1,77 @@
|
||||
|
||||
#include "actors.hpp"
|
||||
|
||||
#include <typeinfo>
|
||||
|
||||
#include <components/esm/loadnpc.hpp>
|
||||
|
||||
#include "../mwworld/class.hpp"
|
||||
#include "../mwworld/inventorystore.hpp"
|
||||
|
||||
namespace MWMechanics
|
||||
{
|
||||
void Actors::updateActor (const MWWorld::Ptr& ptr, float duration)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Actors::updateNpc (const MWWorld::Ptr& ptr, float duration, bool paused)
|
||||
{
|
||||
if (!paused && ptr.getRefData().getHandle()!="player")
|
||||
MWWorld::Class::get (ptr).getInventoryStore (ptr).autoEquip (
|
||||
MWWorld::Class::get (ptr).getNpcStats (ptr), mEnvironment);
|
||||
}
|
||||
|
||||
Actors::Actors (MWWorld::Environment& environment) : mEnvironment (environment), mDuration (0) {}
|
||||
|
||||
void Actors::addActor (const MWWorld::Ptr& ptr)
|
||||
{
|
||||
mActors.insert (ptr);
|
||||
}
|
||||
|
||||
void Actors::removeActor (const MWWorld::Ptr& ptr)
|
||||
{
|
||||
mActors.erase (ptr);
|
||||
}
|
||||
|
||||
void Actors::dropActors (const MWWorld::Ptr::CellStore *cellStore)
|
||||
{
|
||||
std::set<MWWorld::Ptr>::iterator iter = mActors.begin();
|
||||
|
||||
while (iter!=mActors.end())
|
||||
if (iter->getCell()==cellStore)
|
||||
{
|
||||
mActors.erase (iter++);
|
||||
}
|
||||
else
|
||||
++iter;
|
||||
}
|
||||
|
||||
void Actors::update (std::vector<std::pair<std::string, Ogre::Vector3> >& movement, float duration,
|
||||
bool paused)
|
||||
{
|
||||
mDuration += duration;
|
||||
|
||||
if (mDuration>=0.25)
|
||||
{
|
||||
for (std::set<MWWorld::Ptr>::iterator iter (mActors.begin()); iter!=mActors.end(); ++iter)
|
||||
{
|
||||
updateActor (*iter, mDuration);
|
||||
|
||||
if (iter->getTypeName()==typeid (ESM::NPC).name())
|
||||
updateNpc (*iter, mDuration, paused);
|
||||
}
|
||||
|
||||
mDuration = 0;
|
||||
}
|
||||
|
||||
for (std::set<MWWorld::Ptr>::iterator iter (mActors.begin()); iter!=mActors.end();
|
||||
++iter)
|
||||
{
|
||||
Ogre::Vector3 vector = MWWorld::Class::get (*iter).getMovementVector (*iter);
|
||||
|
||||
if (vector!=Ogre::Vector3::ZERO)
|
||||
movement.push_back (std::make_pair (iter->getRefData().getHandle(), vector));
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
#ifndef GAME_MWMECHANICS_ACTORS_H
|
||||
#define GAME_MWMECHANICS_ACTORS_H
|
||||
|
||||
#include <set>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
#include "../mwworld/ptr.hpp"
|
||||
|
||||
namespace Ogre
|
||||
{
|
||||
class Vector3;
|
||||
}
|
||||
|
||||
namespace MWWorld
|
||||
{
|
||||
class Environment;
|
||||
}
|
||||
|
||||
namespace MWMechanics
|
||||
{
|
||||
class Actors
|
||||
{
|
||||
MWWorld::Environment& mEnvironment;
|
||||
std::set<MWWorld::Ptr> mActors;
|
||||
float mDuration;
|
||||
|
||||
void updateActor (const MWWorld::Ptr& ptr, float duration);
|
||||
|
||||
void updateNpc (const MWWorld::Ptr& ptr, float duration, bool paused);
|
||||
|
||||
public:
|
||||
|
||||
Actors (MWWorld::Environment& environment);
|
||||
|
||||
void addActor (const MWWorld::Ptr& ptr);
|
||||
///< Register an actor for stats management
|
||||
|
||||
void removeActor (const MWWorld::Ptr& ptr);
|
||||
///< Deregister an actor for stats management
|
||||
|
||||
void dropActors (const MWWorld::Ptr::CellStore *cellStore);
|
||||
///< Deregister all actors in the given cell.
|
||||
|
||||
void update (std::vector<std::pair<std::string, Ogre::Vector3> >& movement,
|
||||
float duration, bool paused);
|
||||
///< Update actor stats and store desired velocity vectors in \a movement
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
@ -0,0 +1,11 @@
|
||||
#ifndef GAME_MWMECHANICS_DRAWSTATE_H
|
||||
#define GAME_MWMECHANICS_DRAWSTATE_H
|
||||
|
||||
enum DrawState
|
||||
{
|
||||
DrawState_Weapon = 0,
|
||||
DrawState_Spell = 1,
|
||||
DrawState_Nothing = 2,
|
||||
};
|
||||
|
||||
#endif
|
@ -0,0 +1,62 @@
|
||||
#ifndef GAME_RENDER_CONST_H
|
||||
#define GAME_RENDER_CONST_H
|
||||
|
||||
#include <OgreRenderQueue.h>
|
||||
|
||||
namespace MWRender
|
||||
{
|
||||
|
||||
// Render queue groups
|
||||
enum RenderQueueGroups
|
||||
{
|
||||
// Sky early (atmosphere, clouds, moons)
|
||||
RQG_SkiesEarly = Ogre::RENDER_QUEUE_SKIES_EARLY,
|
||||
|
||||
RQG_Main = Ogre::RENDER_QUEUE_MAIN,
|
||||
|
||||
RQG_Water = Ogre::RENDER_QUEUE_7+1,
|
||||
|
||||
RQG_Alpha = Ogre::RENDER_QUEUE_MAIN,
|
||||
|
||||
RQG_UnderWater = Ogre::RENDER_QUEUE_7+1,
|
||||
|
||||
RQG_OcclusionQuery = Ogre::RENDER_QUEUE_8,
|
||||
|
||||
// Sky late (sun & sun flare)
|
||||
RQG_SkiesLate = Ogre::RENDER_QUEUE_SKIES_LATE
|
||||
};
|
||||
|
||||
// Visibility flags
|
||||
enum VisibilityFlags
|
||||
{
|
||||
// Terrain
|
||||
RV_Terrain = 1,
|
||||
|
||||
// Statics (e.g. trees, houses)
|
||||
RV_Statics = 2,
|
||||
|
||||
// Small statics
|
||||
RV_StaticsSmall = 4,
|
||||
|
||||
// Water
|
||||
RV_Water = 8,
|
||||
|
||||
// Actors (player, npcs, creatures)
|
||||
RV_Actors = 16,
|
||||
|
||||
// Misc objects (containers, dynamic objects)
|
||||
RV_Misc = 32,
|
||||
|
||||
RV_Sky = 64,
|
||||
|
||||
// Sun glare (not visible in reflection)
|
||||
RV_Glare = 128,
|
||||
|
||||
RV_Map = RV_Terrain + RV_Statics + RV_StaticsSmall + RV_Misc + RV_Water,
|
||||
|
||||
/// \todo markers (normally hidden)
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
@ -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;
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue