Unify ISOFile (wx) with GameFile (Qt) and put it in UICommon

The original reason I wanted to do this was so that we can replace
the Android-specific code with this in the future, but of course,
just deduplicating between DolphinWX and DolphinQt2 is nice too.

Fixes:

- DolphinQt2 showing the wrong size for split WBFS disc images.

- DolphinQt2 being case sensitive when checking if a file is a DOL/ELF.

- DolphinQt2 not detecting when a Wii banner has become available
after the game list cache was created.

Removes:

- DolphinWX's ability to load PNGs as custom banners. But it was
already rather broken (see https://bugs.dolphin-emu.org/issues/10365
and https://bugs.dolphin-emu.org/issues/10366). The reason I removed
this was because PNG decoding relied on wx code and we don't have any
good non-wx/Qt code for loading PNG files right now (let's not use
SOIL), but we should be able to use libpng directly to implement PNG
loading in the future.

- DolphinQt2's ability to ignore a cached game if the last modified
time differs. We currently don't have a non-wx/Qt way to get the time.
This commit is contained in:
JosJuice
2017-12-31 20:33:36 +01:00
parent 1add238a28
commit 1f1dae367d
67 changed files with 1373 additions and 1736 deletions

View File

@ -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();

View File

@ -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 @@ private:
void OnCodeEditPressed();
void OnCodeRemovePressed();
const GameFile& m_game;
const UICommon::GameFile& m_game;
std::string m_game_id;
u16 m_game_revision;

View File

@ -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();

View File

@ -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 @@ private:
QStandardItemModel* m_tree_model;
QTreeView* m_tree_view;
GameFile m_game;
UICommon::GameFile m_game;
std::unique_ptr<DiscIO::Volume> m_volume;
};

View File

@ -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

View File

@ -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 @@ private:
IniFile m_gameini_local;
IniFile m_gameini_default;
const GameFile& m_game;
const UICommon::GameFile& m_game;
std::string m_game_id;
};

View File

@ -20,10 +20,10 @@
#include "Core/GeckoCodeConfig.h"
#include "DolphinQt2/Config/CheatCodeEditor.h"
#include "DolphinQt2/Config/CheatWarningWidget.h"
#include "DolphinQt2/GameList/GameFile.h"
#include "UICommon/GameFile.h"
GeckoCodeWidget::GeckoCodeWidget(const GameFile& game)
: m_game(game), m_game_id(game.GetGameID().toStdString()), m_game_revision(game.GetRevision())
GeckoCodeWidget::GeckoCodeWidget(const UICommon::GameFile& game)
: m_game(game), m_game_id(game.GetGameID()), m_game_revision(game.GetRevision())
{
CreateWidgets();
ConnectWidgets();

View File

@ -13,18 +13,22 @@
#include "Core/GeckoCode.h"
class CheatWarningWidget;
class GameFile;
class QLabel;
class QListWidget;
class QListWidgetItem;
class QTextEdit;
class QPushButton;
namespace UICommon
{
class GameFile;
}
class GeckoCodeWidget : public QWidget
{
Q_OBJECT
public:
explicit GeckoCodeWidget(const GameFile& game);
explicit GeckoCodeWidget(const UICommon::GameFile& game);
signals:
void OpenGeneralSettings();
@ -43,7 +47,7 @@ private:
void DownloadCodes();
void SaveCodes();
const GameFile& m_game;
const UICommon::GameFile& m_game;
std::string m_game_id;
u16 m_game_revision;

View File

@ -16,8 +16,10 @@
#include "DiscIO/Blob.h"
#include "DiscIO/Enums.h"
#include "DolphinQt2/Config/InfoWidget.h"
#include "DolphinQt2/QtUtils/ImageConverter.h"
#include "UICommon/UICommon.h"
InfoWidget::InfoWidget(const GameFile& game) : m_game(game)
InfoWidget::InfoWidget(const UICommon::GameFile& game) : m_game(game)
{
QVBoxLayout* layout = new QVBoxLayout();
layout->addWidget(CreateISODetails());
@ -32,17 +34,19 @@ QGroupBox* InfoWidget::CreateISODetails()
QLineEdit* file_path = CreateValueDisplay(m_game.GetFilePath());
QLineEdit* internal_name = CreateValueDisplay(m_game.GetInternalName());
QString game_id_string = m_game.GetGameID();
QString game_id_string = QString::fromStdString(m_game.GetGameID());
if (const u64 title_id = m_game.GetTitleID())
game_id_string += QStringLiteral(" (%1)").arg(title_id, 16, 16, QLatin1Char('0'));
QLineEdit* game_id = CreateValueDisplay(game_id_string);
QLineEdit* country = CreateValueDisplay(m_game.GetCountry());
QLineEdit* country = CreateValueDisplay(DiscIO::GetName(m_game.GetCountry(), true));
QLineEdit* maker = CreateValueDisplay(m_game.GetMaker());
QLineEdit* maker_id = CreateValueDisplay(QStringLiteral("0x") + m_game.GetMakerID());
QLineEdit* maker_id = CreateValueDisplay("0x" + m_game.GetMakerID());
QLineEdit* disc_number = CreateValueDisplay(QString::number(m_game.GetDiscNumber()));
QLineEdit* revision = CreateValueDisplay(QString::number(m_game.GetRevision()));
QLineEdit* apploader_date = CreateValueDisplay(m_game.GetApploaderDate());
QLineEdit* iso_size = CreateValueDisplay(FormatSize(m_game.GetFileSize()));
QLineEdit* iso_size = CreateValueDisplay(UICommon::FormatSize(m_game.GetFileSize()));
QWidget* checksum = CreateChecksumComputer();
layout->addRow(tr("File Path:"), file_path);
@ -75,7 +79,7 @@ QGroupBox* InfoWidget::CreateBannerDetails()
CreateLanguageSelector();
layout->addRow(tr("Show Language:"), m_language_selector);
if (m_game.GetPlatformID() == DiscIO::Platform::GAMECUBE_DISC)
if (m_game.GetPlatform() == DiscIO::Platform::GAMECUBE_DISC)
{
layout->addRow(tr("Short Name:"), m_short_name);
layout->addRow(tr("Short Maker:"), m_short_maker);
@ -83,27 +87,26 @@ QGroupBox* InfoWidget::CreateBannerDetails()
layout->addRow(tr("Long Maker:"), m_long_maker);
layout->addRow(tr("Description:"), m_description);
}
else if (DiscIO::IsWii(m_game.GetPlatformID()))
else if (DiscIO::IsWii(m_game.GetPlatform()))
{
layout->addRow(tr("Name:"), m_long_name);
}
if (!m_game.GetBanner().isNull())
{
layout->addRow(tr("Banner:"), CreateBannerGraphic());
}
QPixmap banner = ToQPixmap(m_game.GetBannerImage());
if (!banner.isNull())
layout->addRow(tr("Banner:"), CreateBannerGraphic(banner));
group->setLayout(layout);
return group;
}
QWidget* InfoWidget::CreateBannerGraphic()
QWidget* InfoWidget::CreateBannerGraphic(const QPixmap& image)
{
QWidget* widget = new QWidget();
QHBoxLayout* layout = new QHBoxLayout();
QLabel* banner = new QLabel();
banner->setPixmap(m_game.GetBanner());
banner->setPixmap(image);
QPushButton* save = new QPushButton(tr("Save as..."));
connect(save, &QPushButton::clicked, this, &InfoWidget::SaveBanner);
@ -117,7 +120,7 @@ void InfoWidget::SaveBanner()
{
QString path = QFileDialog::getSaveFileName(this, tr("Select a File"), QDir::currentPath(),
tr("PNG image file (*.png);; All Files (*)"));
m_game.GetBanner().save(path, "PNG");
ToQPixmap(m_game.GetBannerImage()).save(path, "PNG");
}
QLineEdit* InfoWidget::CreateValueDisplay(const QString& value)
@ -128,14 +131,18 @@ QLineEdit* InfoWidget::CreateValueDisplay(const QString& value)
return value_display;
}
QLineEdit* InfoWidget::CreateValueDisplay(const std::string& value)
{
return CreateValueDisplay(QString::fromStdString(value));
}
void InfoWidget::CreateLanguageSelector()
{
m_language_selector = new QComboBox();
QList<DiscIO::Language> languages = m_game.GetAvailableLanguages();
for (int i = 0; i < languages.count(); i++)
for (DiscIO::Language language : m_game.GetLanguages())
{
DiscIO::Language language = languages.at(i);
m_language_selector->addItem(m_game.GetLanguage(language), static_cast<int>(language));
m_language_selector->addItem(QString::fromStdString(DiscIO::GetName(language, true)),
static_cast<int>(language));
}
if (m_language_selector->count() == 1)
m_language_selector->setDisabled(true);
@ -149,11 +156,11 @@ void InfoWidget::ChangeLanguage()
{
DiscIO::Language language =
static_cast<DiscIO::Language>(m_language_selector->currentData().toInt());
m_short_name->setText(m_game.GetShortName(language));
m_short_maker->setText(m_game.GetShortMaker(language));
m_long_name->setText(m_game.GetLongName(language));
m_long_maker->setText(m_game.GetLongMaker(language));
m_description->setText(m_game.GetDescription(language));
m_short_name->setText(QString::fromStdString(m_game.GetShortName(language)));
m_short_maker->setText(QString::fromStdString(m_game.GetShortMaker(language)));
m_long_name->setText(QString::fromStdString(m_game.GetLongName(language)));
m_long_maker->setText(QString::fromStdString(m_game.GetLongMaker(language)));
m_description->setText(QString::fromStdString(m_game.GetDescription(language)));
}
QWidget* InfoWidget::CreateChecksumComputer()
@ -176,8 +183,7 @@ void InfoWidget::ComputeChecksum()
{
QCryptographicHash hash(QCryptographicHash::Md5);
hash.reset();
std::unique_ptr<DiscIO::BlobReader> file(
DiscIO::CreateBlobReader(m_game.GetFilePath().toStdString()));
std::unique_ptr<DiscIO::BlobReader> file(DiscIO::CreateBlobReader(m_game.GetFilePath()));
std::vector<u8> file_data(8 * 1080 * 1080); // read 1MB at a time
u64 game_size = file->GetDataSize();
u64 read_offset = 0;

View File

@ -4,20 +4,23 @@
#pragma once
#include <string>
#include <QWidget>
#include "DolphinQt2/GameList/GameFile.h"
#include "UICommon/GameFile.h"
class QComboBox;
class QGroupBox;
class QTextEdit;
class QLineEdit;
class QPixmap;
class QTextEdit;
class InfoWidget final : public QWidget
{
Q_OBJECT
public:
explicit InfoWidget(const GameFile& game);
explicit InfoWidget(const UICommon::GameFile& game);
private:
void ComputeChecksum();
@ -26,13 +29,13 @@ private:
QGroupBox* CreateBannerDetails();
QGroupBox* CreateISODetails();
QLineEdit* CreateValueDisplay() { return CreateValueDisplay(QStringLiteral("")); };
QLineEdit* CreateValueDisplay(const QString& value);
QLineEdit* CreateValueDisplay(const std::string& value = "");
QWidget* CreateChecksumComputer();
void CreateLanguageSelector();
QWidget* CreateBannerGraphic();
QWidget* CreateBannerGraphic(const QPixmap& image);
GameFile m_game;
UICommon::GameFile m_game;
QLineEdit* m_checksum_result;
QComboBox* m_language_selector;
QLineEdit* m_long_name;

View File

@ -10,7 +10,6 @@
#include <QWidget>
#include "Core/PatchEngine.h"
#include "DolphinQt2/GameList/GameFile.h"
class QDialogButtonBox;
class QGroupBox;

View File

@ -14,8 +14,8 @@
#include "Core/ConfigManager.h"
#include "DolphinQt2/Config/NewPatchDialog.h"
PatchesWidget::PatchesWidget(const GameFile& game)
: m_game(game), m_game_id(game.GetGameID().toStdString()), m_game_revision(game.GetRevision())
PatchesWidget::PatchesWidget(const UICommon::GameFile& game)
: m_game(game), m_game_id(game.GetGameID()), m_game_revision(game.GetRevision())
{
IniFile game_ini_local;
game_ini_local.Load(File::GetUserPath(D_GAMESETTINGS_IDX) + m_game_id + ".ini");

View File

@ -10,7 +10,7 @@
#include <QWidget>
#include "Core/PatchEngine.h"
#include "DolphinQt2/GameList/GameFile.h"
#include "UICommon/GameFile.h"
class QListWidget;
class QListWidgetItem;
@ -19,7 +19,7 @@ class QPushButton;
class PatchesWidget : public QWidget
{
public:
explicit PatchesWidget(const GameFile& game);
explicit PatchesWidget(const UICommon::GameFile& game);
private:
void CreateWidgets();
@ -39,7 +39,7 @@ private:
QPushButton* m_remove_button;
std::vector<PatchEngine::Patch> m_patches;
const GameFile& m_game;
const UICommon::GameFile& m_game;
std::string m_game_id;
u16 m_game_revision;
};

View File

@ -13,11 +13,15 @@
#include "DolphinQt2/Config/InfoWidget.h"
#include "DolphinQt2/Config/PatchesWidget.h"
#include "DolphinQt2/Config/PropertiesDialog.h"
#include "UICommon/GameFile.h"
PropertiesDialog::PropertiesDialog(QWidget* parent, const GameFile& game) : QDialog(parent)
PropertiesDialog::PropertiesDialog(QWidget* parent, const UICommon::GameFile& game)
: QDialog(parent)
{
setWindowTitle(
QStringLiteral("%1: %2 - %3").arg(game.GetFileName(), game.GetGameID(), game.GetLongName()));
setWindowTitle(QStringLiteral("%1: %2 - %3")
.arg(QString::fromStdString(game.GetFileName()),
QString::fromStdString(game.GetGameID()),
QString::fromStdString(game.GetLongName())));
QVBoxLayout* layout = new QVBoxLayout();
QTabWidget* tab_widget = new QTabWidget(this);
@ -39,7 +43,7 @@ PropertiesDialog::PropertiesDialog(QWidget* parent, const GameFile& game) : QDia
tab_widget->addTab(gecko, tr("Gecko Codes"));
tab_widget->addTab(info, tr("Info"));
if (DiscIO::IsDisc(game.GetPlatformID()))
if (DiscIO::IsDisc(game.GetPlatform()))
{
FilesystemWidget* filesystem = new FilesystemWidget(game);
tab_widget->addTab(filesystem, tr("Filesystem"));

View File

@ -6,13 +6,16 @@
#include <QDialog>
#include "DolphinQt2/GameList/GameFile.h"
namespace UICommon
{
class GameFile;
}
class PropertiesDialog final : public QDialog
{
Q_OBJECT
public:
explicit PropertiesDialog(QWidget* parent, const GameFile& game);
explicit PropertiesDialog(QWidget* parent, const UICommon::GameFile& game);
signals:
void OpenGeneralSettings();