Added create data table to gui

This commit is contained in:
Cooldude2606
2019-06-14 20:18:09 +01:00
parent 38b0cffc4e
commit fd6aced4d5
6 changed files with 48 additions and 119 deletions

View File

@@ -293,4 +293,37 @@ function Gui.destory_if_valid(element)
end
end
--- Creates a scroll area with a table inside, table can be any size
-- @tparam LuaGuiElement element the element to add this scroll into
-- @tparam number table_size the number of columns in the table
-- @tparam number maximal_height the max hieght of the scroll
-- @tparam[opt='scroll'] string name the name of the scoll element
-- @treturn LuaGuiElement the table that was made
function Gui.create_scroll_table(element,table_size,maximal_height,name)
local list_scroll =
element.add{
name=name or 'scroll',
type='scroll-pane',
direction='vertical',
horizontal_scroll_policy='never',
vertical_scroll_policy='auto-and-reserve-space'
}
Gui.set_padding(list_scroll,1,1,2,2)
list_scroll.style.horizontally_stretchable = true
list_scroll.style.maximal_height = maximal_height
local list_table =
list_scroll.add{
name='table',
type='table',
column_count=table_size
}
Gui.set_padding(list_table)
list_table.style.horizontally_stretchable = true
list_table.style.vertical_align = 'center'
list_table.style.cell_padding = 0
return list_table
end
return Gui

View File

@@ -111,30 +111,8 @@ local function generate_container(player,element)
}
Gui.set_padding(container)
-- a scroll bar which allows 8 players to be seen at once
local list_scroll =
container.add{
name='scroll',
type='scroll-pane',
direction='vertical',
horizontal_scroll_policy='never',
vertical_scroll_policy='auto-and-reserve-space'
}
Gui.set_padding(list_scroll,1,1,2,2)
list_scroll.style.horizontally_stretchable = true
list_scroll.style.maximal_height = 188
-- 3 wide table to contain: action button, player name, and play time
local list_table =
list_scroll.add{
name='table',
type='table',
column_count=3
}
Gui.set_padding(list_table)
list_table.style.horizontally_stretchable = true
list_table.style.vertical_align = 'center'
list_table.style.cell_padding = 0
local list_table = Gui.create_scroll_table(container,3,188)
-- action bar which contains the different action buttons
local action_bar =

View File

@@ -166,31 +166,10 @@ local function create_section(container,section_name,table_size)
local expand_flow = Gui.create_alignment(header,section_name)
toggle_section(expand_flow)
--- The area which contains the section content
local flow =
container.add{
name=section_name,
type='scroll-pane',
direction='vertical',
horizontal_scroll_policy='never',
vertical_scroll_policy='auto-and-reserve-space'
}
Gui.set_padding(flow,1,1,2,2)
flow.style.horizontally_stretchable = true
flow.style.maximal_height = 215
flow.visible = false
--- Table used to store the data
local flow_table =
flow.add{
name='table',
type='table',
column_count=table_size
}
Gui.set_padding(flow_table)
flow_table.style.horizontally_stretchable = true
flow_table.style.vertical_align = 'center'
flow_table.style.cell_padding = 0
local flow_table = Gui.create_scroll_table(container,table_size,215,section_name)
flow_table.parent.visible = false
end
--[[ Creates the main structure for the gui

View File

@@ -86,22 +86,12 @@ local function generate_container(player,element)
header.style.horizontally_stretchable = true
header.style.use_header_filler = false
-- main flow for the data
local flow =
container.add{
name='scroll',
type='scroll-pane',
direction='vertical',
horizontal_scroll_policy='never',
vertical_scroll_policy='auto-and-reserve-space'
}
Gui.set_padding(flow,1,1,2,2)
flow.style.horizontally_stretchable = true
flow.style.maximal_height = 185
-- table that stores all the data
local flow_table = Gui.create_scroll_table(container,4,185)
-- message to say that you have not made any packs yet
local non_made =
flow.add{
flow_table.parent.add{
name='non_made',
type='label',
caption={'science-info.no-packs'}
@@ -109,17 +99,6 @@ local function generate_container(player,element)
non_made.style.width = 200
non_made.style.single_line = false
-- table that stores all the data
local flow_table =
flow.add{
name='table',
type='table',
column_count=4
}
Gui.set_padding(flow_table)
flow_table.style.horizontally_stretchable = true
flow_table.style.vertical_align = 'center'
local eta
if config.show_eta then
-- footer used to store the eta

View File

@@ -334,22 +334,16 @@ local function generate_container(player,element)
add_new_task(right_align)
end
-- main flow for the data
local flow =
container.add{
name='scroll',
type='scroll-pane',
direction='vertical',
horizontal_scroll_policy='never',
vertical_scroll_policy='auto-and-reserve-space'
}
Gui.set_padding(flow,1,1,2,2)
flow.style.horizontally_stretchable = true
flow.style.maximal_height = 185
-- table that stores all the data
local flow_table = Gui.create_scroll_table(container,3,185)
flow_table.draw_horizontal_lines = true
flow_table.vertical_centering = false
flow_table.style.top_cell_padding = 3
flow_table.style.bottom_cell_padding = 3
-- message to say that you have no tasks
local non_made =
flow.add{
flow_table.parent.add{
name='no_tasks',
type='label',
caption={'task-list.no-tasks'}
@@ -357,20 +351,6 @@ local function generate_container(player,element)
non_made.style.width = 200
non_made.style.single_line = false
-- table that stores all the data
local flow_table =
flow.add{
name='table',
type='table',
column_count=3,
draw_horizontal_lines=true,
vertical_centering=false
}
Gui.set_padding(flow_table)
flow_table.style.horizontally_stretchable = true
flow_table.style.top_cell_padding = 3
flow_table.style.bottom_cell_padding = 3
return flow_table
end

View File

@@ -601,28 +601,8 @@ local function generate_container(player,element)
add_new_warp(right_align)
end
-- main flow for the data
local flow =
container.add{
name='scroll',
type='scroll-pane',
direction='vertical',
horizontal_scroll_policy='never',
vertical_scroll_policy='auto-and-reserve-space'
}
Gui.set_padding(flow,1,1,2,2)
flow.style.horizontally_stretchable = true
flow.style.maximal_height = 258
-- table that stores all the data
local flow_table =
flow.add{
name='table',
type='table',
column_count=3
}
Gui.set_padding(flow_table)
flow_table.style.horizontally_stretchable = true
local flow_table = Gui.create_scroll_table(container,3,258)
flow_table.style.top_cell_padding = 3
flow_table.style.bottom_cell_padding = 3