diff --git a/Core/Config.cpp b/Core/Config.cpp index eb132ada52..352238d289 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -220,6 +220,7 @@ void Config::Load(const char *iniFileName, const char *controllerIniFilename) debugConfig->Get("FontWidth", &iFontWidth, 8); debugConfig->Get("FontHeight", &iFontHeight, 12); debugConfig->Get("DisplayStatusBar", &bDisplayStatusBar, true); + debugConfig->Get("ShowDeveloperMenu", &bShowDeveloperMenu, false); IniFile::Section *gleshacks = iniFile.GetOrCreateSection("GLESHacks"); gleshacks->Get("PrescaleUV", &bPrescaleUV, false); @@ -364,6 +365,8 @@ void Config::Save() { debugConfig->Set("FontWidth", iFontWidth); debugConfig->Set("FontHeight", iFontHeight); debugConfig->Set("DisplayStatusBar", bDisplayStatusBar); + debugConfig->Set("ShowDeveloperMenu", bShowDeveloperMenu); + if (!iniFile.Save(iniFilename_.c_str())) { ERROR_LOG(LOADER, "Error saving config - can't write ini %s", iniFilename_.c_str()); return; diff --git a/Core/Config.h b/Core/Config.h index f98545acc7..0b106883eb 100644 --- a/Core/Config.h +++ b/Core/Config.h @@ -157,6 +157,7 @@ public: int iFontWidth; int iFontHeight; bool bDisplayStatusBar; + bool bShowDeveloperMenu; std::string currentDirectory; std::string externalDirectory; diff --git a/UI/DevScreens.cpp b/UI/DevScreens.cpp index 36c438e0b9..b1095d0b93 100644 --- a/UI/DevScreens.cpp +++ b/UI/DevScreens.cpp @@ -27,6 +27,24 @@ #include "Common/LogManager.h" #include "Core/Config.h" + +void DevMenu::CreatePopupContents(UI::ViewGroup *parent) { + using namespace UI; + + parent->Add(new Choice("Log Channels"))->OnClick.Handle(this, &DevMenu::OnLogConfig); + parent->Add(new Choice("Developer Tools"))->OnClick.Handle(this, &DevMenu::OnDeveloperTools); +} + +UI::EventReturn DevMenu::OnLogConfig(UI::EventParams &e) { + screenManager()->push(new LogConfigScreen()); + return UI::EVENT_DONE; +} + +UI::EventReturn DevMenu::OnDeveloperTools(UI::EventParams &e) { + screenManager()->push(new DeveloperToolsScreen()); + return UI::EVENT_DONE; +} + // It's not so critical to translate everything here, most of this is developers only. void LogConfigScreen::CreateViews() { @@ -35,10 +53,16 @@ void LogConfigScreen::CreateViews() { I18NCategory *d = GetI18NCategory("Dialog"); root_ = new ScrollView(ORIENT_VERTICAL); - + LinearLayout *vert = root_->Add(new LinearLayout(ORIENT_VERTICAL, new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT))); vert->SetSpacing(0); + LinearLayout *topbar = new LinearLayout(ORIENT_HORIZONTAL); + topbar->Add(new Choice("Back"))->OnClick.Handle(this, &UIScreen::OnBack); + topbar->Add(new Choice("Toggle All"))->OnClick.Handle(this, &LogConfigScreen::OnToggleAll); + + vert->Add(topbar); + vert->Add(new ItemHeader("Log Channels")); static const char *logLevelList[] = { @@ -58,11 +82,20 @@ void LogConfigScreen::CreateViews() { LinearLayout *row = new LinearLayout(ORIENT_HORIZONTAL, new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT)); row->Add(new PopupMultiChoice(&chan->level_, chan->GetFullName(), logLevelList, 1, 6, 0, screenManager(), new LinearLayoutParams(1.0))); row->Add(new CheckBox(&chan->enable_, "", "", new LinearLayoutParams(100, WRAP_CONTENT))); - vert->Add(row); } +} - vert->Add(new Button(d->T("Back"), new LayoutParams(260, 64)))->OnClick.Handle(this, &UIScreen::OnBack); +UI::EventReturn LogConfigScreen::OnToggleAll(UI::EventParams &e) { + LogManager *logMan = LogManager::GetInstance(); + + for (int i = 0; i < LogManager::GetNumChannels(); i++) { + LogTypes::LOG_TYPE type = (LogTypes::LOG_TYPE)i; + LogChannel *chan = logMan->GetLogChannel(type); + chan->enable_ = !chan->enable_; + } + + return UI::EVENT_DONE; } void SystemInfoScreen::CreateViews() { diff --git a/UI/DevScreens.h b/UI/DevScreens.h index c0bd2b1548..8df30444c3 100644 --- a/UI/DevScreens.h +++ b/UI/DevScreens.h @@ -27,14 +27,24 @@ #include "UI/MiscScreens.h" +class DevMenu : public PopupScreen { +public: + DevMenu() : PopupScreen("Dev Tools") {} + + virtual void CreatePopupContents(UI::ViewGroup *parent); + +protected: + UI::EventReturn OnLogConfig(UI::EventParams &e); + UI::EventReturn OnDeveloperTools(UI::EventParams &e); +}; + class LogConfigScreen : public UIDialogScreenWithBackground { public: LogConfigScreen() {} virtual void CreateViews(); private: - UI::EventReturn OnLogLevelChanged(UI::EventParams &e); - UI::EventReturn OnLogEnabledChanged(UI::EventParams &e); + UI::EventReturn OnToggleAll(UI::EventParams &e); }; class SystemInfoScreen : public UIDialogScreenWithBackground { diff --git a/UI/EmuScreen.cpp b/UI/EmuScreen.cpp index 5883c2a768..b0fb933b64 100644 --- a/UI/EmuScreen.cpp +++ b/UI/EmuScreen.cpp @@ -49,6 +49,7 @@ #include "UI/MainScreen.h" #include "UI/EmuScreen.h" +#include "UI/DevScreens.h" #include "UI/GameInfoCache.h" #include "UI/MiscScreens.h" @@ -384,6 +385,14 @@ static const struct { int from, to; } legacy_touch_mapping[12] = { void EmuScreen::CreateViews() { root_ = CreatePadLayout(&pauseTrigger_); + if (g_Config.bShowDeveloperMenu) { + root_->Add(new UI::Button("DevMenu"))->OnClick.Handle(this, &EmuScreen::OnDevTools); + } +} + +UI::EventReturn EmuScreen::OnDevTools(UI::EventParams ¶ms) { + screenManager()->push(new DevMenu()); + return UI::EVENT_DONE; } void EmuScreen::update(InputState &input) { diff --git a/UI/EmuScreen.h b/UI/EmuScreen.h index 8899f34d6a..48a098b82f 100644 --- a/UI/EmuScreen.h +++ b/UI/EmuScreen.h @@ -44,6 +44,7 @@ public: protected: virtual void CreateViews(); + UI::EventReturn OnDevTools(UI::EventParams ¶ms); private: void bootGame(const std::string &filename); diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index 5c7a61f67c..25cbf9092c 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -426,13 +426,14 @@ void DeveloperToolsScreen::CreateViews() { list->SetSpacing(0); list->Add(new ItemHeader(s->T("General"))); list->Add(new Choice(de->T("System Information")))->OnClick.Handle(this, &DeveloperToolsScreen::OnSysInfo); + list->Add(new CheckBox(&enableLogging_, de->T("Enable Logging")))->OnClick.Handle(this, &DeveloperToolsScreen::OnLoggingChanged); list->Add(new Choice(de->T("Logging Channels")))->OnClick.Handle(this, &DeveloperToolsScreen::OnLogConfig); + list->Add(new CheckBox(&g_Config.bShowDeveloperMenu, de->T("Show Developer Menu"))); list->Add(new Choice(de->T("Run CPU Tests")))->OnClick.Handle(this, &DeveloperToolsScreen::OnRunCPUTests); list->Add(new Choice(de->T("Restore Default Settings")))->OnClick.Handle(this, &DeveloperToolsScreen::OnRestoreDefaultSettings); #ifndef __SYMBIAN32__ list->Add(new CheckBox(&g_Config.bSoftwareRendering, gs->T("Software Rendering", "Software Rendering (experimental)"))); #endif - list->Add(new CheckBox(&enableLogging_, de->T("Enable Logging")))->OnClick.Handle(this, &DeveloperToolsScreen::OnLoggingChanged); list->Add(new ItemHeader(de->T("Language"))); list->Add(new Choice(de->T("Load language ini")))->OnClick.Handle(this, &DeveloperToolsScreen::OnLoadLanguageIni); list->Add(new Choice(de->T("Save language ini")))->OnClick.Handle(this, &DeveloperToolsScreen::OnSaveLanguageIni);