App::run: the hook presenters are named members
run() assigned 16 presenter lambdas to the hooks before it showed the title screen. They are member functions now (present_sportschau_intro, present_matchday_intro, present_sportschau_replay_step, present_sportschau_scene, present_competition_winner, present_tax_event, present_promotion, club_information_dialog, club_player_dialog, player_detail_dialog, club_statistics_dialog, select_poach_player, present_cup_draw, ...); run() assigns a forwarding lambda and keeps 437 of 1,240 lines: the wiring, the title screen, the event loop and the tear-down. The bodies moved unchanged. Verified: robot (234 commands), UI walk, 9 careers identical; 211 of 211 tests. Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
1 parent
99200f1dc8
commit
c8dee2c377
1 file changed
+71
-38
+71
-38
@@ -3205,10 +3205,11 @@ struct App {
|
||||
|
||||
std::array<bool, 2> setup_button_down{};
|
||||
|
||||
// The statements of the former main(): hook wiring, title screen, event loop and tear-down.
|
||||
int run() {
|
||||
// --- presenters the engine calls through hooks (wired in run()): Sportschau, tax, promotion, the club
|
||||
// dialogs, the poach selection and the cup draw ---
|
||||
|
||||
// Plays the Sportschau intro animation frames with fanfare, then waits for a click.
|
||||
sportschau_presenter.intro = [&](const GameState&, const SportschauIntroView&) {
|
||||
auto present_sportschau_intro(const GameState&, const SportschauIntroView&) {
|
||||
if (!running) return;
|
||||
// PaletteOverride installs KB132's embedded palette; SportschauIntro restores the
|
||||
// normal palette on return. Keep the override local to intro frames.
|
||||
@@ -3231,10 +3232,11 @@ struct App {
|
||||
present_season(sportschau_intro.render_frame(ui::SportschauIntro::frame_count - 1),
|
||||
"OpenBMH - sportschau_intro_ack", intro_colors);
|
||||
wait_sportschau_ack();
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
// Shows the matchday intro screen for a fixed time; a left click skips it.
|
||||
sportschau_presenter.kickoff = [&](const GameState&, const MatchdayIntroView& view) {
|
||||
auto present_matchday_intro(const GameState&, const MatchdayIntroView& view) {
|
||||
if (!running) return;
|
||||
present_season(matchday_intro.render(view), "OpenBMH - matchday_intro",
|
||||
matchday_intro.palette_override() ? &*matchday_intro.palette_override() : nullptr);
|
||||
@@ -3255,11 +3257,12 @@ struct App {
|
||||
if (running && !skipped) SDL_Delay(1);
|
||||
}
|
||||
SDL_FlushEvents(SDL_MOUSEBUTTONDOWN, SDL_MOUSEBUTTONUP);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
// Shows one step of the report replay (log entries growing minute by minute).
|
||||
// Returns true when the replay should stop (quit) or be skipped by a left click.
|
||||
sportschau_presenter.replay.step = [&](const GameState& state,
|
||||
auto present_sportschau_replay_step(const GameState& state,
|
||||
const SportschauFixtureView& fixture, const SportschauReportStep& step) {
|
||||
if (!running) return true;
|
||||
if (step.visible_log_entries == 0 && step.progress_minute == 0) {
|
||||
@@ -3289,11 +3292,12 @@ struct App {
|
||||
if (step.minute_wait) source_tick_wait(unsigned(raw < 6 ? raw / 2 : raw));
|
||||
if (step.chance_wait) source_tick_wait(50);
|
||||
return skip;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
// Plays one highlight (header, optional set piece, shot animation) of the replay, using
|
||||
// the memory-driven delays, then restores the report screen.
|
||||
sportschau_presenter.replay.scene = [&](const GameState& state,
|
||||
auto present_sportschau_scene(const GameState& state,
|
||||
const SportschauFixtureView& fixture, const SportschauSceneView& scene) {
|
||||
if (!running) return;
|
||||
ui::LiveMatchdayFrame frame;
|
||||
@@ -3344,46 +3348,49 @@ struct App {
|
||||
auto restored = scene.report_step; restored.chance_wait = false;
|
||||
present_season(sportschau_replay_screen->render_report(restored),
|
||||
("OpenBMH - sportschau_scene_restored_" + id).c_str());
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
// Shows the full match report of a fixture and waits for acknowledgement.
|
||||
sportschau_presenter.fixture = [&](const GameState& state, const SportschauFixtureView& fixture) {
|
||||
auto present_sportschau_fixture(const GameState& state, const SportschauFixtureView& fixture) {
|
||||
if (!running) return;
|
||||
ui::SportschauMatchReport screen(data, fixture, sportschau_context(state));
|
||||
present_season(screen.render_report(fixture.log_events.size()), "OpenBMH - sportschau_report");
|
||||
wait_sportschau_ack();
|
||||
sportschau_replay_screen.reset();
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
// Shows the competition winner screen.
|
||||
sportschau_presenter.winner = [&](const GameState& state, const CompetitionWinnerView& view) {
|
||||
auto present_competition_winner(const GameState& state, const CompetitionWinnerView& view) {
|
||||
if (!running) return;
|
||||
const auto& colors = competition_winner.palette_override(view.title);
|
||||
present_season(competition_winner.render(state, view),
|
||||
("OpenBMH - competition_winner_" + std::to_string(view.title) + "_" +
|
||||
std::to_string(view.team)).c_str(), colors ? &*colors : nullptr);
|
||||
wait_sportschau_ack(); // SDLFlushEvents2 waits for a mouse press; ESC is ignored.
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
// Shows the team-of-the-matchday (eleven) screen.
|
||||
sportschau_presenter.awards = [&](const GameState& state, const SportschauAwardsView& view) {
|
||||
auto present_sportschau_awards(const GameState& state, const SportschauAwardsView& view) {
|
||||
if (!running) return;
|
||||
present_season(sportschau_eleven.render(view, sportschau_context(state).gradient_text),
|
||||
("OpenBMH - sportschau_eleven_" + std::to_string(view.group)).c_str());
|
||||
wait_sportschau_ack();
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
// Shows the team information screen.
|
||||
sportschau_presenter.team_info = [&](const GameState& state, const SportschauTeamInfoView& view) {
|
||||
auto present_sportschau_team_info(const GameState& state, const SportschauTeamInfoView& view) {
|
||||
if (!running) return;
|
||||
present_season(sportschau_team_info.render(view, sportschau_context(state).gradient_text),
|
||||
("OpenBMH - sportschau_teaminfo_" + std::to_string(view.group)).c_str());
|
||||
wait_sportschau_ack();
|
||||
};
|
||||
}
|
||||
|
||||
tax_presenter.choose = [this](auto&&... a) -> decltype(auto) { return show_tax(std::forward<decltype(a)>(a)...); };
|
||||
|
||||
tax_presenter.observe = [&](const GameState& state, const SeasonTaxEvent& event) {
|
||||
auto present_tax_event(const GameState& state, const SeasonTaxEvent& event) {
|
||||
if (event.kind == SeasonTaxEventKind::notice || event.kind == SeasonTaxEventKind::outcome)
|
||||
(void)show_tax(state, event);
|
||||
if (running && event.kind == SeasonTaxEventKind::animation) {
|
||||
@@ -3404,9 +3411,10 @@ struct App {
|
||||
// Outcome ACK must start on the older drawing frame in this case.
|
||||
season_backdrop = animation.drawing_frame();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
promotion_presenter = [&](const GameState& state, const SeasonPromotionEvent& event) {
|
||||
|
||||
auto present_promotion(const GameState& state, const SeasonPromotionEvent& event) {
|
||||
if (!running) return;
|
||||
auto view = ui::season_promotion_from_game(state, event, season_exe, season_texts);
|
||||
ui::SeasonPromotionScreen screen(data, std::move(view));
|
||||
@@ -3421,11 +3429,12 @@ struct App {
|
||||
wait_promotion_time(50 * 20);
|
||||
for (int step = 1; running && step <= 38; ++step) show_step(step);
|
||||
if (running) wait_promotion_time(50 * 20);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
// Modal club information screen for `team`. Returns true when it was left normally (or
|
||||
// the process timer expired), false when the program is quitting.
|
||||
present_club_information = [&](app::ClubModalServices& services, int team) -> bool {
|
||||
auto club_information_dialog(app::ClubModalServices& services, int team) -> bool {
|
||||
if (!running) return false;
|
||||
//ClubInfoFromGame owns the opening DOWN and consumes its paired UP inside
|
||||
// this synchronous loop. The parent must not retain a held press
|
||||
@@ -3523,11 +3532,12 @@ struct App {
|
||||
SDL_Delay(10);
|
||||
}
|
||||
return false;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
// Opens the player detail card for a row chosen in the club list. The runtime input mode
|
||||
// byte is switched for the card and restored afterwards (RAII helper below).
|
||||
present_club_player = [&](app::ClubModalServices& services, const ui::ClubInfoRequest& selected, const Image& parent_image) {
|
||||
auto club_player_dialog(app::ClubModalServices& services, const ui::ClubInfoRequest& selected, const Image& parent_image) {
|
||||
if (!running) return false;
|
||||
const ClubPlayerDetailSelection selection{selected.runtime_team, selected.player_id,
|
||||
selected.rendered_row, selected.physical_row, selected.human_loan_index};
|
||||
@@ -3542,11 +3552,12 @@ struct App {
|
||||
services.set_runtime_byte(::bmh::layout::CareerSession_DispatchPoachUi_ExecutableField, input_mode);
|
||||
if(!present_player_detail)throw FormatError("generic player presenter unavailable");
|
||||
return present_player_detail(services,selection,parent_image).value_or(false);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
// Modal player detail card. Returns the card's close-parent flag, or std::nullopt when
|
||||
// the program is quitting.
|
||||
present_player_detail = [&](app::ClubModalServices& services,const ClubPlayerDetailSelection& selection,const Image& parent_image) -> std::optional<bool> {
|
||||
auto player_detail_dialog(app::ClubModalServices& services,const ClubPlayerDetailSelection& selection,const Image& parent_image) -> std::optional<bool> {
|
||||
if(!running)return std::nullopt;
|
||||
press.reset(); //ClubPlayerDetailFromGame now owns physical hold/release through its own Source wait.
|
||||
const uint8_t input_mode=services.runtime_byte(::bmh::layout::CareerSession_DispatchPoachUi_ExecutableField);
|
||||
@@ -3688,10 +3699,11 @@ struct App {
|
||||
SDL_Delay(10);
|
||||
}
|
||||
return std::nullopt;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
// Modal team statistics screen with a mode toggle; leaves on close, right press or timer.
|
||||
present_club_statistics = [&](app::ClubModalServices& services, int team, const Image& parent_frame) {
|
||||
auto club_statistics_dialog(app::ClubModalServices& services, int team, const Image& parent_frame) {
|
||||
if (!running) return;
|
||||
auto mode = ui::TeamStatisticsMode::combined;
|
||||
std::unique_ptr<ui::TeamStatisticsScreen> statistics;
|
||||
@@ -3744,12 +3756,11 @@ struct App {
|
||||
}
|
||||
SDL_Delay(10);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
poach_player_selector =
|
||||
[&](app::CareerSession& staged,app::ClubModalServices&,int manager,
|
||||
uint64_t& selection_revision,const Image& transfer_backdrop)
|
||||
-> std::optional<ClubPlayerDetailSelection> {
|
||||
|
||||
auto select_poach_player(app::CareerSession& staged,app::ClubModalServices&,int manager,
|
||||
uint64_t& selection_revision,const Image& transfer_backdrop) -> std::optional<ClubPlayerDetailSelection> {
|
||||
using Phase=app::CareerSession::TableDispatchPhase;
|
||||
press.reset(); // The synchronous Source player-selection loop owns its input.
|
||||
std::string error;
|
||||
@@ -3930,9 +3941,10 @@ struct App {
|
||||
SDL_Delay(10);
|
||||
}
|
||||
throw FormatError("poach: player selection presenter stopped");
|
||||
};
|
||||
}
|
||||
|
||||
cup_draw_presenter = [&](const GameState& state, const SeasonCupDrawEvent& event) {
|
||||
|
||||
auto present_cup_draw(const GameState& state, const SeasonCupDrawEvent& event) {
|
||||
if (!running) return;
|
||||
if (event.phase == SeasonCupDrawPhase::draw) {
|
||||
if (!event.group_stage || event.group_index == 0)
|
||||
@@ -4026,7 +4038,28 @@ struct App {
|
||||
}
|
||||
SDL_Delay(10);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// The statements of the former main(): hook wiring, title screen, event loop and tear-down.
|
||||
int run() {
|
||||
sportschau_presenter.intro = [this](auto&&... a) -> decltype(auto) { return present_sportschau_intro(std::forward<decltype(a)>(a)...); };
|
||||
sportschau_presenter.kickoff = [this](auto&&... a) -> decltype(auto) { return present_matchday_intro(std::forward<decltype(a)>(a)...); };
|
||||
sportschau_presenter.replay.step = [this](auto&&... a) -> decltype(auto) { return present_sportschau_replay_step(std::forward<decltype(a)>(a)...); };
|
||||
sportschau_presenter.replay.scene = [this](auto&&... a) -> decltype(auto) { return present_sportschau_scene(std::forward<decltype(a)>(a)...); };
|
||||
sportschau_presenter.fixture = [this](auto&&... a) -> decltype(auto) { return present_sportschau_fixture(std::forward<decltype(a)>(a)...); };
|
||||
sportschau_presenter.winner = [this](auto&&... a) -> decltype(auto) { return present_competition_winner(std::forward<decltype(a)>(a)...); };
|
||||
sportschau_presenter.awards = [this](auto&&... a) -> decltype(auto) { return present_sportschau_awards(std::forward<decltype(a)>(a)...); };
|
||||
sportschau_presenter.team_info = [this](auto&&... a) -> decltype(auto) { return present_sportschau_team_info(std::forward<decltype(a)>(a)...); };
|
||||
|
||||
tax_presenter.choose = [this](auto&&... a) -> decltype(auto) { return show_tax(std::forward<decltype(a)>(a)...); };
|
||||
tax_presenter.observe = [this](auto&&... a) -> decltype(auto) { return present_tax_event(std::forward<decltype(a)>(a)...); };
|
||||
promotion_presenter = [this](auto&&... a) -> decltype(auto) { return present_promotion(std::forward<decltype(a)>(a)...); };
|
||||
present_club_information = [this](auto&&... a) -> decltype(auto) { return club_information_dialog(std::forward<decltype(a)>(a)...); };
|
||||
present_club_player = [this](auto&&... a) -> decltype(auto) { return club_player_dialog(std::forward<decltype(a)>(a)...); };
|
||||
present_player_detail = [this](auto&&... a) -> decltype(auto) { return player_detail_dialog(std::forward<decltype(a)>(a)...); };
|
||||
present_club_statistics = [this](auto&&... a) -> decltype(auto) { return club_statistics_dialog(std::forward<decltype(a)>(a)...); };
|
||||
poach_player_selector = [this](auto&&... a) -> decltype(auto) { return select_poach_player(std::forward<decltype(a)>(a)...); };
|
||||
cup_draw_presenter = [this](auto&&... a) -> decltype(auto) { return present_cup_draw(std::forward<decltype(a)>(a)...); };
|
||||
|
||||
// =====================================================================================
|
||||
// Opening screen
|
||||
|
||||
Reference in new issue
Block a user