diff --git a/UI/ControlMappingScreen.cpp b/UI/ControlMappingScreen.cpp index ec32447dae..3412cc34b5 100644 --- a/UI/ControlMappingScreen.cpp +++ b/UI/ControlMappingScreen.cpp @@ -252,16 +252,6 @@ void ControlMappingScreen::CreateViews() { } } -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") && screenManager()->topScreen() == this) { - UpdateUIState(UISTATE_MENU); - screenManager()->push(new GameSettingsScreen("")); - } -} - UI::EventReturn ControlMappingScreen::OnClearMapping(UI::EventParams ¶ms) { KeyMap::g_controllerMap.clear(); RecreateViews(); diff --git a/UI/ControlMappingScreen.h b/UI/ControlMappingScreen.h index b7850b3510..aec4fcdce3 100644 --- a/UI/ControlMappingScreen.h +++ b/UI/ControlMappingScreen.h @@ -35,7 +35,6 @@ public: void KeyMapped(int pspkey); // Notification to let us refocus the same one after recreating views. protected: virtual void CreateViews() override; - virtual void sendMessage(const char *message, const char *value) override; private: UI::EventReturn OnDefaultMapping(UI::EventParams ¶ms); UI::EventReturn OnClearMapping(UI::EventParams ¶ms); diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index 7289947eba..009c2b7532 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -1032,20 +1032,6 @@ void GameSettingsScreen::update() { } } -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") && screenManager()->topScreen() == this) { - UpdateUIState(UISTATE_MENU); - screenManager()->push(new ControlMappingScreen()); - } - if (!strcmp(message, "display layout editor") && screenManager()->topScreen() == this) { - UpdateUIState(UISTATE_MENU); - screenManager()->push(new DisplayLayoutScreen()); - } -} - void GameSettingsScreen::onFinish(DialogResult result) { if (g_Config.bEnableSound) { if (PSP_IsInited() && !IsAudioInitialised()) diff --git a/UI/GameSettingsScreen.h b/UI/GameSettingsScreen.h index 66ded9f009..94914d882e 100644 --- a/UI/GameSettingsScreen.h +++ b/UI/GameSettingsScreen.h @@ -35,7 +35,6 @@ public: protected: virtual void CreateViews(); - virtual void sendMessage(const char *message, const char *value); void CallbackRestoreDefaults(bool yes); void CallbackRenderingBackend(bool yes); bool UseVerticalLayout() const; diff --git a/UI/MainScreen.cpp b/UI/MainScreen.cpp index 3be3842386..32287e0a43 100644 --- a/UI/MainScreen.cpp +++ b/UI/MainScreen.cpp @@ -938,10 +938,6 @@ void MainScreen::sendMessage(const char *message, const char *value) { if (!strcmp(message, "boot") && screenManager()->topScreen() == this) { screenManager()->switchScreen(new EmuScreen(value)); } - if (!strcmp(message, "settings") && screenManager()->topScreen() == this) { - UpdateUIState(UISTATE_MENU); - screenManager()->push(new GameSettingsScreen("")); - } if (!strcmp(message, "permission_granted") && !strcmp(value, "storage")) { RecreateViews(); } diff --git a/UI/MiscScreens.cpp b/UI/MiscScreens.cpp index 0b8eba0838..27fddbc051 100644 --- a/UI/MiscScreens.cpp +++ b/UI/MiscScreens.cpp @@ -156,6 +156,8 @@ void DrawGameBackground(UIContext &dc, const std::string &gamePath) { } void HandleCommonMessages(const char *message, const char *value, ScreenManager *manager, Screen *activeScreen) { + bool isActiveScreen = manager->topScreen() == activeScreen; + if (!strcmp(message, "clear jit")) { if (MIPSComp::jit && PSP_IsInited()) { MIPSComp::jit->ClearCache(); @@ -163,12 +165,26 @@ void HandleCommonMessages(const char *message, const char *value, ScreenManager if (PSP_IsInited()) { currentMIPS->UpdateCore((CPUCore)g_Config.iCpuCore); } - } else if (!strcmp(message, "control mapping") && manager->topScreen() == activeScreen) { + } else if (!strcmp(message, "control mapping") && isActiveScreen) { UpdateUIState(UISTATE_MENU); manager->push(new ControlMappingScreen()); - } else if (!strcmp(message, "display layout editor") && manager->topScreen() == activeScreen) { + } else if (!strcmp(message, "display layout editor") && isActiveScreen) { UpdateUIState(UISTATE_MENU); manager->push(new DisplayLayoutScreen()); + } else if (!strcmp(message, "settings") && isActiveScreen) { + UpdateUIState(UISTATE_MENU); + manager->push(new GameSettingsScreen("")); + } else if (!strcmp(message, "language screen") && isActiveScreen) { + I18NCategory *dev = GetI18NCategory("Developer"); + auto langScreen = new NewLanguageScreen(dev->T("Language")); + langScreen->OnChoice.Add([](UI::EventParams &) { + NativeMessageReceived("recreateviews", ""); + if (host) { + host->UpdateUI(); + } + return UI::EVENT_DONE; + }); + manager->push(langScreen); } else if (!strcmp(message, "window minimized")) { if (!strcmp(value, "true")) { gstate_c.skipDrawReason |= SKIPDRAW_WINDOW_MINIMIZED; @@ -214,32 +230,6 @@ void UIDialogScreenWithGameBackground::sendMessage(const char *message, const ch void UIScreenWithBackground::sendMessage(const char *message, const char *value) { HandleCommonMessages(message, value, screenManager(), this); - I18NCategory *dev = GetI18NCategory("Developer"); - 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") && screenManager()->topScreen() == this) { - screenManager()->push(new GameSettingsScreen("", "")); - } -} - -UI::EventReturn UIScreenWithBackground::OnLanguageChange(UI::EventParams &e) { - screenManager()->RecreateAllViews(); - if (host) { - host->UpdateUI(); - } - - return UI::EVENT_DONE; -} - -UI::EventReturn UIDialogScreenWithBackground::OnLanguageChange(UI::EventParams &e) { - screenManager()->RecreateAllViews(); - if (host) { - host->UpdateUI(); - } - - return UI::EVENT_DONE; } void UIDialogScreenWithBackground::DrawBackground(UIContext &dc) { @@ -255,14 +245,6 @@ void UIDialogScreenWithBackground::AddStandardBack(UI::ViewGroup *parent) { void UIDialogScreenWithBackground::sendMessage(const char *message, const char *value) { HandleCommonMessages(message, value, screenManager(), this); - I18NCategory *dev = GetI18NCategory("Developer"); - 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") && screenManager()->topScreen() == this) { - screenManager()->push(new GameSettingsScreen("", "")); - } } PromptScreen::PromptScreen(std::string message, std::string yesButtonText, std::string noButtonText, std::function callback) diff --git a/UI/MiscScreens.h b/UI/MiscScreens.h index 9e412d932b..2fb11bd67b 100644 --- a/UI/MiscScreens.h +++ b/UI/MiscScreens.h @@ -39,7 +39,6 @@ public: protected: void DrawBackground(UIContext &dc) override; void sendMessage(const char *message, const char *value) override; - UI::EventReturn OnLanguageChange(UI::EventParams &e); }; class UIScreenWithGameBackground : public UIScreenWithBackground { @@ -58,7 +57,6 @@ public: protected: void DrawBackground(UIContext &dc) override; void sendMessage(const char *message, const char *value) override; - UI::EventReturn OnLanguageChange(UI::EventParams &e); void AddStandardBack(UI::ViewGroup *parent); }; diff --git a/UI/PauseScreen.cpp b/UI/PauseScreen.cpp index c3b29d2ce3..03363ef4c0 100644 --- a/UI/PauseScreen.cpp +++ b/UI/PauseScreen.cpp @@ -433,6 +433,7 @@ UI::EventReturn GamePauseScreen::OnCreateConfig(UI::EventParams &e) screenManager()->topScreen()->RecreateViews(); return UI::EVENT_DONE; } + UI::EventReturn GamePauseScreen::OnDeleteConfig(UI::EventParams &e) { I18NCategory *di = GetI18NCategory("Dialog"); @@ -443,13 +444,3 @@ UI::EventReturn GamePauseScreen::OnDeleteConfig(UI::EventParams &e) return UI::EVENT_DONE; } - - -void GamePauseScreen::sendMessage(const char *message, const char *value) { - UIDialogScreenWithGameBackground::sendMessage(message, value); - // Since the language message isn't allowed to be in native, we have to have add this - // to every screen which directly inherits from UIScreen(which are few right now, luckily). - if (!strcmp(message, "language")) { - screenManager()->RecreateAllViews(); - } -} diff --git a/UI/PauseScreen.h b/UI/PauseScreen.h index de6b615562..292f5fea0f 100644 --- a/UI/PauseScreen.h +++ b/UI/PauseScreen.h @@ -35,7 +35,6 @@ public: protected: virtual void CreateViews() override; virtual void update() override; - virtual void sendMessage(const char *message, const char *value) override; void CallbackDeleteConfig(bool yes); private: