diff --git a/apps/openmw/mwgui/race.cpp b/apps/openmw/mwgui/race.cpp index 37217ee9c..ae1b8081b 100644 --- a/apps/openmw/mwgui/race.cpp +++ b/apps/openmw/mwgui/race.cpp @@ -92,14 +92,14 @@ RaceDialog::RaceDialog(MWWorld::Environment& environment, bool showNext) updateSpellPowers(); } -void RaceDialog::setRace(const std::string &race) +void RaceDialog::setRaceId(const std::string &raceId) { - currentRace = race; + currentRaceId = raceId; raceList->setIndexSelected(MyGUI::ITEM_NONE); size_t count = raceList->getItemCount(); for (size_t i = 0; i < count; ++i) { - if (boost::iequals(raceList->getItem(i), race)) + if (boost::iequals(raceList->getItem(i), raceId)) { raceList->setIndexSelected(i); break; @@ -172,11 +172,11 @@ void RaceDialog::onSelectRace(MyGUI::List* _sender, size_t _index) if (_index == MyGUI::ITEM_NONE) return; - const std::string race = raceList->getItem(_index); - if (boost::iequals(currentRace, race)) + const std::string *raceId = raceList->getItemDataAt(_index); + if (boost::iequals(currentRaceId, *raceId)) return; - currentRace = race; + currentRaceId = *raceId; updateSkills(); updateSpellPowers(); } @@ -199,8 +199,8 @@ void RaceDialog::updateRaces() if (!playable) // Only display playable races continue; - raceList->addItem(race.name); - if (boost::iequals(race.name, currentRace)) + raceList->addItem(race.name, it->first); + if (boost::iequals(race.name, currentRaceId)) raceList->setIndexSelected(index); ++index; } @@ -214,7 +214,7 @@ void RaceDialog::updateSkills() } skillItems.clear(); - if (currentRace.empty()) + if (currentRaceId.empty()) return; MyGUI::StaticTextPtr skillNameWidget, skillBonusWidget; @@ -223,7 +223,7 @@ void RaceDialog::updateSkills() MyGUI::IntCoord coord2(coord1.left + coord1.width, 0, 40, 18); ESMS::ESMStore &store = environment.mWorld->getStore(); - const ESM::Race *race = store.races.find(currentRace); + const ESM::Race *race = store.races.find(currentRaceId); int count = sizeof(race->data.bonus)/sizeof(race->data.bonus[0]); // TODO: Find a portable macro for this ARRAYSIZE? for (int i = 0; i < count; ++i) { @@ -257,7 +257,7 @@ void RaceDialog::updateSpellPowers() } spellPowerItems.clear(); - if (currentRace.empty()) + if (currentRaceId.empty()) return; MyGUI::StaticTextPtr spellPowerWidget; @@ -265,7 +265,7 @@ void RaceDialog::updateSpellPowers() MyGUI::IntCoord coord(0, 0, spellPowerList->getWidth(), 18); ESMS::ESMStore &store = environment.mWorld->getStore(); - const ESM::Race *race = store.races.find(currentRace); + const ESM::Race *race = store.races.find(currentRaceId); std::vector::const_iterator it = race->powers.list.begin(); std::vector::const_iterator end = race->powers.list.end(); diff --git a/apps/openmw/mwgui/race.hpp b/apps/openmw/mwgui/race.hpp index 749bf55b2..655f74ed4 100644 --- a/apps/openmw/mwgui/race.hpp +++ b/apps/openmw/mwgui/race.hpp @@ -34,12 +34,12 @@ namespace MWGui GM_Female }; - const std::string &getRace() const { return currentRace; } + const std::string &getRaceId() const { return currentRaceId; } Gender getGender() const { return genderIndex == 0 ? GM_Male : GM_Female; } // getFace() // getHair() - void setRace(const std::string &race); + void setRaceId(const std::string &raceId); void setGender(Gender gender) { genderIndex = gender == GM_Male ? 0 : 1; } // setFace() // setHair() @@ -93,7 +93,7 @@ namespace MWGui int genderIndex, faceIndex, hairIndex; int faceCount, hairCount; - std::string currentRace; + std::string currentRaceId; }; } #endif diff --git a/apps/openmw/mwgui/window_manager.cpp b/apps/openmw/mwgui/window_manager.cpp index e1382fd40..f0e0c5b69 100644 --- a/apps/openmw/mwgui/window_manager.cpp +++ b/apps/openmw/mwgui/window_manager.cpp @@ -201,7 +201,7 @@ void WindowManager::onRaceDialogDone() if (raceDialog) { raceDialog->setVisible(false); - environment.mMechanicsManager->setPlayerRace(raceDialog->getRace(), raceDialog->getGender() == RaceDialog::GM_Male); + environment.mMechanicsManager->setPlayerRace(raceDialog->getRaceId(), raceDialog->getGender() == RaceDialog::GM_Male); } delete raceDialog; raceDialog = nullptr; @@ -219,7 +219,7 @@ void WindowManager::onRaceDialogBack() if (raceDialog) { raceDialog->setVisible(false); - environment.mMechanicsManager->setPlayerRace(raceDialog->getRace(), raceDialog->getGender() == RaceDialog::GM_Male); + environment.mMechanicsManager->setPlayerRace(raceDialog->getRaceId(), raceDialog->getGender() == RaceDialog::GM_Male); } delete raceDialog; raceDialog = nullptr;