|
|
@ -20,11 +20,16 @@ UnitPathUI.focus_path = 'unit-path'
|
|
|
|
|
|
|
|
|
|
|
|
UnitPathUI.ATTRS {
|
|
|
|
UnitPathUI.ATTRS {
|
|
|
|
unit = DEFAULT_NIL,
|
|
|
|
unit = DEFAULT_NIL,
|
|
|
|
|
|
|
|
has_path = false,
|
|
|
|
|
|
|
|
has_goal = false,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function UnitPathUI:init()
|
|
|
|
function UnitPathUI:init()
|
|
|
|
self.saved_mode = df.global.ui.main.mode
|
|
|
|
self.saved_mode = df.global.ui.main.mode
|
|
|
|
|
|
|
|
if self.unit then
|
|
|
|
|
|
|
|
self.has_path = #self.unit.path.path.x > 0
|
|
|
|
|
|
|
|
self.has_goal = self.unit.path.dest.x >= 0
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function UnitPathUI:onShow()
|
|
|
|
function UnitPathUI:onShow()
|
|
|
@ -139,12 +144,11 @@ function UnitPathUI:onRenderBody(dc)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
local cursor = guidm.getCursorPos()
|
|
|
|
local cursor = guidm.getCursorPos()
|
|
|
|
local has_path = #self.unit.path.path.x>0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
local vp = self:getViewport()
|
|
|
|
local vp = self:getViewport()
|
|
|
|
local mdc = gui.Painter.new(self.df_layout.map)
|
|
|
|
local mdc = gui.Painter.new(self.df_layout.map)
|
|
|
|
|
|
|
|
|
|
|
|
if not has_path then
|
|
|
|
if not self.has_path then
|
|
|
|
if gui.blink_visible(120) then
|
|
|
|
if gui.blink_visible(120) then
|
|
|
|
paintMapTile(mdc, vp, cursor, self.unit.pos, 15, COLOR_LIGHTRED, COLOR_RED)
|
|
|
|
paintMapTile(mdc, vp, cursor, self.unit.pos, 15, COLOR_LIGHTRED, COLOR_RED)
|
|
|
|
end
|
|
|
|
end
|
|
|
@ -153,7 +157,7 @@ function UnitPathUI:onRenderBody(dc)
|
|
|
|
else
|
|
|
|
else
|
|
|
|
self:renderPath(mdc,vp,cursor)
|
|
|
|
self:renderPath(mdc,vp,cursor)
|
|
|
|
|
|
|
|
|
|
|
|
dc:seek(1,6):pen(COLOR_GREEN):string(df.unit_path_goal[self.unit.path.goal])
|
|
|
|
dc:seek(1,6):pen(COLOR_GREEN):string(df.unit_path_goal[self.unit.path.goal] or '?')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
dc:newline():pen(COLOR_GREY)
|
|
|
|
dc:newline():pen(COLOR_GREY)
|
|
|
@ -183,7 +187,7 @@ function UnitPathUI:onRenderBody(dc)
|
|
|
|
|
|
|
|
|
|
|
|
dc:newline():newline(1):pen(COLOR_WHITE)
|
|
|
|
dc:newline():newline(1):pen(COLOR_WHITE)
|
|
|
|
dc:key('CUSTOM_Z'):string(": Zoom unit, ")
|
|
|
|
dc:key('CUSTOM_Z'):string(": Zoom unit, ")
|
|
|
|
dc:key('CUSTOM_G'):string(": Zoom goal",COLOR_GREY,nil,has_path)
|
|
|
|
dc:key('CUSTOM_G'):string(": Zoom goal",COLOR_GREY,nil,self.has_goal)
|
|
|
|
dc:newline(1)
|
|
|
|
dc:newline(1)
|
|
|
|
dc:key('CUSTOM_N'):string(": Zoom station",COLOR_GREY,nil,has_station)
|
|
|
|
dc:key('CUSTOM_N'):string(": Zoom station",COLOR_GREY,nil,has_station)
|
|
|
|
dc:newline():newline(1)
|
|
|
|
dc:newline():newline(1)
|
|
|
@ -194,7 +198,7 @@ function UnitPathUI:onInput(keys)
|
|
|
|
if keys.CUSTOM_Z then
|
|
|
|
if keys.CUSTOM_Z then
|
|
|
|
self:moveCursorTo(copyall(self.unit.pos))
|
|
|
|
self:moveCursorTo(copyall(self.unit.pos))
|
|
|
|
elseif keys.CUSTOM_G then
|
|
|
|
elseif keys.CUSTOM_G then
|
|
|
|
if #self.unit.path.path.x > 0 then
|
|
|
|
if self.has_goal then
|
|
|
|
self:moveCursorTo(copyall(self.unit.path.dest))
|
|
|
|
self:moveCursorTo(copyall(self.unit.path.dest))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
elseif keys.CUSTOM_N then
|
|
|
|
elseif keys.CUSTOM_N then
|
|
|
@ -208,6 +212,10 @@ function UnitPathUI:onInput(keys)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function UnitPathUI:onGetSelectedUnit()
|
|
|
|
|
|
|
|
return self.unit
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
local unit = dfhack.gui.getSelectedUnit(true)
|
|
|
|
local unit = dfhack.gui.getSelectedUnit(true)
|
|
|
|
|
|
|
|
|
|
|
|
if not unit or not string.match(dfhack.gui.getCurFocus(), '^dwarfmode/ViewUnits/Some/') then
|
|
|
|
if not unit or not string.match(dfhack.gui.getCurFocus(), '^dwarfmode/ViewUnits/Some/') then
|
|
|
|