diff --git a/Common/Data/Text/Parsers.cpp b/Common/Data/Text/Parsers.cpp index a4174c4818..41f611be84 100644 --- a/Common/Data/Text/Parsers.cpp +++ b/Common/Data/Text/Parsers.cpp @@ -7,7 +7,6 @@ // Not strictly a parser... void NiceSizeFormat(uint64_t size, char *out, size_t bufSize) { - const char *sizes[] = { "B","KB","MB","GB","TB","PB","EB" }; int s = 0; int frac = 0; while (size >= 1024) { @@ -18,8 +17,10 @@ void NiceSizeFormat(uint64_t size, char *out, size_t bufSize) { float f = (float)size + ((float)frac / 1024.0f); if (s == 0) snprintf(out, bufSize, "%d B", (int)size); - else + else { + const char* sizes[] = { "B","KB","MB","GB","TB","PB","EB" }; snprintf(out, bufSize, "%3.2f %s", f, sizes[s]); + } } std::string NiceSizeFormat(uint64_t size) { diff --git a/Common/File/FileUtil.cpp b/Common/File/FileUtil.cpp index 184f45ebfd..a431272bc3 100644 --- a/Common/File/FileUtil.cpp +++ b/Common/File/FileUtil.cpp @@ -519,8 +519,8 @@ bool CreateDir(const Path &path) { // Convert it to a "CreateDirIn" call, if possible, since that's // what we can do with the storage API. AndroidContentURI uri(path.ToString()); - std::string newDirName = uri.GetLastPart(); if (uri.NavigateUp()) { + std::string newDirName = uri.GetLastPart(); INFO_LOG(COMMON, "Calling Android_CreateDirectory(%s, %s)", uri.ToString().c_str(), newDirName.c_str()); return Android_CreateDirectory(uri.ToString(), newDirName) == StorageError::SUCCESS; } else { diff --git a/Common/File/PathBrowser.cpp b/Common/File/PathBrowser.cpp index 6091b73ef3..f9c0ba221c 100644 --- a/Common/File/PathBrowser.cpp +++ b/Common/File/PathBrowser.cpp @@ -35,9 +35,9 @@ bool LoadRemoteFileList(const Path &url, const std::string &userAgent, bool *can } // Start by requesting the list of files from the server. - http::RequestParams req(baseURL.Resource(), "text/plain, text/html; q=0.9, */*; q=0.8"); if (http.Resolve(baseURL.Host().c_str(), baseURL.Port())) { if (http.Connect(2, 20.0, cancel)) { + http::RequestParams req(baseURL.Resource(), "text/plain, text/html; q=0.9, */*; q=0.8"); net::RequestProgress progress(cancel); code = http.GET(req, &result, responseHeaders, &progress); http.Disconnect(); diff --git a/Common/OSVersion.cpp b/Common/OSVersion.cpp index f50c171094..ee35ef7c4e 100644 --- a/Common/OSVersion.cpp +++ b/Common/OSVersion.cpp @@ -159,10 +159,10 @@ std::string GetWindowsVersion() { // Start from higher to lower for (auto release = rbegin(windowsReleases); release != rend(windowsReleases); ++release) { - std::string previewText = release->first; WindowsReleaseInfo releaseInfo = release->second; bool buildMatch = DoesVersionMatchWindows(releaseInfo); if (buildMatch) { + std::string previewText = release->first; return previewText; } } diff --git a/Common/UI/PopupScreens.cpp b/Common/UI/PopupScreens.cpp index 2f70fd9810..d1b1f1abbe 100644 --- a/Common/UI/PopupScreens.cpp +++ b/Common/UI/PopupScreens.cpp @@ -333,7 +333,6 @@ void SliderPopupScreen::UpdateTextBox() { void SliderPopupScreen::CreatePopupContents(UI::ViewGroup *parent) { using namespace UI; UIContext &dc = *screenManager()->getUIContext(); - auto di = GetI18NCategory(I18NCat::DIALOG); sliderValue_ = *value_; if (disabled_ && sliderValue_ < 0) @@ -362,6 +361,7 @@ void SliderPopupScreen::CreatePopupContents(UI::ViewGroup *parent) { lin->Add(new TextView(units_))->SetTextColor(dc.theme->itemStyle.fgColor); if (defaultValue_ != NO_DEFAULT_FLOAT) { + auto di = GetI18NCategory(I18NCat::DIALOG); lin->Add(new Button(di->T("Reset")))->OnClick.Add([=](UI::EventParams &) { sliderValue_ = defaultValue_; changing_ = true; @@ -381,7 +381,6 @@ void SliderPopupScreen::CreatePopupContents(UI::ViewGroup *parent) { void SliderFloatPopupScreen::CreatePopupContents(UI::ViewGroup *parent) { using namespace UI; UIContext &dc = *screenManager()->getUIContext(); - auto di = GetI18NCategory(I18NCat::DIALOG); sliderValue_ = *value_; LinearLayout *vert = parent->Add(new LinearLayout(ORIENT_VERTICAL, new LinearLayoutParams(UI::Margins(10, 10)))); @@ -406,6 +405,7 @@ void SliderFloatPopupScreen::CreatePopupContents(UI::ViewGroup *parent) { lin->Add(new TextView(units_))->SetTextColor(dc.theme->itemStyle.fgColor); if (defaultValue_ != NO_DEFAULT_FLOAT) { + auto di = GetI18NCategory(I18NCat::DIALOG); lin->Add(new Button(di->T("Reset")))->OnClick.Add([=](UI::EventParams &) { sliderValue_ = defaultValue_; if (liveUpdate_) { diff --git a/Common/UI/UIScreen.cpp b/Common/UI/UIScreen.cpp index 927d8bdb4a..f7bdef840f 100644 --- a/Common/UI/UIScreen.cpp +++ b/Common/UI/UIScreen.cpp @@ -421,8 +421,8 @@ void PopupScreen::CreateViews() { box_->SetDropShadowExpand(std::max(g_display.dp_xres, g_display.dp_yres)); box_->SetSpacing(0.0f); - View *title = new PopupHeader(title_); if (HasTitleBar()) { + View* title = new PopupHeader(title_); box_->Add(title); } diff --git a/Core/Dialog/PSPNetconfDialog.cpp b/Core/Dialog/PSPNetconfDialog.cpp index c1802db9e7..55143dcf4f 100644 --- a/Core/Dialog/PSPNetconfDialog.cpp +++ b/Core/Dialog/PSPNetconfDialog.cpp @@ -239,7 +239,6 @@ int PSPNetconfDialog::Update(int animSpeed) { UpdateButtons(); UpdateCommon(); auto di = GetI18NCategory(I18NCat::DIALOG); - auto err = GetI18NCategory(I18NCat::ERRORS); u64 now = (u64)(time_now_d() * 1000000.0); // It seems JPCSP doesn't check for NETCONF_STATUS_APNET @@ -250,6 +249,7 @@ int PSPNetconfDialog::Update(int animSpeed) { StartDraw(); if (!hideNotice) { + auto err = GetI18NCategory(I18NCat::ERRORS); const float WRAP_WIDTH = 254.0f; const int confirmBtn = GetConfirmButton(); const int cancelBtn = GetCancelButton(); diff --git a/Core/Dialog/PSPNpSigninDialog.cpp b/Core/Dialog/PSPNpSigninDialog.cpp index 9af12480c9..22caaf2c9d 100644 --- a/Core/Dialog/PSPNpSigninDialog.cpp +++ b/Core/Dialog/PSPNpSigninDialog.cpp @@ -235,11 +235,11 @@ int PSPNpSigninDialog::Update(int animSpeed) { UpdateButtons(); UpdateCommon(); - auto di = GetI18NCategory(I18NCat::DIALOG); auto err = GetI18NCategory(I18NCat::ERRORS); u64 now = (u64)(time_now_d() * 1000000.0); if (request.npSigninStatus == NP_SIGNIN_STATUS_NONE) { + auto di = GetI18NCategory(I18NCat::DIALOG); UpdateFade(animSpeed); StartDraw(); diff --git a/Core/Dialog/SavedataParam.cpp b/Core/Dialog/SavedataParam.cpp index 8a82b3ab35..024a2584b1 100644 --- a/Core/Dialog/SavedataParam.cpp +++ b/Core/Dialog/SavedataParam.cpp @@ -1391,10 +1391,10 @@ bool SavedataParam::GetSize(SceUtilitySavedataParam *param) const std::string saveDir = savePath + GetGameName(param) + GetSaveName(param); bool exists = false; - auto listing = pspFileSystem.GetDirListing(saveDir, &exists); if (param->sizeInfo.IsValid()) { + auto listing = pspFileSystem.GetDirListing(saveDir, &exists); const u64 freeBytes = MemoryStick_FreeSpace(); s64 overwriteBytes = 0; diff --git a/Core/FileSystems/BlockDevices.cpp b/Core/FileSystems/BlockDevices.cpp index b5a1ca0a8a..03fca8d221 100644 --- a/Core/FileSystems/BlockDevices.cpp +++ b/Core/FileSystems/BlockDevices.cpp @@ -66,8 +66,8 @@ BlockDevice *constructBlockDevice(FileLoader *fileLoader) { } void BlockDevice::NotifyReadError() { - auto err = GetI18NCategory(I18NCat::ERRORS); if (!reportedError_) { + auto err = GetI18NCategory(I18NCat::ERRORS); g_OSD.Show(OSDType::MESSAGE_WARNING, err->T("Game disc read error - ISO corrupt"), fileLoader_->GetPath().ToVisualString(), 6.0f); reportedError_ = true; } diff --git a/Core/HLE/Plugins.cpp b/Core/HLE/Plugins.cpp index 745d747a54..a5bb60599e 100644 --- a/Core/HLE/Plugins.cpp +++ b/Core/HLE/Plugins.cpp @@ -180,8 +180,6 @@ bool Load() { auto sy = GetI18NCategory(I18NCat::SYSTEM); for (const std::string &filename : prxPlugins) { - std::string shortName = Path(filename).GetFilename(); - std::string error_string = ""; SceUID module = KernelLoadModule(filename, &error_string); if (!error_string.empty() || module < 0) { @@ -193,6 +191,7 @@ bool Load() { if (ret < 0) { ERROR_LOG(SYSTEM, "Unable to start plugin %s: %08x", filename.c_str(), ret); } else { + std::string shortName = Path(filename).GetFilename(); g_OSD.Show(OSDType::MESSAGE_SUCCESS, ApplySafeSubstitutions(sy->T("Loaded plugin: %1"), shortName)); started = true; } diff --git a/Core/HLE/proAdhoc.cpp b/Core/HLE/proAdhoc.cpp index 32ad2b4bfb..7863551efb 100644 --- a/Core/HLE/proAdhoc.cpp +++ b/Core/HLE/proAdhoc.cpp @@ -1312,7 +1312,6 @@ void timeoutFriendsRecursive(SceNetAdhocctlPeerInfo * node, int32_t* count) { void sendChat(const std::string &chatString) { SceNetAdhocctlChatPacketC2S chat; - auto n = GetI18NCategory(I18NCat::NETWORKING); chat.base.opcode = OPCODE_CHAT; //TODO check network inited, check send success or not, chatlog.pushback error on failed send, pushback error on not connected if (friendFinderRunning) { @@ -1334,6 +1333,7 @@ void sendChat(const std::string &chatString) { } } else { std::lock_guard guard(chatLogLock); + auto n = GetI18NCategory(I18NCat::NETWORKING); chatLog.push_back(n->T("You're in Offline Mode, go to lobby or online hall")); chatMessageGeneration++; } diff --git a/Core/HLE/sceAudiocodec.cpp b/Core/HLE/sceAudiocodec.cpp index 3c9643d897..296b5bf90e 100644 --- a/Core/HLE/sceAudiocodec.cpp +++ b/Core/HLE/sceAudiocodec.cpp @@ -100,8 +100,6 @@ static int sceAudiocodecDecode(u32 ctxPtr, int codec) { } if (IsValidCodec(codec)){ - // Use SimpleAudioDec to decode audio - auto ctx = PSPPointer::Create(ctxPtr); // On stack, no need to allocate. int outbytes = 0; // find a decoder in audioList auto decoder = findDecoder(ctxPtr); @@ -115,6 +113,8 @@ static int sceAudiocodecDecode(u32 ctxPtr, int codec) { } if (decoder != NULL) { + // Use SimpleAudioDec to decode audio + auto ctx = PSPPointer::Create(ctxPtr); // On stack, no need to allocate. // Decode audio decoder->Decode(Memory::GetPointer(ctx->inDataPtr), ctx->inDataSize, Memory::GetPointerWrite(ctx->outDataPtr), &outbytes); } diff --git a/Core/HLE/sceFont.cpp b/Core/HLE/sceFont.cpp index 7259bd2d8d..cb729b672d 100644 --- a/Core/HLE/sceFont.cpp +++ b/Core/HLE/sceFont.cpp @@ -519,10 +519,10 @@ public: fontMap.erase(fonts_[i]); } } - u32 args[2] = { userDataAddr(), (u32)handle_ }; // TODO: The return value of this is leaking. if (handle_) { // Avoid calling free-callback on double-free if (coreState != CORE_POWERDOWN) { + u32 args[2] = { userDataAddr(), (u32)handle_ }; hleEnqueueCall(freeFuncAddr(), 2, args); } } diff --git a/Core/HLE/sceKernelModule.cpp b/Core/HLE/sceKernelModule.cpp index c8fbbff1d1..bd61e25b75 100644 --- a/Core/HLE/sceKernelModule.cpp +++ b/Core/HLE/sceKernelModule.cpp @@ -2164,7 +2164,6 @@ int KernelStartModule(SceUID moduleId, u32 argsize, u32 argAddr, u32 returnValue static void sceKernelStartModule(u32 moduleId, u32 argsize, u32 argAddr, u32 returnValueAddr, u32 optionAddr) { - auto smoption = PSPPointer::Create(optionAddr); u32 error; PSPModule *module = kernelObjects.Get(moduleId, error); if (!module) { @@ -2190,6 +2189,7 @@ static void sceKernelStartModule(u32 moduleId, u32 argsize, u32 argAddr, u32 ret moduleId,argsize,argAddr,returnValueAddr,optionAddr); bool needsWait; + auto smoption = PSPPointer::Create(optionAddr); int ret = KernelStartModule(moduleId, argsize, argAddr, returnValueAddr, smoption.PtrOrNull(), &needsWait); if (needsWait) { diff --git a/Core/MIPS/MIPSAnalyst.cpp b/Core/MIPS/MIPSAnalyst.cpp index 1cdeeb00ba..da8fe13a39 100644 --- a/Core/MIPS/MIPSAnalyst.cpp +++ b/Core/MIPS/MIPSAnalyst.cpp @@ -1179,10 +1179,10 @@ skip: void FinalizeScan(bool insertSymbols) { HashFunctions(); - Path hashMapFilename = GetSysDirectory(DIRECTORY_SYSTEM) / "knownfuncs.ini"; if (g_Config.bFuncHashMap || g_Config.bFuncReplacements) { LoadBuiltinHashMap(); if (g_Config.bFuncHashMap) { + Path hashMapFilename = GetSysDirectory(DIRECTORY_SYSTEM) / "knownfuncs.ini"; LoadHashMap(hashMapFilename); StoreHashMap(hashMapFilename); } diff --git a/Core/SaveState.cpp b/Core/SaveState.cpp index a2248b3ff2..e113ef3ec7 100644 --- a/Core/SaveState.cpp +++ b/Core/SaveState.cpp @@ -367,7 +367,6 @@ namespace SaveState } // Memory is a bit tricky when jit is enabled, since there's emuhacks in it. - auto savedReplacements = SaveAndClearReplacements(); if (MIPSComp::jit && p.mode == p.MODE_WRITE) { std::lock_guard guard(MIPSComp::jitLock); if (MIPSComp::jit) { @@ -388,8 +387,10 @@ namespace SaveState // Don't bother restoring if reading, we'll deal with that in KernelModuleDoState. // In theory, different functions might have been runtime loaded in the state. - if (p.mode != p.MODE_READ) + if (p.mode != p.MODE_READ) { + auto savedReplacements = SaveAndClearReplacements(); RestoreSavedReplacements(savedReplacements); + } MemoryStick_DoState(p); currentMIPS->DoState(p); @@ -601,18 +602,20 @@ namespace SaveState Load(fn, slot, callback, cbUserData); } } else { - auto sy = GetI18NCategory(I18NCat::SYSTEM); - if (callback) + if (callback) { + auto sy = GetI18NCategory(I18NCat::SYSTEM); callback(Status::FAILURE, sy->T("Failed to load state. Error in the file system."), cbUserData); + } } } bool UndoLoad(const Path &gameFilename, Callback callback, void *cbUserData) { if (g_Config.sStateLoadUndoGame != GenerateFullDiscId(gameFilename)) { - auto sy = GetI18NCategory(I18NCat::SYSTEM); - if (callback) + if (callback) { + auto sy = GetI18NCategory(I18NCat::SYSTEM); callback(Status::FAILURE, sy->T("Error: load undo state is from a different game"), cbUserData); + } return false; } @@ -621,9 +624,10 @@ namespace SaveState Load(fn, LOAD_UNDO_SLOT, callback, cbUserData); return true; } else { - auto sy = GetI18NCategory(I18NCat::SYSTEM); - if (callback) + if (callback) { + auto sy = GetI18NCategory(I18NCat::SYSTEM); callback(Status::FAILURE, sy->T("Failed to load state for load undo. Error in the file system."), cbUserData); + } return false; } } @@ -631,10 +635,9 @@ namespace SaveState void SaveSlot(const Path &gameFilename, int slot, Callback callback, void *cbUserData) { Path fn = GenerateSaveSlotFilename(gameFilename, slot, STATE_EXTENSION); - Path shot = GenerateSaveSlotFilename(gameFilename, slot, SCREENSHOT_EXTENSION); Path fnUndo = GenerateSaveSlotFilename(gameFilename, slot, UNDO_STATE_EXTENSION); - Path shotUndo = GenerateSaveSlotFilename(gameFilename, slot, UNDO_SCREENSHOT_EXTENSION); if (!fn.empty()) { + Path shot = GenerateSaveSlotFilename(gameFilename, slot, SCREENSHOT_EXTENSION); auto renameCallback = [=](Status status, const std::string &message, void *data) { if (status != Status::FAILURE) { if (g_Config.bEnableStateUndo) { @@ -654,26 +657,28 @@ namespace SaveState }; // Let's also create a screenshot. if (g_Config.bEnableStateUndo) { + Path shotUndo = GenerateSaveSlotFilename(gameFilename, slot, UNDO_SCREENSHOT_EXTENSION); DeleteIfExists(shotUndo); RenameIfExists(shot, shotUndo); } SaveScreenshot(shot, Callback(), 0); Save(fn.WithExtraExtension(".tmp"), slot, renameCallback, cbUserData); } else { - auto sy = GetI18NCategory(I18NCat::SYSTEM); - if (callback) + if (callback) { + auto sy = GetI18NCategory(I18NCat::SYSTEM); callback(Status::FAILURE, sy->T("Failed to save state. Error in the file system."), cbUserData); + } } } - bool UndoSaveSlot(const Path &gameFilename, int slot) { - Path fn = GenerateSaveSlotFilename(gameFilename, slot, STATE_EXTENSION); - Path shot = GenerateSaveSlotFilename(gameFilename, slot, SCREENSHOT_EXTENSION); + bool UndoSaveSlot(const Path &gameFilename, int slot) { Path fnUndo = GenerateSaveSlotFilename(gameFilename, slot, UNDO_STATE_EXTENSION); - Path shotUndo = GenerateSaveSlotFilename(gameFilename, slot, UNDO_SCREENSHOT_EXTENSION); // Do nothing if there's no undo. if (File::Exists(fnUndo)) { + Path fn = GenerateSaveSlotFilename(gameFilename, slot, STATE_EXTENSION); + Path shot = GenerateSaveSlotFilename(gameFilename, slot, SCREENSHOT_EXTENSION); + Path shotUndo = GenerateSaveSlotFilename(gameFilename, slot, UNDO_SCREENSHOT_EXTENSION); // Swap them so they can undo again to redo. Mistakes happen. SwapIfExists(shotUndo, shot); SwapIfExists(fnUndo, fn); diff --git a/Core/Util/DisArm64.cpp b/Core/Util/DisArm64.cpp index 050589f2f0..5fc2a6eba9 100644 --- a/Core/Util/DisArm64.cpp +++ b/Core/Util/DisArm64.cpp @@ -23,6 +23,7 @@ #include #include +#include #include "Common/Arm64Emitter.h" #include "Common/StringUtils.h" @@ -496,7 +497,7 @@ static void DataProcessingRegister(uint32_t w, uint64_t addr, Instruction *instr int op31 = (w >> 21) & 0x7; int o0 = (w >> 15) & 1; int Ra = (w >> 10) & 0x1f; - const char *opnames[8] = { 0, 0, "maddl", "msubl", "smulh", 0, 0, 0 }; + static constexpr std::array opnames = { 0, 0, "maddl", "msubl", "smulh", 0, 0, 0 }; if (op31 == 0) { // madd/msub supports both 32-bit and 64-bit modes diff --git a/GPU/Common/ShaderId.cpp b/GPU/Common/ShaderId.cpp index a23c37cd05..570b5407e6 100644 --- a/GPU/Common/ShaderId.cpp +++ b/GPU/Common/ShaderId.cpp @@ -1,5 +1,6 @@ #include #include +#include #include "Common/GPU/thin3d.h" #include "Common/StringUtils.h" @@ -29,7 +30,7 @@ std::string VertexShaderDesc(const VShaderID &id) { const char *uvprojModes[4] = { "TexProjPos ", "TexProjUV ", "TexProjNNrm ", "TexProjNrm " }; desc << uvprojModes[uvprojMode]; } - const char *uvgModes[4] = { "UV ", "UVMtx ", "UVEnv ", "UVUnk " }; + static constexpr std::array uvgModes = { "UV ", "UVMtx ", "UVEnv ", "UVUnk " }; int ls0 = id.Bits(VS_BIT_LS0, 2); int ls1 = id.Bits(VS_BIT_LS1, 2); diff --git a/GPU/Common/TextureCacheCommon.cpp b/GPU/Common/TextureCacheCommon.cpp index a3880143fc..1d10254f1d 100644 --- a/GPU/Common/TextureCacheCommon.cpp +++ b/GPU/Common/TextureCacheCommon.cpp @@ -1116,7 +1116,6 @@ bool TextureCacheCommon::MatchFramebuffer( void TextureCacheCommon::SetTextureFramebuffer(const AttachCandidate &candidate) { VirtualFramebuffer *framebuffer = candidate.fb; - FramebufferMatchInfo fbInfo = candidate.match; RasterChannel channel = candidate.channel; if (candidate.match.reinterpret) { @@ -1132,6 +1131,7 @@ void TextureCacheCommon::SetTextureFramebuffer(const AttachCandidate &candidate) nextFramebufferTextureChannel_ = RASTER_COLOR; if (framebufferManager_->UseBufferedRendering()) { + FramebufferMatchInfo fbInfo = candidate.match; // Detect when we need to apply the horizontal texture swizzle. u64 depthUpperBits = (channel == RASTER_DEPTH && framebuffer->fb_format == GE_FORMAT_8888) ? ((gstate.getTextureAddress(0) & 0x600000) >> 20) : 0; bool needsDepthXSwizzle = depthUpperBits == 2; diff --git a/GPU/Common/TransformCommon.cpp b/GPU/Common/TransformCommon.cpp index 5d74f30dd3..7738430dc1 100644 --- a/GPU/Common/TransformCommon.cpp +++ b/GPU/Common/TransformCommon.cpp @@ -148,7 +148,7 @@ void Lighter::Light(float colorOut0[4], float colorOut1[4], const float colorIn[ Color4 diff = (lightDiff * *diffuse) * dot; // Real PSP specular - Vec3f toViewer(0, 0, 1); + static const Vec3f toViewer(0, 0, 1); // Better specular // Vec3f toViewer = (viewer - pos).NormalizedOr001(cpu_info.bSSE4_1); diff --git a/GPU/Debugger/Record.cpp b/GPU/Debugger/Record.cpp index b0cc4a5a62..81aeb4af4e 100644 --- a/GPU/Debugger/Record.cpp +++ b/GPU/Debugger/Record.cpp @@ -619,7 +619,6 @@ void ClearCallback() { static void FinishRecording() { // We're done - this was just to write the result out. - Path filename = WriteRecording(); commands.clear(); pushbuf.clear(); lastVRAM.clear(); @@ -630,8 +629,10 @@ static void FinishRecording() { flipFinishAt = -1; lastEdramTrans = 0x400; - if (writeCallback) + if (writeCallback) { + Path filename = WriteRecording(); writeCallback(filename); + } writeCallback = nullptr; } diff --git a/GPU/Directx9/ShaderManagerDX9.cpp b/GPU/Directx9/ShaderManagerDX9.cpp index b40b8e9457..5f97efa3f9 100644 --- a/GPU/Directx9/ShaderManagerDX9.cpp +++ b/GPU/Directx9/ShaderManagerDX9.cpp @@ -594,7 +594,6 @@ VSShader *ShaderManagerDX9::ApplyShader(bool useHWTransform, bool useHWTessellat vs = new VSShader(device_, VSID, codeBuffer_, useHWTransform); } if (!vs || vs->Failed()) { - auto gr = GetI18NCategory(I18NCat::GRAPHICS); if (!vs) { // TODO: Report this? ERROR_LOG(G3D, "Shader generation failed, falling back to software transform"); @@ -602,6 +601,7 @@ VSShader *ShaderManagerDX9::ApplyShader(bool useHWTransform, bool useHWTessellat ERROR_LOG(G3D, "Shader compilation failed, falling back to software transform"); } if (!g_Config.bHideSlowWarnings) { + auto gr = GetI18NCategory(I18NCat::GRAPHICS); g_OSD.Show(OSDType::MESSAGE_ERROR, gr->T("hardware transform error - falling back to software"), 2.5f); } delete vs; diff --git a/GPU/GLES/ShaderManagerGLES.cpp b/GPU/GLES/ShaderManagerGLES.cpp index 10b25a3ebb..b6ce10489e 100644 --- a/GPU/GLES/ShaderManagerGLES.cpp +++ b/GPU/GLES/ShaderManagerGLES.cpp @@ -804,9 +804,9 @@ Shader *ShaderManagerGLES::ApplyVertexShader(bool useHWTransform, bool useHWTess // Vertex shader not in cache. Let's compile it. vs = CompileVertexShader(*VSID); if (!vs) { - auto gr = GetI18NCategory(I18NCat::GRAPHICS); ERROR_LOG(G3D, "Vertex shader generation failed, falling back to software transform"); if (!g_Config.bHideSlowWarnings) { + auto gr = GetI18NCategory(I18NCat::GRAPHICS); g_OSD.Show(OSDType::MESSAGE_ERROR, gr->T("hardware transform error - falling back to software"), 2.5f); } diff --git a/GPU/Software/Lighting.cpp b/GPU/Software/Lighting.cpp index a19630cec1..49680cc10f 100644 --- a/GPU/Software/Lighting.cpp +++ b/GPU/Software/Lighting.cpp @@ -281,10 +281,11 @@ static inline float Dot33(const Vec3f &a, const Vec3f &b) { template static void ProcessSIMD(VertexData &vertex, const WorldCoords &worldpos, const WorldCoords &worldnormal, const State &state) { // Lighting blending rounds using the half offset method (like alpha blend.) - const Vec4 ones = Vec4::AssignToAll(1); Vec4 colorFactor; - if (state.colorForAmbient || state.colorForDiffuse || state.colorForSpecular) + if (state.colorForAmbient || state.colorForDiffuse || state.colorForSpecular) { + const Vec4 ones = Vec4::AssignToAll(1); colorFactor = LightColorFactor(vertex.color0, ones); + } Vec4 mec = Vec4::FromRGBA(gstate.getMaterialEmissive()); diff --git a/GPU/Software/Rasterizer.cpp b/GPU/Software/Rasterizer.cpp index b4f924e19a..51c6979b97 100644 --- a/GPU/Software/Rasterizer.cpp +++ b/GPU/Software/Rasterizer.cpp @@ -1406,7 +1406,6 @@ void DrawRectangle(const VertexData &v0, const VertexData &v1, const BinCoords & void DrawPoint(const VertexData &v0, const BinCoords &range, const RasterizerState &state) { ScreenCoords pos = v0.screenpos; Vec4 prim_color = Vec4::FromRGBA(v0.color0); - Vec3 sec_color = Vec3::FromRGB(v0.color1); auto &pixelID = state.pixelID; auto &samplerID = state.samplerID; @@ -1446,8 +1445,10 @@ void DrawPoint(const VertexData &v0, const BinCoords &range, const RasterizerSta prim_color = ApplyTexturingSingle(s, t, ToVec4IntArg(prim_color), texLevel, texLevelFrac, bilinear, state); } - if (!pixelID.clearMode) + if (!pixelID.clearMode) { + Vec3 sec_color = Vec3::FromRGB(v0.color1); prim_color += Vec4(sec_color, 0); + } u8 fog = 255; if (pixelID.applyFog) { 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 78dd578fc8..0697ce5169 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")); } @@ -978,7 +977,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(); @@ -1011,6 +1009,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 5d03a06765..bedb7d73e4 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; @@ -661,7 +661,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); @@ -686,6 +685,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"))); @@ -1509,8 +1509,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"; @@ -1520,6 +1518,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; } @@ -1553,10 +1552,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_); @@ -1569,11 +1567,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. @@ -1592,8 +1589,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_); @@ -1947,10 +1944,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 {