mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-29 12:16:37 +09:00
Cleaned up gui
This commit is contained in:
@@ -258,7 +258,7 @@ local function add_player(list_table,player,role_name)
|
||||
player_name.style.font_color = player.chat_color
|
||||
|
||||
-- flow which allows right align for the play time
|
||||
local time_flow = Gui.create_right_align(list_table,'player-time-'..player.index)
|
||||
local time_flow = Gui.create_alignment(list_table,'player-time-'..player.index)
|
||||
|
||||
-- time given in Xh Ym and is right aligned
|
||||
local tick = game.tick > 0 and game.tick or 1
|
||||
@@ -295,7 +295,7 @@ Gui.new_left_frame('gui/player-list')
|
||||
:set_tooltip{'player-list.main-tooltip'}
|
||||
:set_open_by_default()
|
||||
:set_direction('vertical')
|
||||
:on_draw(function(player,element)
|
||||
:on_creation(function(player,element)
|
||||
local list_table,action_bar = generate_container(player,element)
|
||||
generate_action_bar(player,action_bar)
|
||||
|
||||
|
||||
@@ -163,7 +163,7 @@ local function create_section(container,section_name,table_size)
|
||||
}
|
||||
|
||||
--- Right aligned button to toggle the section
|
||||
local expand_flow = Gui.create_right_align(header,section_name)
|
||||
local expand_flow = Gui.create_alignment(header,section_name)
|
||||
toggle_section(expand_flow)
|
||||
|
||||
--- The area which contains the section content
|
||||
@@ -272,7 +272,7 @@ local function create_label_value_pair(element,data_name,value,tooltip,extra)
|
||||
tooltip={'rocket-info.data-tooltip-'..data_name,extra}
|
||||
}
|
||||
--- Right aligned label to store the data
|
||||
local right_flow = Gui.create_right_align(element,data_name_extra)
|
||||
local right_flow = Gui.create_alignment(element,data_name_extra)
|
||||
right_flow.add{
|
||||
type='label',
|
||||
name='label',
|
||||
@@ -470,7 +470,7 @@ local function generate_progress(player,frame)
|
||||
}
|
||||
|
||||
--- Creates the progress value which is right aligned
|
||||
local right_flow = Gui.create_right_align(element,silo_name)
|
||||
local right_flow = Gui.create_alignment(element,silo_name)
|
||||
right_flow.add{
|
||||
type='label',
|
||||
name='label',
|
||||
@@ -517,7 +517,7 @@ end)
|
||||
return player.force.rockets_launched > 0
|
||||
end)
|
||||
:set_direction('vertical')
|
||||
:on_draw(function(player,element)
|
||||
:on_creation(function(player,element)
|
||||
generate_container(player,element)
|
||||
generate_stats(player,element)
|
||||
generate_milestones(player,element)
|
||||
|
||||
@@ -142,7 +142,7 @@ local function generate_container(player,element)
|
||||
}
|
||||
|
||||
-- data for the footer
|
||||
local right_align = Gui.create_right_align(footer,'eta')
|
||||
local right_align = Gui.create_alignment(footer,'eta')
|
||||
eta =
|
||||
right_align.add{
|
||||
name='label',
|
||||
@@ -191,7 +191,7 @@ local function add_data_label(element,name,value,secondary,tooltip)
|
||||
|
||||
else
|
||||
-- right aligned number
|
||||
local right_align = Gui.create_right_align(element,name)
|
||||
local right_align = Gui.create_alignment(element,name)
|
||||
local data =
|
||||
right_align.add{
|
||||
name='label',
|
||||
@@ -341,7 +341,7 @@ Gui.new_left_frame('gui/science-info')
|
||||
:set_sprites('entity/lab')
|
||||
:set_direction('vertical')
|
||||
:set_tooltip{'science-info.main-tooltip'}
|
||||
:on_draw(function(player,element)
|
||||
:on_creation(function(player,element)
|
||||
local table, eta = generate_container(player,element)
|
||||
|
||||
for _,science_pack in ipairs(config) do
|
||||
|
||||
@@ -211,7 +211,7 @@ function generate_task(player,element,task_id)
|
||||
Gui.set_padding(task_area)
|
||||
|
||||
-- if the player can edit then it adds the edit and delete button
|
||||
local flow = Gui.create_right_align(element,'edit-'..task_id)
|
||||
local flow = Gui.create_alignment(element,'edit-'..task_id)
|
||||
local sub_flow = flow.add{type='flow',name=task_id}
|
||||
|
||||
edit_task(sub_flow)
|
||||
@@ -330,7 +330,7 @@ local function generate_container(player,element)
|
||||
|
||||
--- Right aligned button to toggle the section
|
||||
if player_allowed_edit(player) then
|
||||
local right_align = Gui.create_right_align(header)
|
||||
local right_align = Gui.create_alignment(header)
|
||||
add_new_task(right_align)
|
||||
end
|
||||
|
||||
@@ -381,7 +381,7 @@ Gui.new_left_frame('gui/task-list')
|
||||
:set_direction('vertical')
|
||||
:set_tooltip{'task-list.main-tooltip'}
|
||||
:set_open_by_default()
|
||||
:on_draw(function(player,element)
|
||||
:on_creation(function(player,element)
|
||||
local data_table = generate_container(player,element)
|
||||
local force_name = player.force.name
|
||||
|
||||
|
||||
@@ -254,7 +254,7 @@ local warp_timer =
|
||||
Gui.new_progressbar()
|
||||
:set_tooltip{'warp-list.timer-tooltip',config.recharge_time}
|
||||
:set_default_maximum(math.floor(config.recharge_time*config.update_smothing))
|
||||
:add_store(Gui.player_store)
|
||||
:add_store(Gui.categorize_by_player)
|
||||
:set_style(nil,function(style)
|
||||
style.horizontally_stretchable = true
|
||||
style.color = Colors.light_blue
|
||||
@@ -449,7 +449,7 @@ function generate_warp(player,element,warp_id)
|
||||
Gui.set_padding(warp_area)
|
||||
|
||||
-- if the player can edit then it adds the edit and delete button
|
||||
local flow = Gui.create_right_align(element,'edit-'..warp_id)
|
||||
local flow = Gui.create_alignment(element,'edit-'..warp_id)
|
||||
local sub_flow = flow.add{type='flow',name=warp_id}
|
||||
|
||||
edit_warp(sub_flow)
|
||||
@@ -597,7 +597,7 @@ local function generate_container(player,element)
|
||||
|
||||
--- Right aligned button to toggle the section
|
||||
if player_allowed_edit(player) then
|
||||
local right_align = Gui.create_right_align(header)
|
||||
local right_align = Gui.create_alignment(header)
|
||||
add_new_warp(right_align)
|
||||
end
|
||||
|
||||
@@ -637,7 +637,7 @@ Gui.new_left_frame('gui/warp-list')
|
||||
:set_sprites('item/'..config.default_icon)
|
||||
:set_tooltip{'warp-list.main-tooltip',config.activation_range}
|
||||
:set_direction('vertical')
|
||||
:on_draw(function(player,element)
|
||||
:on_creation(function(player,element)
|
||||
local data_table = generate_container(player,element)
|
||||
local force_name = player.force.name
|
||||
|
||||
@@ -655,7 +655,6 @@ end)
|
||||
local warps = force_warps[force_name] or {}
|
||||
for _,warp_id in pairs(warps) do
|
||||
generate_warp(player,data_table,warp_id)
|
||||
make_warp_tag(warp_id)
|
||||
end
|
||||
end)
|
||||
:on_player_toggle(function(player,element,visible)
|
||||
@@ -790,4 +789,24 @@ Event.add(defines.events.on_player_created,function(event)
|
||||
end
|
||||
end)
|
||||
|
||||
local function maintain_tag(event)
|
||||
local tag = event.tag
|
||||
local force = event.force
|
||||
local warps = force_warps[force.name]
|
||||
if warps then
|
||||
for _,warp_id in pairs(warps) do
|
||||
local warp = warp_details[warp_id]
|
||||
if not warp.tag or not warp.tag.valid or warp.tag == tag then
|
||||
if event.name == defines.events.on_chart_tag_removed then
|
||||
warp.tag = nil
|
||||
end
|
||||
make_warp_tag(warp_id)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Event.add(defines.events.on_chart_tag_modified,maintain_tag)
|
||||
Event.add(defines.events.on_chart_tag_removed,maintain_tag)
|
||||
|
||||
return warp_list
|
||||
Reference in New Issue
Block a user