Commit 04497fc8 authored by Gerhard Stein's avatar Gerhard Stein

Cleanups and ESC works for menus again

parent 9d96f212
......@@ -309,7 +309,8 @@ inline std::string itoa(unsigned long num, short base=10) {
}
// std::string itoa
inline std::string itoa(long num, short base=10) {
inline std::string itoa(long num, short base=10)
{
if(num >= 0)
return itoa((unsigned long)num, base);
else
......
......@@ -159,7 +159,7 @@ void CMenu::process()
}
}
if( g_pInput->getPressedCommand(IC_QUIT) )
if( g_pInput->getPressedCommand(IC_BACK) )
{
if(m_menu_mode == PASSIVE)
m_SubMenus.push_back(new CConfirmMenu(" Quit the game? ", m_quit, m_dlg_theme));
......
......@@ -32,8 +32,6 @@ const std::string actionsnames[MAX_COMMANDS] =
};
/**
* \brief This sets the default settings for a classic gameplay
*/
......@@ -133,55 +131,3 @@ void CControlsettings::release()
g_pInput->setTwoButtonFiring(mSelectedPlayer-1, mpTwoButtonSwitch->isEnabled() );
g_pInput->saveControlconfig();
}
//void CControlsettings::setControlsText()
//{
// Here it sets up the items after the player number was chosen
// Then create the controls selection screen
/*std::string buf, buf2;
for(unsigned int i=0 ; i<MAX_COMMANDS ; i++)
{
buf2 = g_pInput->getEventName(IC_LEFT+i, m_chosenPlayer-1);
buf = actionsnames[i] + buf2;
mp_Dialog->setObjectText(i, buf);
}
buf = "Two Button Firing " + getSwitchString(g_pInput->getTwoButtonFiring(m_chosenPlayer-1));
mp_Dialog->m_dlgobject.at(MAX_COMMANDS)->m_Option->m_FontMapID = 1;
mp_Dialog->setObjectText(MAX_COMMANDS, buf);*/
//}
//void CControlsettings::processSpecific()
//{
/*if(!m_suspended)
{
if(m_waiting_for_input) // This part only happens, when waiting for an input
processWaitInput();
else
processSelection();
}
else
{
mp_SubMenu->processCommon();
mp_SubMenu->processSpecific();
mp_SubMenu->postProcess();
if(mp_SubMenu->mustClose())
{
SAFE_DELETE(mp_SubMenu);
m_suspended = false;
if(m_chosenPlayer == 0)
{
m_mustclose = true;
m_suspended = true;
}
else
setControlsText();
}
}*/
//}
......@@ -8,6 +8,8 @@
#include "CMenuController.h"
#include "common/CBehaviorEngine.h"
#include "common/Menu/CControlsettings.h"
#include "common/Menu/CMainMenu.h"
#include "sdl/input/CInput.h"
void CMenuController::process()
{
......@@ -15,6 +17,22 @@ void CMenuController::process()
// process any triggered Game Control related event
CEventContainer &EventContainer = g_pBehaviorEngine->EventList();
// Did the player press the quit/back button
if( g_pInput->getPressedCommand(IC_BACK) )
{
if( mMenuStack.empty() ) // If no menu is open, open the main menu
{
EventContainer.add( new OpenMenuEvent( new CMainMenu(DLG_THEME_VORTICON) ) );
}
else // Close the menu which is open. Might go back if it is a submenu
{
EventContainer.add( new CloseMenuEvent() );
}
}
if(!EventContainer.empty())
{
......
......@@ -96,7 +96,6 @@ void CGameControl::process()
{
mp_GameMode = new CGamePassiveMode( p_Passive->m_DataDirectory, p_Passive->m_Episode );
mp_GameMode->init();
g_pBehaviorEngine->EventList().add( new OpenMenuEvent( new CMainMenu(DLG_THEME_VORTICON) ) );
EventContainer.pop_Event();
}
else if( GMSwitchToPlayGameMode* p_PlayGame = EventContainer.occurredEvent<GMSwitchToPlayGameMode>() )
......
......@@ -248,7 +248,7 @@ void CPlayGameGalaxy::process()
void CPlayGameGalaxy::processInput()
{
// open the menu
if(g_pInput->getPressedCommand(IC_QUIT))
if(g_pInput->getPressedCommand(IC_BACK))
{
//mp_Menu = new CMenuGalaxy(ACTIVE, m_SavedGame, m_restartVideo);
m_BackgroundBitmap = *g_pGfxEngine->getBitmap("KEENSWATCH");
......
......@@ -97,7 +97,7 @@ void CPreviews::showText()
// This is called after the preview screens were shown
mp_TextViewer->process();
if( mp_TextViewer->hasClosed() || g_pInput->getPressedCommand(IC_QUIT) )
if( mp_TextViewer->hasClosed() || g_pInput->getPressedCommand(IC_BACK) )
{
m_destroy_me = true;
}
......
......@@ -90,7 +90,7 @@ void CInput::resetControls(int player) {
InputCommand[i][IC_STATUS].keysym = SDLK_RETURN;
InputCommand[i][IC_HELP].keysym = SDLK_F1;
InputCommand[i][IC_QUIT].keysym = SDLK_ESCAPE;
InputCommand[i][IC_BACK].keysym = SDLK_ESCAPE;
// And those are the default joystick handlings, but they are disabled by default
InputCommand[i][IC_LEFT].joyeventtype = ETYPE_KEYBOARD;
......@@ -125,9 +125,9 @@ void CInput::resetControls(int player) {
InputCommand[i][IC_HELP].joyeventtype = ETYPE_KEYBOARD;
InputCommand[i][IC_HELP].joybutton = 4;
InputCommand[i][IC_HELP].which = 0;
InputCommand[i][IC_QUIT].joyeventtype = ETYPE_KEYBOARD;
InputCommand[i][IC_QUIT].joybutton = 5;
InputCommand[i][IC_QUIT].which = 0;
InputCommand[i][IC_BACK].joyeventtype = ETYPE_KEYBOARD;
InputCommand[i][IC_BACK].joybutton = 5;
InputCommand[i][IC_BACK].which = 0;
#ifdef ANDROID
// Joystick input is broken in main menu and dialogs, so disabled for now
......@@ -229,8 +229,8 @@ void CInput::loadControlconfig(void)
setupInputCommand( InputCommand[i], IC_STATUS, value );
Configuration.ReadString( section, "Help", value, "Key 282 (f1)");
setupInputCommand( InputCommand[i], IC_HELP, value );
Configuration.ReadString( section, "Quit", value, "Key 27 (escape)");
setupInputCommand( InputCommand[i], IC_QUIT, value );
Configuration.ReadString( section, "Back", value, "Key 27 (escape)");
setupInputCommand( InputCommand[i], IC_BACK, value );
Configuration.ReadKeyword( section, "TwoButtonFiring", &TwoButtonFiring[i], false);
}
}
......@@ -268,7 +268,7 @@ void CInput::saveControlconfig()
Configuration.WriteString(section, "Fire", getEventName(IC_FIRE, i));
Configuration.WriteString(section, "Status", getEventName(IC_STATUS, i));
Configuration.WriteString(section, "Help", getEventName(IC_HELP, i));
Configuration.WriteString(section, "Quit", getEventName(IC_QUIT, i));
Configuration.WriteString(section, "Back", getEventName(IC_BACK, i));
Configuration.SetKeyword(section, "TwoButtonFiring", TwoButtonFiring[i]);
}
Configuration.saveCfgFile();
......@@ -1110,7 +1110,7 @@ static TouchButton* getPhoneButtons(stInputCommand InputCommand[NUM_INPUTS][MAX_
{ &InputCommand[0][IC_FIRE], KSPACE, middlex + w / 3, middley, w / 6, h / 2},
{ &InputCommand[0][IC_STATUS], KENTER, 0, 0, w/2, h/4},
{ &InputCommand[0][IC_QUIT], KQUIT, 5*w/6, 0, w/6, h/6},
{ &InputCommand[0][IC_BACK], KQUIT, 5*w/6, 0, w/6, h/6},
{ NULL, KSHOWHIDECTRLS, 4*w/6, 0, w/6, h/6},
// { NULL, KF3 /* save dialog, see gamedo_HandleFKeys */, 3*w/6, 0, w/6, h/6},
};
......
......@@ -134,7 +134,7 @@ enum InputCommands{
IC_FIRE,
IC_STATUS,
IC_HELP,
IC_QUIT,
IC_BACK,
MAX_COMMANDS
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment