diff --git a/Common/Net/HTTPServer.cpp b/Common/Net/HTTPServer.cpp index 36f5b665bd..a4e19d805b 100644 --- a/Common/Net/HTTPServer.cpp +++ b/Common/Net/HTTPServer.cpp @@ -81,7 +81,7 @@ ServerRequest::~ServerRequest() { } delete in_; if (!out_->Empty()) { - WARN_LOG(IO, "Output not empty - connection abort? (%s) (%d bytes)", this->header_.resource, out_->BytesRemaining()); + WARN_LOG(IO, "Output not empty - connection abort? (%s) (%d bytes)", this->header_.resource, (int)out_->BytesRemaining()); } delete out_; } diff --git a/Common/UI/PopupScreens.h b/Common/UI/PopupScreens.h index 8e237bca23..213206b6bc 100644 --- a/Common/UI/PopupScreens.h +++ b/Common/UI/PopupScreens.h @@ -191,27 +191,6 @@ private: std::vector enabled_; }; -class AbstractChoiceWithValueDisplay : public UI::Choice { -public: - AbstractChoiceWithValueDisplay(const std::string &text, LayoutParams *layoutParams = nullptr) - : Choice(text, layoutParams) { - } - - void Draw(UIContext &dc) override; - void GetContentDimensionsBySpec(const UIContext &dc, MeasureSpec horiz, MeasureSpec vert, float &w, float &h) const override; - - void SetPasswordDisplay() { - passwordDisplay_ = true; - } - -protected: - virtual std::string ValueText() const = 0; - - float CalculateValueScale(const UIContext &dc, const std::string &valueText, float availWidth) const; - - bool passwordDisplay_ = false; -}; - // Reads and writes value to determine the current selection. class PopupMultiChoice : public AbstractChoiceWithValueDisplay { public: diff --git a/Common/UI/View.h b/Common/UI/View.h index a84b68a38b..8ba09a00e9 100644 --- a/Common/UI/View.h +++ b/Common/UI/View.h @@ -810,6 +810,38 @@ private: bool choiceStyle_ = false; }; +class AbstractChoiceWithValueDisplay : public Choice { +public: + AbstractChoiceWithValueDisplay(const std::string &text, LayoutParams *layoutParams = nullptr) + : Choice(text, layoutParams) { + } + + void Draw(UIContext &dc) override; + void GetContentDimensionsBySpec(const UIContext &dc, MeasureSpec horiz, MeasureSpec vert, float &w, float &h) const override; + + void SetPasswordDisplay() { + passwordDisplay_ = true; + } + +protected: + virtual std::string ValueText() const = 0; + + float CalculateValueScale(const UIContext &dc, const std::string &valueText, float availWidth) const; + + bool passwordDisplay_ = false; +}; + +class ChoiceWithCallbackValueDisplay : public AbstractChoiceWithValueDisplay { +public: + ChoiceWithCallbackValueDisplay(const std::string &text, std::function valueFunc, LayoutParams *layoutParams = nullptr) + : AbstractChoiceWithValueDisplay(text, layoutParams), valueFunc_(valueFunc) {} +protected: + std::string ValueText() const override { + return valueFunc_(); + } + std::function valueFunc_; +}; + class ItemHeader : public Item { public: ItemHeader(const std::string &text, LayoutParams *layoutParams = 0); diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index 5691479663..bbc4008769 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -679,7 +679,14 @@ void GameSettingsScreen::CreateControlsSettings(UI::ViewGroup *controlsSettings) #endif if (System_GetPropertyBool(SYSPROP_HAS_ACCELEROMETER)) { - Choice *customizeTilt = controlsSettings->Add(new Choice(co->T("Tilt control setup"))); + // Show the tilt type on the item. + Choice *customizeTilt = controlsSettings->Add(new ChoiceWithCallbackValueDisplay(co->T("Tilt control setup"), []() -> std::string { + auto co = GetI18NCategory(I18NCat::CONTROLS); + if ((u32)g_Config.iTiltInputType < (u32)g_numTiltTypes) { + return co->T(g_tiltTypes[g_Config.iTiltInputType]); + } + return ""; + })); customizeTilt->OnClick.Handle(this, &GameSettingsScreen::OnTiltCustomize); } else if (System_GetPropertyInt(SYSPROP_DEVICE_TYPE) == DEVICE_TYPE_VR) { // TODO: This seems like a regression controlsSettings->Add(new CheckBox(&g_Config.bHapticFeedback, co->T("HapticFeedback", "Haptic Feedback (vibration)"))); diff --git a/UI/TiltAnalogSettingsScreen.cpp b/UI/TiltAnalogSettingsScreen.cpp index 1488f75e2b..b0cff83dea 100644 --- a/UI/TiltAnalogSettingsScreen.cpp +++ b/UI/TiltAnalogSettingsScreen.cpp @@ -28,6 +28,9 @@ #include "UI/GamepadEmu.h" #include "UI/TiltAnalogSettingsScreen.h" +const char *g_tiltTypes[] = { "None (Disabled)", "Analog Stick", "D-PAD", "PSP Action Buttons", "L/R Trigger Buttons" }; +const size_t g_numTiltTypes = ARRAY_SIZE(g_tiltTypes); + void TiltAnalogSettingsScreen::CreateViews() { using namespace UI; @@ -100,9 +103,8 @@ void TiltAnalogSettingsScreen::CreateViews() { settings->SetSpacing(0); - static const char *tiltTypes[] = { "None (Disabled)", "Analog Stick", "D-PAD", "PSP Action Buttons", "L/R Trigger Buttons" }; settings->Add(new ItemHeader(co->T("Tilt control setup"))); - settings->Add(new PopupMultiChoice(&g_Config.iTiltInputType, co->T("Tilt Input Type"), tiltTypes, 0, ARRAY_SIZE(tiltTypes), I18NCat::CONTROLS, screenManager()))->OnChoice.Add( + settings->Add(new PopupMultiChoice(&g_Config.iTiltInputType, co->T("Tilt Input Type"), g_tiltTypes, 0, g_numTiltTypes, I18NCat::CONTROLS, screenManager()))->OnChoice.Add( [=](UI::EventParams &p) { //when the tilt event type is modified, we need to reset all tilt settings. //refer to the ResetTiltEvents() function for a detailed explanation. diff --git a/UI/TiltAnalogSettingsScreen.h b/UI/TiltAnalogSettingsScreen.h index b1416cfb69..eb444bd522 100644 --- a/UI/TiltAnalogSettingsScreen.h +++ b/UI/TiltAnalogSettingsScreen.h @@ -39,3 +39,6 @@ private: JoystickHistoryView *tilt_ = nullptr; GamepadView *gpView_ = nullptr; }; + +extern const char *g_tiltTypes[]; +extern const size_t g_numTiltTypes;