Paper windows, a display serif and chalk hand, a symmetric tactics board, the match day as a stage

- Material: menu windows are sheets of paper (warm surface, edge, two sheets beneath,
  serif headings) that slide in once when their menu opens; the desk stays glass.
  Source Serif 4 and Cabin Sketch ship in assets/modern/fonts (SIL OFL, see
  THIRD_PARTY_NOTICES.md); system fonts remain the fallback.
- Tactics board: 320 x 200 units mirrored about its middle - the pitch of the
  attitude on the left, six equal tiles for the play settings on the right with
  their names in chalk, the commitment with a scale across the foot.
- Live match: a 4:3 sheet like the menus (same window zoom) on the darkened stadium.
  One score board per match of a human manager - a full-width card for one match,
  two side by side, a 2 x 2 grid for three or four - with crests, a score plate in
  the clubs' colours (read from the crests), a clock ring, a pressure bar, and a
  time line of goals, cards and injuries. Compact ticker rows with a mark per kind,
  a goal banner on the card, a horizontal speed control, and optional halts at half
  time and when falling behind.
- QA: script command demo-start begins a demo career with 1-4 managers.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
MichaelandClaude Fable 5.2 committed 2026-11-14 16:15:11 +01:00
1 parent 54fef90a5b
commit 9b5d448fb6
21 files changed
+887 -125

No files matched your search

+66 -2
View File
@@ -309,6 +309,40 @@ public:
const auto &r = entries_.at(found->second).raster;
return {found->second, r.width, r.height};
}
// A club's colour, read from its crest: the strongest hue among its opaque pixels, dark
// enough to carry white type. Empty when the crest has no colour to speak of.
std::string crest_colour(const std::string &key) {
const auto identity = "crest-colour:" + key;
if (const auto found = keys_.find(identity); found != keys_.end()) return found->second;
std::string colour;
const auto source = image(key, true);
if (!source.token.empty()) {
const auto &raster = entries_.at(source.token).raster;
std::array<double, 12> weight{}, red{}, green{}, blue{};
for (size_t i = 0; i + 3 < raster.pixels.size(); i += 4) {
const int r = raster.pixels[i], g = raster.pixels[i + 1], b = raster.pixels[i + 2], a = raster.pixels[i + 3];
const int high = std::max({r, g, b}), low = std::min({r, g, b});
if (a < 200 || high - low < 60 || high < 70) continue;
double hue = high == r ? double(g - b) / (high - low) : high == g ? 2 + double(b - r) / (high - low) : 4 + double(r - g) / (high - low);
if (hue < 0) hue += 6;
const size_t bucket = size_t(hue * 2) % 12;
const double w = double(high - low) / 255;
weight[bucket] += w; red[bucket] += r * w; green[bucket] += g * w; blue[bucket] += b * w;
}
const size_t best = size_t(std::max_element(weight.begin(), weight.end()) - weight.begin());
if (weight[best] > 40) {
double r = red[best] / weight[best], g = green[best] / weight[best], b = blue[best] / weight[best];
// white type needs a dark ground
const double light = (.299 * r + .587 * g + .114 * b) / 255;
if (light > .46) { const double f = .46 / light; r *= f; g *= f; b *= f; }
char text[8];
std::snprintf(text, sizeof text, "#%02x%02x%02x", int(r), int(g), int(b));
colour = text;
}
}
keys_[identity] = colour;
return colour;
}
Picture crest(const std::string &key, bool light_surface) {
const auto source = image(key, true);
if (!light_surface || source.token.empty()) return source;
@@ -486,6 +520,7 @@ class App final : public Rml::EventListener {
uint64_t opening_due_ = 0;
bool opening_io_blocked_ = false;
int last_tactic_ = 0;
std::string window_shown_ = "\x01"; // the menu whose window is on screen (window())
#include "modern/ui/engine_state.inc"
#include "modern/ui/settings_state.inc"
@@ -573,7 +608,10 @@ class App final : public Rml::EventListener {
}
std::string window(const std::string &heading, const std::string &content,
bool close = true) {
return "<div class=\"window\"><div class=\"titlebar\">" +
// a sheet of paper on two more; it slides in once when its menu opens, not on every redraw
const std::string arriving = window_shown_ == menu_ ? "" : " window-in";
window_shown_ = menu_;
return "<div class=\"sheet-under first" + arriving + "\"></div><div class=\"sheet-under second" + arriving + "\"></div><div class=\"window" + arriving + "\"><div class=\"titlebar\">" +
(close ? btn("close", "<span>×</span>", "close", "id=\"window-close\" aria-label=\"" + std::string(menu_ == "bank" && bank_view_ != "entrance" ? "Zurück zur Bankhalle" : "Fenster schließen") + "\"")
: "<span style=\"width:76dp;\"></span>") +
"<h1>" + esc(heading) + "</h1></div><div class=\"content\">" +
@@ -882,7 +920,8 @@ class App final : public Rml::EventListener {
}
// Called after the stage was rebuilt: zoom in when it now shows a menu window.
void sync_window_zoom() {
const bool wanted = doc_->QuerySelector(".window") != nullptr;
const bool wanted = doc_->QuerySelector(".window") != nullptr || doc_->QuerySelector(".live-stage") != nullptr;
if (!wanted) window_shown_ = "\x01";
if (wanted == window_zoom_) return;
window_zoom_ = wanted;
resize();
@@ -1280,6 +1319,30 @@ class App final : public Rml::EventListener {
bold_italic = Rml::LoadFontFace(
rml::asset_path(assets_ / "LatoLatin-BoldItalic.ttf"), "Modern",
Rml::Style::FontStyle::Italic, Rml::Style::FontWeight::Bold);
// The display serif for headings and names, and the chalk hand of the tactics board;
// both ship with the game. Without the files the text falls back to the system fonts below.
const auto own = assets_ / "fonts";
bool display = fs::exists(own / "SourceSerif4-Regular.ttf") &&
Rml::LoadFontFace(rml::asset_path(own / "SourceSerif4-Regular.ttf"), "Display", Rml::Style::FontStyle::Normal, Rml::Style::FontWeight::Normal);
if (display && fs::exists(own / "SourceSerif4-Semibold.ttf"))
Rml::LoadFontFace(rml::asset_path(own / "SourceSerif4-Semibold.ttf"), "Display", Rml::Style::FontStyle::Normal, Rml::Style::FontWeight::Bold);
bool chalk = fs::exists(own / "CabinSketch-Regular.ttf") &&
Rml::LoadFontFace(rml::asset_path(own / "CabinSketch-Regular.ttf"), "Chalk", Rml::Style::FontStyle::Normal, Rml::Style::FontWeight::Normal);
if (chalk && fs::exists(own / "CabinSketch-Bold.ttf"))
Rml::LoadFontFace(rml::asset_path(own / "CabinSketch-Bold.ttf"), "Chalk", Rml::Style::FontStyle::Normal, Rml::Style::FontWeight::Bold);
if (!display) {
std::vector<fs::path> serif;
#ifdef _WIN32
if (const char *windir = std::getenv("WINDIR")) serif = {fs::path(windir) / "Fonts" / "georgia.ttf", fs::path(windir) / "Fonts" / "times.ttf"};
#elif defined(__APPLE__)
serif = {"/System/Library/Fonts/Supplemental/Georgia.ttf", "/System/Library/Fonts/NewYork.ttf", "/System/Library/Fonts/Times.ttc"};
#else
serif = {"/usr/share/fonts/truetype/liberation2/LiberationSerif-Regular.ttf", "/usr/share/fonts/truetype/liberation/LiberationSerif-Regular.ttf"};
#endif
serif.push_back(assets_ / "LatoLatin-Regular.ttf");
for (const auto &font : serif)
if (fs::exists(font) && Rml::LoadFontFace(rml::asset_path(font), "Display", Rml::Style::FontStyle::Normal, Rml::Style::FontWeight::Normal)) break;
}
std::vector<fs::path> chalk_fonts;
#ifdef _WIN32
if (const char *windir = std::getenv("WINDIR")) {
@@ -1296,6 +1359,7 @@ class App final : public Rml::EventListener {
"/usr/share/fonts/truetype/liberation/LiberationSerif-Regular.ttf"};
#endif
chalk_fonts.push_back(assets_ / "LatoLatin-Regular.ttf");
if (!chalk)
for (const auto &font : chalk_fonts)
if (fs::exists(font) && Rml::LoadFontFace(rml::asset_path(font), "Chalk",
Rml::Style::FontStyle::Normal,