Cleanup, replaced if with switch

This commit is contained in:
Eli2 2012-03-31 19:50:21 +02:00
parent 08f8701b33
commit 3cc81d74bc

View file

@ -180,71 +180,57 @@ void WindowManager::updateVisible()
// Mouse is visible whenever we're not in game mode // Mouse is visible whenever we're not in game mode
MyGUI::PointerManager::getInstance().setVisible(isGuiMode()); MyGUI::PointerManager::getInstance().setVisible(isGuiMode());
int eff;
switch(mode) {
case GM_Game:
// If in game mode, don't show anything. // If in game mode, don't show anything.
if(mode == GM_Game) //Use a switch/case structure break;
{ case GM_MainMenu:
return;
}
if(mode == GM_MainMenu)
{
// Enable the main menu
menu->setVisible(true); menu->setVisible(true);
return; break;
} case GM_Console:
if(mode == GM_Console)
{
console->enable(); console->enable();
return; break;
} case GM_Name:
case GM_Race:
//There must be a more elegant solution case GM_Class:
if (mode == GM_Name || mode == GM_Race || mode == GM_Class || mode == GM_ClassPick || mode == GM_ClassCreate || mode == GM_Birth || mode == GM_ClassGenerate || mode == GM_Review) case GM_ClassPick:
{ case GM_ClassCreate:
case GM_Birth:
case GM_ClassGenerate:
case GM_Review:
mCharGen->spawnDialog(mode); mCharGen->spawnDialog(mode);
return; break;
} case GM_Inventory:
// First, compute the effective set of windows to show.
if(mode == GM_Inventory) // This is controlled both by what windows the
{
// Ah, inventory mode. First, compute the effective set of
// windows to show. This is controlled both by what windows the
// user has opened/closed (the 'shown' variable) and by what // user has opened/closed (the 'shown' variable) and by what
// windows we are allowed to show (the 'allowed' var.) // windows we are allowed to show (the 'allowed' var.)
int eff = shown & allowed; eff = shown & allowed;
// Show the windows we want // Show the windows we want
map -> setVisible( (eff & GW_Map) != 0 ); map -> setVisible( (eff & GW_Map) != 0 );
stats -> setVisible( (eff & GW_Stats) != 0 ); stats -> setVisible( (eff & GW_Stats) != 0 );
return; break;
} case GM_Dialogue:
if (mode == GM_Dialogue)
{
dialogueWindow->open(); dialogueWindow->open();
return; break;
} case GM_InterMessageBox:
if(mode == GM_InterMessageBox)
{
if(!mMessageBoxManager->isInteractiveMessageBox()) { if(!mMessageBoxManager->isInteractiveMessageBox()) {
setGuiMode(GM_Game); setGuiMode(GM_Game);
} }
return; break;
} case GM_Journal:
if(mode == GM_Journal)
{
mJournal->setVisible(true); mJournal->setVisible(true);
mJournal->open(); mJournal->open();
return; break;
} default:
// Unsupported mode, switch back to game // Unsupported mode, switch back to game
// Note: The call will eventually end up this method again but // Note: The call will eventually end up this method again but
// will stop at the check if(mode == GM_Game) above. // will stop at the check if mode is GM_Game.
setGuiMode(GM_Game); setGuiMode(GM_Game);
break;
}
} }
void WindowManager::setValue (const std::string& id, const MWMechanics::Stat<int>& value) void WindowManager::setValue (const std::string& id, const MWMechanics::Stat<int>& value)