Permalink
Browse files

UI: Avoid navigation with an active dialog.

Cleaning up next.
  • Loading branch information...
unknownbrackets committed Dec 2, 2017
1 parent 68a5861 commit e945ad6ac12e90f8bc91c9881a7dbf13175f086c
Showing with 23 additions and 29 deletions.
  1. +1 −1 UI/ControlMappingScreen.cpp
  2. +4 −4 UI/EmuScreen.cpp
  3. +2 −2 UI/GameSettingsScreen.cpp
  4. +2 −10 UI/MainScreen.cpp
  5. +14 −12 UI/MiscScreens.cpp
@@ -256,7 +256,7 @@ void ControlMappingScreen::sendMessage(const char *message, const char *value) {
// Always call the base class method first to handle the most common messages.
UIDialogScreenWithBackground::sendMessage(message, value);
if (!strcmp(message, "settings")) {
if (!strcmp(message, "settings") && screenManager()->topScreen() == this) {
UpdateUIState(UISTATE_MENU);
screenManager()->push(new GameSettingsScreen(""));
}
@@ -311,7 +311,7 @@ static void AfterStateBoot(bool success, const std::string &message, void *ignor
void EmuScreen::sendMessage(const char *message, const char *value) {
// External commands, like from the Windows UI.
if (!strcmp(message, "pause")) {
if (!strcmp(message, "pause") && screenManager()->topScreen() == this) {
releaseButtons();
screenManager()->push(new GamePauseScreen(gamePath_));
} else if (!strcmp(message, "lost_focus")) {
@@ -346,15 +346,15 @@ void EmuScreen::sendMessage(const char *message, const char *value) {
bootPending_ = true;
bootGame(value);
}
} else if (!strcmp(message, "control mapping")) {
} else if (!strcmp(message, "control mapping") && screenManager()->topScreen() == this) {
UpdateUIState(UISTATE_MENU);
releaseButtons();
screenManager()->push(new ControlMappingScreen());
} else if (!strcmp(message, "display layout editor")) {
} else if (!strcmp(message, "display layout editor") && screenManager()->topScreen() == this) {
UpdateUIState(UISTATE_MENU);
releaseButtons();
screenManager()->push(new DisplayLayoutScreen());
} else if (!strcmp(message, "settings")) {
} else if (!strcmp(message, "settings") && screenManager()->topScreen() == this) {
UpdateUIState(UISTATE_MENU);
releaseButtons();
screenManager()->push(new GameSettingsScreen(gamePath_));
@@ -1036,11 +1036,11 @@ void GameSettingsScreen::sendMessage(const char *message, const char *value) {
// Always call the base class method first to handle the most common messages.
UIDialogScreenWithBackground::sendMessage(message, value);
if (!strcmp(message, "control mapping")) {
if (!strcmp(message, "control mapping") && screenManager()->topScreen() == this) {
UpdateUIState(UISTATE_MENU);
screenManager()->push(new ControlMappingScreen());
}
if (!strcmp(message, "display layout editor")) {
if (!strcmp(message, "display layout editor") && screenManager()->topScreen() == this) {
UpdateUIState(UISTATE_MENU);
screenManager()->push(new DisplayLayoutScreen());
}
@@ -935,18 +935,10 @@ void MainScreen::sendMessage(const char *message, const char *value) {
// Always call the base class method first to handle the most common messages.
UIScreenWithBackground::sendMessage(message, value);
if (!strcmp(message, "boot")) {
if (!strcmp(message, "boot") && screenManager()->topScreen() == this) {
screenManager()->switchScreen(new EmuScreen(value));
}
if (!strcmp(message, "control mapping")) {
UpdateUIState(UISTATE_MENU);
screenManager()->push(new ControlMappingScreen());
}
if (!strcmp(message, "display layout editor")) {
UpdateUIState(UISTATE_MENU);
screenManager()->push(new DisplayLayoutScreen());
}
if (!strcmp(message, "settings")) {
if (!strcmp(message, "settings") && screenManager()->topScreen() == this) {
UpdateUIState(UISTATE_MENU);
screenManager()->push(new GameSettingsScreen(""));
}
@@ -155,17 +155,19 @@ void DrawGameBackground(UIContext &dc, const std::string &gamePath) {
}
}
void HandleCommonMessages(const char *message, const char *value, ScreenManager *manager) {
void HandleCommonMessages(const char *message, const char *value, ScreenManager *manager, Screen *activeScreen) {
if (!strcmp(message, "clear jit")) {
if (MIPSComp::jit && PSP_IsInited()) {
MIPSComp::jit->ClearCache();
}
if (PSP_IsInited()) {
currentMIPS->UpdateCore((CPUCore)g_Config.iCpuCore);
}
} else if (!strcmp(message, "control mapping")) {
} else if (!strcmp(message, "control mapping") && manager->topScreen() == activeScreen) {
UpdateUIState(UISTATE_MENU);
manager->push(new ControlMappingScreen());
} else if (!strcmp(message, "display layout editor")) {
} else if (!strcmp(message, "display layout editor") && manager->topScreen() == activeScreen) {
UpdateUIState(UISTATE_MENU);
manager->push(new DisplayLayoutScreen());
} else if (!strcmp(message, "window minimized")) {
if (!strcmp(value, "true")) {
@@ -191,7 +193,7 @@ void UIScreenWithGameBackground::DrawBackground(UIContext &dc) {
}
void UIScreenWithGameBackground::sendMessage(const char *message, const char *value) {
if (!strcmp(message, "settings")) {
if (!strcmp(message, "settings") && screenManager()->topScreen() == this) {
screenManager()->push(new GameSettingsScreen(gamePath_));
} else {
UIScreenWithBackground::sendMessage(message, value);
@@ -203,21 +205,21 @@ void UIDialogScreenWithGameBackground::DrawBackground(UIContext &dc) {
}
void UIDialogScreenWithGameBackground::sendMessage(const char *message, const char *value) {
if (!strcmp(message, "settings")) {
if (!strcmp(message, "settings") && screenManager()->topScreen() == this) {
screenManager()->push(new GameSettingsScreen(gamePath_));
} else {
UIDialogScreenWithBackground::sendMessage(message, value);
}
}
void UIScreenWithBackground::sendMessage(const char *message, const char *value) {
HandleCommonMessages(message, value, screenManager());
HandleCommonMessages(message, value, screenManager(), this);
I18NCategory *dev = GetI18NCategory("Developer");
if (!strcmp(message, "language screen")) {
if (!strcmp(message, "language screen") && screenManager()->topScreen() == this) {
auto langScreen = new NewLanguageScreen(dev->T("Language"));
langScreen->OnChoice.Handle(this, &UIScreenWithBackground::OnLanguageChange);
screenManager()->push(langScreen);
} else if (!strcmp(message, "settings")) {
} else if (!strcmp(message, "settings") && screenManager()->topScreen() == this) {
screenManager()->push(new GameSettingsScreen("", ""));
}
}
@@ -252,13 +254,13 @@ void UIDialogScreenWithBackground::AddStandardBack(UI::ViewGroup *parent) {
}
void UIDialogScreenWithBackground::sendMessage(const char *message, const char *value) {
HandleCommonMessages(message, value, screenManager());
HandleCommonMessages(message, value, screenManager(), this);
I18NCategory *dev = GetI18NCategory("Developer");
if (!strcmp(message, "language screen")) {
if (!strcmp(message, "language screen") && screenManager()->topScreen() == this) {
auto langScreen = new NewLanguageScreen(dev->T("Language"));
langScreen->OnChoice.Handle(this, &UIDialogScreenWithBackground::OnLanguageChange);
screenManager()->push(langScreen);
} else if (!strcmp(message, "settings")) {
} else if (!strcmp(message, "settings") && screenManager()->topScreen() == this) {
screenManager()->push(new GameSettingsScreen("", ""));
}
}
@@ -447,7 +449,7 @@ void LogoScreen::update() {
}
void LogoScreen::sendMessage(const char *message, const char *value) {
if (!strcmp(message, "boot")) {
if (!strcmp(message, "boot") && screenManager()->topScreen() == this) {
screenManager()->switchScreen(new EmuScreen(value));
}
}

0 comments on commit e945ad6

Please sign in to comment.