Populate native desktop status, fixture and news widgets from the session (by Codex)

This commit is contained in:
Codex committed 2026-10-29 13:58:57 +01:00
1 parent fd5c2b5330
commit dc911f3281
21 files changed
+419 -91

No files matched your search

+54 -45
View File
@@ -64,6 +64,58 @@ std::string App::widget_curve(const std::string &id, const Json &o, int w,
(void)o;
return out;
}
std::string App::widget_warnings(const Json &rows, const Json &o) {
const int w = o.at("w"), h = o.at("h");
const bool wide = h == 224;
const std::vector<std::vector<int>> groups =
wide ? std::vector<std::vector<int>>{{0}, {1}, {2}, {3, 4},
{5, 6}, {7}, {8}, {9}}
: std::vector<std::vector<int>>{{0}, {1}, {2}, {3}, {4},
{5}, {6}, {7}, {8}, {9}};
std::string out = widget_heading("Vereinsstatus", false) +
"<div class=\"desk-warning-grid\">";
const int cols = wide ? 8 : 5,
cw = (w - (wide ? 56 : 52) - (wide ? 7 * 18 : 4 * 14)) / cols,
rh = wide ? h - 76 : (h - 120) / 2;
for (size_t i = 0; i < groups.size(); ++i) {
std::string label, key;
bool attention = false, known = true;
for (int n : groups[i]) {
const auto &v = rows[size_t(n)];
if (!label.empty()) {
label += " & ";
key += ",";
}
label += v.at("name").get<std::string>();
key += std::to_string(n);
attention = attention || v.at("attention") == true;
known = known && v.at("attention").is_boolean();
}
const auto &v = rows[size_t(groups[i][0])];
out += btn(engine_mode_ ? "engine-widget-warning" : "widget-warning",
"<span class=\"status-lamp " +
std::string(attention ? "attention"
: known ? "okay"
: "unknown") +
"\">" + glyph(v.at("icon"), h == 720 ? 42 : 28) + "</span>" +
(wide ? ""
: "<span class=\"warning-caption\">" + esc(label) +
"</span>"),
"desk-warning",
"data-id=\"" + key + "\" data-interactive=\"true\" title=\"" +
esc(label) + "\" aria-label=\"" + esc(label) + ": " +
(attention ? "Handlungsbedarf"
: known ? "In Ordnung"
: "Nicht bekannt") +
"\" style=\"left:" +
std::to_string((wide ? 28 : 26) +
(int(i) % cols) * (cw + (wide ? 18 : 14))) +
"dp;top:" + std::to_string(int(i) / cols * (rh + 20)) +
"dp;width:" + std::to_string(cw) +
"dp;height:" + std::to_string(rh) + "dp;\"");
}
return out + "</div>";
}
std::string App::widget(const std::string &id, const Json &o) {
const auto s = snap();
if (!widget_data_.is_object())
@@ -140,51 +192,8 @@ std::string App::widget(const std::string &id, const Json &o) {
"</small><strong>" + esc(c ? world_->name(*c) : "") +
"</strong></div>";
}
if (id == "warnings") {
const std::vector<std::vector<int>> groups =
wide ? std::vector<std::vector<int>>{{0}, {1}, {2}, {3, 4},
{5, 6}, {7}, {8}, {9}}
: std::vector<std::vector<int>>{{0}, {1}, {2}, {3}, {4},
{5}, {6}, {7}, {8}, {9}};
std::string out =
heading("Vereinsstatus", false) + "<div class=\"desk-warning-grid\">";
const int cols = wide ? 8 : 5,
cw = (w - (wide ? 56 : 52) - (wide ? 7 * 18 : 4 * 14)) / cols,
rh = wide ? h - 76 : (h - 120) / 2;
for (size_t i = 0; i < groups.size(); ++i) {
std::string label, key;
bool attention = false;
for (int n : groups[i]) {
const auto &v = widget_data_.at("warnings")[size_t(n)];
if (!label.empty()) {
label += " & ";
key += ",";
}
label += v.at("name").get<std::string>();
key += std::to_string(n);
attention = attention || v.at("attention") == true;
}
const auto &v = widget_data_.at("warnings")[size_t(groups[i][0])];
out += btn("widget-warning",
"<span class=\"status-lamp " +
std::string(attention ? "attention" : "okay") + "\">" +
glyph(v.at("icon"), h == 720 ? 42 : 28) + "</span>" +
(wide ? ""
: "<span class=\"warning-caption\">" + esc(label) +
"</span>"),
"desk-warning",
"data-id=\"" + key + "\" data-interactive=\"true\" title=\"" +
esc(label) + "\" aria-label=\"" + esc(label) + ": " +
(attention ? "Handlungsbedarf" : "In Ordnung") +
"\" style=\"left:" +
std::to_string((wide ? 28 : 26) +
(int(i) % cols) * (cw + (wide ? 18 : 14))) +
"dp;top:" + std::to_string(int(i) / cols * (rh + 20)) +
"dp;width:" + std::to_string(cw) +
"dp;height:" + std::to_string(rh) + "dp;\"");
}
return out + "</div>";
}
if (id == "warnings")
return widget_warnings(widget_data_.at("warnings"), o);
if (id == "fans")
return heading("Fan-Stimmung") + "<div class=\"desk-mood\">" +
glyph("heart", 36) + "<div><strong>" +