2024-01-20 06:17:21 +00:00
|
|
|
// SPDX-FileCopyrightText: 2002-2024 PCSX2 Dev Team
|
2023-12-22 11:57:49 +00:00
|
|
|
// SPDX-License-Identifier: LGPL-3.0+
|
2021-12-13 12:12:54 +00:00
|
|
|
|
|
|
|
#pragma once
|
2023-10-14 08:45:09 +00:00
|
|
|
#include "ui_SettingsWindow.h"
|
2021-12-13 12:12:54 +00:00
|
|
|
#include <QtCore/QMap>
|
|
|
|
#include <QtCore/QString>
|
2023-10-14 08:45:09 +00:00
|
|
|
#include <QtWidgets/QWidget>
|
2021-12-13 12:12:54 +00:00
|
|
|
#include <array>
|
2022-02-15 14:29:18 +00:00
|
|
|
#include <memory>
|
|
|
|
|
2024-01-20 06:17:21 +00:00
|
|
|
class QWheelEvent;
|
|
|
|
|
2022-02-15 14:29:18 +00:00
|
|
|
class INISettingsInterface;
|
2022-05-18 13:27:23 +00:00
|
|
|
class SettingsInterface;
|
2022-02-15 14:29:18 +00:00
|
|
|
|
|
|
|
namespace GameList
|
|
|
|
{
|
2024-01-20 06:17:21 +00:00
|
|
|
struct Entry;
|
2022-02-15 14:29:18 +00:00
|
|
|
}
|
2021-12-13 12:12:54 +00:00
|
|
|
|
|
|
|
class InterfaceSettingsWidget;
|
|
|
|
class GameListSettingsWidget;
|
|
|
|
class EmulationSettingsWidget;
|
|
|
|
class BIOSSettingsWidget;
|
2023-05-25 16:24:01 +00:00
|
|
|
class GameCheatSettingsWidget;
|
2021-12-13 12:12:54 +00:00
|
|
|
class GameFixSettingsWidget;
|
2023-05-25 16:24:01 +00:00
|
|
|
class GamePatchSettingsWidget;
|
2021-12-13 12:12:54 +00:00
|
|
|
class GraphicsSettingsWidget;
|
|
|
|
class AudioSettingsWidget;
|
|
|
|
class MemoryCardSettingsWidget;
|
2022-06-18 10:20:24 +00:00
|
|
|
class FolderSettingsWidget;
|
2022-03-13 17:58:39 +00:00
|
|
|
class DEV9SettingsWidget;
|
2022-04-18 13:35:14 +00:00
|
|
|
class AchievementSettingsWidget;
|
2022-11-23 13:20:49 +00:00
|
|
|
class AdvancedSettingsWidget;
|
2022-12-24 03:58:21 +00:00
|
|
|
class DebugSettingsWidget;
|
2021-12-13 12:12:54 +00:00
|
|
|
|
2023-10-14 08:45:09 +00:00
|
|
|
class SettingsWindow final : public QWidget
|
2021-12-13 12:12:54 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2023-10-14 08:45:09 +00:00
|
|
|
explicit SettingsWindow();
|
|
|
|
SettingsWindow(std::unique_ptr<INISettingsInterface> sif, const GameList::Entry* game, std::string serial,
|
2023-09-04 11:14:39 +00:00
|
|
|
u32 disc_crc, QString filename = QString());
|
2023-10-14 08:45:09 +00:00
|
|
|
~SettingsWindow();
|
2021-12-13 12:12:54 +00:00
|
|
|
|
2024-05-14 23:42:40 +00:00
|
|
|
static void openGamePropertiesDialog(const GameList::Entry* game, const std::string_view title, std::string serial, u32 disc_crc);
|
2023-12-18 03:47:09 +00:00
|
|
|
static void closeGamePropertiesDialogs();
|
2022-02-15 14:29:18 +00:00
|
|
|
|
2023-09-04 11:14:39 +00:00
|
|
|
SettingsInterface* getSettingsInterface() const;
|
2023-07-20 09:12:17 +00:00
|
|
|
__fi bool isPerGameSettings() const { return static_cast<bool>(m_sif); }
|
|
|
|
__fi const std::string& getSerial() const { return m_serial; }
|
|
|
|
__fi u32 getDiscCRC() const { return m_disc_crc; }
|
2022-02-15 14:29:18 +00:00
|
|
|
|
|
|
|
__fi InterfaceSettingsWidget* getInterfaceSettingsWidget() const { return m_interface_settings; }
|
|
|
|
__fi GameListSettingsWidget* getGameListSettingsWidget() const { return m_game_list_settings; }
|
|
|
|
__fi BIOSSettingsWidget* getBIOSSettingsWidget() const { return m_bios_settings; }
|
|
|
|
__fi EmulationSettingsWidget* getEmulationSettingsWidget() const { return m_emulation_settings; }
|
2023-05-25 16:24:01 +00:00
|
|
|
__fi GameCheatSettingsWidget* getGameCheatSettingsWidget() const { return m_game_cheat_settings_widget; }
|
2022-02-15 14:29:18 +00:00
|
|
|
__fi GameFixSettingsWidget* getGameFixSettingsWidget() const { return m_game_fix_settings_widget; }
|
2023-05-25 16:24:01 +00:00
|
|
|
__fi GamePatchSettingsWidget* getGamePatchSettingsWidget() const { return m_game_patch_settings_widget; }
|
2022-02-15 14:29:18 +00:00
|
|
|
__fi GraphicsSettingsWidget* getGraphicsSettingsWidget() const { return m_graphics_settings; }
|
|
|
|
__fi AudioSettingsWidget* getAudioSettingsWidget() const { return m_audio_settings; }
|
|
|
|
__fi MemoryCardSettingsWidget* getMemoryCardSettingsWidget() const { return m_memory_card_settings; }
|
2022-06-18 10:20:24 +00:00
|
|
|
__fi FolderSettingsWidget* getFolderSettingsWidget() const { return m_folder_settings; }
|
2022-03-13 17:58:39 +00:00
|
|
|
__fi DEV9SettingsWidget* getDEV9SettingsWidget() const { return m_dev9_settings; }
|
2022-04-18 13:35:14 +00:00
|
|
|
__fi AchievementSettingsWidget* getAchievementSettingsWidget() const { return m_achievement_settings; }
|
2022-11-23 13:20:49 +00:00
|
|
|
__fi AdvancedSettingsWidget* getAdvancedSettingsWidget() const { return m_advanced_settings; }
|
2021-12-13 12:12:54 +00:00
|
|
|
|
|
|
|
void registerWidgetHelp(QObject* object, QString title, QString recommended_value, QString text);
|
|
|
|
bool eventFilter(QObject* object, QEvent* event) override;
|
|
|
|
|
2023-07-23 18:38:17 +00:00
|
|
|
void setWindowTitle(const QString& title);
|
|
|
|
|
2022-09-07 07:44:10 +00:00
|
|
|
QString getCategory() const;
|
2022-02-15 14:29:18 +00:00
|
|
|
void setCategory(const char* category);
|
|
|
|
|
|
|
|
// Helper functions for reading effective setting values (from game -> global settings).
|
|
|
|
bool getEffectiveBoolValue(const char* section, const char* key, bool default_value) const;
|
|
|
|
int getEffectiveIntValue(const char* section, const char* key, int default_value) const;
|
|
|
|
float getEffectiveFloatValue(const char* section, const char* key, float default_value) const;
|
|
|
|
std::string getEffectiveStringValue(const char* section, const char* key, const char* default_value) const;
|
|
|
|
|
|
|
|
// Helper functions for reading setting values for this layer (game settings or global).
|
|
|
|
std::optional<bool> getBoolValue(const char* section, const char* key, std::optional<bool> default_value) const;
|
|
|
|
std::optional<int> getIntValue(const char* section, const char* key, std::optional<int> default_value) const;
|
|
|
|
std::optional<float> getFloatValue(const char* section, const char* key, std::optional<float> default_value) const;
|
|
|
|
std::optional<std::string> getStringValue(const char* section, const char* key, std::optional<const char*> default_value) const;
|
|
|
|
void setBoolSettingValue(const char* section, const char* key, std::optional<bool> value);
|
|
|
|
void setIntSettingValue(const char* section, const char* key, std::optional<int> value);
|
|
|
|
void setFloatSettingValue(const char* section, const char* key, std::optional<float> value);
|
|
|
|
void setStringSettingValue(const char* section, const char* key, std::optional<const char*> value);
|
2023-05-29 10:42:46 +00:00
|
|
|
bool containsSettingValue(const char* section, const char* key) const;
|
2022-12-04 08:03:30 +00:00
|
|
|
void removeSettingValue(const char* section, const char* key);
|
2024-05-04 13:33:35 +00:00
|
|
|
void saveAndReloadGameSettings();
|
2022-02-15 14:29:18 +00:00
|
|
|
|
2021-12-13 12:12:54 +00:00
|
|
|
Q_SIGNALS:
|
|
|
|
void settingsResetToDefaults();
|
|
|
|
|
|
|
|
private Q_SLOTS:
|
|
|
|
void onCategoryCurrentRowChanged(int row);
|
|
|
|
void onRestoreDefaultsClicked();
|
2023-09-04 11:14:39 +00:00
|
|
|
void onCopyGlobalSettingsClicked();
|
|
|
|
void onClearSettingsClicked();
|
2021-12-13 12:12:54 +00:00
|
|
|
|
2022-02-15 14:29:18 +00:00
|
|
|
protected:
|
2022-03-04 08:04:05 +00:00
|
|
|
void closeEvent(QCloseEvent*) override;
|
2024-01-21 05:42:03 +00:00
|
|
|
void wheelEvent(QWheelEvent* event) override;
|
2022-02-15 14:29:18 +00:00
|
|
|
|
2021-12-13 12:12:54 +00:00
|
|
|
private:
|
2022-02-15 14:29:18 +00:00
|
|
|
enum : u32
|
|
|
|
{
|
2023-05-25 16:24:01 +00:00
|
|
|
MAX_SETTINGS_WIDGETS = 13
|
2022-02-15 14:29:18 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
void setupUi(const GameList::Entry* game);
|
|
|
|
|
|
|
|
void addWidget(QWidget* widget, QString title, QString icon, QString help_text);
|
2024-01-20 06:17:21 +00:00
|
|
|
bool handleWheelEvent(QWheelEvent* event);
|
2022-02-15 14:29:18 +00:00
|
|
|
|
2023-10-14 08:45:09 +00:00
|
|
|
SettingsWindow* reopen();
|
2023-09-04 11:14:39 +00:00
|
|
|
|
|
|
|
std::unique_ptr<INISettingsInterface> m_sif;
|
2021-12-13 12:12:54 +00:00
|
|
|
|
2023-10-14 08:45:09 +00:00
|
|
|
Ui::SettingsWindow m_ui;
|
2021-12-13 12:12:54 +00:00
|
|
|
|
|
|
|
InterfaceSettingsWidget* m_interface_settings = nullptr;
|
|
|
|
GameListSettingsWidget* m_game_list_settings = nullptr;
|
|
|
|
BIOSSettingsWidget* m_bios_settings = nullptr;
|
|
|
|
EmulationSettingsWidget* m_emulation_settings = nullptr;
|
2023-05-25 16:24:01 +00:00
|
|
|
GameCheatSettingsWidget* m_game_cheat_settings_widget = nullptr;
|
2021-12-13 12:12:54 +00:00
|
|
|
GameFixSettingsWidget* m_game_fix_settings_widget = nullptr;
|
2023-05-25 16:24:01 +00:00
|
|
|
GamePatchSettingsWidget* m_game_patch_settings_widget = nullptr;
|
2021-12-13 12:12:54 +00:00
|
|
|
GraphicsSettingsWidget* m_graphics_settings = nullptr;
|
|
|
|
AudioSettingsWidget* m_audio_settings = nullptr;
|
|
|
|
MemoryCardSettingsWidget* m_memory_card_settings = nullptr;
|
2022-06-18 10:20:24 +00:00
|
|
|
FolderSettingsWidget* m_folder_settings = nullptr;
|
2022-03-13 17:58:39 +00:00
|
|
|
DEV9SettingsWidget* m_dev9_settings = nullptr;
|
2022-04-18 13:35:14 +00:00
|
|
|
AchievementSettingsWidget* m_achievement_settings = nullptr;
|
2022-11-23 13:20:49 +00:00
|
|
|
AdvancedSettingsWidget* m_advanced_settings = nullptr;
|
2022-12-24 03:58:21 +00:00
|
|
|
DebugSettingsWidget* m_debug_settings = nullptr;
|
2021-12-13 12:12:54 +00:00
|
|
|
|
2022-02-15 14:29:18 +00:00
|
|
|
std::array<QString, MAX_SETTINGS_WIDGETS> m_category_help_text;
|
2021-12-13 12:12:54 +00:00
|
|
|
|
|
|
|
QObject* m_current_help_widget = nullptr;
|
|
|
|
QMap<QObject*, QString> m_widget_help_text_map;
|
2022-02-15 14:29:18 +00:00
|
|
|
|
2023-07-23 18:38:17 +00:00
|
|
|
QString m_filename;
|
|
|
|
|
2023-09-04 11:14:39 +00:00
|
|
|
std::string m_game_list_filename;
|
2023-07-20 09:12:17 +00:00
|
|
|
std::string m_serial;
|
|
|
|
u32 m_disc_crc;
|
2021-12-13 12:12:54 +00:00
|
|
|
};
|