Update language immediately in UI.

This commit is contained in:
Unknown W. Brackets 2013-09-01 13:29:23 -07:00
parent 98717fee7c
commit 24ecf9416c
6 changed files with 26 additions and 6 deletions

View file

@ -515,7 +515,15 @@ UI::EventReturn GameSettingsScreen::OnFactoryReset(UI::EventParams &e) {
UI::EventReturn GameSettingsScreen::OnLanguage(UI::EventParams &e) {
I18NCategory *d = GetI18NCategory("Developer");
screenManager()->push(new NewLanguageScreen(d->T("Language")));
auto langScreen = new NewLanguageScreen(d->T("Language"));
langScreen->OnChoice.Handle(this, &GameSettingsScreen::OnLanguageChange);
screenManager()->push(langScreen);
return UI::EVENT_DONE;
}
UI::EventReturn GameSettingsScreen::OnLanguageChange(UI::EventParams &e) {
RecreateViews();
OnLanguageChanged.Trigger(e);
return UI::EVENT_DONE;
}

View file

@ -29,6 +29,8 @@ public:
virtual void update(InputState &input);
UI::Event OnLanguageChanged;
protected:
virtual void CreateViews();
virtual void DrawBackground(UIContext &dc);
@ -50,6 +52,7 @@ private:
// Global settings handlers
UI::EventReturn OnLanguage(UI::EventParams &e);
UI::EventReturn OnLanguageChange(UI::EventParams &e);
UI::EventReturn OnFactoryReset(UI::EventParams &e);
UI::EventReturn OnDeveloperTools(UI::EventParams &e);
UI::EventReturn OnChangeNickname(UI::EventParams &e);

View file

@ -25,6 +25,7 @@
#include "Common/FileUtil.h"
#include "Core/System.h"
#include "Core/Host.h"
#include "Core/SaveState.h"
#include "UI/EmuScreen.h"
@ -585,7 +586,17 @@ UI::EventReturn MainScreen::OnGameSelectedInstant(UI::EventParams &e) {
UI::EventReturn MainScreen::OnGameSettings(UI::EventParams &e) {
// screenManager()->push(new SettingsScreen());
screenManager()->push(new GameSettingsScreen("",""));
auto gameSettings = new GameSettingsScreen("", "");
gameSettings->OnLanguageChanged.Handle(this, &MainScreen::OnLanguageChange);
screenManager()->push(gameSettings);
return UI::EVENT_DONE;
}
UI::EventReturn MainScreen::OnLanguageChange(UI::EventParams &e) {
RecreateViews();
if (host) {
host->UpdateUI();
}
return UI::EVENT_DONE;
}

View file

@ -41,6 +41,7 @@ private:
// Event handlers
UI::EventReturn OnLoadFile(UI::EventParams &e);
UI::EventReturn OnGameSettings(UI::EventParams &e);
UI::EventReturn OnLanguageChange(UI::EventParams &e);
UI::EventReturn OnCredits(UI::EventParams &e);
UI::EventReturn OnSupport(UI::EventParams &e);
UI::EventReturn OnPPSSPPOrg(UI::EventParams &e);

View file

@ -249,6 +249,7 @@ void NewLanguageScreen::OnCompleted(DialogResult result) {
} else {
g_Config.ilanguage = langValuesMapping[code].second;
}
RecreateViews();
} else {
g_Config.languageIni = oldLang;
}

View file

@ -104,7 +104,6 @@ namespace MainWindow
static void *rawInputBuffer;
static size_t rawInputBufferSize;
static int currentSavestateSlot = 0;
static bool menusAreTranslated = false;
#define MAX_LOADSTRING 100
const TCHAR *szTitle = TEXT("PPSSPP");
@ -319,9 +318,6 @@ namespace MainWindow
}
void TranslateMenus() {
if(menusAreTranslated) return;
menusAreTranslated = true;
const char *desktopUI = "DesktopUI";
// File menu