Fix for dereferencing past end of mGuiModes.

pull/144/head
slothlife 11 years ago
parent f130f8535c
commit 281d3b4c95

@ -442,128 +442,131 @@ namespace MWGui
return; return;
} }
GuiMode mode = mGuiModes.back(); if(mGuiModes.size() != 0)
{
switch(mode) { GuiMode mode = mGuiModes.back();
case GM_QuickKeysMenu:
mQuickKeysMenu->setVisible (true); switch(mode) {
break; case GM_QuickKeysMenu:
case GM_MainMenu: mQuickKeysMenu->setVisible (true);
mMenu->setVisible(true); break;
break; case GM_MainMenu:
case GM_Settings: mMenu->setVisible(true);
mSettingsWindow->setVisible(true); break;
break; case GM_Settings:
case GM_Console: mSettingsWindow->setVisible(true);
mConsole->setVisible(true); break;
break; case GM_Console:
case GM_Scroll: mConsole->setVisible(true);
mScrollWindow->setVisible(true); break;
break; case GM_Scroll:
case GM_Book: mScrollWindow->setVisible(true);
mBookWindow->setVisible(true); break;
break; case GM_Book:
case GM_Alchemy: mBookWindow->setVisible(true);
mAlchemyWindow->setVisible(true); break;
break; case GM_Alchemy:
case GM_Rest: mAlchemyWindow->setVisible(true);
mWaitDialog->setVisible(true); break;
break; case GM_Rest:
case GM_RestBed: mWaitDialog->setVisible(true);
mWaitDialog->setVisible(true); break;
mWaitDialog->bedActivated(); case GM_RestBed:
break; mWaitDialog->setVisible(true);
case GM_Levelup: mWaitDialog->bedActivated();
mLevelupDialog->setVisible(true); break;
break; case GM_Levelup:
case GM_Name: mLevelupDialog->setVisible(true);
case GM_Race: break;
case GM_Class: case GM_Name:
case GM_ClassPick: case GM_Race:
case GM_ClassCreate: case GM_Class:
case GM_Birth: case GM_ClassPick:
case GM_ClassGenerate: case GM_ClassCreate:
case GM_Review: case GM_Birth:
mCharGen->spawnDialog(mode); case GM_ClassGenerate:
break; case GM_Review:
case GM_Inventory: mCharGen->spawnDialog(mode);
{ break;
// First, compute the effective set of windows to show. case GM_Inventory:
// This is controlled both by what windows the {
// user has opened/closed (the 'shown' variable) and by what // First, compute the effective set of windows to show.
// windows we are allowed to show (the 'allowed' var.) // This is controlled both by what windows the
int eff = mShown & mAllowed & ~mForceHidden; // user has opened/closed (the 'shown' variable) and by what
// windows we are allowed to show (the 'allowed' var.)
// Show the windows we want int eff = mShown & mAllowed & ~mForceHidden;
mMap ->setVisible(eff & GW_Map);
mStatsWindow ->setVisible(eff & GW_Stats); // Show the windows we want
mInventoryWindow->setVisible(eff & GW_Inventory); mMap ->setVisible(eff & GW_Map);
mInventoryWindow->setGuiMode(mode); mStatsWindow ->setVisible(eff & GW_Stats);
mSpellWindow ->setVisible(eff & GW_Magic); mInventoryWindow->setVisible(eff & GW_Inventory);
break; mInventoryWindow->setGuiMode(mode);
mSpellWindow ->setVisible(eff & GW_Magic);
break;
}
case GM_Container:
mContainerWindow->setVisible(true);
mInventoryWindow->setVisible(true);
mInventoryWindow->setGuiMode(mode);
break;
case GM_Companion:
mCompanionWindow->setVisible(true);
mInventoryWindow->setVisible(true);
mInventoryWindow->setGuiMode(mode);
break;
case GM_Dialogue:
mDialogueWindow->setVisible(true);
break;
case GM_Barter:
mInventoryWindow->setVisible(true);
mInventoryWindow->setTrading(true);
mInventoryWindow->setGuiMode(mode);
mTradeWindow->setVisible(true);
break;
case GM_SpellBuying:
mSpellBuyingWindow->setVisible(true);
break;
case GM_Travel:
mTravelWindow->setVisible(true);
break;
case GM_SpellCreation:
mSpellCreationDialog->setVisible(true);
break;
case GM_Recharge:
mRecharge->setVisible(true);
break;
case GM_Enchanting:
mEnchantingDialog->setVisible(true);
break;
case GM_Training:
mTrainingWindow->setVisible(true);
break;
case GM_MerchantRepair:
mMerchantRepair->setVisible(true);
break;
case GM_Repair:
mRepair->setVisible(true);
break;
case GM_Journal:
mJournal->setVisible(true);
break;
case GM_LoadingWallpaper:
mHud->setVisible(false);
setCursorVisible(false);
break;
case GM_Loading:
// Show the pinned windows
mMap->setVisible(mMap->pinned() && !(mForceHidden & GW_Map));
mStatsWindow->setVisible(mStatsWindow->pinned() && !(mForceHidden & GW_Stats));
mInventoryWindow->setVisible(mInventoryWindow->pinned() && !(mForceHidden & GW_Inventory));
mSpellWindow->setVisible(mSpellWindow->pinned() && !(mForceHidden & GW_Magic));
setCursorVisible(false);
break;
default:
// Unsupported mode, switch back to game
break;
} }
case GM_Container:
mContainerWindow->setVisible(true);
mInventoryWindow->setVisible(true);
mInventoryWindow->setGuiMode(mode);
break;
case GM_Companion:
mCompanionWindow->setVisible(true);
mInventoryWindow->setVisible(true);
mInventoryWindow->setGuiMode(mode);
break;
case GM_Dialogue:
mDialogueWindow->setVisible(true);
break;
case GM_Barter:
mInventoryWindow->setVisible(true);
mInventoryWindow->setTrading(true);
mInventoryWindow->setGuiMode(mode);
mTradeWindow->setVisible(true);
break;
case GM_SpellBuying:
mSpellBuyingWindow->setVisible(true);
break;
case GM_Travel:
mTravelWindow->setVisible(true);
break;
case GM_SpellCreation:
mSpellCreationDialog->setVisible(true);
break;
case GM_Recharge:
mRecharge->setVisible(true);
break;
case GM_Enchanting:
mEnchantingDialog->setVisible(true);
break;
case GM_Training:
mTrainingWindow->setVisible(true);
break;
case GM_MerchantRepair:
mMerchantRepair->setVisible(true);
break;
case GM_Repair:
mRepair->setVisible(true);
break;
case GM_Journal:
mJournal->setVisible(true);
break;
case GM_LoadingWallpaper:
mHud->setVisible(false);
setCursorVisible(false);
break;
case GM_Loading:
// Show the pinned windows
mMap->setVisible(mMap->pinned() && !(mForceHidden & GW_Map));
mStatsWindow->setVisible(mStatsWindow->pinned() && !(mForceHidden & GW_Stats));
mInventoryWindow->setVisible(mInventoryWindow->pinned() && !(mForceHidden & GW_Inventory));
mSpellWindow->setVisible(mSpellWindow->pinned() && !(mForceHidden & GW_Magic));
setCursorVisible(false);
break;
default:
// Unsupported mode, switch back to game
break;
} }
} }

Loading…
Cancel
Save