tidy-fix automàtic (sense naming)
This commit is contained in:
+114
-72
@@ -1,5 +1,6 @@
|
||||
#include "core/rendering/menu.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <cstdio>
|
||||
#include <functional>
|
||||
@@ -72,16 +73,20 @@ namespace Menu {
|
||||
std::string subtitle; // opcional — si no buit, es dibuixa sota el títol
|
||||
};
|
||||
|
||||
static bool isVisible(const Item& it) { return !it.visible || it.visible(); }
|
||||
static auto isVisible(const Item& it) -> bool { return !it.visible || it.visible(); }
|
||||
|
||||
// Troba el pròxim ítem visible en direcció `dir` (±1) a partir de `from`.
|
||||
// Si cap és visible retorna `from`.
|
||||
static int nextVisibleCursor(const Page& p, int from, int dir) {
|
||||
static auto nextVisibleCursor(const Page& p, int from, int dir) -> int {
|
||||
const int n = static_cast<int>(p.items.size());
|
||||
if (n <= 0) return from;
|
||||
if (n <= 0) {
|
||||
return from;
|
||||
}
|
||||
for (int i = 1; i <= n; ++i) {
|
||||
int idx = ((from + dir * i) % n + n) % n;
|
||||
if (isVisible(p.items[idx])) return idx;
|
||||
if (isVisible(p.items[idx])) {
|
||||
return idx;
|
||||
}
|
||||
}
|
||||
return from;
|
||||
}
|
||||
@@ -97,7 +102,7 @@ namespace Menu {
|
||||
|
||||
// --- Transició entre pàgines ---
|
||||
static constexpr float TRANSITION_SPEED = 5.5F; // ~180 ms
|
||||
static Page transition_outgoing_{"", {}, 0};
|
||||
static Page transition_outgoing_{.title = "", .items = {}, .cursor = 0};
|
||||
static bool transition_active_{false};
|
||||
static float transition_progress_{1.0F};
|
||||
static int transition_dir_{+1}; // +1 endavant, -1 enrere
|
||||
@@ -120,19 +125,19 @@ namespace Menu {
|
||||
|
||||
// --- Helpers ---
|
||||
|
||||
static std::string yesNo(bool b) { return b ? Locale::get("menu.values.yes") : Locale::get("menu.values.no"); }
|
||||
static std::string onOff(bool b) { return b ? Locale::get("menu.values.on") : Locale::get("menu.values.off"); }
|
||||
static auto yesNo(bool b) -> std::string { return b ? Locale::get("menu.values.yes") : Locale::get("menu.values.no"); }
|
||||
static auto onOff(bool b) -> std::string { return b ? Locale::get("menu.values.on") : Locale::get("menu.values.off"); }
|
||||
|
||||
// --- Builders de pàgines ---
|
||||
|
||||
static Page buildVideo();
|
||||
static Page buildAudio();
|
||||
static Page buildControls();
|
||||
static Page buildGame();
|
||||
static Page buildSystem();
|
||||
static auto buildVideo() -> Page;
|
||||
static auto buildAudio() -> Page;
|
||||
static auto buildControls() -> Page;
|
||||
static auto buildGame() -> Page;
|
||||
static auto buildSystem() -> Page;
|
||||
|
||||
static Page buildRoot() {
|
||||
Page p{Locale::get("menu.titles.root"), {}, 0};
|
||||
static auto buildRoot() -> Page {
|
||||
Page p{.title = Locale::get("menu.titles.root"), .items = {}, .cursor = 0};
|
||||
p.items.push_back({Locale::get("menu.items.video"), ItemKind::Submenu, nullptr, nullptr, [] { pushPage(buildVideo()); }, nullptr});
|
||||
p.items.push_back({Locale::get("menu.items.audio"), ItemKind::Submenu, nullptr, nullptr, [] { pushPage(buildAudio()); }, nullptr});
|
||||
p.items.push_back({Locale::get("menu.items.controls"), ItemKind::Submenu, nullptr, nullptr, [] { pushPage(buildControls()); }, nullptr});
|
||||
@@ -141,8 +146,8 @@ namespace Menu {
|
||||
return p;
|
||||
}
|
||||
|
||||
static Page buildVideo() {
|
||||
Page p{Locale::get("menu.titles.video"), {}, 0};
|
||||
static auto buildVideo() -> Page {
|
||||
Page p{.title = Locale::get("menu.titles.video"), .items = {}, .cursor = 0};
|
||||
|
||||
// Zoom i fullscreen: sense sentit a WASM (el navegador posseix el canvas)
|
||||
#ifndef __EMSCRIPTEN__
|
||||
@@ -150,8 +155,9 @@ namespace Menu {
|
||||
char buf[16];
|
||||
std::snprintf(buf, sizeof(buf), "%dX", Screen::get()->getZoom());
|
||||
return std::string(buf); }, [](int dir) {
|
||||
if (dir < 0) Screen::get()->decZoom();
|
||||
else if (dir > 0) Screen::get()->incZoom(); }, nullptr, nullptr});
|
||||
if (dir < 0) { Screen::get()->decZoom();
|
||||
} else if (dir > 0) { Screen::get()->incZoom();
|
||||
} }, nullptr, nullptr});
|
||||
|
||||
p.items.push_back({Locale::get("menu.items.screen"), ItemKind::Toggle, [] { return std::string(Screen::get()->isFullscreen() ? Locale::get("menu.values.fullscreen") : Locale::get("menu.values.windowed")); }, [](int) { Screen::get()->toggleFullscreen(); }, nullptr, nullptr, nullptr});
|
||||
#endif
|
||||
@@ -185,15 +191,18 @@ namespace Menu {
|
||||
p.items.push_back({Locale::get("menu.items.shader"), ItemKind::Toggle, [] { return onOff(Options::video.shader_enabled); }, [](int) { Screen::get()->toggleShaders(); }, nullptr, nullptr, nullptr});
|
||||
|
||||
p.items.push_back({Locale::get("menu.items.shader_type"), ItemKind::Cycle, [] { return std::string(Screen::get()->getActiveShaderName()); }, [](int dir) {
|
||||
if (dir < 0) Screen::get()->prevShaderType();
|
||||
else Screen::get()->nextShaderType(); }, nullptr, nullptr, [] { return Options::video.shader_enabled; }});
|
||||
if (dir < 0) { Screen::get()->prevShaderType();
|
||||
} else { Screen::get()->nextShaderType();
|
||||
} }, nullptr, nullptr, [] { return Options::video.shader_enabled; }});
|
||||
|
||||
p.items.push_back({Locale::get("menu.items.preset"), ItemKind::Cycle, [] { return std::string(Screen::get()->getCurrentPresetName()); }, [](int dir) {
|
||||
if (dir < 0) Screen::get()->prevPreset();
|
||||
else Screen::get()->nextPreset(); }, nullptr, nullptr, [] { return Options::video.shader_enabled; }});
|
||||
if (dir < 0) { Screen::get()->prevPreset();
|
||||
} else { Screen::get()->nextPreset();
|
||||
} }, nullptr, nullptr, [] { return Options::video.shader_enabled; }});
|
||||
|
||||
p.items.push_back({Locale::get("menu.items.supersampling"), ItemKind::Toggle, [] { return onOff(Options::video.supersampling); }, [](int) { Screen::get()->toggleSupersampling(); }, nullptr, nullptr, [] {
|
||||
if (!Options::video.shader_enabled) return false;
|
||||
if (!Options::video.shader_enabled) { return false;
|
||||
}
|
||||
const char* name = Screen::get()->getActiveShaderName();
|
||||
return name && std::string(name) == "POSTFX"; }});
|
||||
#endif
|
||||
@@ -213,10 +222,10 @@ namespace Menu {
|
||||
}
|
||||
|
||||
// Converteix volum 0..1 a percentatge i ho formata com "50%"
|
||||
static std::string volPct(float v) {
|
||||
int pct = static_cast<int>(v * 100.0F + 0.5F);
|
||||
if (pct < 0) pct = 0;
|
||||
if (pct > 100) pct = 100;
|
||||
static auto volPct(float v) -> std::string {
|
||||
int pct = static_cast<int>((v * 100.0F) + 0.5F);
|
||||
pct = std::max(pct, 0);
|
||||
pct = std::min(pct, 100);
|
||||
char buf[8];
|
||||
std::snprintf(buf, sizeof(buf), "%d%%", pct);
|
||||
return std::string(buf);
|
||||
@@ -225,13 +234,13 @@ namespace Menu {
|
||||
// Canvi +/- d'un volum en steps de 0.05 (5%) amb clamping
|
||||
static void stepVolume(float& v, int dir) {
|
||||
v += (dir >= 0 ? 0.05F : -0.05F);
|
||||
if (v < 0.0F) v = 0.0F;
|
||||
if (v > 1.0F) v = 1.0F;
|
||||
v = std::max(v, 0.0F);
|
||||
v = std::min(v, 1.0F);
|
||||
Options::applyAudio();
|
||||
}
|
||||
|
||||
static Page buildControls() {
|
||||
Page p{Locale::get("menu.titles.controls"), {}, 0};
|
||||
static auto buildControls() -> Page {
|
||||
Page p{.title = Locale::get("menu.titles.controls"), .items = {}, .cursor = 0};
|
||||
p.items.push_back({Locale::get("menu.items.move_up"), ItemKind::KeyBind, nullptr, nullptr, nullptr, &Options::keys_game.up});
|
||||
p.items.push_back({Locale::get("menu.items.move_down"), ItemKind::KeyBind, nullptr, nullptr, nullptr, &Options::keys_game.down});
|
||||
p.items.push_back({Locale::get("menu.items.move_left"), ItemKind::KeyBind, nullptr, nullptr, nullptr, &Options::keys_game.left});
|
||||
@@ -240,8 +249,8 @@ namespace Menu {
|
||||
return p;
|
||||
}
|
||||
|
||||
static Page buildAudio() {
|
||||
Page p{Locale::get("menu.titles.audio"), {}, 0};
|
||||
static auto buildAudio() -> Page {
|
||||
Page p{.title = Locale::get("menu.titles.audio"), .items = {}, .cursor = 0};
|
||||
|
||||
p.items.push_back({Locale::get("menu.items.master_enable"), ItemKind::Toggle, [] { return onOff(Options::audio.enabled); }, [](int) {
|
||||
Options::audio.enabled = !Options::audio.enabled;
|
||||
@@ -264,8 +273,8 @@ namespace Menu {
|
||||
return p;
|
||||
}
|
||||
|
||||
static Page buildGame() {
|
||||
Page p{Locale::get("menu.titles.game"), {}, 0};
|
||||
static auto buildGame() -> Page {
|
||||
Page p{.title = Locale::get("menu.titles.game"), .items = {}, .cursor = 0};
|
||||
|
||||
p.items.push_back({Locale::get("menu.items.use_new_logo"), ItemKind::Toggle, [] { return yesNo(Options::game.use_new_logo); }, [](int) { Options::game.use_new_logo = !Options::game.use_new_logo; }, nullptr});
|
||||
|
||||
@@ -276,19 +285,23 @@ namespace Menu {
|
||||
return p;
|
||||
}
|
||||
|
||||
static Page buildSystem() {
|
||||
Page p{Locale::get("menu.titles.system"), {}, 0};
|
||||
static auto buildSystem() -> Page {
|
||||
Page p{.title = Locale::get("menu.titles.system"), .items = {}, .cursor = 0};
|
||||
p.subtitle = std::string("v") + Texts::VERSION + " (" + Version::GIT_HASH + ")";
|
||||
|
||||
p.items.push_back({Locale::get("menu.items.restart"), ItemKind::Action, nullptr, nullptr, [] {
|
||||
if (Director::get()) Director::get()->requestRestart();
|
||||
if (Director::get()) {
|
||||
Director::get()->requestRestart();
|
||||
}
|
||||
},
|
||||
nullptr,
|
||||
nullptr});
|
||||
|
||||
#ifndef __EMSCRIPTEN__
|
||||
p.items.push_back({Locale::get("menu.items.exit_game"), ItemKind::Action, nullptr, nullptr, [] {
|
||||
if (Director::get()) Director::get()->requestQuit();
|
||||
if (Director::get()) {
|
||||
Director::get()->requestQuit();
|
||||
}
|
||||
},
|
||||
nullptr,
|
||||
nullptr});
|
||||
@@ -307,10 +320,14 @@ namespace Menu {
|
||||
const Uint8 sb = (src_argb >> 16) & 0xFF;
|
||||
const Uint8 inv = 255 - sa;
|
||||
for (int row = y; row < y + h; row++) {
|
||||
if (row < 0 || row >= SCREEN_H) continue;
|
||||
if (row < 0 || row >= SCREEN_H) {
|
||||
continue;
|
||||
}
|
||||
for (int col = x; col < x + w; col++) {
|
||||
if (col < 0 || col >= SCREEN_W) continue;
|
||||
Uint32* p = &buf[col + row * SCREEN_W];
|
||||
if (col < 0 || col >= SCREEN_W) {
|
||||
continue;
|
||||
}
|
||||
Uint32* p = &buf[col + (row * SCREEN_W)];
|
||||
Uint32 dst = *p;
|
||||
Uint8 dr = dst & 0xFF;
|
||||
Uint8 dg = (dst >> 8) & 0xFF;
|
||||
@@ -318,17 +335,21 @@ namespace Menu {
|
||||
Uint8 r = (sr * sa + dr * inv) / 255;
|
||||
Uint8 g = (sg * sa + dg * inv) / 255;
|
||||
Uint8 b = (sb * sa + db * inv) / 255;
|
||||
*p = 0xFF000000u | (static_cast<Uint32>(b) << 16) | (static_cast<Uint32>(g) << 8) | r;
|
||||
*p = 0xFF000000U | (static_cast<Uint32>(b) << 16) | (static_cast<Uint32>(g) << 8) | r;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void fillRect(Uint32* buf, int x, int y, int w, int h, Uint32 color) {
|
||||
for (int row = y; row < y + h; row++) {
|
||||
if (row < 0 || row >= SCREEN_H) continue;
|
||||
if (row < 0 || row >= SCREEN_H) {
|
||||
continue;
|
||||
}
|
||||
for (int col = x; col < x + w; col++) {
|
||||
if (col < 0 || col >= SCREEN_W) continue;
|
||||
buf[col + row * SCREEN_W] = color;
|
||||
if (col < 0 || col >= SCREEN_W) {
|
||||
continue;
|
||||
}
|
||||
buf[col + (row * SCREEN_W)] = color;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -343,12 +364,14 @@ namespace Menu {
|
||||
// Mida final de la caixa segons el nombre d'items *visibles*.
|
||||
// body = (N-1) * ITEM_SPACING + charH — així BOTTOM_PAD és el buit real
|
||||
// sota el text del darrer ítem, no un buit extra per sobre d'un "slot" buit.
|
||||
static int boxHeight(const Page& page) {
|
||||
static auto boxHeight(const Page& page) -> int {
|
||||
int n = 0;
|
||||
for (const auto& it : page.items) {
|
||||
if (isVisible(it)) ++n;
|
||||
if (isVisible(it)) {
|
||||
++n;
|
||||
}
|
||||
}
|
||||
int body = (n == 0) ? 8 : (n - 1) * ITEM_SPACING + 8;
|
||||
int body = (n == 0) ? 8 : ((n - 1) * ITEM_SPACING) + 8;
|
||||
int header = HEADER_H + (page.subtitle.empty() ? 0 : SUBTITLE_H);
|
||||
return header + body + BOTTOM_PAD;
|
||||
}
|
||||
@@ -403,7 +426,9 @@ namespace Menu {
|
||||
// render() faça decréixer open_anim_ fins a 0. En aquell moment es neteja
|
||||
// l'estat. Si es crida estant ja tancat o tancant-se, no-op.
|
||||
void close() {
|
||||
if (stack_.empty() || closing_) return;
|
||||
if (stack_.empty() || closing_) {
|
||||
return;
|
||||
}
|
||||
closing_ = true;
|
||||
capturing_ = nullptr;
|
||||
transition_active_ = false;
|
||||
@@ -416,7 +441,9 @@ namespace Menu {
|
||||
}
|
||||
|
||||
void captureKey(SDL_Scancode sc) {
|
||||
if (!capturing_) return;
|
||||
if (capturing_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
if (sc == SDL_SCANCODE_ESCAPE) {
|
||||
// Cancel·la
|
||||
capturing_ = nullptr;
|
||||
@@ -427,15 +454,18 @@ namespace Menu {
|
||||
}
|
||||
|
||||
void handleKey(SDL_Scancode sc) {
|
||||
if (!isOpen()) return;
|
||||
if (!isOpen()) {
|
||||
return;
|
||||
}
|
||||
Page& page = stack_.back();
|
||||
if (page.items.empty()) {
|
||||
// Pàgina buida — només backspace surt
|
||||
if (sc == SDL_SCANCODE_BACKSPACE) {
|
||||
if (stack_.size() > 1)
|
||||
if (stack_.size() > 1) {
|
||||
popPage();
|
||||
else
|
||||
} else {
|
||||
close();
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -467,7 +497,9 @@ namespace Menu {
|
||||
case SDL_SCANCODE_KP_ENTER:
|
||||
if (page.items[page.cursor].kind == ItemKind::Submenu ||
|
||||
page.items[page.cursor].kind == ItemKind::Action) {
|
||||
if (page.items[page.cursor].enter) page.items[page.cursor].enter();
|
||||
if (page.items[page.cursor].enter) {
|
||||
page.items[page.cursor].enter();
|
||||
}
|
||||
} else if (page.items[page.cursor].kind == ItemKind::KeyBind) {
|
||||
capturing_ = page.items[page.cursor].scancode;
|
||||
} else if (page.items[page.cursor].change) {
|
||||
@@ -475,10 +507,11 @@ namespace Menu {
|
||||
}
|
||||
break;
|
||||
case SDL_SCANCODE_BACKSPACE:
|
||||
if (stack_.size() > 1)
|
||||
if (stack_.size() > 1) {
|
||||
popPage();
|
||||
else
|
||||
} else {
|
||||
close();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -500,7 +533,7 @@ namespace Menu {
|
||||
static void renderPageContent(Uint32* pixel_data, const Page& page, int box_x, int box_y, int x_offset, int clip_x_min, int clip_x_max, int clip_y_min, int clip_y_max) {
|
||||
// Títol
|
||||
int title_w = font_->width(page.title);
|
||||
int title_x = box_x + (BOX_W - title_w) / 2 + x_offset;
|
||||
int title_x = box_x + ((BOX_W - title_w) / 2) + x_offset;
|
||||
font_->drawClipped(pixel_data, title_x, box_y + TITLE_PAD_Y, page.title, TITLE_COLOR, clip_x_min, clip_x_max, clip_y_min, clip_y_max);
|
||||
|
||||
// Línia sota el títol (també lliscada) — clippada manualment
|
||||
@@ -519,26 +552,31 @@ namespace Menu {
|
||||
int items_y = title_line_y + 4;
|
||||
if (!page.subtitle.empty()) {
|
||||
int sub_w = font_->width(page.subtitle.c_str());
|
||||
int sub_x = box_x + (BOX_W - sub_w) / 2 + x_offset;
|
||||
int sub_x = box_x + ((BOX_W - sub_w) / 2) + x_offset;
|
||||
font_->drawClipped(pixel_data, sub_x, items_y, page.subtitle.c_str(), LABEL_COLOR, clip_x_min, clip_x_max, clip_y_min, clip_y_max);
|
||||
items_y += SUBTITLE_H;
|
||||
}
|
||||
// Compta visibles — si cap, dibuixa placeholder (caixa totalment col·lapsada però oberta)
|
||||
int visible_count = 0;
|
||||
for (const auto& it : page.items)
|
||||
if (isVisible(it)) ++visible_count;
|
||||
for (const auto& it : page.items) {
|
||||
if (isVisible(it)) {
|
||||
++visible_count;
|
||||
}
|
||||
}
|
||||
if (visible_count == 0) {
|
||||
const char* empty_text = Locale::get("menu.values.empty");
|
||||
int ew = font_->width(empty_text);
|
||||
font_->drawClipped(pixel_data, box_x + (BOX_W - ew) / 2 + x_offset, items_y + 2, empty_text, EMPTY_COLOR, clip_x_min, clip_x_max, clip_y_min, clip_y_max);
|
||||
font_->drawClipped(pixel_data, box_x + ((BOX_W - ew) / 2) + x_offset, items_y + 2, empty_text, EMPTY_COLOR, clip_x_min, clip_x_max, clip_y_min, clip_y_max);
|
||||
return;
|
||||
}
|
||||
|
||||
int y_slot = 0; // índex de fila visible (independent de l'índex real de l'ítem)
|
||||
for (size_t i = 0; i < page.items.size(); i++) {
|
||||
const Item& item = page.items[i];
|
||||
if (!isVisible(item)) continue;
|
||||
int y = items_y + y_slot * ITEM_SPACING;
|
||||
if (!isVisible(item)) {
|
||||
continue;
|
||||
}
|
||||
int y = items_y + (y_slot * ITEM_SPACING);
|
||||
++y_slot;
|
||||
bool selected = (static_cast<int>(i) == page.cursor);
|
||||
Uint32 label_color = selected ? CURSOR_COLOR : LABEL_COLOR;
|
||||
@@ -546,7 +584,7 @@ namespace Menu {
|
||||
// Action: sense valor a la dreta — centrem el label amb el cursor just a l'esquerra.
|
||||
if (item.kind == ItemKind::Action) {
|
||||
int lw = font_->width(item.label);
|
||||
int lx = box_x + (BOX_W - lw) / 2 + x_offset;
|
||||
int lx = box_x + ((BOX_W - lw) / 2) + x_offset;
|
||||
if (selected) {
|
||||
font_->drawClipped(pixel_data, lx - font_->width("> "), y, ">", CURSOR_COLOR, clip_x_min, clip_x_max, clip_y_min, clip_y_max);
|
||||
}
|
||||
@@ -567,8 +605,10 @@ namespace Menu {
|
||||
font_->drawClipped(pixel_data, box_x + BOX_W - ITEM_PAD_X - aw + x_offset, y, arrow, ac, clip_x_min, clip_x_max, clip_y_min, clip_y_max);
|
||||
} else if (item.kind == ItemKind::KeyBind) {
|
||||
bool this_capturing = (capturing_ == item.scancode);
|
||||
const char* text = this_capturing ? Locale::get("menu.values.press_key") : (item.scancode ? SDL_GetScancodeName(*item.scancode) : "");
|
||||
if (!text || !*text) text = Locale::get("menu.values.unknown");
|
||||
const char* text = this_capturing ? Locale::get("menu.values.press_key") : ((item.scancode != nullptr) ? SDL_GetScancodeName(*item.scancode) : "");
|
||||
if ((text == nullptr) || (*text == 0)) {
|
||||
text = Locale::get("menu.values.unknown");
|
||||
}
|
||||
int tw = font_->width(text);
|
||||
Uint32 tc = this_capturing ? 0xFF00FFFF : (selected ? CURSOR_COLOR : VALUE_COLOR);
|
||||
font_->drawClipped(pixel_data, box_x + BOX_W - ITEM_PAD_X - tw + x_offset, y, text, tc, clip_x_min, clip_x_max, clip_y_min, clip_y_max);
|
||||
@@ -582,7 +622,9 @@ namespace Menu {
|
||||
}
|
||||
|
||||
void render(Uint32* pixel_data) {
|
||||
if (!isVisible() || !font_ || !pixel_data) return;
|
||||
if (!isVisible() || !font_ || (pixel_data == nullptr)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Delta time
|
||||
Uint32 now = SDL_GetTicks();
|
||||
@@ -600,7 +642,7 @@ namespace Menu {
|
||||
}
|
||||
} else if (open_anim_ < 1.0F) {
|
||||
open_anim_ += OPEN_SPEED * dt;
|
||||
if (open_anim_ > 1.0F) open_anim_ = 1.0F;
|
||||
open_anim_ = std::min(open_anim_, 1.0F);
|
||||
}
|
||||
|
||||
// Avança transició
|
||||
@@ -626,7 +668,7 @@ namespace Menu {
|
||||
animated_h_ = static_cast<float>(current_h);
|
||||
} else {
|
||||
float t = HEIGHT_RATE * dt;
|
||||
if (t > 1.0F) t = 1.0F;
|
||||
t = std::min(t, 1.0F);
|
||||
animated_h_ += diff * t;
|
||||
}
|
||||
}
|
||||
@@ -643,12 +685,12 @@ namespace Menu {
|
||||
|
||||
// Caixa creix verticalment durant l'obertura
|
||||
int box_h = static_cast<int>(target_h * eased);
|
||||
if (box_h < 2) box_h = 2;
|
||||
box_h = std::max(box_h, 2);
|
||||
int box_x = (SCREEN_W - BOX_W) / 2;
|
||||
int box_y = (SCREEN_H - box_h) / 2;
|
||||
|
||||
// Fons semi-transparent (alpha escalat per l'animació d'obertura)
|
||||
Uint8 alpha = static_cast<Uint8>(BG_ALPHA * eased);
|
||||
auto alpha = static_cast<Uint8>(BG_ALPHA * eased);
|
||||
blendRect(pixel_data, box_x, box_y, BOX_W, box_h, BG_COLOR, alpha);
|
||||
|
||||
// El contingut només apareix quan la caixa és prou gran
|
||||
|
||||
Reference in New Issue
Block a user