diff --git a/pcsx2/CDVD/CDVDaccess.cpp b/pcsx2/CDVD/CDVDaccess.cpp index 7b4c5c28aa..0370397ba3 100644 --- a/pcsx2/CDVD/CDVDaccess.cpp +++ b/pcsx2/CDVD/CDVDaccess.cpp @@ -33,6 +33,7 @@ #include "IsoFS/IsoFSCDVD.h" #include "CDVDisoReader.h" +#include "common/StringUtil.h" #include "DebugTools/SymbolMap.h" #include "Config.h" @@ -385,9 +386,9 @@ bool DoCDVDopen() somepick = L"Untitled"; if (EmuConfig.CurrentBlockdump.empty()) - EmuConfig.CurrentBlockdump = wxGetCwd().ToStdString(); + EmuConfig.CurrentBlockdump = StringUtil::wxStringToUTF8String(wxGetCwd()); - wxString temp(Path::Combine(EmuConfig.CurrentBlockdump, somepick)); + wxString temp(Path::Combine(StringUtil::UTF8StringToWxString(EmuConfig.CurrentBlockdump), somepick)); #ifdef ENABLE_TIMESTAMPS wxDateTime curtime(wxDateTime::GetTimeNow()); diff --git a/pcsx2/Config.h b/pcsx2/Config.h index 4a4bacc2d2..1ed0771b46 100644 --- a/pcsx2/Config.h +++ b/pcsx2/Config.h @@ -570,11 +570,7 @@ struct Pcsx2Config std::string GzipIsoIndexTemplate; // for quick-access index with gzipped ISO // Set at runtime, not loaded from config. - CDVD_SourceType CdvdSource; - std::string CurrentIso; - std::string CurrentDiscDrive; std::string CurrentBlockdump; - std::string CurrentELF; std::string CurrentIRX; std::string CurrentGameArgs; AspectRatioType CurrentAspectRatio = AspectRatioType::R4_3; diff --git a/pcsx2/Pcsx2Config.cpp b/pcsx2/Pcsx2Config.cpp index 41b6a433e7..49faf9a8ea 100644 --- a/pcsx2/Pcsx2Config.cpp +++ b/pcsx2/Pcsx2Config.cpp @@ -515,8 +515,6 @@ Pcsx2Config::Pcsx2Config() } GzipIsoIndexTemplate = "$(f).pindex.tmp"; - - CdvdSource = CDVD_SourceType::Iso; } void Pcsx2Config::LoadSave(SettingsWrapper& wrap) @@ -604,12 +602,12 @@ bool Pcsx2Config::MultitapEnabled(uint port) const wxString Pcsx2Config::FullpathToBios() const { - return Path::Combine(EmuFolders::Bios, wxString(BaseFilenames.Bios)); + return Path::Combine(EmuFolders::Bios, StringUtil::UTF8StringToWxString(BaseFilenames.Bios)); } wxString Pcsx2Config::FullpathToMcd(uint slot) const { - return Path::Combine(EmuFolders::MemoryCards, wxString(Mcd[slot].Filename)); + return Path::Combine(EmuFolders::MemoryCards, StringUtil::UTF8StringToWxString(Mcd[slot].Filename)); } void Pcsx2Config::CopyConfig(const Pcsx2Config& cfg) diff --git a/pcsx2/Recording/InputRecording.cpp b/pcsx2/Recording/InputRecording.cpp index 05326e3eb7..ff34c095b5 100644 --- a/pcsx2/Recording/InputRecording.cpp +++ b/pcsx2/Recording/InputRecording.cpp @@ -292,7 +292,7 @@ void InputRecording::SetupInitialState(u32 newStartingFrame) else { // Check if the current game matches with the one used to make the original recording - if (!EmuConfig.CurrentIso.empty()) + if (!g_Conf->CurrentIso.IsEmpty()) if (resolveGameName() != inputRecordingData.GetHeader().gameName) inputRec::consoleLog("Input recording was possibly constructed for a different game."); @@ -350,7 +350,7 @@ bool InputRecording::Create(wxString fileName, const bool fromSaveState, wxStrin StateCopy_SaveToFile(savestate); } else - sApp.SysExecute(EmuConfig.CdvdSource); + sApp.SysExecute(g_Conf->CdvdSource); // Set emulator version inputRecordingData.GetHeader().SetEmulatorVersion(); @@ -405,7 +405,7 @@ bool InputRecording::Play(wxWindow* parent, wxString filename) { state = InputRecordingMode::Replaying; initialLoad = true; - sApp.SysExecute(EmuConfig.CdvdSource); + sApp.SysExecute(g_Conf->CdvdSource); } return true; } @@ -439,7 +439,7 @@ void InputRecording::GoToFirstFrame(wxWindow* parent) StateCopy_LoadFromFile(savestate); } else - sApp.SysExecute(EmuConfig.CdvdSource); + sApp.SysExecute(g_Conf->CdvdSource); if (IsRecording()) SetToReplayMode(); @@ -462,7 +462,7 @@ wxString InputRecording::resolveGameName() } } } - return !gameName.IsEmpty() ? gameName : (wxString)Path::GetFilename(EmuConfig.CurrentIso); + return !gameName.IsEmpty() ? gameName : (wxString)Path::GetFilename(g_Conf->CurrentIso); } #endif diff --git a/pcsx2/gui/AppConfig.cpp b/pcsx2/gui/AppConfig.cpp index 7e0cfac49d..b5bf809de6 100644 --- a/pcsx2/gui/AppConfig.cpp +++ b/pcsx2/gui/AppConfig.cpp @@ -256,6 +256,88 @@ namespace PathDefs } }; + +// -------------------------------------------------------------------------------------- +// Default Filenames +// -------------------------------------------------------------------------------------- +namespace FilenameDefs +{ +wxFileName GetUiConfig() +{ + return pxGetAppName() + L"_ui.ini"; +} + +wxFileName GetUiKeysConfig() +{ + return pxGetAppName() + L"_keys.ini"; +} + +wxFileName GetVmConfig() +{ + return pxGetAppName() + L"_vm.ini"; +} + +wxFileName GetUsermodeConfig() +{ + return wxFileName(L"usermode.ini"); +} + +const wxFileName& Memcard(uint port, uint slot) +{ + static const wxFileName retval[2][4] = + { + { + wxFileName(L"Mcd001.ps2"), + wxFileName(L"Mcd003.ps2"), + wxFileName(L"Mcd005.ps2"), + wxFileName(L"Mcd007.ps2"), + }, + { + wxFileName(L"Mcd002.ps2"), + wxFileName(L"Mcd004.ps2"), + wxFileName(L"Mcd006.ps2"), + wxFileName(L"Mcd008.ps2"), + } + }; + + IndexBoundsAssumeDev(L"FilenameDefs::Memcard", port, 2); + IndexBoundsAssumeDev(L"FilenameDefs::Memcard", slot, 4); + + return retval[port][slot]; +} +}; + +static wxDirName GetResolvedFolder(FoldersEnum_t id) +{ + return g_Conf->Folders.IsDefault(id) ? PathDefs::Get(id) : g_Conf->Folders[id]; +} + +static wxDirName GetSettingsFolder() +{ + if (wxGetApp().Overrides.SettingsFolder.IsOk()) + return wxGetApp().Overrides.SettingsFolder; + + return UseDefaultSettingsFolder ? PathDefs::GetSettings() : SettingsFolder; +} + +wxString GetVmSettingsFilename() +{ + wxFileName fname(wxGetApp().Overrides.VmSettingsFile.IsOk() ? wxGetApp().Overrides.VmSettingsFile : FilenameDefs::GetVmConfig()); + return GetSettingsFolder().Combine(fname).GetFullPath(); +} + +wxString GetUiSettingsFilename() +{ + wxFileName fname(FilenameDefs::GetUiConfig()); + return GetSettingsFolder().Combine(fname).GetFullPath(); +} + +wxString GetUiKeysFilename() +{ + wxFileName fname(FilenameDefs::GetUiKeysConfig()); + return GetSettingsFolder().Combine(fname).GetFullPath(); +} + wxDirName& AppConfig::FolderOptions::operator[]( FoldersEnum_t folderidx ) { switch( folderidx ) @@ -310,36 +392,43 @@ void AppConfig::FolderOptions::Set( FoldersEnum_t folderidx, const wxString& src case FolderId_Settings: SettingsFolder = src; UseDefaultSettingsFolder = useDefault; + EmuFolders::Settings = GetSettingsFolder(); break; case FolderId_Bios: Bios = src; UseDefaultBios = useDefault; + EmuFolders::Bios = GetResolvedFolder(FolderId_Bios); break; case FolderId_Snapshots: Snapshots = src; UseDefaultSnapshots = useDefault; + EmuFolders::Snapshots = GetResolvedFolder(FolderId_Snapshots); break; case FolderId_Savestates: Savestates = src; UseDefaultSavestates = useDefault; + EmuFolders::Savestates = GetResolvedFolder(FolderId_Savestates); break; case FolderId_MemoryCards: MemoryCards = src; UseDefaultMemoryCards = useDefault; + EmuFolders::MemoryCards = GetResolvedFolder(FolderId_MemoryCards); break; case FolderId_Logs: Logs = src; UseDefaultLogs = useDefault; + EmuFolders::Logs = GetResolvedFolder(FolderId_Logs); break; case FolderId_Langs: Langs = src; UseDefaultLangs = useDefault; + EmuFolders::Langs = GetResolvedFolder(FolderId_Langs); break; case FolderId_Documents: @@ -349,93 +438,19 @@ void AppConfig::FolderOptions::Set( FoldersEnum_t folderidx, const wxString& src case FolderId_Cheats: Cheats = src; UseDefaultCheats = useDefault; + EmuFolders::Cheats = GetResolvedFolder(FolderId_Cheats); break; case FolderId_CheatsWS: CheatsWS = src; UseDefaultCheatsWS = useDefault; + EmuFolders::CheatsWS = GetResolvedFolder(FolderId_CheatsWS); break; jNO_DEFAULT } } -// -------------------------------------------------------------------------------------- -// Default Filenames -// -------------------------------------------------------------------------------------- -namespace FilenameDefs -{ - wxFileName GetUiConfig() - { - return pxGetAppName() + L"_ui.ini"; - } - - wxFileName GetUiKeysConfig() - { - return pxGetAppName() + L"_keys.ini"; - } - - wxFileName GetVmConfig() - { - return pxGetAppName() + L"_vm.ini"; - } - - wxFileName GetUsermodeConfig() - { - return wxFileName( L"usermode.ini" ); - } - - const wxFileName& Memcard( uint port, uint slot ) - { - static const wxFileName retval[2][4] = - { - { - wxFileName( L"Mcd001.ps2" ), - wxFileName( L"Mcd003.ps2" ), - wxFileName( L"Mcd005.ps2" ), - wxFileName( L"Mcd007.ps2" ), - }, - { - wxFileName( L"Mcd002.ps2" ), - wxFileName( L"Mcd004.ps2" ), - wxFileName( L"Mcd006.ps2" ), - wxFileName( L"Mcd008.ps2" ), - } - }; - - IndexBoundsAssumeDev( L"FilenameDefs::Memcard", port, 2 ); - IndexBoundsAssumeDev( L"FilenameDefs::Memcard", slot, 4 ); - - return retval[port][slot]; - } -}; - -static wxDirName GetSettingsFolder() -{ - if (wxGetApp().Overrides.SettingsFolder.IsOk()) - return wxGetApp().Overrides.SettingsFolder; - - return UseDefaultSettingsFolder ? PathDefs::GetSettings() : SettingsFolder; -} - -wxString GetVmSettingsFilename() -{ - wxFileName fname( wxGetApp().Overrides.VmSettingsFile.IsOk() ? wxGetApp().Overrides.VmSettingsFile : FilenameDefs::GetVmConfig() ); - return GetSettingsFolder().Combine( fname ).GetFullPath(); -} - -wxString GetUiSettingsFilename() -{ - wxFileName fname( FilenameDefs::GetUiConfig() ); - return GetSettingsFolder().Combine( fname ).GetFullPath(); -} - -wxString GetUiKeysFilename() -{ - wxFileName fname( FilenameDefs::GetUiKeysConfig() ); - return GetSettingsFolder().Combine( fname ).GetFullPath(); -} - bool IsPortable() { return InstallationMode==InstallMode_Portable; @@ -461,6 +476,8 @@ AppConfig::AppConfig() EnablePresets = true; PresetIndex = 1; + + CdvdSource = CDVD_SourceType::Iso; } // ------------------------------------------------------------------------ @@ -527,14 +544,12 @@ void AppConfig::LoadSaveRootItems( IniInterface& ini ) IniEntry( Toolbar_ImageSize ); IniEntry( Toolbar_ShowLabels ); - ini.EnumEntry(L"CdvdSource", EmuConfig.CdvdSource, CDVD_SourceLabels, EmuConfig.CdvdSource); - - wxFileName res(EmuConfig.CurrentIso); - ini.Entry(L"CurrentIso", res, res, ini.IsLoading() || IsPortable()); - EmuConfig.CurrentIso = res.GetFullPath(); + wxFileName res(CurrentIso); + ini.Entry( L"CurrentIso", res, res, ini.IsLoading() || IsPortable() ); + CurrentIso = res.GetFullPath(); ini.Entry(wxT("CurrentBlockdump"), EmuConfig.CurrentBlockdump, EmuConfig.CurrentBlockdump); - ini.Entry(wxT("CurrentELF"), EmuConfig.CurrentELF, EmuConfig.CurrentELF); + IniEntry( CurrentELF ); ini.Entry(wxT("CurrentIRX"), EmuConfig.CurrentIRX, EmuConfig.CurrentIRX); IniEntry( EnableSpeedHacks ); @@ -544,6 +559,8 @@ void AppConfig::LoadSaveRootItems( IniInterface& ini ) IniEntry( EnablePresets ); IniEntry( PresetIndex ); IniEntry( AskOnBoot ); + + ini.EnumEntry( L"CdvdSource", CdvdSource, CDVD_SourceLabels, CdvdSource ); #ifdef __WXMSW__ ini.Entry(wxT("McdCompressNTFS"), EmuOptions.McdCompressNTFS, EmuOptions.McdCompressNTFS); @@ -668,16 +685,15 @@ void AppConfig::FolderOptions::LoadSave( IniInterface& ini ) for( int i=0; i(); g_Conf->LoadSave( loader, wrapper ); - if( !wxFile::Exists( EmuConfig.CurrentIso ) ) + if( !wxFile::Exists( g_Conf->CurrentIso ) ) { - EmuConfig.CurrentIso.clear(); + g_Conf->CurrentIso.clear(); } sApp.DispatchUiSettingsEvent( loader ); @@ -1155,12 +1171,12 @@ void AppLoadSettings() static void SaveUiSettings() { - if( !wxFile::Exists(EmuConfig.CurrentIso ) ) + if( !wxFile::Exists( g_Conf->CurrentIso ) ) { - EmuConfig.CurrentIso.clear(); + g_Conf->CurrentIso.clear(); } - sApp.GetRecentIsoManager().Add( EmuConfig.CurrentIso ); + sApp.GetRecentIsoManager().Add( g_Conf->CurrentIso ); AppIniSaver saver; wxSettingsInterface wxsi(&saver.GetConfig()); diff --git a/pcsx2/gui/AppConfig.h b/pcsx2/gui/AppConfig.h index 1fd1606b29..7529182ea7 100644 --- a/pcsx2/gui/AppConfig.h +++ b/pcsx2/gui/AppConfig.h @@ -270,6 +270,11 @@ public: bool AskOnBoot; + + wxString CurrentIso; + wxString CurrentELF; + CDVD_SourceType CdvdSource; + ConsoleLogOptions ProgLogBox; FolderOptions Folders; GSWindowOptions GSWindow; diff --git a/pcsx2/gui/AppCoreThread.cpp b/pcsx2/gui/AppCoreThread.cpp index d7370d0ab5..00474c737f 100644 --- a/pcsx2/gui/AppCoreThread.cpp +++ b/pcsx2/gui/AppCoreThread.cpp @@ -21,6 +21,7 @@ #include #include "fmt/core.h" +#include "common/StringUtil.h" #include "common/Threading.h" #include "ps2/BiosTools.h" @@ -196,7 +197,7 @@ void AppCoreThread::ChangeCdvdSource() return; } - CDVD_SourceType cdvdsrc(EmuConfig.CdvdSource); + CDVD_SourceType cdvdsrc(g_Conf->CdvdSource); if (cdvdsrc == CDVDsys_GetSourceType()) return; @@ -215,13 +216,18 @@ void Pcsx2App::SysApplySettings() return; CoreThread.ApplySettings(g_Conf->EmuOptions); - CDVD_SourceType cdvdsrc(EmuConfig.CdvdSource); - if (cdvdsrc != CDVDsys_GetSourceType() || (cdvdsrc == CDVD_SourceType::Iso && (CDVDsys_GetFile(cdvdsrc) != EmuConfig.CurrentIso))) + const CDVD_SourceType cdvdsrc(g_Conf->CdvdSource); + const std::string currentIso(StringUtil::wxStringToUTF8String(g_Conf->CurrentIso)); + const std::string currentDisc(StringUtil::wxStringToUTF8String(g_Conf->Folders.RunDisc)); + if (cdvdsrc != CDVDsys_GetSourceType() || + CDVDsys_GetFile(CDVD_SourceType::Iso) != currentIso || + CDVDsys_GetFile(CDVD_SourceType::Disc) != currentDisc) { CoreThread.ResetCdvd(); } - CDVDsys_SetFile(CDVD_SourceType::Iso, EmuConfig.CurrentIso); + CDVDsys_SetFile(CDVD_SourceType::Iso, currentIso); + CDVDsys_SetFile(CDVD_SourceType::Disc, currentDisc); } void AppCoreThread::OnResumeReady() @@ -590,7 +596,7 @@ void AppCoreThread::OnResumeInThread(SystemsMask systemsToReinstate) { if (m_resetCdvd) { - CDVDsys_ChangeSource(EmuConfig.CdvdSource); + CDVDsys_ChangeSource(g_Conf->CdvdSource); cdvdCtrlTrayOpen(); DoCDVDopen(); m_resetCdvd = false; diff --git a/pcsx2/gui/AppInit.cpp b/pcsx2/gui/AppInit.cpp index cc381a9396..ca8ab64e2b 100644 --- a/pcsx2/gui/AppInit.cpp +++ b/pcsx2/gui/AppInit.cpp @@ -21,6 +21,7 @@ #include "MTVU.h" // for thread cancellation on shutdown #include "common/IniInterface.h" +#include "common/StringUtil.h" #include "DebugTools/Debug.h" #include "Dialogs/ModalPopups.h" @@ -458,16 +459,16 @@ bool Pcsx2App::OnInit() (new GameDatabaseLoaderThread())->Start(); // By default no IRX injection - EmuConfig.CurrentIRX = ""; + EmuConfig.CurrentIRX.clear(); if (Startup.SysAutoRun) { g_Conf->EmuOptions.UseBOOT2Injection = !Startup.NoFastBoot; - EmuConfig.CdvdSource = Startup.CdvdSource; + g_Conf->CdvdSource = Startup.CdvdSource; if (Startup.CdvdSource == CDVD_SourceType::Iso) SysUpdateIsoSrcFile(Startup.IsoFile); sApp.SysExecute(Startup.CdvdSource); - EmuConfig.CurrentGameArgs = Startup.GameLaunchArgs; + EmuConfig.CurrentGameArgs = StringUtil::wxStringToUTF8String(Startup.GameLaunchArgs); } else if (Startup.SysAutoRunElf) { @@ -495,7 +496,7 @@ bool Pcsx2App::OnInit() { g_Conf->EmuOptions.UseBOOT2Injection = true; - EmuConfig.CurrentIRX = Startup.ElfFile; + EmuConfig.CurrentIRX = StringUtil::wxStringToUTF8String(Startup.ElfFile); // FIXME: ElfFile is an irx it will crash sApp.SysExecute(Startup.CdvdSource, Startup.ElfFile); diff --git a/pcsx2/gui/AppMain.cpp b/pcsx2/gui/AppMain.cpp index bf5898c8a8..393f6e0214 100644 --- a/pcsx2/gui/AppMain.cpp +++ b/pcsx2/gui/AppMain.cpp @@ -42,6 +42,7 @@ #endif #include "common/IniInterface.h" +#include "common/StringUtil.h" #include "common/AppTrait.h" #include @@ -969,7 +970,7 @@ protected: bool m_UseCDVDsrc; bool m_UseELFOverride; CDVD_SourceType m_cdvdsrc_type; - std::string m_elf_override; + wxString m_elf_override; public: virtual ~SysExecEvent_Execute() = default; @@ -992,11 +993,11 @@ public: { } - SysExecEvent_Execute( CDVD_SourceType srctype, std::string elf_override ) + SysExecEvent_Execute( CDVD_SourceType srctype, const wxString& elf_override ) : m_UseCDVDsrc(true) , m_UseELFOverride(true) , m_cdvdsrc_type(srctype) - , m_elf_override( std::move(elf_override) ) + , m_elf_override( elf_override ) { } @@ -1014,7 +1015,8 @@ protected: // This function below gets called again from AppCoreThread.cpp and will pass the current ISO regardless if we // are starting an ELF. In terms of symbol loading this doesn't matter because AppCoreThread.cpp doesn't clear the symbol map // and we _only_ read symbols if the map is empty - CDVDsys_SetFile(CDVD_SourceType::Iso, m_UseELFOverride ? m_elf_override : EmuConfig.CurrentIso ); + CDVDsys_SetFile(CDVD_SourceType::Disc, StringUtil::wxStringToUTF8String(g_Conf->Folders.RunDisc) ); + CDVDsys_SetFile(CDVD_SourceType::Iso, StringUtil::wxStringToUTF8String(m_UseELFOverride ? m_elf_override : g_Conf->CurrentIso) ); if( m_UseCDVDsrc ) CDVDsys_ChangeSource( m_cdvdsrc_type ); else if( CDVD == NULL ) @@ -1070,7 +1072,7 @@ void SysStatus( const wxString& text ) // Applies a new active iso source file void SysUpdateIsoSrcFile( const wxString& newIsoFile ) { - EmuConfig.CurrentIso = newIsoFile; + g_Conf->CurrentIso = newIsoFile; sMainFrame.UpdateStatusBar(); sMainFrame.UpdateCdvdSrcSelection(); } @@ -1078,7 +1080,6 @@ void SysUpdateIsoSrcFile( const wxString& newIsoFile ) void SysUpdateDiscSrcDrive( const wxString& newDiscDrive ) { g_Conf->Folders.RunDisc = newDiscDrive; - EmuConfig.CurrentDiscDrive = newDiscDrive; AppSaveSettings(); sMainFrame.UpdateCdvdSrcSelection(); } diff --git a/pcsx2/gui/Dialogs/ConfigurationDialog.h b/pcsx2/gui/Dialogs/ConfigurationDialog.h index 66bde6cf9b..6f0b641f2a 100644 --- a/pcsx2/gui/Dialogs/ConfigurationDialog.h +++ b/pcsx2/gui/Dialogs/ConfigurationDialog.h @@ -196,7 +196,7 @@ namespace Dialogs public: virtual ~ConvertMemoryCardDialog() = default; - ConvertMemoryCardDialog( wxWindow* parent, const wxDirName& mcdPath, const Pcsx2Config::McdOptions& mcdSourceConfig ); + ConvertMemoryCardDialog( wxWindow* parent, const wxDirName& mcdPath, MemoryCardType type, const wxString& sourceFilename ); protected: void CreateControls( const MemoryCardType sourceType ); diff --git a/pcsx2/gui/Dialogs/ConvertMemoryCardDialog.cpp b/pcsx2/gui/Dialogs/ConvertMemoryCardDialog.cpp index c5abba653d..5635a1ead4 100644 --- a/pcsx2/gui/Dialogs/ConvertMemoryCardDialog.cpp +++ b/pcsx2/gui/Dialogs/ConvertMemoryCardDialog.cpp @@ -32,14 +32,14 @@ enum MemoryCardConversionType { MemoryCardConversion_MaxCount }; -Dialogs::ConvertMemoryCardDialog::ConvertMemoryCardDialog( wxWindow* parent, const wxDirName& mcdPath, const Pcsx2Config::McdOptions& mcdSourceConfig ) +Dialogs::ConvertMemoryCardDialog::ConvertMemoryCardDialog( wxWindow* parent, const wxDirName& mcdPath, MemoryCardType type, const wxString& sourceFilename ) : wxDialogWithHelpers( parent, _( "Convert a memory card to a different format" ) ) , m_mcdPath( mcdPath ) - , m_mcdSourceFilename( mcdSourceConfig.Filename ) + , m_mcdSourceFilename( sourceFilename ) { SetMinWidth( 472 * MSW_GetDPIScale()); - CreateControls( mcdSourceConfig.Type ); + CreateControls( type ); if ( m_radio_CardType ) m_radio_CardType->Realize(); @@ -62,7 +62,7 @@ Dialogs::ConvertMemoryCardDialog::ConvertMemoryCardDialog( wxWindow* parent, con s_padding += m_radio_CardType | pxSizerFlags::StdExpand(); - if ( mcdSourceConfig.Type != MemoryCardType::MemoryCard_File ) { + if ( type != MemoryCardType::MemoryCard_File ) { s_padding += Heading( pxE( L"Please note that the resulting file may not actually contain all saves, depending on how many are in the source memory card." ) ); } s_padding += Heading( pxE( L"WARNING: Converting a memory card may take a while! Please do not close the emulator during the conversion process, even if the emulator is no longer responding to input." ) ); diff --git a/pcsx2/gui/IsoDropTarget.cpp b/pcsx2/gui/IsoDropTarget.cpp index 044292f576..305b554aad 100644 --- a/pcsx2/gui/IsoDropTarget.cpp +++ b/pcsx2/gui/IsoDropTarget.cpp @@ -88,7 +88,7 @@ protected: dialog += dialog.Heading(AddAppName(_("You have dropped the following ELF binary into %s:\n\n"))); dialog += dialog.GetCharHeight(); - dialog += dialog.Text( EmuConfig.CurrentELF ); + dialog += dialog.Text( g_Conf->CurrentELF ); dialog += dialog.GetCharHeight(); dialog += dialog.Heading(GetMsg_ConfirmSysReset()); @@ -98,7 +98,7 @@ protected: if( confirmed ) { g_Conf->EmuOptions.UseBOOT2Injection = true; - sApp.SysExecute( EmuConfig.CdvdSource, EmuConfig.CurrentELF ); + sApp.SysExecute( g_Conf->CdvdSource, g_Conf->CurrentELF ); } else stopped_core.AllowResume(); @@ -175,7 +175,7 @@ bool IsoDropTarget::OnDropFiles(wxCoord x, wxCoord y, const wxArrayString& filen { Console.WriteLn( L"(Drag&Drop) Found ELF file type!" ); - EmuConfig.CurrentELF = filenames[0]; + g_Conf->CurrentELF = filenames[0]; wxGetApp().PostEvent( DroppedElf(m_WindowBound) ); return true; diff --git a/pcsx2/gui/MainFrame.cpp b/pcsx2/gui/MainFrame.cpp index 8591a708bd..cfdd4eb6f8 100644 --- a/pcsx2/gui/MainFrame.cpp +++ b/pcsx2/gui/MainFrame.cpp @@ -82,12 +82,12 @@ void MainEmuFrame::UpdateStatusBar() if (g_Conf->EnableFastBoot) temp += "Fast Boot - "; - if (EmuConfig.CdvdSource == CDVD_SourceType::Iso) - temp += "Load: '" + wxFileName(EmuConfig.CurrentIso).GetFullName() + "' "; + if (g_Conf->CdvdSource == CDVD_SourceType::Iso) + temp += "Load: '" + wxFileName(g_Conf->CurrentIso).GetFullName() + "' "; } m_statusbar.SetStatusText(temp, 0); - m_statusbar.SetStatusText(CDVD_SourceLabels[enum_cast(EmuConfig.CdvdSource)], 1); + m_statusbar.SetStatusText(CDVD_SourceLabels[enum_cast(g_Conf->CdvdSource)], 1); #ifdef __M_X86_64 m_statusbar.SetStatusText("x64", 2); @@ -100,7 +100,7 @@ void MainEmuFrame::UpdateCdvdSrcSelection() { MenuIdentifiers cdsrc = MenuId_Src_Iso; - switch (EmuConfig.CdvdSource) + switch (g_Conf->CdvdSource) { case CDVD_SourceType::Iso: cdsrc = MenuId_Src_Iso; @@ -772,7 +772,7 @@ void MainEmuFrame::ApplySuspendStatus() void MainEmuFrame::ApplyCDVDStatus() { - const CDVD_SourceType Source = EmuConfig.CdvdSource; + const CDVD_SourceType Source = g_Conf->CdvdSource; wxMenuItem* cdvd_menu = GetMenuBar()->FindItem(MenuId_Boot_CDVD); diff --git a/pcsx2/gui/MainMenuClicks.cpp b/pcsx2/gui/MainMenuClicks.cpp index a5fd88a3c7..bf481b373b 100644 --- a/pcsx2/gui/MainMenuClicks.cpp +++ b/pcsx2/gui/MainMenuClicks.cpp @@ -196,7 +196,7 @@ wxWindowID SwapOrReset_Iso(wxWindow* owner, IScopedCoreThread& core_control, con } wxWindowID result = wxID_CANCEL; - if ((EmuConfig.CdvdSource == CDVD_SourceType::Iso) && (isoFilename == EmuConfig.CurrentIso)) + if ((g_Conf->CdvdSource == CDVD_SourceType::Iso) && (isoFilename == g_Conf->CurrentIso)) { core_control.AllowResume(); return result; @@ -226,7 +226,7 @@ wxWindowID SwapOrReset_Iso(wxWindow* owner, IScopedCoreThread& core_control, con } g_CDVDReset = true; - EmuConfig.CdvdSource = CDVD_SourceType::Iso; + g_Conf->CdvdSource = CDVD_SourceType::Iso; SysUpdateIsoSrcFile(isoFilename); if (result == wxID_RESET) @@ -258,7 +258,7 @@ wxWindowID SwapOrReset_Disc(wxWindow* owner, IScopedCoreThread& core, const wxSt } wxWindowID result = wxID_CANCEL; - if ((EmuConfig.CdvdSource == CDVD_SourceType::Disc) && (driveLetter == EmuConfig.CurrentDiscDrive)) + if ((g_Conf->CdvdSource == CDVD_SourceType::Disc) && (driveLetter == g_Conf->Folders.RunDisc)) { core.AllowResume(); return result; @@ -286,7 +286,7 @@ wxWindowID SwapOrReset_Disc(wxWindow* owner, IScopedCoreThread& core, const wxSt } } - EmuConfig.CdvdSource = CDVD_SourceType::Disc; + g_Conf->CdvdSource = CDVD_SourceType::Disc; SysUpdateDiscSrcDrive(driveLetter); if (result == wxID_RESET) { @@ -309,7 +309,7 @@ wxWindowID SwapOrReset_CdvdSrc(wxWindow* owner, CDVD_SourceType newsrc) wxMessageBox("Please close the GS debugger first before playing a game", _("GS Debugger"), wxICON_ERROR); return wxID_CANCEL; } - if (newsrc == EmuConfig.CdvdSource) + if (newsrc == g_Conf->CdvdSource) return wxID_CANCEL; wxWindowID result = wxID_CANCEL; ScopedCoreThreadPopup core; @@ -320,7 +320,7 @@ wxWindowID SwapOrReset_CdvdSrc(wxWindow* owner, CDVD_SourceType newsrc) wxString changeMsg; changeMsg.Printf(_("You've selected to switch the CDVD source from %s to %s."), - CDVD_SourceLabels[enum_cast(EmuConfig.CdvdSource)], CDVD_SourceLabels[enum_cast(newsrc)]); + CDVD_SourceLabels[enum_cast(g_Conf->CdvdSource)], CDVD_SourceLabels[enum_cast(newsrc)]); dialog += dialog.Heading(changeMsg + L"\n\n" + _("Do you want to swap discs or boot the new image (system reset)?")); @@ -341,8 +341,8 @@ wxWindowID SwapOrReset_CdvdSrc(wxWindow* owner, CDVD_SourceType newsrc) } g_CDVDReset = true; - CDVD_SourceType oldsrc = EmuConfig.CdvdSource; - EmuConfig.CdvdSource = newsrc; + CDVD_SourceType oldsrc = g_Conf->CdvdSource; + g_Conf->CdvdSource = newsrc; if (result != wxID_RESET) { @@ -356,7 +356,7 @@ wxWindowID SwapOrReset_CdvdSrc(wxWindow* owner, CDVD_SourceType newsrc) else { core.DisallowResume(); - sApp.SysExecute(EmuConfig.CdvdSource); + sApp.SysExecute(g_Conf->CdvdSource); } return result; @@ -436,7 +436,7 @@ bool MainEmuFrame::_DoSelectELFBrowser() if (ctrl.ShowModal() != wxID_CANCEL) { g_Conf->Folders.RunELF = wxFileName(ctrl.GetPath()).GetPath(); - EmuConfig.CurrentELF = ctrl.GetPath(); + g_Conf->CurrentELF = ctrl.GetPath(); return true; } @@ -452,18 +452,18 @@ void MainEmuFrame::_DoBootCdvd() } ScopedCoreThreadPause paused_core; - if (EmuConfig.CdvdSource == CDVD_SourceType::Iso) + if (g_Conf->CdvdSource == CDVD_SourceType::Iso) { - bool selector = EmuConfig.CurrentIso.empty(); + bool selector = g_Conf->CurrentIso.IsEmpty(); - if (!selector && !wxFileExists(EmuConfig.CurrentIso)) + if (!selector && !wxFileExists(g_Conf->CurrentIso)) { // User has an iso selected from a previous run, but it doesn't exist anymore. // Issue a courtesy popup and then an Iso Selector to choose a new one. wxDialogWithHelpers dialog(this, _("ISO file not found!")); dialog += dialog.Heading( - _("An error occurred while trying to open the file:") + wxString(L"\n\n") + EmuConfig.CurrentIso + L"\n\n" + + _("An error occurred while trying to open the file:") + wxString(L"\n\n") + g_Conf->CurrentIso + L"\n\n" + _("Error: The configured ISO file does not exist. Click OK to select a new ISO source for CDVD.")); pxIssueConfirmation(dialog, MsgButtons().OK()); @@ -497,7 +497,7 @@ void MainEmuFrame::_DoBootCdvd() } } - sApp.SysExecute(EmuConfig.CdvdSource); + sApp.SysExecute(g_Conf->CdvdSource); } void MainEmuFrame::Menu_CdvdSource_Click(wxCommandEvent& event) @@ -576,7 +576,7 @@ void MainEmuFrame::Menu_IsoClear_Click(wxCommandEvent& event) if (confirmed) { // If the CDVD mode is not ISO, or the system isn't running, wipe the CurrentIso field in INI file - if (EmuConfig.CdvdSource != CDVD_SourceType::Iso || !SysHasValidState()) + if (g_Conf->CdvdSource != CDVD_SourceType::Iso || !SysHasValidState()) SysUpdateIsoSrcFile(""); wxGetApp().GetRecentIsoManager().Clear(); AppSaveSettings(); @@ -730,7 +730,7 @@ void MainEmuFrame::Menu_OpenELF_Click(wxCommandEvent&) if (_DoSelectELFBrowser()) { g_Conf->EmuOptions.UseBOOT2Injection = true; - sApp.SysExecute(EmuConfig.CdvdSource, EmuConfig.CurrentELF); + sApp.SysExecute(g_Conf->CdvdSource, g_Conf->CurrentELF); } stopped_core.AllowResume(); diff --git a/pcsx2/gui/Panels/BiosSelectorPanel.cpp b/pcsx2/gui/Panels/BiosSelectorPanel.cpp index 21f9725295..176bcdaad2 100644 --- a/pcsx2/gui/Panels/BiosSelectorPanel.cpp +++ b/pcsx2/gui/Panels/BiosSelectorPanel.cpp @@ -17,6 +17,7 @@ #include "gui/App.h" #include "ConfigurationPanels.h" +#include "common/StringUtil.h" #include "ps2/BiosTools.h" #include @@ -137,7 +138,7 @@ void Panels::BiosSelectorPanel::Apply() .SetUserMsg(pxE(L"Please select a valid BIOS. If you are unable to make a valid selection then press Cancel to close the Configuration panel.")); } - g_Conf->EmuOptions.BaseFilenames.Bios = (*m_BiosList)[(sptr)m_ComboBox->GetClientData(sel)]; + g_Conf->EmuOptions.BaseFilenames.Bios = StringUtil::wxStringToUTF8String(wxFileName((*m_BiosList)[(sptr)m_ComboBox->GetClientData(sel)]).GetFullName()); } void Panels::BiosSelectorPanel::AppStatusEvent_OnSettingsApplied() @@ -203,13 +204,13 @@ void Panels::BiosSelectorPanel::OnEnumComplete(wxCommandEvent& evt) if (m_EnumeratorThread.get() != enumThread || m_BiosList->size() < enumThread->Result.size()) return; - const wxFileName currentBios = g_Conf->EmuOptions.FullpathToBios(); + const wxString currentBios(g_Conf->EmuOptions.FullpathToBios()); m_ComboBox->Clear(); // Clear the "Enumerating BIOSes..." for (const std::pair& result : enumThread->Result) { const int sel = m_ComboBox->Append(result.first, reinterpret_cast(static_cast(result.second))); - if (currentBios == wxFileName((*m_BiosList)[result.second])) + if (currentBios == (*m_BiosList)[result.second]) m_ComboBox->SetSelection(sel); } // Select a bios if one isn't selected. diff --git a/pcsx2/gui/Panels/MemoryCardListPanel.cpp b/pcsx2/gui/Panels/MemoryCardListPanel.cpp index ea3d6ad843..05c301e3dc 100644 --- a/pcsx2/gui/Panels/MemoryCardListPanel.cpp +++ b/pcsx2/gui/Panels/MemoryCardListPanel.cpp @@ -23,6 +23,7 @@ #include "gui/Dialogs/ConfigurationDialog.h" #include "common/IniInterface.h" +#include "common/StringUtil.h" #include "Sio.h" #include @@ -549,7 +550,7 @@ void Panels::MemoryCardListPanel_Simple::Apply() g_Conf->EmuOptions.Mcd[slot].Type = m_Cards[slot].Type; g_Conf->EmuOptions.Mcd[slot].Enabled = m_Cards[slot].IsEnabled && m_Cards[slot].IsPresent; if (m_Cards[slot].IsPresent) - g_Conf->EmuOptions.Mcd[slot].Filename = m_Cards[slot].Filename.GetFullName(); + g_Conf->EmuOptions.Mcd[slot].Filename = StringUtil::wxStringToUTF8String(m_Cards[slot].Filename.GetFullName()); else g_Conf->EmuOptions.Mcd[slot].Filename.clear(); @@ -570,7 +571,7 @@ void Panels::MemoryCardListPanel_Simple::AppStatusEvent_OnSettingsApplied() for (uint slot = 0; slot < 8; ++slot) { m_Cards[slot].IsEnabled = g_Conf->EmuOptions.Mcd[slot].Enabled; - m_Cards[slot].Filename = g_Conf->EmuOptions.Mcd[slot].Filename; + m_Cards[slot].Filename = StringUtil::UTF8StringToWxString(g_Conf->EmuOptions.Mcd[slot].Filename); // Automatically create the enabled but non-existing file such that it can be managed (else will get created anyway on boot) wxString targetFile = (GetMcdPath() + m_Cards[slot].Filename.GetFullName()).GetFullPath(); @@ -697,11 +698,7 @@ void Panels::MemoryCardListPanel_Simple::UiConvertCard(McdSlotItem& card) return; } - Pcsx2Config::McdOptions config; - config.Filename = card.Filename.GetFullName(); - config.Enabled = card.IsEnabled; - config.Type = card.Type; - Dialogs::ConvertMemoryCardDialog dialog(this, m_FolderPicker->GetPath(), config); + Dialogs::ConvertMemoryCardDialog dialog(this, m_FolderPicker->GetPath(), card.Type, card.Filename.GetFullName()); wxWindowID result = dialog.ShowModal(); if (result != wxID_CANCEL) diff --git a/pcsx2/gui/RecentIsoList.cpp b/pcsx2/gui/RecentIsoList.cpp index 039194ccfe..24670932a4 100644 --- a/pcsx2/gui/RecentIsoList.cpp +++ b/pcsx2/gui/RecentIsoList.cpp @@ -68,7 +68,7 @@ void RecentIsoManager::OnChangedSelection( wxCommandEvent& evt ) // Actually there is no change on the selection so the event can be skip // Note: It also avoids a deadlock which appears when the core thread is already paused // and ScopedCoreThreadPopup try to stop the thread (GSOpen1 code path) - if( (EmuConfig.CdvdSource == CDVD_SourceType::Iso) && (m_Items[i].Filename == EmuConfig.CurrentIso) ) + if( (g_Conf->CdvdSource == CDVD_SourceType::Iso) && (m_Items[i].Filename == g_Conf->CurrentIso) ) { evt.Skip(); return; @@ -224,7 +224,7 @@ void RecentIsoManager::LoadListFrom( IniInterface& ini ) ini.Entry( pxsFmt( L"Filename%02d", i ), loadtmp, loadtmp, true ); if( loadtmp.GetFullName()!=L"" ) Add( loadtmp.GetFullPath() ); } - Add(EmuConfig.CurrentIso ); + Add( g_Conf->CurrentIso ); ini.GetConfig().SetRecordDefaults( true ); } diff --git a/pcsx2/gui/wxSettingsInterface.cpp b/pcsx2/gui/wxSettingsInterface.cpp index 7210c351a6..2283eeb2ef 100644 --- a/pcsx2/gui/wxSettingsInterface.cpp +++ b/pcsx2/gui/wxSettingsInterface.cpp @@ -17,6 +17,7 @@ #include "wxSettingsInterface.h" #include "common/Assertions.h" +#include "common/StringUtil.h" wxSettingsInterface::wxSettingsInterface(wxConfigBase* config) : m_config(config) @@ -98,7 +99,7 @@ bool wxSettingsInterface::GetStringValue(const char* section, const char* key, s return false; wxString ret = m_config->Read(wxKey); - *value = ret.ToStdString(); + *value = StringUtil::wxStringToUTF8String(ret); return true; } @@ -135,7 +136,7 @@ void wxSettingsInterface::SetBoolValue(const char* section, const char* key, boo void wxSettingsInterface::SetStringValue(const char* section, const char* key, const char* value) { CheckPath(section); - m_config->Write(key, value); + m_config->Write(key, wxString::FromUTF8(value)); } std::vector wxSettingsInterface::GetStringList(const char* section, const char* key)