// SPDX-License-Identifier: GPL-3.0-only #pragma once #include #include #include #include #include #include "ui/setup.hpp" namespace bmh { struct GameState; class SaveState; } namespace bmh { struct MatchGroup; } namespace bmh::ui { struct DeskItem { int id = 0, x = 0, y = 0, width = 0, height = 0, kind = 0; uint8_t flags = 0, folder = 0; bool open = false, disabled = false; }; struct DeskDate { int year = 0, month = 0, day = 0, weekday = 0; }; struct DeskManagerIdentity { int runtime_club = -1, club_identity_key = -1, league = -1, portrait = 0; uint16_t badge = 0; std::string name; bool operator==(const DeskManagerIdentity&) const = default; }; struct DeskMatchCallargs { int competition = 33, opponent = -1; bool operator==(const DeskMatchCallargs&) const = default; }; struct DeskRankSample { int matchday = 0; int source_rank = -1; // TablePosition's zero-based 5-bit value. }; struct DeskRankCurve { int runtime_team = -1; int league = -1; std::string team_name; std::optional current_position, strength; std::vector samples; }; struct DeskRecentMatch { int home_team = -1, away_team = -1; std::string home_name, away_name; uint8_t source_score = 0xff; // Original packed byte, without inferred home/away reversal. }; struct DeskOpponentHistory { int runtime_team = -1; std::string team_name; std::array source_results{}; // 5 home + 5 away nibbled result bytes. }; // Copyable, read-only rendering boundary. Runtime club IDs are not master IDs. struct DeskState { SetupOptions options; int manager_slot = 0, runtime_club = -1, league = -1, portrait = 0; // Authoritative slot -> runtime team mapping, copied from GameState::manager_teams. std::vector manager_teams; std::vector managers; // Original active-club roster retained across the temporary national takeover. // In a multiplayer career the visible national desk has only the coach in slot 0. std::vector national_return_roster; bool national_team = false; // SwapManagerSlots2 temporary coach assignment (CoachActive). This can make // a league-only, single-manager career temporarily project team 0x165. bool national_coach_takeover = false; std::string manager_name, club_name; uint16_t badge = 0; uint32_t day_counter = 0; int season_index = 0, season_day = 0; std::optional league_round, table_position, strength; // Desk call arguments are not fully saved in FBM. -1 = confirmed no opponent; // nullopt = unknown. The initial reference title is known only at career day zero. std::optional next_competition, next_opponent; // SourceDrawerTeam swaps the two match labels when the active manager's // record +0x28a marks the club as the away side. bool next_match_away = false; // SourceDrawerTeam's independent pair-count gate: DeskState_FormatError_RuntimeField2==0 and record+28a!=0. // Retained even without a next opponent; that separate gate is resolved // by the renderer. Match-label home/away semantics remain independent. bool paired_drawers_away_order = false; // Source SourceDrawerTeam case 15: resolved only from the current prepared event. std::string next_competition_label, next_competition_detail, next_opponent_name; std::optional next_opponent_badge; bool next_opponent_badge_fallback = false; // Read-only contents for SourceDrawerTeam switch-local cases 0..4, 9..10, // 0x0c, 0x10..0x11, and 0x14..0x15. Cases 0x0d and 0x16 are source-empty. Portrait/name are // already supplied by `portrait` / `manager_name` for cases 0x12/0x13. // Folder entries are native layout record IDs (1..30); their displayed // dimensions are derived from EXE count tables, while saved layout records // remain untouched. Rank samples and result bytes retain native encodings. std::array, 54> layout_records{}; std::array, 3> folder_icon_slots; bool layout_snap = true; // CareerSession_DispatchDesktopLayout_RuntimeField2 == 0: Source snaps desktop drags to its grid. std::array rank_curves; // Own club and authenticated current rival. std::vector recent_matches; std::vector opponent_histories; DeskDate date; int32_t balance = 0, savings = 0; int ticket_price = 0, fans = 0; int32_t money_numerator = 1, money_denominator = 1; bool decorated_background = true, gradient_text = true, drawer_handles = true; bool shortcut_bar_always = true; // DeskDate: DeskState_FormatError_RuntimeField3 == 0 sets afb86 bit 1. std::optional mailbox_shortcut; // original item 44 / kind 63, including a hidden/foldered record bool mailbox_notification_pending = false; // MailboxRecipientMask active-manager bit; transient, non-FBM std::optional menu_layout_shortcut; // final bar cell returns native record 53/kind 72, then dispatches MEN std::array automation{}; std::optional> automation_formation; std::array, 10> warnings{}; std::vector items; // Original linked-list drawing / hit-test order. std::string source; uint64_t revision = 0; }; // Original DeskDate2, including its four-year leap cycle and edition-specific epoch. DeskDate desk_date(uint32_t day_counter, const LeImage& executable); DeskState desk_from_save(const SaveState&, const LeImage&, uint64_t revision = 0); // Uses authoritative typed fields where StaticMemory contains stale copies. // Does not call enter_desk(), RNG, finance transactions or any engine mutator. DeskState desk_from_game(const GameState&, const LeImage&, uint64_t revision, const std::vector* current_groups = nullptr, std::optional source_default_competition = std::nullopt, const DeskMatchCallargs* source_callargs = nullptr); DeskState load_reference_desk(const std::filesystem::path& save, const LeImage& executable); std::string desk_json(const DeskState&); void validate_desk_profile(const SetupOptions&); void validate_desk_state(const DeskState&); } // namespace bmh::ui