Merge branch 'add-exportlegends-and-logregion' into develop

develop
Alexander Gavrilov 2014-05-12 21:51:03 +04:00
commit a6d576961d
5 changed files with 130 additions and 0 deletions

@ -13,6 +13,8 @@ DFHack future
- gui/clone-uniform: duplicates the currently selected uniform in the military screen. - gui/clone-uniform: duplicates the currently selected uniform in the military screen.
- fix/build-location: partial work-around for bug 5991 (trying to build wall while standing on it) - fix/build-location: partial work-around for bug 5991 (trying to build wall while standing on it)
- undump-buildings: removes dump designation from materials used in buildings. - undump-buildings: removes dump designation from materials used in buildings.
- exportlegends: exports data from legends mode, allowing a set-and-forget export of large worlds.
- log-region: each time a fort is loaded identifying information will be written to the gamelog.
New commands: New commands:
- move the 'grow', 'extirpate' and 'immolate' commands as 'plant' subcommands - move the 'grow', 'extirpate' and 'immolate' commands as 'plant' subcommands

@ -1527,6 +1527,15 @@ dwarfexport
----------- -----------
Export dwarves to RuneSmith-compatible XML. Export dwarves to RuneSmith-compatible XML.
exportlegends
-------------
Exports data from legends mode; allowing a set-and-forget export of large worlds.
Options:
:maps: Exports all fifteen detailed maps
:all: first exports the world/gen info, then the XML, then all detailed maps
Job management Job management
============== ==============
@ -2048,6 +2057,11 @@ Options:
Known limitations: if the selected unit is currently performing a job, the mood will not be started. Known limitations: if the selected unit is currently performing a job, the mood will not be started.
log-region
----------
When enabled in dfhack.init, each time a fort is loaded identifying information will be written to the gamelog. Assists in parsing the file if you switch between forts, and adds information for story-building.
======= =======
Scripts Scripts
======= =======

@ -41,6 +41,14 @@ keybinding add Ctrl-Shift-P command-prompt
keybinding add Ctrl-B adv-bodyswap keybinding add Ctrl-B adv-bodyswap
keybinding add Ctrl-Shift-B "adv-bodyswap force" keybinding add Ctrl-Shift-B "adv-bodyswap force"
##############################
# Generic legends bindings #
##############################
# 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 # # Context-specific bindings #
############################# #############################
@ -188,6 +196,9 @@ enable automaterial
# write the correct season to gamelog on world load # write the correct season to gamelog on world load
soundsense-season soundsense-season
# write identifying information about the fort to gamelog on world load
log-region
# patch the material objects in memory to fix cloth stockpiles # patch the material objects in memory to fix cloth stockpiles
fix/cloth-stockpile enable fix/cloth-stockpile enable

@ -0,0 +1,68 @@
-- Export everything from legends mode
-- Based on the script 'exportmaps'
-- Suggested keybinding: keybinding add Shift-A@legends "exportlegends all"
gui = require 'gui'
local args = {...}
local vs = dfhack.gui.getCurViewscreen()
local i = 0
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 = {
[0] = "Standard biome+site map",
"Elevations including lake and ocean floors",
"Elevations respecting water level",
"Biome",
"Hydrosphere",
"Temperature",
"Rainfall",
"Drainage",
"Savagery",
"Volcanism",
"Current vegetation",
"Evil",
"Salinity",
"Structures/fields/roads/etc.",
"Trade",
}
function wait_for_legends_vs()
vs = dfhack.gui.getCurViewscreen()
if i < 15 then
if df.viewscreen_legendsst:is_instance(vs) then
gui.simulateInput(vs, 'LEGENDS_EXPORT_DETAILED_MAP') -- "d" on screen some number internally
dfhack.timeout(10,'frames',wait_for_export_maps_vs)
else
dfhack.timeout(10,'frames',wait_for_legends_vs)
end
end
end
function wait_for_export_maps_vs()
vs = dfhack.gui.getCurViewscreen()
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
print('Exporting: '..MAPS[i])
i = i + 1
gui.simulateInput(vs, 'SELECT') -- 1 internally, enter on screen
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')
wait_for_legends_vs()
elseif args[1] == "maps" then wait_for_legends_vs()
end
elseif df.viewscreen_export_graphical_mapst:is_instance(vs) then
if args[1] == "maps" or "all" then wait_for_export_maps_vs() end
else
dfhack.printerr('Not in legends view')
end

@ -0,0 +1,35 @@
-- On map load writes information about the loaded region to gamelog.txt
-- By Kurik Amudnil and Warmist (http://www.bay12forums.com/smf/index.php?topic=91166.msg4467072#msg4467072)
local function write_gamelog(msg)
local log = io.open('gamelog.txt', 'a')
log:write(msg.."\n")
log:close()
end
local args = {...}
if args[1] == 'disable' then
dfhack.onStateChange[_ENV] = nil
else
dfhack.onStateChange[_ENV] = function(op)
if op == SC_WORLD_LOADED then
if df.world_site.find(df.global.ui.site_id) ~= nil then -- added this check, now only attempts write in fort mode
local site = df.world_site.find(df.global.ui.site_id)
local fort_ent = df.global.ui.main.fortress_entity
local civ_ent = df.historical_entity.find(df.global.ui.civ_id)
local worldname = df.global.world.world_data.name
-- site positions
-- site .pos.x .pos.y
-- site .rgn_min_x .rgn_min_y .rgn_max_x .rgn_max.y
-- site .global_min_x .global_min_y .global_max_x .global_max_y
--site.name
--fort_ent.name
--civ_ent.name
write_gamelog('Loaded '..df.global.world.cur_savegame.save_dir..', '..dfhack.TranslateName(worldname)..' ('..dfhack.TranslateName(worldname ,true)..') at coordinates ('..site.pos.x..','..site.pos.y..')'..NEWLINE..
'Loaded the fortress '..dfhack.TranslateName(site.name)..' ('..dfhack.TranslateName(site.name, true)..'), colonized by the group '..dfhack.TranslateName(fort_ent.name)..' ('..dfhack.TranslateName(fort_ent.name,true)..
') of the civilization '..dfhack.TranslateName(civ_ent.name)..' ('..dfhack.TranslateName(civ_ent.name,true)..').'..NEWLINE)
end
end
end
end