diff options
| author | Alexander Gavrilov | 2012-09-08 13:46:02 +0400 |
|---|---|---|
| committer | Alexander Gavrilov | 2012-09-08 13:46:02 +0400 |
| commit | bfa6ed3e0868c7a2fa9851c3feb8f9055b0330bb (patch) | |
| tree | 13da84ac921e3e607f8908c0816783598cd13a07 /library | |
| parent | 325e294af2bbd2ba0381a476756eddbbfceb1b36 (diff) | |
| download | dfhack-bfa6ed3e0868c7a2fa9851c3feb8f9055b0330bb.tar.gz dfhack-bfa6ed3e0868c7a2fa9851c3feb8f9055b0330bb.tar.bz2 dfhack-bfa6ed3e0868c7a2fa9851c3feb8f9055b0330bb.tar.xz | |
Support setting the target area for the siege engine.
Diffstat (limited to 'library')
| -rw-r--r-- | library/lua/gui/dwarfmode.lua | 29 | ||||
| -rw-r--r-- | library/modules/Gui.cpp | 7 |
2 files changed, 28 insertions, 8 deletions
diff --git a/library/lua/gui/dwarfmode.lua b/library/lua/gui/dwarfmode.lua index 21a94217..661e1559 100644 --- a/library/lua/gui/dwarfmode.lua +++ b/library/lua/gui/dwarfmode.lua @@ -46,7 +46,7 @@ function getPanelLayout() end function getCursorPos() - if g_cursor ~= -30000 then + if g_cursor.x ~= -30000 then return copyall(g_cursor) end end @@ -167,6 +167,18 @@ function Viewport:isVisible(target,gap) return self:isVisibleXY(target,gap) and target.z == self.z end +function Viewport:tileToScreen(coord) + return xyz2pos(coord.x - self.x1, coord.y - self.y1, coord.z - self.z) +end + +function Viewport:getCenter() + return xyz2pos( + math.floor((self.x2+self.x1)/2), + math.floor((self.y2+self.y1)/2), + self.z + ) +end + function Viewport:centerOn(target) return self:clip( target.x - math.floor(self.width/2), @@ -253,16 +265,23 @@ function DwarfOverlay:getViewport(old_vp) end end -function DwarfOverlay:moveCursorTo(cursor,viewport) +function DwarfOverlay:moveCursorTo(cursor,viewport,gap) setCursorPos(cursor) - self:getViewport(viewport):reveal(cursor, 5, 0, 10):set() + self:zoomViewportTo(cursor,viewport,gap) +end + +function DwarfOverlay:zoomViewportTo(target, viewport, gap) + if gap and self:getViewport():isVisible(target, gap) then + return + end + self:getViewport(viewport):reveal(target, 5, 0, 10):set() end -function DwarfOverlay:selectBuilding(building,cursor,viewport) +function DwarfOverlay:selectBuilding(building,cursor,viewport,gap) cursor = cursor or utils.getBuildingCenter(building) df.global.world.selected_building = building - self:moveCursorTo(cursor, viewport) + self:moveCursorTo(cursor, viewport, gap) end function DwarfOverlay:propagateMoveKeys(keys) diff --git a/library/modules/Gui.cpp b/library/modules/Gui.cpp index 8de90873..91df14ea 100644 --- a/library/modules/Gui.cpp +++ b/library/modules/Gui.cpp @@ -173,10 +173,9 @@ DEFINE_GET_FOCUS_STRING_HANDLER(dwarfmode) else if (id == &df::building_trapst::_identity) { auto trap = (df::building_trapst*)selected; - if (trap->trap_type == trap_type::Lever) { - focus += "/Lever"; + focus += "/" + enum_item_key(trap->trap_type); + if (trap->trap_type == trap_type::Lever) jobs = true; - } } else if (ui_building_in_assign && *ui_building_in_assign && ui_building_assign_type && ui_building_assign_units && @@ -189,6 +188,8 @@ DEFINE_GET_FOCUS_STRING_HANDLER(dwarfmode) focus += unit ? "/Unit" : "/None"; } } + else + focus += "/" + enum_item_key(selected->getType()); if (jobs) { |
