manuals tidy tier 3a: rondes, ternaris, anyofallof, padding, etc.
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
// Implementación de stb_vorbis (debe estar ANTES de incluir jail_audio.hpp).
|
||||
// clang-format off
|
||||
#undef STB_VORBIS_HEADER_ONLY
|
||||
#include "external/stb_vorbis.c"
|
||||
#include "external/stb_vorbis.c" // NOLINT(bugprone-suspicious-include): stb header-only library
|
||||
// stb_vorbis.c filtra les macros L, C i R (i PLAYBACK_*) al TU. Les netegem
|
||||
// perquè xocarien amb noms de paràmetres de plantilla en altres headers.
|
||||
#undef L
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <cmath> // Para std::lround
|
||||
#include <cstdint> // Para int8_t, uint8_t
|
||||
#include <memory> // Para std::unique_ptr
|
||||
#include <string> // Para string
|
||||
@@ -62,7 +63,7 @@ class Audio {
|
||||
// --- Helpers de conversió per a la capa de presentació ---
|
||||
// UI (menús, notificacions) manega enters 0..100; internament viu float 0..1.
|
||||
static constexpr auto toPercent(float volume) -> int {
|
||||
return static_cast<int>((volume * 100.0F) + 0.5F);
|
||||
return static_cast<int>(std::lround(volume * 100.0F));
|
||||
}
|
||||
static constexpr auto fromPercent(int percent) -> float {
|
||||
return static_cast<float>(percent) / 100.0F;
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include <vector> // Para std::vector
|
||||
|
||||
#define STB_VORBIS_HEADER_ONLY
|
||||
#include "external/stb_vorbis.c" // Para stb_vorbis_open_memory i streaming
|
||||
#include "external/stb_vorbis.c" // NOLINT(bugprone-suspicious-include): stb header-only library
|
||||
|
||||
// Deleter stateless per a buffers reservats amb `SDL_malloc` / `SDL_LoadWAV*`.
|
||||
// Compatible amb `std::unique_ptr<Uint8[], SDLFreeDeleter>` — zero size
|
||||
@@ -57,10 +57,10 @@ struct JA_Sound_t {
|
||||
|
||||
struct JA_Channel_t {
|
||||
JA_Sound_t* sound{nullptr};
|
||||
SDL_AudioStream* stream{nullptr};
|
||||
int pos{0};
|
||||
int times{0};
|
||||
int group{0};
|
||||
SDL_AudioStream* stream{nullptr};
|
||||
JA_Channel_state state{JA_CHANNEL_FREE};
|
||||
};
|
||||
|
||||
@@ -339,6 +339,10 @@ inline auto JA_LoadMusic(const char* filename) -> JA_Music_t* {
|
||||
fseek(f, 0, SEEK_END);
|
||||
long fsize = ftell(f);
|
||||
fseek(f, 0, SEEK_SET);
|
||||
if (fsize <= 0) {
|
||||
fclose(f);
|
||||
return nullptr;
|
||||
}
|
||||
auto* buffer = static_cast<Uint8*>(malloc(fsize + 1));
|
||||
if (buffer == nullptr) {
|
||||
fclose(f);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "core/input/key_config.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <utility>
|
||||
@@ -154,12 +155,7 @@ namespace KeyConfig {
|
||||
if (sc == SDL_SCANCODE_UNKNOWN) {
|
||||
return false;
|
||||
}
|
||||
for (const auto& e : entries_) {
|
||||
if (e.scancode == sc) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return std::ranges::any_of(entries_, [sc](const auto& e) { return e.scancode == sc; });
|
||||
}
|
||||
|
||||
auto entries() -> const std::vector<KeyEntry>& {
|
||||
|
||||
@@ -12,7 +12,9 @@
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
|
||||
#endif
|
||||
// NOLINTBEGIN(clang-analyzer-unix.Malloc): codi extern de tercers, no l'auditem.
|
||||
#include "external/gif.h"
|
||||
// NOLINTEND(clang-analyzer-unix.Malloc)
|
||||
#if defined(__clang__)
|
||||
#pragma clang diagnostic pop
|
||||
#elif defined(__GNUC__)
|
||||
@@ -26,7 +28,7 @@ Uint32* pixel_data = nullptr;
|
||||
void JD8_Init() {
|
||||
screen = new Uint8[64000]{};
|
||||
main_palette = new Color[256]{};
|
||||
pixel_data = new Uint32[320 * 200]{};
|
||||
pixel_data = new Uint32[std::size_t{320} * 200]{};
|
||||
}
|
||||
|
||||
void JD8_Quit() {
|
||||
|
||||
@@ -106,12 +106,7 @@ auto JI_KeyPressed(int key) -> bool {
|
||||
if (static_cast<int>(keystates[key]) != 0) {
|
||||
return true;
|
||||
}
|
||||
for (auto& virtual_keystate : virtual_keystates) {
|
||||
if (virtual_keystate[key] != 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return std::ranges::any_of(virtual_keystates, [key](const auto& vk) { return vk[key] != 0; });
|
||||
}
|
||||
|
||||
auto JI_CheatActivated(const char* cheat_code) -> bool {
|
||||
|
||||
@@ -16,7 +16,11 @@ namespace Locale {
|
||||
if (node.is_mapping()) {
|
||||
for (auto it = node.begin(); it != node.end(); ++it) {
|
||||
auto key = it.key().get_value<std::string>();
|
||||
std::string full = prefix.empty() ? key : prefix + "." + key;
|
||||
std::string full = prefix;
|
||||
if (!full.empty()) {
|
||||
full += ".";
|
||||
}
|
||||
full += key;
|
||||
traverse(it.value(), full);
|
||||
}
|
||||
} else if (node.is_scalar()) {
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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_);
|
||||
}
|
||||
|
||||
@@ -34,10 +34,14 @@ void ModuleGame::onEnter() {
|
||||
// Audio::playMusic ja és idempotent: si la pista actual coincideix amb la
|
||||
// demanada, no fa res. Per això podem cridar-lo cada onEnter sense
|
||||
// desencadenar restarts indesitjats.
|
||||
const char* music_name = info::ctx.num_piramide == 3 ? "piramide_3.ogg"
|
||||
: info::ctx.num_piramide == 2 ? "piramide_2.ogg"
|
||||
: info::ctx.num_piramide == 6 ? "secreta.ogg"
|
||||
: "piramide_1_4_5.ogg";
|
||||
const char* music_name = "piramide_1_4_5.ogg";
|
||||
if (info::ctx.num_piramide == 3) {
|
||||
music_name = "piramide_3.ogg";
|
||||
} else if (info::ctx.num_piramide == 2) {
|
||||
music_name = "piramide_2.ogg";
|
||||
} else if (info::ctx.num_piramide == 6) {
|
||||
music_name = "secreta.ogg";
|
||||
}
|
||||
Audio::get()->playMusic(music_name);
|
||||
|
||||
// Arranca el fade-in tick-based. El `PaletteFade` avança un pas (de
|
||||
|
||||
@@ -346,7 +346,7 @@ namespace Options {
|
||||
file << " shader_enabled: " << (video.shader_enabled ? "true" : "false") << "\n";
|
||||
file << " supersampling: " << (video.supersampling ? "true" : "false") << "\n";
|
||||
{
|
||||
const char* m = "integer";
|
||||
const char* m = nullptr;
|
||||
switch (video.scaling_mode) {
|
||||
case ScalingMode::DISABLED:
|
||||
m = "disabled";
|
||||
@@ -361,6 +361,7 @@ namespace Options {
|
||||
m = "overscan";
|
||||
break;
|
||||
case ScalingMode::INTEGER:
|
||||
default:
|
||||
m = "integer";
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -117,9 +117,12 @@ namespace scenes {
|
||||
case Phase::Slide2Enter:
|
||||
case Phase::Slide3Enter: {
|
||||
phase_acc_ms_ += delta_ms;
|
||||
const int slide_idx = (phase_ == Phase::Slide1Enter ? 0
|
||||
: phase_ == Phase::Slide2Enter ? 1
|
||||
: 2);
|
||||
int slide_idx = 2;
|
||||
if (phase_ == Phase::Slide1Enter) {
|
||||
slide_idx = 0;
|
||||
} else if (phase_ == Phase::Slide2Enter) {
|
||||
slide_idx = 1;
|
||||
}
|
||||
const float t = std::min(1.0F, static_cast<float>(phase_acc_ms_) / static_cast<float>(SCROLL_MS));
|
||||
const float eased = Easing::outCubic(t);
|
||||
const int pos_x = Easing::lerpInt(SLIDE_START_X[slide_idx], 0, eased);
|
||||
|
||||
Reference in New Issue
Block a user