Call the base class sendMessage when handling messages from native, so every screen can refresh from a language update at any time.

This commit is contained in:
The Dax 2013-10-21 16:52:44 -04:00
parent a28151437b
commit db370c1fd3
8 changed files with 27 additions and 23 deletions

View file

@ -214,9 +214,9 @@ void ControlMappingScreen::CreateViews() {
}
void ControlMappingScreen::sendMessage(const char *message, const char *value) {
if (!strcmp(message, "language")) {
screenManager()->RecreateAllViews();
}
// Always call the base class method first to handle the most common messages.
UIDialogScreenWithBackground::sendMessage(message, value);
if (!strcmp(message, "settings")) {
UpdateUIState(UISTATE_MENU);
screenManager()->push(new GameSettingsScreen(""));

View file

@ -92,12 +92,6 @@ void CwCheatScreen::CreateViews() {
}
}
void CwCheatScreen::sendMessage(const char *message, const char *value) {
if (!strcmp(message, "language")) {
screenManager()->RecreateAllViews();
}
}
UI::EventReturn CwCheatScreen::OnBack(UI::EventParams &params)
{
screenManager()->finishDialog(this, DR_OK);

View file

@ -42,7 +42,6 @@ public:
UI::EventReturn OnEnableAll(UI::EventParams &params);
protected:
virtual void CreateViews();
virtual void sendMessage(const char *message, const char *value);
private:
UI::EventReturn OnCheckBox(UI::EventParams &params);

View file

@ -353,9 +353,9 @@ void GameSettingsScreen::update(InputState &input) {
}
void GameSettingsScreen::sendMessage(const char *message, const char *value) {
if (!strcmp(message, "language")) {
screenManager()->RecreateAllViews();
}
// Always call the base class method first to handle the most common messages.
UIDialogScreenWithBackground::sendMessage(message, value);
if (!strcmp(message, "control mapping")) {
UpdateUIState(UISTATE_MENU);
screenManager()->push(new ControlMappingScreen());
@ -502,12 +502,6 @@ void DeveloperToolsScreen::CreateViews() {
list->Add(new Choice(d->T("Back")))->OnClick.Handle(this, &DeveloperToolsScreen::OnBack);
}
void DeveloperToolsScreen::sendMessage(const char *message, const char *value){
if (!strcmp(message, "language")) {
screenManager()->RecreateAllViews();
}
}
UI::EventReturn DeveloperToolsScreen::OnBack(UI::EventParams &e) {
screenManager()->finishDialog(this, DR_OK);

View file

@ -93,7 +93,6 @@ public:
protected:
virtual void CreateViews();
virtual void sendMessage(const char *message, const char *value);
private:
UI::EventReturn OnBack(UI::EventParams &e);

View file

@ -586,12 +586,12 @@ void MainScreen::CreateViews() {
}
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")) {
screenManager()->switchScreen(new EmuScreen(value));
}
if (!strcmp(message, "language")) {
screenManager()->RecreateAllViews();
}
if (!strcmp(message, "control mapping")) {
UpdateUIState(UISTATE_MENU);
screenManager()->push(new ControlMappingScreen());
@ -845,6 +845,8 @@ UI::EventReturn GamePauseScreen::OnCwCheat(UI::EventParams &e) {
}
void GamePauseScreen::sendMessage(const char *message, const char *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();
}

View file

@ -94,16 +94,30 @@ void DrawBackground(float alpha) {
}
}
void HandleCommonMessages(const char *message, const char *value, ScreenManager *manager) {
if (!strcmp(message, "language")) {
manager->RecreateAllViews();
}
}
void UIScreenWithBackground::DrawBackground(UIContext &dc) {
::DrawBackground(1.0f);
dc.Flush();
}
void UIScreenWithBackground::sendMessage(const char *message, const char *value) {
HandleCommonMessages(message, value, screenManager());
}
void UIDialogScreenWithBackground::DrawBackground(UIContext &dc) {
::DrawBackground(1.0f);
dc.Flush();
}
void UIDialogScreenWithBackground::sendMessage(const char *message, const char *value) {
HandleCommonMessages(message, value, screenManager());
}
PromptScreen::PromptScreen(std::string message, std::string yesButtonText, std::string noButtonText, std::function<void(bool)> callback)
: message_(message), callback_(callback) {
I18NCategory *d = GetI18NCategory("Dialog");

View file

@ -33,6 +33,7 @@ public:
UIScreenWithBackground() : UIScreen() {}
protected:
virtual void DrawBackground(UIContext &dc);
virtual void sendMessage(const char *message, const char *value);
};
class UIDialogScreenWithBackground : public UIDialogScreen {
@ -40,6 +41,7 @@ public:
UIDialogScreenWithBackground() : UIDialogScreen() {}
protected:
virtual void DrawBackground(UIContext &dc);
virtual void sendMessage(const char *message, const char *value);
};
class PromptScreen : public UIDialogScreenWithBackground {