diff --git a/plugins/lua/buildingplan.lua b/plugins/lua/buildingplan.lua index d64317eb0..7e034b988 100644 --- a/plugins/lua/buildingplan.lua +++ b/plugins/lua/buildingplan.lua @@ -14,6 +14,7 @@ local _ENV = mkmodule('plugins.buildingplan') local argparse = require('argparse') local inspector = require('plugins.buildingplan.inspectoroverlay') +local mechanisms = require('plugins.buildingplan.mechanisms') local pens = require('plugins.buildingplan.pens') local planner = require('plugins.buildingplan.planneroverlay') require('dfhack.buildings') @@ -134,12 +135,14 @@ function reload_modules() reload('plugins.buildingplan.itemselection') reload('plugins.buildingplan.planneroverlay') reload('plugins.buildingplan.inspectoroverlay') + reload('plugins.buildingplan.mechanisms') reload('plugins.buildingplan') end OVERLAY_WIDGETS = { planner=planner.PlannerOverlay, inspector=inspector.InspectorOverlay, + mechanisms=mechanisms.MechanismOverlay, } return _ENV diff --git a/plugins/lua/buildingplan/mechanisms.lua b/plugins/lua/buildingplan/mechanisms.lua new file mode 100644 index 000000000..b3475be2b --- /dev/null +++ b/plugins/lua/buildingplan/mechanisms.lua @@ -0,0 +1,69 @@ +local _ENV = mkmodule('plugins.buildingplan.mechanisms') + +local overlay = require('plugins.overlay') +local widgets = require('gui.widgets') + +-------------------------------- +-- MechanismOverlay +-- + +MechanismOverlay = defclass(MechanismOverlay, overlay.OverlayWidget) +MechanismOverlay.ATTRS{ + default_pos={x=5,y=5}, + default_enabled=true, + viewscreens='dwarfmode/LinkingLever', + frame={w=57, h=13}, +} + +function MechanismOverlay:init() + self:addviews{ + widgets.CycleHotkeyLabel{ + view_id='safety1', + frame={t=4, l=4, w=40}, + key='CUSTOM_G', + label='Lever mechanism safety:', + options={ + {label='Any', value=0}, + {label='Magma', value=2, pen=COLOR_RED}, + {label='Fire', value=1, pen=COLOR_LIGHTRED}, + }, + initial_option=0, + }, + widgets.CycleHotkeyLabel{ + view_id='safety2', + frame={t=5, l=4, w=40}, + key='CUSTOM_SHIFT_G', + label='Target mechanism safety:', + options={ + {label='Any', value=0}, + {label='Magma', value=2, pen=COLOR_RED}, + {label='Fire', value=1, pen=COLOR_LIGHTRED}, + }, + initial_option=0, + }, + widgets.HotkeyLabel{ + frame={t=6, l=9, w=48, h=3}, + key='CUSTOM_M', + label='Choose', + auto_height=false, + on_activate=function() end, + }, + widgets.HotkeyLabel{ + frame={t=9, l=9, w=48, h=3}, + key='CUSTOM_SHIFT_M', + label='Choose', + auto_height=false, + on_activate=function() end, + }, + } +end + +function MechanismOverlay:onInput(keys) + if keys._MOUSE_L and self:getMousePos() then + MechanismOverlay.super.onInput(self, keys) + -- don't let clicks bleed through the panel + return true + end +end + +return _ENV