feat(title): FSM IDLE/STARTING amb START per jugador i propagació de StartingPlayers

This commit is contained in:
JailDesigner committed 2026-05-06 13:28:34 +02:00
1 parent 1fc3ab8e31
commit ca64115bfe
9 files changed
+143 -26

No files matched your search

+11 -12
View File
@@ -251,19 +251,18 @@ Director::Director() {
std::cout << "Director: start_scene=" << DebugConfig::toString(START)
<< " starting_players=" << DebugConfig::toString(STARTING_PLAYERS) << '\n';
// El branch Release inicialitza STARTING_PLAYERS amb una constant
// literal i clang considera la captura redundant; en Debug el valor és
// runtime i la captura sí és imprescindible. La lambda viu dins de
// IntroScene, més enllà del scope d'aquest ctor — capturar per
// referència seria UB.
// NOLINTNEXTLINE(clang-diagnostic-unused-lambda-capture)
auto make_game = [STARTING_PLAYERS]() -> std::unique_ptr<Scene> {
// `make_game` i `make_intro` reben `StartingPlayers` com a paràmetre
// perquè la TitleScene tria al moment quins jugadors entren (P1, P2,
// BOTH) segons la pulsació. La IntroScene ho reenvia a la GameScene.
// El valor de `STARTING_PLAYERS` només s'usa com a punt d'entrada en
// mode Debug quan saltem directament a INTRO o GAME (saltant TITLE).
auto make_game = [](DebugConfig::StartingPlayers players) -> std::unique_ptr<Scene> {
auto cfg = GameScene::defaultConfig();
cfg.starting_players = STARTING_PLAYERS;
cfg.starting_players = players;
return std::make_unique<GameScene>(std::move(cfg));
};
auto make_intro = [placeholder_text, make_game]() -> std::unique_ptr<Scene> {
return std::make_unique<IntroScene>(placeholder_text, make_game);
auto make_intro = [placeholder_text, make_game](DebugConfig::StartingPlayers players) -> std::unique_ptr<Scene> {
return std::make_unique<IntroScene>(placeholder_text, players, make_game);
};
auto make_title = [menu_title_text, placeholder_text, title_bg_surface, mini_logo_surface, make_intro]() -> std::unique_ptr<Scene> {
return std::make_unique<TitleScene>(menu_title_text, placeholder_text, title_bg_surface, mini_logo_surface, make_intro);
@@ -277,10 +276,10 @@ Director::Director() {
current_scene_ = make_title();
break;
case DebugConfig::StartScene::INTRO:
current_scene_ = make_intro();
current_scene_ = make_intro(STARTING_PLAYERS);
break;
case DebugConfig::StartScene::GAME:
current_scene_ = make_game();
current_scene_ = make_game(STARTING_PLAYERS);
break;
}
last_ticks_ms_ = SDL_GetTicks();
+4
View File
@@ -102,6 +102,8 @@ UiConfig::UiConfig()
title_copyright_color_(Defaults::UI::Title::COPYRIGHT_COLOR),
title_blink_visible_ms_(Defaults::UI::Title::BLINK_VISIBLE_MS),
title_blink_hidden_ms_(Defaults::UI::Title::BLINK_HIDDEN_MS),
title_starting_ms_(Defaults::UI::Title::STARTING_MS),
title_starting_blink_speedup_(Defaults::UI::Title::STARTING_BLINK_SPEEDUP),
title_heat_haze_{
.enabled = Defaults::UI::Title::HeatHaze::ENABLED,
.amplitude_px = Defaults::UI::Title::HeatHaze::AMPLITUDE_PX,
@@ -224,6 +226,8 @@ void UiConfig::load(const std::string& file_path) {
readColorIndex(t, "copyright_color", title_copyright_color_);
readField(t, "blink_visible_ms", title_blink_visible_ms_);
readField(t, "blink_hidden_ms", title_blink_hidden_ms_);
readField(t, "starting_ms", title_starting_ms_);
readField(t, "starting_blink_speedup", title_starting_blink_speedup_);
if (t.contains("heat_haze")) {
const auto& hh = t["heat_haze"];
readField(hh, "enabled", title_heat_haze_.enabled);
+4
View File
@@ -95,6 +95,8 @@ class UiConfig {
[[nodiscard]] auto titleCopyrightColor() const -> Uint8 { return title_copyright_color_; }
[[nodiscard]] auto titleBlinkVisibleMs() const -> int { return title_blink_visible_ms_; }
[[nodiscard]] auto titleBlinkHiddenMs() const -> int { return title_blink_hidden_ms_; }
[[nodiscard]] auto titleStartingMs() const -> int { return title_starting_ms_; }
[[nodiscard]] auto titleStartingBlinkSpeedup() const -> float { return title_starting_blink_speedup_; }
[[nodiscard]] auto titleHeatHaze() const -> const TitleHeatHaze& { return title_heat_haze_; }
// Corbes d'easing triades al YAML. Si el nom no és conegut, s'usa
@@ -167,6 +169,8 @@ class UiConfig {
Uint8 title_copyright_color_;
int title_blink_visible_ms_;
int title_blink_hidden_ms_;
int title_starting_ms_;
float title_starting_blink_speedup_;
TitleHeatHaze title_heat_haze_;
std::string menu_select_sound_;