mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-24 05:09:44 +00:00
read attribute names from GMST instead of using hard-coded names (doesn't fully work yet, because of encoding issues)
This commit is contained in:
parent
f3ee9ced5c
commit
2da51e5f5a
9 changed files with 140 additions and 12 deletions
|
@ -87,10 +87,18 @@ set(GAMEWORLD_HEADER
|
||||||
)
|
)
|
||||||
source_group(apps\\openmw\\mwworld FILES ${GAMEWORLD} ${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}
|
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
|
# Main executable
|
||||||
add_executable(openmw
|
add_executable(openmw
|
||||||
|
|
|
@ -24,6 +24,8 @@
|
||||||
#include "mwworld/ptr.hpp"
|
#include "mwworld/ptr.hpp"
|
||||||
#include "mwworld/environment.hpp"
|
#include "mwworld/environment.hpp"
|
||||||
|
|
||||||
|
#include "mwmechanics/mechanicsmanager.hpp"
|
||||||
|
|
||||||
#include <OgreRoot.h>
|
#include <OgreRoot.h>
|
||||||
|
|
||||||
void OMW::Engine::executeLocalScripts()
|
void OMW::Engine::executeLocalScripts()
|
||||||
|
@ -81,6 +83,7 @@ OMW::Engine::~Engine()
|
||||||
delete mEnvironment.mWorld;
|
delete mEnvironment.mWorld;
|
||||||
delete mEnvironment.mSoundManager;
|
delete mEnvironment.mSoundManager;
|
||||||
delete mEnvironment.mGlobalScripts;
|
delete mEnvironment.mGlobalScripts;
|
||||||
|
delete mEnvironment.mMechanicsManager;
|
||||||
delete mScriptManager;
|
delete mScriptManager;
|
||||||
delete mScriptContext;
|
delete mScriptContext;
|
||||||
}
|
}
|
||||||
|
@ -196,8 +199,10 @@ void OMW::Engine::go()
|
||||||
mEnvironment.mWindowManager = new MWGui::WindowManager(mGuiManager->getGui(), mEnvironment,
|
mEnvironment.mWindowManager = new MWGui::WindowManager(mGuiManager->getGui(), mEnvironment,
|
||||||
mExtensions, mNewGame);
|
mExtensions, mNewGame);
|
||||||
|
|
||||||
|
// Create sound system
|
||||||
mEnvironment.mSoundManager = new MWSound::SoundManager;
|
mEnvironment.mSoundManager = new MWSound::SoundManager;
|
||||||
|
|
||||||
|
// Create script system
|
||||||
mScriptContext = new MWScript::CompilerContext (MWScript::CompilerContext::Type_Full,
|
mScriptContext = new MWScript::CompilerContext (MWScript::CompilerContext::Type_Full,
|
||||||
mEnvironment);
|
mEnvironment);
|
||||||
mScriptContext->setExtensions (&mExtensions);
|
mScriptContext->setExtensions (&mExtensions);
|
||||||
|
@ -208,6 +213,12 @@ void OMW::Engine::go()
|
||||||
mEnvironment.mGlobalScripts = new MWScript::GlobalScripts (mEnvironment.mWorld->getStore(),
|
mEnvironment.mGlobalScripts = new MWScript::GlobalScripts (mEnvironment.mWorld->getStore(),
|
||||||
*mScriptManager);
|
*mScriptManager);
|
||||||
|
|
||||||
|
// Create game mechanics system
|
||||||
|
mEnvironment.mMechanicsManager = new MWMechanics::MechanicsManager (
|
||||||
|
mEnvironment.mWorld->getStore(), *mEnvironment.mWindowManager);
|
||||||
|
|
||||||
|
mEnvironment.mMechanicsManager->configureGUI();
|
||||||
|
|
||||||
// Sets up the input system
|
// Sets up the input system
|
||||||
MWInput::MWInputManager input(mOgre, mEnvironment.mWorld->getPlayerPos(),
|
MWInput::MWInputManager input(mOgre, mEnvironment.mWorld->getPlayerPos(),
|
||||||
*mEnvironment.mWindowManager, mDebug);
|
*mEnvironment.mWindowManager, mDebug);
|
||||||
|
|
|
@ -161,15 +161,6 @@ namespace MWGui
|
||||||
setText("Race_str", "Race");
|
setText("Race_str", "Race");
|
||||||
setText("Class_str", "Class");
|
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
|
// These are just demo values, you should replace these with
|
||||||
// real calls from outside the class later.
|
// real calls from outside the class later.
|
||||||
setPlayerName("ThePlayer");
|
setPlayerName("ThePlayer");
|
||||||
|
@ -196,6 +187,24 @@ namespace MWGui
|
||||||
{
|
{
|
||||||
mMainWidget->setCaption(playerName);
|
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
|
#endif
|
||||||
|
|
|
@ -84,3 +84,9 @@ void WindowManager::updateVisible()
|
||||||
|
|
||||||
// All other modes are ignored
|
// 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.
|
this class.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
namespace MyGUI
|
namespace MyGUI
|
||||||
{
|
{
|
||||||
class Gui;
|
class Gui;
|
||||||
|
@ -134,6 +136,9 @@ namespace MWGui
|
||||||
}
|
}
|
||||||
|
|
||||||
MyGUI::Gui* getGui() const { return gui; }
|
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
|
#endif
|
||||||
|
|
43
apps/openmw/mwmechanics/mechanicsmanager.cpp
Normal file
43
apps/openmw/mwmechanics/mechanicsmanager.cpp
Normal file
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
30
apps/openmw/mwmechanics/mechanicsmanager.hpp
Normal file
30
apps/openmw/mwmechanics/mechanicsmanager.hpp
Normal file
|
@ -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;
|
class WindowManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace MWMechanics
|
||||||
|
{
|
||||||
|
class MechanicsManager;
|
||||||
|
}
|
||||||
|
|
||||||
namespace MWWorld
|
namespace MWWorld
|
||||||
{
|
{
|
||||||
class World;
|
class World;
|
||||||
|
@ -25,13 +30,15 @@ namespace MWWorld
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Environment()
|
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;
|
World *mWorld;
|
||||||
MWSound::SoundManager *mSoundManager;
|
MWSound::SoundManager *mSoundManager;
|
||||||
MWScript::GlobalScripts *mGlobalScripts;
|
MWScript::GlobalScripts *mGlobalScripts;
|
||||||
MWGui::WindowManager *mWindowManager;
|
MWGui::WindowManager *mWindowManager;
|
||||||
|
MWMechanics::MechanicsManager *mMechanicsManager;
|
||||||
float mFrameDuration;
|
float mFrameDuration;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,6 +75,15 @@ namespace ESMS
|
||||||
ref.load(esm);
|
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(); }
|
int getSize() { return list.size(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue