diff options
Diffstat (limited to 'src/frontend')
-rw-r--r-- | src/frontend/qt_sdl/Platform.cpp | 4 | ||||
-rw-r--r-- | src/frontend/qt_sdl/ROMManager.cpp | 49 | ||||
-rw-r--r-- | src/frontend/qt_sdl/ROMManager.h | 4 | ||||
-rw-r--r-- | src/frontend/qt_sdl/SaveManager.cpp | 4 | ||||
-rw-r--r-- | src/frontend/qt_sdl/SaveManager.h | 4 | ||||
-rw-r--r-- | src/frontend/qt_sdl/main.cpp | 2 |
6 files changed, 40 insertions, 27 deletions
diff --git a/src/frontend/qt_sdl/Platform.cpp b/src/frontend/qt_sdl/Platform.cpp index 6b48335..f626c88 100644 --- a/src/frontend/qt_sdl/Platform.cpp +++ b/src/frontend/qt_sdl/Platform.cpp @@ -288,7 +288,7 @@ bool GetConfigArray(ConfigEntry entry, void* data) } -FILE* OpenFile(std::string path, std::string mode, bool mustexist) +FILE* OpenFile(const std::string& path, const std::string& mode, bool mustexist) { QFile f(QString::fromStdString(path)); @@ -322,7 +322,7 @@ FILE* OpenFile(std::string path, std::string mode, bool mustexist) return file; } -FILE* OpenLocalFile(std::string path, std::string mode) +FILE* OpenLocalFile(const std::string& path, const std::string& mode) { QString qpath = QString::fromStdString(path); QDir dir(qpath); diff --git a/src/frontend/qt_sdl/ROMManager.cpp b/src/frontend/qt_sdl/ROMManager.cpp index ac525b7..cb671e2 100644 --- a/src/frontend/qt_sdl/ROMManager.cpp +++ b/src/frontend/qt_sdl/ROMManager.cpp @@ -58,7 +58,7 @@ ARCodeFile* CheatFile = nullptr; bool CheatsOn = false; -int LastSep(std::string path) +int LastSep(const std::string& path) { int i = path.length() - 1; while (i >= 0) @@ -72,32 +72,45 @@ int LastSep(std::string path) return -1; } -std::string GetAssetPath(bool gba, std::string configpath, std::string ext, std::string file="") +std::string GetAssetPath(bool gba, const std::string& configpath, const std::string& ext, const std::string& file = "") { - if (configpath.empty()) - configpath = gba ? BaseGBAROMDir : BaseROMDir; + std::string result; - if (file.empty()) - { - file = gba ? BaseGBAAssetName : BaseAssetName; - if (file.empty()) - file = "firmware"; - } + if (configpath.empty()) + result = gba ? BaseGBAROMDir : BaseROMDir; + else + result = configpath; + // cut off trailing slashes for (;;) { - int i = configpath.length() - 1; + int i = result.length() - 1; if (i < 0) break; - if (configpath[i] == '/' || configpath[i] == '\\') - configpath = configpath.substr(0, i); + if (result[i] == '/' || result[i] == '\\') + result.resize(i); else break; } - if (!configpath.empty()) - configpath += "/"; + if (!result.empty()) + result += '/'; + + if (file.empty()) + { + std::string& baseName = gba ? BaseGBAAssetName : BaseAssetName; + if (baseName.empty()) + result += "firmware"; + else + result += baseName; + } + else + { + result += file; + } + + result += ext; - return configpath + file + ext; + return result; } @@ -288,7 +301,7 @@ bool SavestateExists(int slot) return Platform::FileExists(ssfile); } -bool LoadState(std::string filename) +bool LoadState(const std::string& filename) { // backup Savestate* backup = new Savestate("timewarp.mln", true); @@ -335,7 +348,7 @@ bool LoadState(std::string filename) return true; } -bool SaveState(std::string filename) +bool SaveState(const std::string& filename) { Savestate* state = new Savestate(filename, true); if (state->Error) diff --git a/src/frontend/qt_sdl/ROMManager.h b/src/frontend/qt_sdl/ROMManager.h index 9e82a5b..efaed36 100644 --- a/src/frontend/qt_sdl/ROMManager.h +++ b/src/frontend/qt_sdl/ROMManager.h @@ -49,8 +49,8 @@ QString GBACartLabel(); std::string GetSavestateName(int slot); bool SavestateExists(int slot); -bool LoadState(std::string filename); -bool SaveState(std::string filename); +bool LoadState(const std::string& filename); +bool SaveState(const std::string& filename); void UndoStateLoad(); void EnableCheats(bool enable); diff --git a/src/frontend/qt_sdl/SaveManager.cpp b/src/frontend/qt_sdl/SaveManager.cpp index 31d2a68..005219b 100644 --- a/src/frontend/qt_sdl/SaveManager.cpp +++ b/src/frontend/qt_sdl/SaveManager.cpp @@ -25,7 +25,7 @@ using Platform::Log; using Platform::LogLevel; -SaveManager::SaveManager(std::string path) : QThread() +SaveManager::SaveManager(const std::string& path) : QThread() { SecondaryBuffer = nullptr; SecondaryBufferLength = 0; @@ -71,7 +71,7 @@ std::string SaveManager::GetPath() return Path; } -void SaveManager::SetPath(std::string path, bool reload) +void SaveManager::SetPath(const std::string& path, bool reload) { Path = path; diff --git a/src/frontend/qt_sdl/SaveManager.h b/src/frontend/qt_sdl/SaveManager.h index 0d38f4b..33035ed 100644 --- a/src/frontend/qt_sdl/SaveManager.h +++ b/src/frontend/qt_sdl/SaveManager.h @@ -34,11 +34,11 @@ class SaveManager : public QThread void run() override; public: - SaveManager(std::string path); + SaveManager(const std::string& path); ~SaveManager(); std::string GetPath(); - void SetPath(std::string path, bool reload); + void SetPath(const std::string& path, bool reload); void RequestFlush(const u8* savedata, u32 savelen, u32 writeoffset, u32 writelen); void CheckFlush(); diff --git a/src/frontend/qt_sdl/main.cpp b/src/frontend/qt_sdl/main.cpp index 7015c6d..518d5f5 100644 --- a/src/frontend/qt_sdl/main.cpp +++ b/src/frontend/qt_sdl/main.cpp @@ -279,7 +279,7 @@ void micClose() micDevice = 0; } -void micLoadWav(std::string name) +void micLoadWav(const std::string& name) { SDL_AudioSpec format; memset(&format, 0, sizeof(SDL_AudioSpec)); |