mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-06-24 19:36:17 +00:00
Use fs::path::native whenever possible, avoid unnecessary fs->string conversions in GUI code (#1064)
* Use filesystem::path whenever possible, remove fs::path::string * My hatred for Windows grows with every passing day * More Qt stuff * custom u8string formatter for fmt library * Use u8string for imgui * Fix toml errors hopefully * Fix not printing issue * Oh and on SDL * I hate Windows even more today * fix toml reading utf-8 paths also small fix for fmt::UTF * Formatting * Fix QT path to run games * Fix path logging in save data * Fix trophy path handling * Update game_list_frame.cpp fixed snd0path * Update main_window.cpp fix snd0path * Update main_window.cpp * paths finally fixed * git info in WIP versions title --------- Co-authored-by: Vinicius Rangel <me@viniciusrangel.dev> Co-authored-by: georgemoralis <giorgosmrls@gmail.com>
This commit is contained in:
parent
54e2179337
commit
6295d6c416
30 changed files with 271 additions and 125 deletions
|
@ -4,10 +4,12 @@
|
|||
#include <QDockWidget>
|
||||
#include <QProgressDialog>
|
||||
|
||||
#include <common/scm_rev.h>
|
||||
#include "about_dialog.h"
|
||||
#include "cheats_patches.h"
|
||||
#include "check_update.h"
|
||||
#include "common/io_file.h"
|
||||
#include "common/path_util.h"
|
||||
#include "common/string_util.h"
|
||||
#include "common/version.h"
|
||||
#include "core/file_format/pkg.h"
|
||||
|
@ -43,7 +45,14 @@ bool MainWindow::Init() {
|
|||
GetPhysicalDevices();
|
||||
// show ui
|
||||
setMinimumSize(350, minimumSizeHint().height());
|
||||
setWindowTitle(QString::fromStdString("shadPS4 v" + std::string(Common::VERSION)));
|
||||
std::string window_title = "";
|
||||
if (Common::isRelease) {
|
||||
window_title = fmt::format("shadPS4 v{}", Common::VERSION);
|
||||
} else {
|
||||
window_title = fmt::format("shadPS4 v{} {} {}", Common::VERSION, Common::g_scm_branch,
|
||||
Common::g_scm_desc);
|
||||
}
|
||||
setWindowTitle(QString::fromStdString(window_title));
|
||||
this->show();
|
||||
// load game list
|
||||
LoadGameLists();
|
||||
|
@ -433,12 +442,14 @@ void MainWindow::CreateConnects() {
|
|||
.arg(" APP VERSION", -11)
|
||||
.arg(" Path");
|
||||
for (const GameInfo& game : m_game_info->m_games) {
|
||||
QString game_path;
|
||||
Common::FS::PathToQString(game_path, game.path);
|
||||
out << QString("%1 %2 %3 %4 %5\n")
|
||||
.arg(QString::fromStdString(game.name), -50)
|
||||
.arg(QString::fromStdString(game.serial), -10)
|
||||
.arg(QString::fromStdString(game.fw), -4)
|
||||
.arg(QString::fromStdString(game.version), -11)
|
||||
.arg(QString::fromStdString(game.path));
|
||||
.arg(game_path);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -517,7 +528,8 @@ void MainWindow::PlayBackgroundMusic() {
|
|||
: m_game_grid_frame->crtRow * m_game_grid_frame->columnCnt +
|
||||
m_game_grid_frame->crtColumn;
|
||||
|
||||
const auto snd0path = QString::fromStdString(m_game_info->m_games[itemID].snd0_path);
|
||||
QString snd0path;
|
||||
Common::FS::PathToQString(snd0path, m_game_info->m_games[itemID].snd0_path);
|
||||
BackgroundMusicPlayer::getInstance().playMusic(snd0path);
|
||||
}
|
||||
|
||||
|
@ -529,28 +541,29 @@ void MainWindow::StartGame() {
|
|||
if (table_mode == 0) {
|
||||
if (m_game_list_frame->currentItem()) {
|
||||
int itemID = m_game_list_frame->currentItem()->row();
|
||||
gamePath = QString::fromStdString(m_game_info->m_games[itemID].path + "/eboot.bin");
|
||||
Common::FS::PathToQString(gamePath, m_game_info->m_games[itemID].path / "eboot.bin");
|
||||
}
|
||||
} else if (table_mode == 1) {
|
||||
if (m_game_grid_frame->cellClicked) {
|
||||
int itemID = (m_game_grid_frame->crtRow * m_game_grid_frame->columnCnt) +
|
||||
m_game_grid_frame->crtColumn;
|
||||
gamePath = QString::fromStdString(m_game_info->m_games[itemID].path + "/eboot.bin");
|
||||
Common::FS::PathToQString(gamePath, m_game_info->m_games[itemID].path / "eboot.bin");
|
||||
}
|
||||
} else {
|
||||
if (m_elf_viewer->currentItem()) {
|
||||
int itemID = m_elf_viewer->currentItem()->row();
|
||||
gamePath = QString::fromStdString(m_elf_viewer->m_elf_list[itemID].toStdString());
|
||||
gamePath = m_elf_viewer->m_elf_list[itemID];
|
||||
}
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -666,9 +679,11 @@ void MainWindow::InstallDragDropPkg(std::filesystem::path file, int pkgNum, int
|
|||
pkg = PKG();
|
||||
pkg.Open(file);
|
||||
std::string failreason;
|
||||
auto extract_path = std::filesystem::path(Config::getGameInstallDir()) / pkg.GetTitleID();
|
||||
auto extract_path = Config::getGameInstallDir() / pkg.GetTitleID();
|
||||
QString pkgType = QString::fromStdString(pkg.GetPkgFlags());
|
||||
QDir game_dir(QString::fromStdString(extract_path.string()));
|
||||
QString gameDirPath;
|
||||
Common::FS::PathToQString(gameDirPath, extract_path);
|
||||
QDir game_dir(gameDirPath);
|
||||
if (game_dir.exists()) {
|
||||
QMessageBox msgBox;
|
||||
msgBox.setWindowTitle(tr("PKG Extraction"));
|
||||
|
@ -690,7 +705,9 @@ void MainWindow::InstallDragDropPkg(std::filesystem::path file, int pkgNum, int
|
|||
|
||||
auto addon_extract_path = Common::FS::GetUserPath(Common::FS::PathType::AddonsDir) /
|
||||
pkg.GetTitleID() / entitlement_label;
|
||||
QDir addon_dir(QString::fromStdString(addon_extract_path.string()));
|
||||
QString addonDirPath;
|
||||
Common::FS::PathToQString(addonDirPath, addon_extract_path);
|
||||
QDir addon_dir(addonDirPath);
|
||||
auto category = psf.GetString("CATEGORY");
|
||||
|
||||
if (pkgType.contains("PATCH")) {
|
||||
|
@ -755,8 +772,7 @@ void MainWindow::InstallDragDropPkg(std::filesystem::path file, int pkgNum, int
|
|||
return;
|
||||
}
|
||||
} else {
|
||||
msgBox.setText(QString(tr("DLC already installed:") + "\n" +
|
||||
QString::fromStdString(addon_extract_path.string()) +
|
||||
msgBox.setText(QString(tr("DLC already installed:") + "\n" + addonDirPath +
|
||||
"\n\n" + tr("Would you like to overwrite?")));
|
||||
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
|
||||
msgBox.setDefaultButton(QMessageBox::No);
|
||||
|
@ -768,8 +784,7 @@ void MainWindow::InstallDragDropPkg(std::filesystem::path file, int pkgNum, int
|
|||
}
|
||||
}
|
||||
} else {
|
||||
msgBox.setText(QString(tr("Game already installed") + "\n" +
|
||||
QString::fromStdString(extract_path.string()) + "\n" +
|
||||
msgBox.setText(QString(tr("Game already installed") + "\n" + addonDirPath + "\n" +
|
||||
tr("Would you like to overwrite?")));
|
||||
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
|
||||
msgBox.setDefaultButton(QMessageBox::No);
|
||||
|
@ -812,7 +827,8 @@ void MainWindow::InstallDragDropPkg(std::filesystem::path file, int pkgNum, int
|
|||
QFutureWatcher<void> futureWatcher;
|
||||
connect(&futureWatcher, &QFutureWatcher<void>::finished, this, [=, this]() {
|
||||
if (pkgNum == nPkg) {
|
||||
QString path = QString::fromStdString(Config::getGameInstallDir());
|
||||
QString path;
|
||||
Common::FS::PathToQString(path, Config::getGameInstallDir());
|
||||
QMessageBox extractMsgBox(this);
|
||||
extractMsgBox.setWindowTitle(tr("Extraction Finished"));
|
||||
extractMsgBox.setText(
|
||||
|
@ -984,14 +1000,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);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -1025,4 +1041,4 @@ void MainWindow::OnLanguageChanged(const std::string& locale) {
|
|||
Config::setEmulatorLanguage(locale);
|
||||
|
||||
LoadTranslation();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue