Fix automation preview, desktop drag highlight and macOS keyboard startup (by Codex)

This commit is contained in:
Codex committed 2026-10-30 23:13:44 +01:00
1 parent 998b037d3d
commit 184a421512
11 files changed
+231 -5

No files matched your search

+14
View File
@@ -488,6 +488,18 @@ DeskDate desk_date(uint32_t counter, const LeImage& exe) {
return d;
}
namespace {
void project_automation_formation(DeskState& desk, const Bytes& formations, bool indoor) {
const int selected = desk.automation[0];
if (selected == 0) return;
if (selected > 8) throw FormatError("desktop: invalid automatic formation");
const size_t offset = size_t(desk.manager_slot) * 0x160 + size_t(indoor) * 0xb0 + size_t(selected - 1) * 22;
if (offset + 22 > formations.size()) throw FormatError("desktop: missing automatic formation");
desk.automation_formation.emplace();
std::copy_n(formations.begin() + offset, 22, desk.automation_formation->begin());
}
}
DeskState desk_from_save(const SaveState& s, const LeImage& exe, uint64_t revision) {
StaticMemory memory(s);
auto manager = block_copy(s, ::bmh::layout::ManagerRecords), tactics = block_copy(s, ::bmh::layout::TacticsBoards), options = block_copy(s, ::bmh::layout::ManagerAutomation);
@@ -510,6 +522,7 @@ DeskState desk_from_save(const SaveState& s, const LeImage& exe, uint64_t revisi
project_table_position(d, table_source);
project_drawer_rows(d, exe, manager, s.pool(0), offsets, position_history,
results_by_opponent, rounds, std::nullopt);
project_automation_formation(d, block_copy(s, layout::Formations), false);
d.source = "original_save_read_only"; return d;
}
@@ -520,6 +533,7 @@ DeskState desk_from_game(const GameState& g, const LeImage& exe, uint64_t revisi
auto d = project(g.memory, {g.manager_records, g.tactics, g.manager_options, g.stocks, g.club_heap_78, g.club_names,
g.club_ids, g.squad_slots, g.players, g.team_morale, g.manager_teams, g.league_rounds},
exe, g.level, g.date, g.season_day(), g.season, revision);
project_automation_formation(d, g.formations, g.indoor);
// DeskDate only auto-opens for an ordinary club manager; the national
// runtime (0x165) suppresses this consumer while manual mailbox access remains valid.
if (d.runtime_club != kNoTeam && d.manager_slot >= 0 && d.manager_slot < 32 && g.memory.has(::bmh::layout::MailboxRecipientMask))
+1
View File
@@ -107,6 +107,7 @@ struct DeskState {
bool mailbox_notification_pending = false; // MailboxRecipientMask active-manager bit; transient, non-FBM
std::optional<DeskItem> menu_layout_shortcut; // final bar cell returns native record 53/kind 72, then dispatches MEN
std::array<uint8_t, 5> automation{};
std::optional<std::array<uint8_t, 22>> automation_formation;
std::array<std::optional<bool>, 10> warnings{};
std::vector<DeskItem> items; // Original linked-list drawing / hit-test order.
std::string source;
+23 -1
View File
@@ -218,7 +218,14 @@ void DesktopScreen::draw_item(Image& out, const DeskItem& item) const {
copy(out, icons_, 97, 111, x + 3 + i * 33, y + 2, 32, 30);
const auto value = state_.automation[i];
if ((i == 4 ? value & 1 : value) != 0) copy(out, icons_, 129 + i * 16, 111, x + i * 33 + 10, y + 4, 17, 11);
// Individual automatic-formation dots need a separately verified renderer.
if (i == 0 && value != 0 && state_.automation_formation) {
const auto& formation = *state_.automation_formation;
// The original miniature excludes the keeper and unused positions.
for (int row = 1; row < 11; ++row)
if (formation[size_t(row)] != 0)
rect(out, x + 10 + formation[size_t(row)] * 15 / 18,
y + 5 + formation[size_t(row + 11)], 1, 1, 0x27);
}
}
break;
case 15:
@@ -275,6 +282,20 @@ Image DesktopScreen::render() const {
if (shortcut_hover_record_ >= 0)
text(out, 0, 235, texts_[text_id(::bmh::layout::Desktop_Render_TextPointer + uint32_t(shortcut_hover_record_) * 4)], 0x5f, 319);
}
if (layout_drag_ && layout_preview_) {
const auto selected = std::find_if(visible.items.begin(), visible.items.end(),
[&](const DeskItem& item) { return item.id == layout_drag_->item; });
if (selected != visible.items.end()) {
draw_item(out, *selected);
const auto& item = *selected;
const int w = item.width - (item.kind >= 50 && !item.open ? 8 : 0);
const int h = item.height - (item.kind >= 50 && !item.open ? 8 : 0);
rect(out, item.x, item.y, w, 1, 0x27);
rect(out, item.x, item.y + h - 1, w, 1, 0x27);
rect(out, item.x, item.y, 1, h, 0x27);
rect(out, item.x + w - 1, item.y, 1, h, 0x27);
}
}
return out;
}
@@ -722,6 +743,7 @@ std::string DesktopScreen::state_json() const {
",\"shortcut_hover_record\":" + std::to_string(shortcut_hover_record_) +
",\"socket_confirmation_armed\":" + std::string(socket_confirmation_armed_ ? "true" : "false") +
",\"bin_mode\":" + std::string(bin_mode_ ? "true" : "false") +
",\"dragging_item\":" + (layout_drag_ ? std::to_string(layout_drag_->item) : "null") +
",\"pending_action\":" + (pending_ ? desk_request_json(*pending_) : "null") +
",\"last_rejection\":" + (last_rejection_.empty() ? "null" : json_quote(last_rejection_)) + "}";
return out;