Analytics: Implement UI.

* Opt-in popup on first start.
* Checkbox and button in the main config dialog.
This commit is contained in:
Pierre Bourdon 2016-06-18 03:24:06 +02:00
parent 121f270367
commit 63dab254e0
3 changed files with 57 additions and 0 deletions

View file

@ -2,14 +2,17 @@
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include <wx/button.h>
#include <wx/checkbox.h>
#include <wx/choice.h>
#include <wx/event.h>
#include <wx/menu.h>
#include <wx/msgdlg.h>
#include <wx/radiobox.h>
#include <wx/sizer.h>
#include <wx/stattext.h>
#include "Core/Analytics.h"
#include "Core/ConfigManager.h"
#include "Core/Core.h"
#include "Core/PowerPC/PowerPC.h"
@ -55,6 +58,8 @@ void GeneralConfigPane::InitializeGUI()
m_idle_skip_checkbox = new wxCheckBox(this, wxID_ANY, _("Enable Idle Skipping (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"));
m_analytics_checkbox = new wxCheckBox(this, wxID_ANY, _("Enable Usage Statistics Reporting"));
m_analytics_new_id = new wxButton(this, wxID_ANY, _("Generate a New Statistics Identity"));
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);
@ -62,12 +67,16 @@ void GeneralConfigPane::InitializeGUI()
m_idle_skip_checkbox->SetToolTip(_("Attempt to detect and skip wait-loops.\nIf unsure, leave this checked."));
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."));
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."));
m_throttler_choice->SetToolTip(_("Limits the emulation speed to the specified percentage.\nNote that raising or lowering the emulation speed will also raise or lower the audio pitch to prevent audio from stuttering."));
m_dual_core_checkbox->Bind(wxEVT_CHECKBOX, &GeneralConfigPane::OnDualCoreCheckBoxChanged, this);
m_idle_skip_checkbox->Bind(wxEVT_CHECKBOX, &GeneralConfigPane::OnIdleSkipCheckBoxChanged, this);
m_cheats_checkbox->Bind(wxEVT_CHECKBOX, &GeneralConfigPane::OnCheatCheckBoxChanged, this);
m_force_ntscj_checkbox->Bind(wxEVT_CHECKBOX, &GeneralConfigPane::OnForceNTSCJCheckBoxChanged, this);
m_analytics_checkbox->Bind(wxEVT_CHECKBOX, &GeneralConfigPane::OnAnalyticsCheckBoxChanged, this);
m_analytics_new_id->Bind(wxEVT_BUTTON, &GeneralConfigPane::OnAnalyticsNewIdButtonClick, this);
m_throttler_choice->Bind(wxEVT_CHOICE, &GeneralConfigPane::OnThrottlerChoiceChanged, this);
m_cpu_engine_radiobox->Bind(wxEVT_RADIOBOX, &GeneralConfigPane::OnCPUEngineRadioBoxChanged, this);
@ -81,12 +90,17 @@ void GeneralConfigPane::InitializeGUI()
basic_settings_sizer->Add(m_cheats_checkbox, 0, wxALL, 5);
basic_settings_sizer->Add(throttler_sizer);
wxStaticBoxSizer* const analytics_sizer = new wxStaticBoxSizer(wxVERTICAL, this, _("Usage Statistics Reporting Settings"));
analytics_sizer->Add(m_analytics_checkbox, 0, wxALL, 5);
analytics_sizer->Add(m_analytics_new_id, 0, wxALL, 5);
wxStaticBoxSizer* const advanced_settings_sizer = new wxStaticBoxSizer(wxVERTICAL, this, _("Advanced Settings"));
advanced_settings_sizer->Add(m_cpu_engine_radiobox, 0, wxALL, 5);
advanced_settings_sizer->Add(m_force_ntscj_checkbox, 0, wxALL, 5);
wxBoxSizer* const main_sizer = new wxBoxSizer(wxVERTICAL);
main_sizer->Add(basic_settings_sizer, 0, wxEXPAND | wxALL, 5);
main_sizer->Add(analytics_sizer, 0, wxEXPAND | wxALL, 5);
main_sizer->Add(advanced_settings_sizer, 0, wxEXPAND | wxALL, 5);
SetSizer(main_sizer);
@ -100,6 +114,7 @@ void GeneralConfigPane::LoadGUIValues()
m_idle_skip_checkbox->SetValue(startup_params.bSkipIdle);
m_cheats_checkbox->SetValue(startup_params.bEnableCheats);
m_force_ntscj_checkbox->SetValue(startup_params.bForceNTSCJ);
m_analytics_checkbox->SetValue(startup_params.m_analytics_enabled);
u32 selection = std::lround(startup_params.m_EmulationSpeed * 10.0f);
if (selection < m_throttler_array_string.size())
m_throttler_choice->SetSelection(selection);
@ -165,3 +180,15 @@ void GeneralConfigPane::OnCPUEngineRadioBoxChanged(wxCommandEvent& event)
SConfig::GetInstance().iCPUCore = cpu_cores[selection].CPUid;
}
void GeneralConfigPane::OnAnalyticsCheckBoxChanged(wxCommandEvent& event)
{
SConfig::GetInstance().m_analytics_enabled = m_analytics_checkbox->IsChecked();
DolphinAnalytics::Instance()->ReloadConfig();
}
void GeneralConfigPane::OnAnalyticsNewIdButtonClick(wxCommandEvent& event)
{
DolphinAnalytics::Instance()->GenerateNewIdentity();
wxMessageBox(_("New identity generated."), _("Identity generation"), wxICON_INFORMATION);
}

View file

@ -7,6 +7,7 @@
#include <wx/arrstr.h>
#include <wx/panel.h>
class wxButton;
class wxCheckBox;
class wxChoice;
class wxRadioBox;
@ -34,6 +35,8 @@ private:
void OnForceNTSCJCheckBoxChanged(wxCommandEvent&);
void OnThrottlerChoiceChanged(wxCommandEvent&);
void OnCPUEngineRadioBoxChanged(wxCommandEvent&);
void OnAnalyticsCheckBoxChanged(wxCommandEvent&);
void OnAnalyticsNewIdButtonClick(wxCommandEvent&);
wxArrayString m_throttler_array_string;
wxArrayString m_cpu_engine_array_string;
@ -43,6 +46,9 @@ private:
wxCheckBox* m_cheats_checkbox;
wxCheckBox* m_force_ntscj_checkbox;
wxCheckBox* m_analytics_checkbox;
wxButton* m_analytics_new_id;
wxChoice* m_throttler_choice;
wxRadioBox* m_cpu_engine_radiobox;

View file

@ -267,6 +267,30 @@ void DolphinApp::AfterInit()
if (!m_batch_mode)
main_frame->UpdateGameList();
if (!SConfig::GetInstance().m_analytics_permission_asked)
{
int answer = wxMessageBox(
_("If authorized, Dolphin can collect data on its performance, "
"feature usage, and configuration, as well as data on your system's "
"hardware and operating system.\n\n"
"No private data is ever collected. This data helps us understand "
"how people and emulated games use Dolphin and prioritize our "
"efforts. It also helps us identify rare configurations that are "
"causing bugs, performance and stability issues.\n"
"This authorization can be revoked at any time through Dolphin's "
"settings.\n\n"
"Do you authorize Dolphin to report this information to Dolphin's "
"developers?"),
_("Usage statistics reporting"),
wxYES_NO, main_frame);
SConfig::GetInstance().m_analytics_permission_asked = true;
SConfig::GetInstance().m_analytics_enabled = (answer == wxYES);
SConfig::GetInstance().SaveSettings();
DolphinAnalytics::Instance()->ReloadConfig();
}
if (m_confirm_stop)
{
if (m_confirm_setting.Upper() == "TRUE")