Skip to content

Commit 593f57d

Browse files
authored
Refactor GUI styles(#1535)
* Update paint brush style * Update autofill style * Update tasklist style * Unify frame styles * Update settings style * Update polls style * Update toolbar tooltip * File formatting
1 parent 847ac47 commit 593f57d

File tree

9 files changed

+1165
-1334
lines changed

9 files changed

+1165
-1334
lines changed

features/gui/autofill.lua

Lines changed: 32 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ local Color = require 'resources.color_presets'
77
local enabled_style = 'working_weapon_button'
88
local disabled_style = 'not_working_weapon_button'
99

10-
local style_map = {[true] = enabled_style, [false] = disabled_style}
11-
local enabled_locale_map = {[true] = {'common.enabled'}, [false] = {'common.disabled'}}
10+
local style_map = { [true] = enabled_style, [false] = disabled_style }
11+
local enabled_locale_map = { [true] = { 'common.enabled' }, [false] = { 'common.disabled' } }
1212

1313
local main_button_name = Gui.uid_name()
1414
local main_frame_name = Gui.uid_name()
@@ -26,15 +26,15 @@ local function player_created(event)
2626
type = 'sprite-button',
2727
name = main_button_name,
2828
sprite = 'item/piercing-rounds-magazine',
29-
tooltip = {'autofill.main_button_tooltip'},
29+
tooltip = { 'autofill.main_button_tooltip' },
3030
auto_toggle = true,
3131
})
3232
end
3333

3434
local function update_ammo_button(button, name, enabled)
3535
local locale_name = Autofill.ammo_locales[name]
3636
local style = style_map[enabled]
37-
local tooltip = {'', locale_name, ' ', enabled_locale_map[enabled]}
37+
local tooltip = { '', locale_name, ' ', enabled_locale_map[enabled] }
3838

3939
button.style = style
4040
button.tooltip = tooltip
@@ -50,37 +50,43 @@ local function toggle_main_frame(event)
5050
local main_button = Gui.get_top_element(player, main_button_name)
5151
main_button.toggled = false
5252
else
53-
frame = Gui.add_left_element(player, { type = 'frame', name = main_frame_name, caption = {'autofill.frame_name'}, direction = 'vertical' })
53+
frame = Gui.add_left_element(player, { type = 'frame', name = main_frame_name, caption = { 'autofill.frame_name' }, direction = 'vertical' })
54+
Gui.set_style(frame, { width = 376 })
5455

55-
local enabled_checkbox =
56-
frame.add {
56+
local inner = frame.add { type = 'frame', style = 'inside_shallow_frame', direction = 'vertical' }
57+
Gui.set_style(inner, { padding = 8 })
58+
59+
local enabled_checkbox = inner.add {
5760
type = 'checkbox',
5861
name = enabled_checkbox_name,
59-
caption = {'autofill.enable'},
60-
state = Autofill.get_enabled(player_index)
62+
caption = { 'autofill.enable' },
63+
state = Autofill.get_enabled(player_index),
6164
}
6265

63-
local ammo_count_flow = frame.add {type = 'flow', direction = 'horizontal'}
64-
local ammo_count_label = ammo_count_flow.add {type = 'label', caption = {'autofill.ammo_count'}}
65-
local ammo_count_textfield =
66-
ammo_count_flow.add {
66+
local ammo_count_flow = inner.add { type = 'flow', direction = 'horizontal' }
67+
local ammo_count_label = ammo_count_flow.add { type = 'label', caption = { 'autofill.ammo_count' } }
68+
Gui.set_style(ammo_count_label, { minimal_width = 140 })
69+
local ammo_count_textfield = ammo_count_flow.add {
6770
type = 'textfield',
6871
name = ammo_count_name,
69-
text = tostring(Autofill.get_ammo_count(player_index))
72+
text = tostring(Autofill.get_ammo_count(player_index)),
73+
numeric = true,
74+
allow_decimal = false,
75+
allow_negative = false,
7076
}
7177

72-
local enabled_ammos_flow = frame.add {type = 'flow', direction = 'horizontal'}
73-
enabled_ammos_flow.add {type = 'label', caption = {'autofill.enabled_ammos'}}
78+
local enabled_ammos_flow = inner.add { type = 'flow', direction = 'horizontal' }
79+
local enabled_ammos_label = enabled_ammos_flow.add { type = 'label', caption = { 'autofill.enabled_ammos' } }
80+
Gui.set_style(enabled_ammos_label, { minimal_width = 140 })
81+
82+
local grid = enabled_ammos_flow.add { type = 'scroll-pane', style = 'deep_slots_scroll_pane' }.add { type = 'table', column_count = 5, style = 'filter_slot_table' }
7483

7584
for name, enabled in pairs(Autofill.get_player_ammos(player_index)) do
76-
local button =
77-
enabled_ammos_flow.add({type = 'flow'}).add(
78-
{
79-
type = 'sprite-button',
80-
name = enabled_ammo_button,
81-
sprite = 'item/' .. name
82-
}
83-
)
85+
local button = grid.add({ type = 'flow' }).add({
86+
type = 'sprite-button',
87+
name = enabled_ammo_button,
88+
sprite = 'item/' .. name,
89+
})
8490
update_ammo_button(button, name, enabled)
8591

8692
Gui.set_data(button, name)
@@ -91,7 +97,7 @@ local function toggle_main_frame(event)
9197
local data = {
9298
enabled_checkbox = enabled_checkbox,
9399
ammo_count_label = ammo_count_label,
94-
ammo_count_textfield = ammo_count_textfield
100+
ammo_count_textfield = ammo_count_textfield,
95101
}
96102

97103
Gui.set_data(frame, data)
@@ -112,7 +118,7 @@ local function set_ammo_count_elements_validation(textfield, label, valid)
112118
else
113119
color = Color.red
114120
label_color = Color.red
115-
tooltip = {'autofill.invalid_ammo_count'}
121+
tooltip = { 'autofill.invalid_ammo_count' }
116122
end
117123

118124
textfield.style.font_color = color

0 commit comments

Comments
 (0)