mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
UI: Cleanup common message handling.
Most of it can just be handled by the common parent classes.
This commit is contained in:
parent
e945ad6ac1
commit
f1bd54148b
9 changed files with 19 additions and 79 deletions
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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())
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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<void(bool)> callback)
|
||||
|
|
|
@ -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);
|
||||
};
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Add table
Reference in a new issue