// SPDX-License-Identifier: GPL-3.0-only fs::path App::front_library_root() const { return config_.mods.empty() ? root_ : config_.mods; } const UiModEntry *App::front_selected() const { for (const auto &entry : front_snapshot_.entries) if (entry.id == selected_mod_) return &entry; return nullptr; } std::string App::front_source_name(const UiModEntry &entry) const { return entry.source == "BMH" ? "Bundesliga Manager Hattrick" : entry.source == "FTLD" || entry.source == "FLTD" ? "Football Limited" : "OpenBMH"; } std::string App::front_size(uint64_t bytes) const { const auto tenths = (bytes * 10 + 524288) / 1048576; return number(int64_t(tenths / 10)) + (tenths % 10 ? "," + std::to_string(tenths % 10) : "") + " MiB"; } // A length of the entry's design in dp: the table is drawn 1672 units across. std::string App::es(double units) { return scalar(units * kEntryUnit) + "dp"; } // The table with the pad on it; `over` lies above the pad (a note that asks something). std::string App::entry_stage(const std::string &paper, const std::string &over) { return "
" + (gui_.contains("entry.table") ? img("entry.table", 3840, 2160, false, true, 2048) : std::string()) + "
" + paper + "
" + over + "
"; } // What is written on the pad: a small line, the heading, a rule, the body and the buttons at // its foot. `right` stands beside the heading; without it the paper clip keeps its room. std::string App::entry_sheet(const std::string &kicker, const std::string &title, const std::string &body, const std::string &foot, const std::string &right) { return "
" + esc(pg_upper(kicker)) + "

" + esc(title) + "

" + (right.empty() ? std::string("") : right) + "
" + body + (foot.empty() ? std::string() : ""); } std::string App::entry_pad(const std::string &kicker, const std::string &title, const std::string &body, const std::string &foot, const std::string &right, const std::string &over) { return entry_stage(entry_sheet(kicker, title, body, foot, right), over); } std::string App::main_menu() { const auto *active = mod(active_mod_); const bool available = active && active->error.empty(); std::string rows; const std::array, 6> actions{ {{"new", "Neues Spiel"}, {"load", "Spiel laden"}, {"network", "Netzwerk"}, {"mods", "Mod"}, {"settings", "Einstellungen"}, {"exit", "Beenden"}}}; for (const auto &[key, title] : actions) { const std::string id = key; const bool network = id == "network", disabled = scene_ != "main" || !menu_.empty() || network || front_quit_ || (id == "new" && !available && !(front_external_override_ && world_)); rows += btn(key, "" + std::string(title) + "" + (network ? "DEMNÄCHST" : "") + "›", std::string("es-mb") + (id == "load" || id == "exit" ? " gap" : ""), "id=\"front-" + id + "\" " + (disabled ? "disabled=\"disabled\"" : "")); } const auto label = front_external_override_ && world_ ? world_->title() : available ? active->name : "Keine Mod aktiviert"; const std::string ask = front_quit_ ? "
Das Spiel wirklich beenden?
" + pg_button("front-quit-no", "Abbrechen", "sm", "id=\"front-quit-no\"") + pg_button("front-quit-yes", "Beenden", "primary sm", "id=\"front-quit-yes\"") + "
" : std::string(); return entry_stage("

Dreierpack Manager

" + ask + "Aktive Mod" + esc(label) + "Version " + std::string(kOpenBmhVersion) + (config_.preview_only ? " · UI-Demo" : " · Entwicklung") + "
"); } std::string App::front_mod_details() { const auto *entry = front_selected(); if (!entry) return "

Noch keine Mods installiert

Importiere einen Originalordner oder ein OpenBMH-Paket.
"; const bool active = entry->active && !front_external_override_; const auto provenance = entry->description.empty() ? front_source_name(*entry) : entry->description; std::string out = "
" + esc(pg_upper(active ? "Aktiv" : entry->valid() ? "Installiert" : "Fehlerhaft")) + "

" + esc(entry->name) + "

" + esc(provenance) + "
"; const std::vector> fields = { {"Art", entry->type}, {"Herkunft", front_source_name(*entry)}, {"Version", entry->version}, {"Inhalt", std::to_string(entry->file_count) + (entry->file_count == 1 ? " Datei" : " Dateien") + " · " + front_size(entry->bytes)}}; for (const auto &[label, value] : fields) out += "
" + esc(label) + "" + esc(value) + "
"; out += "
"; if (!entry->valid()) out += "" + esc(entry->error) + ""; const auto *current = mod(active_mod_); out += "" + esc(active ? "Diese Mod ist für das nächste Spiel ausgewählt." : current ? "Aktivieren ersetzt die Auswahl „" + current->name + "“." : "Aktiviere diese Mod für das nächste Spiel.") + "
"; return out + pg_button("mod-activate", active ? "Aktiv" : "Aktivieren", "primary sm", "id=\"mod-activate\" " + std::string(active || !entry->valid() || front_busy_ ? "disabled=\"disabled\"" : "")) + "
"; } std::string App::front_modal() { if (front_dialog_.empty()) return {}; std::string heading, body, buttons; if (front_dialog_ == "choice") { heading = "Mod importieren"; body = "

Wähle einen Originalordner oder einen Export im OpenBMH-Format.

"; const std::array, 3> choices{ {{{"original", "BMH / Football Limited", "Originalordner mit BMH.EXE oder FLTD.EXE"}}, {{"package", "OpenBMH-Paket", "Weltpaket im neuen Format · .obw oder .zip"}}, {{"folder", "OpenBMH-Exportordner", "Entpackte Welt oder Mod-Ordner mit content.obw"}}}}; for (const auto &c : choices) body += btn("front-pick", "" + std::string(c[1]) + "" + c[2] + "", "es-choice", "data-id=\"" + std::string(c[0]) + "\""); buttons = pg_button("front-dismiss", "Abbrechen"); } else if (front_dialog_ == "name" || front_dialog_ == "rename") { const bool importing = front_dialog_ == "name"; heading = importing ? "Mod übernehmen" : "Mod umbenennen"; body = "
BEZEICHNUNG
"; if (importing && front_plan_) { const auto &m = front_plan_->metadata; body += "

" + esc(m.description) + " · " + esc(m.type) + " · " + std::to_string(m.file_count) + (m.file_count == 1 ? " Datei" : " Dateien") + " · " + front_size(m.bytes) + "

" + std::string(m.type == "Classic" ? "Der vorhandene OpenBMH-Importer konvertiert die Originaldaten in ein eigenständiges Classic-Paket." : "Das geprüfte Weltpaket wird in deine Mod-Bibliothek übernommen.") + " Anschließend kannst du die Mod aktivieren.

"; } body += "" + esc(front_name_error_) + ""; buttons = pg_button("front-dismiss", "Abbrechen") + pg_button("front-name-confirm", importing ? "Importieren" : "Umbenennen", "primary", "id=\"front-name-confirm\" " + std::string(front_name_error_.empty() ? "" : "disabled=\"disabled\"")); } else if (front_dialog_ == "delete") { heading = "Mod löschen?"; body = "

„" + esc(front_target_ ? front_target_->name : "") + "“ wirklich aus der lokalen Bibliothek entfernen?

"; if (front_target_ && front_target_->active) body += "

Danach ist keine Mod aktiviert. Wähle eine andere Mod für das nächste neue Spiel.

"; body += "

Persönliche Spielstände bleiben erhalten.

"; buttons = pg_button("front-dismiss", "Abbrechen") + pg_button("front-delete-confirm", "Löschen", "primary"); } else { heading = "Vorgang nicht möglich"; body = "

" + esc(front_error_) + "

"; buttons = pg_button("front-dismiss", "Verstanden"); } return "

" + esc(heading) + "

" + body + "
" + buttons + "
"; } std::string App::mods_page() { std::string rows; for (size_t i = 0; i < front_snapshot_.entries.size(); ++i) { const auto &entry = front_snapshot_.entries[i]; const bool active = entry.active && !front_external_override_, chosen = entry.id == selected_mod_; rows += btn("mod-select", "" + esc(entry.name) + "" + esc(active ? "Aktiv" : entry.valid() ? entry.source : "Fehlerhaft") + " · " + esc(entry.type) + "", std::string("es-li") + (chosen ? " sel" : ""), "id=\"mod-entry-" + std::to_string(i) + "\" role=\"option\" aria-selected=\"" + (chosen ? "true" : "false") + "\" data-id=\"" + esc(entry.id) + "\" " + (front_busy_ ? "disabled=\"disabled\"" : "")); } if (rows.empty()) rows = "Noch keine Mods vorhanden."; const auto tab = [&](const char *id, const std::string &label) { const bool on = front_tab_ == id; return btn("front-tab", "" + label + "", on ? "on" : "", "id=\"mod-" + std::string(id) + "\" role=\"tab\" aria-selected=\"" + (on ? "true" : "false") + "\" data-id=\"" + id + "\" " + (front_busy_ ? "disabled=\"disabled\"" : "")); }; const auto tabs = ""; const auto pane = front_tab_ == "installed" ? "
" + rows + "
" + front_mod_details() + "
" : std::string("
Downloads folgen in einer späteren Version.
"); const bool selected = front_selected() != nullptr, enabled = !front_busy_ && selected && front_tab_ == "installed"; const auto feedback = front_busy_ ? front_feedback_ : !front_feedback_.empty() ? front_feedback_ : !front_snapshot_.error.empty() ? front_snapshot_.error : "Es kann genau eine Mod aktiv sein."; const std::string off = "disabled=\"disabled\""; const auto foot = (front_tab_ == "installed" ? pg_button("front-import", "Importieren", "sm", "id=\"front-import-button\" " + (front_busy_ ? off : std::string())) + pg_button("mod-rename", "Umbenennen", "sm", "id=\"mod-rename-button\" " + (enabled ? std::string() : off)) + pg_button("mod-remove", "Löschen", "sm", "id=\"mod-remove-button\" " + (enabled ? std::string() : off)) : std::string()) + "" + esc(feedback) + "" + pg_button("front-home", "Zurück", "primary", "id=\"window-close\" " + (front_busy_ ? off : std::string())); return entry_pad("Hauptmenü", "Mod", pane, foot, tabs, front_modal()); } // Spiel laden from the main menu: the saves on the left, the chosen one on the right. std::string App::render_files_pad() { std::string entries; for (size_t i = 0; i < files_rows_.size(); ++i) { const auto &entry = files_rows_[i]; const bool chosen = files_selected_ == entry.id; entries += btn("files-select", "" + esc(entry.name) + "" + esc(entry.valid() ? "Gespeichert am " + files_when(entry.created) : "Datei kann nicht geöffnet werden") + "", std::string("es-li") + (chosen ? " sel" : ""), "id=\"files-entry-" + std::to_string(i) + "\" role=\"option\" data-id=\"" + esc(entry.id) + "\" data-file-row=\"true\" aria-selected=\"" + (chosen ? "true" : "false") + "\""); } if (entries.empty()) entries = "" + std::string(files_native_ && engine_files_busy_ ? "Spielstände werden geladen …" : "Noch keine Spielstände vorhanden.") + ""; std::string details; try { details = files_page_details(false); } catch (const std::exception &e) { details = "
Datei nicht verfügbar" + esc(e.what()) + "
"; } const bool selected = files_entry_ && files_entry_->valid(); const std::string off = "disabled=\"disabled\""; const auto feedback = files_feedback_.empty() ? std::string("Klick oder Pfeiltasten wählen einen Eintrag.") : files_feedback_; return entry_pad("Hauptmenü", "Spiel laden", "
" + entries + "
" + details + "
", pg_button("files-import", "Importieren", "sm") + pg_button("files-rename", "Umbenennen", "sm", selected ? std::string() : off) + pg_button("files-delete", "Löschen", "sm", files_entry_ && !files_entry_->token.empty() ? std::string() : off) + "" + esc(feedback) + "" + pg_button("files-close", "Abbrechen") + pg_button("files-load", "Laden", "primary", "id=\"files-confirm\" " + (selected ? std::string() : off))); } Json App::front_snapshot_view() const { Json rows = Json::array(); for (const auto &row : front_snapshot_.entries) rows.push_back({{"id", row.id}, {"name", row.name}, {"type", row.type}, {"source", row.source}, {"version", row.version}, {"error", row.error}, {"active", row.active}, {"bytes", row.bytes}, {"file_count", row.file_count}, {"token", row.token}}); return {{"tab", front_tab_}, {"dialog", front_dialog_}, {"busy", front_busy_}, {"selected", selected_mod_}, {"active", active_mod_}, {"external_override", front_external_override_}, {"feedback", front_feedback_}, {"name_error", front_name_error_}, {"library_error", front_snapshot_.error}, {"entries", rows}, {"plan", front_plan_ ? Json{{"name", front_plan_->metadata.name}, {"type", front_plan_->metadata.type}, {"source", front_plan_->metadata.source}, {"bytes", front_plan_->metadata.bytes}} : Json()}}; }