mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-31 23:15:41 +00:00
Move data from WindowManager to CharacterCreation to simplify API
This commit is contained in:
parent
b3b8480d49
commit
000e44a18e
5 changed files with 38 additions and 119 deletions
|
@ -253,12 +253,6 @@ namespace MWBase
|
||||||
|
|
||||||
virtual void onFrame (float frameDuration) = 0;
|
virtual void onFrame (float frameDuration) = 0;
|
||||||
|
|
||||||
/// \todo get rid of this stuff. Move it to the respective UI element classes, if needed.
|
|
||||||
virtual std::map<int, MWMechanics::SkillValue > getPlayerSkillValues() = 0;
|
|
||||||
virtual std::map<int, MWMechanics::AttributeValue > getPlayerAttributeValues() = 0;
|
|
||||||
virtual SkillList getPlayerMinorSkills() = 0;
|
|
||||||
virtual SkillList getPlayerMajorSkills() = 0;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetches a GMST string from the store, if there is no setting with the given
|
* Fetches a GMST string from the store, if there is no setting with the given
|
||||||
* ID or it is not a string the default string is returned.
|
* ID or it is not a string the default string is returned.
|
||||||
|
|
|
@ -105,23 +105,32 @@ namespace MWGui
|
||||||
mGenerateClassSpecializations[0] = 0;
|
mGenerateClassSpecializations[0] = 0;
|
||||||
mGenerateClassSpecializations[1] = 0;
|
mGenerateClassSpecializations[1] = 0;
|
||||||
mGenerateClassSpecializations[2] = 0;
|
mGenerateClassSpecializations[2] = 0;
|
||||||
|
|
||||||
|
// Setup player stats
|
||||||
|
for (int i = 0; i < ESM::Attribute::Length; ++i)
|
||||||
|
mPlayerAttributes.emplace(ESM::Attribute::sAttributeIds[i], MWMechanics::AttributeValue());
|
||||||
|
|
||||||
|
for (int i = 0; i < ESM::Skill::Length; ++i)
|
||||||
|
mPlayerSkillValues.emplace(ESM::Skill::sSkillIds[i], MWMechanics::SkillValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
void CharacterCreation::setValue (const std::string& id, const MWMechanics::AttributeValue& value)
|
void CharacterCreation::setValue (const std::string& id, const MWMechanics::AttributeValue& value)
|
||||||
{
|
{
|
||||||
if (mReviewDialog)
|
static const char *ids[] =
|
||||||
{
|
{
|
||||||
static const char *ids[] =
|
"AttribVal1", "AttribVal2", "AttribVal3", "AttribVal4",
|
||||||
{
|
"AttribVal5", "AttribVal6", "AttribVal7", "AttribVal8", 0
|
||||||
"AttribVal1", "AttribVal2", "AttribVal3", "AttribVal4", "AttribVal5",
|
};
|
||||||
"AttribVal6", "AttribVal7", "AttribVal8",
|
|
||||||
0
|
|
||||||
};
|
|
||||||
|
|
||||||
for (int i=0; ids[i]; ++i)
|
for (int i=0; ids[i]; ++i)
|
||||||
|
{
|
||||||
|
if (ids[i]==id)
|
||||||
{
|
{
|
||||||
if (ids[i]==id)
|
mPlayerAttributes[static_cast<ESM::Attribute::AttributeID>(i)] = value;
|
||||||
mReviewDialog->setAttribute(ESM::Attribute::AttributeID(i), value);
|
if (mReviewDialog)
|
||||||
|
mReviewDialog->setAttribute(static_cast<ESM::Attribute::AttributeID>(i), value);
|
||||||
|
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -147,6 +156,7 @@ namespace MWGui
|
||||||
|
|
||||||
void CharacterCreation::setValue(const ESM::Skill::SkillEnum parSkill, const MWMechanics::SkillValue& value)
|
void CharacterCreation::setValue(const ESM::Skill::SkillEnum parSkill, const MWMechanics::SkillValue& value)
|
||||||
{
|
{
|
||||||
|
mPlayerSkillValues[parSkill] = value;
|
||||||
if (mReviewDialog)
|
if (mReviewDialog)
|
||||||
mReviewDialog->setSkillValue(parSkill, value);
|
mReviewDialog->setSkillValue(parSkill, value);
|
||||||
}
|
}
|
||||||
|
@ -155,6 +165,9 @@ namespace MWGui
|
||||||
{
|
{
|
||||||
if (mReviewDialog)
|
if (mReviewDialog)
|
||||||
mReviewDialog->configureSkills(major, minor);
|
mReviewDialog->configureSkills(major, minor);
|
||||||
|
|
||||||
|
mPlayerMajorSkills = major;
|
||||||
|
mPlayerMinorSkills = minor;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CharacterCreation::onFrame(float duration)
|
void CharacterCreation::onFrame(float duration)
|
||||||
|
@ -269,31 +282,21 @@ namespace MWGui
|
||||||
mReviewDialog->setClass(*playerClass);
|
mReviewDialog->setClass(*playerClass);
|
||||||
mReviewDialog->setBirthSign(player.getBirthSign());
|
mReviewDialog->setBirthSign(player.getBirthSign());
|
||||||
|
|
||||||
{
|
MWWorld::Ptr playerPtr = MWMechanics::getPlayer();
|
||||||
MWWorld::Ptr playerPtr = MWMechanics::getPlayer();
|
const MWMechanics::CreatureStats& stats = playerPtr.getClass().getCreatureStats(playerPtr);
|
||||||
const MWMechanics::CreatureStats& stats = playerPtr.getClass().getCreatureStats(playerPtr);
|
|
||||||
|
|
||||||
mReviewDialog->setHealth ( stats.getHealth() );
|
|
||||||
mReviewDialog->setMagicka( stats.getMagicka() );
|
|
||||||
mReviewDialog->setFatigue( stats.getFatigue() );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
mReviewDialog->setHealth(stats.getHealth());
|
||||||
|
mReviewDialog->setMagicka(stats.getMagicka());
|
||||||
|
mReviewDialog->setFatigue(stats.getFatigue());
|
||||||
|
for (auto& attributePair : mPlayerAttributes)
|
||||||
{
|
{
|
||||||
std::map<int, MWMechanics::AttributeValue > attributes = MWBase::Environment::get().getWindowManager()->getPlayerAttributeValues();
|
mReviewDialog->setAttribute(static_cast<ESM::Attribute::AttributeID> (attributePair.first), attributePair.second);
|
||||||
for (auto& attributePair : attributes)
|
|
||||||
{
|
|
||||||
mReviewDialog->setAttribute(static_cast<ESM::Attribute::AttributeID> (attributePair.first), attributePair.second);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
for (auto& skillPair : mPlayerSkillValues)
|
||||||
{
|
{
|
||||||
std::map<int, MWMechanics::SkillValue > skills = MWBase::Environment::get().getWindowManager()->getPlayerSkillValues();
|
mReviewDialog->setSkillValue(static_cast<ESM::Skill::SkillEnum> (skillPair.first), skillPair.second);
|
||||||
for (auto& skillPair : skills)
|
|
||||||
{
|
|
||||||
mReviewDialog->setSkillValue(static_cast<ESM::Skill::SkillEnum> (skillPair.first), skillPair.second);
|
|
||||||
}
|
|
||||||
mReviewDialog->configureSkills(MWBase::Environment::get().getWindowManager()->getPlayerMajorSkills(), MWBase::Environment::get().getWindowManager()->getPlayerMinorSkills());
|
|
||||||
}
|
}
|
||||||
|
mReviewDialog->configureSkills(mPlayerMajorSkills, mPlayerMinorSkills);
|
||||||
|
|
||||||
mReviewDialog->eventDone += MyGUI::newDelegate(this, &CharacterCreation::onReviewDialogDone);
|
mReviewDialog->eventDone += MyGUI::newDelegate(this, &CharacterCreation::onReviewDialogDone);
|
||||||
mReviewDialog->eventBack += MyGUI::newDelegate(this, &CharacterCreation::onReviewDialogBack);
|
mReviewDialog->eventBack += MyGUI::newDelegate(this, &CharacterCreation::onReviewDialogBack);
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include <components/esm/loadskil.hpp>
|
#include <components/esm/loadskil.hpp>
|
||||||
#include <components/esm/loadclas.hpp>
|
#include <components/esm/loadclas.hpp>
|
||||||
|
|
||||||
|
#include <map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "../mwmechanics/stat.hpp"
|
#include "../mwmechanics/stat.hpp"
|
||||||
|
@ -56,6 +57,10 @@ namespace MWGui
|
||||||
osg::Group* mParent;
|
osg::Group* mParent;
|
||||||
Resource::ResourceSystem* mResourceSystem;
|
Resource::ResourceSystem* mResourceSystem;
|
||||||
|
|
||||||
|
SkillList mPlayerMajorSkills, mPlayerMinorSkills;
|
||||||
|
std::map<int, MWMechanics::AttributeValue> mPlayerAttributes;
|
||||||
|
std::map<int, MWMechanics::SkillValue> mPlayerSkillValues;
|
||||||
|
|
||||||
//Dialogs
|
//Dialogs
|
||||||
TextInputDialog* mNameDialog;
|
TextInputDialog* mNameDialog;
|
||||||
RaceDialog* mRaceDialog;
|
RaceDialog* mRaceDialog;
|
||||||
|
|
|
@ -182,12 +182,6 @@ namespace MWGui
|
||||||
, mCursorVisible(true)
|
, mCursorVisible(true)
|
||||||
, mCursorActive(false)
|
, mCursorActive(false)
|
||||||
, mPlayerBounty(-1)
|
, mPlayerBounty(-1)
|
||||||
, mPlayerName()
|
|
||||||
, mPlayerRaceId()
|
|
||||||
, mPlayerAttributes()
|
|
||||||
, mPlayerMajorSkills()
|
|
||||||
, mPlayerMinorSkills()
|
|
||||||
, mPlayerSkillValues()
|
|
||||||
, mGui(nullptr)
|
, mGui(nullptr)
|
||||||
, mGuiModes()
|
, mGuiModes()
|
||||||
, mCursorManager(nullptr)
|
, mCursorManager(nullptr)
|
||||||
|
@ -594,17 +588,6 @@ namespace MWGui
|
||||||
|
|
||||||
mCharGen = new CharacterCreation(mViewer->getSceneData()->asGroup(), mResourceSystem);
|
mCharGen = new CharacterCreation(mViewer->getSceneData()->asGroup(), mResourceSystem);
|
||||||
|
|
||||||
// Setup player stats
|
|
||||||
for (int i = 0; i < ESM::Attribute::Length; ++i)
|
|
||||||
{
|
|
||||||
mPlayerAttributes.insert(std::make_pair(ESM::Attribute::sAttributeIds[i], MWMechanics::AttributeValue()));
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < ESM::Skill::Length; ++i)
|
|
||||||
{
|
|
||||||
mPlayerSkillValues.insert(std::make_pair(ESM::Skill::sSkillIds[i], MWMechanics::SkillValue()));
|
|
||||||
}
|
|
||||||
|
|
||||||
updatePinnedWindows();
|
updatePinnedWindows();
|
||||||
|
|
||||||
// Set up visibility
|
// Set up visibility
|
||||||
|
@ -797,40 +780,14 @@ namespace MWGui
|
||||||
{
|
{
|
||||||
mStatsWindow->setValue (id, value);
|
mStatsWindow->setValue (id, value);
|
||||||
mCharGen->setValue(id, value);
|
mCharGen->setValue(id, value);
|
||||||
|
|
||||||
static const char *ids[] =
|
|
||||||
{
|
|
||||||
"AttribVal1", "AttribVal2", "AttribVal3", "AttribVal4", "AttribVal5",
|
|
||||||
"AttribVal6", "AttribVal7", "AttribVal8"
|
|
||||||
};
|
|
||||||
static ESM::Attribute::AttributeID attributes[] =
|
|
||||||
{
|
|
||||||
ESM::Attribute::Strength,
|
|
||||||
ESM::Attribute::Intelligence,
|
|
||||||
ESM::Attribute::Willpower,
|
|
||||||
ESM::Attribute::Agility,
|
|
||||||
ESM::Attribute::Speed,
|
|
||||||
ESM::Attribute::Endurance,
|
|
||||||
ESM::Attribute::Personality,
|
|
||||||
ESM::Attribute::Luck
|
|
||||||
};
|
|
||||||
for (size_t i = 0; i < sizeof(ids)/sizeof(ids[0]); ++i)
|
|
||||||
{
|
|
||||||
if (id != ids[i])
|
|
||||||
continue;
|
|
||||||
mPlayerAttributes[attributes[i]] = value;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void WindowManager::setValue (int parSkill, const MWMechanics::SkillValue& value)
|
void WindowManager::setValue (int parSkill, const MWMechanics::SkillValue& value)
|
||||||
{
|
{
|
||||||
/// \todo Don't use the skill enum as a parameter type (we will have to drop it anyway, once we
|
/// \todo Don't use the skill enum as a parameter type (we will have to drop it anyway, once we
|
||||||
/// allow custom skills.
|
/// allow custom skills.
|
||||||
mStatsWindow->setValue(static_cast<ESM::Skill::SkillEnum> (parSkill), value);
|
mStatsWindow->setValue(static_cast<ESM::Skill::SkillEnum> (parSkill), value);
|
||||||
mCharGen->setValue(static_cast<ESM::Skill::SkillEnum> (parSkill), value);
|
mCharGen->setValue(static_cast<ESM::Skill::SkillEnum> (parSkill), value);
|
||||||
mPlayerSkillValues[parSkill] = value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowManager::setValue (const std::string& id, const MWMechanics::DynamicStat<float>& value)
|
void WindowManager::setValue (const std::string& id, const MWMechanics::DynamicStat<float>& value)
|
||||||
|
@ -843,10 +800,6 @@ namespace MWGui
|
||||||
void WindowManager::setValue (const std::string& id, const std::string& value)
|
void WindowManager::setValue (const std::string& id, const std::string& value)
|
||||||
{
|
{
|
||||||
mStatsWindow->setValue (id, value);
|
mStatsWindow->setValue (id, value);
|
||||||
if (id=="name")
|
|
||||||
mPlayerName = value;
|
|
||||||
else if (id=="race")
|
|
||||||
mPlayerRaceId = value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowManager::setValue (const std::string& id, int value)
|
void WindowManager::setValue (const std::string& id, int value)
|
||||||
|
@ -868,8 +821,6 @@ namespace MWGui
|
||||||
{
|
{
|
||||||
mStatsWindow->configureSkills (major, minor);
|
mStatsWindow->configureSkills (major, minor);
|
||||||
mCharGen->configureSkills(major, minor);
|
mCharGen->configureSkills(major, minor);
|
||||||
mPlayerMajorSkills = major;
|
|
||||||
mPlayerMinorSkills = minor;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowManager::updateSkillArea()
|
void WindowManager::updateSkillArea()
|
||||||
|
@ -1639,26 +1590,6 @@ namespace MWGui
|
||||||
return mGuiModes.back();
|
return mGuiModes.back();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::map<int, MWMechanics::SkillValue > WindowManager::getPlayerSkillValues()
|
|
||||||
{
|
|
||||||
return mPlayerSkillValues;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::map<int, MWMechanics::AttributeValue > WindowManager::getPlayerAttributeValues()
|
|
||||||
{
|
|
||||||
return mPlayerAttributes;
|
|
||||||
}
|
|
||||||
|
|
||||||
WindowManager::SkillList WindowManager::getPlayerMinorSkills()
|
|
||||||
{
|
|
||||||
return mPlayerMinorSkills;
|
|
||||||
}
|
|
||||||
|
|
||||||
WindowManager::SkillList WindowManager::getPlayerMajorSkills()
|
|
||||||
{
|
|
||||||
return mPlayerMajorSkills;
|
|
||||||
}
|
|
||||||
|
|
||||||
void WindowManager::disallowMouse()
|
void WindowManager::disallowMouse()
|
||||||
{
|
{
|
||||||
mInputBlocker->setVisible (true);
|
mInputBlocker->setVisible (true);
|
||||||
|
|
|
@ -282,12 +282,6 @@ namespace MWGui
|
||||||
|
|
||||||
virtual void onFrame (float frameDuration);
|
virtual void onFrame (float frameDuration);
|
||||||
|
|
||||||
/// \todo get rid of this stuff. Move it to the respective UI element classes, if needed.
|
|
||||||
virtual std::map<int, MWMechanics::SkillValue > getPlayerSkillValues();
|
|
||||||
virtual std::map<int, MWMechanics::AttributeValue > getPlayerAttributeValues();
|
|
||||||
virtual SkillList getPlayerMinorSkills();
|
|
||||||
virtual SkillList getPlayerMajorSkills();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetches a GMST string from the store, if there is no setting with the given
|
* Fetches a GMST string from the store, if there is no setting with the given
|
||||||
* ID or it is not a string the default string is returned.
|
* ID or it is not a string the default string is returned.
|
||||||
|
@ -474,14 +468,6 @@ namespace MWGui
|
||||||
|
|
||||||
void setCursorVisible(bool visible);
|
void setCursorVisible(bool visible);
|
||||||
|
|
||||||
/// \todo get rid of this stuff. Move it to the respective UI element classes, if needed.
|
|
||||||
// Various stats about player as needed by window manager
|
|
||||||
std::string mPlayerName;
|
|
||||||
std::string mPlayerRaceId;
|
|
||||||
std::map<int, MWMechanics::AttributeValue > mPlayerAttributes;
|
|
||||||
SkillList mPlayerMajorSkills, mPlayerMinorSkills;
|
|
||||||
std::map<int, MWMechanics::SkillValue > mPlayerSkillValues;
|
|
||||||
|
|
||||||
MyGUI::Gui *mGui; // Gui
|
MyGUI::Gui *mGui; // Gui
|
||||||
|
|
||||||
struct GuiModeState
|
struct GuiModeState
|
||||||
|
|
Loading…
Reference in a new issue