Bind confirmed bank and ticket actions to real careers (by Codex)

This commit is contained in:
Codex committed 2026-10-28 11:04:11 +01:00
1 parent f75e0f8e49
commit dcf42f2da7
23 files changed
+535 -56

No files matched your search

+9 -7
View File
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-3.0-only
bool App::bank_action(const std::string &action, Rml::Element *target) {
if (menu_ != "bank" || !source_ || !world_) return false;
if (menu_ != "bank" || (!source_ && !engine_mode_) || !world_) return false;
if (action == "close") {
if (bank_view_ == "entrance") return false;
bank_view_ = "entrance";
@@ -20,16 +20,17 @@ bool App::bank_action(const std::string &action, Rml::Element *target) {
}
if (action == "property-next") {
if (bank_view_ != "properties") return true;
bank_property_ = (bank_property_ + 1) % 6;
bank_property_ = (bank_property_ + 1) % (engine_mode_ ? int(engine_bank_projection(engine_data_).at("assets").at("properties").size()) : 6);
focus_after_render_ = "property-next";
refresh();
return true;
}
if (action == "property-owned-next") {
if (bank_view_ != "properties") return true;
const auto state = snap().state;
for (int step = 1; step <= 6; ++step) {
const int next = (bank_owned_ + step) % 6;
const auto state = engine_mode_ ? engine_bank_projection(engine_data_).at("state") : snap().state;
const int count = int(state.at("finance").at("properties").size());
for (int step = 1; step <= count; ++step) {
const int next = (bank_owned_ + step) % count;
if (state.at("finance").at("properties")[size_t(next)] != 0) { bank_owned_ = next; break; }
}
focus_after_render_ = "property-owned-next";
@@ -44,6 +45,7 @@ bool App::bank_action(const std::string &action, Rml::Element *target) {
refresh();
return true;
}
if (engine_mode_) return engine_bank_action(action, target);
if (action != "bank-calc" || !target) return false;
const auto kind = target->GetAttribute<Rml::String>("data-kind", "");
const bool property = kind == "property-buy" || kind == "property-sell";
@@ -94,7 +96,7 @@ bool App::bank_action(const std::string &action, Rml::Element *target) {
}
bool App::bank_event(Rml::Event &event) {
if (menu_ != "bank" || !source_ || amount_ || !popup_.empty()) return false;
if (menu_ != "bank" || (!source_ && !engine_mode_) || amount_ || !popup_.empty()) return false;
const auto type = event.GetType();
auto *target = event.GetTargetElement();
const bool keyboard = type == "keydown";
@@ -122,7 +124,7 @@ bool App::bank_event(Rml::Event &event) {
event.StopImmediatePropagation();
return true;
}
if (type == "change" && target->GetId() == "bank-term") {
if (!engine_mode_ && type == "change" && target->GetId() == "bank-term") {
auto *select = dynamic_cast<Rml::ElementFormControlSelect *>(target);
if (!select || bank_view_ != "credit" || snap().state.at("debt") != 0) return true;
const auto raw = select->GetValue();