mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Finish previous commit
This commit is contained in:
parent
4609df40c9
commit
63181374c7
4 changed files with 28 additions and 39 deletions
|
@ -42,11 +42,15 @@ static uint32_t analogPointerMask = 0;
|
|||
static float g_gamepadOpacity;
|
||||
static double g_lastTouch;
|
||||
|
||||
void GamepadUpdateOpacity() {
|
||||
void GamepadUpdateOpacity(float force) {
|
||||
if (coreState != CORE_RUNNING) {
|
||||
g_gamepadOpacity = 0.0f;
|
||||
return;
|
||||
}
|
||||
if (force >= 0.0f) {
|
||||
g_gamepadOpacity = force;
|
||||
return;
|
||||
}
|
||||
|
||||
float fadeAfterSeconds = g_Config.iTouchButtonHideSeconds;
|
||||
float fadeTransitionSeconds = std::min(fadeAfterSeconds, 0.5f);
|
||||
|
@ -70,6 +74,10 @@ void GamepadTouch() {
|
|||
g_lastTouch = time_now_d();
|
||||
}
|
||||
|
||||
float GamepadGetOpacity() {
|
||||
return g_gamepadOpacity;
|
||||
}
|
||||
|
||||
static u32 GetButtonColor() {
|
||||
return g_Config.iTouchButtonStyle != 0 ? 0xFFFFFF : 0xc0b080;
|
||||
}
|
||||
|
@ -81,13 +89,6 @@ std::string GamepadView::DescribeText() const {
|
|||
return co->T(key_);
|
||||
}
|
||||
|
||||
float GamepadView::GetButtonOpacity() {
|
||||
if (forceVisible_) {
|
||||
return 1.0f;
|
||||
}
|
||||
return g_gamepadOpacity;
|
||||
}
|
||||
|
||||
void MultiTouchButton::GetContentDimensions(const UIContext &dc, float &w, float &h) const {
|
||||
const AtlasImage *image = dc.Draw()->GetAtlas()->getImage(bgImg_);
|
||||
if (image) {
|
||||
|
@ -123,7 +124,7 @@ bool MultiTouchButton::Touch(const TouchInput &input) {
|
|||
}
|
||||
|
||||
void MultiTouchButton::Draw(UIContext &dc) {
|
||||
float opacity = GetButtonOpacity();
|
||||
float opacity = g_gamepadOpacity;
|
||||
if (opacity <= 0.0f)
|
||||
return;
|
||||
|
||||
|
@ -367,7 +368,7 @@ void PSPDpad::ProcessTouch(float x, float y, bool down) {
|
|||
}
|
||||
|
||||
void PSPDpad::Draw(UIContext &dc) {
|
||||
float opacity = GetButtonOpacity();
|
||||
float opacity = g_gamepadOpacity;
|
||||
if (opacity <= 0.0f)
|
||||
return;
|
||||
|
||||
|
@ -417,7 +418,7 @@ void PSPStick::GetContentDimensions(const UIContext &dc, float &w, float &h) con
|
|||
}
|
||||
|
||||
void PSPStick::Draw(UIContext &dc) {
|
||||
float opacity = GetButtonOpacity();
|
||||
float opacity = g_gamepadOpacity;
|
||||
if (opacity <= 0.0f)
|
||||
return;
|
||||
|
||||
|
@ -525,7 +526,7 @@ PSPCustomStick::PSPCustomStick(ImageID bgImg, const char *key, ImageID stickImg,
|
|||
}
|
||||
|
||||
void PSPCustomStick::Draw(UIContext &dc) {
|
||||
float opacity = GetButtonOpacity();
|
||||
float opacity = g_gamepadOpacity;
|
||||
if (opacity <= 0.0f)
|
||||
return;
|
||||
|
||||
|
@ -952,7 +953,6 @@ void GestureGamepad::Draw(UIContext &dc) {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
void GestureGamepad::Update() {
|
||||
const float th = 1.0f;
|
||||
float dx = deltaX_ * g_display.dpi_scale_x * g_Config.fSwipeSensitivity;
|
||||
|
|
|
@ -35,16 +35,8 @@ public:
|
|||
}
|
||||
std::string DescribeText() const override;
|
||||
|
||||
void SetForceVisible(bool visible) {
|
||||
forceVisible_ = visible;
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual float GetButtonOpacity();
|
||||
|
||||
std::string key_;
|
||||
float secondsWithoutTouch_ = 0.0;
|
||||
bool forceVisible_ = false;
|
||||
};
|
||||
|
||||
class MultiTouchButton : public GamepadView {
|
||||
|
@ -378,4 +370,5 @@ namespace GestureKey {
|
|||
}
|
||||
|
||||
void GamepadTouch();
|
||||
void GamepadUpdateOpacity();
|
||||
void GamepadUpdateOpacity(float force = -1.0f);
|
||||
float GamepadGetOpacity();
|
||||
|
|
|
@ -53,6 +53,8 @@ void TiltAnalogSettingsScreen::CreateViews() {
|
|||
menuRoot->Add(settings);
|
||||
}
|
||||
|
||||
GamepadUpdateOpacity(1.0f);
|
||||
|
||||
if (g_Config.iTiltInputType == TILT_ANALOG) {
|
||||
tilt_ = new JoystickHistoryView(StickHistoryViewType::OTHER, "", new LinearLayoutParams(1.0f));
|
||||
root_->Add(tilt_);
|
||||
|
@ -64,7 +66,6 @@ void TiltAnalogSettingsScreen::CreateViews() {
|
|||
case TILT_DPAD:
|
||||
{
|
||||
PSPDpad *pad = rightSide->Add(new PSPDpad(ImageID("I_DIR_LINE"), "D-pad", ImageID("I_DIR_LINE"), ImageID("I_ARROW"), 1.5f, 1.3f, new AnchorLayoutParams(NONE, NONE, NONE, NONE, true)));
|
||||
pad->SetForceVisible(true);
|
||||
break;
|
||||
}
|
||||
case TILT_ACTION_BUTTON:
|
||||
|
@ -73,10 +74,6 @@ void TiltAnalogSettingsScreen::CreateViews() {
|
|||
PSPButton *cross= new PSPButton(CTRL_CROSS, "Cross button", ImageID("I_ROUND_LINE"), ImageID("I_ROUND"), ImageID("I_CROSS"), 1.5f, new AnchorLayoutParams(NONE, NONE, NONE, 100.0f, true));
|
||||
PSPButton *triangle = new PSPButton(CTRL_TRIANGLE, "Triangle button", ImageID("I_ROUND_LINE"), ImageID("I_ROUND"), ImageID("I_TRIANGLE"), 1.5f, new AnchorLayoutParams(NONE, 100.0f, NONE, NONE, true));
|
||||
PSPButton *square = new PSPButton(CTRL_SQUARE, "Square button", ImageID("I_ROUND_LINE"), ImageID("I_ROUND"), ImageID("I_SQUARE"), 1.5f, new AnchorLayoutParams(100.0f, NONE, NONE, NONE, true));
|
||||
circle->SetForceVisible(true);
|
||||
cross->SetForceVisible(true);
|
||||
triangle->SetForceVisible(true);
|
||||
square->SetForceVisible(true);
|
||||
rightSide->Add(circle);
|
||||
rightSide->Add(cross);
|
||||
rightSide->Add(triangle);
|
||||
|
@ -88,8 +85,6 @@ void TiltAnalogSettingsScreen::CreateViews() {
|
|||
PSPButton *lTrigger = new PSPButton(CTRL_LTRIGGER, "Left shoulder button", ImageID("I_SHOULDER_LINE"), ImageID("I_SHOULDER"), ImageID("I_L"), 1.5f, new AnchorLayoutParams(100.0f, NONE, NONE, NONE, true));
|
||||
PSPButton *rTrigger = new PSPButton(CTRL_RTRIGGER, "Right shoulder button", ImageID("I_SHOULDER_LINE"), ImageID("I_SHOULDER"), ImageID("I_R"), 1.5f, new AnchorLayoutParams(NONE, NONE, 100.0f, NONE, true));
|
||||
rTrigger->FlipImageH(true);
|
||||
lTrigger->SetForceVisible(true);
|
||||
rTrigger->SetForceVisible(true);
|
||||
rightSide->Add(lTrigger);
|
||||
rightSide->Add(rTrigger);
|
||||
break;
|
||||
|
|
|
@ -81,10 +81,6 @@ public:
|
|||
}
|
||||
|
||||
protected:
|
||||
float GetButtonOpacity() override {
|
||||
float opacity = g_Config.iTouchButtonOpacity / 100.0f;
|
||||
return std::max(0.5f, opacity);
|
||||
}
|
||||
const Bounds &screenBounds_;
|
||||
float &theScale_;
|
||||
float &x_, &y_;
|
||||
|
@ -116,8 +112,9 @@ public:
|
|||
|
||||
void Draw(UIContext &dc) override {
|
||||
scale_ = theScale_*layoutAreaScale;
|
||||
uint32_t colorBg = colorAlpha(GetButtonColor(), GetButtonOpacity());
|
||||
uint32_t color = colorAlpha(0xFFFFFF, GetButtonOpacity());
|
||||
float opacity = GamepadGetOpacity();
|
||||
uint32_t colorBg = colorAlpha(GetButtonColor(), opacity);
|
||||
uint32_t color = colorAlpha(0xFFFFFF, opacity);
|
||||
|
||||
int centerX = bounds_.centerX();
|
||||
int centerY = bounds_.centerY();
|
||||
|
@ -244,8 +241,9 @@ public:
|
|||
|
||||
void Draw(UIContext &dc) override {
|
||||
scale_ = theScale_*layoutAreaScale;
|
||||
uint32_t colorBg = colorAlpha(GetButtonColor(), GetButtonOpacity());
|
||||
uint32_t color = colorAlpha(0xFFFFFF, GetButtonOpacity());
|
||||
float opacity = GamepadGetOpacity();
|
||||
uint32_t colorBg = colorAlpha(GetButtonColor(), opacity);
|
||||
uint32_t color = colorAlpha(0xFFFFFF, opacity);
|
||||
|
||||
static const float xoff[4] = {1, 0, -1, 0};
|
||||
static const float yoff[4] = {0, 1, 0, -1};
|
||||
|
@ -286,8 +284,9 @@ public:
|
|||
}
|
||||
|
||||
void Draw(UIContext &dc) override {
|
||||
uint32_t colorBg = colorAlpha(GetButtonColor(), GetButtonOpacity());
|
||||
uint32_t downBg = colorAlpha(0x00FFFFFF, GetButtonOpacity() * 0.5f);
|
||||
float opacity = GamepadGetOpacity();
|
||||
uint32_t colorBg = colorAlpha(GetButtonColor(), opacity);
|
||||
uint32_t downBg = colorAlpha(0x00FFFFFF, opacity * 0.5f);
|
||||
|
||||
const ImageID stickImage = g_Config.iTouchButtonStyle ? ImageID("I_STICK_LINE") : ImageID("I_STICK");
|
||||
const ImageID stickBg = g_Config.iTouchButtonStyle ? ImageID("I_STICK_BG_LINE") : ImageID("I_STICK_BG");
|
||||
|
@ -447,6 +446,8 @@ bool ControlLayoutView::Touch(const TouchInput &touch) {
|
|||
}
|
||||
|
||||
void ControlLayoutView::Draw(UIContext& dc) {
|
||||
float opacity = g_Config.iTouchButtonOpacity / 100.0f;
|
||||
GamepadUpdateOpacity(std::max(0.5f, opacity));
|
||||
using namespace UI;
|
||||
dc.FillRect(Drawable(0x80000000), bounds_);
|
||||
dc.Flush();
|
||||
|
|
Loading…
Add table
Reference in a new issue