Bind native balance planning and restore its saved runtime value (by Codex)

This commit is contained in:
Codex committed 2026-10-29 13:32:10 +01:00
1 parent 256d6d5211
commit fd5c2b5330
24 files changed
+717 -28

No files matched your search

+10 -10
View File
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-3.0-only
std::string App::render_balance() {
const auto rows = demo_balance_rows(snap().state, *world_);
const auto rows = balance_rows();
if (!rows.value("ok", false)) throw editor::Error("Die Bilanzdaten sind ungültig.");
std::string out = "<div class=\"balance-native\">";
if (balance_future_) {
@@ -9,13 +9,13 @@ std::string App::render_balance() {
for (const auto &row : rows.at("plan")) {
const auto name = row.at("name").get<std::string>();
out += "<div class=\"balance-plan-row\"><span>" + esc(name) + "</span>" +
btn("balance-plan", esc(number(row.at("amount").get<int64_t>() / finance_currency_factor(*world_))),
btn("balance-plan", esc(number(row.at("amount").get<int64_t>() / (engine_mode_?100:finance_currency_factor(*world_)))),
"balance-plan-value amount-trigger", "id=\"balance-plan-" + std::to_string(i) +
"\" data-id=\"" + std::to_string(i) + "\" aria-label=\"" + esc(name + " in " + (money_unit() == "€" ? "Euro" : money_unit())) + "\"") + "</div>";
"\" data-id=\"" + std::to_string(i) + "\" aria-label=\"" + esc(name + " in " + (engine_mode_?"Euro":money_unit() == "€" ? "Euro" : money_unit())) + "\" " + std::string(engine_mode_&&row.at("editable")!=true?"disabled":"")) + "</div>";
++i;
}
out += "</div></section><p class=\"balance-plan-total\"><span>Geplante Ausgaben</span><span>" +
esc(cash(rows.at("plan_total").get<int64_t>())) + "</span></p>";
esc(balance_cash(rows.at("plan_total").get<int64_t>())) + "</span></p>";
} else {
int index = 0;
for (const auto &kind : {std::string("income"), std::string("costs")}) {
@@ -25,7 +25,7 @@ std::string App::render_balance() {
int n = 0;
for (const auto &row : rows.at(kind)) {
out += "<div class=\"balance-row" + std::string(n++ % 2 == 0 ? " striped" : "") + "\"><span>" +
esc(row.at("name").get<std::string>()) + "</span><span>" + esc(cash(row.at("amount").get<int64_t>())) + "</span></div>";
esc(row.at("name").get<std::string>()) + "</span><span>" + esc(balance_cash(row.at("amount").get<int64_t>())) + "</span></div>";
}
out += "</div></section>";
}
@@ -33,15 +33,15 @@ std::string App::render_balance() {
number(rows.at("league_home_games").get<int64_t>()) + " Liga-Heimspiele",
number(rows.at("other_home_games").get<int64_t>()) + " sonstige Heimspiele",
"Zuschauerschnitt: " + number(rows.at("attendance_average").get<int64_t>()),
"Eintrittspreis: " + cash(rows.at("ticket").get<int64_t>()),
"Kontostand: " + cash(rows.at("cash").get<int64_t>()),
"Saldo: " + cash(rows.at("balance").get<int64_t>())};
"Eintrittspreis: " + balance_cash(rows.at("ticket").get<int64_t>()),
"Kontostand: " + balance_cash(rows.at("cash").get<int64_t>()),
"Saldo: " + balance_cash(rows.at("balance").get<int64_t>())};
for (int i = 0; i < 6; ++i)
out += "<p class=\"balance-summary-item" + std::string(i == 5 ? " balance-net" : "") + "\" style=\"" +
out += "<p class=\"balance-summary-item" + std::string(i == 5 ? " balance-net" : "") + (engine_mode_&&(i==4||i==5)?" "+money_classes(rows.at(i==4?"cash":"balance").get<int64_t>()):std::string()) + "\" style=\"" +
rect(26 + (i % 2) * 1310, 1526 + (i / 2) * 68, 1250, 38) + "\">" + esc(values[size_t(i)]) + "</p>";
}
out += btn("balance-toggle", "<span>" + std::string(balance_future_ ? "Zukunft" : "Aktuell") +
"</span><span class=\"balance-cycle\" aria-hidden=\"true\"><span class=\"cycle-line cycle-top\"></span><span class=\"cycle-line cycle-bottom\"></span><span class=\"cycle-head cycle-right\"></span><span class=\"cycle-head cycle-left\"></span></span>", "balance-toggle report-reset",
"id=\"balance-toggle\" aria-label=\"Zwischen aktueller Bilanz und Zukunftsplanung wechseln\"");
return out + "</div>";
return out + (engine_mode_?"<p id=\"balance-engine-feedback\" style=\"position:absolute;left:0;right:0;bottom:106dp;font-size:24dp;line-height:28dp;\">"+esc(engine_busy_?engine_operation_:engine_balance_feedback_)+"</p>":"") + "</div>";
}