Added Extra Toggle on Rocket Gui

This commit is contained in:
Cooldude2606
2020-05-28 20:04:50 +01:00
parent 7f16a4439a
commit da19fef000
2 changed files with 12 additions and 8 deletions

View File

@@ -105,7 +105,7 @@ local header = Gui.header(
]] ]]
Gui.header = Gui.header =
Gui.element(function(_,parent,caption,tooltip,add_alignment,name) Gui.element(function(_,parent,caption,tooltip,add_alignment,name,label_name)
-- Draw the header -- Draw the header
local header = local header =
parent.add{ parent.add{
@@ -123,7 +123,7 @@ Gui.element(function(_,parent,caption,tooltip,add_alignment,name)
-- Draw the caption label -- Draw the caption label
if caption then if caption then
header.add{ header.add{
name = 'header_label', name = label_name or 'header_label',
type = 'label', type = 'label',
style = 'heading_1_label', style = 'heading_1_label',
caption = caption, caption = caption,

View File

@@ -440,6 +440,14 @@ Gui.element{
end end
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)
-- Draw a section header and main scroll -- Draw a section header and main scroll
-- @element rocket_list_container -- @element rocket_list_container
local section = local section =
@@ -450,7 +458,8 @@ Gui.element(function(_,parent,section_name,table_size)
{'rocket-info.section-caption-'..section_name}, {'rocket-info.section-caption-'..section_name},
{'rocket-info.section-tooltip-'..section_name}, {'rocket-info.section-tooltip-'..section_name},
true, true,
section_name..'-header' section_name..'-header',
header_toggle.name
) )
-- Right aligned button to toggle the section -- Right aligned button to toggle the section
@@ -535,11 +544,6 @@ end
Event.add(defines.events.on_rocket_launched,function(event) Event.add(defines.events.on_rocket_launched,function(event)
local force = event.rocket_silo.force local force = event.rocket_silo.force
update_rocket_gui_all(force.name) update_rocket_gui_all(force.name)
if force.rockets_launched == 1 then
for _,player in pairs(force.players) do
Gui.update_top_flow(player)
end
end
end) end)
--- Update only the progress gui for a force --- Update only the progress gui for a force