2015-03-18 16:00:27 -06:00
|
|
|
// Copyright 2015 Dolphin Emulator Project
|
2015-05-17 17:08:10 -06:00
|
|
|
// Licensed under GPLv2+
|
2015-03-18 16:00:27 -06:00
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
2016-11-03 21:43:35 -06:00
|
|
|
#include "DolphinWX/Config/GeneralConfigPane.h"
|
|
|
|
|
2017-04-15 08:23:48 -06:00
|
|
|
#include <map>
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
2016-06-17 19:24:06 -06:00
|
|
|
#include <wx/button.h>
|
2015-03-18 16:00:27 -06:00
|
|
|
#include <wx/checkbox.h>
|
|
|
|
#include <wx/choice.h>
|
|
|
|
#include <wx/event.h>
|
|
|
|
#include <wx/menu.h>
|
2016-06-17 19:24:06 -06:00
|
|
|
#include <wx/msgdlg.h>
|
2015-03-18 16:00:27 -06:00
|
|
|
#include <wx/radiobox.h>
|
|
|
|
#include <wx/sizer.h>
|
|
|
|
#include <wx/stattext.h>
|
|
|
|
|
2017-04-15 08:23:48 -06:00
|
|
|
#include "Common/Common.h"
|
2016-06-17 19:24:06 -06:00
|
|
|
#include "Core/Analytics.h"
|
2015-03-18 16:00:27 -06:00
|
|
|
#include "Core/ConfigManager.h"
|
|
|
|
#include "Core/Core.h"
|
|
|
|
#include "Core/PowerPC/PowerPC.h"
|
2016-11-05 06:29:29 -06:00
|
|
|
#include "DolphinWX/WxEventUtils.h"
|
2015-03-18 16:00:27 -06:00
|
|
|
|
2017-04-15 08:23:48 -06: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 02:43:46 -06:00
|
|
|
GeneralConfigPane::GeneralConfigPane(wxWindow* parent, wxWindowID id) : wxPanel(parent, id)
|
2015-03-18 16:00:27 -06:00
|
|
|
{
|
2016-06-24 02:43:46 -06:00
|
|
|
InitializeGUI();
|
|
|
|
LoadGUIValues();
|
2016-11-05 06:29:29 -06:00
|
|
|
BindEvents();
|
2015-03-18 16:00:27 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void GeneralConfigPane::InitializeGUI()
|
|
|
|
{
|
2016-06-24 02:43:46 -06: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 08:23:48 -06:00
|
|
|
for (PowerPC::CPUCore cpu_core : PowerPC::AvailableCPUCores())
|
|
|
|
m_cpu_engine_array_string.Add(wxGetTranslation(CPU_CORE_NAMES.at(cpu_core)));
|
2016-06-24 02:43:46 -06:00
|
|
|
|
|
|
|
m_dual_core_checkbox = new wxCheckBox(this, wxID_ANY, _("Enable Dual Core (speedup)"));
|
|
|
|
m_cheats_checkbox = new wxCheckBox(this, wxID_ANY, _("Enable Cheats"));
|
|
|
|
m_force_ntscj_checkbox = new wxCheckBox(this, wxID_ANY, _("Force Console as NTSC-J"));
|
2017-04-26 15:27:13 -06:00
|
|
|
#if defined(USE_ANALYTICS) && USE_ANALYTICS
|
2016-06-24 02:43:46 -06:00
|
|
|
m_analytics_checkbox = new wxCheckBox(this, wxID_ANY, _("Enable Usage Statistics Reporting"));
|
2016-06-23 05:26:47 -06:00
|
|
|
#ifdef __APPLE__
|
2016-06-24 02:43:46 -06:00
|
|
|
m_analytics_new_id = new wxButton(this, wxID_ANY, _("Generate a New Statistics Identity"),
|
|
|
|
wxDefaultPosition, wxSize(350, 25));
|
2016-06-23 05:26:47 -06:00
|
|
|
#else
|
2016-06-24 02:43:46 -06:00
|
|
|
m_analytics_new_id = new wxButton(this, wxID_ANY, _("Generate a New Statistics Identity"));
|
2017-04-26 15:27:13 -06:00
|
|
|
#endif
|
2016-06-23 05:26:47 -06:00
|
|
|
#endif
|
2016-06-24 02:43:46 -06:00
|
|
|
m_throttler_choice =
|
|
|
|
new wxChoice(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_throttler_array_string);
|
|
|
|
m_cpu_engine_radiobox =
|
|
|
|
new wxRadioBox(this, wxID_ANY, _("CPU Emulator Engine"), wxDefaultPosition, wxDefaultSize,
|
|
|
|
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."));
|
|
|
|
m_force_ntscj_checkbox->SetToolTip(
|
|
|
|
_("Forces NTSC-J mode for using the Japanese ROM font.\nIf left unchecked, Dolphin defaults "
|
|
|
|
"to NTSC-U and automatically enables this setting when playing Japanese games."));
|
2017-04-26 15:27:13 -06:00
|
|
|
#if defined(USE_ANALYTICS) && USE_ANALYTICS
|
2016-06-24 02:43:46 -06: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 15:27:13 -06:00
|
|
|
#endif
|
|
|
|
|
2016-06-24 02:43:46 -06: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 13:03:53 -06:00
|
|
|
"or lower the audio pitch unless audio stretching is enabled."));
|
2016-06-24 02:43:46 -06:00
|
|
|
|
2016-08-02 00:22:37 -06:00
|
|
|
const int space5 = FromDIP(5);
|
|
|
|
|
2016-06-24 02:43:46 -06:00
|
|
|
wxBoxSizer* const throttler_sizer = new wxBoxSizer(wxHORIZONTAL);
|
2016-08-02 00:22:37 -06:00
|
|
|
throttler_sizer->AddSpacer(space5);
|
2016-06-24 02:43:46 -06:00
|
|
|
throttler_sizer->Add(new wxStaticText(this, wxID_ANY, _("Speed Limit:")), 0,
|
2016-08-02 00:22:37 -06: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 02:43:46 -06:00
|
|
|
|
|
|
|
wxStaticBoxSizer* const basic_settings_sizer =
|
|
|
|
new wxStaticBoxSizer(wxVERTICAL, this, _("Basic Settings"));
|
2016-08-02 00:22:37 -06: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 02:43:46 -06:00
|
|
|
basic_settings_sizer->Add(throttler_sizer);
|
|
|
|
|
2017-04-26 15:27:13 -06:00
|
|
|
#if defined(USE_ANALYTICS) && USE_ANALYTICS
|
2016-06-24 02:43:46 -06:00
|
|
|
wxStaticBoxSizer* const analytics_sizer =
|
|
|
|
new wxStaticBoxSizer(wxVERTICAL, this, _("Usage Statistics Reporting Settings"));
|
2016-08-02 00:22:37 -06: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 15:27:13 -06:00
|
|
|
#endif
|
2016-06-24 02:43:46 -06:00
|
|
|
|
|
|
|
wxStaticBoxSizer* const advanced_settings_sizer =
|
|
|
|
new wxStaticBoxSizer(wxVERTICAL, this, _("Advanced Settings"));
|
2016-08-02 00:22:37 -06:00
|
|
|
advanced_settings_sizer->AddSpacer(space5);
|
|
|
|
advanced_settings_sizer->Add(m_cpu_engine_radiobox, 0, wxLEFT | wxRIGHT, space5);
|
|
|
|
advanced_settings_sizer->AddSpacer(space5);
|
|
|
|
advanced_settings_sizer->Add(m_force_ntscj_checkbox, 0, wxLEFT | wxRIGHT, space5);
|
|
|
|
advanced_settings_sizer->AddSpacer(space5);
|
2016-06-24 02:43:46 -06:00
|
|
|
|
|
|
|
wxBoxSizer* const main_sizer = new wxBoxSizer(wxVERTICAL);
|
2016-08-02 00:22:37 -06:00
|
|
|
main_sizer->AddSpacer(space5);
|
|
|
|
main_sizer->Add(basic_settings_sizer, 0, wxEXPAND | wxLEFT | wxRIGHT, space5);
|
|
|
|
main_sizer->AddSpacer(space5);
|
2017-04-26 15:27:13 -06:00
|
|
|
#if defined(USE_ANALYTICS) && USE_ANALYTICS
|
2017-03-06 20:19:32 -07:00
|
|
|
main_sizer->Add(analytics_sizer, 0, wxEXPAND | wxLEFT | wxRIGHT, space5);
|
2017-04-26 15:27:13 -06:00
|
|
|
#endif
|
2016-08-02 00:22:37 -06:00
|
|
|
main_sizer->AddSpacer(space5);
|
|
|
|
main_sizer->Add(advanced_settings_sizer, 0, wxEXPAND | wxLEFT | wxRIGHT, space5);
|
|
|
|
main_sizer->AddSpacer(space5);
|
2016-06-24 02:43:46 -06:00
|
|
|
|
|
|
|
SetSizer(main_sizer);
|
2015-03-18 16:00:27 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void GeneralConfigPane::LoadGUIValues()
|
|
|
|
{
|
2016-06-24 02:43:46 -06:00
|
|
|
const SConfig& startup_params = SConfig::GetInstance();
|
|
|
|
|
|
|
|
m_dual_core_checkbox->SetValue(startup_params.bCPUThread);
|
|
|
|
m_cheats_checkbox->SetValue(startup_params.bEnableCheats);
|
|
|
|
m_force_ntscj_checkbox->SetValue(startup_params.bForceNTSCJ);
|
2017-04-26 15:27:13 -06:00
|
|
|
|
|
|
|
#if defined(USE_ANALYTICS) && USE_ANALYTICS
|
2016-06-24 02:43:46 -06:00
|
|
|
m_analytics_checkbox->SetValue(startup_params.m_analytics_enabled);
|
2017-04-26 15:27:13 -06:00
|
|
|
#endif
|
|
|
|
|
2016-06-24 02:43:46 -06: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 08:23:48 -06:00
|
|
|
const std::vector<PowerPC::CPUCore>& cpu_cores = PowerPC::AvailableCPUCores();
|
|
|
|
for (size_t i = 0; i < cpu_cores.size(); ++i)
|
2016-06-24 02:43:46 -06:00
|
|
|
{
|
2017-04-15 08:23:48 -06:00
|
|
|
if (cpu_cores[i] == startup_params.iCPUCore)
|
2016-06-24 02:43:46 -06:00
|
|
|
m_cpu_engine_radiobox->SetSelection(i);
|
|
|
|
}
|
2015-03-18 16:00:27 -06:00
|
|
|
}
|
|
|
|
|
2016-11-05 06:29:29 -06:00
|
|
|
void GeneralConfigPane::BindEvents()
|
2015-03-18 16:00:27 -06:00
|
|
|
{
|
2016-11-05 06:29:29 -06: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);
|
|
|
|
|
|
|
|
m_force_ntscj_checkbox->Bind(wxEVT_CHECKBOX, &GeneralConfigPane::OnForceNTSCJCheckBoxChanged,
|
|
|
|
this);
|
|
|
|
m_force_ntscj_checkbox->Bind(wxEVT_UPDATE_UI, &WxEventUtils::OnEnableIfCoreNotRunning);
|
|
|
|
|
2017-04-26 15:27:13 -06:00
|
|
|
#if defined(USE_ANALYTICS) && USE_ANALYTICS
|
2016-11-05 06:29:29 -06:00
|
|
|
m_analytics_checkbox->Bind(wxEVT_CHECKBOX, &GeneralConfigPane::OnAnalyticsCheckBoxChanged, this);
|
|
|
|
|
|
|
|
m_analytics_new_id->Bind(wxEVT_BUTTON, &GeneralConfigPane::OnAnalyticsNewIdButtonClick, this);
|
2017-04-26 15:27:13 -06:00
|
|
|
#endif
|
2016-11-05 06:29:29 -06: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 16:00:27 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void GeneralConfigPane::OnDualCoreCheckBoxChanged(wxCommandEvent& event)
|
|
|
|
{
|
2016-06-24 02:43:46 -06:00
|
|
|
if (Core::IsRunning())
|
|
|
|
return;
|
2015-03-18 16:00:27 -06:00
|
|
|
|
2016-06-24 02:43:46 -06:00
|
|
|
SConfig::GetInstance().bCPUThread = m_dual_core_checkbox->IsChecked();
|
2015-03-18 16:00:27 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void GeneralConfigPane::OnCheatCheckBoxChanged(wxCommandEvent& event)
|
|
|
|
{
|
2016-06-24 02:43:46 -06:00
|
|
|
SConfig::GetInstance().bEnableCheats = m_cheats_checkbox->IsChecked();
|
2015-03-18 16:00:27 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void GeneralConfigPane::OnForceNTSCJCheckBoxChanged(wxCommandEvent& event)
|
|
|
|
{
|
2016-06-24 02:43:46 -06:00
|
|
|
SConfig::GetInstance().bForceNTSCJ = m_force_ntscj_checkbox->IsChecked();
|
2015-03-18 16:00:27 -06:00
|
|
|
}
|
|
|
|
|
2015-12-15 16:10:47 -07:00
|
|
|
void GeneralConfigPane::OnThrottlerChoiceChanged(wxCommandEvent& event)
|
2015-03-18 16:00:27 -06:00
|
|
|
{
|
2016-06-24 02:43:46 -06:00
|
|
|
if (m_throttler_choice->GetSelection() != wxNOT_FOUND)
|
|
|
|
SConfig::GetInstance().m_EmulationSpeed = m_throttler_choice->GetSelection() * 0.1f;
|
2015-03-18 16:00:27 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void GeneralConfigPane::OnCPUEngineRadioBoxChanged(wxCommandEvent& event)
|
|
|
|
{
|
2017-04-15 08:23:48 -06:00
|
|
|
SConfig::GetInstance().iCPUCore = PowerPC::AvailableCPUCores()[event.GetSelection()];
|
2015-03-18 16:00:27 -06:00
|
|
|
}
|
2016-06-17 19:24:06 -06:00
|
|
|
|
|
|
|
void GeneralConfigPane::OnAnalyticsCheckBoxChanged(wxCommandEvent& event)
|
|
|
|
{
|
2016-06-24 02:43:46 -06:00
|
|
|
SConfig::GetInstance().m_analytics_enabled = m_analytics_checkbox->IsChecked();
|
|
|
|
DolphinAnalytics::Instance()->ReloadConfig();
|
2016-06-17 19:24:06 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void GeneralConfigPane::OnAnalyticsNewIdButtonClick(wxCommandEvent& event)
|
|
|
|
{
|
2016-06-24 02:43:46 -06:00
|
|
|
DolphinAnalytics::Instance()->GenerateNewIdentity();
|
|
|
|
wxMessageBox(_("New identity generated."), _("Identity generation"), wxICON_INFORMATION);
|
2016-06-17 19:24:06 -06:00
|
|
|
}
|