manuals tidy tier 3a: rondes, ternaris, anyofallof, padding, etc.

This commit is contained in:
2026-05-14 19:24:02 +02:00
parent 0b82be193f
commit a48fe51f73
13 changed files with 54 additions and 32 deletions
+15 -3
View File
@@ -223,7 +223,7 @@ namespace Menu {
// Converteix volum 0..1 a percentatge i ho formata com "50%"
static auto volPct(float v) -> std::string {
int pct = static_cast<int>((v * 100.0F) + 0.5F);
int pct = static_cast<int>(std::lround(v * 100.0F));
pct = std::max(pct, 0);
pct = std::min(pct, 100);
char buf[8];
@@ -605,12 +605,24 @@ 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 != nullptr) ? SDL_GetScancodeName(*item.scancode) : "");
const char* text = nullptr;
if (this_capturing) {
text = Locale::get("menu.values.press_key");
} else if (item.scancode != nullptr) {
text = SDL_GetScancodeName(*item.scancode);
} else {
text = "";
}
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);
Uint32 tc = 0;
if (this_capturing) {
tc = 0xFF00FFFF;
} else {
tc = 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);
} else if (item.getValue) {
std::string value = item.getValue();
+2 -2
View File
@@ -14,13 +14,13 @@ namespace Overlay {
void render(Uint32* pixel_data);
// Posició + animació d'una notificació
enum class NotifPosition {
enum class NotifPosition : std::uint8_t {
TOP_LEFT_SLIDE, // Cantó superior esquerra, slide horizontal des de fora
TOP_CENTER_DROP, // Centrat horitzontal, baixa des de sobre
};
// Estil de la notificació: caixa de fons, ombra o contorn del text
enum class NotifStyle {
enum class NotifStyle : std::uint8_t {
BOX, // Rectangle de fons amb accent_color
SHADOW, // Sense fons, text amb ombra (offset +1,+1) en accent_color
OUTLINE, // Sense fons, text amb contorn 4-direccional en accent_color
@@ -767,7 +767,7 @@ namespace Rendering {
}
// Copia directa — el upscale lo hace la GPU en el primer render pass
std::memcpy(mapped, pixels, static_cast<size_t>(width * height * 4));
std::memcpy(mapped, pixels, static_cast<size_t>(width) * static_cast<size_t>(height) * 4);
SDL_UnmapGPUTransferBuffer(device_, upload_buffer_);
}