From cbcd9b5004ac34caf1d4b1c48a39352b252caedb Mon Sep 17 00:00:00 2001 From: TellowKrinkle Date: Thu, 14 Jan 2021 01:13:33 -0600 Subject: [PATCH] wx: Remove wxString implicit constructor from std::string On windows, it uses the current system's character encoding instead of utf-8, which breaks a lot of things. We should avoid it. --- 3rdparty/wxwidgets3.0/include/wx/string.h | 3 +- 3rdparty/wxwidgets3.0/include/wx/variant.h | 2 ++ 3rdparty/wxwidgets3.0/src/common/variant.cpp | 2 ++ common/Console.cpp | 22 ++++++++++++ common/Console.h | 5 +++ common/Dependencies.h | 1 + common/IniInterface.cpp | 4 +-- common/StringHelpers.cpp | 5 +++ pcsx2/CDVD/CDVDaccess.cpp | 2 +- pcsx2/CDVD/GzippedFileReader.cpp | 2 +- pcsx2/DEV9/DEV9Config.cpp | 4 +-- pcsx2/DebugTools/Debug.h | 5 +++ pcsx2/GS/Window/GSwxDialog.cpp | 8 ++--- pcsx2/MemoryCardFolder.cpp | 37 ++++++++++---------- pcsx2/Patch.cpp | 2 +- pcsx2/R5900.cpp | 2 +- pcsx2/Recording/InputRecording.cpp | 4 +-- pcsx2/gui/AppCoreThread.cpp | 10 +++--- pcsx2/gui/AppMain.cpp | 2 +- pcsx2/gui/ConsoleLogger.cpp | 2 +- pcsx2/gui/DriveList.cpp | 4 +-- pcsx2/gui/MainFrame.cpp | 10 +++--- pcsx2/gui/MainMenuClicks.cpp | 2 +- pcsx2/gui/Panels/GSWindowPanel.cpp | 2 +- pcsx2/gui/Panels/VideoPanel.cpp | 8 ++--- pcsx2/ps2/BiosTools.cpp | 5 +-- 26 files changed, 100 insertions(+), 55 deletions(-) diff --git a/3rdparty/wxwidgets3.0/include/wx/string.h b/3rdparty/wxwidgets3.0/include/wx/string.h index ef1a8d9aa8..ddd5fe0081 100644 --- a/3rdparty/wxwidgets3.0/include/wx/string.h +++ b/3rdparty/wxwidgets3.0/include/wx/string.h @@ -1319,7 +1319,7 @@ public: wxString(const wxStdWideString& str) { assign(str.c_str(), str.length()); } #endif - +#ifndef _WIN32 // PCSX2: We don't want to accidentally interpret utf-8 std::strings as something else! #if !wxUSE_UNICODE // ANSI build // FIXME-UTF8: do this in UTF8 build #if wxUSE_UTF8_LOCALE_ONLY, too wxString(const std::string& str) : m_impl(str) {} @@ -1327,6 +1327,7 @@ public: wxString(const std::string& str) { assign(str.c_str(), str.length()); } #endif +#endif #endif // wxUSE_STD_STRING // Also always provide explicit conversions to std::[w]string in any case, diff --git a/3rdparty/wxwidgets3.0/include/wx/variant.h b/3rdparty/wxwidgets3.0/include/wx/variant.h index 39adc729b9..f766971baa 100644 --- a/3rdparty/wxwidgets3.0/include/wx/variant.h +++ b/3rdparty/wxwidgets3.0/include/wx/variant.h @@ -230,6 +230,7 @@ public: wxString GetString() const; #if wxUSE_STD_STRING +#ifndef _WIN32 // PCSX2: std::string conversion removal wxVariant(const std::string& val, const wxString& name = wxEmptyString); bool operator==(const std::string& value) const { return operator==(wxString(value)); } @@ -238,6 +239,7 @@ public: wxVariant& operator=(const std::string& value) { return operator=(wxString(value)); } operator std::string() const { return (operator wxString()).ToStdString(); } +#endif wxVariant(const wxStdWideString& val, const wxString& name = wxEmptyString); bool operator==(const wxStdWideString& value) const diff --git a/3rdparty/wxwidgets3.0/src/common/variant.cpp b/3rdparty/wxwidgets3.0/src/common/variant.cpp index 5fc1931bba..1eea3db852 100644 --- a/3rdparty/wxwidgets3.0/src/common/variant.cpp +++ b/3rdparty/wxwidgets3.0/src/common/variant.cpp @@ -981,11 +981,13 @@ wxVariant::wxVariant(const wxScopedWCharBuffer& val, const wxString& name) } #if wxUSE_STD_STRING +#ifndef _WIN32 // PCSX2: std::string conversion removal wxVariant::wxVariant(const std::string& val, const wxString& name) { m_refData = new wxVariantDataString(wxString(val)); m_name = name; } +#endif wxVariant::wxVariant(const wxStdWideString& val, const wxString& name) { diff --git a/common/Console.cpp b/common/Console.cpp index 4c98f6e045..a4fd650bdb 100644 --- a/common/Console.cpp +++ b/common/Console.cpp @@ -470,6 +470,28 @@ bool IConsoleWriter::Warning(const wxString fmt, ...) const return false; } +bool IConsoleWriter::WriteLn(ConsoleColors color, const std::string& str) const +{ + ConsoleColorScope cs(color); + return WriteLn(str); +} + +bool IConsoleWriter::WriteLn(const std::string& str) const +{ + DoWriteLn(_addIndentation(fromUTF8(str), conlog_Indent)); + + return false; +} + +bool IConsoleWriter::Error(const std::string& str) const +{ + return WriteLn(Color_StrongRed, str); +} + +bool IConsoleWriter::Warning(const std::string& str) const +{ + return WriteLn(Color_StrongOrange, str); +} // -------------------------------------------------------------------------------------- // ConsoleColorScope / ConsoleIndentScope diff --git a/common/Console.h b/common/Console.h index 0a30f6c716..1094884c4a 100644 --- a/common/Console.h +++ b/common/Console.h @@ -125,6 +125,11 @@ struct IConsoleWriter bool WriteLn(const wxString fmt, ...) const; bool Error(const wxString fmt, ...) const; bool Warning(const wxString fmt, ...) const; + + bool WriteLn(ConsoleColors color, const std::string& str) const; + bool WriteLn(const std::string& str) const; + bool Error(const std::string& str) const; + bool Warning(const std::string& str) const; }; // -------------------------------------------------------------------------------------- diff --git a/common/Dependencies.h b/common/Dependencies.h index fcc7ed917c..0e31fa8fee 100644 --- a/common/Dependencies.h +++ b/common/Dependencies.h @@ -270,6 +270,7 @@ extern const wxChar* __fastcall pxExpandMsg(const wxChar* message); extern const wxChar* __fastcall pxGetTranslation(const wxChar* message); extern bool pxIsEnglish(int id); +extern wxString fromUTF8(const std::string& str); extern wxString fromUTF8(const char* src); extern wxString fromAscii(const char* src); diff --git a/common/IniInterface.cpp b/common/IniInterface.cpp index e794c4bad1..02cacee4df 100644 --- a/common/IniInterface.cpp +++ b/common/IniInterface.cpp @@ -274,7 +274,7 @@ void IniLoader::Entry(const wxString& var, std::string& value, const std::string if (m_Config) { wxString temp; - m_Config->Read(var, &temp, wxString(default_value)); + m_Config->Read(var, &temp, fromUTF8(default_value)); value = temp.ToStdString(); } else if (&value != &default_value) @@ -443,5 +443,5 @@ void IniSaver::Entry(const wxString& var, std::string& value, const std::string& { if (!m_Config) return; - m_Config->Write(var, wxString(value)); + m_Config->Write(var, fromUTF8(value)); } diff --git a/common/StringHelpers.cpp b/common/StringHelpers.cpp index 6f3d1a8900..4b256f272a 100644 --- a/common/StringHelpers.cpp +++ b/common/StringHelpers.cpp @@ -31,6 +31,11 @@ __fi wxString fromUTF8(const char* src) return wxString(src, wxMBConvUTF8()); } +__fi wxString fromUTF8(const std::string& str) +{ + return wxString(str.data(), wxMBConvUTF8(), str.size()); +} + __fi wxString fromAscii(const char* src) { return wxString::FromAscii(src); diff --git a/pcsx2/CDVD/CDVDaccess.cpp b/pcsx2/CDVD/CDVDaccess.cpp index de5d9323d2..a20a9051e9 100644 --- a/pcsx2/CDVD/CDVDaccess.cpp +++ b/pcsx2/CDVD/CDVDaccess.cpp @@ -376,7 +376,7 @@ bool DoCDVDopen() return true; } - wxString somepick(Path::GetFilenameWithoutExt(m_SourceFilename[CurrentSourceType])); + wxString somepick(Path::GetFilenameWithoutExt(fromUTF8(m_SourceFilename[CurrentSourceType]))); //FWIW Disc serial availability doesn't seem reliable enough, sometimes it's there and sometime it's just null //Shouldn't the serial be available all time? Potentially need to look into Elfreloadinfo() reliability //TODO: Add extra fallback case for CRC. diff --git a/pcsx2/CDVD/GzippedFileReader.cpp b/pcsx2/CDVD/GzippedFileReader.cpp index 5bc4c44ea0..2f99614cfa 100644 --- a/pcsx2/CDVD/GzippedFileReader.cpp +++ b/pcsx2/CDVD/GzippedFileReader.cpp @@ -185,7 +185,7 @@ static wxString iso2indexname(const wxString& isoname) wxDirName appRoot = // TODO: have only one of this in PCSX2. Right now have few... (wxDirName)(wxFileName(wxStandardPaths::Get().GetExecutablePath()).GetPath()); //TestTemplate(appRoot, isoname, false); - return ApplyTemplate(L"gzip index", appRoot, EmuConfig.GzipIsoIndexTemplate, isoname, false); + return ApplyTemplate(L"gzip index", appRoot, fromUTF8(EmuConfig.GzipIsoIndexTemplate), isoname, false); } GzippedFileReader::GzippedFileReader(void) diff --git a/pcsx2/DEV9/DEV9Config.cpp b/pcsx2/DEV9/DEV9Config.cpp index 41b6f84fdd..5833524917 100644 --- a/pcsx2/DEV9/DEV9Config.cpp +++ b/pcsx2/DEV9/DEV9Config.cpp @@ -43,10 +43,10 @@ void SaveDnsHosts() ScopedIniGroup iniEntry(ini, groupName); ConfigHost entry = config.EthHosts[i]; - wxString url(entry.Url); + wxString url(fromUTF8(entry.Url)); ini.Entry(L"Url", url); //TODO UTF8(?) - wxString desc(entry.Desc); + wxString desc(fromUTF8(entry.Desc)); ini.Entry(L"Desc", desc); char addrBuff[INET_ADDRSTRLEN]; diff --git a/pcsx2/DebugTools/Debug.h b/pcsx2/DebugTools/Debug.h index 87ed02bfae..65e2c87683 100644 --- a/pcsx2/DebugTools/Debug.h +++ b/pcsx2/DebugTools/Debug.h @@ -242,6 +242,11 @@ public: return false; } + + bool Write(const std::string& msg) const + { + return Write(fromUTF8(msg)); + } }; // -------------------------------------------------------------------------------------- diff --git a/pcsx2/GS/Window/GSwxDialog.cpp b/pcsx2/GS/Window/GSwxDialog.cpp index a3a5fd376c..b4d3c6853f 100644 --- a/pcsx2/GS/Window/GSwxDialog.cpp +++ b/pcsx2/GS/Window/GSwxDialog.cpp @@ -36,9 +36,9 @@ namespace for (const GSSetting& setting : s) { if (!setting.note.empty()) - arr.Add(setting.name + " (" + setting.note + ")"); + arr.Add(fromUTF8(setting.name + " (" + setting.note + ")")); else - arr.Add(setting.name); + arr.Add(fromUTF8(setting.name)); } } @@ -204,8 +204,8 @@ void GSUIElementHolder::Load() case UIElem::Type::Directory: { auto* picker = static_cast(elem.control); - picker->SetInitialDirectory(theApp.GetConfigS(elem.config)); - picker->SetPath(theApp.GetConfigS(elem.config)); + picker->SetInitialDirectory(fromUTF8(theApp.GetConfigS(elem.config))); + picker->SetPath(fromUTF8(theApp.GetConfigS(elem.config))); break; } } diff --git a/pcsx2/MemoryCardFolder.cpp b/pcsx2/MemoryCardFolder.cpp index 35a525870a..922e79f272 100644 --- a/pcsx2/MemoryCardFolder.cpp +++ b/pcsx2/MemoryCardFolder.cpp @@ -43,16 +43,29 @@ static YAML::Node LoadYAMLFromFile(const wxString& fileName) if (result) { - wxString fileContents; - if (indexFile.ReadAll(&fileContents)) + size_t len = indexFile.Length(); + std::string fileContents(len, '\0'); + if (indexFile.Read(fileContents.data(), len) == len) { - index = YAML::Load(fileContents.mbc_str()); + index = YAML::Load(fileContents); } } return index; } +/// A helper function to write a YAML file +static void SaveYAMLToFile(const wxString& filename, const YAML::Node& node) +{ + wxFFile file; + if (file.Open(filename, L"w")) + { + // Make sure WX doesn't do anything funny with encoding + std::string yaml = YAML::Dump(node); + file.Write(yaml.data(), yaml.length()); + } +} + FolderMemoryCard::FolderMemoryCard() { m_slot = 0; @@ -1249,11 +1262,7 @@ void FolderMemoryCard::FlushFileEntries(const u32 dirCluster, const u32 remainin entryNode["timeModified"] = entry->entry.data.timeModified.ToTime(); // Write out the changes - wxFFile indexFile; - if (indexFile.Open(metaFileName.GetFullPath(), L"w")) - { - indexFile.Write(YAML::Dump(index)); - } + SaveYAMLToFile(metaFileName.GetFullPath(), index); } MemoryCardFileMetadataReference* dirRef = AddDirEntryToMetadataQuickAccess(entry, parent); @@ -1745,11 +1754,7 @@ void FolderMemoryCard::DeleteFromIndex(const wxString& filePath, const wxString& index.remove(entryUTF8.data()); // Write out the changes - wxFFile indexFile; - if (indexFile.Open(indexName, L"w")) - { - indexFile.Write(YAML::Dump(index)); - } + SaveYAMLToFile(indexName, index); } // from http://www.oocities.org/siliconvalley/station/8269/sma02/sma02.html#ECC @@ -1935,11 +1940,7 @@ void FileAccessHelper::WriteIndex(wxFileName folderName, MemoryCardFileEntry* co entryNode["timeModified"] = e->timeModified.ToTime(); // Write out the changes - wxFFile indexFile; - if (indexFile.Open(folderName.GetFullPath(), L"w")) - { - indexFile.Write(YAML::Dump(index)); - } + SaveYAMLToFile(folderName.GetFullPath(), index); } wxFFile* FileAccessHelper::ReOpen(const wxFileName& folderName, MemoryCardFileMetadataReference* fileRef, bool writeMetadata) diff --git a/pcsx2/Patch.cpp b/pcsx2/Patch.cpp index ff8337a093..f4a57926a9 100644 --- a/pcsx2/Patch.cpp +++ b/pcsx2/Patch.cpp @@ -139,7 +139,7 @@ int LoadPatchesFromGamesDB(const wxString& crc, const GameDatabaseSchema::GameEn { for (auto line : patch.patchLines) { - inifile_command(line); + inifile_command(fromUTF8(line)); } } } diff --git a/pcsx2/R5900.cpp b/pcsx2/R5900.cpp index d61b62da4f..71567be71c 100644 --- a/pcsx2/R5900.cpp +++ b/pcsx2/R5900.cpp @@ -715,7 +715,7 @@ void __fastcall eeloadHook() } } - if (!g_GameStarted && (disctype == 2 || disctype == 1) && elfname == discelf) + if (!g_GameStarted && (disctype == 2 || disctype == 1) && fromUTF8(elfname) == discelf) g_GameLoading = true; } diff --git a/pcsx2/Recording/InputRecording.cpp b/pcsx2/Recording/InputRecording.cpp index ff34c095b5..6956cda346 100644 --- a/pcsx2/Recording/InputRecording.cpp +++ b/pcsx2/Recording/InputRecording.cpp @@ -457,8 +457,8 @@ wxString InputRecording::resolveGameName() GameDatabaseSchema::GameEntry game = gameDB->findGame(std::string(gameKey)); if (game.isValid) { - gameName = game.name; - gameName += L" (" + game.region + L")"; + gameName = fromUTF8(game.name); + gameName += L" (" + fromUTF8(game.region) + L")"; } } } diff --git a/pcsx2/gui/AppCoreThread.cpp b/pcsx2/gui/AppCoreThread.cpp index c7d0236172..222723c824 100644 --- a/pcsx2/gui/AppCoreThread.cpp +++ b/pcsx2/gui/AppCoreThread.cpp @@ -323,7 +323,7 @@ static int loadGameSettings(Pcsx2Config& dest, const GameDatabaseSchema::GameEnt // are effectively booleans like the gamefixes bool mode = game.speedHacks.at(key) ? 1 : 0; dest.Speedhacks.Set(id, mode); - PatchesCon->WriteLn(L"(GameDB) Setting Speedhack '" + key + "' to [mode=%d]", mode); + PatchesCon->WriteLn(fmt::format("(GameDB) Setting Speedhack '{}' to [mode={}]", key, (int)mode)); gf++; } } @@ -338,7 +338,7 @@ static int loadGameSettings(Pcsx2Config& dest, const GameDatabaseSchema::GameEnt { // if the fix is present, it is said to be enabled dest.Gamefixes.Set(id, true); - PatchesCon->WriteLn(L"(GameDB) Enabled Gamefix: " + key); + PatchesCon->WriteLn("(GameDB) Enabled Gamefix: " + key); gf++; // The LUT is only used for 1 game so we allocate it only when the gamefix is enabled (save 4MB) @@ -455,10 +455,10 @@ static void _ApplySettings(const Pcsx2Config& src, Pcsx2Config& fixup) GameDatabaseSchema::GameEntry game = GameDB->findGame(std::string(curGameKey)); if (game.isValid) { - GameInfo::gameName = game.name; - GameInfo::gameName += L" (" + game.region + L")"; + GameInfo::gameName = fromUTF8(game.name); + GameInfo::gameName += L" (" + fromUTF8(game.region) + L")"; gameCompat = L" [Status = " + compatToStringWX(game.compat) + L"]"; - gameMemCardFilter = game.memcardFiltersAsString(); + gameMemCardFilter = fromUTF8(game.memcardFiltersAsString()); } if (fixup.EnablePatches) diff --git a/pcsx2/gui/AppMain.cpp b/pcsx2/gui/AppMain.cpp index d831c94458..6dfe310e8a 100644 --- a/pcsx2/gui/AppMain.cpp +++ b/pcsx2/gui/AppMain.cpp @@ -1019,7 +1019,7 @@ void Pcsx2App::SysExecute() // sources. void Pcsx2App::SysExecute( CDVD_SourceType cdvdsrc, const wxString& elf_override ) { - SysExecutorThread.PostEvent( new SysExecEvent_Execute(cdvdsrc, elf_override.ToStdString()) ); + SysExecutorThread.PostEvent( new SysExecEvent_Execute(cdvdsrc, elf_override) ); #ifndef DISABLE_RECORDING if (g_Conf->EmuOptions.EnableRecordingTools) { diff --git a/pcsx2/gui/ConsoleLogger.cpp b/pcsx2/gui/ConsoleLogger.cpp index 7fe0ad5f6c..a6bc3dfb9b 100644 --- a/pcsx2/gui/ConsoleLogger.cpp +++ b/pcsx2/gui/ConsoleLogger.cpp @@ -1273,6 +1273,6 @@ void OSDlog(ConsoleColors color, bool console, const std::string& str) } void OSDmonitor(ConsoleColors color, const std::string key, const std::string value) { - GSosdMonitor(wxString(key).utf8_str(), wxString(value).utf8_str(), wxGetApp().GetProgramLog()->GetRGBA(color)); + GSosdMonitor(key.c_str(), value.c_str(), wxGetApp().GetProgramLog()->GetRGBA(color)); } diff --git a/pcsx2/gui/DriveList.cpp b/pcsx2/gui/DriveList.cpp index b8aa3935db..993ca7b2b6 100644 --- a/pcsx2/gui/DriveList.cpp +++ b/pcsx2/gui/DriveList.cpp @@ -55,8 +55,8 @@ void DriveListManager::RefreshList() for (auto i : drives) { std::unique_ptr dli = std::unique_ptr(new DriveListItem()); - dli->driveLetter = wxString(i); - dli->itemPtr = m_Menu->AppendRadioItem(wxID_ANY, i); + dli->driveLetter = fromUTF8(i); + dli->itemPtr = m_Menu->AppendRadioItem(wxID_ANY, dli->driveLetter); // Check the last used drive item if (g_Conf->Folders.RunDisc == dli->driveLetter) diff --git a/pcsx2/gui/MainFrame.cpp b/pcsx2/gui/MainFrame.cpp index 91fb9fd5ab..6ff817c610 100644 --- a/pcsx2/gui/MainFrame.cpp +++ b/pcsx2/gui/MainFrame.cpp @@ -62,9 +62,9 @@ wxMenu* MainEmuFrame::MakeStatesSubMenu(int baseid, int loadBackupId) const // For safety i also made them inactive aka grayed out to signify that's it's only for informational purposes // Fixme: In the future this can still be expanded to actually cycle savestates in the GUI. mnuSubstates->Append(baseid - 1, _("File...")); - wxMenuItem* CycleNext = mnuSubstates->Append(baseid - 2, _("Cycle to next slot") + wxString(" ") + fmt::format("({})", wxGetApp().GlobalAccels->findKeycodeWithCommandId("States_CycleSlotForward").toTitleizedString())); + wxMenuItem* CycleNext = mnuSubstates->Append(baseid - 2, _("Cycle to next slot") + wxString("\t") + wxGetApp().GlobalAccels->findKeycodeWithCommandId("States_CycleSlotForward").toTitleizedString()); CycleNext->Enable(false); - wxMenuItem* CycleBack = mnuSubstates->Append(baseid - 3, _("Cycle to previous slot") + wxString(" ") + fmt::format("({})", wxGetApp().GlobalAccels->findKeycodeWithCommandId("States_CycleSlotBackward").toTitleizedString())); + wxMenuItem* CycleBack = mnuSubstates->Append(baseid - 3, _("Cycle to previous slot") + wxString("\t") + wxGetApp().GlobalAccels->findKeycodeWithCommandId("States_CycleSlotBackward").toTitleizedString()); CycleBack->Enable(false); return mnuSubstates; } @@ -89,7 +89,7 @@ void MainEmuFrame::UpdateStatusBar() m_statusbar.SetStatusText(temp, 0); if (g_Conf->EnablePresets) - m_statusbar.SetStatusText(fmt::format("P:{}", g_Conf->PresetIndex + 1), 1); + m_statusbar.SetStatusText(wxString::Format(L"P:%d", g_Conf->PresetIndex + 1), 1); else m_statusbar.SetStatusText("---", 1); @@ -524,7 +524,7 @@ void MainEmuFrame::CreateInputRecordingMenu() m_menuRecording.Append(MenuId_Recording_Settings, _("Settings"), &m_submenu_recording_settings); wxString frame_advance_label = wxString(_("Configure Frame Advance")); - frame_advance_label.Append(fmt::format(" ({})", g_Conf->inputRecording.m_frame_advance_amount)); + frame_advance_label.Append(wxString::Format(" (%d)", g_Conf->inputRecording.m_frame_advance_amount)); m_submenu_recording_settings.Append(MenuId_Recording_Config_FrameAdvance, frame_advance_label, _("Change the amount of frames advanced each time")); m_menuRecording.AppendSeparator(); @@ -836,7 +836,7 @@ void MainEmuFrame::ApplyConfigToGui(AppConfig& configToApply, int flags) #ifndef DISABLE_RECORDING menubar.Check(MenuId_EnableInputRecording, configToApply.EmuOptions.EnableRecordingTools); wxString frame_advance_label = wxString(_("Configure Frame Advance")); - frame_advance_label.Append(fmt::format(" ({})", configToApply.inputRecording.m_frame_advance_amount)); + frame_advance_label.Append(wxString::Format(" (%d)", configToApply.inputRecording.m_frame_advance_amount)); m_submenu_recording_settings.SetLabel(MenuId_Recording_Config_FrameAdvance, frame_advance_label); g_InputRecordingControls.setFrameAdvanceAmount(configToApply.inputRecording.m_frame_advance_amount); #endif diff --git a/pcsx2/gui/MainMenuClicks.cpp b/pcsx2/gui/MainMenuClicks.cpp index bf481b373b..126fe343f8 100644 --- a/pcsx2/gui/MainMenuClicks.cpp +++ b/pcsx2/gui/MainMenuClicks.cpp @@ -1114,7 +1114,7 @@ void MainEmuFrame::Menu_Recording_Config_FrameAdvance(wxCommandEvent& event) g_Conf->inputRecording.m_frame_advance_amount = result; g_InputRecordingControls.setFrameAdvanceAmount(result); wxString frame_advance_label = wxString(_("Configure Frame Advance")); - frame_advance_label.Append(fmt::format(" ({})", result)); + frame_advance_label.Append(wxString::Format(" (%ld)", result)); m_submenu_recording_settings.SetLabel(MenuId_Recording_Config_FrameAdvance, frame_advance_label); } } diff --git a/pcsx2/gui/Panels/GSWindowPanel.cpp b/pcsx2/gui/Panels/GSWindowPanel.cpp index 1c2f8e7fe3..c9afe47a67 100644 --- a/pcsx2/gui/Panels/GSWindowPanel.cpp +++ b/pcsx2/gui/Panels/GSWindowPanel.cpp @@ -107,7 +107,7 @@ Panels::GSWindowSettingsPanel::GSWindowSettingsPanel(wxWindow* parent) s_AspectRatio.AddGrowableCol(1); // Implement custom hotkeys (F6) with translatable string intact + not blank in GUI. - s_AspectRatio += Label(_("Aspect Ratio:") + wxString(" ") + fmt::format("({})", wxGetApp().GlobalAccels->findKeycodeWithCommandId("GSwindow_CycleAspectRatio").toTitleizedString())) | pxMiddle; + s_AspectRatio += Label(_("Aspect Ratio:") + wxString("\t") + wxGetApp().GlobalAccels->findKeycodeWithCommandId("GSwindow_CycleAspectRatio").toTitleizedString()) | pxMiddle; s_AspectRatio += m_combo_AspectRatio | pxAlignRight; s_AspectRatio += Label(_("FMV Aspect Ratio Override:")) | pxMiddle; s_AspectRatio += m_combo_FMVAspectRatioSwitch | pxAlignRight; diff --git a/pcsx2/gui/Panels/VideoPanel.cpp b/pcsx2/gui/Panels/VideoPanel.cpp index ccf336e701..0aef487986 100644 --- a/pcsx2/gui/Panels/VideoPanel.cpp +++ b/pcsx2/gui/Panels/VideoPanel.cpp @@ -65,7 +65,7 @@ Panels::FramelimiterPanel::FramelimiterPanel( wxWindow* parent ) // Implement custom hotkeys (Shift + Tab) with translatable string intact + not blank in GUI. - s_spins += Label(_("Slow Motion Adjust:") + wxString(" ") + fmt::format("({})", wxGetApp().GlobalAccels->findKeycodeWithCommandId("Framelimiter_SlomoToggle").toTitleizedString())) | StdExpand(); + s_spins += Label(_("Slow Motion Adjust:") + wxString::Format(" (%s)", wxGetApp().GlobalAccels->findKeycodeWithCommandId("Framelimiter_SlomoToggle").toTitleizedString())) | StdExpand(); s_spins += 5; s_spins += m_spin_SlomoPct | pxBorder(wxTOP, 3); s_spins += Label(L"%") | StdExpand(); @@ -73,7 +73,7 @@ Panels::FramelimiterPanel::FramelimiterPanel( wxWindow* parent ) // Implement custom hotkeys (Tab) with translatable string intact + not blank in GUI. - s_spins += Label(_("Turbo Adjust:") + wxString(" ") + fmt::format("({})", wxGetApp().GlobalAccels->findKeycodeWithCommandId("Framelimiter_TurboToggle").toTitleizedString())) | StdExpand(); + s_spins += Label(_("Turbo Adjust:") + wxString::Format(" (%s)", wxGetApp().GlobalAccels->findKeycodeWithCommandId("Framelimiter_TurboToggle").toTitleizedString())) | StdExpand(); s_spins += 5; s_spins += m_spin_TurboPct | pxBorder(wxTOP, 3); s_spins += Label(L"%") | StdExpand(); @@ -176,11 +176,11 @@ Panels::FrameSkipPanel::FrameSkipPanel( wxWindow* parent ) ), // Implement custom hotkeys (Tab) with translatable string intact + not blank in GUI. RadioPanelItem( - _("Skip only on Turbo, to enable press") + fmt::format("{} ({})", " ", wxGetApp().GlobalAccels->findKeycodeWithCommandId("Framelimiter_TurboToggle").toTitleizedString()) + _("Skip only on Turbo, to enable press") + wxString::Format(" (%s)", wxGetApp().GlobalAccels->findKeycodeWithCommandId("Framelimiter_TurboToggle").toTitleizedString()) ), // Implement custom hotkeys (Shift + F4) with translatable string intact + not blank in GUI. RadioPanelItem( - _("Constant skipping") + fmt::format("{} ({})", " ", wxGetApp().GlobalAccels->findKeycodeWithCommandId("Frameskip_Toggle").toTitleizedString()), + _("Constant skipping") + wxString::Format(" (%s)", wxGetApp().GlobalAccels->findKeycodeWithCommandId("Frameskip_Toggle").toTitleizedString()), wxEmptyString, _("Normal and Turbo limit rates skip frames. Slow motion mode will still disable frameskipping.") ), diff --git a/pcsx2/ps2/BiosTools.cpp b/pcsx2/ps2/BiosTools.cpp index d6e76ba3e2..866cef846f 100644 --- a/pcsx2/ps2/BiosTools.cpp +++ b/pcsx2/ps2/BiosTools.cpp @@ -228,8 +228,9 @@ static void LoadIrx( const std::string& filename, u8* dest ) s64 filesize = 0; try { - wxFile irx(filename); - if( (filesize=Path::GetFileSize( filename ) ) <= 0 ) { + wxString wname = fromUTF8(filename); + wxFile irx(wname); + if( (filesize=Path::GetFileSize( wname ) ) <= 0 ) { Console.Warning("IRX Warning: %s could not be read", filename.c_str()); return; }