1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-16 17:59:56 +00:00

handle name change during character creation

This commit is contained in:
Marc Zinnschlag 2010-09-15 12:22:06 +02:00
parent edb2df7d27
commit 9dffa75a15
7 changed files with 46 additions and 20 deletions

View file

@ -256,8 +256,7 @@ void OMW::Engine::go()
*mScriptManager);
// Create game mechanics system
mEnvironment.mMechanicsManager = new MWMechanics::MechanicsManager (
mEnvironment.mWorld->getStore(), *mEnvironment.mWindowManager);
mEnvironment.mMechanicsManager = new MWMechanics::MechanicsManager (mEnvironment);
// Create dialog system
mEnvironment.mDialogueManager = new MWDialogue::DialogueManager (mEnvironment);

View file

@ -214,8 +214,6 @@ namespace MWGui
// These are just demo values, you should replace these with
// real calls from outside the class later.
setPlayerName("ThePlayer");
setText("LevelText", "5");
setText("RaceText", "Wood Elf");
setText("ClassText", "Pilgrim");
@ -269,6 +267,12 @@ namespace MWGui
setBar (id, id + "T", value.getCurrent(), value.getModified());
}
}
void setValue (const std::string& id, const std::string& value)
{
if (id=="name")
setPlayerName (value);
}
};
class InventoryWindow : public OEngine::GUI::Layout

View file

@ -140,6 +140,11 @@ void WindowManager::setValue (const std::string& id, const MWMechanics::DynamicS
hud->setValue (id, value);
}
void WindowManager::setValue (const std::string& id, const std::string& value)
{
stats->setValue (id, value);
}
void WindowManager::messageBox (const std::string& message, const std::vector<std::string>& buttons)
{
std::cout << "message box: " << message << std::endl;

View file

@ -164,6 +164,9 @@ namespace MWGui
void setValue (const std::string& id, const MWMechanics::DynamicStat<int>& value);
///< Set value for the given ID.
void setValue (const std::string& id, const std::string& value);
///< set value for the given ID.
void messageBox (const std::string& message, const std::vector<std::string>& buttons);
private:

View file

@ -6,12 +6,13 @@
#include "../mwgui/window_manager.hpp"
#include "../mwworld/class.hpp"
#include "../mwworld/environment.hpp"
#include "../mwworld/world.hpp"
namespace MWMechanics
{
MechanicsManager::MechanicsManager (const ESMS::ESMStore& store,
MWGui::WindowManager& windowManager)
: mStore (store), mWindowManager (windowManager)
MechanicsManager::MechanicsManager (MWWorld::Environment& environment)
: mEnvironment (environment), mSetName (true)
{
}
@ -68,7 +69,7 @@ namespace MWMechanics
{
mWatchedCreature.mAttributes[i] = stats.mAttributes[i];
mWindowManager.setValue (attributeNames[i], stats.mAttributes[i]);
mEnvironment.mWindowManager->setValue (attributeNames[i], stats.mAttributes[i]);
}
}
@ -78,15 +79,22 @@ namespace MWMechanics
{
mWatchedCreature.mDynamic[i] = stats.mDynamic[i];
mWindowManager.setValue (dynamicNames[i], stats.mDynamic[i]);
mEnvironment.mWindowManager->setValue (dynamicNames[i], stats.mDynamic[i]);
}
}
}
if (mSetName)
{
mEnvironment.mWindowManager->setValue ("name", mEnvironment.mWorld->getPlayerPos().getName());
mSetName = false;
}
}
void MechanicsManager::setPlayerName (const std::string& name)
{
mEnvironment.mWorld->getPlayerPos().setName (name);
mSetName = true;
}
void MechanicsManager::setPlayerRace (const std::string& race, bool male)

View file

@ -7,29 +7,24 @@
#include "creaturestats.hpp"
namespace ESMS
namespace MWWorld
{
struct ESMStore;
}
namespace MWGui
{
class WindowManager;
class Environment;
}
namespace MWMechanics
{
class MechanicsManager
{
const ESMS::ESMStore& mStore;
MWGui::WindowManager& mWindowManager;
MWWorld::Environment& mEnvironment;
std::set<MWWorld::Ptr> mActors;
MWWorld::Ptr mWatched;
CreatureStats mWatchedCreature;
bool mSetName;
public:
MechanicsManager (const ESMS::ESMStore& store, MWGui::WindowManager& windowManager);
MechanicsManager (MWWorld::Environment& environment);
void configureGUI();

View file

@ -24,12 +24,14 @@ namespace MWRender
MWWorld::Ptr::CellStore *mCellStore;
Ogre::Camera *camera;
MWWorld::World& mWorld;
std::string mName;
public:
PlayerPos(Ogre::Camera *cam, const ESM::NPC *player, MWWorld::World& world) :
mCellStore (0), camera(cam), mWorld (world)
{
mPlayer.base = player;
mName = player->name;
mPlayer.ref.pos.pos[0] = mPlayer.ref.pos.pos[1] = mPlayer.ref.pos.pos[2] = 0;
}
@ -73,6 +75,16 @@ namespace MWRender
MWWorld::Ptr ptr (&mPlayer, mCellStore);
return ptr;
}
void setName (const std::string& name)
{
mName = name;
}
std::string getName() const
{
return mName;
}
};
}
#endif