Skip to content
Permalink
Browse files

Merge pull request #7879 from spycrab/open_gc_save_folder

Qt/GameList: Implement 'Open gamecube save folder'
  • Loading branch information...
Tilka committed Mar 15, 2019
2 parents 011ecd9 + 90522a7 commit c57e5701cd01a9147cac77fa110a442d68f1ef73
Showing with 68 additions and 3 deletions.
  1. +66 −2 Source/Core/DolphinQt/GameList/GameList.cpp
  2. +2 −1 Source/Core/DolphinQt/GameList/GameList.h
@@ -28,6 +28,7 @@

#include "Common/FileUtil.h"

#include "Core/Config/MainSettings.h"
#include "Core/ConfigManager.h"
#include "Core/Core.h"
#include "Core/HW/DVD/DVDInterface.h"
@@ -355,11 +356,17 @@ void GameList::ShowContextMenu(const QPoint&)

if (platform == DiscIO::Platform::WiiWAD || platform == DiscIO::Platform::WiiDisc)
{
menu->addAction(tr("Open Wii &save folder"), this, &GameList::OpenSaveFolder);
menu->addAction(tr("Open Wii &save folder"), this, &GameList::OpenWiiSaveFolder);
menu->addAction(tr("Export Wii save (Experimental)"), this, &GameList::ExportWiiSave);
menu->addSeparator();
}

if (platform == DiscIO::Platform::GameCubeDisc)
{
menu->addAction(tr("Open GameCube &save folder"), this, &GameList::OpenGCSaveFolder);
menu->addSeparator();
}

menu->addAction(tr("Open &containing folder"), this, &GameList::OpenContainingFolder);
menu->addAction(tr("Delete File..."), this, &GameList::DeleteFile);

@@ -665,7 +672,7 @@ void GameList::OpenContainingFolder()
QDesktopServices::openUrl(url);
}

void GameList::OpenSaveFolder()
void GameList::OpenWiiSaveFolder()
{
const auto game = GetSelectedGame();
if (!game)
@@ -675,6 +682,63 @@ void GameList::OpenSaveFolder()
QDesktopServices::openUrl(url);
}

void GameList::OpenGCSaveFolder()
{
const auto game = GetSelectedGame();
if (!game)
return;

bool found = false;

for (int i = 0; i < 2; i++)
{
QUrl url;
switch (SConfig::GetInstance().m_EXIDevice[i])
{
case ExpansionInterface::EXIDEVICE_MEMORYCARDFOLDER:
{
std::string path = StringFromFormat("%s/%s/%s", File::GetUserPath(D_GCUSER_IDX).c_str(),
SConfig::GetDirectoryForRegion(game->GetRegion()),
i == 0 ? "Card A" : "Card B");

std::string override_path = i == 0 ? Config::Get(Config::MAIN_GCI_FOLDER_A_PATH_OVERRIDE) :
Config::Get(Config::MAIN_GCI_FOLDER_B_PATH_OVERRIDE);

if (!override_path.empty())
path = override_path;

QDir dir(QString::fromStdString(path));

if (!dir.entryList({QStringLiteral("%1-%2-*.gci")
.arg(QString::fromStdString(game->GetMakerID()))
.arg(QString::fromStdString(game->GetGameID().substr(0, 4)))})
.empty())
{
url = QUrl::fromLocalFile(dir.absolutePath());
}
break;
}
case ExpansionInterface::EXIDEVICE_MEMORYCARD:
std::string memcard_path = i == 0 ? Config::Get(Config::MAIN_MEMCARD_A_PATH) :
Config::Get(Config::MAIN_MEMCARD_B_PATH);

std::string memcard_dir;

SplitPath(memcard_path, &memcard_dir, nullptr, nullptr);
url = QUrl::fromLocalFile(QString::fromStdString(memcard_dir));
break;
}

found |= !url.isEmpty();

if (!url.isEmpty())
QDesktopServices::openUrl(url);
}

if (!found)
ModalMessageBox::information(this, tr("Information"), tr("No save data found."));
}

void GameList::DeleteFile()
{
ModalMessageBox confirm_dialog(this);
@@ -56,7 +56,8 @@ class GameList final : public QStackedWidget
void ShowContextMenu(const QPoint&);
void OpenContainingFolder();
void OpenProperties();
void OpenSaveFolder();
void OpenWiiSaveFolder();
void OpenGCSaveFolder();
void OpenWiki();
void SetDefaultISO();
void DeleteFile();

0 comments on commit c57e570

Please sign in to comment.
You can’t perform that action at this time.