forked from teamnwah/openmw-tes3coop
WindowManager: explicitely pass the ESMStore
Fixes potential crash when the loading screen layout tries to retrieve a GMST value via #{GMST} syntax before the World has been created. Possibly related to Bug #2854.
This commit is contained in:
parent
a699b4128a
commit
05f1fbf593
3 changed files with 28 additions and 11 deletions
|
@ -513,6 +513,7 @@ void OMW::Engine::prepareEngine (Settings::Manager & settings)
|
|||
mEnvironment.getWorld()->setupPlayer();
|
||||
input->setPlayer(&mEnvironment.getWorld()->getPlayer());
|
||||
|
||||
window->setStore(mEnvironment.getWorld()->getStore());
|
||||
window->initUI();
|
||||
window->renderWorldMap();
|
||||
|
||||
|
|
|
@ -117,7 +117,8 @@ namespace MWGui
|
|||
osgViewer::Viewer* viewer, osg::Group* guiRoot, Resource::ResourceSystem* resourceSystem
|
||||
, const std::string& logpath, const std::string& resourcePath, bool consoleOnlyScripts,
|
||||
Translation::Storage& translationDataStorage, ToUTF8::FromType encoding, bool exportFonts, const std::map<std::string, std::string>& fallbackMap, const std::string& versionDescription)
|
||||
: mResourceSystem(resourceSystem)
|
||||
: mStore(NULL)
|
||||
, mResourceSystem(resourceSystem)
|
||||
, mViewer(viewer)
|
||||
, mConsoleOnlyScripts(consoleOnlyScripts)
|
||||
, mCurrentModals()
|
||||
|
@ -291,8 +292,7 @@ namespace MWGui
|
|||
|
||||
bool questList = mResourceSystem->getVFS()->exists("textures/tx_menubook_options_over.dds");
|
||||
mJournal = JournalWindow::create(JournalViewModel::create (), questList);
|
||||
mMessageBoxManager = new MessageBoxManager(
|
||||
MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("fMessageTimePerChar")->getFloat());
|
||||
mMessageBoxManager = new MessageBoxManager(mStore->get<ESM::GameSetting>().find("fMessageTimePerChar")->getFloat());
|
||||
mInventoryWindow = new InventoryWindow(mDragAndDrop, mViewer, mResourceSystem);
|
||||
mTradeWindow = new TradeWindow();
|
||||
trackWindow(mTradeWindow, "barter");
|
||||
|
@ -461,6 +461,11 @@ namespace MWGui
|
|||
delete mGuiPlatform;
|
||||
}
|
||||
|
||||
void WindowManager::setStore(const MWWorld::ESMStore &store)
|
||||
{
|
||||
mStore = &store;
|
||||
}
|
||||
|
||||
void WindowManager::cleanupGarbage()
|
||||
{
|
||||
// Delete any dialogs which are no longer in use
|
||||
|
@ -908,8 +913,7 @@ namespace MWGui
|
|||
|
||||
std::string WindowManager::getGameSettingString(const std::string &id, const std::string &default_)
|
||||
{
|
||||
const ESM::GameSetting *setting =
|
||||
MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().search(id);
|
||||
const ESM::GameSetting *setting = mStore->get<ESM::GameSetting>().search(id);
|
||||
|
||||
if (setting && setting->mValue.getType()==ESM::VT_String)
|
||||
return setting->mValue.getString();
|
||||
|
@ -1139,8 +1143,12 @@ namespace MWGui
|
|||
}
|
||||
else
|
||||
{
|
||||
const ESM::GameSetting *setting =
|
||||
MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find(tag);
|
||||
if (!mStore)
|
||||
{
|
||||
std::cerr << "WindowManager::onRetrieveTag: no Store set up yet, can not replace '" << tag << "'" << std::endl;
|
||||
return;
|
||||
}
|
||||
const ESM::GameSetting *setting = mStore->get<ESM::GameSetting>().find(tag);
|
||||
|
||||
if (setting && setting->mValue.getType()==ESM::VT_String)
|
||||
_result = setting->mValue.getString();
|
||||
|
@ -1263,8 +1271,7 @@ namespace MWGui
|
|||
mSelectedSpell = spellId;
|
||||
mHud->setSelectedSpell(spellId, successChancePercent);
|
||||
|
||||
const ESM::Spell* spell =
|
||||
MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().find(spellId);
|
||||
const ESM::Spell* spell = mStore->get<ESM::Spell>().find(spellId);
|
||||
|
||||
mSpellWindow->setTitle(spell->mName);
|
||||
}
|
||||
|
@ -1272,7 +1279,7 @@ namespace MWGui
|
|||
void WindowManager::setSelectedEnchantItem(const MWWorld::Ptr& item)
|
||||
{
|
||||
mSelectedSpell = "";
|
||||
const ESM::Enchantment* ench = MWBase::Environment::get().getWorld()->getStore().get<ESM::Enchantment>()
|
||||
const ESM::Enchantment* ench = mStore->get<ESM::Enchantment>()
|
||||
.find(item.getClass().getEnchantment(item));
|
||||
|
||||
int chargePercent = (item.getCellRef().getEnchantmentCharge() == -1) ? 100
|
||||
|
@ -1707,7 +1714,7 @@ namespace MWGui
|
|||
{
|
||||
reader.getSubNameIs("ID__");
|
||||
std::string spell = reader.getHString();
|
||||
if (MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().search(spell))
|
||||
if (mStore->get<ESM::Spell>().search(spell))
|
||||
mSelectedSpell = spell;
|
||||
}
|
||||
else if (type == ESM::REC_MARK)
|
||||
|
|
|
@ -28,6 +28,11 @@ namespace MyGUI
|
|||
class ImageBox;
|
||||
}
|
||||
|
||||
namespace MWWorld
|
||||
{
|
||||
class ESMStore;
|
||||
}
|
||||
|
||||
namespace Compiler
|
||||
{
|
||||
class Extensions;
|
||||
|
@ -119,6 +124,9 @@ namespace MWGui
|
|||
Translation::Storage& translationDataStorage, ToUTF8::FromType encoding, bool exportFonts, const std::map<std::string,std::string>& fallbackMap, const std::string& versionDescription);
|
||||
virtual ~WindowManager();
|
||||
|
||||
/// Set the ESMStore to use for retrieving of GUI-related strings.
|
||||
void setStore (const MWWorld::ESMStore& store);
|
||||
|
||||
void initUI();
|
||||
void renderWorldMap();
|
||||
|
||||
|
@ -372,6 +380,7 @@ namespace MWGui
|
|||
void writeFog(MWWorld::CellStore* cell);
|
||||
|
||||
private:
|
||||
const MWWorld::ESMStore* mStore;
|
||||
Resource::ResourceSystem* mResourceSystem;
|
||||
|
||||
osgMyGUI::Platform* mGuiPlatform;
|
||||
|
|
Loading…
Reference in a new issue