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.
|
|
|
|
|
|
|
|
#include <cmath>
|
|
|
|
|
|
|
|
#include <wx/checkbox.h>
|
|
|
|
#include <wx/sizer.h>
|
|
|
|
#include <wx/slider.h>
|
|
|
|
#include <wx/stattext.h>
|
|
|
|
|
|
|
|
#include "Core/ConfigManager.h"
|
|
|
|
#include "DolphinWX/Config/AdvancedConfigPane.h"
|
|
|
|
|
|
|
|
AdvancedConfigPane::AdvancedConfigPane(wxWindow* parent, wxWindowID id)
|
|
|
|
: wxPanel(parent, id)
|
|
|
|
{
|
|
|
|
InitializeGUI();
|
|
|
|
LoadGUIValues();
|
|
|
|
}
|
|
|
|
|
|
|
|
void AdvancedConfigPane::InitializeGUI()
|
|
|
|
{
|
|
|
|
m_clock_override_checkbox = new wxCheckBox(this, wxID_ANY, _("Enable CPU Clock Override"));
|
2015-04-30 04:49:58 +00:00
|
|
|
m_clock_override_slider = new wxSlider(this, wxID_ANY, 100, 0, 150, wxDefaultPosition, wxSize(200,-1));
|
2015-03-18 22:00:27 +00:00
|
|
|
m_clock_override_text = new wxStaticText(this, wxID_ANY, "");
|
|
|
|
|
|
|
|
m_clock_override_checkbox->Bind(wxEVT_CHECKBOX, &AdvancedConfigPane::OnClockOverrideCheckBoxChanged, this);
|
|
|
|
m_clock_override_slider->Bind(wxEVT_SLIDER, &AdvancedConfigPane::OnClockOverrideSliderChanged, this);
|
|
|
|
|
|
|
|
wxStaticText* const clock_override_description = new wxStaticText(this, wxID_ANY,
|
2015-04-28 06:07:47 +00:00
|
|
|
_("Higher values can make variable-framerate games "
|
|
|
|
"run at a higher framerate, at the expense of CPU. "
|
|
|
|
"Lower values can make variable-framerate games "
|
2015-03-18 22:00:27 +00:00
|
|
|
"run at a lower framerate, saving CPU.\n\n"
|
2015-04-28 06:07:47 +00:00
|
|
|
"WARNING: Changing this from the default (100%) "
|
|
|
|
"can and will break games and cause glitches. "
|
|
|
|
"Do so at your own risk. Please do not report "
|
|
|
|
"bugs that occur with a non-default clock. "));
|
2016-06-23 11:26:47 +00:00
|
|
|
|
|
|
|
#ifdef __APPLE__
|
|
|
|
clock_override_description->Wrap(550);
|
|
|
|
#else
|
2015-04-28 06:07:47 +00:00
|
|
|
clock_override_description->Wrap(400);
|
2016-06-23 11:26:47 +00:00
|
|
|
#endif
|
2015-03-18 22:00:27 +00:00
|
|
|
|
|
|
|
wxBoxSizer* const clock_override_checkbox_sizer = new wxBoxSizer(wxHORIZONTAL);
|
2015-12-08 01:13:32 +00:00
|
|
|
clock_override_checkbox_sizer->Add(m_clock_override_checkbox, 1, wxALL, 5);
|
2015-03-18 22:00:27 +00:00
|
|
|
|
|
|
|
wxBoxSizer* const clock_override_slider_sizer = new wxBoxSizer(wxHORIZONTAL);
|
|
|
|
clock_override_slider_sizer->Add(m_clock_override_slider, 1, wxALL, 5);
|
|
|
|
clock_override_slider_sizer->Add(m_clock_override_text, 1, wxALL, 5);
|
|
|
|
|
|
|
|
wxBoxSizer* const clock_override_description_sizer = new wxBoxSizer(wxHORIZONTAL);
|
|
|
|
clock_override_description_sizer->Add(clock_override_description, 1, wxALL, 5);
|
|
|
|
|
|
|
|
wxStaticBoxSizer* const cpu_options_sizer = new wxStaticBoxSizer(wxVERTICAL, this, _("CPU Options"));
|
|
|
|
cpu_options_sizer->Add(clock_override_checkbox_sizer);
|
|
|
|
cpu_options_sizer->Add(clock_override_slider_sizer);
|
|
|
|
cpu_options_sizer->Add(clock_override_description_sizer);
|
|
|
|
|
|
|
|
wxBoxSizer* const main_sizer = new wxBoxSizer(wxVERTICAL);
|
|
|
|
main_sizer->Add(cpu_options_sizer , 0, wxEXPAND | wxALL, 5);
|
|
|
|
|
|
|
|
SetSizer(main_sizer);
|
|
|
|
}
|
|
|
|
|
|
|
|
void AdvancedConfigPane::LoadGUIValues()
|
|
|
|
{
|
|
|
|
int ocFactor = (int)(std::log2f(SConfig::GetInstance().m_OCFactor) * 25.f + 100.f + 0.5f);
|
2015-04-30 08:28:43 +00:00
|
|
|
bool oc_enabled = SConfig::GetInstance().m_OCEnable;
|
|
|
|
m_clock_override_checkbox->SetValue(oc_enabled);
|
2015-03-18 22:00:27 +00:00
|
|
|
m_clock_override_slider ->SetValue(ocFactor);
|
2015-04-30 08:28:43 +00:00
|
|
|
m_clock_override_slider->Enable(oc_enabled);
|
2015-03-18 22:00:27 +00:00
|
|
|
UpdateCPUClock();
|
|
|
|
}
|
|
|
|
|
|
|
|
void AdvancedConfigPane::OnClockOverrideCheckBoxChanged(wxCommandEvent& event)
|
|
|
|
{
|
|
|
|
SConfig::GetInstance().m_OCEnable = m_clock_override_checkbox->IsChecked();
|
|
|
|
m_clock_override_slider->Enable(SConfig::GetInstance().m_OCEnable);
|
|
|
|
UpdateCPUClock();
|
|
|
|
}
|
|
|
|
|
|
|
|
void AdvancedConfigPane::OnClockOverrideSliderChanged(wxCommandEvent& event)
|
|
|
|
{
|
|
|
|
// Vaguely exponential scaling?
|
|
|
|
SConfig::GetInstance().m_OCFactor = std::exp2f((m_clock_override_slider->GetValue() - 100.f) / 25.f);
|
|
|
|
UpdateCPUClock();
|
|
|
|
}
|
|
|
|
|
|
|
|
void AdvancedConfigPane::UpdateCPUClock()
|
|
|
|
{
|
2015-06-12 11:56:53 +00:00
|
|
|
bool wii = SConfig::GetInstance().bWii;
|
2015-03-18 22:00:27 +00:00
|
|
|
int percent = (int)(std::roundf(SConfig::GetInstance().m_OCFactor * 100.f));
|
|
|
|
int clock = (int)(std::roundf(SConfig::GetInstance().m_OCFactor * (wii ? 729.f : 486.f)));
|
|
|
|
|
|
|
|
m_clock_override_text->SetLabel(SConfig::GetInstance().m_OCEnable ? wxString::Format("%d %% (%d mhz)", percent, clock) : "");
|
|
|
|
}
|