Merge pull request #252 from qurious-pixel/patch-1

Move "game_data" to RW directory inside user folder for linux
This commit is contained in:
georgemoralis 2024-07-16 23:05:29 +03:00 committed by GitHub
commit 7ad44317f8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 14 additions and 13 deletions

View File

@ -48,7 +48,7 @@ bool TRP::Extract(std::filesystem::path trophyPath) {
return false; return false;
s64 seekPos = sizeof(TrpHeader); s64 seekPos = sizeof(TrpHeader);
std::filesystem::path trpFilesPath(std::filesystem::current_path() / "game_data" / std::filesystem::path trpFilesPath(std::filesystem::current_path() / "user/game_data" /
title / "TrophyFiles" / it.path().stem()); title / "TrophyFiles" / it.path().stem());
std::filesystem::create_directories(trpFilesPath / "Icons"); std::filesystem::create_directories(trpFilesPath / "Icons");
std::filesystem::create_directory(trpFilesPath / "Xml"); std::filesystem::create_directory(trpFilesPath / "Xml");
@ -88,4 +88,4 @@ bool TRP::Extract(std::filesystem::path trophyPath) {
index++; index++;
} }
return true; return true;
} }

View File

@ -114,8 +114,9 @@ void GameGridFrame::SetGridBackgroundImage(int row, int column) {
if (item) { if (item) {
QString pic1Path = QString::fromStdString((*m_games_shared)[itemID].pic_path); QString pic1Path = QString::fromStdString((*m_games_shared)[itemID].pic_path);
QString blurredPic1Path = QString blurredPic1Path =
qApp->applicationDirPath() + QDir::currentPath() +
QString::fromStdString("/game_data/" + (*m_games_shared)[itemID].serial + "/pic1.png"); QString::fromStdString("/user/game_data/" + (*m_games_shared)[itemID].serial +
"/pic1.png");
backgroundImage = QImage(blurredPic1Path); backgroundImage = QImage(blurredPic1Path);
if (backgroundImage.isNull()) { if (backgroundImage.isNull()) {
@ -123,7 +124,7 @@ void GameGridFrame::SetGridBackgroundImage(int row, int column) {
backgroundImage = m_game_list_utils.BlurImage(image, image.rect(), 16); backgroundImage = m_game_list_utils.BlurImage(image, image.rect(), 16);
std::filesystem::path img_path = std::filesystem::path img_path =
std::filesystem::path("game_data/") / (*m_games_shared)[itemID].serial; std::filesystem::path("user/game_data/") / (*m_games_shared)[itemID].serial;
std::filesystem::create_directories(img_path); std::filesystem::create_directories(img_path);
if (!backgroundImage.save(blurredPic1Path, "PNG")) { if (!backgroundImage.save(blurredPic1Path, "PNG")) {
// qDebug() << "Error: Unable to save image."; // qDebug() << "Error: Unable to save image.";
@ -142,4 +143,4 @@ void GameGridFrame::RefreshGridBackgroundImage() {
palette.setColor(QPalette::Highlight, transparentColor); palette.setColor(QPalette::Highlight, transparentColor);
this->setPalette(palette); this->setPalette(palette);
} }
} }

View File

@ -99,8 +99,8 @@ void GameListFrame::SetListBackgroundImage(QTableWidgetItem* item) {
QString pic1Path = QString::fromStdString(m_game_info->m_games[item->row()].pic_path); QString pic1Path = QString::fromStdString(m_game_info->m_games[item->row()].pic_path);
QString blurredPic1Path = QString blurredPic1Path =
qApp->applicationDirPath() + QDir::currentPath() +
QString::fromStdString("/game_data/" + m_game_info->m_games[item->row()].serial + QString::fromStdString("/user/game_data/" + m_game_info->m_games[item->row()].serial +
"/pic1.png"); "/pic1.png");
backgroundImage = QImage(blurredPic1Path); backgroundImage = QImage(blurredPic1Path);
@ -109,7 +109,7 @@ void GameListFrame::SetListBackgroundImage(QTableWidgetItem* item) {
backgroundImage = m_game_list_utils.BlurImage(image, image.rect(), 16); backgroundImage = m_game_list_utils.BlurImage(image, image.rect(), 16);
std::filesystem::path img_path = std::filesystem::path img_path =
std::filesystem::path("game_data/") / m_game_info->m_games[item->row()].serial; std::filesystem::path("user/game_data/") / m_game_info->m_games[item->row()].serial;
std::filesystem::create_directories(img_path); std::filesystem::create_directories(img_path);
if (!backgroundImage.save(blurredPic1Path, "PNG")) { if (!backgroundImage.save(blurredPic1Path, "PNG")) {
// qDebug() << "Error: Unable to save image."; // qDebug() << "Error: Unable to save image.";
@ -206,4 +206,4 @@ void GameListFrame::SetRegionFlag(int row, int column, QString itemStr) {
widget->setLayout(layout); widget->setLayout(layout);
this->setItem(row, column, item); this->setItem(row, column, item);
this->setCellWidget(row, column, widget); this->setCellWidget(row, column, widget);
} }

View File

@ -20,7 +20,7 @@ int main(int argc, char* argv[]) {
// Load configurations and initialize Qt application // Load configurations and initialize Qt application
const auto config_dir = Common::FS::GetUserPath(Common::FS::PathType::UserDir); const auto config_dir = Common::FS::GetUserPath(Common::FS::PathType::UserDir);
Config::load(config_dir / "config.toml"); Config::load(config_dir / "config.toml");
QString gameDataPath = qApp->applicationDirPath() + "/game_data/"; QString gameDataPath = QDir::currentPath() + "/user/game_data/";
std::string stdStr = gameDataPath.toStdString(); std::string stdStr = gameDataPath.toStdString();
std::filesystem::path path(stdStr); std::filesystem::path path(stdStr);
#ifdef _WIN64 #ifdef _WIN64

View File

@ -19,7 +19,7 @@ TrophyViewer::TrophyViewer(QString trophyPath, QString gameTrpPath) : QMainWindo
} }
void TrophyViewer::PopulateTrophyWidget(QString title) { void TrophyViewer::PopulateTrophyWidget(QString title) {
QString trophyDir = qApp->applicationDirPath() + "/game_data/" + title + "/TrophyFiles"; QString trophyDir = QDir::currentPath() + "/user/game_data/" + title + "/TrophyFiles";
QDir dir(trophyDir); QDir dir(trophyDir);
if (!dir.exists()) { if (!dir.exists()) {
std::filesystem::path path(gameTrpPath_.toStdString()); std::filesystem::path path(gameTrpPath_.toStdString());
@ -142,4 +142,4 @@ void TrophyViewer::SetTableItem(QTableWidget* parent, int row, int column, QStri
widget->setLayout(layout); widget->setLayout(layout);
parent->setItem(row, column, item); parent->setItem(row, column, item);
parent->setCellWidget(row, column, widget); parent->setCellWidget(row, column, widget);
} }