2015-03-18 22:00:27 +00:00
|
|
|
// Copyright 2015 Dolphin Emulator Project
|
2015-05-17 23:08:10 +00:00
|
|
|
// Licensed under GPLv2+
|
2015-03-18 22:00:27 +00:00
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
2016-11-04 03:43:35 +00:00
|
|
|
#include "DolphinWX/Config/GeneralConfigPane.h"
|
|
|
|
|
2017-04-15 14:23:48 +00:00
|
|
|
#include <map>
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
2016-06-18 01:24:06 +00:00
|
|
|
#include <wx/button.h>
|
2015-03-18 22:00:27 +00:00
|
|
|
#include <wx/checkbox.h>
|
|
|
|
#include <wx/choice.h>
|
|
|
|
#include <wx/event.h>
|
|
|
|
#include <wx/menu.h>
|
2016-06-18 01:24:06 +00:00
|
|
|
#include <wx/msgdlg.h>
|
2015-03-18 22:00:27 +00:00
|
|
|
#include <wx/radiobox.h>
|
|
|
|
#include <wx/sizer.h>
|
|
|
|
#include <wx/stattext.h>
|
|
|
|
|
2017-04-15 14:23:48 +00:00
|
|
|
#include "Common/Common.h"
|
2016-06-18 01:24:06 +00:00
|
|
|
#include "Core/Analytics.h"
|
2015-03-18 22:00:27 +00:00
|
|
|
#include "Core/ConfigManager.h"
|
|
|
|
#include "Core/Core.h"
|
|
|
|
#include "Core/PowerPC/PowerPC.h"
|
2016-11-05 12:29:29 +00:00
|
|
|
#include "DolphinWX/WxEventUtils.h"
|
2015-03-18 22:00:27 +00:00
|
|
|
|
2017-04-15 14:23:48 +00:00
|
|
|
static const std::map<PowerPC::CPUCore, std::string> CPU_CORE_NAMES = {
|
|
|
|
{PowerPC::CORE_INTERPRETER, _trans("Interpreter (slowest)")},
|
|
|
|
{PowerPC::CORE_CACHEDINTERPRETER, _trans("Cached Interpreter (slower)")},
|
|
|
|
{PowerPC::CORE_JIT64, _trans("JIT Recompiler (recommended)")},
|
|
|
|
{PowerPC::CORE_JITARM64, _trans("JIT Arm64 (experimental)")},
|
|
|
|
};
|
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
GeneralConfigPane::GeneralConfigPane(wxWindow* parent, wxWindowID id) : wxPanel(parent, id)
|
2015-03-18 22:00:27 +00:00
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
InitializeGUI();
|
|
|
|
LoadGUIValues();
|
2016-11-05 12:29:29 +00:00
|
|
|
BindEvents();
|
2015-03-18 22:00:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void GeneralConfigPane::InitializeGUI()
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
m_throttler_array_string.Add(_("Unlimited"));
|
|
|
|
for (int i = 10; i <= 200; i += 10) // from 10% to 200%
|
|
|
|
{
|
|
|
|
if (i == 100)
|
|
|
|
m_throttler_array_string.Add(wxString::Format(_("%i%% (Normal Speed)"), i));
|
|
|
|
else
|
|
|
|
m_throttler_array_string.Add(wxString::Format(_("%i%%"), i));
|
|
|
|
}
|
|
|
|
|
2017-04-15 14:23:48 +00:00
|
|
|
for (PowerPC::CPUCore cpu_core : PowerPC::AvailableCPUCores())
|
|
|
|
m_cpu_engine_array_string.Add(wxGetTranslation(CPU_CORE_NAMES.at(cpu_core)));
|
2016-06-24 08:43:46 +00:00
|
|
|
|
|
|
|
m_dual_core_checkbox = new wxCheckBox(this, wxID_ANY, _("Enable Dual Core (speedup)"));
|
|
|
|
m_cheats_checkbox = new wxCheckBox(this, wxID_ANY, _("Enable Cheats"));
|
2017-04-26 21:27:13 +00:00
|
|
|
#if defined(USE_ANALYTICS) && USE_ANALYTICS
|
2016-06-24 08:43:46 +00:00
|
|
|
m_analytics_checkbox = new wxCheckBox(this, wxID_ANY, _("Enable Usage Statistics Reporting"));
|
2016-06-23 11:26:47 +00:00
|
|
|
#ifdef __APPLE__
|
2016-06-24 08:43:46 +00:00
|
|
|
m_analytics_new_id = new wxButton(this, wxID_ANY, _("Generate a New Statistics Identity"),
|
|
|
|
wxDefaultPosition, wxSize(350, 25));
|
2016-06-23 11:26:47 +00:00
|
|
|
#else
|
2016-06-24 08:43:46 +00:00
|
|
|
m_analytics_new_id = new wxButton(this, wxID_ANY, _("Generate a New Statistics Identity"));
|
2017-04-26 21:27:13 +00:00
|
|
|
#endif
|
2016-06-23 11:26:47 +00:00
|
|
|
#endif
|
2016-06-24 08:43:46 +00:00
|
|
|
m_throttler_choice =
|
|
|
|
new wxChoice(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_throttler_array_string);
|
|
|
|
m_cpu_engine_radiobox =
|
2017-07-23 11:11:06 +00:00
|
|
|
new wxRadioBox(this, wxID_ANY, _("CPU Emulation Engine"), wxDefaultPosition, wxDefaultSize,
|
2016-06-24 08:43:46 +00:00
|
|
|
m_cpu_engine_array_string, 0, wxRA_SPECIFY_ROWS);
|
|
|
|
|
|
|
|
m_dual_core_checkbox->SetToolTip(
|
|
|
|
_("Splits the CPU and GPU threads so they can be run on separate cores.\nProvides major "
|
|
|
|
"speed improvements on most modern PCs, but can cause occasional crashes/glitches."));
|
|
|
|
m_cheats_checkbox->SetToolTip(_("Enables the use of Action Replay and Gecko cheats."));
|
2017-04-26 21:27:13 +00:00
|
|
|
#if defined(USE_ANALYTICS) && USE_ANALYTICS
|
2016-06-24 08:43:46 +00:00
|
|
|
m_analytics_checkbox->SetToolTip(
|
|
|
|
_("Enables the collection and sharing of usage statistics data with the Dolphin development "
|
|
|
|
"team. This data is used to improve the emulator and help us understand how our users "
|
|
|
|
"interact with the system. No private data is ever collected."));
|
|
|
|
m_analytics_new_id->SetToolTip(
|
|
|
|
_("Usage statistics reporting uses a unique random per-machine identifier to distinguish "
|
|
|
|
"users from one another. This button generates a new random identifier for this machine "
|
|
|
|
"which is dissociated from the previous one."));
|
2017-04-26 21:27:13 +00:00
|
|
|
#endif
|
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
m_throttler_choice->SetToolTip(_("Limits the emulation speed to the specified percentage.\nNote "
|
|
|
|
"that raising or lowering the emulation speed will also raise "
|
2017-04-12 19:03:53 +00:00
|
|
|
"or lower the audio pitch unless audio stretching is enabled."));
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2016-08-02 06:22:37 +00:00
|
|
|
const int space5 = FromDIP(5);
|
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
wxBoxSizer* const throttler_sizer = new wxBoxSizer(wxHORIZONTAL);
|
2016-08-02 06:22:37 +00:00
|
|
|
throttler_sizer->AddSpacer(space5);
|
2016-06-24 08:43:46 +00:00
|
|
|
throttler_sizer->Add(new wxStaticText(this, wxID_ANY, _("Speed Limit:")), 0,
|
2016-08-02 06:22:37 +00:00
|
|
|
wxALIGN_CENTER_VERTICAL | wxBOTTOM, space5);
|
|
|
|
throttler_sizer->AddSpacer(space5);
|
|
|
|
throttler_sizer->Add(m_throttler_choice, 0, wxALIGN_CENTER_VERTICAL | wxBOTTOM, space5);
|
|
|
|
throttler_sizer->AddSpacer(space5);
|
2016-06-24 08:43:46 +00:00
|
|
|
|
|
|
|
wxStaticBoxSizer* const basic_settings_sizer =
|
|
|
|
new wxStaticBoxSizer(wxVERTICAL, this, _("Basic Settings"));
|
2016-08-02 06:22:37 +00:00
|
|
|
basic_settings_sizer->AddSpacer(space5);
|
|
|
|
basic_settings_sizer->Add(m_dual_core_checkbox, 0, wxLEFT | wxRIGHT, space5);
|
|
|
|
basic_settings_sizer->AddSpacer(space5);
|
|
|
|
basic_settings_sizer->Add(m_cheats_checkbox, 0, wxLEFT | wxRIGHT, space5);
|
|
|
|
basic_settings_sizer->AddSpacer(space5);
|
2016-06-24 08:43:46 +00:00
|
|
|
basic_settings_sizer->Add(throttler_sizer);
|
|
|
|
|
2017-04-26 21:27:13 +00:00
|
|
|
#if defined(USE_ANALYTICS) && USE_ANALYTICS
|
2016-06-24 08:43:46 +00:00
|
|
|
wxStaticBoxSizer* const analytics_sizer =
|
|
|
|
new wxStaticBoxSizer(wxVERTICAL, this, _("Usage Statistics Reporting Settings"));
|
2016-08-02 06:22:37 +00:00
|
|
|
analytics_sizer->AddSpacer(space5);
|
|
|
|
analytics_sizer->Add(m_analytics_checkbox, 0, wxLEFT | wxRIGHT, space5);
|
|
|
|
analytics_sizer->AddSpacer(space5);
|
|
|
|
analytics_sizer->Add(m_analytics_new_id, 0, wxLEFT | wxRIGHT, space5);
|
|
|
|
analytics_sizer->AddSpacer(space5);
|
2017-04-26 21:27:13 +00:00
|
|
|
#endif
|
2016-06-24 08:43:46 +00:00
|
|
|
|
|
|
|
wxStaticBoxSizer* const advanced_settings_sizer =
|
|
|
|
new wxStaticBoxSizer(wxVERTICAL, this, _("Advanced Settings"));
|
2016-08-02 06:22:37 +00:00
|
|
|
advanced_settings_sizer->AddSpacer(space5);
|
|
|
|
advanced_settings_sizer->Add(m_cpu_engine_radiobox, 0, wxLEFT | wxRIGHT, space5);
|
|
|
|
advanced_settings_sizer->AddSpacer(space5);
|
2016-06-24 08:43:46 +00:00
|
|
|
|
|
|
|
wxBoxSizer* const main_sizer = new wxBoxSizer(wxVERTICAL);
|
2016-08-02 06:22:37 +00:00
|
|
|
main_sizer->AddSpacer(space5);
|
|
|
|
main_sizer->Add(basic_settings_sizer, 0, wxEXPAND | wxLEFT | wxRIGHT, space5);
|
|
|
|
main_sizer->AddSpacer(space5);
|
2017-04-26 21:27:13 +00:00
|
|
|
#if defined(USE_ANALYTICS) && USE_ANALYTICS
|
2017-03-07 03:19:32 +00:00
|
|
|
main_sizer->Add(analytics_sizer, 0, wxEXPAND | wxLEFT | wxRIGHT, space5);
|
2017-04-26 21:27:13 +00:00
|
|
|
#endif
|
2016-08-02 06:22:37 +00:00
|
|
|
main_sizer->AddSpacer(space5);
|
|
|
|
main_sizer->Add(advanced_settings_sizer, 0, wxEXPAND | wxLEFT | wxRIGHT, space5);
|
|
|
|
main_sizer->AddSpacer(space5);
|
2016-06-24 08:43:46 +00:00
|
|
|
|
|
|
|
SetSizer(main_sizer);
|
2015-03-18 22:00:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void GeneralConfigPane::LoadGUIValues()
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
const SConfig& startup_params = SConfig::GetInstance();
|
|
|
|
|
|
|
|
m_dual_core_checkbox->SetValue(startup_params.bCPUThread);
|
|
|
|
m_cheats_checkbox->SetValue(startup_params.bEnableCheats);
|
2017-04-26 21:27:13 +00:00
|
|
|
|
|
|
|
#if defined(USE_ANALYTICS) && USE_ANALYTICS
|
2016-06-24 08:43:46 +00:00
|
|
|
m_analytics_checkbox->SetValue(startup_params.m_analytics_enabled);
|
2017-04-26 21:27:13 +00:00
|
|
|
#endif
|
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
u32 selection = std::lround(startup_params.m_EmulationSpeed * 10.0f);
|
|
|
|
if (selection < m_throttler_array_string.size())
|
|
|
|
m_throttler_choice->SetSelection(selection);
|
|
|
|
|
2017-04-15 14:23:48 +00:00
|
|
|
const std::vector<PowerPC::CPUCore>& cpu_cores = PowerPC::AvailableCPUCores();
|
|
|
|
for (size_t i = 0; i < cpu_cores.size(); ++i)
|
2016-06-24 08:43:46 +00:00
|
|
|
{
|
2017-04-15 14:23:48 +00:00
|
|
|
if (cpu_cores[i] == startup_params.iCPUCore)
|
2016-06-24 08:43:46 +00:00
|
|
|
m_cpu_engine_radiobox->SetSelection(i);
|
|
|
|
}
|
2015-03-18 22:00:27 +00:00
|
|
|
}
|
|
|
|
|
2016-11-05 12:29:29 +00:00
|
|
|
void GeneralConfigPane::BindEvents()
|
2015-03-18 22:00:27 +00:00
|
|
|
{
|
2016-11-05 12:29:29 +00:00
|
|
|
m_dual_core_checkbox->Bind(wxEVT_CHECKBOX, &GeneralConfigPane::OnDualCoreCheckBoxChanged, this);
|
|
|
|
m_dual_core_checkbox->Bind(wxEVT_UPDATE_UI, &WxEventUtils::OnEnableIfCoreNotRunning);
|
|
|
|
|
|
|
|
m_cheats_checkbox->Bind(wxEVT_CHECKBOX, &GeneralConfigPane::OnCheatCheckBoxChanged, this);
|
|
|
|
m_cheats_checkbox->Bind(wxEVT_UPDATE_UI, &WxEventUtils::OnEnableIfCoreNotRunning);
|
|
|
|
|
2017-04-26 21:27:13 +00:00
|
|
|
#if defined(USE_ANALYTICS) && USE_ANALYTICS
|
2016-11-05 12:29:29 +00:00
|
|
|
m_analytics_checkbox->Bind(wxEVT_CHECKBOX, &GeneralConfigPane::OnAnalyticsCheckBoxChanged, this);
|
|
|
|
|
|
|
|
m_analytics_new_id->Bind(wxEVT_BUTTON, &GeneralConfigPane::OnAnalyticsNewIdButtonClick, this);
|
2017-04-26 21:27:13 +00:00
|
|
|
#endif
|
2016-11-05 12:29:29 +00:00
|
|
|
|
|
|
|
m_throttler_choice->Bind(wxEVT_CHOICE, &GeneralConfigPane::OnThrottlerChoiceChanged, this);
|
|
|
|
|
|
|
|
m_cpu_engine_radiobox->Bind(wxEVT_RADIOBOX, &GeneralConfigPane::OnCPUEngineRadioBoxChanged, this);
|
|
|
|
m_cpu_engine_radiobox->Bind(wxEVT_UPDATE_UI, &WxEventUtils::OnEnableIfCoreNotRunning);
|
2015-03-18 22:00:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void GeneralConfigPane::OnDualCoreCheckBoxChanged(wxCommandEvent& event)
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
if (Core::IsRunning())
|
|
|
|
return;
|
2015-03-18 22:00:27 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
SConfig::GetInstance().bCPUThread = m_dual_core_checkbox->IsChecked();
|
2015-03-18 22:00:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void GeneralConfigPane::OnCheatCheckBoxChanged(wxCommandEvent& event)
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
SConfig::GetInstance().bEnableCheats = m_cheats_checkbox->IsChecked();
|
2015-03-18 22:00:27 +00:00
|
|
|
}
|
|
|
|
|
2015-12-15 23:10:47 +00:00
|
|
|
void GeneralConfigPane::OnThrottlerChoiceChanged(wxCommandEvent& event)
|
2015-03-18 22:00:27 +00:00
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
if (m_throttler_choice->GetSelection() != wxNOT_FOUND)
|
|
|
|
SConfig::GetInstance().m_EmulationSpeed = m_throttler_choice->GetSelection() * 0.1f;
|
2015-03-18 22:00:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void GeneralConfigPane::OnCPUEngineRadioBoxChanged(wxCommandEvent& event)
|
|
|
|
{
|
2017-04-15 14:23:48 +00:00
|
|
|
SConfig::GetInstance().iCPUCore = PowerPC::AvailableCPUCores()[event.GetSelection()];
|
2015-03-18 22:00:27 +00:00
|
|
|
}
|
2016-06-18 01:24:06 +00:00
|
|
|
|
|
|
|
void GeneralConfigPane::OnAnalyticsCheckBoxChanged(wxCommandEvent& event)
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
SConfig::GetInstance().m_analytics_enabled = m_analytics_checkbox->IsChecked();
|
|
|
|
DolphinAnalytics::Instance()->ReloadConfig();
|
2016-06-18 01:24:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void GeneralConfigPane::OnAnalyticsNewIdButtonClick(wxCommandEvent& event)
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
DolphinAnalytics::Instance()->GenerateNewIdentity();
|
2017-07-23 11:11:06 +00:00
|
|
|
wxMessageBox(_("New identity generated."), _("Identity Generation"), wxICON_INFORMATION);
|
2016-06-18 01:24:06 +00:00
|
|
|
}
|