Complete Modern game setup and manager selection with staged confirmation (by Codex)
This commit is contained in:
1 parent
a0bb8b47dc
commit
967520190d
18 files changed
+1784
-531
No files matched your search
+12
-175
@@ -127,6 +127,8 @@ void App::ProcessEvent(Rml::Event &event) try {
|
||||
// are being constructed. Opening a squad menu must stay read-only.
|
||||
if (setting_menu_markup_ && (menu_ == "lineup" || menu_ == "transfer" || menu_ == "news" || menu_ == "settings" || menu_=="widgets" || menu_=="save" || menu_=="load" || menu_=="view-save" || menu_=="view-load") &&
|
||||
(type == "change" || type == "input")) return;
|
||||
if (setting_menu_markup_ && (scene_ == "manager" || scene_ == "newgame") &&
|
||||
(type == "change" || type == "input")) return;
|
||||
if (type == "keydown")
|
||||
keyboard_navigation_ = true;
|
||||
else if (type == "mousedown")
|
||||
@@ -146,10 +148,11 @@ void App::ProcessEvent(Rml::Event &event) try {
|
||||
if (n->GetId() == "native-ticket-layer")
|
||||
return;
|
||||
if(front_event(event))return;
|
||||
if (entry_event(event)) return;
|
||||
if (amount_event(event)) return;
|
||||
if (popup_.empty() && settings_event(event)) return;
|
||||
if (popup_.empty() && (files_event(event) || widget_event(event))) return;
|
||||
if ((menu_ == "lineup" || menu_ == "transfer") && (type == "change" || type == "input")) {
|
||||
if ((menu_ == "lineup" || menu_ == "transfer" || scene_ == "manager") && (type == "change" || type == "input")) {
|
||||
if (auto *select = dynamic_cast<Rml::ElementFormControlSelect *>(event.GetTargetElement());
|
||||
select && select->IsSelectBoxVisible()) {
|
||||
pending_selects_.insert(select->GetId());
|
||||
@@ -399,6 +402,7 @@ void App::ProcessEvent(Rml::Event &event) try {
|
||||
[this](auto *n) {
|
||||
return !n->IsVisible(true) ||
|
||||
n->HasAttribute("disabled") ||
|
||||
n->template GetAttribute<int>("tabindex", 0) < 0 ||
|
||||
(menu_ == "scorers" &&
|
||||
n->GetId().starts_with("player-stat-tab-") &&
|
||||
n->template GetAttribute<Rml::String>("aria-selected", "false") != "true");
|
||||
@@ -459,6 +463,7 @@ void App::dispatch(const std::string &action, Rml::Element *target) {
|
||||
const auto id =
|
||||
target ? target->GetAttribute<Rml::String>("data-id", "") : std::string();
|
||||
if(front_action(action,target))return;
|
||||
if (entry_action(action, target)) return;
|
||||
if (settings_action(action,target)) return;
|
||||
if (files_action(action,target) || widget_action(action,target)) return;
|
||||
if (lineup_action(action, target) || transfer_action(action, target)) return;
|
||||
@@ -666,139 +671,7 @@ void App::dispatch(const std::string &action, Rml::Element *target) {
|
||||
"Modern-UI-Paket verwenden.");
|
||||
return;
|
||||
}
|
||||
if (auto *m = mod(active_mod_); m && m->type == "Modern")
|
||||
load_world(m->file);
|
||||
if (!source_) {
|
||||
message("Bitte eine Modern-Mod aktivieren.");
|
||||
return;
|
||||
}
|
||||
scene_ = "newgame";
|
||||
menu_.clear();
|
||||
refresh();
|
||||
return;
|
||||
}
|
||||
if (action == "setup-step") {
|
||||
const auto step = target->GetAttribute<int>("data-step", 0);
|
||||
const int limit = id == "duration" ? 5
|
||||
: id == "difficulty" ? 10
|
||||
: id == "players"
|
||||
? (start_options_.value("league", true) ? 4 : 1)
|
||||
: 3;
|
||||
if (id == "duration" || id == "difficulty" || id == "players" ||
|
||||
id == "mode")
|
||||
start_options_[id] =
|
||||
std::clamp(start_options_.value(id, 1) + step, 1, limit);
|
||||
refresh();
|
||||
return;
|
||||
}
|
||||
if (action == "setup-competition") {
|
||||
if (id == "league" || id == "world") {
|
||||
auto next = start_options_;
|
||||
next[id] = !next.value(id, true);
|
||||
if ((next.value("league", true) || next.value("world", true)) &&
|
||||
(next.value("league", true) || next.value("players", 1) == 1))
|
||||
start_options_ = std::move(next);
|
||||
}
|
||||
refresh();
|
||||
return;
|
||||
}
|
||||
if (action == "setup-next") {
|
||||
managers_draft_ = Json::array();
|
||||
manager_index_ = 0;
|
||||
adding_manager_ = false;
|
||||
manager_picker_ = false;
|
||||
selections_["portrait"] = "0";
|
||||
selections_["manager-name"] = "Alex Berger";
|
||||
scene_ = "manager";
|
||||
refresh();
|
||||
return;
|
||||
}
|
||||
if (action == "manager-clubs") {
|
||||
selections_["manager-name"] = field("manager-name");
|
||||
manager_picker_ = true;
|
||||
refresh();
|
||||
return;
|
||||
}
|
||||
if (action == "manager-clubs-back") {
|
||||
manager_picker_ = false;
|
||||
refresh();
|
||||
return;
|
||||
}
|
||||
if (action == "portrait-style") {
|
||||
selections_["manager-name"] = field("manager-name");
|
||||
selections_["portrait-style"] = id;
|
||||
refresh();
|
||||
return;
|
||||
}
|
||||
if (action == "portrait") {
|
||||
selections_["manager-name"] = field("manager-name");
|
||||
selections_["portrait"] = id;
|
||||
refresh();
|
||||
return;
|
||||
}
|
||||
if (action == "manager-club") {
|
||||
if (!world_->manageable(id))
|
||||
return;
|
||||
selected_club_ = id;
|
||||
country_ = "nation:de";
|
||||
league_ = world_->find("clubs", id)->value("competition", league_);
|
||||
manager_picker_ = false;
|
||||
refresh();
|
||||
return;
|
||||
}
|
||||
if (action == "manager-back") {
|
||||
scene_ = adding_manager_ ? "desktop" : "newgame";
|
||||
refresh();
|
||||
return;
|
||||
}
|
||||
if (action == "manager-next") {
|
||||
const auto name = field("manager-name");
|
||||
if (name.empty() || !world_->manageable(selected_club_)) {
|
||||
message("Bitte einen Namen und einen deutschen Verein wählen.");
|
||||
return;
|
||||
}
|
||||
const Json m = {
|
||||
{"name", name},
|
||||
{"club", selected_club_},
|
||||
{"portrait", selections_["portrait"].empty()
|
||||
? 0
|
||||
: std::stoi(selections_["portrait"])},
|
||||
{"portrait_style",
|
||||
selections_["portrait-style"] == "painted" ? "painted" : "photo"},
|
||||
{"strength_choice", selections_["manager-strength"].empty()
|
||||
? 1
|
||||
: std::stoi(selections_["manager-strength"])}};
|
||||
confirmation("Sind alle Eingaben richtig?", [this, m] {
|
||||
auto candidate = managers_draft_;
|
||||
candidate.push_back(m);
|
||||
if (!adding_manager_ &&
|
||||
manager_index_ + 1 < start_options_.value("players", 1)) {
|
||||
managers_draft_ = candidate;
|
||||
++manager_index_;
|
||||
selections_["manager-name"] = std::array<const char *, 4>{
|
||||
"Alex Berger", "Chris Winter", "Robin Meier",
|
||||
"Jamie Sommer"}[size_t(manager_index_)];
|
||||
for (int p = 0; p < 12; ++p)
|
||||
if (std::none_of(
|
||||
candidate.begin(), candidate.end(),
|
||||
[&](const auto &v) { return v.value("portrait", 0) == p; })) {
|
||||
selections_["portrait"] = std::to_string(p);
|
||||
break;
|
||||
}
|
||||
refresh();
|
||||
return;
|
||||
}
|
||||
if (!apply("managers", candidate))
|
||||
return;
|
||||
managers_draft_ = std::move(candidate);
|
||||
apply("edit", {{"key", "setup"}, {"value", start_options_}});
|
||||
scene_ = adding_manager_ || !start_options_.value("league", true)
|
||||
? "desktop"
|
||||
: "opening";
|
||||
opening_page_ = 0;
|
||||
draw_revealed_ = 0;
|
||||
refresh();
|
||||
});
|
||||
entry_begin();
|
||||
return;
|
||||
}
|
||||
if (action == "opening-play") {
|
||||
@@ -837,28 +710,7 @@ void App::dispatch(const std::string &action, Rml::Element *target) {
|
||||
if (route == "kickoff")
|
||||
return;
|
||||
if (route == "newplayer") {
|
||||
const auto existing = snap().state.at("managers");
|
||||
if (existing.size() >= 4) {
|
||||
message("Alle vier Mitspielerplätze sind belegt.");
|
||||
return;
|
||||
}
|
||||
managers_draft_ = existing;
|
||||
manager_index_ = int(existing.size());
|
||||
adding_manager_ = true;
|
||||
manager_picker_ = false;
|
||||
selections_["manager-name"] = std::array<const char *, 4>{
|
||||
"Alex Berger", "Chris Winter", "Robin Meier",
|
||||
"Jamie Sommer"}[existing.size()];
|
||||
for (int p = 0; p < 12; ++p)
|
||||
if (std::none_of(existing.begin(), existing.end(), [&](const auto &v) {
|
||||
return v.value("portrait", 0) == p;
|
||||
})) {
|
||||
selections_["portrait"] = std::to_string(p);
|
||||
break;
|
||||
}
|
||||
menu_.clear();
|
||||
scene_ = "manager";
|
||||
refresh();
|
||||
entry_add();
|
||||
return;
|
||||
}
|
||||
static const std::set<std::string> available = {
|
||||
@@ -949,6 +801,7 @@ void App::dispatch(const std::string &action, Rml::Element *target) {
|
||||
}
|
||||
}
|
||||
void App::change(Rml::Element *target) {
|
||||
if (entry_change(target)) return;
|
||||
if(front_change(target)||files_change(target) || widget_change(target) || settings_change(target))return;
|
||||
const auto kind = target->GetAttribute<Rml::String>("data-change", "");
|
||||
auto *control = dynamic_cast<Rml::ElementFormControl *>(target);
|
||||
@@ -993,26 +846,10 @@ void App::change(Rml::Element *target) {
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (kind == "manager-country" && value == country_)
|
||||
return;
|
||||
if (kind == "manager-league" && value == league_)
|
||||
return;
|
||||
if (kind == "manager-country" || kind == "manager-league")
|
||||
focus_after_render_ = target->GetId();
|
||||
if (kind == "manager-country" || kind == "manager-league") {
|
||||
if (!manager_picker_)
|
||||
selections_["manager-name"] = field("manager-name");
|
||||
if (kind == "manager-country") {
|
||||
country_ = value;
|
||||
league_.clear();
|
||||
} else
|
||||
league_ = value;
|
||||
refresh();
|
||||
} else if (kind == "manager-strength") {
|
||||
selections_["manager-strength"] = value;
|
||||
}
|
||||
|
||||
}
|
||||
void App::input(Rml::Element *target) {
|
||||
if (entry_input(target)) return;
|
||||
if(front_change(target)||files_change(target) || widget_change(target) || settings_change(target))return;
|
||||
const auto kind = target->GetAttribute<Rml::String>("data-input", "");
|
||||
auto *control = dynamic_cast<Rml::ElementFormControl *>(target);
|
||||
@@ -1145,7 +982,7 @@ void App::script() {
|
||||
{"transfer_view", transfer_view_}, {"transfer_dialog", transfer_dialog_}, {"transfer_draft", transfer_draft_},
|
||||
{"career_view", career_view_}, {"rankings_view", rankings_view_},
|
||||
{"stadium_view", stadium_view_},
|
||||
{"front_view",front_snapshot_view()}, {"files_view",{{"mode",files_mode_},{"selected",files_selected_},{"name",files_name_},{"feedback",files_feedback_}}}, {"widget_view",{{"query",widget_query_},{"notice",widget_notice_}}}, {"ui_preferences",ui_preferences_}, {"settings_draft",settings_draft_}, {"settings_category",settings_category_}, {"settings_query",settings_query_}, {"settings_notice",settings_notice_},
|
||||
{"entry_view", entry_snapshot()}, {"front_view",front_snapshot_view()}, {"files_view",{{"mode",files_mode_},{"selected",files_selected_},{"name",files_name_},{"feedback",files_feedback_}}}, {"widget_view",{{"query",widget_query_},{"notice",widget_notice_}}}, {"ui_preferences",ui_preferences_}, {"settings_draft",settings_draft_}, {"settings_category",settings_category_}, {"settings_query",settings_query_}, {"settings_notice",settings_notice_},
|
||||
{"statistics_view", statistics_view_}, {"statistics_trophy", statistics_trophy_},
|
||||
{"statistics_scrolls", statistics_scrolls_},
|
||||
{"news_view", news_view_}, {"news_dialog", news_dialog_},
|
||||
|
||||
Reference in new issue
Block a user