Complete Modern season preparation with persistent draw progress (by Codex)
This commit is contained in:
1 parent
967520190d
commit
e81ecf95f2
27 files changed
+1432
-208
No files matched your search
@@ -72,108 +72,6 @@ std::string App::render_desktop() {
|
||||
}
|
||||
return out + "</div>";
|
||||
}
|
||||
std::string App::render_opening() {
|
||||
const std::array<const char *, 3> names = {"UEFA-Cup", "Champions League",
|
||||
"Europapokal der Pokalsieger"};
|
||||
const auto german = world_->clubs("comp:de-1");
|
||||
std::vector<const Json *> pool;
|
||||
for (auto *l : world_->leagues("nation:de"))
|
||||
for (auto *c : world_->clubs(l->value("id", "")))
|
||||
if (pool.size() < 64)
|
||||
pool.push_back(c);
|
||||
std::string body;
|
||||
if (opening_page_ < 3) {
|
||||
body = "<h2 style=\"font-size:46dp;\">" +
|
||||
std::string(names[size_t(opening_page_)]) +
|
||||
"</h2><p class=\"small\" style=\"margin-top:16dp;\">Deutsche Teams "
|
||||
"· Saison " +
|
||||
esc(snap().state.value("date", std::string()).substr(0, 4)) + "</p>";
|
||||
const int count = opening_page_ == 0 ? 4 : 1;
|
||||
for (int i = 0; i < count && size_t(i) < german.size(); ++i) {
|
||||
const auto *c = german[size_t((i + opening_page_) % int(german.size()))];
|
||||
const bool single = count == 1;
|
||||
const int x = single ? 704 : 150 + (i % 2) * 1178,
|
||||
y = single ? 360 : 180 + (i / 2) * 730;
|
||||
body += "<div class=\"panel center\" style=\"position:absolute;" +
|
||||
rect(x, y, single ? 1200 : 1128, single ? 1000 : 680) +
|
||||
"padding:65dp;\">" + crest(c, single ? 620 : 360) +
|
||||
"<h3 style=\"margin-top:26dp;font-size:" +
|
||||
std::to_string(single ? 64 : 50) + "dp;font-weight:normal;\">" +
|
||||
esc(world_->name(*c)) + "</h3></div>";
|
||||
}
|
||||
body +=
|
||||
"<div class=\"bottom-controls\" style=\"justify-content:flex-end;\">" +
|
||||
btn("opening-next", "Weiter", "primary",
|
||||
"style=\"flex:none;width:390dp;\"") +
|
||||
"</div>";
|
||||
} else {
|
||||
const auto pair = [&](int index, int known, int size) {
|
||||
const size_t a = size_t(index * 2), b = a + 1;
|
||||
if (b >= pool.size())
|
||||
return std::string();
|
||||
const auto label_for = [&](const Json *c, bool home, bool visible) {
|
||||
const auto text = "<span class=\"opening-pair-name\">" +
|
||||
(visible ? esc(world_->name(*c)) : home ? "Heim" : "Noch nicht gezogen") + "</span>";
|
||||
const auto logo = visible ? crest(c, size) : "";
|
||||
return "<span class=\"opening-pair-side " + std::string(home ? "home" : "away") + "\">" +
|
||||
(home ? text + logo : logo + text) + "</span>";
|
||||
};
|
||||
return "<div class=\"opening-pair-row " + std::string(size == 36 ? "compact" : size == 66 ? "current" : "") +
|
||||
"\"><span class=\"opening-pair-number\"><span>" + std::to_string(index + 1) + "</span></span>" +
|
||||
label_for(pool[a], true, known > 0) + "<span class=\"opening-pair-versus\"><span>–</span></span>" +
|
||||
label_for(pool[b], false, known > 1) + "<span class=\"opening-pair-counter\" aria-hidden=\"true\"></span></div>";
|
||||
};
|
||||
body = "<h2 style=\"font-size:46dp;\">" +
|
||||
std::string(opening_page_ == 3 ? "1. Runde" : "DFB-Pokal") +
|
||||
"</h2><p class=\"small\" style=\"margin-top:16dp;\">" +
|
||||
(opening_page_ == 3 ? "DFB-Pokal · Saison " : "1. Runde · Saison ") +
|
||||
esc(snap().state.value("date", std::string()).substr(0, 4)) + "</p>";
|
||||
if (opening_page_ == 3) {
|
||||
body += "<span class=\"small\" "
|
||||
"style=\"position:absolute;right:0;top:20dp;\">" +
|
||||
std::to_string(draw_revealed_) +
|
||||
" / 64 Mannschaften</span><div style=\"position:absolute;" +
|
||||
rect(0, 138, 2608, 850) + "\">" +
|
||||
img("art.cup-draw-v1.png", 2608, 850, false, false, 1800) +
|
||||
"</div>";
|
||||
const int current = std::max(0, (draw_revealed_ - 1) / 2),
|
||||
known = draw_revealed_ ? draw_revealed_ - current * 2 : 0;
|
||||
body += "<div class=\"panel\" style=\"position:absolute;" +
|
||||
rect(130, 1026, 2352, 126) +
|
||||
"padding:10dp 28dp;font-size:38dp;\">" +
|
||||
pair(current, known, 66) + "</div>";
|
||||
for (int i = std::max(0, current - 3); i < current; ++i)
|
||||
body +=
|
||||
"<div style=\"position:absolute;" +
|
||||
rect(158, 1190 + (i - std::max(0, current - 3)) * 155, 2296, 145) +
|
||||
"border-bottom:2dp var(--border);\">" + pair(i, 2, 42) + "</div>";
|
||||
body += "<div class=\"bottom-controls\" "
|
||||
"style=\"justify-content:flex-end;\">" +
|
||||
btn("opening-play", draw_playing_ ? "Pause" : "Fortsetzen", {},
|
||||
"style=\"flex:none;width:390dp;\"") +
|
||||
btn("opening-all", "Alle Paarungen anzeigen", {},
|
||||
"style=\"flex:none;width:600dp;\"") +
|
||||
"</div>";
|
||||
} else {
|
||||
for (int column = 0; column < 2; ++column) {
|
||||
body += "<div class=\"panel\" style=\"position:absolute;" +
|
||||
rect(column * 1323, 154, 1289, 1500) + "padding:12dp 18dp;\">";
|
||||
for (int row = 0; row < 16; ++row)
|
||||
body += "<div style=\"height:92dp;font-size:27dp;border-bottom:1dp "
|
||||
"var(--border);\">" +
|
||||
pair(column * 16 + row, 2, 36) + "</div>";
|
||||
body += "</div>";
|
||||
}
|
||||
body += "<div class=\"bottom-controls\" "
|
||||
"style=\"justify-content:flex-end;\">" +
|
||||
btn("opening-finish", "Weiter zum Desktop", "primary",
|
||||
"style=\"flex:none;width:550dp;\"") +
|
||||
"</div>";
|
||||
}
|
||||
}
|
||||
return window(opening_page_ < 3 ? "Deutsche Teams" : "DFB-Pokal", body,
|
||||
false);
|
||||
}
|
||||
std::string App::render_camp() {
|
||||
const auto index_file =
|
||||
Json::parse(editor::read_file(gui_.root() / "gui-assets.json"));
|
||||
|
||||
Reference in new issue
Block a user