Add optional "DevMenu" in-game button for quick access to things like log settings

This commit is contained in:
Henrik Rydgard 2013-09-07 20:54:11 +02:00
parent cbad7657e9
commit c31ae0645f
7 changed files with 64 additions and 6 deletions

View File

@ -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;

View File

@ -157,6 +157,7 @@ public:
int iFontWidth;
int iFontHeight;
bool bDisplayStatusBar;
bool bShowDeveloperMenu;
std::string currentDirectory;
std::string externalDirectory;

View File

@ -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() {
@ -39,6 +57,12 @@ void LogConfigScreen::CreateViews() {
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<UIScreen>(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<UIScreen>(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() {

View File

@ -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 {

View File

@ -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 &params) {
screenManager()->push(new DevMenu());
return UI::EVENT_DONE;
}
void EmuScreen::update(InputState &input) {

View File

@ -44,6 +44,7 @@ public:
protected:
virtual void CreateViews();
UI::EventReturn OnDevTools(UI::EventParams &params);
private:
void bootGame(const std::string &filename);

View File

@ -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);