reworked itemselection ui & added vertical divider pens

develop
Taxi Service 2023-04-03 22:23:32 +02:00
parent 7d293c89a2
commit 07a4da6573
3 changed files with 52 additions and 36 deletions

@ -42,6 +42,7 @@ changelog.txt uses a syntax similar to RST, with a few special sequences:
## Misc Improvements
- `buildingplan`: items in the item selection dialog should now use the same item quality symbols as the base game
- `buildingplan`: rearranged elements of ``itemselection`` interface
## Documentation

@ -55,7 +55,7 @@ end
ItemSelection = defclass(ItemSelection, widgets.Window)
ItemSelection.ATTRS{
frame_title='Choose items',
frame={w=56, h=20, l=4, t=8},
frame={w=56, h=24, l=4, t=7},
resizable=true,
index=DEFAULT_NIL,
desc=DEFAULT_NIL,
@ -114,17 +114,8 @@ function ItemSelection:init()
on_click=self:callback('submit'),
visible=function() return self.num_selected >= self.quantity end,
},
widgets.FilteredList{
view_id='flist',
frame={t=3, l=0, r=0, b=4},
case_sensitive=false,
choices=choices,
icon_width=2,
on_submit=self:callback('toggle_group'),
edit_on_char=function(ch) return ch:match('[%l -]') end,
},
widgets.CycleHotkeyLabel{
frame={l=0, b=2},
frame={l=1, t=3},
key='CUSTOM_SHIFT_R',
label='Sort by:',
options={
@ -134,53 +125,71 @@ function ItemSelection:init()
},
on_change=self:callback('on_sort'),
},
widgets.HotkeyLabel{
frame={l=0, b=1},
key='SELECT',
label='Use all/none',
auto_width=true,
on_activate=function() self:toggle_group(self.subviews.flist.list:getSelected()) end,
widgets.FilteredList{
view_id='flist',
frame={t=5, l=1, r=1, b=5},
case_sensitive=false,
choices=choices,
icon_width=2,
on_submit=self:callback('toggle_group'),
edit_on_char=function(ch) return ch:match('[%l -]') end,
},
widgets.HotkeyLabel{
frame={l=22, b=1},
key='CUSTOM_SHIFT_C',
label='Continue',
auto_width=true,
on_activate=self:callback('submit'),
widgets.Label{
frame={l=1, t=5},
text_pen=COLOR_LIGHTCYAN,
text={">"},
},
widgets.HotkeyLabel{
frame={l=38, b=1},
key='LEAVESCREEN',
label='Go back',
auto_width=true,
on_activate=self:callback('on_cancel'),
widgets.Panel{
frame={l=0, t=6, r=0, b=4},
frame_style=gui.INTERIOR_FRAME,
},
widgets.HotkeyLabel{
frame={l=0, b=0},
frame={l=0, b=2},
key='KEYBOARD_CURSOR_RIGHT_FAST',
key_sep=' : ',
key_sep='ight: ',
label='Use one',
auto_width=true,
on_activate=function() self:increment_group(self.subviews.flist.list:getSelected()) end,
},
widgets.Label{
frame={l=6, b=0, w=5},
frame={l=6, b=2, w=5},
text_pen=COLOR_LIGHTGREEN,
text='Right',
},
widgets.HotkeyLabel{
frame={l=23, b=0},
frame={l=1, b=1},
key='KEYBOARD_CURSOR_LEFT_FAST',
key_sep=' : ',
key_sep='eft: ',
label='Use one fewer',
auto_width=true,
on_activate=function() self:decrement_group(self.subviews.flist.list:getSelected()) end,
},
widgets.Label{
frame={l=29, b=0, w=4},
frame={l=7, b=1, w=4},
text_pen=COLOR_LIGHTGREEN,
text='Left',
},
widgets.HotkeyLabel{
frame={l=6, b=0},
key='SELECT',
label='Use all/none',
auto_width=true,
on_activate=function() self:toggle_group(self.subviews.flist.list:getSelected()) end,
},
widgets.HotkeyLabel{
frame={r=5, b=2},
key='LEAVESCREEN',
label='Go back',
auto_width=true,
on_activate=self:callback('on_cancel'),
},
widgets.HotkeyLabel{
frame={r=4, b=0},
key='CUSTOM_SHIFT_C',
label='Continue',
auto_width=true,
on_activate=self:callback('submit'),
},
}
end
@ -234,7 +243,7 @@ function ItemSelection:get_choices(sort_fn)
for desc,choice in pairs(buckets) do
local data = choice.data
choice.text = {
{width=10, text=function() return ('[%d/%d]'):format(data.selected, data.quantity) end},
{width=10, text=function() return ('%d/%d'):format(data.selected, data.quantity) end},
{gap=2, text=desc},
}
table.insert(choices, choice)

@ -2,6 +2,7 @@ local _ENV = mkmodule('plugins.buildingplan.pens')
GOOD_TILE_PEN, BAD_TILE_PEN = nil, nil
VERT_TOP_PEN, VERT_MID_PEN, VERT_BOT_PEN = nil, nil, nil
HORI_LEFT_PEN, HORI_MID_PEN, HORI_RIGHT_PEN = nil, nil, nil
BUTTON_START_PEN, BUTTON_END_PEN = nil, nil
SELECTED_ITEM_PEN = nil
MINIMIZED_LEFT_PEN, MINIMIZED_RIGHT_PEN = nil, nil
@ -22,6 +23,11 @@ function reload_pens()
VERT_MID_PEN = to_pen{tile=tp(tb_texpos, 4), ch=192, fg=COLOR_GREY, bg=COLOR_BLACK}
VERT_BOT_PEN = to_pen{tile=tp(tb_texpos, 11), ch=179, fg=COLOR_GREY, bg=COLOR_BLACK}
local mb_texpos = dfhack.textures.getMediumBordersTexposStart()
HORI_LEFT_PEN = to_pen{tile=tp(mb_texpos, 12), ch=195, fg=COLOR_GREY, bg=COLOR_BLACK}
HORI_MID_PEN = to_pen{tile=tp(mb_texpos, 5), ch=196, fg=COLOR_GREY, bg=COLOR_BLACK}
HORI_RIGHT_PEN = to_pen{tile=tp(mb_texpos, 13), ch=180, fg=COLOR_GREY, bg=COLOR_BLACK}
local cp_texpos = dfhack.textures.getControlPanelTexposStart()
BUTTON_START_PEN = to_pen{tile=tp(cp_texpos, 13), ch='[', fg=COLOR_YELLOW}
BUTTON_END_PEN = to_pen{tile=tp(cp_texpos, 15), ch=']', fg=COLOR_YELLOW}