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();
|
mEnvironment.getWorld()->setupPlayer();
|
||||||
input->setPlayer(&mEnvironment.getWorld()->getPlayer());
|
input->setPlayer(&mEnvironment.getWorld()->getPlayer());
|
||||||
|
|
||||||
|
window->setStore(mEnvironment.getWorld()->getStore());
|
||||||
window->initUI();
|
window->initUI();
|
||||||
window->renderWorldMap();
|
window->renderWorldMap();
|
||||||
|
|
||||||
|
|
|
@ -117,7 +117,8 @@ namespace MWGui
|
||||||
osgViewer::Viewer* viewer, osg::Group* guiRoot, Resource::ResourceSystem* resourceSystem
|
osgViewer::Viewer* viewer, osg::Group* guiRoot, Resource::ResourceSystem* resourceSystem
|
||||||
, const std::string& logpath, const std::string& resourcePath, bool consoleOnlyScripts,
|
, 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)
|
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)
|
, mViewer(viewer)
|
||||||
, mConsoleOnlyScripts(consoleOnlyScripts)
|
, mConsoleOnlyScripts(consoleOnlyScripts)
|
||||||
, mCurrentModals()
|
, mCurrentModals()
|
||||||
|
@ -291,8 +292,7 @@ namespace MWGui
|
||||||
|
|
||||||
bool questList = mResourceSystem->getVFS()->exists("textures/tx_menubook_options_over.dds");
|
bool questList = mResourceSystem->getVFS()->exists("textures/tx_menubook_options_over.dds");
|
||||||
mJournal = JournalWindow::create(JournalViewModel::create (), questList);
|
mJournal = JournalWindow::create(JournalViewModel::create (), questList);
|
||||||
mMessageBoxManager = new MessageBoxManager(
|
mMessageBoxManager = new MessageBoxManager(mStore->get<ESM::GameSetting>().find("fMessageTimePerChar")->getFloat());
|
||||||
MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("fMessageTimePerChar")->getFloat());
|
|
||||||
mInventoryWindow = new InventoryWindow(mDragAndDrop, mViewer, mResourceSystem);
|
mInventoryWindow = new InventoryWindow(mDragAndDrop, mViewer, mResourceSystem);
|
||||||
mTradeWindow = new TradeWindow();
|
mTradeWindow = new TradeWindow();
|
||||||
trackWindow(mTradeWindow, "barter");
|
trackWindow(mTradeWindow, "barter");
|
||||||
|
@ -461,6 +461,11 @@ namespace MWGui
|
||||||
delete mGuiPlatform;
|
delete mGuiPlatform;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WindowManager::setStore(const MWWorld::ESMStore &store)
|
||||||
|
{
|
||||||
|
mStore = &store;
|
||||||
|
}
|
||||||
|
|
||||||
void WindowManager::cleanupGarbage()
|
void WindowManager::cleanupGarbage()
|
||||||
{
|
{
|
||||||
// Delete any dialogs which are no longer in use
|
// 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_)
|
std::string WindowManager::getGameSettingString(const std::string &id, const std::string &default_)
|
||||||
{
|
{
|
||||||
const ESM::GameSetting *setting =
|
const ESM::GameSetting *setting = mStore->get<ESM::GameSetting>().search(id);
|
||||||
MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().search(id);
|
|
||||||
|
|
||||||
if (setting && setting->mValue.getType()==ESM::VT_String)
|
if (setting && setting->mValue.getType()==ESM::VT_String)
|
||||||
return setting->mValue.getString();
|
return setting->mValue.getString();
|
||||||
|
@ -1139,8 +1143,12 @@ namespace MWGui
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const ESM::GameSetting *setting =
|
if (!mStore)
|
||||||
MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find(tag);
|
{
|
||||||
|
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)
|
if (setting && setting->mValue.getType()==ESM::VT_String)
|
||||||
_result = setting->mValue.getString();
|
_result = setting->mValue.getString();
|
||||||
|
@ -1263,8 +1271,7 @@ namespace MWGui
|
||||||
mSelectedSpell = spellId;
|
mSelectedSpell = spellId;
|
||||||
mHud->setSelectedSpell(spellId, successChancePercent);
|
mHud->setSelectedSpell(spellId, successChancePercent);
|
||||||
|
|
||||||
const ESM::Spell* spell =
|
const ESM::Spell* spell = mStore->get<ESM::Spell>().find(spellId);
|
||||||
MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().find(spellId);
|
|
||||||
|
|
||||||
mSpellWindow->setTitle(spell->mName);
|
mSpellWindow->setTitle(spell->mName);
|
||||||
}
|
}
|
||||||
|
@ -1272,7 +1279,7 @@ namespace MWGui
|
||||||
void WindowManager::setSelectedEnchantItem(const MWWorld::Ptr& item)
|
void WindowManager::setSelectedEnchantItem(const MWWorld::Ptr& item)
|
||||||
{
|
{
|
||||||
mSelectedSpell = "";
|
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));
|
.find(item.getClass().getEnchantment(item));
|
||||||
|
|
||||||
int chargePercent = (item.getCellRef().getEnchantmentCharge() == -1) ? 100
|
int chargePercent = (item.getCellRef().getEnchantmentCharge() == -1) ? 100
|
||||||
|
@ -1707,7 +1714,7 @@ namespace MWGui
|
||||||
{
|
{
|
||||||
reader.getSubNameIs("ID__");
|
reader.getSubNameIs("ID__");
|
||||||
std::string spell = reader.getHString();
|
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;
|
mSelectedSpell = spell;
|
||||||
}
|
}
|
||||||
else if (type == ESM::REC_MARK)
|
else if (type == ESM::REC_MARK)
|
||||||
|
|
|
@ -28,6 +28,11 @@ namespace MyGUI
|
||||||
class ImageBox;
|
class ImageBox;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace MWWorld
|
||||||
|
{
|
||||||
|
class ESMStore;
|
||||||
|
}
|
||||||
|
|
||||||
namespace Compiler
|
namespace Compiler
|
||||||
{
|
{
|
||||||
class Extensions;
|
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);
|
Translation::Storage& translationDataStorage, ToUTF8::FromType encoding, bool exportFonts, const std::map<std::string,std::string>& fallbackMap, const std::string& versionDescription);
|
||||||
virtual ~WindowManager();
|
virtual ~WindowManager();
|
||||||
|
|
||||||
|
/// Set the ESMStore to use for retrieving of GUI-related strings.
|
||||||
|
void setStore (const MWWorld::ESMStore& store);
|
||||||
|
|
||||||
void initUI();
|
void initUI();
|
||||||
void renderWorldMap();
|
void renderWorldMap();
|
||||||
|
|
||||||
|
@ -372,6 +380,7 @@ namespace MWGui
|
||||||
void writeFog(MWWorld::CellStore* cell);
|
void writeFog(MWWorld::CellStore* cell);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
const MWWorld::ESMStore* mStore;
|
||||||
Resource::ResourceSystem* mResourceSystem;
|
Resource::ResourceSystem* mResourceSystem;
|
||||||
|
|
||||||
osgMyGUI::Platform* mGuiPlatform;
|
osgMyGUI::Platform* mGuiPlatform;
|
||||||
|
|
Loading…
Reference in a new issue