From 95f535dab0c7513af191a8b472bd1ab2ed58e271 Mon Sep 17 00:00:00 2001 From: Herman Semenov Date: Wed, 20 Dec 2023 12:35:02 +0300 Subject: [PATCH] [UI/Windows] Object out of scope optimization for better codegeneration (lower level scope) --- UI/ChatScreen.cpp | 7 +++---- UI/ControlMappingScreen.cpp | 16 +++++++++------- UI/DevScreens.cpp | 6 ++---- UI/DisplayLayoutScreen.cpp | 4 ++-- UI/EmuScreen.cpp | 5 ++--- UI/GameScreen.cpp | 14 +++++++------- UI/GameSettingsScreen.cpp | 21 +++++++++------------ UI/GamepadEmu.cpp | 5 +++-- UI/MainScreen.cpp | 6 ++---- UI/MemStickScreen.cpp | 5 ++--- UI/OnScreenDisplay.cpp | 2 +- UI/RemoteISOScreen.cpp | 3 +-- UI/ReportScreen.cpp | 2 +- UI/SavedataScreen.cpp | 6 +++--- UI/Store.cpp | 2 +- UI/TabbedDialogScreen.cpp | 8 +++----- Windows/GEDebugger/TabState.cpp | 11 ++++++----- Windows/GPU/WindowsGLContext.cpp | 3 +-- Windows/XinputDevice.cpp | 2 +- 19 files changed, 59 insertions(+), 69 deletions(-) diff --git a/UI/ChatScreen.cpp b/UI/ChatScreen.cpp index 9d5b8536dd..4d4faa882a 100644 --- a/UI/ChatScreen.cpp +++ b/UI/ChatScreen.cpp @@ -47,7 +47,6 @@ void ChatMenu::CreateContents(UI::ViewGroup *parent) { void ChatMenu::CreateSubviews(const Bounds &screenBounds) { using namespace UI; - auto n = GetI18NCategory(I18NCat::NETWORKING); float width = 550.0f; switch (g_Config.iChatScreenPosition) { @@ -80,6 +79,7 @@ void ChatMenu::CreateSubviews(const Bounds &screenBounds) { box_->SetBG(UI::Drawable(0x99303030)); box_->SetHasDropShadow(false); + auto n = GetI18NCategory(I18NCat::NETWORKING); View *title = new PopupHeader(n->T("Chat")); box_->Add(title); @@ -141,7 +141,6 @@ void ChatMenu::UpdateChat() { std::string name = g_Config.sNickName; std::string displayname = i.substr(0, i.find(':')); - std::string chattext = i.substr(displayname.length()); if (name.substr(0, 8) == displayname) { namecolor = 0xE53935; @@ -156,6 +155,7 @@ void ChatMenu::UpdateChat() { TextView *nameView = line->Add(new TextView(displayname, ALIGN_LEFT, true, new LinearLayoutParams(WRAP_CONTENT, WRAP_CONTENT, 0.0f))); nameView->SetTextColor(0xFF000000 | namecolor); + std::string chattext = i.substr(displayname.length()); TextView *chatView = line->Add(new TextView(chattext, ALIGN_LEFT | FLAG_WRAP_TEXT, true, new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT, 1.0f))); chatView->SetTextColor(0xFF000000 | textcolor); } @@ -165,8 +165,6 @@ void ChatMenu::UpdateChat() { } void ChatMenu::Update() { - auto n = GetI18NCategory(I18NCat::NETWORKING); - AnchorLayout::Update(); if (scroll_ && toBottom_) { toBottom_ = false; @@ -180,6 +178,7 @@ void ChatMenu::Update() { #if defined(USING_WIN_UI) // Could remove the fullscreen check here, it works now. + auto n = GetI18NCategory(I18NCat::NETWORKING); if (promptInput_ && g_Config.bBypassOSKWithKeyboard && !g_Config.UseFullScreen()) { System_InputBoxGetString(n->T("Chat"), n->T("Chat Here"), [](const std::string &value, int) { sendChat(value); diff --git a/UI/ControlMappingScreen.cpp b/UI/ControlMappingScreen.cpp index 50c5ae56a3..31f26044d8 100644 --- a/UI/ControlMappingScreen.cpp +++ b/UI/ControlMappingScreen.cpp @@ -403,12 +403,12 @@ bool KeyMappingNewMouseKeyDialog::key(const KeyInput &key) { mapped_ = true; - MultiInputMapping kdf(InputMapping(key.deviceId, key.keyCode)); - TriggerFinish(DR_YES); g_Config.bMapMouse = false; - if (callback_) + if (callback_) { + MultiInputMapping kdf(InputMapping(key.deviceId, key.keyCode)); callback_(kdf); + } } return true; } @@ -455,18 +455,20 @@ void KeyMappingNewMouseKeyDialog::axis(const AxisInput &axis) { if (axis.value > AXIS_BIND_THRESHOLD) { mapped_ = true; - MultiInputMapping kdf(InputMapping(axis.deviceId, axis.axisId, 1)); TriggerFinish(DR_YES); - if (callback_) + if (callback_) { + MultiInputMapping kdf(InputMapping(axis.deviceId, axis.axisId, 1)); callback_(kdf); + } } if (axis.value < -AXIS_BIND_THRESHOLD) { mapped_ = true; - MultiInputMapping kdf(InputMapping(axis.deviceId, axis.axisId, -1)); TriggerFinish(DR_YES); - if (callback_) + if (callback_) { + MultiInputMapping kdf(InputMapping(axis.deviceId, axis.axisId, -1)); callback_(kdf); + } } } diff --git a/UI/DevScreens.cpp b/UI/DevScreens.cpp index 1bc7a66ce3..3594a7104a 100644 --- a/UI/DevScreens.cpp +++ b/UI/DevScreens.cpp @@ -993,13 +993,12 @@ void AddressPromptScreen::BackspaceDigit() { } void AddressPromptScreen::UpdatePreviewDigits() { - auto dev = GetI18NCategory(I18NCat::DEVELOPER); - if (addr_ != 0) { char temp[32]; snprintf(temp, 32, "%8X", addr_); addrView_->SetText(temp); } else { + auto dev = GetI18NCategory(I18NCat::DEVELOPER); addrView_->SetText(dev->T("Enter address")); } } @@ -1072,8 +1071,6 @@ void JitCompareScreen::UpdateDisasm() { using namespace UI; - auto dev = GetI18NCategory(I18NCat::DEVELOPER); - JitBlockCacheDebugInterface *blockCacheDebug = MIPSComp::jit->GetBlockCacheDebugInterface(); char temp[256]; @@ -1081,6 +1078,7 @@ void JitCompareScreen::UpdateDisasm() { blockName_->SetText(temp); if (currentBlock_ < 0 || !blockCacheDebug || currentBlock_ >= blockCacheDebug->GetNumBlocks()) { + auto dev = GetI18NCategory(I18NCat::DEVELOPER); leftDisasm_->Add(new TextView(dev->T("No block"))); rightDisasm_->Add(new TextView(dev->T("No block"))); blockStats_->SetText(""); diff --git a/UI/DisplayLayoutScreen.cpp b/UI/DisplayLayoutScreen.cpp index d82d3a9da8..d60474556b 100644 --- a/UI/DisplayLayoutScreen.cpp +++ b/UI/DisplayLayoutScreen.cpp @@ -163,15 +163,15 @@ UI::EventReturn DisplayLayoutScreen::OnPostProcShaderChange(UI::EventParams &e) } static std::string PostShaderTranslateName(const char *value) { - auto gr = GetI18NCategory(I18NCat::GRAPHICS); - auto ps = GetI18NCategory(I18NCat::POSTSHADERS); if (!strcmp(value, "Off")) { + auto gr = GetI18NCategory(I18NCat::GRAPHICS); // Off is a legacy fake item (gonna migrate off it later). return gr->T("Add postprocessing shader"); } const ShaderInfo *info = GetPostShaderInfo(value); if (info) { + auto ps = GetI18NCategory(I18NCat::POSTSHADERS); return ps->T(value, info ? info->name.c_str() : value); } else { return value; diff --git a/UI/EmuScreen.cpp b/UI/EmuScreen.cpp index 7cf3908c3a..69f32f661c 100644 --- a/UI/EmuScreen.cpp +++ b/UI/EmuScreen.cpp @@ -233,8 +233,6 @@ bool EmuScreen::bootAllowStorage(const Path &filename) { } void EmuScreen::bootGame(const Path &filename) { - auto sc = GetI18NCategory(I18NCat::SCREEN); - if (Achievements::IsBlockingExecution()) { // Keep waiting. return; @@ -288,6 +286,7 @@ void EmuScreen::bootGame(const Path &filename) { g_Discord.SetPresenceGame(info->GetTitle().c_str()); } else { + auto sc = GetI18NCategory(I18NCat::SCREEN); g_Discord.SetPresenceGame(sc->T("Untitled PSP game")); } @@ -970,7 +969,6 @@ void EmuScreen::CreateViews() { using namespace UI; auto dev = GetI18NCategory(I18NCat::DEVELOPER); - auto n = GetI18NCategory(I18NCat::NETWORKING); auto sc = GetI18NCategory(I18NCat::SCREEN); const Bounds &bounds = screenManager()->getUIContext()->GetLayoutBounds(); @@ -1003,6 +1001,7 @@ void EmuScreen::CreateViews() { if (g_Config.bEnableNetworkChat) { if (g_Config.iChatButtonPosition != 8) { + auto n = GetI18NCategory(I18NCat::NETWORKING); AnchorLayoutParams *layoutParams = AnchorInCorner(bounds, g_Config.iChatButtonPosition, 80.0f, 50.0f); ChoiceWithValueDisplay *btn = new ChoiceWithValueDisplay(&newChatMessages_, n->T("Chat"), layoutParams); root_->Add(btn)->OnClick.Handle(this, &EmuScreen::OnChat); diff --git a/UI/GameScreen.cpp b/UI/GameScreen.cpp index 59a45455fa..f9fcdce607 100644 --- a/UI/GameScreen.cpp +++ b/UI/GameScreen.cpp @@ -94,7 +94,6 @@ void GameScreen::CreateViews() { auto di = GetI18NCategory(I18NCat::DIALOG); auto ga = GetI18NCategory(I18NCat::GAME); - auto pa = GetI18NCategory(I18NCat::PAUSE); // Information in the top left. // Back button to the bottom left. @@ -202,6 +201,7 @@ void GameScreen::CreateViews() { rightColumnItems->Add(AddOtherChoice(new Choice(ga->T("Show In Folder"))))->OnClick.Handle(this, &GameScreen::OnShowInFolder); #endif if (g_Config.bEnableCheats) { + auto pa = GetI18NCategory(I18NCat::PAUSE); rightColumnItems->Add(AddOtherChoice(new Choice(pa->T("Cheats"))))->OnClick.Handle(this, &GameScreen::OnCwCheat); } @@ -459,12 +459,12 @@ UI::EventReturn GameScreen::OnGameSettings(UI::EventParams &e) { } UI::EventReturn GameScreen::OnDeleteSaveData(UI::EventParams &e) { - auto di = GetI18NCategory(I18NCat::DIALOG); - auto ga = GetI18NCategory(I18NCat::GAME); std::shared_ptr info = g_gameInfoCache->GetInfo(NULL, gamePath_, GAMEINFO_WANTBG | GAMEINFO_WANTSIZE); if (info) { // Check that there's any savedata to delete if (saveDirs.size()) { + auto di = GetI18NCategory(I18NCat::DIALOG); + auto ga = GetI18NCategory(I18NCat::GAME); screenManager()->push( new PromptScreen(gamePath_, di->T("DeleteConfirmAll", "Do you really want to delete all\nyour save data for this game?"), ga->T("ConfirmDelete"), di->T("Cancel"), std::bind(&GameScreen::CallbackDeleteSaveData, this, std::placeholders::_1))); @@ -476,8 +476,8 @@ UI::EventReturn GameScreen::OnDeleteSaveData(UI::EventParams &e) { } void GameScreen::CallbackDeleteSaveData(bool yes) { - std::shared_ptr info = g_gameInfoCache->GetInfo(NULL, gamePath_, 0); if (yes) { + std::shared_ptr info = g_gameInfoCache->GetInfo(NULL, gamePath_, 0); info->DeleteAllSaveData(); info->saveDataSize = 0; info->installDataSize = 0; @@ -485,10 +485,10 @@ void GameScreen::CallbackDeleteSaveData(bool yes) { } UI::EventReturn GameScreen::OnDeleteGame(UI::EventParams &e) { - auto di = GetI18NCategory(I18NCat::DIALOG); - auto ga = GetI18NCategory(I18NCat::GAME); std::shared_ptr info = g_gameInfoCache->GetInfo(NULL, gamePath_, GAMEINFO_WANTBG | GAMEINFO_WANTSIZE); if (info) { + auto di = GetI18NCategory(I18NCat::DIALOG); + auto ga = GetI18NCategory(I18NCat::GAME); screenManager()->push( new PromptScreen(gamePath_, di->T("DeleteConfirmGame", "Do you really want to delete this game\nfrom your device? You can't undo this."), ga->T("ConfirmDelete"), di->T("Cancel"), std::bind(&GameScreen::CallbackDeleteGame, this, std::placeholders::_1))); @@ -498,8 +498,8 @@ UI::EventReturn GameScreen::OnDeleteGame(UI::EventParams &e) { } void GameScreen::CallbackDeleteGame(bool yes) { - std::shared_ptr info = g_gameInfoCache->GetInfo(NULL, gamePath_, 0); if (yes) { + std::shared_ptr info = g_gameInfoCache->GetInfo(NULL, gamePath_, 0); info->Delete(); g_gameInfoCache->Clear(); screenManager()->switchScreen(new MainScreen()); diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index 227bd76039..c00776ee24 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -158,9 +158,9 @@ static bool UsingHardwareTextureScaling() { } static std::string TextureTranslateName(const char *value) { - auto ts = GetI18NCategory(I18NCat::TEXTURESHADERS); const TextureShaderInfo *info = GetTextureShaderInfo(value); if (info) { + auto ts = GetI18NCategory(I18NCat::TEXTURESHADERS); return ts->T(value, info ? info->name.c_str() : value); } else { return value; @@ -205,9 +205,9 @@ bool PathToVisualUsbPath(Path path, std::string &outPath) { } static std::string PostShaderTranslateName(const char *value) { - auto ps = GetI18NCategory(I18NCat::POSTSHADERS); const ShaderInfo *info = GetPostShaderInfo(value); if (info) { + auto ps = GetI18NCategory(I18NCat::POSTSHADERS); return ps->T(value, info ? info->name.c_str() : value); } else { return value; @@ -659,7 +659,6 @@ void GameSettingsScreen::CreateControlsSettings(UI::ViewGroup *controlsSettings) using namespace UI; auto co = GetI18NCategory(I18NCat::CONTROLS); - auto di = GetI18NCategory(I18NCat::DIALOG); auto ms = GetI18NCategory(I18NCat::MAINSETTINGS); int deviceType = System_GetPropertyInt(SYSPROP_DEVICE_TYPE); @@ -684,6 +683,7 @@ void GameSettingsScreen::CreateControlsSettings(UI::ViewGroup *controlsSettings) // TVs don't have touch control, at least not yet. if ((deviceType != DEVICE_TYPE_TV) && (deviceType != DEVICE_TYPE_VR)) { + auto di = GetI18NCategory(I18NCat::DIALOG); controlsSettings->Add(new ItemHeader(co->T("OnScreen", "On-Screen Touch Controls"))); controlsSettings->Add(new CheckBox(&g_Config.bShowTouchControls, co->T("OnScreen", "On-Screen Touch Controls"))); layoutEditorChoice_ = controlsSettings->Add(new Choice(co->T("Customize Touch Controls"))); @@ -1501,8 +1501,6 @@ void GameSettingsScreen::dialogFinished(const Screen *dialog, DialogResult resul } void GameSettingsScreen::CallbackMemstickFolder(bool yes) { - auto sy = GetI18NCategory(I18NCat::SYSTEM); - if (yes) { Path memstickDirFile = g_Config.internalDataDirectory / "memstick_dir.txt"; std::string testWriteFile = pendingMemstickFolder_ + "/.write_verify_file"; @@ -1512,6 +1510,7 @@ void GameSettingsScreen::CallbackMemstickFolder(bool yes) { File::CreateFullPath(Path(pendingMemstickFolder_)); } if (!File::WriteDataToFile(true, "1", 1, Path(testWriteFile))) { + auto sy = GetI18NCategory(I18NCat::SYSTEM); settingInfo_->Show(sy->T("ChangingMemstickPathInvalid", "That path couldn't be used to save Memory Stick files."), nullptr); return; } @@ -1545,10 +1544,9 @@ static void TriggerRestart(const char *why, bool editThenRestore, const Path &ga } UI::EventReturn GameSettingsScreen::OnRenderingBackend(UI::EventParams &e) { - auto di = GetI18NCategory(I18NCat::DIALOG); - // It only makes sense to show the restart prompt if the backend was actually changed. if (g_Config.iGPUBackend != (int)GetGPUBackend()) { + auto di = GetI18NCategory(I18NCat::DIALOG); screenManager()->push(new PromptScreen(gamePath_, di->T("Changing this setting requires PPSSPP to restart."), di->T("Restart"), di->T("Cancel"), [=](bool yes) { if (yes) { TriggerRestart("GameSettingsScreen::RenderingBackendYes", editThenRestore_, gamePath_); @@ -1561,11 +1559,10 @@ UI::EventReturn GameSettingsScreen::OnRenderingBackend(UI::EventParams &e) { } UI::EventReturn GameSettingsScreen::OnRenderingDevice(UI::EventParams &e) { - auto di = GetI18NCategory(I18NCat::DIALOG); - // It only makes sense to show the restart prompt if the device was actually changed. std::string *deviceNameSetting = GPUDeviceNameSetting(); if (deviceNameSetting && *deviceNameSetting != GetGPUBackendDevice()) { + auto di = GetI18NCategory(I18NCat::DIALOG); screenManager()->push(new PromptScreen(gamePath_, di->T("Changing this setting requires PPSSPP to restart."), di->T("Restart"), di->T("Cancel"), [=](bool yes) { // If the user ends up deciding not to restart, set the config back to the current backend // so it doesn't get switched by accident. @@ -1584,8 +1581,8 @@ UI::EventReturn GameSettingsScreen::OnRenderingDevice(UI::EventParams &e) { } UI::EventReturn GameSettingsScreen::OnInflightFramesChoice(UI::EventParams &e) { - auto di = GetI18NCategory(I18NCat::DIALOG); if (g_Config.iInflightFrames != prevInflightFrames_) { + auto di = GetI18NCategory(I18NCat::DIALOG); screenManager()->push(new PromptScreen(gamePath_, di->T("Changing this setting requires PPSSPP to restart."), di->T("Restart"), di->T("Cancel"), [=](bool yes) { if (yes) { TriggerRestart("GameSettingsScreen::InflightFramesYes", editThenRestore_, gamePath_); @@ -1939,10 +1936,10 @@ void GameSettingsScreen::CallbackRestoreDefaults(bool yes) { } UI::EventReturn GameSettingsScreen::OnRestoreDefaultSettings(UI::EventParams &e) { - auto dev = GetI18NCategory(I18NCat::DEVELOPER); - auto di = GetI18NCategory(I18NCat::DIALOG); auto sy = GetI18NCategory(I18NCat::SYSTEM); if (g_Config.bGameSpecific) { + auto dev = GetI18NCategory(I18NCat::DEVELOPER); + auto di = GetI18NCategory(I18NCat::DIALOG); screenManager()->push( new PromptScreen(gamePath_, dev->T("RestoreGameDefaultSettings", "Are you sure you want to restore the game-specific settings back to the ppsspp defaults?\n"), di->T("OK"), di->T("Cancel"), std::bind(&GameSettingsScreen::CallbackRestoreDefaults, this, std::placeholders::_1))); diff --git a/UI/GamepadEmu.cpp b/UI/GamepadEmu.cpp index 30dda67609..4297ca72c6 100644 --- a/UI/GamepadEmu.cpp +++ b/UI/GamepadEmu.cpp @@ -791,7 +791,6 @@ UI::ViewGroup *CreatePadLayout(float xres, float yres, bool *pause, bool showPau const ImageID roundImage = g_Config.iTouchButtonStyle ? ImageID("I_ROUND_LINE") : ImageID("I_ROUND"); const ImageID rectImage = g_Config.iTouchButtonStyle ? ImageID("I_RECT_LINE") : ImageID("I_RECT"); const ImageID shoulderImage = g_Config.iTouchButtonStyle ? ImageID("I_SHOULDER_LINE") : ImageID("I_SHOULDER"); - const ImageID dirImage = g_Config.iTouchButtonStyle ? ImageID("I_DIR_LINE") : ImageID("I_DIR"); const ImageID stickImage = g_Config.iTouchButtonStyle ? ImageID("I_STICK_LINE") : ImageID("I_STICK"); const ImageID stickBg = g_Config.iTouchButtonStyle ? ImageID("I_STICK_BG_LINE") : ImageID("I_STICK_BG"); @@ -853,8 +852,10 @@ UI::ViewGroup *CreatePadLayout(float xres, float yres, bool *pause, bool showPau if (rTrigger) rTrigger->FlipImageH(true); - if (g_Config.touchDpad.show) + if (g_Config.touchDpad.show) { + const ImageID dirImage = g_Config.iTouchButtonStyle ? ImageID("I_DIR_LINE") : ImageID("I_DIR"); root->Add(new PSPDpad(dirImage, "D-pad", ImageID("I_DIR"), ImageID("I_ARROW"), g_Config.touchDpad.scale, g_Config.fDpadSpacing, buttonLayoutParams(g_Config.touchDpad))); + } if (g_Config.touchAnalogStick.show) root->Add(new PSPStick(stickBg, "Left analog stick", stickImage, ImageID("I_STICK"), 0, g_Config.touchAnalogStick.scale, buttonLayoutParams(g_Config.touchAnalogStick))); diff --git a/UI/MainScreen.cpp b/UI/MainScreen.cpp index 2de67dd0ce..9213bac6db 100644 --- a/UI/MainScreen.cpp +++ b/UI/MainScreen.cpp @@ -1071,8 +1071,6 @@ void MainScreen::CreateViews() { auto mm = GetI18NCategory(I18NCat::MAINMENU); - Margins actionMenuMargins(0, 10, 10, 0); - tabHolder_ = new TabHolder(ORIENT_HORIZONTAL, 64, new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT, 1.0f)); ViewGroup *leftColumn = tabHolder_; tabHolder_->SetTag("MainScreenGames"); @@ -1252,6 +1250,7 @@ void MainScreen::CreateViews() { root_->Add(rightColumn); root_->Add(leftColumn); } else { + Margins actionMenuMargins(0, 10, 10, 0); root_ = new LinearLayout(ORIENT_HORIZONTAL); rightColumn->ReplaceLayoutParams(new LinearLayoutParams(300, FILL_PARENT, actionMenuMargins)); root_->Add(leftColumn); @@ -1266,10 +1265,9 @@ void MainScreen::CreateViews() { root_->SetTag("mainroot"); - auto u = GetI18NCategory(I18NCat::UPGRADE); - upgradeBar_ = 0; if (!g_Config.upgradeMessage.empty()) { + auto u = GetI18NCategory(I18NCat::UPGRADE); upgradeBar_ = new LinearLayout(ORIENT_HORIZONTAL, new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT)); UI::Margins textMargins(10, 5); diff --git a/UI/MemStickScreen.cpp b/UI/MemStickScreen.cpp index 9050368d84..41d7332012 100644 --- a/UI/MemStickScreen.cpp +++ b/UI/MemStickScreen.cpp @@ -61,14 +61,13 @@ static bool FolderSeemsToBeUsed(const Path &newMemstickFolder) { } static bool SwitchMemstickFolderTo(Path newMemstickFolder) { - Path testWriteFile = newMemstickFolder / ".write_verify_file"; - // Doesn't already exist, create. // Should this ever happen? if (newMemstickFolder.Type() == PathType::NATIVE) { if (!File::Exists(newMemstickFolder)) { File::CreateFullPath(newMemstickFolder); } + Path testWriteFile = newMemstickFolder / ".write_verify_file"; if (!File::WriteDataToFile(true, "1", 1, testWriteFile)) { return false; } @@ -562,7 +561,6 @@ ConfirmMemstickMoveScreen::~ConfirmMemstickMoveScreen() { void ConfirmMemstickMoveScreen::CreateViews() { using namespace UI; - auto di = GetI18NCategory(I18NCat::DIALOG); auto sy = GetI18NCategory(I18NCat::SYSTEM); auto iz = GetI18NCategory(I18NCat::MEMSTICK); @@ -618,6 +616,7 @@ void ConfirmMemstickMoveScreen::CreateViews() { leftColumn->Add(new CheckBox(&moveData_, iz->T("Move Data")))->OnClick.Handle(this, &ConfirmMemstickMoveScreen::OnMoveDataClick); } + auto di = GetI18NCategory(I18NCat::DIALOG); leftColumn->Add(new Choice(di->T("OK")))->OnClick.Handle(this, &ConfirmMemstickMoveScreen::OnConfirm); leftColumn->Add(new Choice(di->T("Back")))->OnClick.Handle(this, &UIScreen::OnBack); } diff --git a/UI/OnScreenDisplay.cpp b/UI/OnScreenDisplay.cpp index 9781a251a6..df6915d04b 100644 --- a/UI/OnScreenDisplay.cpp +++ b/UI/OnScreenDisplay.cpp @@ -134,8 +134,8 @@ static void RenderNotice(UIContext &dc, Bounds bounds, float height1, NoticeLeve if (iconID.isValid()) { // Atlas icon. dc.Draw()->GetAtlas()->measureImage(iconID, &iconW, &iconH); - Bounds iconBounds = Bounds(bounds.x + 2.5f, bounds.y + 2.5f, iconW, iconH); if (!iconName.empty()) { + Bounds iconBounds = Bounds(bounds.x + 2.5f, bounds.y + 2.5f, iconW, iconH); // If it's not a preset OSD icon, give it some background to blend in. The RA icon for example // easily melts into the orange of warnings otherwise. dc.FillRect(UI::Drawable(0x50000000), iconBounds.Expand(2.0f)); diff --git a/UI/RemoteISOScreen.cpp b/UI/RemoteISOScreen.cpp index 9ade1fd803..f12005e30f 100644 --- a/UI/RemoteISOScreen.cpp +++ b/UI/RemoteISOScreen.cpp @@ -526,8 +526,6 @@ void RemoteISOBrowseScreen::CreateViews() { bool vertical = UseVerticalLayout(); - Margins actionMenuMargins(0, 10, 10, 0); - TabHolder *leftColumn = new TabHolder(ORIENT_HORIZONTAL, 64, new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT)); tabHolder_ = leftColumn; tabHolder_->SetTag("RemoteGames"); @@ -562,6 +560,7 @@ void RemoteISOBrowseScreen::CreateViews() { root_->Add(rightColumn); root_->Add(leftColumn); } else { + Margins actionMenuMargins(0, 10, 10, 0); root_ = new LinearLayout(ORIENT_HORIZONTAL); leftColumn->ReplaceLayoutParams(new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT, 1.0)); rightColumn->ReplaceLayoutParams(new LinearLayoutParams(300, FILL_PARENT, actionMenuMargins)); diff --git a/UI/ReportScreen.cpp b/UI/ReportScreen.cpp index a1785f4363..36f5162fdf 100644 --- a/UI/ReportScreen.cpp +++ b/UI/ReportScreen.cpp @@ -253,7 +253,6 @@ EventReturn ReportScreen::HandleReportingChange(EventParams &e) { void ReportScreen::CreateViews() { auto rp = GetI18NCategory(I18NCat::REPORTING); auto di = GetI18NCategory(I18NCat::DIALOG); - auto sy = GetI18NCategory(I18NCat::SYSTEM); Margins actionMenuMargins(0, 20, 15, 0); Margins contentMargins(0, 20, 5, 5); @@ -265,6 +264,7 @@ void ReportScreen::CreateViews() { leftColumnItems->Add(new TextView(rp->T("FeedbackDesc", "How's the emulation? Let us and the community know!"), FLAG_WRAP_TEXT, false, new LinearLayoutParams(Margins(12, 5, 0, 5))))->SetShadow(true); if (!Reporting::IsEnabled()) { + auto sy = GetI18NCategory(I18NCat::SYSTEM); reportingNotice_ = leftColumnItems->Add(new TextView(rp->T("FeedbackDisabled", "Compatibility server reports must be enabled."), FLAG_WRAP_TEXT, false, new LinearLayoutParams(Margins(12, 5, 0, 5)))); reportingNotice_->SetShadow(true); reportingNotice_->SetTextColor(0xFF3030FF); diff --git a/UI/SavedataScreen.cpp b/UI/SavedataScreen.cpp index ca07dec0ee..c39428204b 100644 --- a/UI/SavedataScreen.cpp +++ b/UI/SavedataScreen.cpp @@ -98,7 +98,6 @@ public: LinearLayout *toprow = new LinearLayout(ORIENT_HORIZONTAL, new LayoutParams(FILL_PARENT, WRAP_CONTENT)); content->Add(toprow); - auto sa = GetI18NCategory(I18NCat::SAVEDATA); if (ginfo->fileType == IdentifiedFileType::PSP_SAVEDATA_DIRECTORY) { std::string savedata_detail = ginfo->paramSFO.GetValueString("SAVEDATA_DETAIL"); std::string savedata_title = ginfo->paramSFO.GetValueString("SAVEDATA_TITLE"); @@ -120,6 +119,7 @@ public: if (File::Exists(image_path)) { toprow->Add(new AsyncImageFileView(image_path, IS_KEEP_ASPECT, new LinearLayoutParams(480, 272, Margins(10, 0)))); } else { + auto sa = GetI18NCategory(I18NCat::SAVEDATA); toprow->Add(new TextView(sa->T("No screenshot"), new LinearLayoutParams(Margins(10, 5))))->SetTextColor(textStyle.fgColor); } content->Add(new TextView(GetFileDateAsString(savePath_), 0, true, new LinearLayoutParams(Margins(10, 5))))->SetTextColor(textStyle.fgColor); @@ -613,7 +613,6 @@ SavedataScreen::~SavedataScreen() { void SavedataScreen::CreateViews() { using namespace UI; auto sa = GetI18NCategory(I18NCat::SAVEDATA); - auto di = GetI18NCategory(I18NCat::DIALOG); Path savedata_dir = GetSysDirectory(DIRECTORY_SAVEDATA); Path savestate_dir = GetSysDirectory(DIRECTORY_SAVESTATE); @@ -655,6 +654,7 @@ void SavedataScreen::CreateViews() { AddStandardBack(root_); if (System_GetPropertyBool(SYSPROP_HAS_TEXT_INPUT_DIALOG)) { + auto di = GetI18NCategory(I18NCat::DIALOG); root_->Add(new Choice(di->T("Search"), "", false, new AnchorLayoutParams(WRAP_CONTENT, 64, NONE, NONE, 10, 10)))->OnClick.Handle(this, &SavedataScreen::OnSearch); } @@ -672,8 +672,8 @@ UI::EventReturn SavedataScreen::OnSortClick(UI::EventParams &e) { } UI::EventReturn SavedataScreen::OnSearch(UI::EventParams &e) { - auto di = GetI18NCategory(I18NCat::DIALOG); if (System_GetPropertyBool(SYSPROP_HAS_TEXT_INPUT_DIALOG)) { + auto di = GetI18NCategory(I18NCat::DIALOG); System_InputBoxGetString(di->T("Filter"), searchFilter_, [](const std::string &value, int ivalue) { System_PostUIMessage(UIMessage::SAVEDATA_SEARCH, value); }); diff --git a/UI/Store.cpp b/UI/Store.cpp index 76bf39f3f9..c1701301b6 100644 --- a/UI/Store.cpp +++ b/UI/Store.cpp @@ -495,7 +495,6 @@ void StoreScreen::CreateViews() { root_ = new LinearLayout(ORIENT_VERTICAL); auto di = GetI18NCategory(I18NCat::DIALOG); - auto st = GetI18NCategory(I18NCat::STORE); auto mm = GetI18NCategory(I18NCat::MAINMENU); // Top bar @@ -508,6 +507,7 @@ void StoreScreen::CreateViews() { LinearLayout *content; if (connectionError_ || loading_) { + auto st = GetI18NCategory(I18NCat::STORE); content = new LinearLayout(ORIENT_VERTICAL, new LinearLayoutParams(FILL_PARENT, FILL_PARENT, 1.0f)); content->Add(new TextView(loading_ ? std::string(st->T("Loading...")) : StringFromFormat("%s: %d", st->T("Connection Error"), resultCode_))); if (!loading_) { diff --git a/UI/TabbedDialogScreen.cpp b/UI/TabbedDialogScreen.cpp index 7f80be3056..7c570b0655 100644 --- a/UI/TabbedDialogScreen.cpp +++ b/UI/TabbedDialogScreen.cpp @@ -7,8 +7,6 @@ #include "UI/TabbedDialogScreen.h" UI::LinearLayout *TabbedUIDialogScreenWithGameBackground::AddTab(const char *tag, const std::string &title, bool isSearch) { - auto se = GetI18NCategory(I18NCat::SEARCH); - using namespace UI; ViewGroup *scroll = new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(FILL_PARENT, FILL_PARENT)); scroll->SetTag(tag); @@ -21,6 +19,7 @@ UI::LinearLayout *TabbedUIDialogScreenWithGameBackground::AddTab(const char *tag if (!isSearch) { settingTabContents_.push_back(contents); + auto se = GetI18NCategory(I18NCat::SEARCH); auto notice = contents->Add(new TextView(se->T("Filtering settings by '%1'"), new LinearLayoutParams(Margins(20, 5)))); notice->SetVisibility(V_GONE); settingTabFilterNotices_.push_back(notice); @@ -39,12 +38,10 @@ void TabbedUIDialogScreenWithGameBackground::CreateViews() { // Scrolling action menu to the right. using namespace UI; - auto ms = GetI18NCategory(I18NCat::MAINSETTINGS); - auto di = GetI18NCategory(I18NCat::DIALOG); - root_ = new AnchorLayout(new LayoutParams(FILL_PARENT, FILL_PARENT)); if (vertical) { + auto di = GetI18NCategory(I18NCat::DIALOG); LinearLayout *verticalLayout = new LinearLayout(ORIENT_VERTICAL, new LayoutParams(FILL_PARENT, FILL_PARENT)); tabHolder_ = new TabHolder(ORIENT_HORIZONTAL, 200, new LinearLayoutParams(1.0f)); verticalLayout->Add(tabHolder_); @@ -82,6 +79,7 @@ void TabbedUIDialogScreenWithGameBackground::CreateViews() { int deviceType = System_GetPropertyInt(SYSPROP_DEVICE_TYPE); if ((g_display.dp_xres < g_display.dp_yres || g_display.dp_yres >= 500) && (deviceType != DEVICE_TYPE_VR) && ShowSearchControls()) { auto se = GetI18NCategory(I18NCat::SEARCH); + auto ms = GetI18NCategory(I18NCat::MAINSETTINGS); // Search LinearLayout *searchSettings = AddTab("GameSettingsSearch", ms->T("Search"), true); diff --git a/Windows/GEDebugger/TabState.cpp b/Windows/GEDebugger/TabState.cpp index 5719d2a347..335cf2302e 100644 --- a/Windows/GEDebugger/TabState.cpp +++ b/Windows/GEDebugger/TabState.cpp @@ -17,6 +17,7 @@ #include "Common/CommonWindows.h" #include +#include #include "Common/CommonFuncs.h" #include "Common/CommonTypes.h" #include "Common/Data/Encoding/Utf8.h" @@ -727,7 +728,7 @@ void FormatStateRow(wchar_t *dest, const TabStateRow &info, u32 value, bool enab case CMD_FMT_TEXLEVEL: { - const char *mipLevelModes[] = { + static constexpr std::array mipLevelModes = { "auto + bias", "bias", "slope + bias", @@ -768,13 +769,13 @@ void FormatStateRow(wchar_t *dest, const TabStateRow &info, u32 value, bool enab case CMD_FMT_TEXMAPMODE: { - const char *uvGenModes[] = { + static constexpr std::array uvGenModes = { "tex coords", "tex matrix", "tex env map", "unknown (tex coords?)", }; - const char *uvProjModes[] = { + static constexpr std::array uvProjModes = { "pos", "uv", "normalized normal", @@ -812,13 +813,13 @@ void FormatStateRow(wchar_t *dest, const TabStateRow &info, u32 value, bool enab case CMD_FMT_LIGHTTYPE: { - const char *lightComputations[] = { + static constexpr std::array lightComputations = { "diffuse", "diffuse + spec", "pow(diffuse)", "unknown (diffuse?)", }; - const char *lightTypes[] = { + static constexpr std::array lightTypes = { "directional", "point", "spot", diff --git a/Windows/GPU/WindowsGLContext.cpp b/Windows/GPU/WindowsGLContext.cpp index 026d70f29c..e799a2e330 100644 --- a/Windows/GPU/WindowsGLContext.cpp +++ b/Windows/GPU/WindowsGLContext.cpp @@ -241,8 +241,6 @@ bool WindowsGLContext::InitFromRenderThread(std::string *error_message) { // GL_VERSION GL_VENDOR GL_RENDERER // "1.4.0 - Build 8.14.10.2364" "intel" intel Pineview Platform - auto err = GetI18NCategory(I18NCat::ERRORS); - std::string glVersion = (const char *)glGetString(GL_VERSION); std::string glRenderer = (const char *)glGetString(GL_RENDERER); const std::string openGL_1 = "1."; @@ -262,6 +260,7 @@ bool WindowsGLContext::InitFromRenderThread(std::string *error_message) { "DirectX is currently compatible with less games, but on your GPU it may be the only choice.\n\n" "Visit the forums at https://forums.ppsspp.org for more information.\n\n"; + auto err = GetI18NCategory(I18NCat::ERRORS); std::wstring versionDetected = ConvertUTF8ToWString(glVersion + "\n\n"); std::wstring error = ConvertUTF8ToWString(err->T("InsufficientOpenGLDriver", defaultError)); std::wstring title = ConvertUTF8ToWString(err->T("OpenGLDriverError", "OpenGL driver error")); diff --git a/Windows/XinputDevice.cpp b/Windows/XinputDevice.cpp index 8d65b3fe28..7ad79255ef 100644 --- a/Windows/XinputDevice.cpp +++ b/Windows/XinputDevice.cpp @@ -165,11 +165,11 @@ int XinputDevice::UpdateState() { bool anySuccess = false; for (int i = 0; i < XUSER_MAX_COUNT; i++) { XINPUT_STATE state{}; - XINPUT_VIBRATION vibration{}; if (check_delay[i]-- > 0) continue; DWORD dwResult = PPSSPP_XInputGetState(i, &state); if (dwResult == ERROR_SUCCESS) { + XINPUT_VIBRATION vibration{}; UpdatePad(i, state, vibration); anySuccess = true; } else {