diff --git a/assets/modern/advertising.rcss b/assets/modern/advertising.rcss index 678046c..10483ac 100644 --- a/assets/modern/advertising.rcss +++ b/assets/modern/advertising.rcss @@ -1,72 +1,2 @@ /* SPDX-License-Identifier: GPL-3.0-only */ -.advertising-page {position:absolute;left:0;right:0;top:0;bottom:0;} -.advertising-boards {position:absolute;left:0;right:0;top:0;height:310dp;border:2dp var(--border);border-radius:18dp;background-color:#13232e40;} -.advertising-board {position:absolute;min-width:0;min-height:0;padding:16dp 12dp 40dp;border:2dp var(--border);border-radius:12dp;background-color:transparent;decorator:linear-gradient(180deg,#90a6b51c,#6b83950d);color:var(--text);font-size:28dp;display:flex;align-items:center;justify-content:center;} -.advertising-board:hover {background-color:#c5d9e726;} -.advertising-board small {position:absolute;left:0;right:0;width:100%;bottom:10dp;text-align:center;font-size:28dp;line-height:25dp;color:var(--muted);} -.advertising-board small>span,.advertising-free {display:block;width:100%;text-align:center;white-space:nowrap;} -.advertising-free {font-size:28dp;line-height:31dp;color:#bdcdd8;} -.advertising-board.selected,.advertising-card.selected {border-color:var(--accent);} -.ad-brand {display:flex;align-items:center;justify-content:center;min-width:0;max-width:100%;background-color:#f5efdc;color:#12334b;padding:10dp 16dp;font-size:38dp;font-weight:bold;line-height:1.2;letter-spacing:1dp;overflow:hidden;} -.ad-brand>span {display:block;width:100%;text-align:center;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;} -.ad-brand-1 {background-color:#154c7b;color:#fcf6c9;} -.ad-brand-2 {background-color:#f4cc55;color:#3e3630;} -.ad-brand-3 {background-color:#daddce;color:#ab2d2d;} -.ad-brand-4 {background-color:#c73529;color:#ffebc5;} -.advertising-board .ad-brand {width:100%;min-height:62dp;padding:8dp;border-radius:5dp;font-size:28dp;letter-spacing:.5dp;} -.advertising-card {position:absolute;min-width:0;padding:0;border:2dp var(--border);border-radius:18dp;background-color:#11263266;color:var(--text);font-size:30dp;overflow:hidden;} -.advertising-card:hover {background-color:#20374380;} -.advertising-card>strong {position:absolute;left:0;right:0;top:0;height:64dp;border-bottom:2dp var(--border);background-color:#90a8b410;font-size:30dp;font-weight:normal;display:flex;align-items:center;justify-content:center;} -.advertising-card>strong>span {display:block;width:100%;text-align:center;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;} -.advertising-art {position:absolute;left:61.25dp;top:65dp;width:510dp;height:510dp;} -.advertising-shirt .advertising-art {top:100dp;} -.advertising-card>output {position:absolute;left:0;right:0;bottom:0;height:70dp;border-top:2dp var(--border);background-color:#10232e66;color:#b8dfd0;font-size:33dp;display:flex;align-items:center;justify-content:center;} -.advertising-card>output>span {display:block;width:100%;text-align:center;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;} -.advertising-shirt>.ad-brand {position:absolute;left:35%;top:52%;width:30%;max-height:94dp;padding:4dp;font-size:21dp;border-radius:4dp;} -.advertising-tv {left:0;top:1032dp;width:596dp;height:638dp;} -.advertising-tv-art {position:absolute;left:26dp;top:79dp;width:540dp;height:540dp;} -.advertising-tv>.ad-brand {position:absolute;left:14%;top:26%;width:35%;height:20%;padding:4dp;font-size:22dp;border-radius:8dp;} -.advertising-details {position:absolute;left:636dp;right:0;top:1032dp;bottom:4dp;border:2dp var(--border);border-radius:18dp;background-color:#13232e40;} -.advertising-hint {position:absolute;left:60dp;right:60dp;top:88dp;font-size:29dp;line-height:46.4dp;text-align:left;color:#a4bacb;} -.advertising-hint h2 {margin:0 0 30dp;font-size:38dp;line-height:60.8dp;font-weight:normal;color:var(--text);} -.advertising-hint p {margin:12dp 0;} -.advertising-offer {position:absolute;left:32dp;right:32dp;top:28dp;height:310dp;} -.ad-offer-mark {position:absolute;left:0;top:70dp;width:430dp;height:170dp;} -.ad-offer-mark .ad-brand {width:430dp;height:170dp;padding:16dp;border-radius:12dp;font-size:38dp;} -.ad-offer-arrows {position:absolute;left:458dp;top:70dp;width:84dp;height:170dp;display:flex;flex-direction:column;gap:18dp;} -.ad-offer-arrow {width:84dp;height:76dp;flex-shrink:0;padding:0;border-radius:12dp;font-size:52dp;line-height:52dp;display:flex;align-items:center;justify-content:center;color:#bfd5e4;} -.ad-offer-arrow>span {display:block;width:100%;text-align:center;} -.ad-offer-facts {position:absolute;left:570dp;right:0;top:82dp;height:146dp;font-size:30dp;line-height:34dp;} -.ad-offer-facts>div {height:56dp;display:flex;gap:28dp;} -.ad-offer-facts>div>span {display:block;width:200dp;flex-shrink:0;color:#9fb7c9;white-space:nowrap;} -.ad-offer-facts>div:first-child>span {color:var(--text);} -.ad-offer-facts>div>strong {display:block;flex:1;min-width:0;font-weight:normal;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;} -.advertising-actions {position:absolute;left:32dp;right:32dp;top:356dp;height:82dp;display:flex;gap:24dp;} -.advertising-control {flex:1;min-width:0;height:82dp;padding:12dp 24dp;border-radius:12dp;font-size:30dp;background-color:transparent;decorator:linear-gradient(180deg,#c1d1e31c,#869eb312);} -.advertising-totals {position:absolute;left:32dp;right:32dp;bottom:28dp;height:105dp;border-top:2dp var(--border);padding-top:24dp;display:flex;gap:24dp;font-size:28dp;line-height:29dp;} -.advertising-totals>div {flex:1;min-width:0;} -.advertising-totals>div>span {display:block;width:100%;color:#a0b7c8;white-space:nowrap;} -.advertising-totals output {display:block;width:100%;margin-top:12dp;font-size:33dp;line-height:38dp;white-space:nowrap;color:var(--text);} -.advertising-totals>div:last-child>output {color:#b8dfd0;} -body.silver .advertising-boards,body.silver .advertising-details,body.silver .advertising-card,body.silver .advertising-card>output {background-color:#fcf9f190;} -body.silver .advertising-board {decorator:linear-gradient(180deg,#ffffffd8,#e9e1cf99);} -body.silver .advertising-board:hover,body.silver .advertising-card:hover {background-color:#ffffff80;} -body.silver .advertising-free,body.silver .advertising-hint,body.silver .ad-offer-facts>div>span,body.silver .advertising-totals>div>span {color:#526779;} -body.silver .ad-offer-arrow {color:#233443;} -body.silver .advertising-card>output,body.silver .advertising-totals>div:last-child>output {color:#25617a;} -body.silver .advertising-control {decorator:linear-gradient(180deg,#ffffffd8,#e9e1cf99);} -body.matchday .advertising-boards,body.matchday .advertising-details,body.matchday .advertising-card,body.matchday .advertising-card>output {background-color:#1d1e2466;} -body.matchday .advertising-board {decorator:linear-gradient(180deg,#e8d6dc12,#a1a0aa0d);} -body.matchday .advertising-board:hover,body.matchday .advertising-card:hover {background-color:#ffffff12;} -body.matchday .advertising-free,body.matchday .advertising-hint,body.matchday .ad-offer-facts>div>span,body.matchday .advertising-totals>div>span {color:#b7b4b9;} -body.matchday .ad-offer-arrow {color:#efeded;} -body.matchday .advertising-card>output,body.matchday .advertising-totals>div:last-child>output {color:#efb2aa;} -body.matchday .advertising-control {decorator:linear-gradient(180deg,#e8d6dc12,#a1a0aa0d);} - -/* Engine money keeps its sign semantics independently of the skin accent. */ -body .advertising-page .advertising-card>output.money-amount, -body .advertising-page .advertising-totals>div>output.money-amount {color:var(--money);} -body .advertising-page .advertising-card>output.money-amount.is-negative, -body .advertising-page .advertising-totals>div>output.money-amount.is-negative {color:var(--danger);} - -.engine-ad-preview-label {position:absolute;left:32dp;right:32dp;bottom:150dp;height:34dp;font-size:28dp;line-height:30dp;color:var(--muted);} +/* Advertising is a page of the notebook now: its styles are the ad-* rules in pages.rcss. */ diff --git a/assets/modern/art/advertising-scenes.png b/assets/modern/art/advertising-scenes.png new file mode 100644 index 0000000..044f636 Binary files /dev/null and b/assets/modern/art/advertising-scenes.png differ diff --git a/assets/modern/art/advertising-shirt.png b/assets/modern/art/advertising-shirt.png new file mode 100644 index 0000000..2fa714e Binary files /dev/null and b/assets/modern/art/advertising-shirt.png differ diff --git a/assets/modern/art/gui-assets.json b/assets/modern/art/gui-assets.json index 321c9e7..103afe8 100644 --- a/assets/modern/art/gui-assets.json +++ b/assets/modern/art/gui-assets.json @@ -91,6 +91,56 @@ 1, 1 ] + }, + "advertising.scene.merchandise": { + "file": "advertising-scenes.png", + "sha256": "cf7a8a2de9294a8b458114f108fd87fc7936f62a0186673d2bab6f005e0ec5aa", + "crop": [ + 0, + 0, + 0.4972, + 0.4954 + ] + }, + "advertising.scene.press": { + "file": "advertising-scenes.png", + "sha256": "cf7a8a2de9294a8b458114f108fd87fc7936f62a0186673d2bab6f005e0ec5aa", + "crop": [ + 0.5028, + 0, + 0.4972, + 0.4954 + ] + }, + "advertising.scene.fans": { + "file": "advertising-scenes.png", + "sha256": "cf7a8a2de9294a8b458114f108fd87fc7936f62a0186673d2bab6f005e0ec5aa", + "crop": [ + 0, + 0.5028, + 0.4972, + 0.4972 + ] + }, + "advertising.scene.tv": { + "file": "advertising-scenes.png", + "sha256": "cf7a8a2de9294a8b458114f108fd87fc7936f62a0186673d2bab6f005e0ec5aa", + "crop": [ + 0.5028, + 0.5028, + 0.4972, + 0.4972 + ] + }, + "advertising.scene.shirt": { + "file": "advertising-shirt.png", + "sha256": "c96e7ddbb8792d8633ffd24f7de5ef9e0f167e852713e28fddae7cdba2b80225", + "crop": [ + 0, + 0, + 1, + 1 + ] } } } diff --git a/assets/modern/pages.rcss b/assets/modern/pages.rcss index c14b903..2010116 100644 --- a/assets/modern/pages.rcss +++ b/assets/modern/pages.rcss @@ -705,3 +705,34 @@ body.midnight .cp-map-name,body.matchday .cp-map-name {color:#f0ece2;font-effect .mg-hint strong {font-family:Display;font-weight:normal;font-size:36dp;margin-right:12dp;} .mg-owner label {display:block;} .mg-owner select {width:520dp;height:68dp;padding:0 27dp;border:2dp var(--p-div);border-radius:36dp;background-color:var(--p-n1);font-family:Modern;font-size:30dp;color:var(--p-text);} + +/* --- advertising: the ground with its fourteen boards, five pictures, the offers as a note --- */ +.ad-ground {position:relative;display:block;flex:none;width:1714.5dp;height:1395dp;} +.ad-ground img {position:absolute;left:0;top:0;} +.ad-board,.ad-board:hover,.ad-board:focus,.ad-board:disabled {position:absolute;display:block;padding:0;margin:0;border:0dp;border-radius:27dp;background-color:transparent;decorator:none;overflow:visible;} +.ad-board:hover {background-color:#c8733c26;} +.ad-board.selected,.ad-board.selected:hover {background-color:#c8733c33;} +.ad-board-face {position:absolute;left:0;top:0;display:flex;flex-direction:column;align-items:center;justify-content:center;width:100%;height:100%;padding:0 20dp;} +.ad-board-face.right {transform:rotate(90deg);} +.ad-board-face.left {transform:rotate(-90deg);} +.ad-board-no {display:block;width:100%;text-align:center;font-family:Modern;font-size:19dp;line-height:25dp;font-weight:bold;letter-spacing:1.5dp;color:#8c491a;} +.ad-board-face strong {display:block;width:100%;font-family:Modern;font-size:25dp;line-height:31dp;font-weight:bold;text-align:center;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;color:#2e2b25;} +.ad-board-face strong.free {font-weight:normal;color:#56633f;} +.ad-forecast {flex:1;min-height:0;padding:22dp 36dp;} +.ad-forecast .pg-row {gap:27dp;} +.ad-plus {color:var(--p-s8);} +.ad-minus {color:var(--p-a8);} +.ad-tiles {display:flex;flex:1;min-width:0;flex-wrap:wrap;align-content:flex-start;gap:18dp;} +.ad-tile,.ad-tile:hover,.ad-tile:focus,.ad-tile:disabled {position:relative;display:block;flex:none;width:519dp;height:528dp;padding:0;margin:0;border:2dp var(--p-div);border-radius:45dp;background-color:var(--p-n1);decorator:none;overflow:hidden;text-align:left;} +.ad-tile:hover,.ad-tile.selected {border-color:var(--p-a6);} +.ad-tile-art {position:absolute;left:0;top:0;display:block;width:519dp;height:459dp;overflow:hidden;} +.ad-tile-cap {position:absolute;left:0;top:459dp;display:block;width:515dp;height:65dp;line-height:65dp;padding:0 32dp;font-family:Display;font-size:36dp;color:var(--p-text);} +.ad-tile-cap span {display:block;white-space:nowrap;} +.ad-tile-over {position:absolute;left:0;top:259dp;display:none;width:515dp;height:200dp;padding:22dp 32dp 0;background-color:#201e1dd9;color:#f9f4ed;} +.ad-tile:hover .ad-tile-over,.ad-tile:focus .ad-tile-over,.ad-tile.selected .ad-tile-over {display:block;} +.ad-tile-k {display:block;font-family:Modern;font-size:22dp;line-height:30dp;font-weight:bold;letter-spacing:1.5dp;color:#f0b48a;} +.ad-tile-over strong {display:block;font-family:Display;font-weight:normal;font-size:43dp;line-height:54dp;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;color:#f9f4ed;} +.ad-tile-d {display:block;font-family:Modern;font-size:27dp;line-height:36dp;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;color:#e6dccb;} +.ad-note {display:flex;flex-direction:column;flex:none;gap:14dp;width:519dp;height:528dp;padding:32dp 34dp;font-size:28dp;line-height:38dp;} +.ad-note span {display:block;} +.ad-mark {display:block;flex:none;border-radius:36dp;font-family:Display;text-align:center;color:#ffffff;} diff --git a/src/modern/ui/advertising_screens.inc b/src/modern/ui/advertising_screens.inc index c6f4755..2393ae4 100644 --- a/src/modern/ui/advertising_screens.inc +++ b/src/modern/ui/advertising_screens.inc @@ -1,66 +1,173 @@ // SPDX-License-Identifier: GPL-3.0-only +namespace { +// Where the fourteen boards stand around the pitch, in units of the page on a ground of +// 762 x 620: five along the far side, two at each end, five along the near side, numbered +// clockwise from the upper left. +struct AdBoard { double x, y, w, h; int turn; }; // turn: 0 flat, 1 right end, -1 left end +constexpr double ad_ground_w = 762, ad_ground_h = 620; +AdBoard ad_board(int index) { + constexpr double long_w = 117.3, deep = 62, step = 123.4, first = 76.2, tall = 208; + if (index < 5) return {first + index * step, 0, long_w, deep, 0}; + if (index < 7) return {ad_ground_w - deep, 92 + (index - 5) * (tall + 20), deep, tall, 1}; + if (index < 12) return {first + (11 - index) * step, ad_ground_h - deep, long_w, deep, 0}; + return {0, 92 + (13 - index) * (tall + 20), deep, tall, -1}; +} +// The ground seen from above: the apron with its track, the mown pitch with all its lines, +// goals, benches and corner flags, and around it the frames of the fourteen boards: lit where +// a sponsor has signed, an empty frame where the place is free. +std::string ad_ground_svg(const std::array &taken, int chosen) { + const auto n = [](double v) { return scalar(std::round(v * 10) / 10); }; + std::string svg = ""; + // apron and running track + svg += ""; + for (int lane = 0; lane < 3; ++lane) svg += ""; + svg += ""; + // the pitch: eleven mown stripes + constexpr double px = 112, py = 110, pw = 538, ph = 400; + for (int stripe = 0; stripe < 11; ++stripe) + svg += ""; + const double cx = px + pw / 2, cy = py + ph / 2; + svg += ""; + for (const int side : {-1, 1}) { + const double edge = side < 0 ? px : px + pw; + // penalty area, goal area, the arc at the area, the corner arcs + svg += ""; + svg += ""; + svg += ""; + } + svg += ""; + for (const int side : {-1, 1}) { + const double edge = side < 0 ? px : px + pw, back = edge + side * 13; + // the goal with its net, and the flags in the corners + svg += ""; + for (int k = 1; k < 5; ++k) svg += ""; + for (const double flag_y : {py, py + ph}) + svg += ""; + } + // the two benches on the far side, with their roofs + for (const double bench : {cx - 96, cx + 40}) + svg += ""; + // the boards: a shadow towards the pitch, two feet, the frame + for (int i = 0; i < 14; ++i) { + const auto b = ad_board(i); + const bool on = taken[size_t(i)], here = i == chosen; + const double fx = b.x + 4, fy = b.y + 4, fw = b.w - 8, fh = b.h - 8; + svg += ""; + if (b.turn == 0) + for (const double foot : {fx + 14, fx + fw - 14}) svg += ""; + else + for (const double foot : {fy + 16, fy + fh - 16}) svg += " 0 ? fx - 5 : fx + fw - 2) + "\" y=\"" + n(foot - 2) + "\" width=\"7\" height=\"4\" fill=\"#6f6a60\"/>"; + svg += ""; + // a sponsor's board carries a stripe in the accent along its outer edge + if (on) svg += b.turn == 0 ? "" + : " 0 ? fx + fw - 6 : fx + 3) + "\" y=\"" + n(fy + 9) + "\" width=\"3\" height=\"" + n(fh - 18) + "\" rx=\"1.5\" fill=\"#c8733c\"/>"; + } + return svg + ""; +} +// A sponsor's mark where there is no logo: its initials on a rounded square of a colour of its own. +std::string ad_mark(const std::string &name, double size) { + static constexpr std::array colours{"#8c491a", "#56633f", "#2b6f8f", "#a8452f", "#6b5a48", "#3d6f5a"}; + unsigned sum = 0; + std::string initials; + bool start = true; + for (size_t i = 0; i < name.size(); ++i) { + const auto c = static_cast(name[i]); + sum += c; + if (c == ' ' || c == '-' || c == '.') { start = true; continue; } + if (start && initials.size() < 2 && c < 128 && std::isalnum(c)) initials += char(std::toupper(c)); + start = false; + } + if (initials.empty()) initials = "·"; + return "" + esc(initials) + ""; +} +} // namespace + +// Verein > Werbung: the ground with its fourteen boards on the left, the five pictures for +// shirt, television and the three budgets on the right. The pointer on a picture shows what +// stands there today; a click opens the offers as a note, or the number pad of a budget. std::string App::render_advertising() { const auto snapshot = engine_mode_ ? Snapshot{input_revision(), world_, Json::object()} : snap(); const auto view = engine_mode_ ? engine_advertising_projection(engine_data_) : demo_advertising_view(snapshot.state, *world_); const auto ad_cash = [&](int64_t value) { return engine_mode_ ? money(value, {{"code", "EUR"}, {"minor_units", 2}}) : cash(value); }; if (!view.value("ok", false)) return {}; - const auto brand = [&](const Json &c) { - if (c.at("sponsor") == -1) return std::string(); - return "() % 5) + - "\">" + esc(c.at("name").get()) + ""; + const auto &slots = view.at("slots"); + const auto taken_at = [&](int i) { return slots[size_t(i)].at("active") == true; }; + std::array taken{}; + int signed_boards = 0; + for (int i = 0; i < 14; ++i) if ((taken[size_t(i)] = taken_at(i))) ++signed_boards; + page_hint_ = std::to_string(signed_boards) + " von 14 Banden vergeben"; + // what a contract says today + const auto terms = [&](const Json &slot) { + return std::to_string(slot.value("months", 0)) + (slot.value("months", 0) == 1 ? " Monat" : " Monate") + " · " + ad_cash(slot.value("amount", int64_t(0))) + " / Monat"; }; - std::string out = "
"; + std::string out = "
" + + picture(renderer_.diagram("advertising-ground", ad_ground_svg(taken, advertising_selected_ >= 0 && advertising_selected_ < 14 ? advertising_selected_ : -1), 2400), ad_ground_w * 2.25, ad_ground_h * 2.25); for (int i = 0; i < 14; ++i) { - const auto &c = view.at("slots")[size_t(i)]; - out += btn("ad-contract", (c.at("active") == true ? brand(c) : "Platz frei") + - "Bande " + std::to_string(i + 1) + "", "advertising-board " + std::string(advertising_selected_ == i ? "selected" : ""), - "id=\"ad-contract-" + std::to_string(i) + "\" data-ad-contract=\"" + std::to_string(i) + "\" data-id=\"" + std::to_string(i) + - "\" aria-pressed=\"" + (advertising_selected_ == i ? "true" : "false") + "\" aria-label=\"Bande " + std::to_string(i + 1) + ", " + - esc(c.at("name").get()) + "\" style=\"" + rect(16 + (i % 7) * (354.285714 + 16), 16 + (i / 7) * 145, 354.285714, 129) + "\""); + const auto &c = slots[size_t(i)]; + const auto b = ad_board(i); + const bool on = taken[size_t(i)]; + const auto name = c.at("name").get(); + // the boards at the ends are read from the pitch: their writing stands upright + const std::string face = " 0 ? " right" : b.turn < 0 ? " left" : "") + "\" style=\"" + (b.turn ? "left:" + pg((b.w - b.h) / 2) + ";top:" + pg((b.h - b.w) / 2) + ";width:" + pg(b.h) + ";height:" + pg(b.w) + ";" : std::string()) + + "\">BANDE " + std::to_string(i + 1) + "" + esc(on ? name : "Platz frei") + ""; + out += btn("ad-contract", face, std::string("ad-board") + (on ? " on" : "") + (advertising_selected_ == i ? " selected" : ""), + "id=\"ad-contract-" + std::to_string(i) + "\" data-ad-contract=\"" + std::to_string(i) + "\" data-id=\"" + std::to_string(i) + "\" aria-pressed=\"" + (advertising_selected_ == i ? "true" : "false") + "\" aria-label=\"Bande " + std::to_string(i + 1) + ", " + + esc(on ? name + ", " + terms(c) : std::string("Platz frei")) + "\" title=\"" + esc(on ? name + " · " + terms(c) : std::string("Platz frei · anklicken für Angebote")) + "\" style=\"left:" + pg(b.x) + ";top:" + pg(b.y) + ";width:" + pg(b.w) + ";height:" + pg(b.h) + ";\""); } - out += "
"; - const std::array headings{"Trikotwerbung", "Fanartikel", "Öffentlichkeitsarbeit", "Fanbetreuung"}; - for (int i = 0; i < 4; ++i) { - std::string body = "" + std::string(headings[size_t(i)]) + "
" + - img("advertising.panel." + std::to_string(i), 510, 510, false, false, 1000) + "
"; - if (i == 0) body += brand(view.at("slots")[14]); - else body += "" + esc(ad_cash(view.at("spending")[size_t(i - 1)].at("amount").get())) + ""; - out += btn(i == 0 ? "ad-contract" : "ad-spending", body, - "advertising-card advertising-panel " + std::string(i == 0 ? "advertising-shirt " : "") + (i == 0 && advertising_selected_ == 14 ? "selected" : ""), - "id=\"" + std::string(i == 0 ? "ad-contract-14" : "ad-spending-" + std::to_string(i - 1)) + "\" data-id=\"" + std::to_string(i == 0 ? 14 : i - 1) + - "\" " + (i == 0 ? "data-ad-contract=\"14\" aria-pressed=\"" + std::string(advertising_selected_ == 14 ? "true" : "false") + "\" " - : "data-ad-spending=\"" + std::to_string(i - 1) + "\" ") + - "style=\"" + rect(i * 658.5, 346, 636.5, 650) + "\""); + out += "
" + pg_kicker("Vereinsprognose / Monat") + "
"; + for (const auto &[label, key] : std::array, 3>{{{"Einnahmen", "income"}, {"Ausgaben", "expenses"}, {"Saldo", "balance"}}}) { + const auto value = view.at(key).get(); + out += "
" + std::string(label) + "= 0 ? " ad-plus" : " ad-minus") : "") + "\">" + + esc((std::string(key) == "balance" && value > 0 ? "+ " : "") + ad_cash(value)) + "
"; } - out += btn("ad-contract", "TV-Rechte
" + - img("art.advertising-tv-v1.png", 540, 540, false, false, 1000) + "
" + brand(view.at("slots")[15]), - "advertising-card advertising-tv " + std::string(advertising_selected_ == 15 ? "selected" : ""), - "id=\"ad-contract-15\" data-ad-contract=\"15\" data-id=\"15\" aria-pressed=\"" + std::string(advertising_selected_ == 15 ? "true" : "false") + "\""); - out += "
"; - if (advertising_selected_ < 0 || advertising_selected_ > 15) { - out += "

Werbung und Vereinsausgaben

" - "

Bande, Trikot oder TV-Rechte auswählen.

Die drei Ausgabenbilder öffnen die Zahleneingabe.

"; - } else { - const auto &choices = engine_mode_ ? view.at("slots")[size_t(advertising_selected_)].at("choices") : Json::array(); - if (engine_mode_) advertising_offer_ = std::clamp(advertising_offer_, 0, int(choices.size()) - 1); - const auto quote = engine_mode_ ? engine_advertising_quote(engine_data_, advertising_selected_, advertising_offer_) : demo_advertising_quote(snapshot.state, advertising_selected_, advertising_offer_, *world_); - const bool active = quote.at("active"); - const bool cycle = engine_mode_ ? quote.at("can_cycle").get() : !active; - const bool accept = engine_mode_ ? quote.at("can_accept").get() : !active; - out += "
" + brand(quote) + - "
" + - btn("ad-offer", "‹", "ad-offer-arrow", "id=\"ad-offer-previous\" data-step=\"-1\" aria-label=\"Vorheriges Angebot\" " + std::string(cycle ? "" : "disabled")) + - btn("ad-offer", "›", "ad-offer-arrow", "id=\"ad-offer-next\" data-step=\"1\" aria-label=\"Nächstes Angebot\" " + std::string(cycle ? "" : "disabled")) + - "
" + esc(quote.at("label").get()) + "" + - esc(quote.at("name").get()) + "
Dauer" + std::to_string(quote.at("months").get()) + - " Monate" + (engine_mode_ && quote.at("boards") > 1 ? " · " + std::to_string(quote.at("boards").get()) + " Banden" : std::string()) + "
" + (active ? "Vertrag" : "Angebot") + "" + - esc(ad_cash(quote.at("amount").get())) + " / Monat
"; + out += "
"; + // the five pictures: the pointer shows what stands there, a click goes on + const auto tile = [&](const std::string &action, const std::string &id, const std::string &attrs, const std::string &art, const std::string &title, const std::string &kicker, const std::string &value, const std::string &detail, bool selected) { + return btn(action, "" + img(art, 520, 459, false, true, 1100) + "" + esc(pg_upper(kicker)) + "" + esc(value) + "" + esc(detail) + + "" + esc(title) + "", + std::string("ad-tile") + (selected ? " selected" : ""), "id=\"" + id + "\" " + attrs + " aria-label=\"" + esc(title + ": " + value + (detail.empty() ? "" : ", " + detail)) + "\""); + }; + for (const auto &[slot, art, title] : std::array, 2>{{{14, "advertising.scene.shirt", "Trikotwerbung"}, {15, "advertising.scene.tv", "TV-Rechte"}}}) { + const auto &c = slots[size_t(slot)]; + const bool on = c.at("active") == true; + out += tile("ad-contract", "ad-contract-" + std::to_string(slot), "data-ad-contract=\"" + std::to_string(slot) + "\" data-id=\"" + std::to_string(slot) + "\" aria-pressed=\"" + (advertising_selected_ == slot ? "true" : "false") + "\"", art, title, + on ? (slot == 14 ? "Aktueller Sponsor" : "Aktueller Sender") : "Platz frei", on ? c.at("name").get() : std::string("Kein Vertrag"), on ? terms(c) : std::string("Anklicken für Angebote"), advertising_selected_ == slot); } - if (engine_mode_) out += "Vereinsprognose / Monat"; - out += "
"; - for (const auto &[label, key] : std::array, 3>{{{"Einnahmen", "income"}, {"Ausgaben", "expenses"}, {"Saldo", "balance"}}}) - out += "
" + std::string(label) + "" + esc(ad_cash(view.at(key).get())) + "
"; - return out + "
"; + static constexpr std::array spending_art{"advertising.scene.merchandise", "advertising.scene.press", "advertising.scene.fans"}; + std::string delivery; + for (int i = 0; i < 3; ++i) { + const auto &row = view.at("spending")[size_t(i)]; + const int weeks = row.value("delivery_weeks", 0); + if (i == 0 && weeks > 0) delivery = "Fanartikel: Die Lieferung läuft noch " + std::to_string(weeks) + (weeks == 1 ? " Woche." : " Wochen."); + out += tile("ad-spending", "ad-spending-" + std::to_string(i), "data-ad-spending=\"" + std::to_string(i) + "\" data-id=\"" + std::to_string(i) + "\"", spending_art[size_t(i)], row.at("name").get(), i == 0 ? "Bestellung" : "Monatsbudget", + ad_cash(row.at("amount").get()), i == 0 && weeks > 0 ? "Lieferung läuft noch" : "Anklicken zum Ändern", false); + } + out += "
Werbung und VereinsausgabenDer Mauszeiger auf einem Bild zeigt den aktuellen Stand. Ein Klick auf eine Bande, das Trikot oder die Kamera blättert durch die Angebote; die drei Ausgaben öffnen das Zahlenfeld." + + (delivery.empty() ? std::string() : "" + esc(delivery) + "") + "
"; + if (advertising_selected_ < 0 || advertising_selected_ > 15) return out; + // the offers for the chosen place, as a note + const auto &choices = engine_mode_ ? slots[size_t(advertising_selected_)].at("choices") : Json::array(); + if (engine_mode_) advertising_offer_ = std::clamp(advertising_offer_, 0, int(choices.size()) - 1); + const auto quote = engine_mode_ ? engine_advertising_quote(engine_data_, advertising_selected_, advertising_offer_) : demo_advertising_quote(snapshot.state, advertising_selected_, advertising_offer_, *world_); + const bool active = quote.at("active"); + const bool cycle = engine_mode_ ? quote.at("can_cycle").get() : !active; + const bool accept = engine_mode_ ? quote.at("can_accept").get() : !active; + const auto place = quote.at("label").get(), sponsor = quote.at("name").get(); + // which of the offers this is: a running contract stands before them + const int running = engine_mode_ && !choices.empty() && choices[0].at("active") == true ? 1 : 0; + const int count = engine_mode_ ? int(choices.size()) - running : 3; + const bool none = engine_mode_ && !active && quote.value("offer_id", Json()).is_null(); + const auto which = active ? std::string("Laufender Vertrag") : none ? std::string("Keine Angebote") : "Angebot " + std::to_string(advertising_offer_ - running + 1) + " von " + std::to_string(std::max(1, count)); + const int boards = engine_mode_ ? quote.value("boards", 1) : 1; + out += "

" + esc(place) + "

" + + std::string(active ? "Der Vertrag läuft; mit den Pfeilen siehst du, was sonst geboten wird." : "Mit den Pfeilen durch die Angebote blättern.") + "
" + (none ? std::string() : ad_mark(sponsor, 171)) + + "
" + pg_kicker(which) + "

" + esc(sponsor) + "

" + + (none ? std::string("Für diesen Platz liegt derzeit nichts vor.") : (active ? "Noch " : "Dauer ") + std::to_string(quote.at("months").get()) + (quote.at("months").get() == 1 ? " Monat" : " Monate") + (boards > 1 ? " · " + std::to_string(boards) + " Banden" : std::string())) + + "
" + (none ? std::string() : "
" + pg_kicker("je Monat") + "" + esc(ad_cash(quote.at("amount").get())) + "
") + "
"; + return out; } diff --git a/src/modern/ui/pages.inc b/src/modern/ui/pages.inc index ebffec8..9ef337f 100644 --- a/src/modern/ui/pages.inc +++ b/src/modern/ui/pages.inc @@ -6,7 +6,7 @@ // sheet of the old format, shown scaled inside the book. bool App::page_native() const { if (scene_ == "managerhub") return true; - static const std::set native{"camp", "toto", "settings", "save", "load", "stadium", "statistics", "news", "transfer", "training", "almanac", "tactics", "achievements", "highscore", "balance", "contracts", "environment", "tables", "league", "other", "strengths", "fairplay", "indoor", "scorers"}; + static const std::set native{"advertising", "camp", "toto", "settings", "save", "load", "stadium", "statistics", "news", "transfer", "training", "almanac", "tactics", "achievements", "highscore", "balance", "contracts", "environment", "tables", "league", "other", "strengths", "fairplay", "indoor", "scorers"}; if (menu_ == "calendar" || menu_ == "postpone" || menu_ == "lineup") return notebook_page() && engine_mode_; // a national coach arranges friendlies on the older sheet if (menu_ == "friendlies") return notebook_page() && engine_mode_ && engine_data_.contains("desktop") && engine_data_.at("desktop").at("meta").at("scope").at("role") == "club";