Skip to content

Commit

Permalink
UI: Add right-click to act as esc ingame
Browse files Browse the repository at this point in the history
  • Loading branch information
IonAgorria committed Apr 10, 2024
1 parent b4c4558 commit b728976
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 84 deletions.
161 changes: 82 additions & 79 deletions Source/UserInterface/MainMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1611,83 +1611,91 @@ void OnSplashScreenKeyLast(CShellWindow* pWnd, InterfaceEventCode code, int para

//-----------------------------------
//general
void onMMBackButton(CShellWindow* pWnd, InterfaceEventCode code, int param) {
if( code == EVENT_UNPRESSED && intfCanHandleInput() ) {
int nShow;
switch ( pWnd->m_pParent->ID ) {
case SQSH_MM_SINGLE_SCR:
case SQSH_MM_MULTIPLAYER_LIST_SCR:
case SQSH_MM_COMMUNITY_SCR:
case SQSH_MM_OPTIONS_SCR:
case SQSH_MM_CREDITS_SCR:
nShow = SQSH_MM_START_SCR;
break;
case SQSH_MM_ADDONS_SCR:
nShow = SQSH_MM_COMMUNITY_SCR;
break;
case SQSH_MM_GAME_SCR:
case SQSH_MM_SOUND_SCR:
nShow = SQSH_MM_OPTIONS_SCR;
break;
case SQSH_MM_GRAPHICS_SCR:
GraphOptionsManager::getInstance().reset();
nShow = SQSH_MM_OPTIONS_SCR;
break;
case SQSH_MM_MULTIPLAYER_JOIN_SCR:
case SQSH_MM_MULTIPLAYER_LOBBY_SCR:
case SQSH_MM_MULTIPLAYER_PASSWORD_SCR:
nShow = SQSH_MM_MULTIPLAYER_LIST_SCR;
break;
case SQSH_MM_MULTIPLAYER_HOST_SCR:
nShow = SQSH_MM_MULTIPLAYER_LOBBY_SCR;
break;
case SQSH_MM_SCENARIO_SCR:
case SQSH_MM_BATTLE_SCR:
case SQSH_MM_LOAD_SCR:
case SQSH_MM_LOAD_REPLAY_SCR:
case SQSH_MM_CONTENT_CHOOSER_SCR:
nShow = SQSH_MM_SINGLE_SCR;
break;
case SQSH_MM_LOAD_IN_GAME_SCR:
case SQSH_MM_SAVE_GAME_SCR:
nShow = SQSH_MM_INMISSION_SCR;
break;
case SQSH_MM_SAVE_REPLAY_SCR:
nShow = SQSH_MM_STATS_SCR;
break;
case SQSH_MM_PROFILE_SCR:
showSingleMenu(pWnd);
return;
case SQSH_MM_MISSION_TASK_SCR:
nShow = RESUME_GAME;
break;
case SQSH_MM_CUSTOM_SCR:
OnComboGraphicsSettings(_shellIconManager.GetWnd(SQSH_MM_SETTINGS_COMBO), EVENT_CREATEWND, -1);
nShow = SQSH_MM_GRAPHICS_SCR;
break;
case SQSH_MM_SCREEN_OPTIONS:

void goToPreviousScreen(CShellWindow* pWnd, int current_screen_id) {
int nShow = 0;
switch (current_screen_id) {
case SQSH_MM_SINGLE_SCR:
case SQSH_MM_MULTIPLAYER_LIST_SCR:
case SQSH_MM_COMMUNITY_SCR:
case SQSH_MM_OPTIONS_SCR:
case SQSH_MM_CREDITS_SCR:
nShow = SQSH_MM_START_SCR;
break;
case SQSH_MM_ADDONS_SCR:
nShow = SQSH_MM_COMMUNITY_SCR;
break;
case SQSH_MM_GAME_SCR:
case SQSH_MM_SOUND_SCR:
nShow = SQSH_MM_OPTIONS_SCR;
break;
case SQSH_MM_GRAPHICS_SCR:
GraphOptionsManager::getInstance().reset();
nShow = SQSH_MM_OPTIONS_SCR;
break;
case SQSH_MM_MULTIPLAYER_JOIN_SCR:
case SQSH_MM_MULTIPLAYER_LOBBY_SCR:
case SQSH_MM_MULTIPLAYER_PASSWORD_SCR:
nShow = SQSH_MM_MULTIPLAYER_LIST_SCR;
break;
case SQSH_MM_MULTIPLAYER_HOST_SCR:
nShow = SQSH_MM_MULTIPLAYER_LOBBY_SCR;
break;
case SQSH_MM_SCENARIO_SCR:
case SQSH_MM_BATTLE_SCR:
case SQSH_MM_LOAD_SCR:
case SQSH_MM_LOAD_REPLAY_SCR:
case SQSH_MM_CONTENT_CHOOSER_SCR:
nShow = SQSH_MM_SINGLE_SCR;
break;
case SQSH_MM_LOAD_IN_GAME_SCR:
case SQSH_MM_SAVE_GAME_SCR:
nShow = SQSH_MM_INMISSION_SCR;
break;
case SQSH_MM_SAVE_REPLAY_SCR:
nShow = SQSH_MM_STATS_SCR;
break;
case SQSH_MM_PROFILE_SCR:
showSingleMenu(pWnd);
return;
case SQSH_MM_INMISSION_SCR:
case SQSH_MM_MISSION_TASK_SCR:
nShow = RESUME_GAME;
break;
case SQSH_MM_CUSTOM_SCR:
OnComboGraphicsSettings(_shellIconManager.GetWnd(SQSH_MM_SETTINGS_COMBO), EVENT_CREATEWND, -1);
nShow = SQSH_MM_GRAPHICS_SCR;
break;
case SQSH_MM_SCREEN_OPTIONS:
// GraphOptionsManager::getInstance().reset();
// extern void PerimeterDataChannelSave();
// PerimeterDataChannelSave();
nShow = SQSH_MM_INMISSION_SCR;
break;
case SQSH_MM_SCREEN_GAME:
case SQSH_MM_SCREEN_SOUND:
nShow = SQSH_MM_SCREEN_OPTIONS;
break;
case SQSH_MM_INGAME_CUSTOM_SCR:
OnComboGraphicsSettings(_shellIconManager.GetWnd(SQSH_MM_SETTINGS_COMBO), EVENT_CREATEWND, -1);
nShow = SQSH_MM_SCREEN_GRAPHICS;
break;
case SQSH_MM_SCREEN_GRAPHICS:
GraphOptionsManager::getInstance().reset();
nShow = SQSH_MM_SCREEN_OPTIONS;
break;
default:
return;
}
_shellIconManager.SwitchMenuScreens( pWnd->m_pParent->ID, nShow );
}
nShow = SQSH_MM_INMISSION_SCR;
break;
case SQSH_MM_SCREEN_GAME:
case SQSH_MM_SCREEN_SOUND:
nShow = SQSH_MM_SCREEN_OPTIONS;
break;
case SQSH_MM_INGAME_CUSTOM_SCR:
OnComboGraphicsSettings(_shellIconManager.GetWnd(SQSH_MM_SETTINGS_COMBO), EVENT_CREATEWND, -1);
nShow = SQSH_MM_SCREEN_GRAPHICS;
break;
case SQSH_MM_SCREEN_GRAPHICS:
GraphOptionsManager::getInstance().reset();
nShow = SQSH_MM_SCREEN_OPTIONS;
break;
default:
return;
}
if (nShow != 0) {
_shellIconManager.SwitchMenuScreens(current_screen_id, nShow);
}
}

void onMMBackButton(CShellWindow* pWnd, InterfaceEventCode code, int param) {
if( code == EVENT_UNPRESSED && intfCanHandleInput() ) {
goToPreviousScreen(pWnd, pWnd->m_pParent->ID);
}
}

//start menu
Expand Down Expand Up @@ -1860,11 +1868,6 @@ void onMMInMissRestartButton(CShellWindow* pWnd, InterfaceEventCode code, int pa
showMessageBox();
}
}
void onMMInMissResumeButton(CShellWindow* pWnd, InterfaceEventCode code, int param) {
if( code == EVENT_UNPRESSED && intfCanHandleInput() ) {
_shellIconManager.SwitchMenuScreens( pWnd->m_pParent->ID, RESUME_GAME );
}
}
void exitToInterfaceMessage(CShellWindow* pWnd) {
int id_off = pWnd ? pWnd->m_pParent->ID : -1;
switch(gameShell->currentSingleProfile.getLastGameType()) {
Expand Down
2 changes: 1 addition & 1 deletion Source/UserInterface/PerimeterShellDisp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ _handlertbl[] = {
{SQSH_MM_INMISSION_LOAD_BTN, onMMInMissLoadButton},
{SQSH_MM_INMISSION_OPTIONS_BTN, onMMInMissOptionsButton},
{SQSH_MM_INMISSION_RESTART_BTN, onMMInMissRestartButton},
{SQSH_MM_INMISSION_RESUME_BTN, onMMInMissResumeButton},
{SQSH_MM_INMISSION_RESUME_BTN, onMMBackButton},
{SQSH_MM_INMISSION_QUIT_BTN, onMMInMissQuitButton},

//battle
Expand Down
16 changes: 12 additions & 4 deletions Source/UserInterface/PerimeterShellUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -604,14 +604,22 @@ void CShellWindow::OnLButtonHold()
}
void CShellWindow::OnRButtonDown(float _x, float _y)
{
//Don't check for SQSH_ENABLED as you need right click on disable buttons
//SND2DPlaySound( m_sound, x );
if(m_handler /*&& (state & SQSH_ENABLED)*/ && m_effect == 0) //нужен правый клик в задизабленые кнопки!
m_handler(this, EVENT_RPRESSED, 0);
if (m_effect == 0) {
if (m_handler) {
m_handler(this, EVENT_RPRESSED, 0);
} else if (isContainer() && (m_attr_cont->load_group & SHELL_LOAD_GROUP_GAME)) {
this->checkDefaultEscBtn();
}
}
}
void CShellWindow::OnRButtonUp(float _x, float _y)
{
if(m_handler /*&& (state & SQSH_ENABLED)*/ && m_effect == 0)// нужен правый клик в задизабленые кнопки!
m_handler(this, EVENT_RUNPRESSED, 0);
//Don't check for SQSH_ENABLED as you need right click on disable buttons
if (m_handler && m_effect == 0) {
m_handler(this, EVENT_RUNPRESSED, 0);
}
}

void CShellWindow::Move(float _x, float _y, float _sx, float _sy)
Expand Down

0 comments on commit b728976

Please sign in to comment.