mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-30 20:41:41 +09:00
Added common header creation
This commit is contained in:
@@ -326,4 +326,32 @@ function Gui.create_scroll_table(element,table_size,maximal_height,name)
|
|||||||
return list_table
|
return list_table
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Creates a header section with a label and button area
|
||||||
|
-- @tparam LuaGuiElement element the element to add this header into
|
||||||
|
-- @tparam localeString caption the caption that is used as the title
|
||||||
|
-- @tparam[opt] localeString tooltip the tooltip that is shown on the caption
|
||||||
|
-- @tparam[opt] boolean right_align when true will include the right align area
|
||||||
|
-- @tparam[opt='header'] string name the name of the header area
|
||||||
|
-- @treturn LuaGuiElement the header that was made, or the align area if that was created
|
||||||
|
function Gui.create_header(element,caption,tooltip,right_align,name)
|
||||||
|
local header =
|
||||||
|
element.add{
|
||||||
|
name=name or 'header',
|
||||||
|
type='frame',
|
||||||
|
style='subheader_frame'
|
||||||
|
}
|
||||||
|
Gui.set_padding(header,2,2,4,4)
|
||||||
|
header.style.horizontally_stretchable = true
|
||||||
|
header.style.use_header_filler = false
|
||||||
|
|
||||||
|
header.add{
|
||||||
|
type='label',
|
||||||
|
style='heading_1_label',
|
||||||
|
caption=caption,
|
||||||
|
tooltip=tooltip
|
||||||
|
}
|
||||||
|
|
||||||
|
return right_align and Gui.create_alignment(header,'header-align') or header
|
||||||
|
end
|
||||||
|
|
||||||
return Gui
|
return Gui
|
||||||
@@ -145,26 +145,16 @@ end)
|
|||||||
--- Used to create the three different sections
|
--- Used to create the three different sections
|
||||||
local function create_section(container,section_name,table_size)
|
local function create_section(container,section_name,table_size)
|
||||||
--- Header for the section
|
--- Header for the section
|
||||||
local header =
|
local header_area = Gui.create_header(
|
||||||
container.add{
|
container,
|
||||||
type='frame',
|
{'rocket-info.section-caption-'..section_name},
|
||||||
name=section_name..'-header',
|
{'rocket-info.section-tooltip-'..section_name},
|
||||||
style='subheader_frame',
|
true,
|
||||||
}
|
section_name..'-header'
|
||||||
Gui.set_padding(header,4,1,4,4)
|
)
|
||||||
header.style.horizontally_stretchable = true
|
|
||||||
|
|
||||||
--- Caption for the header bar
|
|
||||||
header.add{
|
|
||||||
type='label',
|
|
||||||
style='heading_1_label',
|
|
||||||
caption={'rocket-info.section-caption-'..section_name},
|
|
||||||
tooltip={'rocket-info.section-tooltip-'..section_name}
|
|
||||||
}
|
|
||||||
|
|
||||||
--- Right aligned button to toggle the section
|
--- Right aligned button to toggle the section
|
||||||
local expand_flow = Gui.create_alignment(header,section_name)
|
toggle_section(header_area)
|
||||||
toggle_section(expand_flow)
|
|
||||||
|
|
||||||
--- Table used to store the data
|
--- Table used to store the data
|
||||||
local flow_table = Gui.create_scroll_table(container,table_size,215,section_name)
|
local flow_table = Gui.create_scroll_table(container,table_size,215,section_name)
|
||||||
|
|||||||
@@ -75,16 +75,11 @@ local function generate_container(player,element)
|
|||||||
Gui.set_padding(container)
|
Gui.set_padding(container)
|
||||||
|
|
||||||
-- main header for the gui
|
-- main header for the gui
|
||||||
local header =
|
Gui.create_header(
|
||||||
container.add{
|
container,
|
||||||
name='header',
|
{'science-info.main-caption'},
|
||||||
type='frame',
|
{'science-info.main-tooltip'}
|
||||||
caption={'science-info.main-caption'},
|
)
|
||||||
style='subheader_frame'
|
|
||||||
}
|
|
||||||
Gui.set_padding(header,2,2,4,4)
|
|
||||||
header.style.horizontally_stretchable = true
|
|
||||||
header.style.use_header_filler = false
|
|
||||||
|
|
||||||
-- table that stores all the data
|
-- table that stores all the data
|
||||||
local flow_table = Gui.create_scroll_table(container,4,185)
|
local flow_table = Gui.create_scroll_table(container,4,185)
|
||||||
|
|||||||
@@ -310,28 +310,16 @@ local function generate_container(player,element)
|
|||||||
container.style.vertically_stretchable = false
|
container.style.vertically_stretchable = false
|
||||||
|
|
||||||
-- main header for the gui
|
-- main header for the gui
|
||||||
local header =
|
local header_area = Gui.create_header(
|
||||||
container.add{
|
container,
|
||||||
name='header',
|
{'task-list.main-caption'},
|
||||||
type='frame',
|
{'task-list.sub-tooltip'},
|
||||||
style='subheader_frame'
|
true
|
||||||
}
|
)
|
||||||
Gui.set_padding(header,2,2,4,4)
|
|
||||||
header.style.horizontally_stretchable = true
|
|
||||||
header.style.use_header_filler = false
|
|
||||||
|
|
||||||
--- Caption for the header bar
|
|
||||||
header.add{
|
|
||||||
type='label',
|
|
||||||
style='heading_1_label',
|
|
||||||
caption={'task-list.main-caption'},
|
|
||||||
tooltip={'task-list.sub-tooltip'}
|
|
||||||
}
|
|
||||||
|
|
||||||
--- Right aligned button to toggle the section
|
--- Right aligned button to toggle the section
|
||||||
if player_allowed_edit(player) then
|
if player_allowed_edit(player) then
|
||||||
local right_align = Gui.create_alignment(header)
|
add_new_task(header_area)
|
||||||
add_new_task(right_align)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- table that stores all the data
|
-- table that stores all the data
|
||||||
|
|||||||
@@ -577,28 +577,16 @@ local function generate_container(player,element)
|
|||||||
container.style.vertically_stretchable = false
|
container.style.vertically_stretchable = false
|
||||||
|
|
||||||
-- main header for the gui
|
-- main header for the gui
|
||||||
local header =
|
local header_area = Gui.create_header(
|
||||||
container.add{
|
container,
|
||||||
name='header',
|
{'warp-list.main-caption'},
|
||||||
type='frame',
|
{'warp-list.sub-tooltip',config.recharge_time,config.activation_range},
|
||||||
style='subheader_frame'
|
true
|
||||||
}
|
)
|
||||||
Gui.set_padding(header,2,2,4,4)
|
|
||||||
header.style.horizontally_stretchable = true
|
|
||||||
header.style.use_header_filler = false
|
|
||||||
|
|
||||||
--- Caption for the header bar
|
|
||||||
header.add{
|
|
||||||
type='label',
|
|
||||||
style='heading_1_label',
|
|
||||||
caption={'warp-list.main-caption'},
|
|
||||||
tooltip={'warp-list.sub-tooltip',config.recharge_time,config.activation_range}
|
|
||||||
}
|
|
||||||
|
|
||||||
--- Right aligned button to toggle the section
|
--- Right aligned button to toggle the section
|
||||||
if player_allowed_edit(player) then
|
if player_allowed_edit(player) then
|
||||||
local right_align = Gui.create_alignment(header)
|
add_new_warp(header_area)
|
||||||
add_new_warp(right_align)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- table that stores all the data
|
-- table that stores all the data
|
||||||
|
|||||||
Reference in New Issue
Block a user