mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-01 14:58:14 +00:00
Fix rendering of the hold-overlay for main screen buttons without icons
This commit is contained in:
1 parent
e6a2a36bb8
commit
fb4d2a0f3f
3 files changed
+33
-16
No files matched your search
@@ -43,6 +43,18 @@ uint32_t colorBlend(uint32_t rgb1, uint32_t rgb2, float alpha) {
|
||||
return c;
|
||||
}
|
||||
|
||||
uint32_t colorAdd(uint32_t color, uint32_t color2) {
|
||||
const int r = (int)((color >> 0) & 0xFF) + (int)((color2 >> 0) & 0xFF);
|
||||
const int g = (int)((color >> 8) & 0xFF) + (int)((color2 >> 8) & 0xFF);
|
||||
const int b = (int)((color >> 16) & 0xFF) + (int)((color2 >> 16) & 0xFF);
|
||||
const int a = (int)((color >> 24) & 0xFF) + (int)((color2 >> 24) & 0xFF);
|
||||
uint32_t c = clamp(a, 0, 255) << 24;
|
||||
c |= clamp(b, 0, 255) << 16;
|
||||
c |= clamp(g, 0, 255) << 8;
|
||||
c |= clamp(r, 0, 255);
|
||||
return c;
|
||||
}
|
||||
|
||||
uint32_t alphaMul(uint32_t color, float alphaMul) {
|
||||
const uint32_t rgb = color & 0xFFFFFF;
|
||||
int32_t alpha = color >> 24;
|
||||
|
||||
@@ -6,6 +6,7 @@ uint32_t whiteAlpha(float alpha);
|
||||
uint32_t blackAlpha(float alpha);
|
||||
uint32_t colorAlpha(uint32_t color, float alpha);
|
||||
uint32_t colorBlend(uint32_t color, uint32_t color2, float alpha);
|
||||
uint32_t colorAdd(uint32_t color, uint32_t color2);
|
||||
uint32_t alphaMul(uint32_t color, float alphaMul);
|
||||
uint32_t rgba(float r, float g, float b, float alpha);
|
||||
uint32_t rgba_clamp(float r, float g, float b, float alpha);
|
||||
|
||||
+20
-16
@@ -296,6 +296,22 @@ void GameButton::Draw(UIContext &dc) {
|
||||
default: break;
|
||||
}
|
||||
|
||||
Bounds overlayBounds = bounds_;
|
||||
u32 overlayColor = 0;
|
||||
if (holdEnabled_ && holdStart_ != 0.0) {
|
||||
double time_held = time_now_d() - holdStart_;
|
||||
overlayColor = whiteAlpha(time_held / 2.5f);
|
||||
if (holdStart_ != 0.0) {
|
||||
double time_held = time_now_d() - holdStart_;
|
||||
int holdFrameCount = (int)(time_held * 60.0f);
|
||||
if (holdFrameCount > 60) {
|
||||
// Blink before launching by holding
|
||||
if (((holdFrameCount >> 3) & 1) == 0)
|
||||
overlayColor = 0x0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (imageIcon.isValid()) {
|
||||
Style style = dc.GetTheme().itemStyle;
|
||||
|
||||
@@ -305,6 +321,10 @@ void GameButton::Draw(UIContext &dc) {
|
||||
|
||||
dc.FillRect(style.background, bounds_);
|
||||
DrawIconWithText(dc, imageIcon, ginfo->GetTitle(), bounds_, gridStyle_, style);
|
||||
|
||||
if (overlayColor) {
|
||||
dc.FillRect(Drawable(overlayColor), overlayBounds);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -345,13 +365,6 @@ void GameButton::Draw(UIContext &dc) {
|
||||
int txOffset = down_ ? 4 : 0;
|
||||
if (!gridStyle_) txOffset = 0;
|
||||
|
||||
Bounds overlayBounds = bounds_;
|
||||
u32 overlayColor = 0;
|
||||
if (holdEnabled_ && holdStart_ != 0.0) {
|
||||
double time_held = time_now_d() - holdStart_;
|
||||
overlayColor = whiteAlpha(time_held / 2.5f);
|
||||
}
|
||||
|
||||
// Render button
|
||||
int dropsize = 10;
|
||||
if (texture) {
|
||||
@@ -378,15 +391,6 @@ void GameButton::Draw(UIContext &dc) {
|
||||
|
||||
dc.Draw()->Flush();
|
||||
dc.GetDrawContext()->BindTexture(0, texture);
|
||||
if (holdStart_ != 0.0) {
|
||||
double time_held = time_now_d() - holdStart_;
|
||||
int holdFrameCount = (int)(time_held * 60.0f);
|
||||
if (holdFrameCount > 60) {
|
||||
// Blink before launching by holding
|
||||
if (((holdFrameCount >> 3) & 1) == 0)
|
||||
color = darkenColor(color);
|
||||
}
|
||||
}
|
||||
dc.Draw()->DrawTexRect(x, y, x+w, y+h, 0, 0, 1, 1, color);
|
||||
dc.Draw()->Flush();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user