Put constans into extra namespace as kBackToMainMenuID...

collides with itself. GameStateAwards::kBackToMainMenuID and
GameStateOptions::kBackToMainMenuID define those with different
values.
This commit is contained in:
Tobias Loose
2013-11-23 16:18:45 +01:00
parent 1e8fc81aa3
commit 9f0b70d1c9
2 changed files with 13 additions and 14 deletions
+5 -5
View File
@@ -21,7 +21,7 @@ enum ENUM_AWARDS_STATE
}; };
namespace namespace GameStateAwardsConstants
{ {
const int kBackToTrophiesID = 2; const int kBackToTrophiesID = 2;
const int kBackToMainMenuID = 1; const int kBackToMainMenuID = 1;
@@ -186,8 +186,8 @@ void GameStateAwards::Update(float dt)
SAFE_DELETE(menu); SAFE_DELETE(menu);
menu = NEW SimpleMenu(JGE::GetInstance(), WResourceManager::Instance(), EXIT_AWARDS_MENU, this, Fonts::MENU_FONT, 50, 170); menu = NEW SimpleMenu(JGE::GetInstance(), WResourceManager::Instance(), EXIT_AWARDS_MENU, this, Fonts::MENU_FONT, 50, 170);
if (mState == STATE_DETAILS) if (mState == STATE_DETAILS)
menu->Add(kBackToTrophiesID, "Back to Trophies"); menu->Add(GameStateAwardsConstants::kBackToTrophiesID, "Back to Trophies");
menu->Add(kBackToMainMenuID, "Back to Main Menu"); menu->Add(GameStateAwardsConstants::kBackToMainMenuID, "Back to Main Menu");
menu->Add(kCancelMenuID, "Cancel"); menu->Add(kCancelMenuID, "Cancel");
break; break;
case JGE_BTN_PREV: case JGE_BTN_PREV:
@@ -359,11 +359,11 @@ void GameStateAwards::ButtonPressed(int controllerId, int controlId)
if (controllerId == EXIT_AWARDS_MENU) if (controllerId == EXIT_AWARDS_MENU)
switch (controlId) switch (controlId)
{ {
case kBackToMainMenuID: case GameStateAwardsConstants::kBackToMainMenuID:
mParent->DoTransition(TRANSITION_FADE, GAME_STATE_MENU); mParent->DoTransition(TRANSITION_FADE, GAME_STATE_MENU);
showMenu = false; showMenu = false;
break; break;
case kBackToTrophiesID: case GameStateAwardsConstants::kBackToTrophiesID:
mState = STATE_LISTVIEW; mState = STATE_LISTVIEW;
SAFE_DELETE(detailview); SAFE_DELETE(detailview);
showMenu = false; showMenu = false;
+8 -9
View File
@@ -7,13 +7,12 @@
#include "SimplePad.h" #include "SimplePad.h"
#include "Translate.h" #include "Translate.h"
namespace namespace GameStateOptionsConstants
{ {
const int kSaveAndBackToMainMenuID = 1; const int kSaveAndBackToMainMenuID = 1;
const int kBackToMainMenuID = 2; const int kBackToMainMenuID = 2;
const int kNewProfileID = 4; const int kNewProfileID = 4;
const int kReloadID = 5; const int kReloadID = 5;
} }
GameStateOptions::GameStateOptions(GameApp* parent) : GameStateOptions::GameStateOptions(GameApp* parent) :
@@ -78,7 +77,7 @@ void GameStateOptions::Start()
optionsList->Add(NEW WGuiSplit(cPrf, cThm)); optionsList->Add(NEW WGuiSplit(cPrf, cThm));
optionsList->Add(cStyle); optionsList->Add(cStyle);
optionsList->Add(NEW WGuiButton(NEW WGuiHeader("New Profile"), -102, kNewProfileID, this)); optionsList->Add(NEW WGuiButton(NEW WGuiHeader("New Profile"), -102, GameStateOptionsConstants::kNewProfileID, this));
optionsList->Add(NEW WDecoCheat(NEW OptionInteger(Options::CHEATMODE, "Enable Cheat Mode"))); optionsList->Add(NEW WDecoCheat(NEW OptionInteger(Options::CHEATMODE, "Enable Cheat Mode")));
optionsList->Add(NEW WDecoCheat(NEW OptionInteger(Options::OPTIMIZE_HAND, "Optimize Starting Hand"))); optionsList->Add(NEW WDecoCheat(NEW OptionInteger(Options::OPTIMIZE_HAND, "Optimize Starting Hand")));
@@ -118,8 +117,8 @@ void GameStateOptions::Start()
optionsTabs->Add(optionsList); optionsTabs->Add(optionsList);
optionsMenu = NEW SimpleMenu(JGE::GetInstance(), WResourceManager::Instance(), -102, this, Fonts::MAIN_FONT, 50, 170); optionsMenu = NEW SimpleMenu(JGE::GetInstance(), WResourceManager::Instance(), -102, this, Fonts::MAIN_FONT, 50, 170);
optionsMenu->Add(kBackToMainMenuID, "Back to Main Menu"); optionsMenu->Add(GameStateOptionsConstants::kBackToMainMenuID, "Back to Main Menu");
optionsMenu->Add(kSaveAndBackToMainMenuID, "Save And Exit"); optionsMenu->Add(GameStateOptionsConstants::kSaveAndBackToMainMenuID, "Save And Exit");
optionsMenu->Add(kCancelMenuID, "Cancel"); optionsMenu->Add(kCancelMenuID, "Cancel");
optionsTabs->Entering(JGE_BTN_NONE); optionsTabs->Entering(JGE_BTN_NONE);
@@ -285,21 +284,21 @@ void GameStateOptions::ButtonPressed(int controllerId, int controlId)
if (controllerId == -102) if (controllerId == -102)
switch (controlId) switch (controlId)
{ {
case kSaveAndBackToMainMenuID: case GameStateOptionsConstants::kSaveAndBackToMainMenuID:
mState = SAVE; mState = SAVE;
break; break;
//Set Audio volume //Set Audio volume
case kBackToMainMenuID: case GameStateOptionsConstants::kBackToMainMenuID:
mParent->DoTransition(TRANSITION_FADE, GAME_STATE_MENU); mParent->DoTransition(TRANSITION_FADE, GAME_STATE_MENU);
break; break;
case kCancelMenuID: case kCancelMenuID:
mState = SHOW_OPTIONS; mState = SHOW_OPTIONS;
break; break;
case kNewProfileID: case GameStateOptionsConstants::kNewProfileID:
options.keypadStart("", &newProfile); options.keypadStart("", &newProfile);
options.keypadTitle("New Profile"); options.keypadTitle("New Profile");
break; break;
case kReloadID: case GameStateOptionsConstants::kReloadID:
mReload = true; mReload = true;
break; break;
} }