Allow look up/down, unsuspend job if pressing wait with job.

develop
Warmist 2012-11-29 18:49:36 +02:00
parent f617d2844b
commit 346b402a0f
1 changed files with 13 additions and 4 deletions

@ -309,9 +309,16 @@ function AssignJobToBuild(args)
DialogBuildingChoose(dfhack.curry(BuildingChosen,args.old_pos,args.pos)) DialogBuildingChoose(dfhack.curry(BuildingChosen,args.old_pos,args.pos))
end end
end end
function CancelJob(unit)
local c_job=unit.job.current_job
if c_job then
unit.job.current_job =nil --todo add real cancelation
end
end
function ContinueJob(unit) function ContinueJob(unit)
local c_job=unit.job.current_job local c_job=unit.job.current_job
if c_job then if c_job then
c_job.flags.suspend=false
for k,v in pairs(c_job.items) do for k,v in pairs(c_job.items) do
if v.is_fetching==1 then if v.is_fetching==1 then
unit.path.dest:assign(v.item.pos) unit.path.dest:assign(v.item.pos)
@ -394,6 +401,7 @@ ALLOWED_KEYS={
A_MOVE_NE=true,A_MOVE_SW=true,A_MOVE_SE=true,A_STANCE=true,SELECT=true,A_MOVE_DOWN_AUX=true, A_MOVE_NE=true,A_MOVE_SW=true,A_MOVE_SE=true,A_STANCE=true,SELECT=true,A_MOVE_DOWN_AUX=true,
A_MOVE_UP_AUX=true,A_LOOK=true,CURSOR_DOWN=true,CURSOR_UP=true,CURSOR_LEFT=true,CURSOR_RIGHT=true, A_MOVE_UP_AUX=true,A_LOOK=true,CURSOR_DOWN=true,CURSOR_UP=true,CURSOR_LEFT=true,CURSOR_RIGHT=true,
CURSOR_UPLEFT=true,CURSOR_UPRIGHT=true,CURSOR_DOWNLEFT=true,CURSOR_DOWNRIGHT=true,A_CLEAR_ANNOUNCEMENTS=true, CURSOR_UPLEFT=true,CURSOR_UPRIGHT=true,CURSOR_DOWNLEFT=true,CURSOR_DOWNRIGHT=true,A_CLEAR_ANNOUNCEMENTS=true,
CURSOR_UP_Z=true,CURSOR_DOWN_Z=true,
} }
function moddedpos(pos,delta) function moddedpos(pos,delta)
return {x=pos.x+delta[1],y=pos.y+delta[2],z=pos.z+delta[3]} return {x=pos.x+delta[1],y=pos.y+delta[2],z=pos.z+delta[3]}
@ -411,12 +419,13 @@ function usetool:onHelp()
showHelp() showHelp()
end end
function usetool:onInput(keys) function usetool:onInput(keys)
local adv=df.global.world.units.active[0]
if keys.LEAVESCREEN then if keys.LEAVESCREEN then
if df.global.cursor.x~=-30000 then if df.global.cursor.x~=-30000 then
self:sendInputToParent("LEAVESCREEN") self:sendInputToParent("LEAVESCREEN")
else else
self:dismiss() self:dismiss()
CancelJob(adv)
end end
elseif keys[keybinds.key_next.key] then elseif keys[keybinds.key_next.key] then
mode=(mode+1)%#dig_modes mode=(mode+1)%#dig_modes
@ -426,14 +435,14 @@ function usetool:onInput(keys)
--elseif keys.A_LOOK then --elseif keys.A_LOOK then
-- self:sendInputToParent("A_LOOK") -- self:sendInputToParent("A_LOOK")
elseif keys[keybinds.key_continue.key] then elseif keys[keybinds.key_continue.key] then
ContinueJob(df.global.world.units.active[0]) ContinueJob(adv)
self:sendInputToParent("A_WAIT") self:sendInputToParent("A_WAIT")
else else
local adv=df.global.world.units.active[0]
local cur_mode=dig_modes[(mode or 0)+1] local cur_mode=dig_modes[(mode or 0)+1]
local failed=false local failed=false
for code,_ in pairs(keys) do for code,_ in pairs(keys) do
--print(code) print(code)
if MOVEMENT_KEYS[code] then if MOVEMENT_KEYS[code] then
local state={unit=adv,pos=moddedpos(adv.pos,MOVEMENT_KEYS[code]),dir=MOVEMENT_KEYS[code], local state={unit=adv,pos=moddedpos(adv.pos,MOVEMENT_KEYS[code]),dir=MOVEMENT_KEYS[code],
old_pos={x=adv.pos.x,y=adv.pos.y, z=adv.pos.z}} old_pos={x=adv.pos.x,y=adv.pos.y, z=adv.pos.z}}