From 27ae8f2ab9e5f5ba603f4b40a056475e29fec9e2 Mon Sep 17 00:00:00 2001 From: PeridexisErrant Date: Wed, 24 Sep 2014 21:34:09 +1000 Subject: [PATCH] exportlegends can do site maps, IDd field Expanded exportlegends.lua to handle site maps as well, and improved precision of args. Identified `vs.anon_21`; I'm not sure what the process is so I've used it here and noted it's discovery. --- NEWS | 3 ++ Readme.rst | 7 +++-- dfhack.init-example | 1 - scripts/exportlegends.lua | 61 ++++++++++++++++++++++++++++----------- 4 files changed, 52 insertions(+), 20 deletions(-) diff --git a/NEWS b/NEWS index bf4f7adf2..355b16123 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,8 @@ DFHack future + Misc Improvements: + - exportlegends.lua can now handle site maps + DFHack 0.40.13-r1 Internals: - unified spatter structs diff --git a/Readme.rst b/Readme.rst index b143b0c54..4ecc8a0b9 100644 --- a/Readme.rst +++ b/Readme.rst @@ -1420,12 +1420,15 @@ Export dwarves to RuneSmith-compatible XML. exportlegends ------------- -Exports data from legends mode; allowing a set-and-forget export of large worlds. +Controls legends mode to export data - especially useful to set-and-forget large +worlds, or when you want a map of every site when there are several hundred. Options: +:info: Exports the world/gen info and the legends XML +:sites: Exports all available site maps :maps: Exports all seventeen detailed maps -:all: first exports the world/gen info, then the XML, then all detailed maps +:all: Equivalent to calling all of the above, in that order Job management diff --git a/dfhack.init-example b/dfhack.init-example index f0f380095..fe8641db7 100644 --- a/dfhack.init-example +++ b/dfhack.init-example @@ -60,7 +60,6 @@ keybinding add Ctrl-Shift-B "adv-bodyswap force" # export all information, or just the detailed maps (doesn't handle site maps) keybinding add Ctrl-A@legends "exportlegends all" -keybinding add Ctrl-D@legends "exportlegends maps" ############################# # Context-specific bindings # diff --git a/scripts/exportlegends.lua b/scripts/exportlegends.lua index bb758368f..78989879c 100644 --- a/scripts/exportlegends.lua +++ b/scripts/exportlegends.lua @@ -1,8 +1,7 @@ -- Export everything from legends mode --- use "exportlegends maps" for detailed maps, or "exportlegends all" to also export legends +-- Valid args: "all", "info", "maps", "sites" gui = require 'gui' - local args = {...} local vs = dfhack.gui.getCurViewscreen() local i = 1 @@ -26,8 +25,18 @@ local MAPS = { "Nobility and Holdings", "Diplomacy", } + +-- export information and XML ('p, x') +function export_legends_info() + print(' Exporting: World map/gen info') + gui.simulateInput(vs, 'LEGENDS_EXPORT_MAP') + print(' Exporting: Legends xml') + gui.simulateInput(vs, 'LEGENDS_EXPORT_XML') +end + +-- presses 'd' for detailed maps function wait_for_legends_vs() - vs = dfhack.gui.getCurViewscreen() + local vs = dfhack.gui.getCurViewscreen() if i <= #MAPS then if df.viewscreen_legendsst:is_instance(vs) then gui.simulateInput(vs, 'LEGENDS_EXPORT_DETAILED_MAP') @@ -37,30 +46,48 @@ function wait_for_legends_vs() end end end + +-- selects detailed map and export it function wait_for_export_maps_vs() - vs = dfhack.gui.getCurViewscreen() - if df.viewscreen_export_graphical_mapst:is_instance(vs) then + local vs = dfhack.gui.getCurViewscreen() + if dfhack.gui.getCurFocus() == "export_graphical_map" then vs.sel_idx = i print(' Exporting: '..MAPS[i]..' map') - i = i + 1 gui.simulateInput(vs, 'SELECT') + i = i + 1 dfhack.timeout(10,'frames',wait_for_legends_vs) else dfhack.timeout(10,'frames',wait_for_export_maps_vs) end end -if df.viewscreen_legendsst:is_instance( vs ) then -- dfhack.gui.getCurFocus() == "legends" - if args[1] == "all" then - gui.simulateInput(vs, df.interface_key.LEGENDS_EXPORT_MAP) - print(' Exporting: world map/gen info') - gui.simulateInput(vs, df.interface_key.LEGENDS_EXPORT_XML) - print(' Exporting: legends xml') +-- export site maps +function export_site_maps() + local vs = dfhack.gui.getCurViewscreen() + print(' Exporting: All possible site maps') + vs.anon_21 = 1 -- get to sites screen before the next bit + gui.simulateInput(vs, 'SELECT') + for i=1, #vs.sites do + gui.simulateInput(vs, 'LEGENDS_EXPORT_MAP') + gui.simulateInput(vs, 'STANDARDSCROLL_DOWN') + end + gui.simulateInput(vs, 'LEAVESCREEN') +end + +-- main() +if dfhack.gui.getCurFocus() == "legends" then + if args[1] == "all" then + export_legends_info() + export_site_maps() wait_for_legends_vs() - elseif args[1] == "maps" then wait_for_legends_vs() + elseif args[1] == "info" then + wait_for_legends_vs() + elseif args[1] == "maps" then + wait_for_legends_vs() + elseif args[1] == "sites" then + export_site_maps() + else dfhack.printerr('Valid arguments are "all", "info", "maps" or "sites"') end -elseif df.viewscreen_export_graphical_mapst:is_instance(vs) then - if args[1] == "maps" or args[1] == "all" then wait_for_export_maps_vs() end else - dfhack.printerr('Not in legends view') -end + dfhack.printerr('Not in main legends view') +end \ No newline at end of file