Files
Dreierpack-Manager/src/ui/player_card.hpp
T
ClaudeandClaude Sonnet 5.5 551d564efb More buttons without a lasting state look pressed while held
Advertising offers and notices, the player card, the training camp booking and
notice, the file dialog (page button, overwrite question) and the bank notices
and credit fee question now draw the pressed look from the mouse press until
the release. Manager notices share source_dialog_button_at for their OK/Ja/Nein.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-08 18:36:48 +01:00

81 lines
3.9 KiB
C++

// SPDX-License-Identifier: GPL-3.0-only
// Player card screen for a player of the active manager squad, with the monthly statistics curves sub-view.
// State: PlayerCardState (lineup row, club/nationality names, optional loan and statistics context) and local
// UI flags. Unsupported cases (loan, negotiation) are reported in the state, and no request is sent to the
// engine. player_card_market_value() deliberately returns unknown where the original draws random numbers.
// Implemented in player_card.cpp.
#pragma once
#include "ui/lineup.hpp"
namespace bmh::ui {
struct PlayerStatisticsContext {
uint8_t months = 0; // Manager record +0x286; at most twelve board samples
uint8_t display_flags = 0; // Flags[manager*3+2], four curves and ABS/REL
};
struct PlayerCardLoan {
int owner = -1, borrower = -1, months = 0;
std::array<int, 2> badges{};
std::array<std::string, 2> full_names, short_names;
};
// Owned projection of a domestic player in the active manager's ordinary squad.
// A lender's separate twelve-slot snapshot uses the generic42dbd caller.
struct PlayerCardState {
LineupState lineup;
int row = -1, badge = -1;
std::string nationality_name, club_short_name;
bool portrait_available = true;
int money_numerator = 1, money_denominator = 1;
std::string unsupported_record; // explicit loan/negotiation gate, no invented card
std::optional<PlayerCardLoan> loan;
std::optional<PlayerStatisticsContext> statistics;
};
PlayerCardState player_card_from_save(const SaveState&, const LeImage&, int row, uint64_t revision = 0);
PlayerCardState player_card_from_game(const GameState&, const LeImage&, int row, uint64_t revision);
// AddToSquad + PlayerCardMarketValue. Below 50,000 the original draws random numbers;
// that branch deliberately returns unknown instead of changing engine RNG.
std::optional<uint32_t> player_card_market_value(const Player&, const LeImage&);
// Original graph coordinates for one monthly series; shared by the renderer and
// offline reference inspection. Curves 0..3: value, strength, form, total.
std::vector<std::pair<int,int>> player_statistics_points(const PlayerCardState&, const LeImage&, int curve, bool absolute);
class PlayerCardScreen {
public:
PlayerCardScreen(const std::filesystem::path& data, PlayerCardState state, std::optional<Image> parent_frame = std::nullopt);
Image render() const;
bool click(int x, int y, bool right = false);
// Mouse DOWN on a card button: drawn pressed until the release (click()).
bool press(int x, int y);
bool key(std::string_view key);
bool close_requested() const { return close_; }
bool in_statistics() const { return statistics_open_; }
const PlayerCardState& state() const { return state_; }
std::string state_json() const;
private:
PlayerCardState state_;
LeImage exe_;
Font small_, heading_;
TextDb texts_;
Image widgets_, atlas_, flags_, portrait_, letters_, badge_, parent_frame_;
std::array<Image, 2> loan_badges_;
bool close_ = false;
bool statistics_open_ = false;
int pressed_button_ = -1; // 0 Schließen, 1 Statistik, 2 Zurück (statistics page) while the mouse button is held
std::optional<Image> statistics_frame_; // previous UI frame for original button redraw edges
std::optional<Image> restored_card_frame_; // card loop does not reconstruct its outer frame
uint8_t statistics_flags_ = 0;
std::string unsupported_navigation_;
void text(Image&, int x, int baseline, std::string_view, uint8_t color, int right = -1, bool heading = false) const;
void frame(Image&, int x, int y, int width, int height) const;
void button(Image&, int x, int y, int width, std::string_view, bool active = false) const;
Image render_card() const;
Image render_statistics() const;
void draw_portrait(Image&, const LineupPlayer&) const;
const std::string& label(uint32_t address) const;
};
} // namespace bmh::ui