mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-11-22 21:09:52 +00:00
Show the tilt input type directly on the item that goes to the tilt settings
This commit is contained in:
parent
e3177ac870
commit
f42e9d94a3
@ -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_;
|
||||
}
|
||||
|
@ -191,27 +191,6 @@ private:
|
||||
std::vector<bool> 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:
|
||||
|
@ -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<std::string()> valueFunc, LayoutParams *layoutParams = nullptr)
|
||||
: AbstractChoiceWithValueDisplay(text, layoutParams), valueFunc_(valueFunc) {}
|
||||
protected:
|
||||
std::string ValueText() const override {
|
||||
return valueFunc_();
|
||||
}
|
||||
std::function<std::string()> valueFunc_;
|
||||
};
|
||||
|
||||
class ItemHeader : public Item {
|
||||
public:
|
||||
ItemHeader(const std::string &text, LayoutParams *layoutParams = 0);
|
||||
|
@ -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)")));
|
||||
|
@ -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.
|
||||
|
@ -39,3 +39,6 @@ private:
|
||||
JoystickHistoryView *tilt_ = nullptr;
|
||||
GamepadView *gpView_ = nullptr;
|
||||
};
|
||||
|
||||
extern const char *g_tiltTypes[];
|
||||
extern const size_t g_numTiltTypes;
|
||||
|
Loading…
Reference in New Issue
Block a user