| 1 | // Copyright 2016 Dolphin Emulator Project |
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later |
| 3 | |
| 4 | #include "DolphinQt/Config/PropertiesDialog.h" |
| 5 | |
| 6 | #include <memory> |
| 7 | |
| 8 | #include <QDialogButtonBox> |
| 9 | #include <QPushButton> |
| 10 | #include <QVBoxLayout> |
| 11 | |
| 12 | #include "DiscIO/Enums.h" |
| 13 | #include "DiscIO/Volume.h" |
| 14 | |
| 15 | #include "DolphinQt/Config/ARCodeWidget.h" |
| 16 | #include "DolphinQt/Config/FilesystemWidget.h" |
| 17 | #include "DolphinQt/Config/GameConfigWidget.h" |
| 18 | #include "DolphinQt/Config/GeckoCodeWidget.h" |
| 19 | #include "DolphinQt/Config/GraphicsModListWidget.h" |
| 20 | #include "DolphinQt/Config/InfoWidget.h" |
| 21 | #include "DolphinQt/Config/PatchesWidget.h" |
| 22 | #include "DolphinQt/Config/VerifyWidget.h" |
| 23 | #include "DolphinQt/QtUtils/WrapInScrollArea.h" |
| 24 | |
| 25 | #include "UICommon/GameFile.h" |
| 26 | |
| 27 | PropertiesDialog::PropertiesDialog(QWidget* parent, const UICommon::GameFile& game) |
| 28 | : StackedSettingsWindow{parent}, m_filepath(game.GetFilePath()) |
| 29 | { |
| 30 | setWindowTitle(QStringLiteral("%1: %2 - %3") |
| 31 | .arg(QString::fromStdString(game.GetFileName()), |
| 32 | QString::fromStdString(game.GetGameID()), |
| 33 | QString::fromStdString(game.GetLongName()))); |
| 34 | |
| 35 | auto* const info = new InfoWidget(game); |
| 36 | auto* const ar = new ARCodeWidget(game.GetGameID(), game.GetRevision()); |
| 37 | auto* const gecko = |
| 38 | new GeckoCodeWidget(game.GetGameID(), game.GetGameTDBID(), game.GetRevision()); |
| 39 | auto* const patches = new PatchesWidget(game); |
| 40 | auto* const game_config = new GameConfigWidget(game); |
| 41 | auto* const graphics_mod_list = new GraphicsModListWidget(game); |
| 42 | |
| 43 | connect(gecko, &GeckoCodeWidget::OpenGeneralSettings, this, |
| 44 | &PropertiesDialog::OpenGeneralSettings); |
| 45 | |
| 46 | connect(ar, &ARCodeWidget::OpenGeneralSettings, this, &PropertiesDialog::OpenGeneralSettings); |
| 47 | #ifdef USE_RETRO_ACHIEVEMENTS |
| 48 | connect(ar, &ARCodeWidget::OpenAchievementSettings, this, |
| 49 | &PropertiesDialog::OpenAchievementSettings); |
| 50 | connect(gecko, &GeckoCodeWidget::OpenAchievementSettings, this, |
| 51 | &PropertiesDialog::OpenAchievementSettings); |
| 52 | connect(patches, &PatchesWidget::OpenAchievementSettings, this, |
| 53 | &PropertiesDialog::OpenAchievementSettings); |
| 54 | #endif // USE_RETRO_ACHIEVEMENTS |
| 55 | |
| 56 | connect(graphics_mod_list, &GraphicsModListWidget::OpenGraphicsSettings, this, |
| 57 | &PropertiesDialog::OpenGraphicsSettings); |
| 58 | |
| 59 | // Note: Intentional selective use of AddWrappedPane for a sensible dialog "minimumSize". |
| 60 | AddWrappedPane(info, tr("Info")); |
| 61 | AddPane(game_config, tr("Game Config")); |
| 62 | AddPane(patches, tr("Patches")); |
| 63 | AddPane(ar, tr("AR Codes")); |
| 64 | AddPane(gecko, tr("Gecko Codes")); |
| 65 | AddWrappedPane(graphics_mod_list, tr("Graphics Mods")); |
| 66 | |
| 67 | if (game.GetPlatform() != DiscIO::Platform::ELFOrDOL) |
| 68 | { |
| 69 | std::shared_ptr<DiscIO::Volume> volume = DiscIO::CreateVolume(game.GetFilePath()); |
| 70 | if (volume) |
| 71 | { |
| 72 | auto* const verify = new VerifyWidget(volume); |
| 73 | AddPane(verify, tr("Verify")); |
| 74 | |
| 75 | if (DiscIO::IsDisc(game.GetPlatform())) |
| 76 | { |
| 77 | auto* const filesystem = new FilesystemWidget(volume); |
| 78 | AddPane(filesystem, tr("Filesystem")); |
| 79 | } |
| 80 | } |
| 81 | } |
| 82 | |
| 83 | connect(this, &QDialog::rejected, graphics_mod_list, &GraphicsModListWidget::SaveToDisk); |
| 84 | |
| 85 | OnDoneCreatingPanes(); |
| 86 | } |