|
|
@ -228,6 +228,8 @@ function GmEditorUi:editSelected(index,choice)
|
|
|
|
self:updateTarget(true)
|
|
|
|
self:updateTarget(true)
|
|
|
|
elseif trg_type == 'userdata' or trg_type == 'table' then
|
|
|
|
elseif trg_type == 'userdata' or trg_type == 'table' then
|
|
|
|
self:pushTarget(trg.target[trg_key])
|
|
|
|
self:pushTarget(trg.target[trg_key])
|
|
|
|
|
|
|
|
elseif trg_type == 'nil' or trg_type == 'function' then
|
|
|
|
|
|
|
|
-- ignore
|
|
|
|
else
|
|
|
|
else
|
|
|
|
print("Unknown type:"..trg_type)
|
|
|
|
print("Unknown type:"..trg_type)
|
|
|
|
pcall(function() print("Subtype:"..tostring(trg.target[trg_key]._kind)) end)
|
|
|
|
pcall(function() print("Subtype:"..tostring(trg.target[trg_key]._kind)) end)
|
|
|
@ -379,21 +381,45 @@ function GmEditorUi:popTarget()
|
|
|
|
self:updateTarget()
|
|
|
|
self:updateTarget()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
function show_editor(trg)
|
|
|
|
function show_editor(trg)
|
|
|
|
|
|
|
|
if not trg then
|
|
|
|
|
|
|
|
qerror('Target not found')
|
|
|
|
|
|
|
|
end
|
|
|
|
local screen = GmEditorUi{target=trg}
|
|
|
|
local screen = GmEditorUi{target=trg}
|
|
|
|
screen:show()
|
|
|
|
screen:show()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
eval_env = {}
|
|
|
|
|
|
|
|
setmetatable(eval_env, {__index = function(_, k)
|
|
|
|
|
|
|
|
if k == 'scr' or k == 'screen' then
|
|
|
|
|
|
|
|
return dfhack.gui.getCurViewscreen()
|
|
|
|
|
|
|
|
elseif k == 'bld' or k == 'building' then
|
|
|
|
|
|
|
|
return dfhack.gui.getSelectedBuilding()
|
|
|
|
|
|
|
|
elseif k == 'item' then
|
|
|
|
|
|
|
|
return dfhack.gui.getSelectedItem()
|
|
|
|
|
|
|
|
elseif k == 'job' then
|
|
|
|
|
|
|
|
return dfhack.gui.getSelectedJob()
|
|
|
|
|
|
|
|
elseif k == 'wsjob' or k == 'workshop_job' then
|
|
|
|
|
|
|
|
return dfhack.gui.getSelectedWorkshopJob()
|
|
|
|
|
|
|
|
elseif k == 'unit' then
|
|
|
|
|
|
|
|
return dfhack.gui.getSelectedUnit()
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
return _G[k]
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end})
|
|
|
|
|
|
|
|
function eval(s)
|
|
|
|
|
|
|
|
local f, err = load("return " .. s, "expression", "t", eval_env)
|
|
|
|
|
|
|
|
if err then qerror(err) end
|
|
|
|
|
|
|
|
return f()
|
|
|
|
|
|
|
|
end
|
|
|
|
if #args~=0 then
|
|
|
|
if #args~=0 then
|
|
|
|
if args[1]=="dialog" then
|
|
|
|
if args[1]=="dialog" then
|
|
|
|
function thunk(entry)
|
|
|
|
function thunk(entry)
|
|
|
|
local t=load("return "..entry)()
|
|
|
|
show_editor(eval(entry))
|
|
|
|
show_editor(t)
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
dialog.showInputPrompt("Gm Editor", "Object to edit:", COLOR_GRAY, "",thunk)
|
|
|
|
dialog.showInputPrompt("Gm Editor", "Object to edit:", COLOR_GRAY, "",thunk)
|
|
|
|
elseif args[1]=="free" then
|
|
|
|
elseif args[1]=="free" then
|
|
|
|
show_editor(df.reinterpret_cast(df[args[2]],args[3]))
|
|
|
|
show_editor(df.reinterpret_cast(df[args[2]],args[3]))
|
|
|
|
else
|
|
|
|
else
|
|
|
|
local t=load("return "..args[1])()
|
|
|
|
show_editor(eval(args[1]))
|
|
|
|
show_editor(t)
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
else
|
|
|
|
else
|
|
|
|
show_editor(getTargetFromScreens())
|
|
|
|
show_editor(getTargetFromScreens())
|
|
|
|