Skip to content
Permalink
Browse files
Merge pull request #6281 from JosJuice/unify-gamelist-code
Unify ISOFile (wx) with GameFile (Qt) and put it in UICommon
  • Loading branch information
leoetlino committed Mar 9, 2018
2 parents ef975b8 + 1f1dae3 commit 63838c0
Show file tree
Hide file tree
Showing 67 changed files with 1,373 additions and 1,736 deletions.
@@ -160,6 +160,28 @@ bool InstallWAD(const std::string& wad_path)
return InstallWAD(ios, DiscIO::WiiWAD{wad_path}, InstallType::Permanent);
}

bool UninstallTitle(u64 title_id)
{
IOS::HLE::Kernel ios;
return ios.GetES()->DeleteTitleContent(title_id) == IOS::HLE::IPC_SUCCESS;
}

bool IsTitleInstalled(u64 title_id)
{
const std::string content_dir =
Common::GetTitleContentPath(title_id, Common::FromWhichRoot::FROM_CONFIGURED_ROOT);

if (!File::IsDirectory(content_dir))
return false;

// Since this isn't IOS and we only need a simple way to figure out if a title is installed,
// we make the (reasonable) assumption that having more than just the TMD in the content
// directory means that the title is installed.
const auto entries = File::ScanDirectoryTree(content_dir, false);
return std::any_of(entries.children.begin(), entries.children.end(),
[](const auto& file) { return file.virtualName != "title.tmd"; });
}

// Common functionality for system updaters.
class SystemUpdater
{
@@ -38,6 +38,10 @@ bool InstallWAD(IOS::HLE::Kernel& ios, const DiscIO::WiiWAD& wad, InstallType ty
// and does a permanent install.
bool InstallWAD(const std::string& wad_path);

bool UninstallTitle(u64 title_id);

bool IsTitleInstalled(u64 title_id);

enum class UpdateResult
{
Succeeded,
@@ -25,7 +25,7 @@

namespace DiscIO
{
// Increment CACHE_REVISION (GameListCtrl.cpp) if the enum below is modified
// Increment CACHE_REVISION (GameFileCache.cpp) if the enum below is modified
enum class BlobType
{
PLAIN,
@@ -5,12 +5,112 @@
#include <map>
#include <string>

#include "Common/Assert.h"
#include "Common/Common.h"
#include "Common/CommonTypes.h"
#include "Common/Logging/Log.h"
#include "Common/MsgHandler.h"
#include "DiscIO/Enums.h"

namespace DiscIO
{
std::string GetName(Country country, bool translate)
{
std::string name;

switch (country)
{
case Country::COUNTRY_EUROPE:
name = _trans("Europe");
break;
case Country::COUNTRY_JAPAN:
name = _trans("Japan");
break;
case Country::COUNTRY_USA:
name = _trans("USA");
break;
case Country::COUNTRY_AUSTRALIA:
name = _trans("Australia");
break;
case Country::COUNTRY_FRANCE:
name = _trans("France");
break;
case Country::COUNTRY_GERMANY:
name = _trans("Germany");
break;
case Country::COUNTRY_ITALY:
name = _trans("Italy");
break;
case Country::COUNTRY_KOREA:
name = _trans("Korea");
break;
case Country::COUNTRY_NETHERLANDS:
name = _trans("Netherlands");
break;
case Country::COUNTRY_RUSSIA:
name = _trans("Russia");
break;
case Country::COUNTRY_SPAIN:
name = _trans("Spain");
break;
case Country::COUNTRY_TAIWAN:
name = _trans("Taiwan");
break;
case Country::COUNTRY_WORLD:
name = _trans("World");
break;
default:
name = _trans("Unknown");
break;
}

return translate ? GetStringT(name.c_str()) : name;
}

std::string GetName(Language language, bool translate)
{
std::string name;

switch (language)
{
case Language::LANGUAGE_JAPANESE:
name = _trans("Japanese");
break;
case Language::LANGUAGE_ENGLISH:
name = _trans("English");
break;
case Language::LANGUAGE_GERMAN:
name = _trans("German");
break;
case Language::LANGUAGE_FRENCH:
name = _trans("French");
break;
case Language::LANGUAGE_SPANISH:
name = _trans("Spanish");
break;
case Language::LANGUAGE_ITALIAN:
name = _trans("Italian");
break;
case Language::LANGUAGE_DUTCH:
name = _trans("Dutch");
break;
case Language::LANGUAGE_SIMPLIFIED_CHINESE:
name = _trans("Simplified Chinese");
break;
case Language::LANGUAGE_TRADITIONAL_CHINESE:
name = _trans("Traditional Chinese");
break;
case Language::LANGUAGE_KOREAN:
name = _trans("Korean");
break;
default:
name = _trans("Unknown");
break;
}

return translate ? GetStringT(name.c_str()) : name;
}

bool IsDisc(Platform volume_type)
{
return volume_type == Platform::GAMECUBE_DISC || volume_type == Platform::WII_DISC;
@@ -26,7 +126,7 @@ bool IsNTSC(Region region)
return region == Region::NTSC_J || region == Region::NTSC_U || region == Region::NTSC_K;
}

// Increment CACHE_REVISION (GameListCtrl.cpp) if the code below is modified
// Increment CACHE_REVISION (GameFileCache.cpp) if the code below is modified

Country TypicalCountryForRegion(Region region)
{
@@ -230,7 +330,7 @@ std::string GetSysMenuVersionString(u16 title_version)
}
}

std::string GetCompanyFromID(const std::string& company_id)
const std::string& GetCompanyFromID(const std::string& company_id)
{
static const std::map<std::string, std::string> companies = {
{"01", "Nintendo"},
@@ -517,10 +617,11 @@ std::string GetCompanyFromID(const std::string& company_id)
{"ZW", "Judo Baby"},
{"ZX", "TopWare Interactive"}};

static const std::string EMPTY_STRING;
auto iterator = companies.find(company_id);
if (iterator != companies.end())
return iterator->second;
else
return "";
return EMPTY_STRING;
}
}
@@ -10,7 +10,7 @@

namespace DiscIO
{
// Increment CACHE_REVISION (GameListCtrl.cpp) if these enums are modified
// Increment CACHE_REVISION (GameFileCache.cpp) if these enums are modified

enum class Platform
{
@@ -68,6 +68,9 @@ enum class Language
LANGUAGE_UNKNOWN
};

std::string GetName(Country country, bool translate);
std::string GetName(Language language, bool translate);

bool IsDisc(Platform volume_type);
bool IsWii(Platform volume_type);
bool IsNTSC(Region region);
@@ -82,5 +85,5 @@ Country CountrySwitch(u8 country_code);
Region GetSysMenuRegion(u16 title_version);
std::string GetSysMenuVersionString(u16 title_version);

std::string GetCompanyFromID(const std::string& company_id);
const std::string& GetCompanyFromID(const std::string& company_id);
}
@@ -82,8 +82,6 @@ set(SRCS
Debugger/RegisterColumn.cpp
Debugger/RegisterWidget.cpp
Debugger/WatchWidget.cpp
GameList/GameFileCache.cpp
GameList/GameFile.cpp
GameList/GameList.cpp
GameList/GameListModel.cpp
GameList/GameTracker.cpp
@@ -98,6 +96,7 @@ set(SRCS
NetPlay/PadMappingDialog.cpp
QtUtils/DoubleClickEventFilter.cpp
QtUtils/ElidedButton.cpp
QtUtils/ImageConverter.cpp
QtUtils/ListTabWidget.cpp
QtUtils/WindowActivationEventFilter.cpp
QtUtils/AspectRatioWidget.cpp
@@ -16,10 +16,10 @@
#include "Core/ConfigManager.h"
#include "DolphinQt2/Config/CheatCodeEditor.h"
#include "DolphinQt2/Config/CheatWarningWidget.h"
#include "DolphinQt2/GameList/GameFile.h"
#include "UICommon/GameFile.h"

ARCodeWidget::ARCodeWidget(const GameFile& game)
: m_game(game), m_game_id(game.GetGameID().toStdString()), m_game_revision(game.GetRevision())
ARCodeWidget::ARCodeWidget(const UICommon::GameFile& game)
: m_game(game), m_game_id(game.GetGameID()), m_game_revision(game.GetRevision())
{
CreateWidgets();
ConnectWidgets();
@@ -12,8 +12,12 @@
#include "Common/CommonTypes.h"
#include "Core/ActionReplay.h"

class CheatWarningWidget;
namespace UICommon
{
class GameFile;
}

class CheatWarningWidget;
class QLabel;
class QListWidget;
class QListWidgetItem;
@@ -23,7 +27,7 @@ class ARCodeWidget : public QWidget
{
Q_OBJECT
public:
explicit ARCodeWidget(const GameFile& game);
explicit ARCodeWidget(const UICommon::GameFile& game);

signals:
void OpenGeneralSettings();
@@ -41,7 +45,7 @@ class ARCodeWidget : public QWidget
void OnCodeEditPressed();
void OnCodeRemovePressed();

const GameFile& m_game;
const UICommon::GameFile& m_game;
std::string m_game_id;
u16 m_game_revision;

@@ -37,8 +37,8 @@ enum class EntryType
};
Q_DECLARE_METATYPE(EntryType);

FilesystemWidget::FilesystemWidget(const GameFile& game)
: m_game(game), m_volume(DiscIO::CreateVolumeFromFilename(game.GetFilePath().toStdString()))
FilesystemWidget::FilesystemWidget(const UICommon::GameFile& game)
: m_game(game), m_volume(DiscIO::CreateVolumeFromFilename(game.GetFilePath()))
{
CreateWidgets();
ConnectWidgets();
@@ -8,7 +8,7 @@
#include <memory>

#include "DiscIO/Volume.h"
#include "DolphinQt2/GameList/GameFile.h"
#include "UICommon/GameFile.h"

class QStandardItem;
class QStandardItemModel;
@@ -24,7 +24,7 @@ class FilesystemWidget final : public QWidget
{
Q_OBJECT
public:
explicit FilesystemWidget(const GameFile& game);
explicit FilesystemWidget(const UICommon::GameFile& game);

private:
void CreateWidgets();
@@ -46,6 +46,6 @@ class FilesystemWidget final : public QWidget
QStandardItemModel* m_tree_model;
QTreeView* m_tree_view;

GameFile m_game;
UICommon::GameFile m_game;
std::unique_ptr<DiscIO::Volume> m_volume;
};
@@ -23,7 +23,7 @@
#include "Core/ConfigLoaders/GameConfigLoader.h"
#include "Core/ConfigManager.h"
#include "DolphinQt2/Config/Graphics/GraphicsSlider.h"
#include "DolphinQt2/GameList/GameFile.h"
#include "UICommon/GameFile.h"

constexpr int DETERMINISM_NOT_SET_INDEX = 0;
constexpr int DETERMINISM_AUTO_INDEX = 1;
@@ -35,9 +35,9 @@ constexpr const char* DETERMINISM_AUTO_STRING = "auto";
constexpr const char* DETERMINISM_NONE_STRING = "none";
constexpr const char* DETERMINISM_FAKE_COMPLETION_STRING = "fake-completion";

GameConfigWidget::GameConfigWidget(const GameFile& game) : m_game(game)
GameConfigWidget::GameConfigWidget(const UICommon::GameFile& game) : m_game(game)
{
m_game_id = m_game.GetGameID().toStdString();
m_game_id = m_game.GetGameID();
m_gameini_local_path =
QString::fromStdString(File::GetUserPath(D_GAMESETTINGS_IDX) + m_game_id + ".ini");
m_gameini_local = SConfig::LoadLocalGameIni(m_game_id, m_game.GetRevision());
@@ -241,8 +241,8 @@ void GameConfigWidget::SaveCheckBox(QCheckBox* checkbox, const std::string& sect
void GameConfigWidget::LoadSettings()
{
// Load state information
m_state_combo->setCurrentIndex(m_game.GetRating());
m_state_comment_edit->setText(m_game.GetIssues());
m_state_combo->setCurrentIndex(m_game.GetEmuState());
m_state_comment_edit->setText(QString::fromStdString(m_game.GetIssues()));

// Load game-specific settings

@@ -301,10 +301,10 @@ void GameConfigWidget::SaveSettings()
QString comment = m_state_comment_edit->text();
int state = m_state_combo->currentIndex();

if (comment != m_game.GetIssues())
if (comment != QString::fromStdString(m_game.GetIssues()))
m_gameini_local.GetOrCreateSection("EmuState")->Set("EmulationIssues", comment.toStdString());

if (state != m_game.GetRating())
if (state != m_game.GetEmuState())
m_gameini_local.GetOrCreateSection("EmuState")->Set("EmulationStateId", state);

// Save game-specific settings
@@ -11,7 +11,11 @@

#include "Common/IniFile.h"

namespace UICommon
{
class GameFile;
}

class QCheckBox;
class QComboBox;
class QGroupBox;
@@ -25,7 +29,7 @@ class GameConfigWidget : public QWidget
{
Q_OBJECT
public:
explicit GameConfigWidget(const GameFile& game);
explicit GameConfigWidget(const UICommon::GameFile& game);

private:
void CreateWidgets();
@@ -65,6 +69,6 @@ class GameConfigWidget : public QWidget
IniFile m_gameini_local;
IniFile m_gameini_default;

const GameFile& m_game;
const UICommon::GameFile& m_game;
std::string m_game_id;
};

0 comments on commit 63838c0

Please sign in to comment.