remove some more shitty strings

This commit is contained in:
Arisotura 2021-11-17 20:57:30 +01:00
parent 5bb8f4c922
commit 13afaa0303
5 changed files with 32 additions and 37 deletions

View File

@ -30,7 +30,7 @@
AudioSettingsDialog* AudioSettingsDialog::currentDlg = nullptr; AudioSettingsDialog* AudioSettingsDialog::currentDlg = nullptr;
extern char* EmuDirectory; extern std::string EmuDirectory;
AudioSettingsDialog::AudioSettingsDialog(QWidget* parent) : QDialog(parent), ui(new Ui::AudioSettingsDialog) AudioSettingsDialog::AudioSettingsDialog(QWidget* parent) : QDialog(parent), ui(new Ui::AudioSettingsDialog)
@ -129,7 +129,7 @@ void AudioSettingsDialog::on_btnMicWavBrowse_clicked()
{ {
QString file = QFileDialog::getOpenFileName(this, QString file = QFileDialog::getOpenFileName(this,
"Select WAV file...", "Select WAV file...",
EmuDirectory, QString::fromStdString(EmuDirectory),
"WAV files (*.wav);;Any file (*.*)"); "WAV files (*.wav);;Any file (*.*)");
if (file.isEmpty()) return; if (file.isEmpty()) return;

View File

@ -32,7 +32,7 @@
CheatsDialog* CheatsDialog::currentDlg = nullptr; CheatsDialog* CheatsDialog::currentDlg = nullptr;
extern char* EmuDirectory; extern std::string EmuDirectory;
namespace Frontend { extern ARCodeFile* CheatFile; } namespace Frontend { extern ARCodeFile* CheatFile; }

View File

@ -33,7 +33,7 @@
EmuSettingsDialog* EmuSettingsDialog::currentDlg = nullptr; EmuSettingsDialog* EmuSettingsDialog::currentDlg = nullptr;
extern char* EmuDirectory; extern std::string EmuDirectory;
extern bool RunningSomething; extern bool RunningSomething;
bool EmuSettingsDialog::needsReset = false; bool EmuSettingsDialog::needsReset = false;
@ -294,7 +294,7 @@ void EmuSettingsDialog::on_btnBIOS9Browse_clicked()
{ {
QString file = QFileDialog::getOpenFileName(this, QString file = QFileDialog::getOpenFileName(this,
"Select DS-mode ARM9 BIOS...", "Select DS-mode ARM9 BIOS...",
EmuDirectory, QString::fromStdString(EmuDirectory),
"BIOS files (*.bin *.rom);;Any file (*.*)"); "BIOS files (*.bin *.rom);;Any file (*.*)");
if (file.isEmpty()) return; if (file.isEmpty()) return;
@ -306,7 +306,7 @@ void EmuSettingsDialog::on_btnBIOS7Browse_clicked()
{ {
QString file = QFileDialog::getOpenFileName(this, QString file = QFileDialog::getOpenFileName(this,
"Select DS-mode ARM7 BIOS...", "Select DS-mode ARM7 BIOS...",
EmuDirectory, QString::fromStdString(EmuDirectory),
"BIOS files (*.bin *.rom);;Any file (*.*)"); "BIOS files (*.bin *.rom);;Any file (*.*)");
if (file.isEmpty()) return; if (file.isEmpty()) return;
@ -318,7 +318,7 @@ void EmuSettingsDialog::on_btnFirmwareBrowse_clicked()
{ {
QString file = QFileDialog::getOpenFileName(this, QString file = QFileDialog::getOpenFileName(this,
"Select DS-mode firmware...", "Select DS-mode firmware...",
EmuDirectory, QString::fromStdString(EmuDirectory),
"Firmware files (*.bin *.rom);;Any file (*.*)"); "Firmware files (*.bin *.rom);;Any file (*.*)");
if (file.isEmpty()) return; if (file.isEmpty()) return;
@ -330,7 +330,7 @@ void EmuSettingsDialog::on_btnDSiBIOS9Browse_clicked()
{ {
QString file = QFileDialog::getOpenFileName(this, QString file = QFileDialog::getOpenFileName(this,
"Select DSi-mode ARM9 BIOS...", "Select DSi-mode ARM9 BIOS...",
EmuDirectory, QString::fromStdString(EmuDirectory),
"BIOS files (*.bin *.rom);;Any file (*.*)"); "BIOS files (*.bin *.rom);;Any file (*.*)");
if (file.isEmpty()) return; if (file.isEmpty()) return;
@ -342,7 +342,7 @@ void EmuSettingsDialog::on_btnDSiBIOS7Browse_clicked()
{ {
QString file = QFileDialog::getOpenFileName(this, QString file = QFileDialog::getOpenFileName(this,
"Select DSi-mode ARM7 BIOS...", "Select DSi-mode ARM7 BIOS...",
EmuDirectory, QString::fromStdString(EmuDirectory),
"BIOS files (*.bin *.rom);;Any file (*.*)"); "BIOS files (*.bin *.rom);;Any file (*.*)");
if (file.isEmpty()) return; if (file.isEmpty()) return;
@ -368,7 +368,7 @@ void EmuSettingsDialog::on_btnDLDISDBrowse_clicked()
{ {
QString file = QFileDialog::getOpenFileName(this, QString file = QFileDialog::getOpenFileName(this,
"Select DLDI SD image...", "Select DLDI SD image...",
EmuDirectory, QString::fromStdString(EmuDirectory),
"Image files (*.bin *.rom *.img *.dmg);;Any file (*.*)"); "Image files (*.bin *.rom *.img *.dmg);;Any file (*.*)");
if (file.isEmpty()) return; if (file.isEmpty()) return;
@ -387,7 +387,7 @@ void EmuSettingsDialog::on_btnDLDIFolderBrowse_clicked()
{ {
QString dir = QFileDialog::getExistingDirectory(this, QString dir = QFileDialog::getExistingDirectory(this,
"Select DLDI SD folder...", "Select DLDI SD folder...",
EmuDirectory); QString::fromStdString(EmuDirectory));
if (dir.isEmpty()) return; if (dir.isEmpty()) return;
@ -398,7 +398,7 @@ void EmuSettingsDialog::on_btnDSiFirmwareBrowse_clicked()
{ {
QString file = QFileDialog::getOpenFileName(this, QString file = QFileDialog::getOpenFileName(this,
"Select DSi DS-mode firmware...", "Select DSi DS-mode firmware...",
EmuDirectory, QString::fromStdString(EmuDirectory),
"Firmware files (*.bin *.rom);;Any file (*.*)"); "Firmware files (*.bin *.rom);;Any file (*.*)");
if (file.isEmpty()) return; if (file.isEmpty()) return;
@ -410,7 +410,7 @@ void EmuSettingsDialog::on_btnDSiNANDBrowse_clicked()
{ {
QString file = QFileDialog::getOpenFileName(this, QString file = QFileDialog::getOpenFileName(this,
"Select DSi NAND...", "Select DSi NAND...",
EmuDirectory, QString::fromStdString(EmuDirectory),
"NAND files (*.bin *.rom);;Any file (*.*)"); "NAND files (*.bin *.rom);;Any file (*.*)");
if (file.isEmpty()) return; if (file.isEmpty()) return;
@ -436,7 +436,7 @@ void EmuSettingsDialog::on_btnDSiSDBrowse_clicked()
{ {
QString file = QFileDialog::getOpenFileName(this, QString file = QFileDialog::getOpenFileName(this,
"Select DSi SD image...", "Select DSi SD image...",
EmuDirectory, QString::fromStdString(EmuDirectory),
"Image files (*.bin *.rom *.img *.dmg);;Any file (*.*)"); "Image files (*.bin *.rom *.img *.dmg);;Any file (*.*)");
if (file.isEmpty()) return; if (file.isEmpty()) return;
@ -455,7 +455,7 @@ void EmuSettingsDialog::on_btnDSiSDFolderBrowse_clicked()
{ {
QString dir = QFileDialog::getExistingDirectory(this, QString dir = QFileDialog::getExistingDirectory(this,
"Select DSi SD folder...", "Select DSi SD folder...",
EmuDirectory); QString::fromStdString(EmuDirectory));
if (dir.isEmpty()) return; if (dir.isEmpty()) return;

View File

@ -61,7 +61,7 @@
#endif #endif
char* EmuDirectory; std::string EmuDirectory;
void emuStop(); void emuStop();
@ -90,35 +90,29 @@ void Init(int argc, char** argv)
} }
if (len > 0) if (len > 0)
{ {
EmuDirectory = new char[len+1]; std::string emudir = argv[0];
strncpy(EmuDirectory, argv[0], len); EmuDirectory = emudir.substr(0, len);
EmuDirectory[len] = '\0';
} }
else else
{ {
EmuDirectory = new char[2]; EmuDirectory = ".";
strcpy(EmuDirectory, ".");
} }
} }
else else
{ {
EmuDirectory = new char[2]; EmuDirectory = ".";
strcpy(EmuDirectory, ".");
} }
#else #else
QString confdir; QString confdir;
QDir config(QStandardPaths::writableLocation(QStandardPaths::ConfigLocation)); QDir config(QStandardPaths::writableLocation(QStandardPaths::ConfigLocation));
config.mkdir("melonDS"); config.mkdir("melonDS");
confdir = config.absolutePath() + "/melonDS/"; confdir = config.absolutePath() + "/melonDS/";
EmuDirectory = new char[confdir.length() + 1]; EmuDirectory = confdir.toStdString();
memcpy(EmuDirectory, confdir.toUtf8().data(), confdir.length());
EmuDirectory[confdir.length()] = '\0';
#endif #endif
} }
void DeInit() void DeInit()
{ {
delete[] EmuDirectory;
} }
@ -197,7 +191,7 @@ std::string GetConfigString(ConfigEntry entry)
FILE* OpenFile(std::string path, std::string mode, bool mustexist) FILE* OpenFile(std::string path, std::string mode, bool mustexist)
{ {
QFile f(path.c_str()); QFile f(QString::fromStdString(path));
if (mustexist && !f.exists()) if (mustexist && !f.exists())
{ {
@ -231,24 +225,25 @@ FILE* OpenFile(std::string path, std::string mode, bool mustexist)
FILE* OpenLocalFile(std::string path, std::string mode) FILE* OpenLocalFile(std::string path, std::string mode)
{ {
QDir dir(path.c_str()); QString qpath = QString::fromStdString(path);
QDir dir(qpath);
QString fullpath; QString fullpath;
if (dir.isAbsolute()) if (dir.isAbsolute())
{ {
// If it's an absolute path, just open that. // If it's an absolute path, just open that.
fullpath = path.c_str(); fullpath = qpath;
} }
else else
{ {
#ifdef PORTABLE #ifdef PORTABLE
fullpath = QString(EmuDirectory) + QDir::separator() + path.c_str(); fullpath = QString::fromStdString(EmuDirectory) + QDir::separator() + qpath;
#else #else
// Check user configuration directory // Check user configuration directory
QDir config(QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation)); QDir config(QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation));
config.mkdir("melonDS"); config.mkdir("melonDS");
fullpath = config.absolutePath() + "/melonDS/"; fullpath = config.absolutePath() + "/melonDS/";
fullpath.append(path.c_str()); fullpath.append(qpath);
#endif #endif
} }

View File

@ -35,7 +35,7 @@
FILE* TitleManagerDialog::curNAND = nullptr; FILE* TitleManagerDialog::curNAND = nullptr;
TitleManagerDialog* TitleManagerDialog::currentDlg = nullptr; TitleManagerDialog* TitleManagerDialog::currentDlg = nullptr;
extern char* EmuDirectory; extern std::string EmuDirectory;
TitleManagerDialog::TitleManagerDialog(QWidget* parent) : QDialog(parent), ui(new Ui::TitleManagerDialog) TitleManagerDialog::TitleManagerDialog(QWidget* parent) : QDialog(parent), ui(new Ui::TitleManagerDialog)
@ -285,7 +285,7 @@ void TitleManagerDialog::onImportTitleData()
QString file = QFileDialog::getOpenFileName(this, QString file = QFileDialog::getOpenFileName(this,
"Select file to import...", "Select file to import...",
EmuDirectory, QString::fromStdString(EmuDirectory),
"Title data files (*.sav);;Any file (*.*)"); "Title data files (*.sav);;Any file (*.*)");
if (file.isEmpty()) return; if (file.isEmpty()) return;
@ -355,7 +355,7 @@ void TitleManagerDialog::onExportTitleData()
QString file = QFileDialog::getSaveFileName(this, QString file = QFileDialog::getSaveFileName(this,
"Select path to export to...", "Select path to export to...",
QString(EmuDirectory) + exportname, QString::fromStdString(EmuDirectory) + exportname,
"Title data files (*.sav);;Any file (*.*)"); "Title data files (*.sav);;Any file (*.*)");
if (file.isEmpty()) return; if (file.isEmpty()) return;
@ -528,7 +528,7 @@ void TitleImportDialog::on_btnAppBrowse_clicked()
{ {
QString file = QFileDialog::getOpenFileName(this, QString file = QFileDialog::getOpenFileName(this,
"Select title executable...", "Select title executable...",
EmuDirectory, QString::fromStdString(EmuDirectory),
"DSiWare executables (*.app *.nds *.dsi *.srl);;Any file (*.*)"); "DSiWare executables (*.app *.nds *.dsi *.srl);;Any file (*.*)");
if (file.isEmpty()) return; if (file.isEmpty()) return;
@ -540,7 +540,7 @@ void TitleImportDialog::on_btnTmdBrowse_clicked()
{ {
QString file = QFileDialog::getOpenFileName(this, QString file = QFileDialog::getOpenFileName(this,
"Select title metadata...", "Select title metadata...",
EmuDirectory, QString::fromStdString(EmuDirectory),
"DSiWare metadata (*.tmd);;Any file (*.*)"); "DSiWare metadata (*.tmd);;Any file (*.*)");
if (file.isEmpty()) return; if (file.isEmpty()) return;