mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-06-13 00:58:29 +02:00
Qt/GameConfigWidget: Complete overhaul
This commit is contained in:
@ -6,16 +6,12 @@
|
||||
|
||||
#include <QCheckBox>
|
||||
#include <QComboBox>
|
||||
#include <QDesktopServices>
|
||||
#include <QFile>
|
||||
#include <QGridLayout>
|
||||
#include <QGroupBox>
|
||||
#include <QHBoxLayout>
|
||||
#include <QLabel>
|
||||
#include <QLineEdit>
|
||||
#include <QPushButton>
|
||||
#include <QSlider>
|
||||
#include <QSpinBox>
|
||||
#include <QUrl>
|
||||
#include <QTabWidget>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
#include "Common/CommonPaths.h"
|
||||
@ -24,6 +20,7 @@
|
||||
#include "Core/ConfigLoaders/GameConfigLoader.h"
|
||||
#include "Core/ConfigManager.h"
|
||||
|
||||
#include "DolphinQt/Config/GameConfigEdit.h"
|
||||
#include "DolphinQt/Config/Graphics/GraphicsSlider.h"
|
||||
|
||||
#include "UICommon/GameFile.h"
|
||||
@ -38,22 +35,51 @@ constexpr const char* DETERMINISM_AUTO_STRING = "auto";
|
||||
constexpr const char* DETERMINISM_NONE_STRING = "none";
|
||||
constexpr const char* DETERMINISM_FAKE_COMPLETION_STRING = "fake-completion";
|
||||
|
||||
static void PopulateTab(QTabWidget* tab, const std::string& path, std::string game_id,
|
||||
bool read_only)
|
||||
{
|
||||
while (!game_id.empty())
|
||||
{
|
||||
const std::string ini_path = path + game_id + ".ini";
|
||||
if (File::Exists(ini_path))
|
||||
{
|
||||
auto* edit =
|
||||
new GameConfigEdit(nullptr, QString::fromStdString(path + game_id + ".ini"), read_only);
|
||||
tab->addTab(edit, QString::fromStdString(game_id));
|
||||
}
|
||||
|
||||
game_id = game_id.substr(0, game_id.size() - 1);
|
||||
}
|
||||
}
|
||||
|
||||
GameConfigWidget::GameConfigWidget(const UICommon::GameFile& game) : m_game(game)
|
||||
{
|
||||
m_game_id = m_game.GetGameID();
|
||||
|
||||
m_gameini_local_path =
|
||||
QString::fromStdString(File::GetUserPath(D_GAMESETTINGS_IDX) + m_game_id + ".ini");
|
||||
|
||||
CreateWidgets();
|
||||
LoadSettings();
|
||||
ConnectWidgets();
|
||||
|
||||
PopulateTab(m_default_tab, File::GetSysDirectory() + "GameSettings/", m_game_id, true);
|
||||
PopulateTab(m_local_tab, File::GetUserPath(D_GAMESETTINGS_IDX), m_game_id, false);
|
||||
|
||||
// Always give the user the opportunity to create a new INI
|
||||
if (m_local_tab->count() == 0)
|
||||
{
|
||||
auto* edit = new GameConfigEdit(
|
||||
nullptr, QString::fromStdString(File::GetUserPath(D_GAMESETTINGS_IDX) + m_game_id + ".ini"),
|
||||
false);
|
||||
m_local_tab->addTab(edit, QString::fromStdString(m_game_id));
|
||||
}
|
||||
}
|
||||
|
||||
void GameConfigWidget::CreateWidgets()
|
||||
{
|
||||
// General
|
||||
m_refresh_config = new QPushButton(tr("Refresh"));
|
||||
m_edit_user_config = new QPushButton(tr("Edit User Config"));
|
||||
m_view_default_config = new QPushButton(tr("View Default Config"));
|
||||
|
||||
// Core
|
||||
auto* core_box = new QGroupBox(tr("Core"));
|
||||
@ -128,23 +154,51 @@ void GameConfigWidget::CreateWidgets()
|
||||
settings_layout->addWidget(core_box);
|
||||
settings_layout->addWidget(stereoscopy_box);
|
||||
|
||||
auto* layout = new QGridLayout;
|
||||
auto* general_layout = new QGridLayout;
|
||||
|
||||
layout->addWidget(settings_box, 0, 0, 1, -1);
|
||||
general_layout->addWidget(settings_box, 0, 0, 1, -1);
|
||||
|
||||
auto* button_layout = new QHBoxLayout;
|
||||
button_layout->setMargin(0);
|
||||
|
||||
layout->addLayout(button_layout, 1, 0, 1, -1);
|
||||
|
||||
button_layout->addWidget(m_refresh_config);
|
||||
button_layout->addWidget(m_edit_user_config);
|
||||
button_layout->addWidget(m_view_default_config);
|
||||
general_layout->addWidget(m_refresh_config, 1, 0, 1, -1);
|
||||
|
||||
for (QCheckBox* item : {m_enable_dual_core, m_enable_mmu, m_enable_fprf, m_sync_gpu,
|
||||
m_enable_fast_disc, m_use_dsp_hle, m_use_monoscopic_shadows})
|
||||
item->setTristate(true);
|
||||
|
||||
auto* general_widget = new QWidget;
|
||||
general_widget->setLayout(general_layout);
|
||||
|
||||
// Advanced
|
||||
auto* advanced_layout = new QVBoxLayout;
|
||||
|
||||
auto* default_group = new QGroupBox(tr("Default Config (Read Only)"));
|
||||
auto* default_layout = new QVBoxLayout;
|
||||
m_default_tab = new QTabWidget;
|
||||
|
||||
default_group->setLayout(default_layout);
|
||||
default_layout->addWidget(m_default_tab);
|
||||
|
||||
auto* local_group = new QGroupBox(tr("User Config"));
|
||||
auto* local_layout = new QVBoxLayout;
|
||||
m_local_tab = new QTabWidget;
|
||||
|
||||
local_group->setLayout(local_layout);
|
||||
local_layout->addWidget(m_local_tab);
|
||||
|
||||
advanced_layout->addWidget(default_group);
|
||||
advanced_layout->addWidget(local_group);
|
||||
|
||||
auto* advanced_widget = new QWidget;
|
||||
|
||||
advanced_widget->setLayout(advanced_layout);
|
||||
|
||||
auto* layout = new QVBoxLayout;
|
||||
auto* tab_widget = new QTabWidget;
|
||||
|
||||
tab_widget->addTab(general_widget, tr("General"));
|
||||
tab_widget->addTab(advanced_widget, tr("Editor"));
|
||||
|
||||
layout->addWidget(tab_widget);
|
||||
|
||||
setLayout(layout);
|
||||
}
|
||||
|
||||
@ -152,8 +206,6 @@ void GameConfigWidget::ConnectWidgets()
|
||||
{
|
||||
// Buttons
|
||||
connect(m_refresh_config, &QPushButton::pressed, this, &GameConfigWidget::LoadSettings);
|
||||
connect(m_edit_user_config, &QPushButton::pressed, this, &GameConfigWidget::EditUserConfig);
|
||||
connect(m_view_default_config, &QPushButton::pressed, this, &GameConfigWidget::ViewDefaultConfig);
|
||||
|
||||
for (QCheckBox* box : {m_enable_dual_core, m_enable_mmu, m_enable_fprf, m_sync_gpu,
|
||||
m_enable_fast_disc, m_use_dsp_hle, m_use_monoscopic_shadows})
|
||||
@ -347,29 +399,3 @@ void GameConfigWidget::SaveSettings()
|
||||
if (success && File::GetSize(m_gameini_local_path.toStdString()) == 0)
|
||||
File::Delete(m_gameini_local_path.toStdString());
|
||||
}
|
||||
|
||||
void GameConfigWidget::EditUserConfig()
|
||||
{
|
||||
QFile file(m_gameini_local_path);
|
||||
|
||||
if (!file.exists())
|
||||
{
|
||||
file.open(QIODevice::WriteOnly);
|
||||
file.close();
|
||||
}
|
||||
|
||||
QDesktopServices::openUrl(QUrl::fromLocalFile(m_gameini_local_path));
|
||||
}
|
||||
|
||||
void GameConfigWidget::ViewDefaultConfig()
|
||||
{
|
||||
for (const std::string& filename :
|
||||
ConfigLoaders::GetGameIniFilenames(m_game_id, m_game.GetRevision()))
|
||||
{
|
||||
QString path =
|
||||
QString::fromStdString(File::GetSysDirectory() + GAMESETTINGS_DIR DIR_SEP + filename);
|
||||
|
||||
if (QFile(path).exists())
|
||||
QDesktopServices::openUrl(QUrl::fromLocalFile(path));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user