Modern UI statistics screen: transfer history and the six curves
Section 1 lists the manager's transfers from the original's own records, section 2 the six curves of the original (its labels, weekly values and the absolute scale); the interface scales them itself. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
015fa65f56
commit
6054a44acf
5 files changed
+64
-5
No files matched your search
@@ -8752,6 +8752,64 @@ std::string ui_text(const cli::Json& j, const char* key) {
|
||||
|
||||
} // namespace
|
||||
|
||||
cli::Json ModernSession::read_statistics_screen(const cli::Json& request) const {
|
||||
using O = cli::Json::Object;
|
||||
using A = cli::Json::Array;
|
||||
const int manager = int(g_.memory.has(::bmh::layout::ActiveManager) ? g_.memory.u8(::bmh::layout::ActiveManager) : 0);
|
||||
cli::Json answer = modern::query_statistics_screen(g_, manager, request);
|
||||
auto* out = std::get_if<O>(&answer.value);
|
||||
if (!out || !out->count("section") || !(*out)["section"].integer()) return answer;
|
||||
const int64_t section = *(*out)["section"].integer();
|
||||
if (section != 1 && section != 2) return answer;
|
||||
const bool club = manager >= 0 && size_t(manager) < g_.manager_teams.size() &&
|
||||
g_.manager_teams[size_t(manager)] >= 0 && g_.manager_teams[size_t(manager)] < league_clubs();
|
||||
try {
|
||||
if (section == 1 && club) {
|
||||
// the manager's transfer list of the original (+0x760/+0x7d8): date, kind, player, other club, fee
|
||||
const ui::TransferHistoryProjection h = ui::transfer_history_from_game(g_, manager);
|
||||
auto& cols = std::get<A>((*out)["columns"].value);
|
||||
for (const char* c : {"Saison / Spieler", "Von", "Nach", "Ablöse"}) cols.push_back(O{{"text", c}});
|
||||
const size_t team = size_t(g_.manager_teams[size_t(manager)]);
|
||||
const std::string own = team < g_.world_club_name.size() && !g_.world_club_name[team].empty()
|
||||
? g_.world_club_name[team] : ui::original_to_utf8(g_.club_name(int(team)));
|
||||
static constexpr const char* kKinds[4] = {"Verkauf", "Kauf", "Verleih", "Leihe"};
|
||||
for (const auto& r : h.rows) {
|
||||
const AlmanacDate d = almanac_date(r.source_date_counter, g_.display_start_year);
|
||||
const std::string other = r.special_counterparty ? "Ausland" : ui::original_to_utf8(r.counterparty_club_name);
|
||||
const bool outgoing = (r.source_kind & 3) == 0 || (r.source_kind & 3) == 2;
|
||||
std::get<A>((*out)["rows"].value).push_back(O{{"cells", A{
|
||||
O{{"text", std::to_string(d.year) + " · " + ui::original_to_utf8(r.saved_player_name)}, {"kind", kKinds[r.source_kind & 3]}},
|
||||
O{{"text", outgoing ? own : other}}, O{{"text", outgoing ? other : own}},
|
||||
O{{"text", std::to_string(r.source_fee) + " €"}, {"value", int64_t(r.source_fee)}, {"money", modern::ui_money(r.source_fee)}}}}});
|
||||
}
|
||||
}
|
||||
if (section == 2 && club) {
|
||||
// the six curves of the original (labels from the executable), values per recorded week;
|
||||
// the interface scales them (absolute: min/max of the original's absolute scale)
|
||||
const ui::AnalyticsState a = ui::analytics_from_game(g_, exe_, manager, Image(320, 240)); // (the underlay only draws)
|
||||
const A* active = (*out)["curves"].array();
|
||||
auto& series = std::get<A>((*out)["series"].value);
|
||||
for (size_t i = 0; i < a.series.size(); ++i) {
|
||||
A values;
|
||||
for (int32_t v : a.series[i].values) values.push_back(int64_t(v));
|
||||
series.push_back(O{{"name", ui::original_to_utf8(a.series[i].label)}, {"color", int(a.series[i].color)},
|
||||
{"active", active && i < active->size() ? (*active)[i] : cli::Json(true)},
|
||||
{"values", std::move(values)}, {"absoluteMin", int64_t(a.series[i].absolute_min)},
|
||||
{"absoluteMax", int64_t(a.series[i].absolute_max)}, {"points", A{}}});
|
||||
}
|
||||
}
|
||||
} catch (const std::exception& e) {
|
||||
(*out)["reasonDetail"] = std::string(e.what()); // stays "not recorded"
|
||||
return answer;
|
||||
}
|
||||
const bool filled = section == 1 ? !std::get<A>((*out)["rows"].value).empty() : !std::get<A>((*out)["series"].value).empty();
|
||||
if (filled) {
|
||||
(*out)["available"] = true;
|
||||
out->erase("reason");
|
||||
}
|
||||
return answer;
|
||||
}
|
||||
|
||||
cli::Json ModernSession::ui_read(const cli::Json& request, uint64_t revision) const {
|
||||
using O = cli::Json::Object;
|
||||
using A = cli::Json::Array;
|
||||
|
||||
@@ -834,9 +834,8 @@ public:
|
||||
// The almanac screen (index, calendar, day, match; docs/new_engine/ui-anbindung.md). Read-only.
|
||||
cli::Json read_almanac(const cli::Json& request) const { return query_almanac(g_, request); }
|
||||
// The statistics screen for the manager at the desk (docs/new_engine/ui-anbindung.md). Read-only.
|
||||
cli::Json read_statistics_screen(const cli::Json& request) const {
|
||||
return query_statistics_screen(g_, int(g_.memory.has(::bmh::layout::ActiveManager) ? g_.memory.u8(::bmh::layout::ActiveManager) : 0), request);
|
||||
}
|
||||
// Sections 1 (transfer history) and 2 (the six curves) come from the original's own records.
|
||||
cli::Json read_statistics_screen(const cli::Json& request) const;
|
||||
// The read queries of the new interface (docs/new_engine/ui-abfragen.md): status, leagues,
|
||||
// table, fixtures, squad and the statistics, for the manager at the desk. Read-only.
|
||||
cli::Json read(const cli::Json& request) const {
|
||||
|
||||
Reference in new issue
Block a user