From 787db5812df3e1b528c5aeef5e31dbe6a15f7fb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Mon, 28 Oct 2013 16:04:53 +0100 Subject: [PATCH] UI cleanup and a crashfix for duplicate back key events --- UI/ControlMappingScreen.cpp | 13 +------------ UI/ControlMappingScreen.h | 1 - UI/GameSettingsScreen.cpp | 15 ++------------- UI/GameSettingsScreen.h | 2 -- UI/MainScreen.cpp | 5 +++-- UI/MainScreen.h | 2 +- UI/TiltAnalogSettingsScreen.cpp | 20 ++------------------ UI/TiltAnalogSettingsScreen.h | 4 +--- UI/TouchControlLayoutScreen.cpp | 22 ++++------------------ UI/TouchControlLayoutScreen.h | 1 - 10 files changed, 14 insertions(+), 71 deletions(-) diff --git a/UI/ControlMappingScreen.cpp b/UI/ControlMappingScreen.cpp index 14896fda2e..ff0b4b20a1 100644 --- a/UI/ControlMappingScreen.cpp +++ b/UI/ControlMappingScreen.cpp @@ -193,7 +193,7 @@ void ControlMappingScreen::CreateViews() { leftColumn->Add(new Choice(k->T("Clear All")))->OnClick.Handle(this, &ControlMappingScreen::OnClearMapping); leftColumn->Add(new Choice(k->T("Default All")))->OnClick.Handle(this, &ControlMappingScreen::OnDefaultMapping); leftColumn->Add(new Spacer(new LinearLayoutParams(1.0f))); - leftColumn->Add(new Choice(d->T("Back")))->OnClick.Handle(this, &ControlMappingScreen::OnBack); + leftColumn->Add(new Choice(d->T("Back")))->OnClick.Handle(this, &UIScreen::OnBack); /* ChoiceStrip *mode = leftColumn->Add(new ChoiceStrip(ORIENT_VERTICAL)); mode->AddChoice("Replace"); @@ -223,17 +223,6 @@ void ControlMappingScreen::sendMessage(const char *message, const char *value) { } } -UI::EventReturn ControlMappingScreen::OnBack(UI::EventParams &e) { - // If we're in-game, return to the game via DR_CANCEL. - if(PSP_IsInited()) { - screenManager()->finishDialog(this, DR_CANCEL); - } else { - screenManager()->finishDialog(this, DR_OK); - } - - return UI::EVENT_DONE; -} - UI::EventReturn ControlMappingScreen::OnClearMapping(UI::EventParams ¶ms) { KeyMap::g_controllerMap.clear(); RecreateViews(); diff --git a/UI/ControlMappingScreen.h b/UI/ControlMappingScreen.h index a8a489648c..0a56f125ba 100644 --- a/UI/ControlMappingScreen.h +++ b/UI/ControlMappingScreen.h @@ -29,7 +29,6 @@ public: protected: virtual void CreateViews(); virtual void sendMessage(const char *message, const char *value); - virtual UI::EventReturn OnBack(UI::EventParams &e); private: UI::EventReturn OnDefaultMapping(UI::EventParams ¶ms); diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index 4ef77467bd..7c60eb2a23 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -58,7 +58,7 @@ void GameSettingsScreen::CreateViews() { GameInfo *info = g_gameInfoCache.GetInfo(gamePath_, true); cap60FPS_ = g_Config.iForceMaxEmulatedFPS == 60; - + iAlternateSpeedPercent_ = 3; for (int i = 0; i < 8; i++) { if (g_Config.iFpsLimit <= alternateSpeedTable[i]) { @@ -394,18 +394,6 @@ void GameSettingsScreen::onFinish(DialogResult result) { KeyMap::UpdateConfirmCancelKeys(); } -UI::EventReturn GameSettingsScreen::OnBack(UI::EventParams &e) { - // If we're in-game, return to the game via DR_CANCEL. - if (PSP_IsInited()) { - screenManager()->finishDialog(this, DR_CANCEL); - host->UpdateScreen(); - } else { - screenManager()->finishDialog(this, DR_OK); - } - - return UI::EVENT_DONE; -} - /* void GlobalSettingsScreen::CreateViews() { using namespace UI; @@ -524,6 +512,7 @@ void DeveloperToolsScreen::CreateViews() { 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); + list->Add(new ItemHeader("")); list->Add(new Choice(d->T("Back")))->OnClick.Handle(this, &UIScreen::OnBack); } diff --git a/UI/GameSettingsScreen.h b/UI/GameSettingsScreen.h index 89dbd35323..1c36418601 100644 --- a/UI/GameSettingsScreen.h +++ b/UI/GameSettingsScreen.h @@ -52,11 +52,9 @@ private: UI::EventReturn OnControlMapping(UI::EventParams &e); UI::EventReturn OnTouchControlLayout(UI::EventParams &e); UI::EventReturn OnDumpNextFrameToLog(UI::EventParams &e); - UI::EventReturn OnBack(UI::EventParams &e); UI::EventReturn OnReloadCheats(UI::EventParams &e); UI::EventReturn OnToggleTouchControls(UI::EventParams &e); UI::EventReturn OnTiltAnalogSettings(UI::EventParams &e); - // Global settings handlers UI::EventReturn OnLanguage(UI::EventParams &e); diff --git a/UI/MainScreen.cpp b/UI/MainScreen.cpp index d2a9b5a31e..233f79cd8d 100644 --- a/UI/MainScreen.cpp +++ b/UI/MainScreen.cpp @@ -778,9 +778,10 @@ void GamePauseScreen::CreateViews() { ViewGroup *rightColumn = new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(300, FILL_PARENT, actionMenuMargins)); root_->Add(rightColumn); - ViewGroup *rightColumnItems = new LinearLayout(ORIENT_VERTICAL); + LinearLayout *rightColumnItems = new LinearLayout(ORIENT_VERTICAL); rightColumn->Add(rightColumnItems); + rightColumnItems->SetSpacing(0.0f); rightColumnItems->Add(new Choice(i->T("Continue")))->OnClick.Handle(this, &UIScreen::OnBack); rightColumnItems->Add(new Choice(i->T("Game Settings")))->OnClick.Handle(this, &GamePauseScreen::OnGameSettings); if (g_Config.bEnableCheats) { @@ -794,7 +795,7 @@ void GamePauseScreen::CreateViews() { } UI::EventReturn GamePauseScreen::OnGameSettings(UI::EventParams &e) { - screenManager()->push(new GameSettingsScreen(gamePath_)); + screenManager()->push(new GameSettingsScreen(gamePath_)); return UI::EVENT_DONE; } diff --git a/UI/MainScreen.h b/UI/MainScreen.h index a690defad1..bdac77ca83 100644 --- a/UI/MainScreen.h +++ b/UI/MainScreen.h @@ -55,7 +55,7 @@ private: class GamePauseScreen : public UIDialogScreen { public: GamePauseScreen(const std::string &filename) : UIDialogScreen(), gamePath_(filename), saveSlots_(NULL) {} - ~GamePauseScreen(); + virtual ~GamePauseScreen(); virtual void onFinish(DialogResult result); diff --git a/UI/TiltAnalogSettingsScreen.cpp b/UI/TiltAnalogSettingsScreen.cpp index 532bd11300..5fedd197e7 100644 --- a/UI/TiltAnalogSettingsScreen.cpp +++ b/UI/TiltAnalogSettingsScreen.cpp @@ -3,19 +3,16 @@ #include "Core/System.h" #include "i18n/i18n.h" -TiltAnalogSettingsScreen::TiltAnalogSettingsScreen() : currentTiltX_(0), currentTiltY_(0) {}; - void TiltAnalogSettingsScreen::CreateViews() { using namespace UI; I18NCategory *c = GetI18NCategory("Controls"); - root_ = root_ = new ScrollView(ORIENT_VERTICAL); + root_ = new ScrollView(ORIENT_VERTICAL); LinearLayout *settings = new LinearLayout(ORIENT_VERTICAL); - settings->SetSpacing(0); - + settings->SetSpacing(0); settings->Add(new ItemHeader(c->T("Invert Axes"))); settings->Add(new CheckBox(&g_Config.bInvertTiltX, c->T("Invert Tilt along X axis"))); settings->Add(new CheckBox(&g_Config.bInvertTiltY, c->T("Invert Tilt along Y axis"))); @@ -25,7 +22,6 @@ void TiltAnalogSettingsScreen::CreateViews() { settings->Add(new PopupSliderChoice(&g_Config.iTiltSensitivityX, 0, 100, c->T("Tilt Sensitivity along X axis"), screenManager())); settings->Add(new PopupSliderChoice(&g_Config.iTiltSensitivityY, 0, 100, c->T("Tilt Sensitivity along Y axis"), screenManager())); settings->Add(new PopupSliderChoiceFloat(&g_Config.fDeadzoneRadius, 0.0, 1.0, c->T("Deadzone Radius"), screenManager())); - settings->Add(new ItemHeader(c->T("Calibration"))); InfoItem *calibrationInfo = new InfoItem("To calibrate, keep device on a flat surface and press calibrate.", ""); @@ -48,18 +44,6 @@ void TiltAnalogSettingsScreen::update(InputState &input) { currentTiltY_ = input.acc.x; }; - -UI::EventReturn TiltAnalogSettingsScreen::OnBack(UI::EventParams &e) { - if (PSP_IsInited()) { - screenManager()->finishDialog(this, DR_CANCEL); - } else { - screenManager()->finishDialog(this, DR_OK); - } - - return UI::EVENT_DONE; -}; - - UI::EventReturn TiltAnalogSettingsScreen::OnCalibrate(UI::EventParams &e) { g_Config.fTiltBaseX = currentTiltX_; g_Config.fTiltBaseY = currentTiltY_; diff --git a/UI/TiltAnalogSettingsScreen.h b/UI/TiltAnalogSettingsScreen.h index d8353d34d3..59e43cb1ae 100644 --- a/UI/TiltAnalogSettingsScreen.h +++ b/UI/TiltAnalogSettingsScreen.h @@ -23,12 +23,10 @@ class TiltAnalogSettingsScreen : public UIDialogScreenWithBackground { public: - TiltAnalogSettingsScreen(); + TiltAnalogSettingsScreen() : currentTiltX_(0), currentTiltY_(0) {} virtual void CreateViews(); virtual void update(InputState &input); -protected: - virtual UI::EventReturn OnBack(UI::EventParams &e); private: UI::EventReturn OnCalibrate(UI::EventParams &e); float currentTiltX_, currentTiltY_; diff --git a/UI/TouchControlLayoutScreen.cpp b/UI/TouchControlLayoutScreen.cpp index 1a0d839986..95da6686dc 100644 --- a/UI/TouchControlLayoutScreen.cpp +++ b/UI/TouchControlLayoutScreen.cpp @@ -225,20 +225,6 @@ void TouchControlLayoutScreen::touch(const TouchInput &touch) { } }; - - -UI::EventReturn TouchControlLayoutScreen::OnBack(UI::EventParams &e) { - - // Hm, wtf? - if (PSP_IsInited()) { - screenManager()->finishDialog(this, DR_CANCEL); - } else { - screenManager()->finishDialog(this, DR_OK); - } - - return UI::EVENT_DONE; -}; - void TouchControlLayoutScreen::onFinish(DialogResult reason) { g_Config.Save(); } @@ -291,7 +277,7 @@ void TouchControlLayoutScreen::CreateViews() { Choice *back = new Choice(d->T("Back"), "", false, new AnchorLayoutParams(leftMargin, WRAP_CONTENT, 10, NONE, NONE, 10)); Choice *visibility = new Choice(c->T("Visibility"), "", false, new AnchorLayoutParams(leftMargin, WRAP_CONTENT, 10, NONE, NONE, 158)); reset->OnClick.Handle(this, &TouchControlLayoutScreen::OnReset); - back->OnClick.Handle(this, &TouchControlLayoutScreen::OnBack); + back->OnClick.Handle(this, &UIScreen::OnBack); visibility->OnClick.Handle(this, &TouchControlLayoutScreen::OnVisibility); root_->Add(visibility); root_->Add(reset); @@ -300,9 +286,9 @@ void TouchControlLayoutScreen::CreateViews() { TabHolder *tabHolder = new TabHolder(ORIENT_VERTICAL, leftMargin, new AnchorLayoutParams(10, 0, 10, 0, false)); root_->Add(tabHolder); - //this is more for show than anything else. It's used to provide a boundary - //so that buttons like back can be placed within the boundary. - //serves no other purpose. + // this is more for show than anything else. It's used to provide a boundary + // so that buttons like back can be placed within the boundary. + // serves no other purpose. AnchorLayout *controlsHolder = new AnchorLayout(new LayoutParams(FILL_PARENT, FILL_PARENT)); I18NCategory *ms = GetI18NCategory("MainSettings"); diff --git a/UI/TouchControlLayoutScreen.h b/UI/TouchControlLayoutScreen.h index 8db09235b7..728361b5cc 100644 --- a/UI/TouchControlLayoutScreen.h +++ b/UI/TouchControlLayoutScreen.h @@ -34,7 +34,6 @@ public: virtual void onFinish(DialogResult reason); protected: - virtual UI::EventReturn OnBack(UI::EventParams &e); virtual UI::EventReturn OnReset(UI::EventParams &e); virtual UI::EventReturn OnVisibility(UI::EventParams &e);