From b71d06e07c877ed34e3d8a3284bb22b009cd7baa Mon Sep 17 00:00:00 2001 From: Vinicius Rangel Date: Wed, 25 Sep 2024 13:52:22 -0300 Subject: [PATCH] Fix QT path to run games --- src/emulator.cpp | 4 ++-- src/qt_gui/game_info.cpp | 2 +- src/qt_gui/game_info.h | 4 ++-- src/qt_gui/main_window.cpp | 13 +++++++------ src/video_core/renderdoc.cpp | 4 ++-- src/video_core/renderdoc.h | 2 +- 6 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/emulator.cpp b/src/emulator.cpp index e68fb8f18..b27c73867 100644 --- a/src/emulator.cpp +++ b/src/emulator.cpp @@ -189,7 +189,7 @@ void Emulator::Run(const std::filesystem::path& file) { if (!std::filesystem::exists(mount_captures_dir)) { std::filesystem::create_directory(mount_captures_dir); } - VideoCore::SetOutputDir(mount_captures_dir.generic_string(), id); + VideoCore::SetOutputDir(mount_captures_dir, id); // Initialize kernel and library facilities. Libraries::Kernel::init_pthreads(); @@ -205,7 +205,7 @@ void Emulator::Run(const std::filesystem::path& file) { std::filesystem::path sce_module_folder = file.parent_path() / "sce_module"; if (std::filesystem::is_directory(sce_module_folder)) { for (const auto& entry : std::filesystem::directory_iterator(sce_module_folder)) { - LOG_INFO(Loader, "Loading {}", entry.path().string().c_str()); + LOG_INFO(Loader, "Loading {}", fmt::UTF(entry.path().u8string())); linker->LoadModule(entry.path()); } } diff --git a/src/qt_gui/game_info.cpp b/src/qt_gui/game_info.cpp index 52aa64322..6e8d89713 100644 --- a/src/qt_gui/game_info.cpp +++ b/src/qt_gui/game_info.cpp @@ -21,7 +21,7 @@ void GameInfoClass::GetGameInfo(QWidget* parent) { } } m_games = QtConcurrent::mapped(filePaths, [&](const QString& path) { - return readGameInfo(path.toStdString()); + return readGameInfo(Common::FS::PathFromQString(path)); }).results(); // Progress bar, please be patient :) diff --git a/src/qt_gui/game_info.h b/src/qt_gui/game_info.h index 7f60c37df..c7739f5f9 100644 --- a/src/qt_gui/game_info.h +++ b/src/qt_gui/game_info.h @@ -22,12 +22,12 @@ public: return a.name < b.name; } - static GameInfo readGameInfo(const std::string& filePath) { + static GameInfo readGameInfo(const std::filesystem::path& filePath) { GameInfo game; game.path = filePath; PSF psf; - if (psf.Open(std::filesystem::path(game.path) / "sce_sys" / "param.sfo")) { + if (psf.Open(game.path / "sce_sys" / "param.sfo")) { game.icon_path = game.path / "sce_sys" / "icon0.png"; QString iconpath; Common::FS::PathToQString(iconpath, game.icon_path); diff --git a/src/qt_gui/main_window.cpp b/src/qt_gui/main_window.cpp index 808058b73..fa478878c 100644 --- a/src/qt_gui/main_window.cpp +++ b/src/qt_gui/main_window.cpp @@ -511,11 +511,12 @@ void MainWindow::StartGame() { if (gamePath != "") { AddRecentFiles(gamePath); Core::Emulator emulator; - if (!std::filesystem::exists(gamePath.toUtf8().constData())) { + const auto path = Common::FS::PathFromQString(gamePath); + if (!std::filesystem::exists(path)) { QMessageBox::critical(nullptr, tr("Run Game"), QString(tr("Eboot.bin file not found"))); return; } - emulator.Run(gamePath.toUtf8().constData()); + emulator.Run(path); } } @@ -948,14 +949,14 @@ void MainWindow::CreateRecentGameActions() { } connect(m_recent_files_group, &QActionGroup::triggered, this, [this](QAction* action) { - QString gamePath = action->text(); - AddRecentFiles(gamePath); // Update the list. + auto gamePath = Common::FS::PathFromQString(action->text()); + AddRecentFiles(action->text()); // Update the list. Core::Emulator emulator; - if (!std::filesystem::exists(gamePath.toUtf8().constData())) { + if (!std::filesystem::exists(gamePath)) { QMessageBox::critical(nullptr, tr("Run Game"), QString(tr("Eboot.bin file not found"))); return; } - emulator.Run(gamePath.toUtf8().constData()); + emulator.Run(gamePath); }); } diff --git a/src/video_core/renderdoc.cpp b/src/video_core/renderdoc.cpp index 7f88e1264..7e0994992 100644 --- a/src/video_core/renderdoc.cpp +++ b/src/video_core/renderdoc.cpp @@ -110,11 +110,11 @@ void TriggerCapture() { } } -void SetOutputDir(const std::string& path, const std::string& prefix) { +void SetOutputDir(const std::filesystem::path& path, const std::string& prefix) { if (!rdoc_api) { return; } - rdoc_api->SetCaptureFilePathTemplate((path + '\\' + prefix).c_str()); + rdoc_api->SetCaptureFilePathTemplate(fmt::UTF((path / prefix).u8string()).data.data()); } } // namespace VideoCore diff --git a/src/video_core/renderdoc.h b/src/video_core/renderdoc.h index febf6fbc1..91e242d04 100644 --- a/src/video_core/renderdoc.h +++ b/src/video_core/renderdoc.h @@ -20,6 +20,6 @@ void EndCapture(); void TriggerCapture(); /// Sets output directory for captures -void SetOutputDir(const std::string& path, const std::string& prefix); +void SetOutputDir(const std::filesystem::path& path, const std::string& prefix); } // namespace VideoCore