|
|
@ -4,12 +4,15 @@ local itemselection = require('plugins.buildingplan.itemselection')
|
|
|
|
local filterselection = require('plugins.buildingplan.filterselection')
|
|
|
|
local filterselection = require('plugins.buildingplan.filterselection')
|
|
|
|
local gui = require('gui')
|
|
|
|
local gui = require('gui')
|
|
|
|
local guidm = require('gui.dwarfmode')
|
|
|
|
local guidm = require('gui.dwarfmode')
|
|
|
|
|
|
|
|
local json = require('json')
|
|
|
|
local overlay = require('plugins.overlay')
|
|
|
|
local overlay = require('plugins.overlay')
|
|
|
|
local pens = require('plugins.buildingplan.pens')
|
|
|
|
local pens = require('plugins.buildingplan.pens')
|
|
|
|
local utils = require('utils')
|
|
|
|
local utils = require('utils')
|
|
|
|
local widgets = require('gui.widgets')
|
|
|
|
local widgets = require('gui.widgets')
|
|
|
|
require('dfhack.buildings')
|
|
|
|
require('dfhack.buildings')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
config = config or json.open('dfhack-config/buildingplan.json')
|
|
|
|
|
|
|
|
|
|
|
|
local uibs = df.global.buildreq
|
|
|
|
local uibs = df.global.buildreq
|
|
|
|
|
|
|
|
|
|
|
|
reset_counts_flag = false
|
|
|
|
reset_counts_flag = false
|
|
|
@ -336,14 +339,14 @@ PlannerOverlay.ATTRS{
|
|
|
|
|
|
|
|
|
|
|
|
function PlannerOverlay:init()
|
|
|
|
function PlannerOverlay:init()
|
|
|
|
self.selected = 1
|
|
|
|
self.selected = 1
|
|
|
|
self.minimized = false
|
|
|
|
self.state = ensure_key(config.data, 'planner')
|
|
|
|
|
|
|
|
|
|
|
|
local main_panel = widgets.Panel{
|
|
|
|
local main_panel = widgets.Panel{
|
|
|
|
view_id='main',
|
|
|
|
view_id='main',
|
|
|
|
frame={t=1, l=0, r=0, h=14},
|
|
|
|
frame={t=1, l=0, r=0, h=14},
|
|
|
|
frame_style=gui.INTERIOR_MEDIUM_FRAME,
|
|
|
|
frame_style=gui.INTERIOR_MEDIUM_FRAME,
|
|
|
|
frame_background=gui.CLEAR_PEN,
|
|
|
|
frame_background=gui.CLEAR_PEN,
|
|
|
|
visible=function() return not self.minimized end,
|
|
|
|
visible=self:callback('is_not_minimized'),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
local minimized_panel = widgets.Panel{
|
|
|
|
local minimized_panel = widgets.Panel{
|
|
|
@ -355,8 +358,8 @@ function PlannerOverlay:init()
|
|
|
|
{text=' show Planner ', pen=pens.MINI_TEXT_PEN, hpen=pens.MINI_TEXT_HPEN},
|
|
|
|
{text=' show Planner ', pen=pens.MINI_TEXT_PEN, hpen=pens.MINI_TEXT_HPEN},
|
|
|
|
{text='['..string.char(31)..']', pen=pens.MINI_BUTT_PEN, hpen=pens.MINI_BUTT_HPEN},
|
|
|
|
{text='['..string.char(31)..']', pen=pens.MINI_BUTT_PEN, hpen=pens.MINI_BUTT_HPEN},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
visible=function() return self.minimized end,
|
|
|
|
visible=self:callback('is_minimized'),
|
|
|
|
on_click=function() self.minimized = not self.minimized end,
|
|
|
|
on_click=self:callback('toggle_minimized'),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
widgets.Label{
|
|
|
|
widgets.Label{
|
|
|
|
frame={t=0, r=0, h=1},
|
|
|
|
frame={t=0, r=0, h=1},
|
|
|
@ -364,8 +367,8 @@ function PlannerOverlay:init()
|
|
|
|
{text=' hide Planner ', pen=pens.MINI_TEXT_PEN, hpen=pens.MINI_TEXT_HPEN},
|
|
|
|
{text=' hide Planner ', pen=pens.MINI_TEXT_PEN, hpen=pens.MINI_TEXT_HPEN},
|
|
|
|
{text='['..string.char(30)..']', pen=pens.MINI_BUTT_PEN, hpen=pens.MINI_BUTT_HPEN},
|
|
|
|
{text='['..string.char(30)..']', pen=pens.MINI_BUTT_PEN, hpen=pens.MINI_BUTT_HPEN},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
visible=function() return not self.minimized end,
|
|
|
|
visible=self:callback('is_not_minimized'),
|
|
|
|
on_click=function() self.minimized = not self.minimized end,
|
|
|
|
on_click=self:callback('toggle_minimized'),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -554,7 +557,7 @@ function PlannerOverlay:init()
|
|
|
|
view_id='divider',
|
|
|
|
view_id='divider',
|
|
|
|
frame={t=10, l=0, r=0, h=1},
|
|
|
|
frame={t=10, l=0, r=0, h=1},
|
|
|
|
on_render=self:callback('draw_divider_h'),
|
|
|
|
on_render=self:callback('draw_divider_h'),
|
|
|
|
visible=function() return not self.minimized end,
|
|
|
|
visible=self:callback('is_not_minimized'),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
local error_panel = widgets.ResizingPanel{
|
|
|
|
local error_panel = widgets.ResizingPanel{
|
|
|
@ -562,7 +565,7 @@ function PlannerOverlay:init()
|
|
|
|
frame={t=15, l=0, r=0},
|
|
|
|
frame={t=15, l=0, r=0},
|
|
|
|
frame_style=gui.BOLD_FRAME,
|
|
|
|
frame_style=gui.BOLD_FRAME,
|
|
|
|
frame_background=gui.CLEAR_PEN,
|
|
|
|
frame_background=gui.CLEAR_PEN,
|
|
|
|
visible=function() return not self.minimized end,
|
|
|
|
visible=self:callback('is_not_minimized'),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
error_panel:addviews{
|
|
|
|
error_panel:addviews{
|
|
|
@ -609,7 +612,7 @@ function PlannerOverlay:init()
|
|
|
|
frame={t=0, l=1, w=37, h=1},
|
|
|
|
frame={t=0, l=1, w=37, h=1},
|
|
|
|
frame_inset=0,
|
|
|
|
frame_inset=0,
|
|
|
|
frame_background=gui.CLEAR_PEN,
|
|
|
|
frame_background=gui.CLEAR_PEN,
|
|
|
|
visible=function() return not self.minimized end,
|
|
|
|
visible=self:callback('is_not_minimized'),
|
|
|
|
subviews={
|
|
|
|
subviews={
|
|
|
|
prev_next_selector,
|
|
|
|
prev_next_selector,
|
|
|
|
},
|
|
|
|
},
|
|
|
@ -624,6 +627,19 @@ function PlannerOverlay:init()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function PlannerOverlay:is_minimized()
|
|
|
|
|
|
|
|
return self.state.minimized
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function PlannerOverlay:is_not_minimized()
|
|
|
|
|
|
|
|
return not self.state.minimized
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function PlannerOverlay:toggle_minimized()
|
|
|
|
|
|
|
|
self.state.minimized = not self.state.minimized
|
|
|
|
|
|
|
|
config:write()
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function PlannerOverlay:draw_divider_h(dc)
|
|
|
|
function PlannerOverlay:draw_divider_h(dc)
|
|
|
|
local x2 = dc.width -1
|
|
|
|
local x2 = dc.width -1
|
|
|
|
for x=0,x2 do
|
|
|
|
for x=0,x2 do
|
|
|
@ -735,13 +751,13 @@ function PlannerOverlay:onInput(keys)
|
|
|
|
return false
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
end
|
|
|
|
if keys.CUSTOM_ALT_M then
|
|
|
|
if keys.CUSTOM_ALT_M then
|
|
|
|
self.minimized = not self.minimized
|
|
|
|
self:toggle_minimized()
|
|
|
|
return true
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
if PlannerOverlay.super.onInput(self, keys) then
|
|
|
|
if PlannerOverlay.super.onInput(self, keys) then
|
|
|
|
return true
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
if self.minimized then return false end
|
|
|
|
if self:is_minimized() then return false end
|
|
|
|
if keys._MOUSE_L_DOWN then
|
|
|
|
if keys._MOUSE_L_DOWN then
|
|
|
|
if is_over_options_panel() then return false end
|
|
|
|
if is_over_options_panel() then return false end
|
|
|
|
local detect_rect = copyall(self.frame_rect)
|
|
|
|
local detect_rect = copyall(self.frame_rect)
|
|
|
@ -837,7 +853,7 @@ function PlannerOverlay:onRenderFrame(dc, rect)
|
|
|
|
uibs.building_type, uibs.building_subtype, uibs.custom_type))
|
|
|
|
uibs.building_type, uibs.building_subtype, uibs.custom_type))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
if self.minimized then return end
|
|
|
|
if self:is_minimized() then return end
|
|
|
|
|
|
|
|
|
|
|
|
local bounds = get_selected_bounds(self.saved_selection_pos, self.saved_pos)
|
|
|
|
local bounds = get_selected_bounds(self.saved_selection_pos, self.saved_pos)
|
|
|
|
if not bounds then return end
|
|
|
|
if not bounds then return end
|
|
|
|