read attribute names from GMST instead of using hard-coded names (doesn't fully work yet, because of encoding issues)

actorid
Marc Zinnschlag 15 years ago
parent 532ccbd1f8
commit 61d09c4768

@ -87,10 +87,18 @@ set(GAMEWORLD_HEADER
)
source_group(apps\\openmw\\mwworld FILES ${GAMEWORLD} ${GAMEWORLD_HEADER})
set(GAMEMECHANICS
mwmechanics/mechanicsmanager.cpp)
set(GAMEMECHANICS_HEADER
mwmechanics/mechanicsmanager.hpp)
source_group(apps\\openmw\\mwmechanics FILES ${GAMEMECHANICS} ${GAMEMECHANICS_HEADER})
set(OPENMW_CPP ${GAME} ${GAMEREND} ${GAMEINPUT} ${GAMESCRIPT} ${GAMESOUND} ${GAMEGUI} ${GAMEWORLD})
set(OPENMW_CPP ${GAME} ${GAMEREND} ${GAMEINPUT} ${GAMESCRIPT} ${GAMESOUND} ${GAMEGUI} ${GAMEWORLD}
${GAMEMECHANICS}
)
set(OPENMW_HEADER ${GAME_HEADER} ${GAMEREND_HEADER} ${GAMEINPUT_HEADER} ${GAMESCRIPT_HEADER}
${GAMESOUND_HEADER} ${GAMEGUI_HEADER} ${GAMEWORLD_HEADER})
${GAMESOUND_HEADER} ${GAMEGUI_HEADER} ${GAMEWORLD_HEADER} ${GAMEMECHANICS_HEADER}
)
# Main executable
add_executable(openmw

@ -24,6 +24,8 @@
#include "mwworld/ptr.hpp"
#include "mwworld/environment.hpp"
#include "mwmechanics/mechanicsmanager.hpp"
#include <OgreRoot.h>
void OMW::Engine::executeLocalScripts()
@ -81,6 +83,7 @@ OMW::Engine::~Engine()
delete mEnvironment.mWorld;
delete mEnvironment.mSoundManager;
delete mEnvironment.mGlobalScripts;
delete mEnvironment.mMechanicsManager;
delete mScriptManager;
delete mScriptContext;
}
@ -196,8 +199,10 @@ void OMW::Engine::go()
mEnvironment.mWindowManager = new MWGui::WindowManager(mGuiManager->getGui(), mEnvironment,
mExtensions, mNewGame);
// Create sound system
mEnvironment.mSoundManager = new MWSound::SoundManager;
// Create script system
mScriptContext = new MWScript::CompilerContext (MWScript::CompilerContext::Type_Full,
mEnvironment);
mScriptContext->setExtensions (&mExtensions);
@ -207,6 +212,12 @@ void OMW::Engine::go()
mEnvironment.mGlobalScripts = new MWScript::GlobalScripts (mEnvironment.mWorld->getStore(),
*mScriptManager);
// Create game mechanics system
mEnvironment.mMechanicsManager = new MWMechanics::MechanicsManager (
mEnvironment.mWorld->getStore(), *mEnvironment.mWindowManager);
mEnvironment.mMechanicsManager->configureGUI();
// Sets up the input system
MWInput::MWInputManager input(mOgre, mEnvironment.mWorld->getPlayerPos(),

@ -161,15 +161,6 @@ namespace MWGui
setText("Race_str", "Race");
setText("Class_str", "Class");
setText("Attrib1", "Strength");
setText("Attrib2", "Intelligence");
setText("Attrib3", "Willpower");
setText("Attrib4", "Agility");
setText("Attrib5", "Speed");
setText("Attrib6", "Endurance");
setText("Attrib7", "Personality");
setText("Attrib8", "Luck");
// These are just demo values, you should replace these with
// real calls from outside the class later.
setPlayerName("ThePlayer");
@ -196,6 +187,24 @@ namespace MWGui
{
mMainWidget->setCaption(playerName);
}
/// Set label text for the value with the given ID.
void setLabel (const std::string& id, const std::string& label)
{
static const char *ids[] =
{
"Attrib1", "Attrib2", "Attrib3", "Attrib4", "Attrib5", "Attrib6",
"Attrib7", "Attrib8",
0
};
for (int i=0; ids[i]; ++i)
if (ids[i]==id)
{
setText (id, label);
break;
}
}
};
}
#endif

@ -84,3 +84,9 @@ void WindowManager::updateVisible()
// All other modes are ignored
}
void WindowManager::setLabel (const std::string& id, const std::string& label)
{
stats->setLabel (id, label);
}

@ -10,6 +10,8 @@
this class.
*/
#include <string>
namespace MyGUI
{
class Gui;
@ -134,6 +136,9 @@ namespace MWGui
}
MyGUI::Gui* getGui() const { return gui; }
void setLabel (const std::string& id, const std::string& label);
///< Set label text for the value with the given ID.
};
}
#endif

@ -0,0 +1,43 @@
#include "mechanicsmanager.hpp"
#include <components/esm_store/store.hpp>
#include "../mwgui/window_manager.hpp"
namespace MWMechanics
{
MechanicsManager::MechanicsManager (const ESMS::ESMStore& store,
MWGui::WindowManager& windowManager)
: mStore (store), mWindowManager (windowManager)
{
}
void MechanicsManager::configureGUI()
{
const char *names[][2] =
{
{ "Attrib1", "sAttributeStrength" },
{ "Attrib2", "sAttributeIntelligence" },
{ "Attrib3", "sAttributeWillpower" },
{ "Attrib4", "sAttributeAgility" },
{ "Attrib5", "sAttributeSpeed" },
{ "Attrib6", "sAttributeEndurance" },
{ "Attrib7", "sAttributePersonality" },
{ "Attrib8", "sAttributeLuck" },
{ 0, 0 }
};
for (int i=0; names[i][0]; ++i)
{
// This crashes because of encoding problems:
// std::string label = mStore.gameSettings.find (names[i][1])->str;
std::string label = names[i][1]; // until the problem is fixed, use the GMST ID as label
mWindowManager.setLabel (names[i][0], label);
}
}
}

@ -0,0 +1,30 @@
#ifndef GAME_MWMECHANICS_PTR_H
#define GAME_MWMECHANICS_PTR_H
namespace ESMS
{
class ESMStore;
}
namespace MWGui
{
class WindowManager;
}
namespace MWMechanics
{
class MechanicsManager
{
const ESMS::ESMStore& mStore;
MWGui::WindowManager& mWindowManager;
public:
MechanicsManager (const ESMS::ESMStore& store, MWGui::WindowManager& windowManager);
void configureGUI();
};
}
#endif

@ -16,6 +16,11 @@ namespace MWGui
class WindowManager;
}
namespace MWMechanics
{
class MechanicsManager;
}
namespace MWWorld
{
class World;
@ -25,13 +30,15 @@ namespace MWWorld
{
public:
Environment()
: mWorld (0), mSoundManager (0), mGlobalScripts (0), mWindowManager (0), mFrameDuration (0)
: mWorld (0), mSoundManager (0), mGlobalScripts (0), mWindowManager (0),
mMechanicsManager (0), mFrameDuration (0)
{}
World *mWorld;
MWSound::SoundManager *mSoundManager;
MWScript::GlobalScripts *mGlobalScripts;
MWGui::WindowManager *mWindowManager;
MWMechanics::MechanicsManager *mMechanicsManager;
float mFrameDuration;
};
}

@ -75,6 +75,15 @@ namespace ESMS
ref.load(esm);
}
// Find the given object ID, or return NULL if not found.
const X* find(const std::string &id) const
{
std::string id2 = toLower (id);
if(list.find(id2) == list.end())
return NULL;
return &list.find(id2)->second;
}
int getSize() { return list.size(); }
};

Loading…
Cancel
Save