update exportlegends for DF40.x

Better code and also exports the new maps.  Extending to also export
site maps would be cool eventually.
develop
PeridexisErrant 2014-09-09 17:47:26 +10:00
parent c4d6c384ae
commit af79ae44c9
3 changed files with 18 additions and 16 deletions

@ -1,5 +1,9 @@
DFHack future DFHack future
Misc improvements:
updated exportlegends.lua to work with new maps, dfhack 40.11 r1+
DFHack 0.40.11-r1 DFHack 0.40.11-r1
Internals: Internals:

@ -1424,7 +1424,7 @@ Exports data from legends mode; allowing a set-and-forget export of large worlds
Options: Options:
:maps: Exports all fifteen detailed maps :maps: Exports all seventeen detailed maps
:all: first exports the world/gen info, then the XML, then all detailed maps :all: first exports the world/gen info, then the XML, then all detailed maps

@ -1,18 +1,14 @@
-- Export everything from legends mode -- Export everything from legends mode
-- Based on the script 'exportmaps' -- use "exportlegends maps" for detailed maps, or "exportlegends all" to also export legends
-- Suggested keybinding: keybinding add Shift-A@legends "exportlegends all"
gui = require 'gui' gui = require 'gui'
local args = {...} local args = {...}
local vs = dfhack.gui.getCurViewscreen() local vs = dfhack.gui.getCurViewscreen()
local i = 0 local i = 1
if args[1] then print(' A script which exports data from legends mode. Valid arguments are "maps" (detailed maps) or "all" (detailed maps, world/gen info, XML).') end
local MAPS = { local MAPS = {
[0] = "Standard biome+site map", "Standard biome+site map",
"Elevations including lake and ocean floors", "Elevations including lake and ocean floors",
"Elevations respecting water level", "Elevations respecting water level",
"Biome", "Biome",
@ -27,12 +23,14 @@ local MAPS = {
"Salinity", "Salinity",
"Structures/fields/roads/etc.", "Structures/fields/roads/etc.",
"Trade", "Trade",
"Nobility and Holdings",
"Diplomacy",
} }
function wait_for_legends_vs() function wait_for_legends_vs()
vs = dfhack.gui.getCurViewscreen() vs = dfhack.gui.getCurViewscreen()
if i < 15 then if i <= #MAPS then
if df.viewscreen_legendsst:is_instance(vs) then if df.viewscreen_legendsst:is_instance(vs) then
gui.simulateInput(vs, 'LEGENDS_EXPORT_DETAILED_MAP') -- "d" on screen some number internally gui.simulateInput(vs, 'LEGENDS_EXPORT_DETAILED_MAP')
dfhack.timeout(10,'frames',wait_for_export_maps_vs) dfhack.timeout(10,'frames',wait_for_export_maps_vs)
else else
dfhack.timeout(10,'frames',wait_for_legends_vs) dfhack.timeout(10,'frames',wait_for_legends_vs)
@ -42,10 +40,10 @@ end
function wait_for_export_maps_vs() function wait_for_export_maps_vs()
vs = dfhack.gui.getCurViewscreen() vs = dfhack.gui.getCurViewscreen()
if df.viewscreen_export_graphical_mapst:is_instance(vs) then if df.viewscreen_export_graphical_mapst:is_instance(vs) then
vs.anon_13 = i -- anon_13 appears to be the selection cursor for this viewscreen vs.sel_idx = i
print('Exporting: '..MAPS[i]) print(' Exporting: '..MAPS[i]..' map')
i = i + 1 i = i + 1
gui.simulateInput(vs, 'SELECT') -- 1 internally, enter on screen gui.simulateInput(vs, 'SELECT')
dfhack.timeout(10,'frames',wait_for_legends_vs) dfhack.timeout(10,'frames',wait_for_legends_vs)
else else
dfhack.timeout(10,'frames',wait_for_export_maps_vs) dfhack.timeout(10,'frames',wait_for_export_maps_vs)
@ -55,14 +53,14 @@ end
if df.viewscreen_legendsst:is_instance( vs ) then -- dfhack.gui.getCurFocus() == "legends" if df.viewscreen_legendsst:is_instance( vs ) then -- dfhack.gui.getCurFocus() == "legends"
if args[1] == "all" then if args[1] == "all" then
gui.simulateInput(vs, df.interface_key.LEGENDS_EXPORT_MAP) gui.simulateInput(vs, df.interface_key.LEGENDS_EXPORT_MAP)
print('Exporting: world map/gen info') print(' Exporting: world map/gen info')
gui.simulateInput(vs, df.interface_key.LEGENDS_EXPORT_XML) gui.simulateInput(vs, df.interface_key.LEGENDS_EXPORT_XML)
print('Exporting: legends xml') print(' Exporting: legends xml')
wait_for_legends_vs() wait_for_legends_vs()
elseif args[1] == "maps" then wait_for_legends_vs() elseif args[1] == "maps" then wait_for_legends_vs()
end end
elseif df.viewscreen_export_graphical_mapst:is_instance(vs) then elseif df.viewscreen_export_graphical_mapst:is_instance(vs) then
if args[1] == "maps" or "all" then wait_for_export_maps_vs() end if args[1] == "maps" or args[1] == "all" then wait_for_export_maps_vs() end
else else
dfhack.printerr('Not in legends view') dfhack.printerr('Not in legends view')
end end