|
|
|
@ -622,7 +622,7 @@ QualityAndMaterialsPage.ATTRS{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
local TYPE_COL_WIDTH = 20
|
|
|
|
|
local HEADER_HEIGHT = 8
|
|
|
|
|
local HEADER_HEIGHT = 6
|
|
|
|
|
local QUALITY_HEIGHT = 9
|
|
|
|
|
local FOOTER_HEIGHT = 4
|
|
|
|
|
|
|
|
|
@ -649,7 +649,6 @@ local function mat_sort_by_quantity(a, b)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function QualityAndMaterialsPage:init()
|
|
|
|
|
self.lowest_other_item_heat_safety = 2
|
|
|
|
|
self.dirty = true
|
|
|
|
|
|
|
|
|
|
local enable_item_quality = can_be_improved(self.index)
|
|
|
|
@ -667,38 +666,9 @@ function QualityAndMaterialsPage:init()
|
|
|
|
|
{gap=1, pen=COLOR_LIGHTCYAN, text=self:callback('get_summary')}
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
widgets.CycleHotkeyLabel{
|
|
|
|
|
view_id='safety',
|
|
|
|
|
frame={t=2, l=0, w=35},
|
|
|
|
|
key='CUSTOM_SHIFT_G',
|
|
|
|
|
label='Building heat safety:',
|
|
|
|
|
options={
|
|
|
|
|
{label='Fire Magma', value=0, pen=COLOR_GREY},
|
|
|
|
|
{label='Fire Magma', value=2, pen=COLOR_RED},
|
|
|
|
|
{label='Fire', value=1, pen=COLOR_LIGHTRED},
|
|
|
|
|
},
|
|
|
|
|
on_change=self:callback('set_heat_safety'),
|
|
|
|
|
},
|
|
|
|
|
widgets.Label{
|
|
|
|
|
frame={t=2, l=30},
|
|
|
|
|
text='Magma',
|
|
|
|
|
auto_width=true,
|
|
|
|
|
text_pen=COLOR_GREY,
|
|
|
|
|
visible=function() return self.subviews.safety:getOptionValue() == 1 end,
|
|
|
|
|
},
|
|
|
|
|
widgets.Label{
|
|
|
|
|
frame={t=3, l=3},
|
|
|
|
|
text='Other items for this building may not be able to use all of their selected materials.',
|
|
|
|
|
visible=function() return self.subviews.safety:getOptionValue() > self.lowest_other_item_heat_safety end,
|
|
|
|
|
},
|
|
|
|
|
widgets.EditField{
|
|
|
|
|
frame={l=0, t=4, w=23},
|
|
|
|
|
label_text='Search: ',
|
|
|
|
|
on_char=function(ch) return ch:match('%l') end,
|
|
|
|
|
},
|
|
|
|
|
widgets.CycleHotkeyLabel{
|
|
|
|
|
view_id='mat_sort',
|
|
|
|
|
frame={l=24, t=4, w=21},
|
|
|
|
|
frame={l=0, t=2, w=21},
|
|
|
|
|
label='Sort by:',
|
|
|
|
|
key='CUSTOM_SHIFT_R',
|
|
|
|
|
options={
|
|
|
|
@ -709,12 +679,17 @@ function QualityAndMaterialsPage:init()
|
|
|
|
|
},
|
|
|
|
|
widgets.ToggleHotkeyLabel{
|
|
|
|
|
view_id='hide_zero',
|
|
|
|
|
frame={l=24, t=5, w=24},
|
|
|
|
|
frame={l=0, t=3, w=24},
|
|
|
|
|
label='Hide unavailable:',
|
|
|
|
|
key='CUSTOM_SHIFT_H',
|
|
|
|
|
initial_option=false,
|
|
|
|
|
on_change=function() self.dirty = true end,
|
|
|
|
|
},
|
|
|
|
|
widgets.EditField{
|
|
|
|
|
frame={l=26, t=2},
|
|
|
|
|
label_text='Search: ',
|
|
|
|
|
on_char=function(ch) return ch:match('[%l -]') end,
|
|
|
|
|
},
|
|
|
|
|
widgets.Label{
|
|
|
|
|
frame={l=1, b=0},
|
|
|
|
|
text='Type',
|
|
|
|
@ -727,8 +702,7 @@ function QualityAndMaterialsPage:init()
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
widgets.Panel{
|
|
|
|
|
view_id='materials_lists',
|
|
|
|
|
widgets.Panel{view_id='materials_lists',
|
|
|
|
|
frame={l=0, t=HEADER_HEIGHT, r=0, b=FOOTER_HEIGHT+QUALITY_HEIGHT},
|
|
|
|
|
frame_style=gui.INTERIOR_FRAME,
|
|
|
|
|
subviews={
|
|
|
|
@ -739,11 +713,13 @@ function QualityAndMaterialsPage:init()
|
|
|
|
|
icon_width=2,
|
|
|
|
|
cursor_pen=COLOR_CYAN,
|
|
|
|
|
on_double_click=self:callback('toggle_category'),
|
|
|
|
|
on_submit=self:callback('toggle_category'),
|
|
|
|
|
},
|
|
|
|
|
widgets.List{
|
|
|
|
|
view_id='materials_mats',
|
|
|
|
|
frame={l=TYPE_COL_WIDTH, t=0, r=0, b=0},
|
|
|
|
|
icon_width=2,
|
|
|
|
|
on_submit=self:callback('toggle_material'),
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
@ -866,25 +842,35 @@ end
|
|
|
|
|
local MAT_ENABLED_PEN = to_pen{ch=string.char(251), fg=COLOR_LIGHTGREEN}
|
|
|
|
|
local MAT_DISABLED_PEN = to_pen{ch='x', fg=COLOR_RED}
|
|
|
|
|
|
|
|
|
|
local function make_cat_choice(label, cat, key, enabled_cats)
|
|
|
|
|
local enabled = enabled_cats[cat]
|
|
|
|
|
local function make_cat_choice(label, cat, key, cats)
|
|
|
|
|
local enabled = cats[cat]
|
|
|
|
|
local icon = nil
|
|
|
|
|
if not cats.unset then
|
|
|
|
|
icon = enabled and MAT_ENABLED_PEN or MAT_DISABLED_PEN
|
|
|
|
|
end
|
|
|
|
|
return {
|
|
|
|
|
text=label,
|
|
|
|
|
key=key,
|
|
|
|
|
enabled=enabled,
|
|
|
|
|
cat=cat,
|
|
|
|
|
icon=enabled and MAT_ENABLED_PEN or MAT_DISABLED_PEN
|
|
|
|
|
icon=icon,
|
|
|
|
|
}
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
local function make_mat_choice(name, props)
|
|
|
|
|
local function make_mat_choice(name, props, cats)
|
|
|
|
|
local quantity = tonumber(props.count)
|
|
|
|
|
local text = ('%5d - %s'):format(quantity, name)
|
|
|
|
|
local enabled = props.enabled == 'true'
|
|
|
|
|
local enabled = props.enabled == 'true' and cats[props.category]
|
|
|
|
|
local icon = nil
|
|
|
|
|
if not cats.unset then
|
|
|
|
|
icon = enabled and MAT_ENABLED_PEN or MAT_DISABLED_PEN
|
|
|
|
|
end
|
|
|
|
|
return {
|
|
|
|
|
text=text,
|
|
|
|
|
icon=enabled and MAT_ENABLED_PEN or MAT_DISABLED_PEN,
|
|
|
|
|
enabled=enabled,
|
|
|
|
|
icon=icon,
|
|
|
|
|
name=name,
|
|
|
|
|
cat=props.category,
|
|
|
|
|
quantity=quantity,
|
|
|
|
|
}
|
|
|
|
|
end
|
|
|
|
@ -894,7 +880,6 @@ function QualityAndMaterialsPage:refresh()
|
|
|
|
|
local subviews = self.subviews
|
|
|
|
|
|
|
|
|
|
local heat = getHeatSafetyFilter(uibs.building_type, uibs.building_subtype, uibs.custom_type)
|
|
|
|
|
subviews.safety:setOption(heat)
|
|
|
|
|
if heat >= 2 then summary = summary .. 'Magma safe '
|
|
|
|
|
elseif heat == 1 then summary = summary .. 'Fire safe '
|
|
|
|
|
end
|
|
|
|
@ -904,12 +889,12 @@ function QualityAndMaterialsPage:refresh()
|
|
|
|
|
subviews.min_quality:setOption(quality.min_quality)
|
|
|
|
|
subviews.max_quality:setOption(quality.max_quality)
|
|
|
|
|
|
|
|
|
|
local categories = utils.invert(getMaterialMaskFilter(uibs.building_type, uibs.building_subtype, uibs.custom_type, self.index-1))
|
|
|
|
|
local cats = getMaterialMaskFilter(uibs.building_type, uibs.building_subtype, uibs.custom_type, self.index-1)
|
|
|
|
|
local category_choices={
|
|
|
|
|
make_cat_choice('Stone', 'stone', 'CUSTOM_SHIFT_S', categories),
|
|
|
|
|
make_cat_choice('Wood', 'wood', 'CUSTOM_SHIFT_O', categories),
|
|
|
|
|
make_cat_choice('Metal', 'metal', 'CUSTOM_SHIFT_M', categories),
|
|
|
|
|
make_cat_choice('Other', 'other', 'CUSTOM_SHIFT_T', categories),
|
|
|
|
|
make_cat_choice('Stone', 'stone', 'CUSTOM_SHIFT_S', cats),
|
|
|
|
|
make_cat_choice('Wood', 'wood', 'CUSTOM_SHIFT_O', cats),
|
|
|
|
|
make_cat_choice('Metal', 'metal', 'CUSTOM_SHIFT_M', cats),
|
|
|
|
|
make_cat_choice('Glass', 'glass', 'CUSTOM_SHIFT_G', cats),
|
|
|
|
|
}
|
|
|
|
|
self.subviews.materials_categories:setChoices(category_choices)
|
|
|
|
|
|
|
|
|
@ -918,7 +903,7 @@ function QualityAndMaterialsPage:refresh()
|
|
|
|
|
local hide_zero = self.subviews.hide_zero:getOptionValue()
|
|
|
|
|
for name,props in pairs(mat_filter) do
|
|
|
|
|
if not hide_zero or tonumber(props.count) > 0 then
|
|
|
|
|
table.insert(mat_choices, make_mat_choice(name, props))
|
|
|
|
|
table.insert(mat_choices, make_mat_choice(name, props, cats))
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
table.sort(mat_choices, self.subviews.mat_sort:getOptionValue())
|
|
|
|
@ -933,20 +918,37 @@ function QualityAndMaterialsPage:get_summary()
|
|
|
|
|
return self.summary
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function QualityAndMaterialsPage:toggle_category(idx, choice)
|
|
|
|
|
choice.enabled = not choice.enabled
|
|
|
|
|
function QualityAndMaterialsPage:toggle_category(_, choice)
|
|
|
|
|
local cats = {}
|
|
|
|
|
if not choice.icon then
|
|
|
|
|
-- toggling from unset to something is set
|
|
|
|
|
table.insert(cats, choice.cat)
|
|
|
|
|
else
|
|
|
|
|
choice.enabled = not choice.enabled
|
|
|
|
|
for _,c in ipairs(self.subviews.materials_categories:getChoices()) do
|
|
|
|
|
if c.enabled then
|
|
|
|
|
table.insert(cats, c.cat)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
setMaterialMaskFilter(uibs.building_type, uibs.building_subtype, uibs.custom_type, self.index-1, cats)
|
|
|
|
|
self.dirty = true
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function QualityAndMaterialsPage:set_heat_safety(heat)
|
|
|
|
|
setHeatSafetyFilter(uibs.building_type, uibs.building_subtype, uibs.custom_type, heat)
|
|
|
|
|
function QualityAndMaterialsPage:toggle_material(_, choice)
|
|
|
|
|
local mats = {}
|
|
|
|
|
if not choice.icon then
|
|
|
|
|
-- toggling from unset to something is set
|
|
|
|
|
table.insert(mats, choice.name)
|
|
|
|
|
else
|
|
|
|
|
choice.enabled = not choice.enabled
|
|
|
|
|
for _,c in ipairs(self.subviews.materials_mats:getChoices()) do
|
|
|
|
|
if c.enabled then
|
|
|
|
|
table.insert(mats, c.name)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
setMaterialFilter(uibs.building_type, uibs.building_subtype, uibs.custom_type, self.index-1, mats)
|
|
|
|
|
self.dirty = true
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|