2017-05-04 04:19:51 +00:00
|
|
|
// Copyright 2017 Dolphin Emulator Project
|
|
|
|
// Licensed under GPLv2+
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
2018-07-06 22:40:15 +00:00
|
|
|
#include "DolphinQt/Settings/GeneralPane.h"
|
2017-05-04 04:19:51 +00:00
|
|
|
|
2018-05-26 13:06:57 +00:00
|
|
|
#include <map>
|
|
|
|
|
2017-05-04 04:19:51 +00:00
|
|
|
#include <QCheckBox>
|
|
|
|
#include <QComboBox>
|
|
|
|
#include <QFormLayout>
|
|
|
|
#include <QGroupBox>
|
|
|
|
#include <QLabel>
|
|
|
|
#include <QMessageBox>
|
|
|
|
#include <QPushButton>
|
2017-05-05 10:38:59 +00:00
|
|
|
#include <QRadioButton>
|
2017-05-04 04:19:51 +00:00
|
|
|
#include <QSlider>
|
|
|
|
#include <QVBoxLayout>
|
|
|
|
#include <QWidget>
|
|
|
|
|
|
|
|
#include "Core/Analytics.h"
|
2018-07-19 22:10:37 +00:00
|
|
|
#include "Core/Config/MainSettings.h"
|
2018-06-08 20:56:11 +00:00
|
|
|
#include "Core/Config/UISettings.h"
|
2017-05-04 04:19:51 +00:00
|
|
|
#include "Core/ConfigManager.h"
|
2018-04-21 20:09:46 +00:00
|
|
|
#include "Core/Core.h"
|
2017-05-05 10:38:59 +00:00
|
|
|
#include "Core/PowerPC/PowerPC.h"
|
2018-05-28 01:48:04 +00:00
|
|
|
|
2018-07-06 22:40:15 +00:00
|
|
|
#include "DolphinQt/Settings.h"
|
2018-05-28 01:48:04 +00:00
|
|
|
|
2018-03-22 11:20:15 +00:00
|
|
|
#include "UICommon/AutoUpdate.h"
|
2018-06-06 04:16:42 +00:00
|
|
|
#ifdef USE_DISCORD_PRESENCE
|
|
|
|
#include "UICommon/DiscordPresence.h"
|
|
|
|
#endif
|
2018-03-22 11:20:15 +00:00
|
|
|
|
|
|
|
constexpr int AUTO_UPDATE_DISABLE_INDEX = 0;
|
|
|
|
constexpr int AUTO_UPDATE_STABLE_INDEX = 1;
|
|
|
|
constexpr int AUTO_UPDATE_BETA_INDEX = 2;
|
|
|
|
constexpr int AUTO_UPDATE_DEV_INDEX = 3;
|
|
|
|
|
|
|
|
constexpr const char* AUTO_UPDATE_DISABLE_STRING = "";
|
|
|
|
constexpr const char* AUTO_UPDATE_STABLE_STRING = "stable";
|
|
|
|
constexpr const char* AUTO_UPDATE_BETA_STRING = "beta";
|
|
|
|
constexpr const char* AUTO_UPDATE_DEV_STRING = "dev";
|
2017-05-04 04:19:51 +00:00
|
|
|
|
2018-05-26 13:06:57 +00:00
|
|
|
static const std::map<PowerPC::CPUCore, const char*> CPU_CORE_NAMES = {
|
2018-06-15 12:11:18 +00:00
|
|
|
{PowerPC::CPUCore::Interpreter, QT_TR_NOOP("Interpreter (slowest)")},
|
|
|
|
{PowerPC::CPUCore::CachedInterpreter, QT_TR_NOOP("Cached Interpreter (slower)")},
|
|
|
|
{PowerPC::CPUCore::JIT64, QT_TR_NOOP("JIT Recompiler (recommended)")},
|
|
|
|
{PowerPC::CPUCore::JITARM64, QT_TR_NOOP("JIT Arm64 (experimental)")},
|
2018-05-26 13:06:57 +00:00
|
|
|
};
|
|
|
|
|
2017-05-04 04:19:51 +00:00
|
|
|
GeneralPane::GeneralPane(QWidget* parent) : QWidget(parent)
|
|
|
|
{
|
|
|
|
CreateLayout();
|
|
|
|
LoadConfig();
|
2018-03-27 18:27:03 +00:00
|
|
|
|
|
|
|
ConnectLayout();
|
2018-04-21 20:09:46 +00:00
|
|
|
|
|
|
|
connect(&Settings::Instance(), &Settings::EmulationStateChanged, this,
|
|
|
|
&GeneralPane::OnEmulationStateChanged);
|
2017-05-04 04:19:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void GeneralPane::CreateLayout()
|
|
|
|
{
|
|
|
|
m_main_layout = new QVBoxLayout;
|
|
|
|
// Create layout here
|
|
|
|
CreateBasic();
|
2018-03-22 11:20:15 +00:00
|
|
|
|
|
|
|
if (AutoUpdateChecker::SystemSupportsAutoUpdates())
|
|
|
|
CreateAutoUpdate();
|
|
|
|
|
2017-05-04 04:19:51 +00:00
|
|
|
#if defined(USE_ANALYTICS) && USE_ANALYTICS
|
|
|
|
CreateAnalytics();
|
|
|
|
#endif
|
|
|
|
CreateAdvanced();
|
2017-06-21 02:18:34 +00:00
|
|
|
|
2017-05-04 04:19:51 +00:00
|
|
|
m_main_layout->addStretch(1);
|
|
|
|
setLayout(m_main_layout);
|
|
|
|
}
|
|
|
|
|
2018-04-21 20:09:46 +00:00
|
|
|
void GeneralPane::OnEmulationStateChanged(Core::State state)
|
|
|
|
{
|
|
|
|
const bool running = state != Core::State::Uninitialized;
|
|
|
|
|
|
|
|
m_checkbox_dualcore->setEnabled(!running);
|
|
|
|
m_checkbox_cheats->setEnabled(!running);
|
2018-07-17 10:03:41 +00:00
|
|
|
#ifdef USE_DISCORD_PRESENCE
|
2018-07-14 21:38:55 +00:00
|
|
|
m_checkbox_discord_presence->setEnabled(!running);
|
2018-07-17 10:03:41 +00:00
|
|
|
#endif
|
2018-07-14 21:38:55 +00:00
|
|
|
|
2018-05-26 13:06:57 +00:00
|
|
|
for (QRadioButton* radio_button : m_cpu_cores)
|
|
|
|
radio_button->setEnabled(!running);
|
2018-04-21 20:09:46 +00:00
|
|
|
}
|
|
|
|
|
2017-05-04 04:19:51 +00:00
|
|
|
void GeneralPane::ConnectLayout()
|
|
|
|
{
|
2018-03-27 18:27:03 +00:00
|
|
|
connect(m_checkbox_dualcore, &QCheckBox::toggled, this, &GeneralPane::OnSaveConfig);
|
|
|
|
connect(m_checkbox_cheats, &QCheckBox::toggled, this, &GeneralPane::OnSaveConfig);
|
2018-06-01 02:54:15 +00:00
|
|
|
#ifdef USE_DISCORD_PRESENCE
|
|
|
|
connect(m_checkbox_discord_presence, &QCheckBox::toggled, this, &GeneralPane::OnSaveConfig);
|
|
|
|
#endif
|
2018-03-22 11:20:15 +00:00
|
|
|
|
|
|
|
if (AutoUpdateChecker::SystemSupportsAutoUpdates())
|
|
|
|
{
|
|
|
|
connect(m_combobox_update_track,
|
|
|
|
static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
|
|
|
|
&GeneralPane::OnSaveConfig);
|
|
|
|
connect(&Settings::Instance(), &Settings::AutoUpdateTrackChanged, this,
|
|
|
|
&GeneralPane::LoadConfig);
|
|
|
|
}
|
|
|
|
|
2017-05-04 04:19:51 +00:00
|
|
|
// Advanced
|
2017-05-05 10:38:59 +00:00
|
|
|
connect(m_combobox_speedlimit,
|
2018-03-27 18:27:03 +00:00
|
|
|
static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
|
|
|
|
[this]() { OnSaveConfig(); });
|
2018-05-26 13:06:57 +00:00
|
|
|
for (QRadioButton* radio_button : m_cpu_cores)
|
|
|
|
connect(radio_button, &QRadioButton::toggled, this, &GeneralPane::OnSaveConfig);
|
2017-05-04 04:19:51 +00:00
|
|
|
|
|
|
|
#if defined(USE_ANALYTICS) && USE_ANALYTICS
|
2018-03-23 22:25:17 +00:00
|
|
|
connect(&Settings::Instance(), &Settings::AnalyticsToggled, this, &GeneralPane::LoadConfig);
|
2018-03-27 18:27:03 +00:00
|
|
|
connect(m_checkbox_enable_analytics, &QCheckBox::toggled, this, &GeneralPane::OnSaveConfig);
|
|
|
|
connect(m_button_generate_new_identity, &QPushButton::pressed, this,
|
2017-05-04 04:19:51 +00:00
|
|
|
&GeneralPane::GenerateNewIdentity);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void GeneralPane::CreateBasic()
|
|
|
|
{
|
|
|
|
auto* basic_group = new QGroupBox(tr("Basic Settings"));
|
|
|
|
auto* basic_group_layout = new QVBoxLayout;
|
|
|
|
basic_group->setLayout(basic_group_layout);
|
|
|
|
m_main_layout->addWidget(basic_group);
|
|
|
|
|
2017-05-05 10:38:59 +00:00
|
|
|
m_checkbox_dualcore = new QCheckBox(tr("Enable Dual Core (speedup)"));
|
|
|
|
basic_group_layout->addWidget(m_checkbox_dualcore);
|
|
|
|
|
|
|
|
m_checkbox_cheats = new QCheckBox(tr("Enable Cheats"));
|
|
|
|
basic_group_layout->addWidget(m_checkbox_cheats);
|
|
|
|
|
2018-06-01 02:54:15 +00:00
|
|
|
#ifdef USE_DISCORD_PRESENCE
|
2018-06-06 04:16:42 +00:00
|
|
|
m_checkbox_discord_presence = new QCheckBox(tr("Show Current Game on Discord"));
|
2018-06-01 02:54:15 +00:00
|
|
|
basic_group_layout->addWidget(m_checkbox_discord_presence);
|
|
|
|
#endif
|
|
|
|
|
2017-05-05 10:38:59 +00:00
|
|
|
auto* speed_limit_layout = new QFormLayout;
|
2018-06-12 13:45:33 +00:00
|
|
|
speed_limit_layout->setFormAlignment(Qt::AlignLeft | Qt::AlignTop);
|
|
|
|
speed_limit_layout->setFieldGrowthPolicy(QFormLayout::AllNonFixedFieldsGrow);
|
2017-05-05 10:38:59 +00:00
|
|
|
basic_group_layout->addLayout(speed_limit_layout);
|
|
|
|
|
|
|
|
m_combobox_speedlimit = new QComboBox();
|
|
|
|
|
|
|
|
m_combobox_speedlimit->addItem(tr("Unlimited"));
|
|
|
|
for (int i = 10; i <= 200; i += 10) // from 10% to 200%
|
|
|
|
{
|
2017-05-24 11:09:05 +00:00
|
|
|
QString str;
|
|
|
|
if (i != 100)
|
2018-05-30 10:43:59 +00:00
|
|
|
str = QStringLiteral("%1%").arg(i);
|
2017-05-24 11:09:05 +00:00
|
|
|
else
|
2018-05-30 10:43:59 +00:00
|
|
|
str = tr("%1% (Normal Speed)").arg(i);
|
2017-05-05 10:38:59 +00:00
|
|
|
|
2017-05-24 11:09:05 +00:00
|
|
|
m_combobox_speedlimit->addItem(str);
|
2017-05-05 10:38:59 +00:00
|
|
|
}
|
2017-05-04 04:19:51 +00:00
|
|
|
|
2017-05-05 10:38:59 +00:00
|
|
|
speed_limit_layout->addRow(tr("&Speed Limit:"), m_combobox_speedlimit);
|
2017-05-04 04:19:51 +00:00
|
|
|
}
|
|
|
|
|
2018-03-22 11:20:15 +00:00
|
|
|
void GeneralPane::CreateAutoUpdate()
|
|
|
|
{
|
|
|
|
auto* auto_update_group = new QGroupBox(tr("Auto Update Settings"));
|
|
|
|
auto* layout = new QFormLayout;
|
|
|
|
auto_update_group->setLayout(layout);
|
|
|
|
m_main_layout->addWidget(auto_update_group);
|
|
|
|
|
|
|
|
m_combobox_update_track = new QComboBox(this);
|
|
|
|
|
|
|
|
layout->addRow(tr("&Auto Update:"), m_combobox_update_track);
|
|
|
|
|
|
|
|
for (const QString& option : {tr("Don't Update"), tr("Stable (once a year)"),
|
|
|
|
tr("Beta (once a month)"), tr("Dev (multiple times a day)")})
|
|
|
|
m_combobox_update_track->addItem(option);
|
|
|
|
}
|
|
|
|
|
2017-05-04 04:19:51 +00:00
|
|
|
#if defined(USE_ANALYTICS) && USE_ANALYTICS
|
|
|
|
void GeneralPane::CreateAnalytics()
|
|
|
|
{
|
2017-07-23 10:58:32 +00:00
|
|
|
auto* analytics_group = new QGroupBox(tr("Usage Statistics Reporting Settings"));
|
2017-05-04 04:19:51 +00:00
|
|
|
auto* analytics_group_layout = new QVBoxLayout;
|
|
|
|
analytics_group->setLayout(analytics_group_layout);
|
|
|
|
m_main_layout->addWidget(analytics_group);
|
|
|
|
|
|
|
|
m_checkbox_enable_analytics = new QCheckBox(tr("Enable Usage Statistics Reporting"));
|
|
|
|
m_button_generate_new_identity = new QPushButton(tr("Generate a New Statistics Identity"));
|
|
|
|
analytics_group_layout->addWidget(m_checkbox_enable_analytics);
|
|
|
|
analytics_group_layout->addWidget(m_button_generate_new_identity);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
void GeneralPane::CreateAdvanced()
|
|
|
|
{
|
|
|
|
auto* advanced_group = new QGroupBox(tr("Advanced Settings"));
|
|
|
|
auto* advanced_group_layout = new QVBoxLayout;
|
|
|
|
advanced_group->setLayout(advanced_group_layout);
|
|
|
|
m_main_layout->addWidget(advanced_group);
|
|
|
|
|
|
|
|
// Speed Limit
|
2017-05-05 10:38:59 +00:00
|
|
|
auto* engine_group = new QGroupBox(tr("CPU Emulation Engine"));
|
|
|
|
auto* engine_group_layout = new QVBoxLayout;
|
|
|
|
engine_group->setLayout(engine_group_layout);
|
|
|
|
advanced_group_layout->addWidget(engine_group);
|
|
|
|
|
2018-05-26 13:06:57 +00:00
|
|
|
for (PowerPC::CPUCore cpu_core : PowerPC::AvailableCPUCores())
|
|
|
|
{
|
|
|
|
m_cpu_cores.emplace_back(new QRadioButton(tr(CPU_CORE_NAMES.at(cpu_core))));
|
|
|
|
engine_group_layout->addWidget(m_cpu_cores.back());
|
|
|
|
}
|
2017-05-04 04:19:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void GeneralPane::LoadConfig()
|
|
|
|
{
|
2018-03-22 11:20:15 +00:00
|
|
|
if (AutoUpdateChecker::SystemSupportsAutoUpdates())
|
|
|
|
{
|
|
|
|
const auto track = Settings::Instance().GetAutoUpdateTrack().toStdString();
|
|
|
|
|
|
|
|
if (track == AUTO_UPDATE_DISABLE_STRING)
|
|
|
|
m_combobox_update_track->setCurrentIndex(AUTO_UPDATE_DISABLE_INDEX);
|
|
|
|
else if (track == AUTO_UPDATE_STABLE_STRING)
|
|
|
|
m_combobox_update_track->setCurrentIndex(AUTO_UPDATE_STABLE_INDEX);
|
|
|
|
else if (track == AUTO_UPDATE_BETA_STRING)
|
|
|
|
m_combobox_update_track->setCurrentIndex(AUTO_UPDATE_BETA_INDEX);
|
|
|
|
else
|
|
|
|
m_combobox_update_track->setCurrentIndex(AUTO_UPDATE_DEV_INDEX);
|
|
|
|
}
|
|
|
|
|
2017-06-23 23:09:45 +00:00
|
|
|
#if defined(USE_ANALYTICS) && USE_ANALYTICS
|
2018-03-23 22:25:17 +00:00
|
|
|
m_checkbox_enable_analytics->setChecked(Settings::Instance().IsAnalyticsEnabled());
|
2017-06-23 23:09:45 +00:00
|
|
|
#endif
|
2017-05-05 10:38:59 +00:00
|
|
|
m_checkbox_dualcore->setChecked(SConfig::GetInstance().bCPUThread);
|
2017-08-30 19:00:59 +00:00
|
|
|
m_checkbox_cheats->setChecked(Settings::Instance().GetCheatsEnabled());
|
2018-06-01 02:54:15 +00:00
|
|
|
#ifdef USE_DISCORD_PRESENCE
|
2018-06-08 20:56:11 +00:00
|
|
|
m_checkbox_discord_presence->setChecked(Config::Get(Config::MAIN_USE_DISCORD_PRESENCE));
|
2018-06-01 02:54:15 +00:00
|
|
|
#endif
|
2017-06-22 22:11:53 +00:00
|
|
|
int selection = qRound(SConfig::GetInstance().m_EmulationSpeed * 10);
|
2017-05-05 10:38:59 +00:00
|
|
|
if (selection < m_combobox_speedlimit->count())
|
|
|
|
m_combobox_speedlimit->setCurrentIndex(selection);
|
|
|
|
m_checkbox_dualcore->setChecked(SConfig::GetInstance().bCPUThread);
|
|
|
|
|
2018-05-26 13:06:57 +00:00
|
|
|
const std::vector<PowerPC::CPUCore>& available_cpu_cores = PowerPC::AvailableCPUCores();
|
|
|
|
for (size_t i = 0; i < available_cpu_cores.size(); ++i)
|
2017-05-04 04:19:51 +00:00
|
|
|
{
|
2018-06-15 12:11:18 +00:00
|
|
|
if (available_cpu_cores[i] == SConfig::GetInstance().cpu_core)
|
2018-05-26 13:06:57 +00:00
|
|
|
m_cpu_cores[i]->setChecked(true);
|
2017-05-04 04:19:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-22 11:20:15 +00:00
|
|
|
static QString UpdateTrackFromIndex(int index)
|
|
|
|
{
|
|
|
|
QString value;
|
|
|
|
|
|
|
|
switch (index)
|
|
|
|
{
|
|
|
|
case AUTO_UPDATE_DISABLE_INDEX:
|
|
|
|
value = QString::fromStdString(AUTO_UPDATE_DISABLE_STRING);
|
|
|
|
break;
|
|
|
|
case AUTO_UPDATE_STABLE_INDEX:
|
|
|
|
value = QString::fromStdString(AUTO_UPDATE_STABLE_STRING);
|
|
|
|
break;
|
|
|
|
case AUTO_UPDATE_BETA_INDEX:
|
|
|
|
value = QString::fromStdString(AUTO_UPDATE_BETA_STRING);
|
|
|
|
break;
|
|
|
|
case AUTO_UPDATE_DEV_INDEX:
|
|
|
|
value = QString::fromStdString(AUTO_UPDATE_DEV_STRING);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
2017-05-04 04:19:51 +00:00
|
|
|
void GeneralPane::OnSaveConfig()
|
|
|
|
{
|
2018-03-27 18:27:03 +00:00
|
|
|
auto& settings = SConfig::GetInstance();
|
2018-03-22 11:20:15 +00:00
|
|
|
if (AutoUpdateChecker::SystemSupportsAutoUpdates())
|
|
|
|
{
|
|
|
|
Settings::Instance().SetAutoUpdateTrack(
|
|
|
|
UpdateTrackFromIndex(m_combobox_update_track->currentIndex()));
|
|
|
|
}
|
|
|
|
|
2018-06-01 02:54:15 +00:00
|
|
|
#ifdef USE_DISCORD_PRESENCE
|
2018-06-06 04:16:42 +00:00
|
|
|
Discord::SetDiscordPresenceEnabled(m_checkbox_discord_presence->isChecked());
|
2018-06-01 02:54:15 +00:00
|
|
|
#endif
|
|
|
|
|
2017-06-23 23:09:45 +00:00
|
|
|
#if defined(USE_ANALYTICS) && USE_ANALYTICS
|
2018-03-23 22:25:17 +00:00
|
|
|
Settings::Instance().SetAnalyticsEnabled(m_checkbox_enable_analytics->isChecked());
|
2017-06-23 23:09:45 +00:00
|
|
|
#endif
|
2018-03-27 18:27:03 +00:00
|
|
|
settings.bCPUThread = m_checkbox_dualcore->isChecked();
|
2018-07-19 22:10:37 +00:00
|
|
|
Config::SetBaseOrCurrent(Config::MAIN_CPU_THREAD, m_checkbox_dualcore->isChecked());
|
2017-08-30 19:00:59 +00:00
|
|
|
Settings::Instance().SetCheatsEnabled(m_checkbox_cheats->isChecked());
|
2018-07-19 22:10:37 +00:00
|
|
|
Config::SetBaseOrCurrent(Config::MAIN_ENABLE_CHEATS, m_checkbox_cheats->isChecked());
|
2018-03-27 18:27:03 +00:00
|
|
|
settings.m_EmulationSpeed = m_combobox_speedlimit->currentIndex() * 0.1f;
|
2018-05-26 13:06:57 +00:00
|
|
|
|
|
|
|
for (size_t i = 0; i < m_cpu_cores.size(); ++i)
|
|
|
|
{
|
|
|
|
if (m_cpu_cores[i]->isChecked())
|
|
|
|
{
|
2018-06-15 12:11:18 +00:00
|
|
|
settings.cpu_core = PowerPC::AvailableCPUCores()[i];
|
2018-07-19 22:10:37 +00:00
|
|
|
Config::SetBaseOrCurrent(Config::MAIN_CPU_CORE, PowerPC::AvailableCPUCores()[i]);
|
2018-05-26 13:06:57 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-27 18:27:03 +00:00
|
|
|
settings.SaveSettings();
|
2017-05-04 04:19:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#if defined(USE_ANALYTICS) && USE_ANALYTICS
|
|
|
|
void GeneralPane::GenerateNewIdentity()
|
|
|
|
{
|
|
|
|
DolphinAnalytics::Instance()->GenerateNewIdentity();
|
2018-10-02 04:26:43 +00:00
|
|
|
QMessageBox message_box(this);
|
2017-05-04 04:19:51 +00:00
|
|
|
message_box.setIcon(QMessageBox::Information);
|
|
|
|
message_box.setWindowTitle(tr("Identity Generation"));
|
|
|
|
message_box.setText(tr("New identity generated."));
|
|
|
|
message_box.exec();
|
|
|
|
}
|
|
|
|
#endif
|