mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 14:19:46 -06:00
GCVolume: supports reading all opening.bnr information
DQT2: Game properties dialog contains info tab giving information about the selected iso.
This commit is contained in:
@ -13,7 +13,10 @@ set(SRCS
|
||||
Resources.cpp
|
||||
Settings.cpp
|
||||
ToolBar.cpp
|
||||
Config/FilesystemWidget.cpp
|
||||
Config/InfoWidget.cpp
|
||||
Config/PathDialog.cpp
|
||||
Config/PropertiesDialog.cpp
|
||||
Config/SettingsWindow.cpp
|
||||
GameList/GameFile.cpp
|
||||
GameList/GameList.cpp
|
||||
|
9
Source/Core/DolphinQt2/Config/FilesystemWidget.cpp
Normal file
9
Source/Core/DolphinQt2/Config/FilesystemWidget.cpp
Normal file
@ -0,0 +1,9 @@
|
||||
// Copyright 2016 Dolphin Emulator Project
|
||||
// Licensed under GPLv2+
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include "DolphinQt2/Config/FilesystemWidget.h"
|
||||
|
||||
FilesystemWidget::FilesystemWidget(const GameFile& game) : m_game(game)
|
||||
{
|
||||
}
|
19
Source/Core/DolphinQt2/Config/FilesystemWidget.h
Normal file
19
Source/Core/DolphinQt2/Config/FilesystemWidget.h
Normal file
@ -0,0 +1,19 @@
|
||||
// Copyright 2016 Dolphin Emulator Project
|
||||
// Licensed under GPLv2+
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
#include "DolphinQt2/GameList/GameFile.h"
|
||||
|
||||
class FilesystemWidget final : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit FilesystemWidget(const GameFile& game);
|
||||
|
||||
private:
|
||||
GameFile m_game;
|
||||
};
|
196
Source/Core/DolphinQt2/Config/InfoWidget.cpp
Normal file
196
Source/Core/DolphinQt2/Config/InfoWidget.cpp
Normal file
@ -0,0 +1,196 @@
|
||||
// Copyright 2016 Dolphin Emulator Project
|
||||
// Licensed under GPLv2+
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include <QComboBox>
|
||||
#include <QCryptographicHash>
|
||||
#include <QFileDialog>
|
||||
#include <QFormLayout>
|
||||
#include <QGroupBox>
|
||||
#include <QLabel>
|
||||
#include <QLineEdit>
|
||||
#include <QProgressDialog>
|
||||
#include <QPushButton>
|
||||
#include <QTextEdit>
|
||||
|
||||
#include "DolphinQt2/Config/InfoWidget.h"
|
||||
|
||||
InfoWidget::InfoWidget(const GameFile& game) : m_game(game)
|
||||
{
|
||||
QVBoxLayout* layout = new QVBoxLayout();
|
||||
layout->addWidget(CreateISODetails());
|
||||
layout->addWidget(CreateBannerDetails());
|
||||
setLayout(layout);
|
||||
}
|
||||
|
||||
QGroupBox* InfoWidget::CreateISODetails()
|
||||
{
|
||||
QGroupBox* group = new QGroupBox(tr("ISO Details"));
|
||||
QFormLayout* layout = new QFormLayout;
|
||||
|
||||
QLineEdit* file_path = CreateValueDisplay(m_game.GetFilePath());
|
||||
QLineEdit* internal_name = CreateValueDisplay(m_game.GetInternalName());
|
||||
QLineEdit* game_id = CreateValueDisplay(m_game.GetUniqueID());
|
||||
QLineEdit* country = CreateValueDisplay(m_game.GetCountry());
|
||||
QLineEdit* maker = CreateValueDisplay(m_game.GetMaker());
|
||||
QLineEdit* maker_id = CreateValueDisplay(QStringLiteral("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()));
|
||||
QWidget* checksum = CreateChecksumComputer();
|
||||
|
||||
layout->addRow(tr("File Path:"), file_path);
|
||||
layout->addRow(tr("Internal Name:"), internal_name);
|
||||
layout->addRow(tr("Game ID:"), game_id);
|
||||
layout->addRow(tr("Country:"), country);
|
||||
layout->addRow(tr("Maker:"), maker);
|
||||
layout->addRow(tr("Maker ID:"), maker_id);
|
||||
layout->addRow(tr("Disc Number:"), disc_number);
|
||||
layout->addRow(tr("Revision:"), revision);
|
||||
layout->addRow(tr("Apploader Date:"), apploader_date);
|
||||
layout->addRow(tr("ISO Size:"), iso_size);
|
||||
layout->addRow(tr("MD5 Checksum:"), checksum);
|
||||
|
||||
group->setLayout(layout);
|
||||
return group;
|
||||
}
|
||||
|
||||
QGroupBox* InfoWidget::CreateBannerDetails()
|
||||
{
|
||||
QGroupBox* group = new QGroupBox(tr("%1 Banner Details").arg(m_game.GetPlatform()));
|
||||
QFormLayout* layout = new QFormLayout;
|
||||
|
||||
m_long_name = CreateValueDisplay();
|
||||
m_short_name = CreateValueDisplay();
|
||||
m_short_maker = CreateValueDisplay();
|
||||
m_long_maker = CreateValueDisplay();
|
||||
m_description = new QTextEdit();
|
||||
m_description->setReadOnly(true);
|
||||
QWidget* banner = CreateBannerGraphic();
|
||||
CreateLanguageSelector();
|
||||
|
||||
layout->addRow(tr("Show Language:"), m_language_selector);
|
||||
if (m_game.GetPlatformID() == DiscIO::IVolume::GAMECUBE_DISC)
|
||||
{
|
||||
layout->addRow(tr("Short Name:"), m_short_name);
|
||||
layout->addRow(tr("Short Maker:"), m_short_maker);
|
||||
layout->addRow(tr("Long Name:"), m_long_name);
|
||||
layout->addRow(tr("Long Maker:"), m_long_maker);
|
||||
layout->addRow(tr("Description:"), m_description);
|
||||
}
|
||||
else if (m_game.GetPlatformID() == DiscIO::IVolume::WII_DISC)
|
||||
{
|
||||
layout->addRow(tr("Name:"), m_long_name);
|
||||
}
|
||||
layout->addRow(tr("Banner:"), banner);
|
||||
|
||||
group->setLayout(layout);
|
||||
return group;
|
||||
}
|
||||
|
||||
QWidget* InfoWidget::CreateBannerGraphic()
|
||||
{
|
||||
QWidget* widget = new QWidget();
|
||||
QHBoxLayout* layout = new QHBoxLayout();
|
||||
|
||||
QLabel* banner = new QLabel();
|
||||
banner->setPixmap(m_game.GetBanner());
|
||||
QPushButton* save = new QPushButton(tr("Save as..."));
|
||||
connect(save, &QPushButton::clicked, this, &InfoWidget::SaveBanner);
|
||||
|
||||
layout->addWidget(banner);
|
||||
layout->addWidget(save);
|
||||
widget->setLayout(layout);
|
||||
return widget;
|
||||
}
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
QLineEdit* InfoWidget::CreateValueDisplay(const QString& value)
|
||||
{
|
||||
QLineEdit* value_display = new QLineEdit(value);
|
||||
value_display->setReadOnly(true);
|
||||
value_display->setCursorPosition(0);
|
||||
return value_display;
|
||||
}
|
||||
|
||||
void InfoWidget::CreateLanguageSelector()
|
||||
{
|
||||
m_language_selector = new QComboBox();
|
||||
QList<DiscIO::IVolume::ELanguage> languages = m_game.GetAvailableLanguages();
|
||||
for (int i = 0; i < languages.count(); i++)
|
||||
{
|
||||
DiscIO::IVolume::ELanguage language = languages.at(i);
|
||||
m_language_selector->addItem(m_game.GetLanguage(language), language);
|
||||
}
|
||||
if (m_language_selector->count() == 1)
|
||||
m_language_selector->setDisabled(true);
|
||||
connect(m_language_selector, SIGNAL(currentIndexChanged(int)), this, SLOT(ChangeLanguage()));
|
||||
ChangeLanguage();
|
||||
}
|
||||
|
||||
void InfoWidget::ChangeLanguage()
|
||||
{
|
||||
DiscIO::IVolume::ELanguage language =
|
||||
static_cast<DiscIO::IVolume::ELanguage>(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));
|
||||
}
|
||||
|
||||
QWidget* InfoWidget::CreateChecksumComputer()
|
||||
{
|
||||
QWidget* widget = new QWidget();
|
||||
QHBoxLayout* layout = new QHBoxLayout();
|
||||
layout->setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
m_checksum_result = new QLineEdit();
|
||||
QPushButton* calculate = new QPushButton(tr("Compute"));
|
||||
connect(calculate, &QPushButton::clicked, this, &InfoWidget::ComputeChecksum);
|
||||
layout->addWidget(m_checksum_result);
|
||||
layout->addWidget(calculate);
|
||||
|
||||
widget->setLayout(layout);
|
||||
return widget;
|
||||
}
|
||||
|
||||
void InfoWidget::ComputeChecksum()
|
||||
{
|
||||
QCryptographicHash hash(QCryptographicHash::Md5);
|
||||
hash.reset();
|
||||
std::unique_ptr<DiscIO::IBlobReader> file(
|
||||
DiscIO::CreateBlobReader(m_game.GetFilePath().toStdString()));
|
||||
std::vector<u8> file_data(8 * 1080 * 1080); // read 1MB at a time
|
||||
u64 game_size = file->GetDataSize();
|
||||
u64 read_offset = 0;
|
||||
|
||||
// a maximum of 1000 is used instead of game_size because otherwise 8GB games overflow the int
|
||||
// typed maximum parameter
|
||||
QProgressDialog* progress =
|
||||
new QProgressDialog(tr("Computing MD5 Checksum"), tr("Cancel"), 0, 1000, this);
|
||||
progress->setWindowTitle(tr("Computing MD5 Checksum"));
|
||||
progress->setMinimumDuration(500);
|
||||
progress->setWindowModality(Qt::WindowModal);
|
||||
while (read_offset < game_size)
|
||||
{
|
||||
progress->setValue(static_cast<double>(read_offset) / static_cast<double>(game_size) * 1000);
|
||||
if (progress->wasCanceled())
|
||||
return;
|
||||
|
||||
u64 read_size = std::min(file_data.size(), game_size - read_offset);
|
||||
file->Read(read_offset, read_size, file_data.data());
|
||||
hash.addData(reinterpret_cast<char*>(file_data.data()), read_size);
|
||||
read_offset += read_size;
|
||||
}
|
||||
m_checksum_result->setText(QString::fromUtf8(hash.result().toHex()));
|
||||
Q_ASSERT(read_offset == game_size);
|
||||
progress->setValue(1000);
|
||||
}
|
44
Source/Core/DolphinQt2/Config/InfoWidget.h
Normal file
44
Source/Core/DolphinQt2/Config/InfoWidget.h
Normal file
@ -0,0 +1,44 @@
|
||||
// Copyright 2016 Dolphin Emulator Project
|
||||
// Licensed under GPLv2+
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
#include "DolphinQt2/GameList/GameFile.h"
|
||||
|
||||
class QComboBox;
|
||||
class QGroupBox;
|
||||
class QTextEdit;
|
||||
class QLineEdit;
|
||||
|
||||
class InfoWidget final : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit InfoWidget(const GameFile& game);
|
||||
|
||||
private slots:
|
||||
void ComputeChecksum();
|
||||
void ChangeLanguage();
|
||||
void SaveBanner();
|
||||
|
||||
private:
|
||||
QGroupBox* CreateBannerDetails();
|
||||
QGroupBox* CreateISODetails();
|
||||
QLineEdit* CreateValueDisplay() { return CreateValueDisplay(QStringLiteral("")); };
|
||||
QLineEdit* CreateValueDisplay(const QString& value);
|
||||
QWidget* CreateChecksumComputer();
|
||||
void CreateLanguageSelector();
|
||||
QWidget* CreateBannerGraphic();
|
||||
|
||||
GameFile m_game;
|
||||
QLineEdit* m_checksum_result;
|
||||
QComboBox* m_language_selector;
|
||||
QLineEdit* m_long_name;
|
||||
QLineEdit* m_short_name;
|
||||
QLineEdit* m_short_maker;
|
||||
QLineEdit* m_long_maker;
|
||||
QTextEdit* m_description;
|
||||
};
|
30
Source/Core/DolphinQt2/Config/PropertiesDialog.cpp
Normal file
30
Source/Core/DolphinQt2/Config/PropertiesDialog.cpp
Normal file
@ -0,0 +1,30 @@
|
||||
// Copyright 2016 Dolphin Emulator Project
|
||||
// Licensed under GPLv2+
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include <QDialogButtonBox>
|
||||
#include <QTabWidget>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
#include "DolphinQt2/Config/FilesystemWidget.h"
|
||||
#include "DolphinQt2/Config/InfoWidget.h"
|
||||
#include "DolphinQt2/Config/PropertiesDialog.h"
|
||||
|
||||
PropertiesDialog::PropertiesDialog(QWidget* parent, const GameFile& game) : QDialog(parent)
|
||||
{
|
||||
setWindowTitle(QStringLiteral("%1: %2").arg(game.GetUniqueID()).arg(game.GetLongName()));
|
||||
QVBoxLayout* layout = new QVBoxLayout();
|
||||
|
||||
QTabWidget* tab_widget = new QTabWidget(this);
|
||||
InfoWidget* info = new InfoWidget(game);
|
||||
FilesystemWidget* filesystem = new FilesystemWidget(game);
|
||||
tab_widget->addTab(info, tr("Info"));
|
||||
tab_widget->addTab(filesystem, tr("Filesystem"));
|
||||
layout->addWidget(tab_widget);
|
||||
|
||||
QDialogButtonBox* ok_box = new QDialogButtonBox(QDialogButtonBox::Ok);
|
||||
connect(ok_box, &QDialogButtonBox::accepted, this, &PropertiesDialog::accept);
|
||||
layout->addWidget(ok_box);
|
||||
|
||||
setLayout(layout);
|
||||
}
|
16
Source/Core/DolphinQt2/Config/PropertiesDialog.h
Normal file
16
Source/Core/DolphinQt2/Config/PropertiesDialog.h
Normal file
@ -0,0 +1,16 @@
|
||||
// Copyright 2016 Dolphin Emulator Project
|
||||
// Licensed under GPLv2+
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
#include "DolphinQt2/GameList/GameFile.h"
|
||||
|
||||
class PropertiesDialog final : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit PropertiesDialog(QWidget* parent, const GameFile& game);
|
||||
};
|
@ -78,7 +78,10 @@
|
||||
<!--NOTE: When adding moc'd files, you must list the outputs in the following ItemGroup!-->
|
||||
<ItemGroup>
|
||||
<QtMoc Include="AboutDialog.h" />
|
||||
<QtMoc Include="Config\FilesystemWidget.h" />
|
||||
<QtMoc Include="Config\InfoWidget.h" />
|
||||
<QtMoc Include="Config\PathDialog.h" />
|
||||
<QtMoc Include="Config\PropertiesDialog.h" />
|
||||
<QtMoc Include="Config\SettingsWindow.h" />
|
||||
<QtMoc Include="GameList\GameFile.h" />
|
||||
<QtMoc Include="GameList\GameList.h" />
|
||||
@ -96,22 +99,28 @@
|
||||
<!--TODO figure out how to get QtMoc to add outputs to ClCompile's inputs...-->
|
||||
<ItemGroup>
|
||||
<ClCompile Include="$(QtMocOutPrefix)AboutDialog.cpp" />
|
||||
<ClCompile Include="$(QtMocOutPrefix)FilesystemWidget.cpp" />
|
||||
<ClCompile Include="$(QtMocOutPrefix)GameFile.cpp" />
|
||||
<ClCompile Include="$(QtMocOutPrefix)GameList.cpp" />
|
||||
<ClCompile Include="$(QtMocOutPrefix)GameListModel.cpp" />
|
||||
<ClCompile Include="$(QtMocOutPrefix)GameTracker.cpp" />
|
||||
<ClCompile Include="$(QtMocOutPrefix)Host.cpp" />
|
||||
<ClCompile Include="$(QtMocOutPrefix)InfoWidget.cpp" />
|
||||
<ClCompile Include="$(QtMocOutPrefix)ListProxyModel.cpp" />
|
||||
<ClCompile Include="$(QtMocOutPrefix)MainWindow.cpp" />
|
||||
<ClCompile Include="$(QtMocOutPrefix)MenuBar.cpp" />
|
||||
<ClCompile Include="$(QtMocOutPrefix)PathDialog.cpp" />
|
||||
<ClCompile Include="$(QtMocOutPrefix)PropertiesDialog.cpp" />
|
||||
<ClCompile Include="$(QtMocOutPrefix)RenderWidget.cpp" />
|
||||
<ClCompile Include="$(QtMocOutPrefix)Settings.cpp" />
|
||||
<ClCompile Include="$(QtMocOutPrefix)SettingsWindow.cpp" />
|
||||
<ClCompile Include="$(QtMocOutPrefix)TableDelegate.cpp" />
|
||||
<ClCompile Include="$(QtMocOutPrefix)ToolBar.cpp" />
|
||||
<ClCompile Include="AboutDialog.cpp" />
|
||||
<ClCompile Include="Config\FilesystemWidget.cpp" />
|
||||
<ClCompile Include="Config\InfoWidget.cpp" />
|
||||
<ClCompile Include="Config\PathDialog.cpp" />
|
||||
<ClCompile Include="Config\PropertiesDialog.cpp" />
|
||||
<ClCompile Include="Config\SettingsWindow.cpp" />
|
||||
<ClCompile Include="GameList\GameFile.cpp" />
|
||||
<ClCompile Include="GameList\GameList.cpp" />
|
||||
|
@ -75,6 +75,18 @@
|
||||
<ClCompile Include="$(QtMocOutPrefix)SettingsWindow.cpp">
|
||||
<Filter>Generated Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Config\PropertiesDialog.cpp" />
|
||||
<ClCompile Include="$(QtMocOutPrefix)InfoWidget.cpp">
|
||||
<Filter>Generated Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="$(QtMocOutPrefix)PropertiesDialog.cpp">
|
||||
<Filter>Generated Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Config\FilesystemWidget.cpp" />
|
||||
<ClCompile Include="Config\InfoWidget.cpp" />
|
||||
<ClCompile Include="$(QtMocOutPrefix)FilesystemWidget.cpp">
|
||||
<Filter>Generated Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<QtMoc Include="MainWindow.h" />
|
||||
@ -104,6 +116,9 @@
|
||||
<QtMoc Include="GameList\TableDelegate.h" />
|
||||
<QtMoc Include="AboutDialog.h" />
|
||||
<QtMoc Include="Config\SettingsWindow.h" />
|
||||
<QtMoc Include="Config\PropertiesDialog.h" />
|
||||
<QtMoc Include="Config\FilesystemWidget.h" />
|
||||
<QtMoc Include="Config\InfoWidget.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<QtUi Include="*.ui" />
|
||||
|
@ -5,8 +5,6 @@
|
||||
#include <QCryptographicHash>
|
||||
#include <QDataStream>
|
||||
#include <QDir>
|
||||
#include <QFile>
|
||||
#include <QFileInfo>
|
||||
#include <QImage>
|
||||
#include <QSharedPointer>
|
||||
|
||||
@ -20,6 +18,11 @@
|
||||
static const int CACHE_VERSION = 13; // Last changed in PR #3261
|
||||
static const int DATASTREAM_VERSION = QDataStream::Qt_5_5;
|
||||
|
||||
QList<DiscIO::IVolume::ELanguage> GameFile::GetAvailableLanguages() const
|
||||
{
|
||||
return m_long_names.keys();
|
||||
}
|
||||
|
||||
static QMap<DiscIO::IVolume::ELanguage, QString>
|
||||
ConvertLanguageMap(const std::map<DiscIO::IVolume::ELanguage, std::string>& map)
|
||||
{
|
||||
@ -137,22 +140,22 @@ bool GameFile::TryLoadVolume()
|
||||
return false;
|
||||
|
||||
m_unique_id = QString::fromStdString(volume->GetUniqueID());
|
||||
m_maker_id = QString::fromStdString(volume->GetMakerID());
|
||||
std::string maker_id = volume->GetMakerID();
|
||||
m_maker = QString::fromStdString(DiscIO::GetCompanyFromID(maker_id));
|
||||
m_maker_id = QString::fromStdString(maker_id);
|
||||
m_revision = volume->GetRevision();
|
||||
m_internal_name = QString::fromStdString(volume->GetInternalName());
|
||||
m_short_names = ConvertLanguageMap(volume->GetNames(false));
|
||||
m_long_names = ConvertLanguageMap(volume->GetNames(true));
|
||||
m_short_names = ConvertLanguageMap(volume->GetShortNames());
|
||||
m_long_names = ConvertLanguageMap(volume->GetLongNames());
|
||||
m_short_makers = ConvertLanguageMap(volume->GetShortMakers());
|
||||
m_long_makers = ConvertLanguageMap(volume->GetLongMakers());
|
||||
m_descriptions = ConvertLanguageMap(volume->GetDescriptions());
|
||||
m_company = QString::fromStdString(volume->GetCompany());
|
||||
m_disc_number = volume->GetDiscNumber();
|
||||
m_platform = volume->GetVolumeType();
|
||||
m_country = volume->GetCountry();
|
||||
m_blob_type = volume->GetBlobType();
|
||||
m_raw_size = volume->GetRawSize();
|
||||
|
||||
if (m_company.isEmpty() && m_unique_id.size() >= 6)
|
||||
m_company =
|
||||
QString::fromStdString(DiscIO::GetCompanyFromID(m_unique_id.mid(4, 2).toStdString()));
|
||||
m_apploader_date = QString::fromStdString(volume->GetApploaderDate());
|
||||
|
||||
ReadBanner(*volume);
|
||||
|
||||
@ -176,12 +179,13 @@ bool GameFile::TryLoadElfDol()
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void GameFile::SaveCache()
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
QString GameFile::GetLanguageString(const QMap<DiscIO::IVolume::ELanguage, QString>& m) const
|
||||
QString GameFile::GetBannerString(const QMap<DiscIO::IVolume::ELanguage, QString>& m) const
|
||||
{
|
||||
// Try the settings language, then English, then just pick one.
|
||||
if (m.isEmpty())
|
||||
@ -200,3 +204,100 @@ QString GameFile::GetLanguageString(const QMap<DiscIO::IVolume::ELanguage, QStri
|
||||
return m[DiscIO::IVolume::LANGUAGE_ENGLISH];
|
||||
return m.first();
|
||||
}
|
||||
|
||||
QString GameFile::GetPlatform() const
|
||||
{
|
||||
switch (m_platform)
|
||||
{
|
||||
case DiscIO::IVolume::GAMECUBE_DISC:
|
||||
return QObject::tr("GameCube");
|
||||
case DiscIO::IVolume::WII_DISC:
|
||||
return QObject::tr("Wii");
|
||||
case DiscIO::IVolume::WII_WAD:
|
||||
return QObject::tr("Wii Channel");
|
||||
case DiscIO::IVolume::ELF_DOL:
|
||||
return QObject::tr("ELF/DOL");
|
||||
default:
|
||||
return QObject::tr("Unknown");
|
||||
}
|
||||
}
|
||||
|
||||
QString GameFile::GetCountry() const
|
||||
{
|
||||
switch (m_country)
|
||||
{
|
||||
case DiscIO::IVolume::COUNTRY_EUROPE:
|
||||
return QObject::tr("Europe");
|
||||
case DiscIO::IVolume::COUNTRY_JAPAN:
|
||||
return QObject::tr("Japan");
|
||||
case DiscIO::IVolume::COUNTRY_USA:
|
||||
return QObject::tr("USA");
|
||||
case DiscIO::IVolume::COUNTRY_AUSTRALIA:
|
||||
return QObject::tr("Australia");
|
||||
case DiscIO::IVolume::COUNTRY_FRANCE:
|
||||
return QObject::tr("France");
|
||||
case DiscIO::IVolume::COUNTRY_GERMANY:
|
||||
return QObject::tr("Germany");
|
||||
case DiscIO::IVolume::COUNTRY_ITALY:
|
||||
return QObject::tr("Italy");
|
||||
case DiscIO::IVolume::COUNTRY_KOREA:
|
||||
return QObject::tr("Korea");
|
||||
case DiscIO::IVolume::COUNTRY_NETHERLANDS:
|
||||
return QObject::tr("Netherlands");
|
||||
case DiscIO::IVolume::COUNTRY_RUSSIA:
|
||||
return QObject::tr("Russia");
|
||||
case DiscIO::IVolume::COUNTRY_SPAIN:
|
||||
return QObject::tr("Spain");
|
||||
case DiscIO::IVolume::COUNTRY_TAIWAN:
|
||||
return QObject::tr("Taiwan");
|
||||
case DiscIO::IVolume::COUNTRY_WORLD:
|
||||
return QObject::tr("World");
|
||||
default:
|
||||
return QObject::tr("Unknown");
|
||||
}
|
||||
}
|
||||
|
||||
QString GameFile::GetLanguage(DiscIO::IVolume::ELanguage lang) const
|
||||
{
|
||||
switch (lang)
|
||||
{
|
||||
case DiscIO::IVolume::LANGUAGE_JAPANESE:
|
||||
return QObject::tr("Japanese");
|
||||
case DiscIO::IVolume::LANGUAGE_ENGLISH:
|
||||
return QObject::tr("English");
|
||||
case DiscIO::IVolume::LANGUAGE_GERMAN:
|
||||
return QObject::tr("German");
|
||||
case DiscIO::IVolume::LANGUAGE_FRENCH:
|
||||
return QObject::tr("French");
|
||||
case DiscIO::IVolume::LANGUAGE_SPANISH:
|
||||
return QObject::tr("Spanish");
|
||||
case DiscIO::IVolume::LANGUAGE_ITALIAN:
|
||||
return QObject::tr("Italian");
|
||||
case DiscIO::IVolume::LANGUAGE_DUTCH:
|
||||
return QObject::tr("Dutch");
|
||||
case DiscIO::IVolume::LANGUAGE_SIMPLIFIED_CHINESE:
|
||||
return QObject::tr("Simplified Chinese");
|
||||
case DiscIO::IVolume::LANGUAGE_TRADITIONAL_CHINESE:
|
||||
return QObject::tr("Traditional Chinese");
|
||||
case DiscIO::IVolume::LANGUAGE_KOREAN:
|
||||
return QObject::tr("Korean");
|
||||
default:
|
||||
return QObject::tr("Unknown");
|
||||
}
|
||||
}
|
||||
|
||||
// Convert an integer size to a friendly string representation.
|
||||
QString FormatSize(qint64 size)
|
||||
{
|
||||
QStringList units{QStringLiteral("KB"), QStringLiteral("MB"), QStringLiteral("GB"),
|
||||
QStringLiteral("TB")};
|
||||
QStringListIterator i(units);
|
||||
QString unit = QStringLiteral("B");
|
||||
double num = (double)size;
|
||||
while (num > 1024.0 && i.hasNext())
|
||||
{
|
||||
unit = i.next();
|
||||
num /= 1024.0;
|
||||
}
|
||||
return QStringLiteral("%1 %2").arg(QString::number(num, 'f', 1)).arg(unit);
|
||||
}
|
||||
|
@ -19,34 +19,43 @@ public:
|
||||
|
||||
bool IsValid() const { return m_valid; }
|
||||
// These will be properly initialized before we try to load the file.
|
||||
QString GetPath() const { return m_path; }
|
||||
QString GetFilePath() const { return m_path; }
|
||||
QString GetFileName() const { return m_file_name; }
|
||||
QString GetExtension() const { return m_extension; }
|
||||
QString GetFolder() const { return m_folder; }
|
||||
QString GetFileExtension() const { return m_extension; }
|
||||
QString GetFileFolder() const { return m_folder; }
|
||||
qint64 GetFileSize() const { return m_size; }
|
||||
// The rest will not.
|
||||
QString GetUniqueID() const { return m_unique_id; }
|
||||
QString GetMakerID() const { return m_maker_id; }
|
||||
QString GetMaker() const { return m_maker; }
|
||||
u16 GetRevision() const { return m_revision; }
|
||||
QString GetInternalName() const { return m_internal_name; }
|
||||
QString GetCompany() const { return m_company; }
|
||||
u8 GetDiscNumber() const { return m_disc_number; }
|
||||
u64 GetRawSize() const { return m_raw_size; }
|
||||
QPixmap GetBanner() const { return m_banner; }
|
||||
QString GetIssues() const { return m_issues; }
|
||||
int GetRating() const { return m_rating; }
|
||||
DiscIO::IVolume::EPlatform GetPlatform() const { return m_platform; }
|
||||
DiscIO::IVolume::ECountry GetCountry() const { return m_country; }
|
||||
QString GetApploaderDate() const { return m_apploader_date; }
|
||||
DiscIO::IVolume::EPlatform GetPlatformID() const { return m_platform; }
|
||||
QString GetPlatform() const;
|
||||
DiscIO::IVolume::ECountry GetCountryID() const { return m_country; }
|
||||
QString GetCountry() const;
|
||||
DiscIO::BlobType GetBlobType() const { return m_blob_type; }
|
||||
QString GetShortName() const { return GetLanguageString(m_short_names); }
|
||||
// Banner details
|
||||
QString GetLanguage(DiscIO::IVolume::ELanguage lang) const;
|
||||
QList<DiscIO::IVolume::ELanguage> GetAvailableLanguages() const;
|
||||
QString GetShortName() const { return GetBannerString(m_short_names); }
|
||||
QString GetShortMaker() const { return GetBannerString(m_short_makers); }
|
||||
QString GetLongName() const { return GetBannerString(m_long_names); }
|
||||
QString GetLongMaker() const { return GetBannerString(m_long_makers); }
|
||||
QString GetDescription() const { return GetBannerString(m_descriptions); }
|
||||
QString GetShortName(DiscIO::IVolume::ELanguage lang) const { return m_short_names[lang]; }
|
||||
QString GetLongName() const { return GetLanguageString(m_long_names); }
|
||||
QString GetShortMaker(DiscIO::IVolume::ELanguage lang) const { return m_short_makers[lang]; }
|
||||
QString GetLongName(DiscIO::IVolume::ELanguage lang) const { return m_long_names[lang]; }
|
||||
QString GetDescription() const { return GetLanguageString(m_descriptions); }
|
||||
QString GetLongMaker(DiscIO::IVolume::ELanguage lang) const { return m_long_makers[lang]; }
|
||||
QString GetDescription(DiscIO::IVolume::ELanguage lang) const { return m_descriptions[lang]; }
|
||||
private:
|
||||
DiscIO::IVolume::ELanguage GetDefaultLanguage() const;
|
||||
QString GetLanguageString(const QMap<DiscIO::IVolume::ELanguage, QString>& m) const;
|
||||
QString GetBannerString(const QMap<DiscIO::IVolume::ELanguage, QString>& m) const;
|
||||
|
||||
QString GetCacheFileName() const;
|
||||
void ReadBanner(const DiscIO::IVolume& volume);
|
||||
@ -67,11 +76,14 @@ private:
|
||||
qint64 m_size = 0;
|
||||
|
||||
QString m_unique_id;
|
||||
QString m_maker;
|
||||
QString m_maker_id;
|
||||
u16 m_revision = 0;
|
||||
QString m_internal_name;
|
||||
QMap<DiscIO::IVolume::ELanguage, QString> m_short_names;
|
||||
QMap<DiscIO::IVolume::ELanguage, QString> m_long_names;
|
||||
QMap<DiscIO::IVolume::ELanguage, QString> m_short_makers;
|
||||
QMap<DiscIO::IVolume::ELanguage, QString> m_long_makers;
|
||||
QMap<DiscIO::IVolume::ELanguage, QString> m_descriptions;
|
||||
QString m_company;
|
||||
u8 m_disc_number = 0;
|
||||
@ -82,4 +94,7 @@ private:
|
||||
QPixmap m_banner;
|
||||
QString m_issues;
|
||||
int m_rating = 0;
|
||||
QString m_apploader_date;
|
||||
};
|
||||
|
||||
QString FormatSize(qint64 size);
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include <QMenu>
|
||||
#include <QUrl>
|
||||
|
||||
#include "DolphinQt2/Config/PropertiesDialog.h"
|
||||
#include "DolphinQt2/GameList/GameList.h"
|
||||
#include "DolphinQt2/GameList/ListProxyModel.h"
|
||||
#include "DolphinQt2/GameList/TableDelegate.h"
|
||||
@ -103,12 +104,26 @@ void GameList::MakeListView()
|
||||
void GameList::ShowContextMenu(const QPoint&)
|
||||
{
|
||||
QMenu* menu = new QMenu(this);
|
||||
menu->addAction(tr("Properties"));
|
||||
menu->addAction(tr("Open Wiki Page"), this, SLOT(OpenWiki()));
|
||||
menu->addAction(tr("Set as Default ISO"), this, SLOT(SetDefaultISO()));
|
||||
DiscIO::IVolume::EPlatform platform = GameFile(GetSelectedGame()).GetPlatformID();
|
||||
if (platform == DiscIO::IVolume::GAMECUBE_DISC || platform == DiscIO::IVolume::WII_DISC)
|
||||
{
|
||||
menu->addAction(tr("Properties"), this, SLOT(OpenProperties()));
|
||||
menu->addAction(tr("Open Wiki Page"), this, SLOT(OpenWiki()));
|
||||
menu->addAction(tr("Set as Default ISO"), this, SLOT(SetDefaultISO()));
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
menu->exec(QCursor::pos());
|
||||
}
|
||||
|
||||
void GameList::OpenProperties()
|
||||
{
|
||||
PropertiesDialog* properties = new PropertiesDialog(this, GameFile(GetSelectedGame()));
|
||||
properties->show();
|
||||
}
|
||||
|
||||
void GameList::OpenWiki()
|
||||
{
|
||||
QString game_id = GameFile(GetSelectedGame()).GetUniqueID();
|
||||
|
@ -29,6 +29,7 @@ public slots:
|
||||
void SetViewColumn(int col, bool view) { m_table->setColumnHidden(col, !view); }
|
||||
private slots:
|
||||
void ShowContextMenu(const QPoint&);
|
||||
void OpenProperties();
|
||||
void OpenWiki();
|
||||
void SetDefaultISO();
|
||||
|
||||
|
@ -34,11 +34,11 @@ QVariant GameListModel::data(const QModelIndex& index, int role) const
|
||||
case COL_DESCRIPTION:
|
||||
return game->GetDescription();
|
||||
case COL_MAKER:
|
||||
return game->GetCompany();
|
||||
return game->GetMaker();
|
||||
case COL_SIZE:
|
||||
return game->GetFileSize();
|
||||
case COL_COUNTRY:
|
||||
return game->GetCountry();
|
||||
return game->GetCountryID();
|
||||
case COL_RATING:
|
||||
return game->GetRating();
|
||||
}
|
||||
@ -85,7 +85,7 @@ int GameListModel::columnCount(const QModelIndex& parent) const
|
||||
|
||||
void GameListModel::UpdateGame(QSharedPointer<GameFile> game)
|
||||
{
|
||||
QString path = game->GetPath();
|
||||
QString path = game->GetFilePath();
|
||||
|
||||
int entry = FindGame(path);
|
||||
if (entry < 0)
|
||||
@ -111,7 +111,7 @@ int GameListModel::FindGame(const QString& path) const
|
||||
{
|
||||
for (int i = 0; i < m_games.size(); i++)
|
||||
{
|
||||
if (m_games[i]->GetPath() == path)
|
||||
if (m_games[i]->GetFilePath() == path)
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
|
@ -25,7 +25,7 @@ public:
|
||||
int columnCount(const QModelIndex& parent) const override;
|
||||
|
||||
// Path of the Game at the specified index.
|
||||
QString GetPath(int index) const { return m_games[index]->GetPath(); }
|
||||
QString GetPath(int index) const { return m_games[index]->GetFilePath(); }
|
||||
enum
|
||||
{
|
||||
COL_PLATFORM = 0,
|
||||
|
@ -4,28 +4,13 @@
|
||||
|
||||
#include <QPainter>
|
||||
|
||||
#include "DolphinQt2/GameList/GameFile.h"
|
||||
#include "DolphinQt2/GameList/GameListModel.h"
|
||||
#include "DolphinQt2/GameList/TableDelegate.h"
|
||||
#include "DolphinQt2/Resources.h"
|
||||
|
||||
static QSize NORMAL_BANNER_SIZE(96, 32);
|
||||
|
||||
// Convert an integer size to a friendly string representation.
|
||||
static QString FormatSize(qint64 size)
|
||||
{
|
||||
QStringList units{QStringLiteral("KB"), QStringLiteral("MB"), QStringLiteral("GB"),
|
||||
QStringLiteral("TB")};
|
||||
QStringListIterator i(units);
|
||||
QString unit = QStringLiteral("B");
|
||||
double num = (double)size;
|
||||
while (num > 1024.0 && i.hasNext())
|
||||
{
|
||||
unit = i.next();
|
||||
num /= 1024.0;
|
||||
}
|
||||
return QStringLiteral("%1 %2").arg(QString::number(num, 'f', 1)).arg(unit);
|
||||
}
|
||||
|
||||
TableDelegate::TableDelegate(QWidget* parent) : QStyledItemDelegate(parent)
|
||||
{
|
||||
}
|
||||
|
Reference in New Issue
Block a user