Config: Swap out wxString for std::string

Also in CDVD.
This commit is contained in:
Connor McLaughlin 2021-09-21 20:05:11 +10:00 committed by Kojin
parent d13982ea0e
commit 4d8905abd6
11 changed files with 38 additions and 40 deletions

View File

@ -293,30 +293,29 @@ static void DetectDiskType()
diskTypeCached = FindDiskType(mType); diskTypeCached = FindDiskType(mType);
} }
static wxString m_SourceFilename[3]; static std::string m_SourceFilename[3];
static CDVD_SourceType m_CurrentSourceType = CDVD_SourceType::NoDisc; static CDVD_SourceType m_CurrentSourceType = CDVD_SourceType::NoDisc;
void CDVDsys_SetFile(CDVD_SourceType srctype, const wxString& newfile) void CDVDsys_SetFile(CDVD_SourceType srctype, std::string newfile)
{ {
m_SourceFilename[enum_cast(srctype)] = newfile; m_SourceFilename[enum_cast(srctype)] = std::move(newfile);
// look for symbol file // look for symbol file
if (symbolMap.IsEmpty()) if (symbolMap.IsEmpty())
{ {
wxString symName; std::string symName;
int n = newfile.Last('.'); std::string::size_type n = m_SourceFilename[enum_cast(srctype)].rfind('.');
if (n == wxNOT_FOUND) if (n == std::string::npos)
symName = newfile + L".sym"; symName = m_SourceFilename[enum_cast(srctype)] + ".sym";
else else
symName = newfile.substr(0, n) + L".sym"; symName = m_SourceFilename[enum_cast(srctype)].substr(0, n) + ".sym";
wxCharBuffer buf = symName.ToUTF8(); symbolMap.LoadNocashSym(symName.c_str());
symbolMap.LoadNocashSym(buf);
symbolMap.UpdateActiveSymbols(); symbolMap.UpdateActiveSymbols();
} }
} }
const wxString& CDVDsys_GetFile(CDVD_SourceType srctype) const std::string& CDVDsys_GetFile(CDVD_SourceType srctype)
{ {
return m_SourceFilename[enum_cast(srctype)]; return m_SourceFilename[enum_cast(srctype)];
} }
@ -364,10 +363,7 @@ bool DoCDVDopen()
//TODO_CDVD check if ISO and Disc use UTF8 //TODO_CDVD check if ISO and Disc use UTF8
auto CurrentSourceType = enum_cast(m_CurrentSourceType); auto CurrentSourceType = enum_cast(m_CurrentSourceType);
int ret = CDVD->open(!m_SourceFilename[CurrentSourceType].IsEmpty() ? int ret = CDVD->open(!m_SourceFilename[CurrentSourceType].empty() ? m_SourceFilename[CurrentSourceType].c_str() : nullptr);
static_cast<const char*>(m_SourceFilename[CurrentSourceType].ToUTF8()) :
(char*)NULL);
if (ret == -1) if (ret == -1)
return false; // error! (handled by caller) return false; // error! (handled by caller)
@ -388,8 +384,8 @@ bool DoCDVDopen()
else if (somepick.IsEmpty()) else if (somepick.IsEmpty())
somepick = L"Untitled"; somepick = L"Untitled";
if (EmuConfig.CurrentBlockdump.IsEmpty()) if (EmuConfig.CurrentBlockdump.empty())
EmuConfig.CurrentBlockdump = wxGetCwd(); EmuConfig.CurrentBlockdump = wxGetCwd().ToStdString();
wxString temp(Path::Combine(EmuConfig.CurrentBlockdump, somepick)); wxString temp(Path::Combine(EmuConfig.CurrentBlockdump, somepick));

View File

@ -14,6 +14,7 @@
*/ */
#pragma once #pragma once
#include <string>
typedef struct _cdvdSubQ typedef struct _cdvdSubQ
{ {
@ -151,8 +152,8 @@ extern CDVD_API CDVDapi_NoDisc;
extern const wxChar* CDVD_SourceLabels[]; extern const wxChar* CDVD_SourceLabels[];
extern void CDVDsys_ChangeSource(CDVD_SourceType type); extern void CDVDsys_ChangeSource(CDVD_SourceType type);
extern void CDVDsys_SetFile(CDVD_SourceType srctype, const wxString& newfile); extern void CDVDsys_SetFile(CDVD_SourceType srctype, std::string newfile);
extern const wxString& CDVDsys_GetFile(CDVD_SourceType srctype); extern const std::string& CDVDsys_GetFile(CDVD_SourceType srctype);
extern CDVD_SourceType CDVDsys_GetSourceType(); extern CDVD_SourceType CDVDsys_GetSourceType();
extern bool DoCDVDopen(); extern bool DoCDVDopen();

View File

@ -19,6 +19,7 @@
#include "common/General.h" #include "common/General.h"
#include "common/Path.h" #include "common/Path.h"
#include <wx/filename.h> #include <wx/filename.h>
#include <string>
class IniInterface; class IniInterface;
@ -585,16 +586,16 @@ struct Pcsx2Config
// Memorycard options - first 2 are default slots, last 6 are multitap 1 and 2 // Memorycard options - first 2 are default slots, last 6 are multitap 1 and 2
// slots (3 each) // slots (3 each)
McdOptions Mcd[8]; McdOptions Mcd[8];
wxString GzipIsoIndexTemplate; // for quick-access index with gzipped ISO std::string GzipIsoIndexTemplate; // for quick-access index with gzipped ISO
// Set at runtime, not loaded from config. // Set at runtime, not loaded from config.
CDVD_SourceType CdvdSource; CDVD_SourceType CdvdSource;
wxString CurrentIso; std::string CurrentIso;
wxString CurrentDiscDrive; std::string CurrentDiscDrive;
wxString CurrentBlockdump; std::string CurrentBlockdump;
wxString CurrentELF; std::string CurrentELF;
wxString CurrentIRX; std::string CurrentIRX;
wxString CurrentGameArgs; std::string CurrentGameArgs;
AspectRatioType CurrentAspectRatio = AspectRatioType::R4_3; AspectRatioType CurrentAspectRatio = AspectRatioType::R4_3;
LimiterModeType LimiterMode = LimiterModeType::Nominal; LimiterModeType LimiterMode = LimiterModeType::Nominal;

View File

@ -508,7 +508,7 @@ Pcsx2Config::Pcsx2Config()
Mcd[slot].Type = MemoryCardType::MemoryCard_File; Mcd[slot].Type = MemoryCardType::MemoryCard_File;
} }
GzipIsoIndexTemplate = L"$(f).pindex.tmp"; GzipIsoIndexTemplate = "$(f).pindex.tmp";
CdvdSource = CDVD_SourceType::Iso; CdvdSource = CDVD_SourceType::Iso;
} }

View File

@ -224,7 +224,7 @@ static __fi void execI()
#endif #endif
// Inject IRX hack // Inject IRX hack
if (psxRegs.pc == 0x1630 && EmuConfig.CurrentIRX.Length() > 3) { if (psxRegs.pc == 0x1630 && EmuConfig.CurrentIRX.length() > 3) {
if (iopMemRead32(0x20018) == 0x1F) { if (iopMemRead32(0x20018) == 0x1F) {
// FIXME do I need to increase the module count (0x1F -> 0x20) // FIXME do I need to increase the module count (0x1F -> 0x20)
iopMemWrite32(0x20094, 0xbffc0000); iopMemWrite32(0x20094, 0xbffc0000);

View File

@ -292,7 +292,7 @@ void InputRecording::SetupInitialState(u32 newStartingFrame)
else else
{ {
// Check if the current game matches with the one used to make the original recording // Check if the current game matches with the one used to make the original recording
if (!EmuConfig.CurrentIso.IsEmpty()) if (!EmuConfig.CurrentIso.empty())
if (resolveGameName() != inputRecordingData.GetHeader().gameName) if (resolveGameName() != inputRecordingData.GetHeader().gameName)
inputRec::consoleLog("Input recording was possibly constructed for a different game."); inputRec::consoleLog("Input recording was possibly constructed for a different game.");

View File

@ -671,7 +671,7 @@ void AppConfig::FolderOptions::LoadSave( IniInterface& ini )
operator[]( (FoldersEnum_t)i ).Normalize(); operator[]( (FoldersEnum_t)i ).Normalize();
EmuConfig.Folders.Settings = GetSettingsFolder(); EmuConfig.Folders.Settings = GetSettingsFolder();
EmuConfig.CurrentDiscDrive = RunDisc; EmuConfig.CurrentDiscDrive = RunDisc.ToStdString();
EmuConfig.Folders.Bios = Bios; EmuConfig.Folders.Bios = Bios;
EmuConfig.Folders.Snapshots = Snapshots; EmuConfig.Folders.Snapshots = Snapshots;
EmuConfig.Folders.Savestates = Savestates; EmuConfig.Folders.Savestates = Savestates;

View File

@ -969,7 +969,7 @@ protected:
bool m_UseCDVDsrc; bool m_UseCDVDsrc;
bool m_UseELFOverride; bool m_UseELFOverride;
CDVD_SourceType m_cdvdsrc_type; CDVD_SourceType m_cdvdsrc_type;
wxString m_elf_override; std::string m_elf_override;
public: public:
virtual ~SysExecEvent_Execute() = default; virtual ~SysExecEvent_Execute() = default;
@ -992,11 +992,11 @@ public:
{ {
} }
SysExecEvent_Execute( CDVD_SourceType srctype, const wxString& elf_override ) SysExecEvent_Execute( CDVD_SourceType srctype, std::string elf_override )
: m_UseCDVDsrc(true) : m_UseCDVDsrc(true)
, m_UseELFOverride(true) , m_UseELFOverride(true)
, m_cdvdsrc_type(srctype) , m_cdvdsrc_type(srctype)
, m_elf_override( elf_override ) , m_elf_override( std::move(elf_override) )
{ {
} }
@ -1039,7 +1039,7 @@ void Pcsx2App::SysExecute()
// sources. // sources.
void Pcsx2App::SysExecute( CDVD_SourceType cdvdsrc, const wxString& elf_override ) void Pcsx2App::SysExecute( CDVD_SourceType cdvdsrc, const wxString& elf_override )
{ {
SysExecutorThread.PostEvent( new SysExecEvent_Execute(cdvdsrc, elf_override) ); SysExecutorThread.PostEvent( new SysExecEvent_Execute(cdvdsrc, elf_override.ToStdString()) );
#ifndef DISABLE_RECORDING #ifndef DISABLE_RECORDING
if (g_Conf->EmuOptions.EnableRecordingTools) if (g_Conf->EmuOptions.EnableRecordingTools)
{ {

View File

@ -454,7 +454,7 @@ void MainEmuFrame::_DoBootCdvd()
if (EmuConfig.CdvdSource == CDVD_SourceType::Iso) if (EmuConfig.CdvdSource == CDVD_SourceType::Iso)
{ {
bool selector = EmuConfig.CurrentIso.IsEmpty(); bool selector = EmuConfig.CurrentIso.empty();
if (!selector && !wxFileExists(EmuConfig.CurrentIso)) if (!selector && !wxFileExists(EmuConfig.CurrentIso))
{ {

View File

@ -221,14 +221,14 @@ static void LoadExtraRom( const wxChar* ext, u8 (&dest)[_size] )
} }
} }
static void LoadIrx( const wxString& filename, u8* dest ) static void LoadIrx( const std::string& filename, u8* dest )
{ {
s64 filesize = 0; s64 filesize = 0;
try try
{ {
wxFile irx(filename); wxFile irx(filename);
if( (filesize=Path::GetFileSize( filename ) ) <= 0 ) { if( (filesize=Path::GetFileSize( filename ) ) <= 0 ) {
Console.Warning(L"IRX Warning: %s could not be read", WX_STR(filename)); Console.Warning("IRX Warning: %s could not be read", filename.c_str());
return; return;
} }
@ -236,7 +236,7 @@ static void LoadIrx( const wxString& filename, u8* dest )
} }
catch (Exception::BadStream& ex) catch (Exception::BadStream& ex)
{ {
Console.Warning(L"IRX Warning: %s could not be read", WX_STR(filename)); Console.Warning("IRX Warning: %s could not be read", filename.c_str());
Console.Indent().WriteLn(L"Details: %s", WX_STR(ex.FormatDiagnosticMessage())); Console.Indent().WriteLn(L"Details: %s", WX_STR(ex.FormatDiagnosticMessage()));
} }
} }
@ -299,7 +299,7 @@ void LoadBIOS()
LoadExtraRom( L"rom2", eeMem->ROM2 ); LoadExtraRom( L"rom2", eeMem->ROM2 );
LoadExtraRom( L"erom", eeMem->EROM ); LoadExtraRom( L"erom", eeMem->EROM );
if (EmuConfig.CurrentIRX.Length() > 3) if (EmuConfig.CurrentIRX.length() > 3)
LoadIrx(EmuConfig.CurrentIRX, &eeMem->ROM[0x3C0000]); LoadIrx(EmuConfig.CurrentIRX, &eeMem->ROM[0x3C0000]);
CurrentBiosInformation.threadListAddr = 0; CurrentBiosInformation.threadListAddr = 0;

View File

@ -1300,7 +1300,7 @@ static void __fastcall iopRecRecompile(const u32 startpc)
u32 willbranch3 = 0; u32 willbranch3 = 0;
// Inject IRX hack // Inject IRX hack
if (startpc == 0x1630 && EmuConfig.CurrentIRX.Length() > 3) if (startpc == 0x1630 && EmuConfig.CurrentIRX.length() > 3)
{ {
if (iopMemRead32(0x20018) == 0x1F) if (iopMemRead32(0x20018) == 0x1F)
{ {