From cb98bd1a798e7f7b77fb65a8ad311f7bdb23ddad Mon Sep 17 00:00:00 2001 From: Jan Borsodi Date: Tue, 14 Sep 2010 14:30:12 +0200 Subject: [PATCH] Spellpower list is now fetched from the ESM store. --- apps/openmw/mwgui/mw_chargen.cpp | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/apps/openmw/mwgui/mw_chargen.cpp b/apps/openmw/mwgui/mw_chargen.cpp index fb9627aa0f..8c12eff141 100644 --- a/apps/openmw/mwgui/mw_chargen.cpp +++ b/apps/openmw/mwgui/mw_chargen.cpp @@ -215,26 +215,29 @@ void RaceDialog::updateSpellPowers() } spellPowerItems.clear(); - MyGUI::StaticTextPtr spellPowerName; + if (currentRace.empty()) + return; + + MyGUI::StaticTextPtr spellPowerWidget; const int lineHeight = 18; MyGUI::IntCoord coord(0, 0, spellPowerList->getWidth(), 18); - const char *inputList[] = { - "Depth Perception", - "Resist Fire", - "Ancestor Guardian", - 0 - }; + ESMS::ESMStore &store = environment.mWorld->getStore(); + const ESM::Race *race = store.races.find(currentRace); - for (int i = 0; inputList[i]; ++i) + std::vector::const_iterator it = race->powers.list.begin(); + std::vector::const_iterator end = race->powers.list.end(); + for (int i = 0; it != end; ++it) { - std::ostringstream name; - name << std::string("SpellPowerName") << i; - spellPowerName = spellPowerList->createWidget("SandText", coord, MyGUI::Align::Default, name.str()); - spellPowerName->setCaption(inputList[i]); + const std::string &spellpower = *it; + const ESM::Spell *spell = store.spells.find(spellpower); + assert(spell); + spellPowerWidget = spellPowerList->createWidget("SandText", coord, MyGUI::Align::Default, std::string("SpellPowerName") + boost::lexical_cast(i)); + spellPowerWidget->setCaption(spell->name); - spellPowerItems.push_back(spellPowerName); + spellPowerItems.push_back(spellPowerWidget); coord.top += lineHeight; + ++i; } }