Migrate gui modules

This commit is contained in:
Cooldude2606
2023-10-01 23:44:38 +01:00
parent 51480e4ca5
commit edbfcd3afd
13 changed files with 153 additions and 123 deletions

View File

@@ -32,7 +32,8 @@ Gui.element{
type = 'sprite-button',
sprite = 'utility/expand_dark',
hovered_sprite = 'utility/expand',
tooltip = {'autofill.toggle-section-tooltip'}
tooltip = {'autofill.toggle-section-tooltip'},
name = Gui.unique_static_name
}
:style(Gui.sprite_style(20))
:on_click(function(_, element, _)
@@ -50,14 +51,6 @@ Gui.element{
end
end)
--- Used to assign an event to the header label to trigger a toggle
-- @element header_toggle
local header_toggle = Gui.element()
:on_click(function(_, element, event)
event.element = element.parent.alignment[toggle_section.name]
toggle_section:raise_custom_event(event)
end)
--- Toggle enitity button, used for toggling autofill for the specific entity
-- All entity autofill settings will be ignored if its disabled
-- @element entity_toggle
@@ -95,16 +88,18 @@ end)
--- Draw a section header and main scroll
-- @element autofill_section_container
local section =
Gui.element(function(_, parent, section_name, table_size)
Gui.element(function(definition, parent, section_name, table_size)
-- Draw the header for the section
local header = Gui.header(
parent,
{'autofill.toggle-section-caption', rich_img('item', section_name), {'entity-name.'..section_name}},
{'autofill.toggle-section-tooltip'},
true,
section_name..'-header',
header_toggle.name
section_name..'-header'
)
definition:triggers_events(header.parent.header_label)
-- Right aligned button to toggle the section
header.caption = section_name
entity_toggle(header, section_name)
@@ -120,13 +115,16 @@ Gui.element(function(_, parent, section_name, table_size)
return section_table
end)
:on_click(function(_, element, event)
event.element = element.parent.alignment[toggle_section.name]
toggle_section:raise_custom_event(event)
end)
--- Toggle item button, used for toggling autofill for the specific item
-- @element toggle_item_button
local toggle_item_button =
Gui.element(function(event_trigger, parent, item)
Gui.element(function(_, parent, item)
return parent.add{
name = event_trigger,
type = 'sprite-button',
sprite = 'item/'..item.name,
tooltip = {'autofill.toggle-tooltip', rich_img('item', item.name), item.category},
@@ -161,9 +159,8 @@ end)
--- Amount text field for a autofill item
-- @element amount_textfield
local amount_textfield =
Gui.element(function(event_trigger, parent, item)
Gui.element(function(_, parent, item)
return parent.add{
name = event_trigger,
type = 'textfield',
text = item.amount,
tooltip = {'autofill.amount-tooltip', item.category },
@@ -233,9 +230,9 @@ end)
--- Main gui container for the left flow
-- @element autofill_container
autofill_container =
Gui.element(function(event_trigger, parent)
Gui.element(function(definition, parent)
-- Draw the internal container
local container = Gui.container(parent, event_trigger)
local container = Gui.container(parent, definition.name)
-- Draw the scroll container
local scroll_table = Gui.scroll_table(container, 400, 1, 'autofill-scroll-table')
-- Set the scroll panel to always show the scrollbar (not doing this will result in a changing gui size)
@@ -293,6 +290,7 @@ Gui.element(function(event_trigger, parent)
-- Return the external container
return container.parent
end)
:static_name(Gui.unique_static_name)
:add_to_left_flow()
--- Button on the top flow used to toggle autofill container