mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-01 14:58:14 +00:00
Clean up language switching code slightly, add (disabled) shortcut to randomize for testing.
Remove background color from some titles.
This commit is contained in:
1 parent
67a7e8cd97
commit
be34e45536
4 files changed
+24
-11
No files matched your search
@@ -1158,10 +1158,7 @@ void GameSettingsScreen::CreateSystemSettings(UI::ViewGroup *systemSettings) {
|
||||
systemSettings->Add(new ChoiceWithValueDisplay(&g_Config.sLanguageIni, sy->T("Language"), langCodeToName))->OnClick.Add([&](UI::EventParams &e) {
|
||||
auto sy = GetI18NCategory(I18NCat::SYSTEM);
|
||||
auto langScreen = new NewLanguageScreen(sy->T("Language"));
|
||||
langScreen->OnChoice.Add([&](UI::EventParams &e) {
|
||||
screenManager()->RecreateAllViews();
|
||||
System_Notify(SystemNotification::UI);
|
||||
});
|
||||
// The actual switching is handled in OnCompleted in NewLanguageScreen.
|
||||
if (e.v)
|
||||
langScreen->SetPopupOrigin(e.v);
|
||||
screenManager()->push(langScreen);
|
||||
|
||||
+5
-6
@@ -40,6 +40,7 @@
|
||||
#include "Common/TimeUtil.h"
|
||||
#include "Common/File/FileUtil.h"
|
||||
#include "Common/Render/ManagedTexture.h"
|
||||
#include "Common/StringUtils.h"
|
||||
|
||||
#include "Core/Config.h"
|
||||
#include "Core/System.h"
|
||||
@@ -329,13 +330,10 @@ void NewLanguageScreen::OnCompleted(DialogResult result) {
|
||||
std::string oldLang = g_Config.sLanguageIni;
|
||||
std::string iniFile = langs_[listView_->GetSelected()].name;
|
||||
|
||||
size_t dot = iniFile.find('.');
|
||||
std::string code;
|
||||
if (dot != std::string::npos)
|
||||
code = iniFile.substr(0, dot);
|
||||
|
||||
if (code.empty())
|
||||
std::string_view code, part2;
|
||||
if (!SplitStringOnce(iniFile, &code, &part2, '.')) {
|
||||
return;
|
||||
}
|
||||
|
||||
g_Config.sLanguageIni = code;
|
||||
|
||||
@@ -352,6 +350,7 @@ void NewLanguageScreen::OnCompleted(DialogResult result) {
|
||||
|
||||
if (iniLoadedSuccessfully) {
|
||||
RecreateViews();
|
||||
System_Notify(SystemNotification::UI);
|
||||
} else {
|
||||
// Failed to load the language ini. Shouldn't really happen, but let's just switch back to the old language.
|
||||
g_Config.sLanguageIni = oldLang;
|
||||
|
||||
@@ -66,7 +66,6 @@ TopBar::TopBar(const UIContext &ctx, bool usePortraitLayout, std::string_view ti
|
||||
// If using HCENTER, to balance the centering, add a spacer on the right.
|
||||
// Add(new Spacer(50.0f));
|
||||
}
|
||||
SetBG(ctx.GetTheme().itemDownStyle.background);
|
||||
}
|
||||
|
||||
SettingInfoMessage::SettingInfoMessage(int align, float cutOffY, UI::AnchorLayoutParams *lp)
|
||||
|
||||
@@ -1384,6 +1384,24 @@ bool NativeKey(const KeyInput &key) {
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef _DEBUG
|
||||
// Debug hack: Randomize the language with F9!
|
||||
if (false && (key.keyCode == NKCODE_F9 && (key.flags & KEY_DOWN))) {
|
||||
std::vector<File::FileInfo> tempLangs;
|
||||
g_VFS.GetFileListing("lang", &tempLangs, "ini");
|
||||
int x = rand() % tempLangs.size();
|
||||
std::string_view code, part2;
|
||||
if (SplitStringOnce(tempLangs[x].name, &code, &part2, '.')) {
|
||||
g_Config.sLanguageIni = code;
|
||||
INFO_LOG(Log::System, "Switching to random language: %s", g_Config.sLanguageIni.c_str());
|
||||
if (g_i18nrepo.LoadIni(g_Config.sLanguageIni)) {
|
||||
g_screenManager->RecreateAllViews();
|
||||
System_Notify(SystemNotification::UI);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!g_screenManager) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user