forked from mirror/openmw-tes3mp
Stat setValue, use the enum values all the way through instead of converting enum->string->same enum
This commit is contained in:
parent
0695e8d8b2
commit
53b85eaaa9
5 changed files with 22 additions and 111 deletions
|
@ -173,45 +173,10 @@ void StatsWindow::setValue (const std::string& id, int value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void StatsWindow::setValue (const std::string& id, const MWMechanics::Stat<float>& value)
|
void StatsWindow::setValue(const ESM::Skill::SkillEnum parSkill, const MWMechanics::Stat<float>& value)
|
||||||
{
|
{
|
||||||
static struct {const char *id; ESM::Skill::SkillEnum skillId; } skillMap[] =
|
skillValues[parSkill] = value;
|
||||||
{
|
MyGUI::StaticTextPtr widget = skillWidgetMap[(int)parSkill];
|
||||||
{"SkillBlock", ESM::Skill::Block},
|
|
||||||
{"SkillArmorer", ESM::Skill::Armorer},
|
|
||||||
{"SkillMediumArmor", ESM::Skill::MediumArmor},
|
|
||||||
{"SkillHeavyArmor", ESM::Skill::HeavyArmor},
|
|
||||||
{"SkillBluntWeapon", ESM::Skill::BluntWeapon},
|
|
||||||
{"SkillLongBlade", ESM::Skill::LongBlade},
|
|
||||||
{"SkillAxe", ESM::Skill::Axe},
|
|
||||||
{"SkillSpear", ESM::Skill::Spear},
|
|
||||||
{"SkillAthletics", ESM::Skill::Athletics},
|
|
||||||
{"SkillEnchant", ESM::Skill::Armorer},
|
|
||||||
{"SkillDestruction", ESM::Skill::Destruction},
|
|
||||||
{"SkillAlteration", ESM::Skill::Alteration},
|
|
||||||
{"SkillIllusion", ESM::Skill::Illusion},
|
|
||||||
{"SkillConjuration", ESM::Skill::Conjuration},
|
|
||||||
{"SkillMysticism", ESM::Skill::Mysticism},
|
|
||||||
{"SkillRestoration", ESM::Skill::Restoration},
|
|
||||||
{"SkillAlchemy", ESM::Skill::Alchemy},
|
|
||||||
{"SkillUnarmored", ESM::Skill::Unarmored},
|
|
||||||
{"SkillSecurity", ESM::Skill::Security},
|
|
||||||
{"SkillSneak", ESM::Skill::Sneak},
|
|
||||||
{"SkillAcrobatics", ESM::Skill::Acrobatics},
|
|
||||||
{"SkillLightArmor", ESM::Skill::LightArmor},
|
|
||||||
{"SkillShortBlade", ESM::Skill::ShortBlade},
|
|
||||||
{"SkillMarksman", ESM::Skill::Marksman},
|
|
||||||
{"SkillMercantile", ESM::Skill::Mercantile},
|
|
||||||
{"SkillSpeechcraft", ESM::Skill::Speechcraft},
|
|
||||||
{"SkillHandToHand", ESM::Skill::HandToHand},
|
|
||||||
};
|
|
||||||
for (size_t i = 0; i < sizeof(skillMap)/sizeof(skillMap[0]); ++i)
|
|
||||||
{
|
|
||||||
if (skillMap[i].id == id)
|
|
||||||
{
|
|
||||||
int skillId = skillMap[i].skillId;
|
|
||||||
skillValues[skillId] = value;
|
|
||||||
MyGUI::StaticTextPtr widget = skillWidgetMap[skillId];
|
|
||||||
if (widget)
|
if (widget)
|
||||||
{
|
{
|
||||||
float modified = value.getModified(), base = value.getBase();
|
float modified = value.getModified(), base = value.getBase();
|
||||||
|
@ -224,9 +189,6 @@ void StatsWindow::setValue (const std::string& id, const MWMechanics::Stat<float
|
||||||
|
|
||||||
setStyledText(widget, style, text);
|
setStyledText(widget, style, text);
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void StatsWindow::configureSkills (const std::vector<int>& major, const std::vector<int>& minor)
|
void StatsWindow::configureSkills (const std::vector<int>& major, const std::vector<int>& minor)
|
||||||
|
|
|
@ -37,7 +37,7 @@ namespace MWGui
|
||||||
void setValue (const std::string& id, const MWMechanics::DynamicStat<int>& value);
|
void setValue (const std::string& id, const MWMechanics::DynamicStat<int>& value);
|
||||||
void setValue (const std::string& id, const std::string& value);
|
void setValue (const std::string& id, const std::string& value);
|
||||||
void setValue (const std::string& id, int value);
|
void setValue (const std::string& id, int value);
|
||||||
void setValue (const std::string& id, const MWMechanics::Stat<float>& value);
|
void setValue(const ESM::Skill::SkillEnum parSkill, const MWMechanics::Stat<float>& value);
|
||||||
|
|
||||||
void configureSkills (const SkillList& major, const SkillList& minor);
|
void configureSkills (const SkillList& major, const SkillList& minor);
|
||||||
void setFactions (const std::vector<Faction>& factions);
|
void setFactions (const std::vector<Faction>& factions);
|
||||||
|
|
|
@ -366,49 +366,11 @@ void WindowManager::setValue (const std::string& id, const MWMechanics::Stat<int
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowManager::setValue (const std::string& id, const MWMechanics::Stat<float>& value)
|
|
||||||
{
|
|
||||||
stats->setValue (id, value);
|
|
||||||
|
|
||||||
static struct {const char *id; ESM::Skill::SkillEnum skillId; } skillMap[] =
|
void WindowManager::setValue(const ESM::Skill::SkillEnum parSkill, const MWMechanics::Stat<float>& value)
|
||||||
{
|
{
|
||||||
{"SkillBlock", ESM::Skill::Block},
|
stats->setValue(parSkill, value);
|
||||||
{"SkillArmorer", ESM::Skill::Armorer},
|
playerSkillValues[parSkill] = value;
|
||||||
{"SkillMediumArmor", ESM::Skill::MediumArmor},
|
|
||||||
{"SkillHeavyArmor", ESM::Skill::HeavyArmor},
|
|
||||||
{"SkillBluntWeapon", ESM::Skill::BluntWeapon},
|
|
||||||
{"SkillLongBlade", ESM::Skill::LongBlade},
|
|
||||||
{"SkillAxe", ESM::Skill::Axe},
|
|
||||||
{"SkillSpear", ESM::Skill::Spear},
|
|
||||||
{"SkillAthletics", ESM::Skill::Athletics},
|
|
||||||
{"SkillEnchant", ESM::Skill::Armorer},
|
|
||||||
{"SkillDestruction", ESM::Skill::Destruction},
|
|
||||||
{"SkillAlteration", ESM::Skill::Alteration},
|
|
||||||
{"SkillIllusion", ESM::Skill::Illusion},
|
|
||||||
{"SkillConjuration", ESM::Skill::Conjuration},
|
|
||||||
{"SkillMysticism", ESM::Skill::Mysticism},
|
|
||||||
{"SkillRestoration", ESM::Skill::Restoration},
|
|
||||||
{"SkillAlchemy", ESM::Skill::Alchemy},
|
|
||||||
{"SkillUnarmored", ESM::Skill::Unarmored},
|
|
||||||
{"SkillSecurity", ESM::Skill::Security},
|
|
||||||
{"SkillSneak", ESM::Skill::Sneak},
|
|
||||||
{"SkillAcrobatics", ESM::Skill::Acrobatics},
|
|
||||||
{"SkillLightArmor", ESM::Skill::LightArmor},
|
|
||||||
{"SkillShortBlade", ESM::Skill::ShortBlade},
|
|
||||||
{"SkillMarksman", ESM::Skill::Marksman},
|
|
||||||
{"SkillMercantile", ESM::Skill::Mercantile},
|
|
||||||
{"SkillSpeechcraft", ESM::Skill::Speechcraft},
|
|
||||||
{"SkillHandToHand", ESM::Skill::HandToHand},
|
|
||||||
};
|
|
||||||
for (size_t i = 0; i < sizeof(skillMap)/sizeof(skillMap[0]); ++i)
|
|
||||||
{
|
|
||||||
if (skillMap[i].id == id)
|
|
||||||
{
|
|
||||||
ESM::Skill::SkillEnum skillId = skillMap[i].skillId;
|
|
||||||
playerSkillValues[skillId] = value;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowManager::setValue (const std::string& id, const MWMechanics::DynamicStat<int>& value)
|
void WindowManager::setValue (const std::string& id, const MWMechanics::DynamicStat<int>& value)
|
||||||
|
|
|
@ -205,7 +205,7 @@ namespace MWGui
|
||||||
void setValue (const std::string& id, const MWMechanics::Stat<int>& value);
|
void setValue (const std::string& id, const MWMechanics::Stat<int>& value);
|
||||||
///< Set value for the given ID.
|
///< Set value for the given ID.
|
||||||
|
|
||||||
void setValue (const std::string& id, const MWMechanics::Stat<float>& value);
|
void setValue(const ESM::Skill::SkillEnum parSkill, const MWMechanics::Stat<float>& value);
|
||||||
///< Set value for the given ID.
|
///< Set value for the given ID.
|
||||||
|
|
||||||
void setValue (const std::string& id, const MWMechanics::DynamicStat<int>& value);
|
void setValue (const std::string& id, const MWMechanics::DynamicStat<int>& value);
|
||||||
|
|
|
@ -276,17 +276,6 @@ namespace MWMechanics
|
||||||
"HBar", "MBar", "FBar"
|
"HBar", "MBar", "FBar"
|
||||||
};
|
};
|
||||||
|
|
||||||
static const char *skillNames[27] =
|
|
||||||
{
|
|
||||||
"SkillBlock", "SkillArmorer", "SkillMediumArmor", "SkillHeavyArmor",
|
|
||||||
"SkillBluntWeapon", "SkillLongBlade", "SkillAxe", "SkillSpear",
|
|
||||||
"SkillAthletics", "SkillEnchant", "SkillDestruction", "SkillAlteration",
|
|
||||||
"SkillIllusion", "SkillConjuration", "SkillMysticism", "SkillRestoration",
|
|
||||||
"SkillAlchemy", "SkillUnarmored", "SkillSecurity", "SkillSneak",
|
|
||||||
"SkillAcrobatics", "SkillLightArmor", "SkillShortBlade", "SkillMarksman",
|
|
||||||
"SkillMercantile", "SkillSpeechcraft", "SkillHandToHand",
|
|
||||||
};
|
|
||||||
|
|
||||||
for (int i=0; i<8; ++i)
|
for (int i=0; i<8; ++i)
|
||||||
{
|
{
|
||||||
if (stats.mAttributes[i]!=mWatchedCreature.mAttributes[i])
|
if (stats.mAttributes[i]!=mWatchedCreature.mAttributes[i])
|
||||||
|
@ -309,16 +298,14 @@ namespace MWMechanics
|
||||||
|
|
||||||
bool update = false;
|
bool update = false;
|
||||||
|
|
||||||
|
//Loop over ESM::Skill::SkillEnum
|
||||||
for(int i = 0; i < 27; ++i)
|
for(int i = 0; i < 27; ++i)
|
||||||
{
|
{
|
||||||
if(npcStats.mSkill[i] != mWatchedNpc.mSkill[i])
|
if(npcStats.mSkill[i] != mWatchedNpc.mSkill[i])
|
||||||
{
|
{
|
||||||
update = true;
|
update = true;
|
||||||
|
|
||||||
mWatchedNpc.mSkill[i] = npcStats.mSkill[i];
|
mWatchedNpc.mSkill[i] = npcStats.mSkill[i];
|
||||||
|
mEnvironment.mWindowManager->setValue((ESM::Skill::SkillEnum)i, npcStats.mSkill[i]);
|
||||||
mEnvironment.mWindowManager->setValue (skillNames[i], npcStats.mSkill[i]);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue