Added the notion of a 'cancel' button, and unified all the 'cancel' menu IDs to be kCancelMenuID (ie -1). I've slaved the Menu button (ie Esc on win, 'Start' button on PSP) to this - the idea being, if you hit the Menu button to bring up a menu, hitting it again will dismiss it without doing anything, which is pretty standard behavior for most console/computer games.

This commit is contained in:
wrenczes@gmail.com
2010-11-07 02:08:17 +00:00
parent b0c61049da
commit 3c19533a4c
13 changed files with 303 additions and 274 deletions
+3
View File
@@ -25,6 +25,8 @@
#define JGUI_INITIAL_DELAY 0.4
#define JGUI_REPEAT_DELAY 0.2
const int kCancelMenuID = -1;
class JGuiListener
{
public:
@@ -71,6 +73,7 @@ class JGuiController
JButton mActionButton;
JButton mCancelButton;
int mCurr;
int mStyle;
+8
View File
@@ -76,6 +76,7 @@ JGuiController::JGuiController(int id, JGuiListener* listener) : mId(id), mListe
mShowCursor = false;
mActionButton = JGE_BTN_OK;
mCancelButton = JGE_BTN_MENU;
mStyle = JGUI_STYLE_WRAPPING;
@@ -110,6 +111,13 @@ bool JGuiController::CheckUserInput(JButton key){
return true;
}
}
else if (key == mCancelButton)
{
if (mListener != NULL)
{
mListener->ButtonPressed(mId, kCancelMenuID);
}
}
else if ((JGE_BTN_LEFT == key) || (JGE_BTN_UP == key)) // || mEngine->GetAnalogY() < 64 || mEngine->GetAnalogX() < 64)
{
int n = mCurr;
+2 -2
View File
@@ -53,12 +53,12 @@ enum DECK_VIEWER_MENU_ITEMS
{
MENU_ITEM_NEW_DECK = -30,
MENU_ITEM_CHEAT_MODE = -12,
MENU_ITEM_CANCEL = -1,
MENU_ITEM_CANCEL = kCancelMenuID,
MENU_ITEM_SAVE_RETURN_MAIN_MENU = 0,
MENU_ITEM_SAVE_RENAME = 1,
MENU_ITEM_SWITCH_DECKS_NO_SAVE = 2,
MENU_ITEM_MAIN_MENU = 3,
MENU_ITEM_EDITOR_CANCEL = 4,
MENU_ITEM_EDITOR_CANCEL = kCancelMenuID,
MENU_ITEM_SAVE_AS_AI_DECK = 5,
MENU_ITEM_YES = 20,
MENU_ITEM_NO = 21,
+2 -2
View File
@@ -57,8 +57,8 @@ class GameStateDuel: public GameState, public JGuiListener
enum ENUM_DUEL_STATE_MENU_ITEM
{
MENUITEM_NEW_DECK = -1,
MENUITEM_CANCEL = -10,
MENUITEM_CANCEL = kCancelMenuID,
MENUITEM_NEW_DECK = -10,
MENUITEM_RANDOM_PLAYER = -11,
MENUITEM_RANDOM_AI = -12,
MENUITEM_MAIN_MENU = -13,
+1 -1
View File
@@ -232,7 +232,7 @@ void ActionLayer::setMenuObject(Targetable * object, bool must){
abilitiesMenu->Add(i,currentAction->getMenuText());
}
}
if (!must) abilitiesMenu->Add(-1, "Cancel");
if (!must) abilitiesMenu->Add(kCancelMenuID, "Cancel");
else cantCancel = 1;
modal = 1;
}
+11 -5
View File
@@ -17,6 +17,12 @@ enum ENUM_AWARDS_STATE{
STATE_DETAILS,
};
namespace
{
const int kBackToTrophiesID = 2;
const int kBackToMainMenuID = 1;
}
GameStateAwards::GameStateAwards(GameApp* parent): GameState(parent){
}
@@ -164,9 +170,9 @@ void GameStateAwards::Update(float dt)
SAFE_DELETE(menu);
menu = NEW SimpleMenu(-102, this,Fonts::MENU_FONT, 50,170);
if(mState == STATE_DETAILS)
menu->Add(2, "Back to Trophies");
menu->Add(1, "Back to Main Menu");
menu->Add(3, "Cancel");
menu->Add(kBackToTrophiesID, "Back to Trophies");
menu->Add(kBackToMainMenuID, "Back to Main Menu");
menu->Add(kCancelMenuID, "Cancel");
break;
case JGE_BTN_PREV:
mParent->DoTransition(TRANSITION_FADE,GAME_STATE_MENU);
@@ -321,11 +327,11 @@ void GameStateAwards::ButtonPressed(int controllerId, int controlId)
{
if(controllerId == -102)
switch (controlId){
case 1:
case kBackToMainMenuID:
mParent->DoTransition(TRANSITION_FADE,GAME_STATE_MENU);
showMenu = false;
break;
case 2:
case kBackToTrophiesID:
mState = STATE_LISTVIEW;
SAFE_DELETE(detailview);
showMenu = false;
+2 -2
View File
@@ -129,7 +129,7 @@ void GameStateDuel::Start()
fillDeckMenu(deckmenu,RESPATH"/player/premade");
}
deckmenu->Add( MENUITEM_NEW_DECK, "New Deck...", "Create a new deck to play with.");
deckmenu->Add( MENUITEM_MAIN_MENU, "Main Menu", "Return to Main Menu");
deckmenu->Add( MENUITEM_CANCEL, "Main Menu", "Return to Main Menu");
}
for (int i = 0; i < 2; ++i){
@@ -556,7 +556,7 @@ void GameStateDuel::ButtonPressed(int controllerId, int controlId) {
mGamePhase = DUEL_STATE_CHOOSE_DECK2_TO_PLAY;
break;
}
else if (controlId == MENUITEM_MAIN_MENU ) // user clicked on "Cancel"
else if (controlId == MENUITEM_MAIN_MENU || controlId == MENUITEM_CANCEL ) // user clicked on "Cancel"
{
if (deckmenu)
deckmenu->Close();
+4 -1
View File
@@ -50,6 +50,7 @@ enum ENUM_MENU_STATE_MINOR
enum
{
SUBMENUITEM_CANCEL = kCancelMenuID,
MENUITEM_PLAY,
MENUITEM_DECKEDITOR,
MENUITEM_SHOP,
@@ -58,7 +59,6 @@ enum
SUBMENUITEM_1PLAYER,
SUBMENUITEM_2PLAYER,
SUBMENUITEM_DEMO,
SUBMENUITEM_CANCEL,
SUBMENUITEM_TESTSUITE,
SUBMENUITEM_MOMIR,
SUBMENUITEM_CLASSIC,
@@ -698,7 +698,10 @@ void GameStateMenu::ButtonPressed(int controllerId, int controlId)
currentState = MENU_STATE_MAJOR_DUEL | MENU_STATE_MINOR_SUBMENU_CLOSING;
break;
case SUBMENUITEM_CANCEL:
if (subMenuController != NULL)
{
subMenuController->Close();
}
currentState = MENU_STATE_MAJOR_MAINMENU | MENU_STATE_MINOR_SUBMENU_CLOSING;
break;
+18 -9
View File
@@ -8,6 +8,15 @@
#include "GameOptions.h"
#include "Translate.h"
namespace
{
const int kSaveAndBackToMainMenuID = 1;
const int kBackToMainMenuID = 2;
const int kNewProfileID = 4;
const int kReloadID = 5;
}
GameStateOptions::GameStateOptions(GameApp* parent): GameState(parent), mReload(false), grabber(NULL), optionsMenu(NULL), optionsTabs(NULL) {}
GameStateOptions::~GameStateOptions() {}
@@ -62,7 +71,7 @@ void GameStateOptions::Start()
optionsList->Add(NEW WGuiSplit(cPrf,cThm));
optionsList->Add(cStyle);
optionsList->Add(NEW WGuiButton(NEW WGuiHeader("New Profile"),-102,4,this));
optionsList->Add(NEW WGuiButton(NEW WGuiHeader("New Profile"),-102, kNewProfileID, this));
optionsList->Add(NEW WDecoCheat(NEW OptionInteger(Options::CHEATMODE, "Enable cheat mode")));
optionsTabs->Add(optionsList);
@@ -89,9 +98,9 @@ void GameStateOptions::Start()
optionsTabs->Add(optionsList);
optionsMenu = NEW SimpleMenu(-102, this,Fonts::MENU_FONT, 50,170);
optionsMenu->Add(2, "Back to Main Menu");
optionsMenu->Add(1, "Save & Back to Main Menu");
optionsMenu->Add(3, "Cancel");
optionsMenu->Add(kBackToMainMenuID, "Back to Main Menu");
optionsMenu->Add(kSaveAndBackToMainMenuID, "Save & Back to Main Menu");
optionsMenu->Add(kCancelMenuID, "Cancel");
optionsTabs->Entering(JGE_BTN_NONE);
}
@@ -245,21 +254,21 @@ void GameStateOptions::ButtonPressed(int controllerId, int controlId)
//Exit menu?
if(controllerId == -102)
switch (controlId){
case 1:
case kSaveAndBackToMainMenuID:
mState = SAVE;
break;
//Set Audio volume
case 2:
case kBackToMainMenuID:
mParent->DoTransition(TRANSITION_FADE,GAME_STATE_MENU);
break;
case 3:
case kCancelMenuID:
mState = SHOW_OPTIONS;
break;
case 4:
case kNewProfileID:
options.keypadStart("",&newProfile);
options.keypadTitle("New Profile");
break;
case 5:
case kReloadID:
mReload = true;
break;
}
+2 -2
View File
@@ -417,7 +417,7 @@ void GameStateShop::Update(float dt)
if (options[Options::CHEATMODE].number)
menu->Add(-2,"Steal 1,000 credits");
menu->Add(12,"Save & Back to Main Menu");
menu->Add(13, "Cancel");
menu->Add(kCancelMenuID, "Cancel");
}
break;
case STAGE_SHOP_TASKS:
@@ -437,7 +437,7 @@ void GameStateShop::Update(float dt)
menu = NEW SimpleMenu(11,this,Fonts::MENU_FONT,SCREEN_WIDTH/2-100,20);
menu->Add(15,"Return to shop");
menu->Add(12,"Save & Back to Main Menu");
menu->Add(13, "Cancel");
menu->Add(kCancelMenuID, "Cancel");
}
}
}
+2 -2
View File
@@ -48,7 +48,7 @@ void GameStateStory::loadStoriesMenu(const char * root){
for (size_t i = 0; i < stories.size(); ++i){
menu->Add(i, stories[i].c_str());
}
menu->Add(-1,"Cancel");
menu->Add(kCancelMenuID, "Cancel");
}
}
@@ -62,7 +62,7 @@ void GameStateStory::Update(float dt) {
if (!menu && mEngine->GetButtonClick(JGE_BTN_MENU)){
menu = NEW SimpleMenu(100, this, Fonts::MENU_FONT, SCREEN_WIDTH/2-100, 25);
menu->Add(0,"Back to main menu");
menu->Add(-1, "Cancel");
menu->Add(kCancelMenuID, "Cancel");
}
if (menu) {
menu->Update(dt);
+2 -2
View File
@@ -1649,7 +1649,7 @@ void WGuiFilterItem::updateValue(){
}
if(!mNew)
mParent->subMenu->Add(-2,"Remove");
mParent->subMenu->Add(-1,"Cancel");
mParent->subMenu->Add(kCancelMenuID,"Cancel");
if(delMenu){
SAFE_DELETE(mParent->subMenu);
mState = STATE_FINISHED;
@@ -1754,7 +1754,7 @@ void WGuiFilterItem::updateValue(){
}
mParent->addArg("Digit","alpha:#;");
}
mParent->subMenu->Add(-1,"Cancel");
mParent->subMenu->Add(kCancelMenuID,"Cancel");
break;
case STATE_CHOOSE_VAL:
mState = STATE_FINISHED;