From eb1ae54d63b167a86f6a1a851716b7c8b5d194ba Mon Sep 17 00:00:00 2001 From: lethosor Date: Sat, 19 Dec 2015 17:09:29 -0500 Subject: [PATCH] Add ui_lever_target_type scan to find-offsets --- library/xml | 2 +- scripts/devel/find-offsets.lua | 55 +++++++++++++++++++++++++++++++++- 2 files changed, 55 insertions(+), 2 deletions(-) diff --git a/library/xml b/library/xml index 9105ebc0c..4ad540bba 160000 --- a/library/xml +++ b/library/xml @@ -1 +1 @@ -Subproject commit 9105ebc0cdb12667683426d7e57d9d4f79dc689b +Subproject commit 4ad540bbae076d574ebc8795242bd89da4b15811 diff --git a/scripts/devel/find-offsets.lua b/scripts/devel/find-offsets.lua index 17bc4f6f9..2c3df0f34 100644 --- a/scripts/devel/find-offsets.lua +++ b/scripts/devel/find-offsets.lua @@ -259,9 +259,19 @@ local function dwarfmode_to_top() return true end -local function feed_menu_choice(catnames,catkeys,enum) +local function feed_menu_choice(catnames,catkeys,enum,enter_seq,exit_seq,prompt) + local entered = false return function (idx) + if idx == 0 and prompt and not utils.prompt_yes_no(' Proceed?', true) then + return false + end idx = idx % #catnames + 1 + if not entered then + entered = true + else + dwarfmode_feed_input(table.unpack(exit_seq or {})) + end + dwarfmode_feed_input(table.unpack(enter_seq or {})) dwarfmode_feed_input(catkeys[idx]) if enum then return true, enum[catnames[idx]] @@ -1155,6 +1165,48 @@ NOTE: If not done after first 3-4 steps, resize the game window.]], ms.found_offset('ui_building_in_resize', addr) end +-- +-- ui_lever_target_type +-- +local function find_ui_lever_target_type() + local catnames = { + 'Bridge', 'Door', 'Floodgate', + 'Cage', 'Chain', 'TrackStop', + 'GearAssembly', + } + local catkeys = { + 'HOTKEY_TRAP_BRIDGE', 'HOTKEY_TRAP_DOOR', 'HOTKEY_TRAP_FLOODGATE', + 'HOTKEY_TRAP_CAGE', 'HOTKEY_TRAP_CHAIN', 'HOTKEY_TRAP_TRACK_STOP', + 'HOTKEY_TRAP_GEAR_ASSEMBLY', + } + local addr + + if dwarfmode_to_top() then + dwarfmode_feed_input('D_BUILDJOB') + + addr = searcher:find_interactive( + 'Auto-searching for ui_lever_target_type. Please select a lever:', + 'int8_t', + feed_menu_choice(catnames, catkeys, df.lever_target_type, + {'BUILDJOB_ADD'}, + {'LEAVESCREEN', 'LEAVESCREEN'}, + true -- prompt + ), + 20 + ) + end + + if not addr then + addr = searcher:find_menu_cursor([[ +Searching for ui_lever_target_type. Please select a lever with +'q' and enter the "add task" menu with 'a':]], + 'int8_t', catnames, df.lever_target_type + ) + end + + ms.found_offset('ui_lever_target_type', addr) +end + -- -- window_x -- @@ -1568,6 +1620,7 @@ exec_finder(find_ui_workshop_in_add, 'ui_workshop_in_add') exec_finder(find_ui_workshop_job_cursor, 'ui_workshop_job_cursor') exec_finder(find_ui_building_in_assign, 'ui_building_in_assign') exec_finder(find_ui_building_in_resize, 'ui_building_in_resize') +exec_finder(find_ui_lever_target_type, 'ui_lever_target_type') exec_finder(find_window_x, 'window_x') exec_finder(find_window_y, 'window_y') exec_finder(find_window_z, 'window_z')