Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
ElBread3 committed Oct 7, 2024
1 parent 91915b2 commit ceb5dba
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/emulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ void Emulator::Run(const std::filesystem::path& file) {
std::string app_version;
u32 fw_version;

std::filesystem::path game_patch_folder = (file.parent_path().string() + "-UPDATE");
std::filesystem::path game_patch_folder = file.parent_path().concat("-UPDATE");
std::filesystem::path sce_sys_folder = std::filesystem::exists(game_patch_folder / "sce_sys")
? game_patch_folder / "sce_sys"
: file.parent_path() / "sce_sys";
Expand Down
24 changes: 14 additions & 10 deletions src/qt_gui/gui_context_menus.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,13 @@ class GuiContextMenus : public QObject {

if (selected == &openSfoViewer) {
PSF psf;
std::string game_folder_path = m_games[itemID].path;
if (std::filesystem::exists(game_folder_path + "-UPDATE")) {
game_folder_path += "-UPDATE";
QString game_update_path;
Common::FS::PathToQString(game_update_path, m_games[itemID].path.concat("-UPDATE"));
std::filesystem::path game_folder_path = m_games[itemID].path;
if (std::filesystem::exists(m_games[itemID].path)) {
game_folder_path = Common::FS::PathFromQString(game_update_path);
}
if (psf.Open(std::filesystem::path(game_folder_path) / "sce_sys" / "param.sfo")) {
if (psf.Open(game_folder_path / "sce_sys" / "param.sfo")) {
int rows = psf.GetEntries().size();
QTableWidget* tableWidget = new QTableWidget(rows, 2);
tableWidget->setAttribute(Qt::WA_DeleteOnClose);
Expand Down Expand Up @@ -288,22 +290,24 @@ class GuiContextMenus : public QObject {

if (selected == deleteGame || selected == deleteUpdate || selected == deleteDLC) {
bool error = false;
QString folder_path = QString::fromStdString(m_games[itemID].path);
QString folder_path, game_update_path;
Common::FS::PathToQString(folder_path, m_games[itemID].path.concat("-UPDATE"));
Common::FS::PathToQString(game_update_path, m_games[itemID].path.concat("-UPDATE"));
QString message_type = tr("Game");
if (selected == deleteUpdate) {
if (!std::filesystem::exists(m_games[itemID].path + "-UPDATE")) {
if (!std::filesystem::exists(m_games[itemID].path.concat("-UPDATE"))) {
QMessageBox::critical(nullptr, tr("Error"),
QString(tr("This game has no update to delete!")));
error = true;
} else {
folder_path = QString::fromStdString(m_games[itemID].path + "-UPDATE");
folder_path = game_update_path;
message_type = tr("Update");
}
} else if (selected == deleteDLC) {
std::filesystem::path game_path = folder_path.toStdString();
std::filesystem::path addon_path =
Config::getAddonInstallDir() / game_path.parent_path().filename();
if (!std::filesystem::exists(addon_path.string())) {
Config::getAddonInstallDir() /
Common::FS::PathFromQString(folder_path).parent_path().filename();
if (!std::filesystem::exists(addon_path)) {
QMessageBox::critical(nullptr, tr("Error"),
QString(tr("This game has no DLC to delete!")));
error = true;
Expand Down
7 changes: 4 additions & 3 deletions src/qt_gui/main_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -665,9 +665,10 @@ void MainWindow::InstallDragDropPkg(std::filesystem::path file, int pkgNum, int
}
auto game_folder_path = Config::getGameInstallDir() / pkg.GetTitleID();
QString pkgType = QString::fromStdString(pkg.GetPkgFlags());
auto game_update_path = pkgType.contains("PATCH")
? Config::getGameInstallDir() / (std::string(pkg.GetTitleID()) + "-UPDATE")
: game_folder_path;
auto game_update_path =
pkgType.contains("Patch")
? Config::getGameInstallDir() / (std::string(pkg.GetTitleID()) + "-UPDATE")
: game_folder_path;
if (!std::filesystem::exists(game_update_path)) {
std::filesystem::create_directory(game_update_path);
}
Expand Down

0 comments on commit ceb5dba

Please sign in to comment.