Fixed inventory crash and skipmenu launch

This commit is contained in:
Andrei Kortunov 2017-04-12 22:57:32 +04:00
parent 72a16dc78b
commit c3d49d5ca5
5 changed files with 28 additions and 9 deletions

View file

@ -104,6 +104,7 @@ namespace MWBase
* new dialogs. * new dialogs.
*/ */
virtual void update() = 0; virtual void update() = 0;
virtual void updateVisible() = 0;
/// @note This method will block until the video finishes playing /// @note This method will block until the video finishes playing
/// (and will continually update the window while doing so) /// (and will continually update the window while doing so)

View file

@ -780,7 +780,7 @@ namespace MWGui
void MapWindow::setVisible(bool visible) void MapWindow::setVisible(bool visible)
{ {
WindowBase::setVisible(visible); WindowBase::setVisible(visible);
mButton->setVisible(visible && MWBase::Environment::get().getWindowManager()->isGuiMode()); mButton->setVisible(visible && MWBase::Environment::get().getWindowManager()->getMode() != MWGui::GM_None);
} }
void MapWindow::renderGlobalMap() void MapWindow::renderGlobalMap()

View file

@ -368,6 +368,8 @@ namespace MWGui
mPlayerSkillValues.insert(std::make_pair(ESM::Skill::sSkillIds[i], MWMechanics::SkillValue())); mPlayerSkillValues.insert(std::make_pair(ESM::Skill::sSkillIds[i], MWMechanics::SkillValue()));
} }
updatePinnedWindows();
// Set up visibility // Set up visibility
updateVisible(); updateVisible();
@ -400,11 +402,6 @@ namespace MWGui
allow(GW_ALL); allow(GW_ALL);
mRestAllowed = !newgame; mRestAllowed = !newgame;
mStatsWindow->setPinned(Settings::Manager::getBool("stats pin", "Windows"));
mMap->setPinned(Settings::Manager::getBool("map pin", "Windows"));
mSpellWindow->setPinned(Settings::Manager::getBool("spells pin", "Windows"));
mInventoryWindow->setPinned(Settings::Manager::getBool("inventory pin", "Windows"));
} }
WindowManager::~WindowManager() WindowManager::~WindowManager()
@ -492,7 +489,6 @@ namespace MWGui
void WindowManager::update() void WindowManager::update()
{ {
cleanupGarbage(); cleanupGarbage();
mHud->update(); mHud->update();
} }
@ -560,6 +556,12 @@ namespace MWGui
{ {
mInventoryWindow->setGuiMode(GM_None); mInventoryWindow->setGuiMode(GM_None);
// If game is not running, we can't be sure that widgets are initialized properly
MWBase::StateManager::State state = MWBase::Environment::get().getStateManager()->getState();
if (state != MWBase::StateManager::State_Running)
return;
mMap->setVisible(mMap->pinned() && !(mForceHidden & GW_Map) && (mAllowed & GW_Map)); mMap->setVisible(mMap->pinned() && !(mForceHidden & GW_Map) && (mAllowed & GW_Map));
mStatsWindow->setVisible(mStatsWindow->pinned() && !(mForceHidden & GW_Stats) && (mAllowed & GW_Stats)); mStatsWindow->setVisible(mStatsWindow->pinned() && !(mForceHidden & GW_Stats) && (mAllowed & GW_Stats));
mInventoryWindow->setVisible(mInventoryWindow->pinned() && !(mForceHidden & GW_Inventory) && (mAllowed & GW_Inventory)); mInventoryWindow->setVisible(mInventoryWindow->pinned() && !(mForceHidden & GW_Inventory) && (mAllowed & GW_Inventory));
@ -1709,6 +1711,8 @@ namespace MWGui
mCompanionWindow->resetReference(); mCompanionWindow->resetReference();
mConsole->resetReference(); mConsole->resetReference();
mInventoryWindow->rebuildAvatar();
mSelectedSpell.clear(); mSelectedSpell.clear();
mCustomMarkers.clear(); mCustomMarkers.clear();
@ -1868,6 +1872,17 @@ namespace MWGui
mVideoWidget->stop(); mVideoWidget->stop();
} }
void WindowManager::updatePinnedWindows()
{
mInventoryWindow->setPinned(Settings::Manager::getBool("inventory pin", "Windows"));
mMap->setPinned(Settings::Manager::getBool("map pin", "Windows"));
mSpellWindow->setPinned(Settings::Manager::getBool("spells pin", "Windows"));
mStatsWindow->setPinned(Settings::Manager::getBool("stats pin", "Windows"));
}
void WindowManager::pinWindow(GuiWindow window) void WindowManager::pinWindow(GuiWindow window)
{ {
switch (window) switch (window)

View file

@ -362,6 +362,8 @@ namespace MWGui
virtual void pinWindow (MWGui::GuiWindow window); virtual void pinWindow (MWGui::GuiWindow window);
virtual void updatePinnedWindows ();
/// Fade the screen in, over \a time seconds /// Fade the screen in, over \a time seconds
virtual void fadeScreenIn(const float time, bool clearQueue); virtual void fadeScreenIn(const float time, bool clearQueue);
/// Fade the screen out to black, over \a time seconds /// Fade the screen out to black, over \a time seconds

View file

@ -139,8 +139,7 @@ void MWState::StateManager::newGame (bool bypass)
{ {
cleanup(); cleanup();
if (!bypass) MWBase::Environment::get().getWindowManager()->setNewGame (!bypass);
MWBase::Environment::get().getWindowManager()->setNewGame (true);
try try
{ {
@ -149,6 +148,8 @@ void MWState::StateManager::newGame (bool bypass)
MWBase::Environment::get().getWorld()->startNewGame (bypass); MWBase::Environment::get().getWorld()->startNewGame (bypass);
mState = State_Running; mState = State_Running;
MWBase::Environment::get().getWindowManager()->updateVisible();
} }
catch (std::exception& e) catch (std::exception& e)
{ {