Complete the Modern main menu and persistent mod library (by Codex)
This commit is contained in:
1 parent
ab4a962a39
commit
6bcd95d668
21 files changed
+2043
-248
No files matched your search
+12
-141
@@ -145,6 +145,7 @@ void App::ProcessEvent(Rml::Event &event) try {
|
||||
n = n->GetParentNode())
|
||||
if (n->GetId() == "native-ticket-layer")
|
||||
return;
|
||||
if(front_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;
|
||||
@@ -457,6 +458,7 @@ void App::ProcessEvent(Rml::Event &event) try {
|
||||
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 (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;
|
||||
@@ -618,6 +620,7 @@ void App::dispatch(const std::string &action, Rml::Element *target) {
|
||||
return;
|
||||
}
|
||||
if (action == "load") {
|
||||
if(auto *active=mod(active_mod_);active&&active->type=="Modern"&&(!world_||world_->source()!=fs::absolute(active->file).lexically_normal()))load_world(active->file);
|
||||
if (!source_) {
|
||||
if (auto *m = mod(active_mod_); m && m->type == "Modern")
|
||||
load_world(m->file);
|
||||
@@ -639,7 +642,7 @@ void App::dispatch(const std::string &action, Rml::Element *target) {
|
||||
contents->content_id,
|
||||
{},
|
||||
m->file.parent_path()};
|
||||
launch::ModLibrary library(root_);
|
||||
launch::ModLibrary library(front_library_root());
|
||||
const auto user = library.user_directory(entry);
|
||||
SDL_HideWindow(video_.window);
|
||||
const int code =
|
||||
@@ -674,142 +677,6 @@ void App::dispatch(const std::string &action, Rml::Element *target) {
|
||||
refresh();
|
||||
return;
|
||||
}
|
||||
if (action == "mod-select") {
|
||||
selected_mod_ = id;
|
||||
refresh();
|
||||
return;
|
||||
}
|
||||
if (action == "mod-activate") {
|
||||
if (auto *m = mod(selected_mod_)) {
|
||||
if (!m->error.empty()) {
|
||||
message(m->error);
|
||||
return;
|
||||
}
|
||||
active_mod_ = m->name;
|
||||
}
|
||||
refresh();
|
||||
return;
|
||||
}
|
||||
if (action == "mod-remove") {
|
||||
if (auto *m = mod(selected_mod_)) {
|
||||
const auto name = m->name;
|
||||
confirmation(
|
||||
"Mod „" + name + "“ löschen? Persönliche Daten bleiben erhalten.",
|
||||
[this, name] {
|
||||
auto *m = mod(name);
|
||||
if (!m)
|
||||
return;
|
||||
launch::ModLibrary library(root_);
|
||||
library.remove({m->name, m->type, {}, {}, m->file.parent_path()});
|
||||
if (active_mod_ == name)
|
||||
active_mod_.clear();
|
||||
selected_mod_.clear();
|
||||
collect_mods();
|
||||
refresh();
|
||||
});
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (action == "mod-rename") {
|
||||
auto *m = mod(selected_mod_);
|
||||
if (!m)
|
||||
return;
|
||||
const auto previous = m->name;
|
||||
text_dialog("Mod umbenennen", previous,
|
||||
[this, previous](const std::string &name) {
|
||||
launch::ModLibrary::validate_name(name);
|
||||
auto *m = mod(previous);
|
||||
if (!m)
|
||||
throw editor::Error("Mod ist nicht mehr vorhanden.");
|
||||
launch::ModLibrary library(root_);
|
||||
library.rename(
|
||||
{m->name, m->type, {}, {}, m->file.parent_path()}, name);
|
||||
if (active_mod_ == previous)
|
||||
active_mod_ = name;
|
||||
selected_mod_ = name;
|
||||
collect_mods();
|
||||
refresh();
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (action == "import-modern") {
|
||||
NFD::Guard guard;
|
||||
NFD::UniquePath chosen;
|
||||
const nfdfilteritem_t filter[] = {{"OpenBMH-Welt", "obw"}};
|
||||
const auto result = NFD::OpenDialog(chosen, filter, 1);
|
||||
if (result == NFD_CANCEL)
|
||||
return;
|
||||
if (result != NFD_OKAY) {
|
||||
message("Die Dateiauswahl konnte nicht geöffnet werden.");
|
||||
return;
|
||||
}
|
||||
const auto file = editor::path(chosen.get());
|
||||
auto candidate = Catalog::open(file);
|
||||
auto initial = candidate->title();
|
||||
for (char &c : initial)
|
||||
if (std::string("/\\:*?\"<>|").find(c) != std::string::npos)
|
||||
c = '-';
|
||||
if (initial.empty())
|
||||
initial = "Modern";
|
||||
text_dialog("Bezeichnung der neuen Mod", initial,
|
||||
[this, file](const std::string &name) {
|
||||
launch::ModLibrary::validate_name(name);
|
||||
const auto destination = root_ / "mods" / editor::path(name);
|
||||
if (fs::exists(destination))
|
||||
throw editor::Error(
|
||||
"Eine Mod mit diesem Namen ist bereits vorhanden.");
|
||||
fs::create_directories(destination.parent_path());
|
||||
const auto staging =
|
||||
destination.parent_path() /
|
||||
(".ui-import-" + std::to_string(SDL_GetTicks64()));
|
||||
if (!fs::create_directory(staging))
|
||||
throw editor::Error("Import wird bereits vorbereitet.");
|
||||
try {
|
||||
fs::copy_file(file, staging / "content.obw");
|
||||
(void)Catalog::open(staging / "content.obw");
|
||||
fs::rename(staging, destination);
|
||||
} catch (...) {
|
||||
fs::remove_all(staging);
|
||||
throw;
|
||||
}
|
||||
collect_mods();
|
||||
selected_mod_ = name;
|
||||
refresh();
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (action == "import-classic") {
|
||||
NFD::Guard guard;
|
||||
NFD::UniquePath chosen;
|
||||
const auto result = NFD::PickFolder(chosen);
|
||||
if (result == NFD_CANCEL)
|
||||
return;
|
||||
if (result != NFD_OKAY) {
|
||||
message("Die Ordnerauswahl konnte nicht geöffnet werden.");
|
||||
return;
|
||||
}
|
||||
try {
|
||||
launch::AddMod request;
|
||||
request.source = editor::path(chosen.get());
|
||||
const auto game = launch::check_game_directory(request.source);
|
||||
request.name = game.family == launch::GameFamily::english ? "FTDL-classic"
|
||||
: "BMH-classic";
|
||||
request.migrate = false;
|
||||
text_dialog("Bezeichnung der neuen Mod", request.name,
|
||||
[this, request](const std::string &name) mutable {
|
||||
launch::ModLibrary::validate_name(name);
|
||||
request.name = name;
|
||||
launch::ModLibrary library(root_);
|
||||
library.add(request, migrate_);
|
||||
collect_mods();
|
||||
selected_mod_ = name;
|
||||
refresh();
|
||||
});
|
||||
} catch (const std::exception &e) {
|
||||
message(e.what());
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (action == "setup-step") {
|
||||
const auto step = target->GetAttribute<int>("data-step", 0);
|
||||
const int limit = id == "duration" ? 5
|
||||
@@ -1082,7 +949,7 @@ void App::dispatch(const std::string &action, Rml::Element *target) {
|
||||
}
|
||||
}
|
||||
void App::change(Rml::Element *target) {
|
||||
if(files_change(target) || widget_change(target) || settings_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);
|
||||
if (!control)
|
||||
@@ -1146,7 +1013,7 @@ void App::change(Rml::Element *target) {
|
||||
}
|
||||
}
|
||||
void App::input(Rml::Element *target) {
|
||||
if(files_change(target) || widget_change(target) || settings_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-input", "");
|
||||
auto *control = dynamic_cast<Rml::ElementFormControl *>(target);
|
||||
if (!control)
|
||||
@@ -1211,7 +1078,11 @@ void App::script() {
|
||||
try {
|
||||
const auto command = Json::parse(line);
|
||||
const auto type = command.value("type", std::string());
|
||||
if (type == "click" || type == "right") {
|
||||
if(type=="front-wait"){
|
||||
const auto end=SDL_GetTicks64()+command.value("timeout_ms",uint64_t(300000));
|
||||
while(front_busy_&&SDL_GetTicks64()<end){front_poll();if(needs_render_||dirty_)frame();SDL_Delay(10);}
|
||||
if(front_busy_)throw editor::Error("Modvorgang hat das QA-Zeitlimit überschritten.");
|
||||
} else if (type == "click" || type == "right") {
|
||||
const auto point = locate(command);
|
||||
const int button = type == "right" ? 1 : 0;
|
||||
context_->ProcessMouseMove(point.x, point.y, 0);
|
||||
@@ -1274,7 +1145,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_},
|
||||
{"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_},
|
||||
{"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