Merge pull request #3558 from unknownbrackets/reporting

Disable reporting w/ "Read Framebuffers" and refresh UI on lang change
This commit is contained in:
Henrik Rydgård committed 2013-09-01 14:58:09 -07:00
commit 2bc373eaa0
10 files changed
+106 -17

No files matched your search

+25 -1
View File
@@ -236,9 +236,18 @@ namespace Reporting
return 0;
}
bool IsSupported()
{
// Disabled when using certain hacks, because they make for poor reports.
// TODO: Numbers to avoid dependency on GLES code.
if (g_Config.iRenderingMode == 2 || g_Config.iRenderingMode == 3)
return false;
return true;
}
bool IsEnabled()
{
if (g_Config.sReportHost.empty())
if (g_Config.sReportHost.empty() || !IsSupported())
return false;
// Disabled by default for now.
if (g_Config.sReportHost.compare("default") == 0)
@@ -246,6 +255,21 @@ namespace Reporting
return true;
}
void Enable(bool flag, std::string host)
{
if (IsSupported() && IsEnabled() != flag)
{
// "" means explicitly disabled. Don't ever turn on by default.
// "default" means it's okay to turn it on by default.
g_Config.sReportHost = flag ? host : "";
}
}
void EnableDefault()
{
g_Config.sReportHost = "default";
}
void ReportMessage(const char *message, ...)
{
if (!IsEnabled() || CheckSpamLimited())
+13
View File
@@ -16,6 +16,7 @@
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
#include "Common/CommonTypes.h"
#include <string>
#define ERROR_LOG_REPORT(t,...) { ERROR_LOG(t, __VA_ARGS__); Reporting::ReportMessage(__VA_ARGS__); }
#define WARN_LOG_REPORT(t,...) { WARN_LOG(t, __VA_ARGS__); Reporting::ReportMessage(__VA_ARGS__); }
@@ -34,6 +35,18 @@
namespace Reporting
{
// Returns whether or not the reporting system is currently enabled.
bool IsEnabled();
// Returns whether the reporting system can be enabled (based on system or settings.)
bool IsSupported();
// Set the current enabled state of the reporting system and desired reporting server host.
void Enable(bool flag, std::string host);
// Use the default reporting setting (per compiled settings) of host and enabled state.
void EnableDefault();
// Report a message string, using the format string as a key.
void ReportMessage(const char *message, ...);
}
+30 -6
View File
@@ -34,6 +34,7 @@
#include "math/curves.h"
#include "Core/HW/atrac3plus.h"
#include "Core/System.h"
#include "Core/Reporting.h"
#include "Common/KeyMap.h"
#ifdef _WIN32
@@ -69,6 +70,8 @@ public:
virtual void Draw(UIContext &dc);
UI::Event OnChoice;
private:
void UpdateText();
EventReturn HandleClick(EventParams &e);
@@ -104,6 +107,11 @@ void PopupMultiChoice::ChoiceCallback(int num) {
if (num != -1) {
*value_ = num + minVal_;
UpdateText();
UI::EventParams e;
e.v = this;
e.a = num;
OnChoice.Trigger(e);
}
}
@@ -232,7 +240,7 @@ void GameSettingsScreen::CreateViews() {
graphicsSettings->Add(new ItemHeader(gs->T("Rendering Mode")));
static const char *renderingMode[] = { "Non-Buffered Rendering", "Buffered Rendering", "Read Framebuffers To Memory (CPU)", "Read Framebuffers To Memory (GPU)"};
graphicsSettings->Add(new PopupMultiChoice(&g_Config.iRenderingMode, gs->T("Mode"), renderingMode, 0, 4, gs, screenManager()));
graphicsSettings->Add(new PopupMultiChoice(&g_Config.iRenderingMode, gs->T("Mode"), renderingMode, 0, 4, gs, screenManager()))->OnChoice.Handle(this, &GameSettingsScreen::OnRenderingMode);
graphicsSettings->Add(new ItemHeader(gs->T("Frame Rate Control")));
static const char *frameSkip[] = {"Off", "Auto", "1", "2", "3", "4", "5", "6", "7", "8"};
@@ -348,7 +356,7 @@ void GameSettingsScreen::CreateViews() {
#endif
systemSettings->Add(new PopupSliderChoice(&g_Config.iLockedCPUSpeed, 0, 1000, s->T("Change CPU Clock", "Change CPU Clock (0 = default)"), screenManager()));
enableReports_ = g_Config.sReportHost != "default";
enableReports_ = Reporting::IsEnabled();
//#ifndef ANDROID
systemSettings->Add(new ItemHeader(s->T("Cheats", "Cheats (experimental, see forums)")));
systemSettings->Add(new CheckBox(&g_Config.bEnableCheats, s->T("Enable Cheats")));
@@ -368,7 +376,9 @@ void GameSettingsScreen::CreateViews() {
systemSettings->Add(new Choice(s->T("Change Nickname")))->OnClick.Handle(this, &GameSettingsScreen::OnChangeNickname);
#endif
systemSettings->Add(new Choice(s->T("Clear Recent Games List")))->OnClick.Handle(this, &GameSettingsScreen::OnClearRecents);
systemSettings->Add(new CheckBox(&enableReports_, s->T("Enable Compatibility Server Reports")));
enableReportsCheckbox_ = new CheckBox(&enableReports_, s->T("Enable Compatibility Server Reports"));
enableReportsCheckbox_->SetEnabled(Reporting::IsSupported());
systemSettings->Add(enableReportsCheckbox_);
systemSettings->Add(new Choice(s->T("Developer Tools")))->OnClick.Handle(this, &GameSettingsScreen::OnDeveloperTools);
@@ -394,6 +404,12 @@ UI::EventReturn GameSettingsScreen::OnReloadCheats(UI::EventParams &e) {
return UI::EVENT_DONE;
}
UI::EventReturn GameSettingsScreen::OnRenderingMode(UI::EventParams &e) {
enableReports_ = Reporting::IsEnabled();
enableReportsCheckbox_->SetEnabled(Reporting::IsSupported());
return UI::EVENT_DONE;
}
void DrawBackground(float alpha);
UI::EventReturn GameSettingsScreen::OnDumpNextFrameToLog(UI::EventParams &e) {
@@ -456,7 +472,7 @@ UI::EventReturn GameSettingsScreen::OnBack(UI::EventParams &e) {
Atrac3plus_Decoder::Init();
else Atrac3plus_Decoder::Shutdown();
}
g_Config.sReportHost = enableReports_ ? "report.ppsspp.org" : "default";
Reporting::Enable(enableReports_, "report.ppsspp.org");
g_Config.Save();
#ifdef _WIN32
@@ -473,7 +489,7 @@ void GlobalSettingsScreen::CreateViews() {
using namespace UI;
root_ = new ScrollView(ORIENT_VERTICAL);
enableReports_ = g_Config.sReportHost != "";
enableReports_ = Reporting::IsEnabled();
}*/
UI::EventReturn GameSettingsScreen::OnChangeNickname(UI::EventParams &e) {
@@ -499,7 +515,15 @@ UI::EventReturn GameSettingsScreen::OnFactoryReset(UI::EventParams &e) {
UI::EventReturn GameSettingsScreen::OnLanguage(UI::EventParams &e) {
I18NCategory *d = GetI18NCategory("Developer");
screenManager()->push(new NewLanguageScreen(d->T("Language")));
auto langScreen = new NewLanguageScreen(d->T("Language"));
langScreen->OnChoice.Handle(this, &GameSettingsScreen::OnLanguageChange);
screenManager()->push(langScreen);
return UI::EVENT_DONE;
}
UI::EventReturn GameSettingsScreen::OnLanguageChange(UI::EventParams &e) {
RecreateViews();
OnLanguageChanged.Trigger(e);
return UI::EVENT_DONE;
}
+5
View File
@@ -29,6 +29,8 @@ public:
virtual void update(InputState &input);
UI::Event OnLanguageChanged;
protected:
virtual void CreateViews();
virtual void DrawBackground(UIContext &dc);
@@ -39,6 +41,7 @@ private:
// As we load metadata in the background, we need to be able to update these after the fact.
UI::TextView *tvTitle_;
UI::TextView *tvGameSize_;
UI::CheckBox *enableReportsCheckbox_;
// Event handlers
UI::EventReturn OnDownloadPlugin(UI::EventParams &e);
@@ -49,10 +52,12 @@ private:
// Global settings handlers
UI::EventReturn OnLanguage(UI::EventParams &e);
UI::EventReturn OnLanguageChange(UI::EventParams &e);
UI::EventReturn OnFactoryReset(UI::EventParams &e);
UI::EventReturn OnDeveloperTools(UI::EventParams &e);
UI::EventReturn OnChangeNickname(UI::EventParams &e);
UI::EventReturn OnClearRecents(UI::EventParams &e);
UI::EventReturn OnRenderingMode(UI::EventParams &e);
// Temporaries to convert bools to int settings
bool cap60FPS_;
+12 -1
View File
@@ -25,6 +25,7 @@
#include "Common/FileUtil.h"
#include "Core/System.h"
#include "Core/Host.h"
#include "Core/SaveState.h"
#include "UI/EmuScreen.h"
@@ -585,7 +586,17 @@ UI::EventReturn MainScreen::OnGameSelectedInstant(UI::EventParams &e) {
UI::EventReturn MainScreen::OnGameSettings(UI::EventParams &e) {
// screenManager()->push(new SettingsScreen());
screenManager()->push(new GameSettingsScreen("",""));
auto gameSettings = new GameSettingsScreen("", "");
gameSettings->OnLanguageChanged.Handle(this, &MainScreen::OnLanguageChange);
screenManager()->push(gameSettings);
return UI::EVENT_DONE;
}
UI::EventReturn MainScreen::OnLanguageChange(UI::EventParams &e) {
RecreateViews();
if (host) {
host->UpdateUI();
}
return UI::EVENT_DONE;
}
+1
View File
@@ -41,6 +41,7 @@ private:
// Event handlers
UI::EventReturn OnLoadFile(UI::EventParams &e);
UI::EventReturn OnGameSettings(UI::EventParams &e);
UI::EventReturn OnLanguageChange(UI::EventParams &e);
UI::EventReturn OnCredits(UI::EventParams &e);
UI::EventReturn OnSupport(UI::EventParams &e);
UI::EventReturn OnPPSSPPOrg(UI::EventParams &e);
+1
View File
@@ -249,6 +249,7 @@ void NewLanguageScreen::OnCompleted(DialogResult result) {
} else {
g_Config.ilanguage = langValuesMapping[code].second;
}
RecreateViews();
} else {
g_Config.languageIni = oldLang;
}
+1 -2
View File
@@ -156,8 +156,7 @@ void WindowsHost::ShutdownSound()
void WindowsHost::UpdateUI()
{
MainWindow::TranslateMenus();
MainWindow::Update();
PostMessage(MainWindow::GetHWND(), MainWindow::WM_USER_UPDATE_UI, 0, 0);
}
+15 -5
View File
@@ -21,6 +21,7 @@
#include "Common/CommonWindows.h"
#include <map>
#include <string>
#include "base/NativeApp.h"
#include "Globals.h"
@@ -104,7 +105,7 @@ namespace MainWindow
static void *rawInputBuffer;
static size_t rawInputBufferSize;
static int currentSavestateSlot = 0;
static bool menusAreTranslated = false;
static std::map<int, std::string> initialMenuKeys;
#define MAX_LOADSTRING 100
const TCHAR *szTitle = TEXT("PPSSPP");
@@ -255,6 +256,13 @@ namespace MainWindow
return retVal;
}
const std::string &GetMenuItemInitialText(const int menuID) {
if (initialMenuKeys.find(menuID) == initialMenuKeys.end()) {
initialMenuKeys[menuID] = GetMenuItemText(menuID);
}
return initialMenuKeys[menuID];
}
// These are used as an offset
// to determine which menu item to change.
// Make sure to count(from 0) the separators too, when dealing with submenus!!
@@ -309,7 +317,7 @@ namespace MainWindow
void TranslateMenuItem(const int menuID, const char *category, const bool enabled = true, const bool checked = false, const std::wstring& accelerator = L"") {
I18NCategory *c = GetI18NCategory(category);
std::string key = c->T(GetMenuItemText(menuID).c_str());
std::string key = c->T(GetMenuItemInitialText(menuID).c_str());
std::wstring translated = ConvertUTF8ToWString(key);
translated.append(accelerator);
ModifyMenu(menu, menuID, MF_STRING
@@ -319,9 +327,6 @@ namespace MainWindow
}
void TranslateMenus() {
if(menusAreTranslated) return;
menusAreTranslated = true;
const char *desktopUI = "DesktopUI";
// File menu
@@ -1419,6 +1424,11 @@ namespace MainWindow
EnableMenuItem(menu, ID_EMULATION_ATRAC3_SOUND, MF_GRAYED);
break;
case WM_USER_UPDATE_UI:
TranslateMenus();
Update();
break;
case WM_MENUSELECT:
// Unfortunately, accelerate keys (hotkeys) shares the same enabled/disabled states
// with corresponding menu items.
+3 -2
View File
@@ -9,8 +9,9 @@ namespace MainWindow
{
enum {
WM_USER_SAVESTATE_FINISH = WM_USER + 100,
WM_USER_LOG_STATUS_CHANGED = WM_USER + 200,
WM_USER_ATRAC_STATUS_CHANGED = WM_USER + 300,
WM_USER_LOG_STATUS_CHANGED = WM_USER + 101,
WM_USER_ATRAC_STATUS_CHANGED = WM_USER + 102,
WM_USER_UPDATE_UI = WM_USER + 103,
};
enum {