mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-11-27 00:03:37 +01:00
Revise how the language system works.
On Win32, the Language menubar is eliminated in favour of displaying a NewLanguageScreen on screens that are of type UIDialogScreenWithBackground/UIScreenWithBackground; UIScreen inheriting screens (e.g. GamePauseScreen) still require manual additions.
This commit is contained in:
1 parent
e2e74e81d6
commit
728101aebb
9 files changed
+65
-95
No files matched your search
@@ -435,7 +435,7 @@ UI::EventReturn GameSettingsScreen::OnLanguage(UI::EventParams &e) {
|
||||
|
||||
UI::EventReturn GameSettingsScreen::OnLanguageChange(UI::EventParams &e) {
|
||||
RecreateViews();
|
||||
OnLanguageChanged.Trigger(e);
|
||||
|
||||
if (host) {
|
||||
host->UpdateUI();
|
||||
}
|
||||
|
||||
@@ -30,7 +30,6 @@ public:
|
||||
virtual void update(InputState &input);
|
||||
virtual void onFinish(DialogResult result);
|
||||
|
||||
UI::Event OnLanguageChanged;
|
||||
UI::Event OnRecentChanged;
|
||||
|
||||
protected:
|
||||
|
||||
+14
-11
@@ -650,20 +650,11 @@ UI::EventReturn MainScreen::OnGameSelectedInstant(UI::EventParams &e) {
|
||||
UI::EventReturn MainScreen::OnGameSettings(UI::EventParams &e) {
|
||||
// screenManager()->push(new SettingsScreen());
|
||||
auto gameSettings = new GameSettingsScreen("", "");
|
||||
gameSettings->OnLanguageChanged.Handle(this, &MainScreen::OnLanguageChange);
|
||||
gameSettings->OnRecentChanged.Handle(this, &MainScreen::OnRecentChange);
|
||||
screenManager()->push(gameSettings);
|
||||
return UI::EVENT_DONE;
|
||||
}
|
||||
|
||||
UI::EventReturn MainScreen::OnLanguageChange(UI::EventParams &e) {
|
||||
RecreateViews();
|
||||
if (host) {
|
||||
host->UpdateUI();
|
||||
}
|
||||
return UI::EVENT_DONE;
|
||||
}
|
||||
|
||||
UI::EventReturn MainScreen::OnRecentChange(UI::EventParams &e) {
|
||||
RecreateViews();
|
||||
if (host) {
|
||||
@@ -852,10 +843,22 @@ UI::EventReturn GamePauseScreen::OnCwCheat(UI::EventParams &e) {
|
||||
return UI::EVENT_DONE;
|
||||
}
|
||||
|
||||
UI::EventReturn GamePauseScreen::OnLanguageChange(UI::EventParams &e) {
|
||||
RecreateViews();
|
||||
if (host) {
|
||||
host->UpdateUI();
|
||||
}
|
||||
|
||||
return UI::EVENT_DONE;
|
||||
}
|
||||
|
||||
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();
|
||||
I18NCategory *de = GetI18NCategory("Developer");
|
||||
if (!strcmp(message, "language screen")) {
|
||||
auto langScreen = new NewLanguageScreen(de->T("Language"));
|
||||
langScreen->OnChoice.Handle(this, &GamePauseScreen::OnLanguageChange);
|
||||
screenManager()->push(langScreen);
|
||||
}
|
||||
}
|
||||
+2
-1
@@ -43,7 +43,6 @@ private:
|
||||
// Event handlers
|
||||
UI::EventReturn OnLoadFile(UI::EventParams &e);
|
||||
UI::EventReturn OnGameSettings(UI::EventParams &e);
|
||||
UI::EventReturn OnLanguageChange(UI::EventParams &e);
|
||||
UI::EventReturn OnRecentChange(UI::EventParams &e);
|
||||
UI::EventReturn OnCredits(UI::EventParams &e);
|
||||
UI::EventReturn OnSupport(UI::EventParams &e);
|
||||
@@ -74,6 +73,8 @@ private:
|
||||
UI::EventReturn OnLoadState(UI::EventParams &e);
|
||||
UI::EventReturn OnRewind(UI::EventParams &e);
|
||||
|
||||
UI::EventReturn OnLanguageChange(UI::EventParams &e);
|
||||
|
||||
UI::EventReturn OnStateSelected(UI::EventParams &e);
|
||||
UI::EventReturn OnCwCheat(UI::EventParams &e);
|
||||
|
||||
|
||||
+30
-8
@@ -94,19 +94,36 @@ 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());
|
||||
I18NCategory *de = GetI18NCategory("Developer");
|
||||
if (!strcmp(message, "language screen")) {
|
||||
auto langScreen = new NewLanguageScreen(de->T("Language"));
|
||||
langScreen->OnChoice.Handle(this, &UIScreenWithBackground::OnLanguageChange);
|
||||
screenManager()->push(langScreen);
|
||||
}
|
||||
}
|
||||
|
||||
UI::EventReturn UIScreenWithBackground::OnLanguageChange(UI::EventParams &e) {
|
||||
RecreateViews();
|
||||
if (host) {
|
||||
host->UpdateUI();
|
||||
}
|
||||
|
||||
return UI::EVENT_DONE;
|
||||
}
|
||||
|
||||
UI::EventReturn UIDialogScreenWithBackground::OnLanguageChange(UI::EventParams &e) {
|
||||
RecreateViews();
|
||||
if (host) {
|
||||
host->UpdateUI();
|
||||
}
|
||||
|
||||
return UI::EVENT_DONE;
|
||||
}
|
||||
|
||||
void UIDialogScreenWithBackground::DrawBackground(UIContext &dc) {
|
||||
@@ -115,7 +132,12 @@ void UIDialogScreenWithBackground::DrawBackground(UIContext &dc) {
|
||||
}
|
||||
|
||||
void UIDialogScreenWithBackground::sendMessage(const char *message, const char *value) {
|
||||
HandleCommonMessages(message, value, screenManager());
|
||||
I18NCategory *de = GetI18NCategory("Developer");
|
||||
if (!strcmp(message, "language screen")) {
|
||||
auto langScreen = new NewLanguageScreen(de->T("Language"));
|
||||
langScreen->OnChoice.Handle(this, &UIDialogScreenWithBackground::OnLanguageChange);
|
||||
screenManager()->push(langScreen);
|
||||
}
|
||||
}
|
||||
|
||||
PromptScreen::PromptScreen(std::string message, std::string yesButtonText, std::string noButtonText, std::function<void(bool)> callback)
|
||||
|
||||
@@ -36,6 +36,7 @@ public:
|
||||
protected:
|
||||
virtual void DrawBackground(UIContext &dc);
|
||||
virtual void sendMessage(const char *message, const char *value);
|
||||
virtual UI::EventReturn OnLanguageChange(UI::EventParams &e);
|
||||
};
|
||||
|
||||
class UIDialogScreenWithBackground : public UIDialogScreen {
|
||||
@@ -44,6 +45,7 @@ public:
|
||||
protected:
|
||||
virtual void DrawBackground(UIContext &dc);
|
||||
virtual void sendMessage(const char *message, const char *value);
|
||||
virtual UI::EventReturn OnLanguageChange(UI::EventParams &e);
|
||||
};
|
||||
|
||||
class PromptScreen : public UIDialogScreenWithBackground {
|
||||
|
||||
+14
-69
@@ -391,20 +391,19 @@ namespace MainWindow
|
||||
MENU_EMULATION = 1,
|
||||
MENU_DEBUG = 2,
|
||||
MENU_OPTIONS = 3,
|
||||
MENU_LANGUAGE = 4,
|
||||
MENU_HELP = 5,
|
||||
MENU_HELP = 4,
|
||||
|
||||
// File submenus
|
||||
SUBMENU_FILE_SAVESTATE_SLOT = 6,
|
||||
|
||||
// Game Settings submenus
|
||||
SUBMENU_CUSTOM_SHADERS = 8,
|
||||
SUBMENU_RENDERING_RESOLUTION = 9,
|
||||
SUBMENU_WINDOW_SIZE = 10,
|
||||
SUBMENU_RENDERING_MODE = 11,
|
||||
SUBMENU_FRAME_SKIPPING = 12,
|
||||
SUBMENU_TEXTURE_FILTERING = 13,
|
||||
SUBMENU_TEXTURE_SCALING = 14,
|
||||
SUBMENU_CUSTOM_SHADERS = 9,
|
||||
SUBMENU_RENDERING_RESOLUTION = 10,
|
||||
SUBMENU_WINDOW_SIZE = 11,
|
||||
SUBMENU_RENDERING_MODE = 12,
|
||||
SUBMENU_FRAME_SKIPPING = 13,
|
||||
SUBMENU_TEXTURE_FILTERING = 14,
|
||||
SUBMENU_TEXTURE_SCALING = 15,
|
||||
};
|
||||
|
||||
std::string GetMenuItemText(int menuID) {
|
||||
@@ -460,44 +459,6 @@ namespace MainWindow
|
||||
AppendMenu(helpMenu, MF_STRING | MF_BYCOMMAND, ID_HELP_ABOUT, aboutPPSSPP.c_str());
|
||||
}
|
||||
|
||||
void CreateLanguageMenu() {
|
||||
I18NCategory *des = GetI18NCategory("DesktopUI");
|
||||
|
||||
const std::wstring languageKey = ConvertUTF8ToWString(des->T("Language"));
|
||||
|
||||
// Like in CreateHelpMenu, remove and insert the new menu.
|
||||
RemoveMenu(menu, MENU_LANGUAGE, MF_BYPOSITION);
|
||||
|
||||
HMENU langMenu = CreatePopupMenu();
|
||||
InsertMenu(menu, MENU_LANGUAGE, MF_POPUP | MF_STRING | MF_BYPOSITION, (UINT_PTR)langMenu, languageKey.c_str());
|
||||
|
||||
// Create the Language menu items by creating a new menu item for each
|
||||
// language with its full name("English", "Magyar", etc.) as the value.
|
||||
// Also collect the country codes while we're at it so we can send them to
|
||||
// NativeMessageReceived easier.
|
||||
auto langValuesMap = GetLangValuesMapping();
|
||||
|
||||
// Start adding items after ID_LANGUAGE_BASE.
|
||||
int item = ID_LANGUAGE_BASE + 1;
|
||||
std::wstring fullLanguageName;
|
||||
int checkedStatus = -1;
|
||||
|
||||
for(auto i = langValuesMap.begin(); i != langValuesMap.end(); ++i) {
|
||||
fullLanguageName = ConvertUTF8ToWString(i->second.first);
|
||||
|
||||
checkedStatus = MF_UNCHECKED;
|
||||
|
||||
if(g_Config.sLanguageIni == i->first) {
|
||||
checkedStatus = MF_CHECKED;
|
||||
// Update iLanguage so games boot with the proper language, if available.
|
||||
g_Config.iLanguage = langValuesMap[g_Config.sLanguageIni].second;
|
||||
}
|
||||
|
||||
AppendMenu(langMenu, MF_STRING | MF_BYPOSITION | checkedStatus, item++, fullLanguageName.c_str());
|
||||
countryCodes.push_back(i->first);
|
||||
}
|
||||
}
|
||||
|
||||
void UpdateDynamicMenuCheckmarks() {
|
||||
int item = ID_SHADERS_BASE + 1;
|
||||
|
||||
@@ -603,6 +564,7 @@ namespace MainWindow
|
||||
TranslateMenuItem(ID_DEBUG_MEMORYVIEW, L"\tCtrl+M");
|
||||
|
||||
// Options menu
|
||||
TranslateMenuItem(ID_OPTIONS_LANGUAGE);
|
||||
TranslateMenuItem(ID_OPTIONS_TOPMOST);
|
||||
TranslateMenuItem(ID_OPTIONS_PAUSE_FOCUS);
|
||||
TranslateMenuItem(ID_OPTIONS_MORE_SETTINGS);
|
||||
@@ -644,9 +606,6 @@ namespace MainWindow
|
||||
TranslateMenuItem(ID_EMULATION_SOUND);
|
||||
TranslateMenuItem(ID_EMULATION_CHEATS, L"\tCtrl+T");
|
||||
|
||||
// Language menu: it's translated in CreateLanguageMenu.
|
||||
CreateLanguageMenu();
|
||||
|
||||
// Help menu: it's translated in CreateHelpMenu.
|
||||
CreateHelpMenu();
|
||||
|
||||
@@ -1236,6 +1195,10 @@ namespace MainWindow
|
||||
SaveState::SaveSlot(g_Config.iCurrentStateSlot, SaveStateActionFinished);
|
||||
break;
|
||||
|
||||
case ID_OPTIONS_LANGUAGE:
|
||||
NativeMessageReceived("language screen", "");
|
||||
break;
|
||||
|
||||
case ID_OPTIONS_SCREENAUTO: SetInternalResolution(RESOLUTION_AUTO); break;
|
||||
case ID_OPTIONS_SCREEN1X: SetInternalResolution(RESOLUTION_NATIVE); break;
|
||||
case ID_OPTIONS_SCREEN2X: SetInternalResolution(RESOLUTION_2X); break;
|
||||
@@ -1456,28 +1419,10 @@ namespace MainWindow
|
||||
|
||||
default:
|
||||
{
|
||||
// Just handle language switching here.
|
||||
// The Menu ID is contained in wParam, so subtract
|
||||
// ID_LANGUAGE_BASE and an additional 1 off it.
|
||||
u32 index = (wParam - ID_LANGUAGE_BASE - 1);
|
||||
if(index >= 0 && index < countryCodes.size()) {
|
||||
std::string oldLang = g_Config.sLanguageIni;
|
||||
g_Config.sLanguageIni = countryCodes[index];
|
||||
|
||||
if(i18nrepo.LoadIni(g_Config.sLanguageIni)) {
|
||||
NativeMessageReceived("language", "");
|
||||
PostMessage(hwndMain, WM_USER_UPDATE_UI, 0, 0);
|
||||
}
|
||||
else
|
||||
g_Config.sLanguageIni = oldLang;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// Handle the dynamic shader switching here.
|
||||
// The Menu ID is contained in wParam, so subtract
|
||||
// ID_SHADERS_BASE and an additional 1 off it.
|
||||
index = (wParam - ID_SHADERS_BASE - 1);
|
||||
u32 index = (wParam - ID_SHADERS_BASE - 1);
|
||||
if (index >= 0 && index < availableShaders.size()) {
|
||||
g_Config.sPostShaderName = availableShaders[index];
|
||||
|
||||
|
||||
@@ -416,6 +416,7 @@ BEGIN
|
||||
MENUITEM "Pause When Not Focused", ID_OPTIONS_PAUSE_FOCUS
|
||||
MENUITEM "More Settings...", ID_OPTIONS_MORE_SETTINGS
|
||||
MENUITEM "Control Mapping...", ID_OPTIONS_CONTROLS
|
||||
MENUITEM "Language...", ID_OPTIONS_LANGUAGE
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Stretch to Display", ID_OPTIONS_STRETCHDISPLAY
|
||||
MENUITEM "Fullscreen", ID_OPTIONS_FULLSCREEN
|
||||
|
||||
+1
-4
@@ -159,9 +159,6 @@
|
||||
#define IDC_GEDBG_TEXADDR 1192
|
||||
#define IDC_GEDBG_FBTABS 1193
|
||||
|
||||
// Don't define anything else in the 3000 range.
|
||||
// It's reserved for languages.
|
||||
#define ID_LANGUAGE_BASE 3000
|
||||
#define ID_SHADERS_BASE 5000
|
||||
|
||||
#define ID_FILE_EXIT 40000
|
||||
@@ -299,7 +296,7 @@
|
||||
#define IDC_GEDBG_STEPPRIM 40138
|
||||
#define ID_DISASM_ADDFUNCTION 40139
|
||||
#define ID_DISASM_REMOVEFUNCTION 40140
|
||||
|
||||
#define ID_OPTIONS_LANGUAGE 40141
|
||||
|
||||
// Dummy option to let the buffered rendering hotkey cycle through all the options.
|
||||
#define ID_OPTIONS_BUFFEREDRENDERINGDUMMY 40500
|
||||
|
||||
Reference in new issue
Block a user