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

View File

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

View File

@ -19,6 +19,7 @@
#include "common/General.h"
#include "common/Path.h"
#include <wx/filename.h>
#include <string>
class IniInterface;
@ -585,16 +586,16 @@ struct Pcsx2Config
// Memorycard options - first 2 are default slots, last 6 are multitap 1 and 2
// slots (3 each)
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.
CDVD_SourceType CdvdSource;
wxString CurrentIso;
wxString CurrentDiscDrive;
wxString CurrentBlockdump;
wxString CurrentELF;
wxString CurrentIRX;
wxString CurrentGameArgs;
std::string CurrentIso;
std::string CurrentDiscDrive;
std::string CurrentBlockdump;
std::string CurrentELF;
std::string CurrentIRX;
std::string CurrentGameArgs;
AspectRatioType CurrentAspectRatio = AspectRatioType::R4_3;
LimiterModeType LimiterMode = LimiterModeType::Nominal;

View File

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

View File

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

View File

@ -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.IsEmpty())
if (!EmuConfig.CurrentIso.empty())
if (resolveGameName() != inputRecordingData.GetHeader().gameName)
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();
EmuConfig.Folders.Settings = GetSettingsFolder();
EmuConfig.CurrentDiscDrive = RunDisc;
EmuConfig.CurrentDiscDrive = RunDisc.ToStdString();
EmuConfig.Folders.Bios = Bios;
EmuConfig.Folders.Snapshots = Snapshots;
EmuConfig.Folders.Savestates = Savestates;

View File

@ -969,7 +969,7 @@ protected:
bool m_UseCDVDsrc;
bool m_UseELFOverride;
CDVD_SourceType m_cdvdsrc_type;
wxString m_elf_override;
std::string m_elf_override;
public:
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_UseELFOverride(true)
, m_cdvdsrc_type(srctype)
, m_elf_override( elf_override )
, m_elf_override( std::move(elf_override) )
{
}
@ -1039,7 +1039,7 @@ void Pcsx2App::SysExecute()
// sources.
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
if (g_Conf->EmuOptions.EnableRecordingTools)
{

View File

@ -454,7 +454,7 @@ void MainEmuFrame::_DoBootCdvd()
if (EmuConfig.CdvdSource == CDVD_SourceType::Iso)
{
bool selector = EmuConfig.CurrentIso.IsEmpty();
bool selector = EmuConfig.CurrentIso.empty();
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;
try
{
wxFile irx(filename);
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;
}
@ -236,7 +236,7 @@ static void LoadIrx( const wxString& filename, u8* dest )
}
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()));
}
}
@ -299,7 +299,7 @@ void LoadBIOS()
LoadExtraRom( L"rom2", eeMem->ROM2 );
LoadExtraRom( L"erom", eeMem->EROM );
if (EmuConfig.CurrentIRX.Length() > 3)
if (EmuConfig.CurrentIRX.length() > 3)
LoadIrx(EmuConfig.CurrentIRX, &eeMem->ROM[0x3C0000]);
CurrentBiosInformation.threadListAddr = 0;

View File

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