mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-29 04:06:39 +09:00
Drying Code
This commit is contained in:
@@ -56,15 +56,10 @@ local close_action_bar =
|
||||
Gui.element{
|
||||
type = 'sprite-button',
|
||||
sprite = 'utility/close_black',
|
||||
hovered_sprite = 'utility/close_white',
|
||||
tooltip = {'player-list.close-action-bar'},
|
||||
style = 'tool_button'
|
||||
}
|
||||
:style{
|
||||
padding = -1,
|
||||
width = 28,
|
||||
height = 28
|
||||
style = 'shortcut_bar_button_red'
|
||||
}
|
||||
:style(Gui.sprite_style(30,-1,{ top_margin = -1, right_margin = -1 }))
|
||||
:on_click(function(player,element)
|
||||
Store.clear(selected_player_store,player)
|
||||
Store.clear(selected_action_store,player)
|
||||
@@ -77,13 +72,9 @@ Gui.element{
|
||||
type = 'sprite-button',
|
||||
sprite = 'utility/confirm_slot',
|
||||
tooltip = {'player-list.reason-confirm'},
|
||||
style = 'tool_button'
|
||||
}
|
||||
:style{
|
||||
padding = -1,
|
||||
width = 28,
|
||||
height = 28
|
||||
style = 'shortcut_bar_button_green'
|
||||
}
|
||||
:style(Gui.sprite_style(30,-1,{ left_margin = -2, right_margin = -1 }))
|
||||
:on_click(function(player,element)
|
||||
local reason = element.parent.entry.text or 'Non Given'
|
||||
local action_name = Store.get(selected_action_store,player)
|
||||
@@ -167,17 +158,12 @@ Gui.element(function(_,parent)
|
||||
-- Loop over all the buttons in the config
|
||||
for action_name,button_data in pairs(config.buttons) do
|
||||
-- Added the permission flow
|
||||
local permission_flow =
|
||||
parent.add{
|
||||
type = 'flow',
|
||||
name = action_name
|
||||
}
|
||||
local permission_flow = parent.add{ type = 'flow', name = action_name }
|
||||
permission_flow.visible = false
|
||||
-- Add the buttons under that permission
|
||||
for _,button in ipairs(button_data) do
|
||||
button(permission_flow)
|
||||
end
|
||||
-- Hide the flow by default, will be made visble when a player is selected
|
||||
permission_flow.visible = false
|
||||
end
|
||||
|
||||
return parent
|
||||
@@ -189,6 +175,7 @@ local function update_action_bar_buttons(element)
|
||||
local selected_player_name = Store.get(selected_player_store,player)
|
||||
|
||||
if not selected_player_name then
|
||||
-- Hide the action bar when no player is selected
|
||||
element.visible = false
|
||||
|
||||
else
|
||||
@@ -218,30 +205,8 @@ end
|
||||
-- @element player_list_container
|
||||
local player_list_container =
|
||||
Gui.element(function(event_trigger,parent)
|
||||
-- Draw the external container
|
||||
local frame =
|
||||
parent.add{
|
||||
name = event_trigger,
|
||||
type = 'frame'
|
||||
}
|
||||
|
||||
-- Set the frame style
|
||||
local frame_style = frame.style
|
||||
frame_style.padding = 2
|
||||
frame_style.minimal_width = 200
|
||||
|
||||
-- Draw the internal container
|
||||
local container =
|
||||
frame.add{
|
||||
name = 'container',
|
||||
type = 'frame',
|
||||
direction = 'vertical',
|
||||
style = 'window_content_frame_packed'
|
||||
}
|
||||
|
||||
-- Set the container style
|
||||
local style = container.style
|
||||
style.vertically_stretchable = false
|
||||
local container = Gui.container(parent,event_trigger,200)
|
||||
|
||||
-- Draw the scroll table for the players
|
||||
local scroll_table = Gui.scroll_table(container,184,3)
|
||||
@@ -251,38 +216,24 @@ Gui.element(function(event_trigger,parent)
|
||||
scroll_table_style.padding = {1,0,1,2}
|
||||
|
||||
-- Add the action bar
|
||||
local action_bar =
|
||||
container.add{
|
||||
name = 'action_bar',
|
||||
type = 'frame',
|
||||
style = 'subfooter_frame'
|
||||
}
|
||||
local action_bar = Gui.footer(container,nil,nil,false,'action_bar')
|
||||
|
||||
-- Change the style of the action bar
|
||||
local action_bar_style = action_bar.style
|
||||
action_bar_style.height = 35
|
||||
action_bar_style.padding = {1,3}
|
||||
action_bar_style.use_header_filler = false
|
||||
action_bar_style.horizontally_stretchable = true
|
||||
action_bar.visible = false
|
||||
|
||||
-- Add the buttons to the action bar
|
||||
add_action_bar_buttons(action_bar)
|
||||
|
||||
-- Add the reason bar
|
||||
local reason_bar =
|
||||
container.add{
|
||||
name = 'reason_bar',
|
||||
type = 'frame',
|
||||
style = 'subfooter_frame'
|
||||
}
|
||||
local reason_bar = Gui.footer(container,nil,nil,false,'reason_bar')
|
||||
|
||||
-- Change the style of the reason bar
|
||||
local reason_bar_style = reason_bar.style
|
||||
reason_bar_style.height = 35
|
||||
reason_bar_style.padding = {-1,3}
|
||||
reason_bar_style.use_header_filler = false
|
||||
reason_bar_style.horizontally_stretchable = true
|
||||
reason_bar.visible = false
|
||||
|
||||
-- Add the text entry for the reason bar
|
||||
@@ -304,27 +255,24 @@ Gui.element(function(event_trigger,parent)
|
||||
reason_confirm(reason_bar)
|
||||
|
||||
-- Return the exteral container
|
||||
return frame
|
||||
return container.parent
|
||||
end)
|
||||
:add_to_left_flow(true)
|
||||
|
||||
--- Button on the top flow used to toggle the player list container
|
||||
-- @element task_list_toggle
|
||||
Gui.element{
|
||||
type = 'sprite-button',
|
||||
sprite = 'entity/character',
|
||||
tooltip = {'player-list.main-tooltip'},
|
||||
style = Gui.top_flow_button_style
|
||||
}
|
||||
:style{
|
||||
padding = -2
|
||||
}
|
||||
:add_to_top_flow(function(player)
|
||||
-- @element toggle_left_element
|
||||
Gui.left_toolbar_button('entity/character', {'player-list.main-tooltip'}, player_list_container, function(player)
|
||||
return Roles.player_allowed(player,'gui/player-list')
|
||||
end)
|
||||
:on_click(function(player,_,_)
|
||||
Gui.toggle_left_element(player, player_list_container)
|
||||
end)
|
||||
|
||||
-- Get caption and tooltip format for a player
|
||||
local function get_time_formats(online_time,afk_time)
|
||||
local tick = game.tick > 0 and game.tick or 1
|
||||
local percent = math.round(online_time/tick,3)*100
|
||||
local caption = format_time(online_time)
|
||||
local tooltip = {'player-list.afk-time', percent, format_time(afk_time,{minutes=true,long=true})}
|
||||
return caption, tooltip
|
||||
end
|
||||
|
||||
-- Get the player time to be used to update time label
|
||||
local function get_player_times()
|
||||
@@ -332,18 +280,19 @@ local function get_player_times()
|
||||
local player_times = {}
|
||||
for _, player in pairs(game.connected_players) do
|
||||
ctn = ctn + 1
|
||||
local tick = game.tick > 0 and game.tick or 1
|
||||
local percent = math.round(player.online_time/tick,3)*100
|
||||
-- Add the player time details to the array
|
||||
local caption, tooltip = get_time_formats(player.online_time, player.afk_time)
|
||||
player_times[ctn] = {
|
||||
element_name = 'player-time-'..player.index,
|
||||
caption = format_time(player.online_time),
|
||||
tooltip = {'player-list.afk-time',percent,format_time(player.afk_time,{minutes=true,long=true})}
|
||||
caption = caption,
|
||||
tooltip = tooltip
|
||||
}
|
||||
end
|
||||
|
||||
return player_times
|
||||
end
|
||||
|
||||
-- Get a sorted list of all online players
|
||||
local function get_player_list_order()
|
||||
-- Sort all the online players into roles
|
||||
local players = {}
|
||||
@@ -358,20 +307,20 @@ local function get_player_list_order()
|
||||
-- Sort the players from roles into a set order
|
||||
local ctn = 0
|
||||
local player_list_order = {}
|
||||
local tick = game.tick > 0 and game.tick or 1
|
||||
for _,role_name in pairs(Roles.config.order) do
|
||||
if players[role_name] then
|
||||
for _,player in pairs(players[role_name]) do
|
||||
ctn = ctn + 1
|
||||
local percent = math.round(player.online_time/tick,3)*100
|
||||
-- Add the player data to the array
|
||||
local caption, tooltip = get_time_formats(player.online_time, player.afk_time)
|
||||
player_list_order[ctn] = {
|
||||
name = player.name,
|
||||
index = player.index,
|
||||
tag = player.tag,
|
||||
role_name = role_name,
|
||||
chat_color = player.chat_color,
|
||||
caption = format_time(player.online_time),
|
||||
tooltip = {'player-list.afk-time',percent,format_time(player.afk_time,{minutes=true,long=true})}
|
||||
caption = caption,
|
||||
tooltip = tooltip
|
||||
}
|
||||
end
|
||||
end
|
||||
@@ -381,15 +330,15 @@ local function get_player_list_order()
|
||||
for i = 1, 10 do
|
||||
local online_time = math.random(1,tick)
|
||||
local afk_time = math.random(online_time-(tick/10),tick)
|
||||
local percent = math.round(online_time/tick,3)*100
|
||||
local caption, tooltip = get_time_formats(online_time, afk_time)
|
||||
player_list_order[ctn+i] = {
|
||||
name='Player '..i,
|
||||
index=0-i,
|
||||
tag='',
|
||||
role_name = 'Fake Player',
|
||||
chat_color=table.get_random_dictionary_entry(Colors),
|
||||
caption = format_time(online_time),
|
||||
tooltip = {'player-list.afk-time',percent,format_time(afk_time,{minutes=true,long=true})},
|
||||
chat_color = table.get_random_dictionary_entry(Colors),
|
||||
caption = caption,
|
||||
tooltip = tooltip
|
||||
}
|
||||
end]]
|
||||
|
||||
@@ -400,8 +349,7 @@ end
|
||||
Event.on_nth_tick(1800,function()
|
||||
local player_times = get_player_times()
|
||||
for _,player in pairs(game.connected_players) do
|
||||
local left_flow = Gui.get_left_flow(player)
|
||||
local frame = left_flow[player_list_container.name]
|
||||
local frame = Gui.get_left_element(player,player_list_container)
|
||||
local scroll_table = frame.container.scroll.table
|
||||
for _,player_time in pairs(player_times) do
|
||||
update_player_base(scroll_table,player_time)
|
||||
@@ -413,8 +361,7 @@ end)
|
||||
Event.add(defines.events.on_player_left_game,function(event)
|
||||
local remove_player = event.player
|
||||
for _,player in pairs(game.connected_players) do
|
||||
local left_flow = Gui.get_left_flow(player)
|
||||
local frame = left_flow[player_list_container.name]
|
||||
local frame = Gui.get_left_element(player,player_list_container)
|
||||
local scroll_table = frame.container.scroll.table
|
||||
remove_player_base(scroll_table,remove_player)
|
||||
end
|
||||
@@ -424,8 +371,7 @@ end)
|
||||
local function redraw_player_list()
|
||||
local player_list_order = get_player_list_order()
|
||||
for _,player in pairs(game.connected_players) do
|
||||
local left_flow = Gui.get_left_flow(player)
|
||||
local frame = left_flow[player_list_container.name]
|
||||
local frame = Gui.get_left_element(player,player_list_container)
|
||||
local scroll_table = frame.container.scroll.table
|
||||
scroll_table.clear()
|
||||
for _,next_player_data in ipairs(player_list_order) do
|
||||
@@ -441,8 +387,7 @@ Event.add(Roles.events.on_role_unassigned,redraw_player_list)
|
||||
--- When the action player is changed the action bar will update
|
||||
Store.watch(selected_player_store,function(value,player_name)
|
||||
local player = Game.get_player_from_any(player_name)
|
||||
local left_flow = Gui.get_left_flow(player)
|
||||
local frame = left_flow[player_list_container.name]
|
||||
local frame = Gui.get_left_element(player,player_list_container)
|
||||
local scroll_table = frame.container.scroll.table
|
||||
update_action_bar_buttons(frame.container.action_bar)
|
||||
for _,next_player in pairs(game.connected_players) do
|
||||
@@ -462,8 +407,7 @@ end)
|
||||
--- When the action name is changed the reason input will update
|
||||
Store.watch(selected_action_store,function(value,player_name)
|
||||
local player = Game.get_player_from_any(player_name)
|
||||
local left_flow = Gui.get_left_flow(player)
|
||||
local frame = left_flow[player_list_container.name]
|
||||
local frame = Gui.get_left_element(player,player_list_container)
|
||||
local element = frame.container.reason_bar
|
||||
if value then
|
||||
-- if there is a new value then check the player is still online
|
||||
|
||||
@@ -29,7 +29,8 @@ local function check_player_permissions(player,action)
|
||||
return false
|
||||
end
|
||||
|
||||
if config.progress[action..'_role_permission'] and not Roles.player_allowed(player,config.progress[action..'_role_permission']) then
|
||||
if config.progress[action..'_role_permission']
|
||||
and not Roles.player_allowed(player,config.progress[action..'_role_permission']) then
|
||||
return false
|
||||
end
|
||||
|
||||
@@ -45,12 +46,13 @@ Gui.element(function(_,parent,label_data)
|
||||
local data_fullname = data_subname and data_name..data_subname or data_name
|
||||
|
||||
-- Add the name label
|
||||
parent.add{
|
||||
local name_label = parent.add{
|
||||
type = 'label',
|
||||
name = data_fullname..'-label',
|
||||
caption = {'rocket-info.data-caption-'..data_name,data_subname},
|
||||
tooltip = {'rocket-info.data-tooltip-'..data_name,data_subname}
|
||||
}
|
||||
name_label.style.padding = {0,2}
|
||||
|
||||
--- Right aligned label to store the data
|
||||
local alignment = Gui.alignment(parent,nil,nil,data_fullname)
|
||||
@@ -61,6 +63,7 @@ Gui.element(function(_,parent,label_data)
|
||||
caption = label_data.value,
|
||||
tooltip = label_data.tooltip
|
||||
}
|
||||
element.style.padding = {0,2}
|
||||
|
||||
return element
|
||||
end)
|
||||
@@ -187,11 +190,7 @@ Gui.element{
|
||||
sprite = 'utility/play',
|
||||
tooltip = {'rocket-info.toggle-rocket-tooltip'}
|
||||
}
|
||||
:style{
|
||||
padding = -2,
|
||||
width = 16,
|
||||
height = 16
|
||||
}
|
||||
:style(Gui.sprite_style(16))
|
||||
:on_click(function(player,element,_)
|
||||
local rocket_silo_name = element.parent.name:sub(8)
|
||||
local rocket_silo = Rockets.get_silo_entity(rocket_silo_name)
|
||||
@@ -214,11 +213,7 @@ Gui.element{
|
||||
sprite = 'utility/center',
|
||||
tooltip = {'rocket-info.launch-tooltip'}
|
||||
}
|
||||
:style{
|
||||
padding = -2,
|
||||
width = 16,
|
||||
height = 16
|
||||
}
|
||||
:style(Gui.sprite_style(16,-1))
|
||||
:on_click(function(player,element,_)
|
||||
local rocket_silo_name = element.parent.name:sub(8)
|
||||
local silo_data = Rockets.get_silo_data_by_name(rocket_silo_name)
|
||||
@@ -333,6 +328,7 @@ local function get_progress_data(force_name)
|
||||
silo_name = silo_data.name,
|
||||
remove = true
|
||||
})
|
||||
|
||||
else
|
||||
-- Get the progress caption and tooltip
|
||||
local progress_color = Colors.white
|
||||
@@ -430,12 +426,8 @@ Gui.element{
|
||||
hovered_sprite = 'utility/expand',
|
||||
tooltip = {'rocket-info.toggle-section-tooltip'}
|
||||
}
|
||||
:style{
|
||||
padding = -2,
|
||||
height = 20,
|
||||
width = 20
|
||||
}
|
||||
:on_click(function(player,element,_)
|
||||
:style(Gui.sprite_style(20))
|
||||
:on_click(function(_,element,_)
|
||||
local header_flow = element.parent
|
||||
local flow_name = header_flow.caption
|
||||
local flow = header_flow.parent.parent[flow_name]
|
||||
@@ -479,33 +471,13 @@ end)
|
||||
-- @element rocket_list_container
|
||||
local rocket_list_container =
|
||||
Gui.element(function(event_trigger,parent)
|
||||
-- Draw the external container
|
||||
local frame =
|
||||
parent.add{
|
||||
name = event_trigger,
|
||||
type = 'frame'
|
||||
}
|
||||
|
||||
-- Set the frame style
|
||||
local frame_style = frame.style
|
||||
frame_style.padding = 2
|
||||
frame_style.minimal_width = 200
|
||||
|
||||
-- Draw the internal container
|
||||
local container =
|
||||
frame.add{
|
||||
name = 'container',
|
||||
type = 'frame',
|
||||
direction = 'vertical',
|
||||
style = 'window_content_frame_packed'
|
||||
}
|
||||
local container = Gui.container(parent,event_trigger,200)
|
||||
|
||||
-- Set the container style
|
||||
local style = container.style
|
||||
style.vertically_stretchable = false
|
||||
style.padding = 0
|
||||
|
||||
|
||||
local player = Gui.get_player_from_element(parent)
|
||||
local force_name = player.force.name
|
||||
-- Draw stats section
|
||||
@@ -525,37 +497,27 @@ Gui.element(function(event_trigger,parent)
|
||||
if check_player_permissions(player,'toggle_active') then col_count = col_count+1 end
|
||||
local progress = section(container,'progress',col_count)
|
||||
-- Label used when there are no active silos
|
||||
progress.add{
|
||||
local no_silos = progress.add{
|
||||
type = 'label',
|
||||
name = 'no_silos',
|
||||
caption = {'rocket-info.progress-no-silos'}
|
||||
}
|
||||
}
|
||||
no_silos.style.padding = {1,2}
|
||||
update_build_progress(progress,get_progress_data(force_name))
|
||||
end
|
||||
|
||||
-- Return the exteral container
|
||||
return frame
|
||||
return container.parent
|
||||
end)
|
||||
:add_to_left_flow(function(player)
|
||||
return player.force.rockets_launched > 0 and Roles.player_allowed(player,'gui/rocket-info')
|
||||
end)
|
||||
|
||||
--- Button on the top flow used to toggle the container
|
||||
-- @element rocket_list_toggle
|
||||
Gui.element{
|
||||
type = 'sprite-button',
|
||||
sprite = 'entity/rocket-silo',
|
||||
style = Gui.top_flow_button_style
|
||||
}
|
||||
:style{
|
||||
padding = -2
|
||||
}
|
||||
:add_to_top_flow(function(player)
|
||||
-- @element toggle_left_element
|
||||
Gui.left_toolbar_button('entity/rocket-silo', {'rocket-info.main-tooltip'}, rocket_list_container, function(player)
|
||||
return Roles.player_allowed(player,'gui/rocket-info')
|
||||
end)
|
||||
:on_click(function(player,_,_)
|
||||
Gui.toggle_left_element(player, rocket_list_container)
|
||||
end)
|
||||
|
||||
--- Update the gui for all players on a force
|
||||
local function update_rocket_gui_all(force_name)
|
||||
@@ -563,8 +525,7 @@ local function update_rocket_gui_all(force_name)
|
||||
local milestones = get_milestone_data(force_name)
|
||||
local progress = get_progress_data(force_name)
|
||||
for _,player in pairs(game.forces[force_name].players) do
|
||||
local left_flow = Gui.get_left_flow(player)
|
||||
local frame = left_flow[rocket_list_container.name]
|
||||
local frame = Gui.get_left_element(player,rocket_list_container)
|
||||
local container = frame.container
|
||||
update_data_labels(container.stats.table,stats)
|
||||
update_data_labels(container.milestones.table,milestones)
|
||||
@@ -587,8 +548,7 @@ end)
|
||||
local function update_rocket_gui_progress(force_name)
|
||||
local progress = get_progress_data(force_name)
|
||||
for _,player in pairs(game.forces[force_name].players) do
|
||||
local left_flow = Gui.get_left_flow(player)
|
||||
local frame = left_flow[rocket_list_container.name]
|
||||
local frame = Gui.get_left_element(player,rocket_list_container)
|
||||
local container = frame.container
|
||||
update_build_progress(container.progress.table,progress)
|
||||
end
|
||||
@@ -616,8 +576,7 @@ Event.add(defines.events.on_robot_built_entity,on_built)
|
||||
--- Redraw the progress section on role change
|
||||
local function role_update_event(event)
|
||||
local player = game.players[event.player_index]
|
||||
local left_flow = Gui.get_left_flow(player)
|
||||
local container = left_flow[rocket_list_container.name].container
|
||||
local container = Gui.get_left_element(player,rocket_list_container).container
|
||||
local progress = container.progress
|
||||
if config.progress.show_progress then
|
||||
progress.destroy()
|
||||
|
||||
@@ -47,7 +47,9 @@ Gui.element(function(_,parent,production_label_data)
|
||||
}
|
||||
|
||||
-- Change the style
|
||||
surfix_element.style.font_color = color
|
||||
local surfix_element_style = surfix_element.style
|
||||
surfix_element_style.font_color = color
|
||||
surfix_element_style.right_margin = 1
|
||||
|
||||
-- Return the value label
|
||||
return element
|
||||
@@ -119,8 +121,6 @@ Gui.element(function(_,parent,science_pack_data)
|
||||
type = 'frame',
|
||||
style = 'bordered_frame'
|
||||
}
|
||||
|
||||
-- Change the style of the delta flow
|
||||
delta_flow.style.padding = {0,3}
|
||||
|
||||
-- Draw the delta flow table
|
||||
@@ -130,8 +130,6 @@ Gui.element(function(_,parent,science_pack_data)
|
||||
type = 'table',
|
||||
column_count = 2
|
||||
}
|
||||
|
||||
-- Change the style of the delta flow table
|
||||
delta_table.style.padding = 0
|
||||
|
||||
-- Draw the production labels
|
||||
@@ -223,9 +221,9 @@ local function get_eta_label_data(player)
|
||||
return { research = false }
|
||||
end
|
||||
|
||||
local limit
|
||||
local progress = force.research_progress
|
||||
local remaining = research.research_unit_count*(1-progress)
|
||||
local limit
|
||||
|
||||
-- Check for the limiting science pack
|
||||
for _,ingredient in pairs(research.research_unit_ingredients) do
|
||||
@@ -266,40 +264,14 @@ local science_info_container =
|
||||
Gui.element(function(event_trigger,parent)
|
||||
local player = Gui.get_player_from_element(parent)
|
||||
|
||||
-- Draw the external container
|
||||
local frame =
|
||||
parent.add{
|
||||
name = event_trigger,
|
||||
type = 'frame'
|
||||
}
|
||||
|
||||
-- Set the frame style
|
||||
local frame_style = frame.style
|
||||
frame_style.padding = 2
|
||||
frame_style.minimal_width = 200
|
||||
|
||||
-- Draw the internal container
|
||||
local container =
|
||||
frame.add{
|
||||
name = 'container',
|
||||
type = 'frame',
|
||||
direction = 'vertical',
|
||||
style = 'window_content_frame_packed'
|
||||
}
|
||||
|
||||
-- Set the container style
|
||||
local style = container.style
|
||||
style.vertically_stretchable = false
|
||||
local container = Gui.container(parent,event_trigger,200)
|
||||
|
||||
-- Draw the header
|
||||
Gui.header(
|
||||
container,
|
||||
{'science-info.main-caption'},
|
||||
{'science-info.main-tooltip'}
|
||||
)
|
||||
Gui.header(container, {'science-info.main-caption'}, {'science-info.main-tooltip'})
|
||||
|
||||
-- Draw the scroll table for the tasks
|
||||
local scroll_table = Gui.scroll_table(container,185,4)
|
||||
local scroll_table = Gui.scroll_table(container,178,4)
|
||||
|
||||
-- Draw the no packs label
|
||||
local no_packs_label =
|
||||
@@ -318,20 +290,7 @@ Gui.element(function(event_trigger,parent)
|
||||
-- Add the footer and eta
|
||||
if config.show_eta then
|
||||
-- Draw the footer
|
||||
local footer = Gui.header(
|
||||
container,
|
||||
{'science-info.eta-caption'},
|
||||
{'science-info.eta-tooltip'},
|
||||
true,
|
||||
'footer'
|
||||
)
|
||||
|
||||
-- Set the style
|
||||
footer.parent.style = 'subheader_frame'
|
||||
local footer_style = footer.parent.style
|
||||
footer_style.padding = {2,4}
|
||||
footer_style.use_header_filler = false
|
||||
footer_style.horizontally_stretchable = true
|
||||
local footer = Gui.footer(container, {'science-info.eta-caption'}, {'science-info.eta-tooltip'}, true)
|
||||
|
||||
-- Draw the eta label
|
||||
local eta_label =
|
||||
@@ -354,27 +313,15 @@ Gui.element(function(event_trigger,parent)
|
||||
end
|
||||
|
||||
-- Return the exteral container
|
||||
return frame
|
||||
return container.parent
|
||||
end)
|
||||
:add_to_left_flow()
|
||||
|
||||
--- Button on the top flow used to toggle the task list container
|
||||
-- @element task_list_toggle
|
||||
Gui.element{
|
||||
type = 'sprite-button',
|
||||
sprite = 'entity/lab',
|
||||
tooltip = {'science-info.main-tooltip'},
|
||||
style = Gui.top_flow_button_style
|
||||
}
|
||||
:style{
|
||||
padding = -2
|
||||
}
|
||||
:add_to_top_flow(function(player)
|
||||
-- @element toggle_left_element
|
||||
Gui.left_toolbar_button('entity/lab', {'science-info.main-tooltip'}, science_info_container, function(player)
|
||||
return Roles.player_allowed(player,'gui/science-info')
|
||||
end)
|
||||
:on_click(function(player,_,_)
|
||||
Gui.toggle_left_element(player, science_info_container)
|
||||
end)
|
||||
|
||||
--- Updates the gui every 1 second
|
||||
Event.on_nth_tick(60,function()
|
||||
@@ -382,8 +329,7 @@ Event.on_nth_tick(60,function()
|
||||
local force_eta_data = {}
|
||||
for _,player in pairs(game.connected_players) do
|
||||
local force_name = player.force.name
|
||||
local left_flow = Gui.get_left_flow(player)
|
||||
local frame = left_flow[science_info_container.name]
|
||||
local frame = Gui.get_left_element(player,science_info_container)
|
||||
local container = frame.container
|
||||
|
||||
-- Update the science packs
|
||||
|
||||
@@ -11,6 +11,12 @@ local config = require 'config.tasks' --- @dep config.tasks
|
||||
local format_time,table_keys = ext_require('expcore.common','format_time','table_keys') --- @dep expcore.common
|
||||
local Tasks = require 'modules.control.tasks' --- @dep modules.control.tasks
|
||||
|
||||
-- Styles used for sprite buttons
|
||||
local Styles = {
|
||||
sprite20 = Gui.sprite_style(20),
|
||||
sprite22 = Gui.sprite_style(20, nil, { right_margin = -3 })
|
||||
}
|
||||
|
||||
--- If a player is allowed to use the edit buttons
|
||||
local function check_player_permissions(player,task)
|
||||
if task then
|
||||
@@ -60,11 +66,7 @@ Gui.element{
|
||||
tooltip = {'task-list.add-tooltip'},
|
||||
style = 'tool_button'
|
||||
}
|
||||
:style{
|
||||
padding = -2,
|
||||
height = 20,
|
||||
width = 20
|
||||
}
|
||||
:style(Styles.sprite20)
|
||||
:on_click(function(player,_,_)
|
||||
Tasks.add_task(player.force.name,nil,player.name)
|
||||
end)
|
||||
@@ -78,11 +80,7 @@ Gui.element{
|
||||
tooltip = {'task-list.edit-tooltip-none'},
|
||||
style = 'tool_button'
|
||||
}
|
||||
:style{
|
||||
padding = -2,
|
||||
height = 20,
|
||||
width = 20
|
||||
}
|
||||
:style(Styles.sprite20)
|
||||
:on_click(function(player,element,_)
|
||||
local task_id = element.parent.name:sub(6)
|
||||
Tasks.set_editing(task_id,player.name,true)
|
||||
@@ -97,11 +95,7 @@ Gui.element{
|
||||
tooltip = {'task-list.discard-tooltip'},
|
||||
style = 'tool_button'
|
||||
}
|
||||
:style{
|
||||
padding = -2,
|
||||
height = 20,
|
||||
width = 20
|
||||
}
|
||||
:style(Styles.sprite20)
|
||||
:on_click(function(_,element,_)
|
||||
local task_id = element.parent.name:sub(6)
|
||||
Tasks.remove_task(task_id)
|
||||
@@ -112,22 +106,16 @@ end)
|
||||
local add_task_base =
|
||||
Gui.element(function(_,parent,task_id)
|
||||
-- Add the task number label
|
||||
parent.add{
|
||||
local task_number = parent.add{
|
||||
name = 'count-'..task_id,
|
||||
type = 'label',
|
||||
caption = '0)'
|
||||
}
|
||||
task_number.style.left_margin = 1
|
||||
|
||||
-- Add a flow which will contain the task message and edit buttons
|
||||
local task_flow =
|
||||
parent.add{
|
||||
name = task_id,
|
||||
type = 'flow',
|
||||
}
|
||||
|
||||
-- Set the padding on the task flow
|
||||
local task_flow_style = task_flow.style
|
||||
task_flow_style.padding = 0
|
||||
local task_flow = parent.add{ name = task_id, type = 'flow', }
|
||||
task_flow.style.padding = 0
|
||||
|
||||
-- Add the two edit buttons outside the task flow
|
||||
local edit_flow = Gui.alignment(parent,nil,nil,'edit-'..task_id)
|
||||
@@ -155,12 +143,7 @@ Gui.element{
|
||||
tooltip = {'task-list.confirm-tooltip'},
|
||||
style = 'shortcut_bar_button_green'
|
||||
}
|
||||
:style{
|
||||
padding = -2,
|
||||
right_margin = -3,
|
||||
height = 22,
|
||||
width = 22
|
||||
}
|
||||
:style(Styles.sprite22)
|
||||
:on_click(function(player,element,_)
|
||||
local task_id = element.parent.name
|
||||
local new_message = element.parent[task_editing.name].text
|
||||
@@ -177,12 +160,7 @@ Gui.element{
|
||||
tooltip = {'task-list.cancel-tooltip'},
|
||||
style = 'shortcut_bar_button_red'
|
||||
}
|
||||
:style{
|
||||
padding = -2,
|
||||
right_margin = -3,
|
||||
height = 22,
|
||||
width = 22
|
||||
}
|
||||
:style(Styles.sprite22)
|
||||
:on_click(function(player,element,_)
|
||||
local task_id = element.parent.name
|
||||
Tasks.set_editing(task_id,player.name)
|
||||
@@ -203,11 +181,6 @@ Gui.element(function(event_trigger,parent,task)
|
||||
clear_and_focus_on_right_click = true
|
||||
}
|
||||
|
||||
-- Change the style
|
||||
local style = element.style
|
||||
style.maximal_width = 110
|
||||
style.height = 20
|
||||
|
||||
-- Add the edit buttons
|
||||
cancel_edit(parent)
|
||||
confirm_edit(parent)
|
||||
@@ -215,6 +188,10 @@ Gui.element(function(event_trigger,parent,task)
|
||||
-- Return the element
|
||||
return element
|
||||
end)
|
||||
:style{
|
||||
maximal_width = 110,
|
||||
height = 20
|
||||
}
|
||||
:on_confirmed(function(player,element,_)
|
||||
local task_id = element.parent.name
|
||||
local new_message = element.text
|
||||
@@ -229,24 +206,18 @@ Gui.element(function(_,parent,task)
|
||||
local message = task.message
|
||||
local last_edit_name = task.last_edit_name
|
||||
local last_edit_time = task.last_edit_time
|
||||
|
||||
-- Draw the element
|
||||
local element =
|
||||
parent.add{
|
||||
return parent.add{
|
||||
name = task_editing.name,
|
||||
type = 'label',
|
||||
caption = message,
|
||||
tooltip = {'task-list.last-edit', last_edit_name, format_time(last_edit_time)}
|
||||
}
|
||||
|
||||
-- Change the style
|
||||
local style = element.style
|
||||
style.single_line = false
|
||||
style.maximal_width = 150
|
||||
|
||||
-- Return the element
|
||||
return element
|
||||
end)
|
||||
:style{
|
||||
single_line = false,
|
||||
maximal_width = 150
|
||||
}
|
||||
|
||||
--- Updates a task for a player
|
||||
local function update_task(player,task_table,task_id)
|
||||
@@ -308,10 +279,12 @@ local function update_task(player,task_table,task_id)
|
||||
edit_task_element.enabled = false
|
||||
task_flow.clear()
|
||||
task_editing(task_flow,task).focus()
|
||||
task_table.parent.scroll_to_element(task_flow,'top-third')
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
-- Update all the tasks for a player
|
||||
local function update_all_tasks(player,scroll_table)
|
||||
local task_ids = Tasks.get_force_task_ids(player.force.name)
|
||||
if #task_ids > 0 then
|
||||
@@ -325,30 +298,8 @@ end
|
||||
-- @element task_list_container
|
||||
local task_list_container =
|
||||
Gui.element(function(event_trigger,parent)
|
||||
-- Draw the external container
|
||||
local frame =
|
||||
parent.add{
|
||||
name = event_trigger,
|
||||
type = 'frame'
|
||||
}
|
||||
|
||||
-- Set the frame style
|
||||
local frame_style = frame.style
|
||||
frame_style.padding = 2
|
||||
frame_style.minimal_width = 200
|
||||
|
||||
-- Draw the internal container
|
||||
local container =
|
||||
frame.add{
|
||||
name = 'container',
|
||||
type = 'frame',
|
||||
direction = 'vertical',
|
||||
style = 'window_content_frame_packed'
|
||||
}
|
||||
|
||||
-- Set the container style
|
||||
local style = container.style
|
||||
style.vertically_stretchable = false
|
||||
local container = Gui.container(parent,event_trigger,200)
|
||||
|
||||
-- Draw the header
|
||||
local header = Gui.header(
|
||||
@@ -364,7 +315,7 @@ Gui.element(function(event_trigger,parent)
|
||||
add_new_task_element.visible = check_player_permissions(player)
|
||||
|
||||
-- Draw the scroll table for the tasks
|
||||
local scroll_table = Gui.scroll_table(container,185,3)
|
||||
local scroll_table = Gui.scroll_table(container,190,3)
|
||||
scroll_table.draw_horizontal_lines = true
|
||||
scroll_table.vertical_centering = false
|
||||
|
||||
@@ -397,7 +348,7 @@ Gui.element(function(event_trigger,parent)
|
||||
end
|
||||
|
||||
-- Return the exteral container
|
||||
return frame
|
||||
return container.parent
|
||||
end)
|
||||
:add_to_left_flow(function(player)
|
||||
local task_ids = Tasks.get_force_task_ids(player.force.name)
|
||||
@@ -405,22 +356,10 @@ end)
|
||||
end)
|
||||
|
||||
--- Button on the top flow used to toggle the task list container
|
||||
-- @element task_list_toggle
|
||||
Gui.element{
|
||||
type = 'sprite-button',
|
||||
sprite = 'utility/not_enough_repair_packs_icon',
|
||||
tooltip = {'task-list.main-tooltip'},
|
||||
style = Gui.top_flow_button_style
|
||||
}
|
||||
:style{
|
||||
padding = -2
|
||||
}
|
||||
:add_to_top_flow(function(player)
|
||||
-- @element toggle_left_element
|
||||
Gui.left_toolbar_button('utility/not_enough_repair_packs_icon', {'task-list.main-tooltip'}, task_list_container, function(player)
|
||||
return Roles.player_allowed(player,'gui/task-list')
|
||||
end)
|
||||
:on_click(function(player,_,_)
|
||||
Gui.toggle_left_element(player, task_list_container)
|
||||
end)
|
||||
|
||||
--- When a new task is added it will udpate the task list for everyone on that force
|
||||
Tasks.on_update(function(task,task_id,removed_task)
|
||||
@@ -435,8 +374,7 @@ Tasks.on_update(function(task,task_id,removed_task)
|
||||
-- Update the task for all the players on the force
|
||||
local task_ids = Tasks.get_force_task_ids(force.name)
|
||||
for _,player in pairs(force.connected_players) do
|
||||
local left_flow = Gui.get_left_flow(player)
|
||||
local frame = left_flow[task_list_container.name]
|
||||
local frame = Gui.get_left_element(player,task_list_container)
|
||||
local scroll_table = frame.container.scroll.table
|
||||
|
||||
-- Update the task that was changed
|
||||
@@ -455,8 +393,7 @@ end)
|
||||
--- Update the tasks when the player joins
|
||||
Event.add(defines.events.on_player_joined_game,function(event)
|
||||
local player = game.players[event.player_index]
|
||||
local left_flow = Gui.get_left_flow(player)
|
||||
local frame = left_flow[task_list_container.name]
|
||||
local frame = Gui.get_left_element(player,task_list_container)
|
||||
local scroll_table = frame.container.scroll.table
|
||||
update_all_tasks(player,scroll_table)
|
||||
end)
|
||||
@@ -464,8 +401,7 @@ end)
|
||||
--- Makes sure the right buttons are present when roles change
|
||||
local function role_update_event(event)
|
||||
local player = game.players[event.player_index]
|
||||
local left_flow = Gui.get_left_flow(player)
|
||||
local container = left_flow[task_list_container.name].container
|
||||
local container = Gui.get_left_element(player,task_list_container).container
|
||||
|
||||
-- Update the tasks, incase the user can now edit them
|
||||
local scroll_table = container.scroll.table
|
||||
|
||||
@@ -31,6 +31,13 @@ Global.register(keep_gui_open,function(tbl)
|
||||
keep_gui_open = tbl
|
||||
end)
|
||||
|
||||
-- Styles used for sprite buttons
|
||||
local Styles = {
|
||||
sprite20 = Gui.sprite_style(20),
|
||||
sprite22 = Gui.sprite_style(20, nil, { right_margin = -3 }),
|
||||
sprite32 = { height = 32, width = 32, left_margin = 1 }
|
||||
}
|
||||
|
||||
--- Returns if a player is allowed to edit the given warp
|
||||
--- If a player is allowed to use the edit buttons
|
||||
local function check_player_permissions(player,action,warp)
|
||||
@@ -71,11 +78,7 @@ Gui.element{
|
||||
tooltip = {'warp-list.add-tooltip'},
|
||||
style = 'tool_button'
|
||||
}
|
||||
:style{
|
||||
padding = -2,
|
||||
height = 20,
|
||||
width = 20
|
||||
}
|
||||
:style(Styles.sprite20)
|
||||
:on_click(function(player,element)
|
||||
-- Add the new warp
|
||||
local force_name = player.force.name
|
||||
@@ -95,11 +98,7 @@ Gui.element{
|
||||
tooltip = {'warp-list.discard-tooltip'},
|
||||
style = 'tool_button'
|
||||
}
|
||||
:style{
|
||||
padding = -2,
|
||||
height = 20,
|
||||
width = 20
|
||||
}
|
||||
:style(Styles.sprite20)
|
||||
:on_click(function(_,element)
|
||||
local warp_id = element.parent.name:sub(6)
|
||||
Warps.remove_warp(warp_id)
|
||||
@@ -114,11 +113,7 @@ Gui.element{
|
||||
tooltip = {'warp-list.edit-tooltip-none'},
|
||||
style = 'tool_button'
|
||||
}
|
||||
:style{
|
||||
padding = -2,
|
||||
height = 20,
|
||||
width = 20
|
||||
}
|
||||
:style(Styles.sprite20)
|
||||
:on_click(function(player,element)
|
||||
local warp_id = element.parent.name:sub(6)
|
||||
Warps.set_editing(warp_id,player.name,true)
|
||||
@@ -135,18 +130,10 @@ Gui.element(function(_,parent,warp_id)
|
||||
type = 'flow',
|
||||
caption = warp_id
|
||||
}
|
||||
|
||||
-- Change the style of the flow
|
||||
icon_flow.style.padding = 0
|
||||
|
||||
-- Add a flow which will contain the warp name and edit buttons
|
||||
local warp_flow =
|
||||
parent.add{
|
||||
name = warp_id,
|
||||
type = 'flow',
|
||||
}
|
||||
|
||||
-- Set the padding on the warp flow
|
||||
local warp_flow = parent.add{ type = 'flow', name = warp_id }
|
||||
warp_flow.style.padding = 0
|
||||
|
||||
-- Add the two edit buttons outside the warp flow
|
||||
@@ -176,12 +163,7 @@ Gui.element{
|
||||
tooltip = {'warp-list.confirm-tooltip'},
|
||||
style = 'shortcut_bar_button_green'
|
||||
}
|
||||
:style{
|
||||
padding = -2,
|
||||
right_margin = -3,
|
||||
height = 22,
|
||||
width = 22
|
||||
}
|
||||
:style(Styles.sprite22)
|
||||
:on_click(function(player,element)
|
||||
local warp_id = element.parent.name
|
||||
local warp_name = element.parent[warp_editing.name].text
|
||||
@@ -199,12 +181,7 @@ Gui.element{
|
||||
tooltip = {'warp-list.cancel-tooltip'},
|
||||
style = 'shortcut_bar_button_red'
|
||||
}
|
||||
:style{
|
||||
padding = -2,
|
||||
right_margin = -3,
|
||||
height = 22,
|
||||
width = 22
|
||||
}
|
||||
:style(Styles.sprite22)
|
||||
:on_click(function(player,element)
|
||||
local warp_id = element.parent.name
|
||||
Warps.set_editing(warp_id,player.name)
|
||||
@@ -225,11 +202,6 @@ Gui.element(function(event_trigger,parent,warp)
|
||||
clear_and_focus_on_right_click = true
|
||||
}
|
||||
|
||||
-- Change the style
|
||||
local style = element.style
|
||||
style.maximal_width = 110
|
||||
style.height = 20
|
||||
|
||||
-- Add the edit buttons
|
||||
cancel_edit(parent)
|
||||
confirm_edit(parent)
|
||||
@@ -237,6 +209,10 @@ Gui.element(function(event_trigger,parent,warp)
|
||||
-- Return the element
|
||||
return element
|
||||
end)
|
||||
:style{
|
||||
maximal_width = 110,
|
||||
height = 20
|
||||
}
|
||||
:on_confirmed(function(player,element,_)
|
||||
local warp_id = element.parent.name
|
||||
local warp_name = element.text
|
||||
@@ -249,27 +225,20 @@ end)
|
||||
-- @element warp_label
|
||||
local warp_label =
|
||||
Gui.element(function(event_trigger,parent,warp)
|
||||
local name = warp.name
|
||||
local last_edit_name = warp.last_edit_name
|
||||
local last_edit_time = warp.last_edit_time
|
||||
|
||||
-- Draw the element
|
||||
local element =
|
||||
parent.add{
|
||||
return parent.add{
|
||||
name = event_trigger,
|
||||
type = 'label',
|
||||
caption = name,
|
||||
caption = warp.name,
|
||||
tooltip = {'warp-list.last-edit',last_edit_name,format_time(last_edit_time)}
|
||||
}
|
||||
|
||||
-- Change the style
|
||||
local style = element.style
|
||||
style.single_line = false
|
||||
style.maximal_width = 150
|
||||
|
||||
-- Return the element
|
||||
return element
|
||||
end)
|
||||
:style{
|
||||
single_line = false,
|
||||
maximal_width = 150
|
||||
}
|
||||
:on_click(function(player,element,_)
|
||||
local warp_id = element.parent.name
|
||||
local warp = Warps.get_warp(warp_id)
|
||||
@@ -283,25 +252,16 @@ end)
|
||||
warp_icon_button =
|
||||
Gui.element(function(event_trigger,parent,warp)
|
||||
local warp_position = warp.position
|
||||
|
||||
-- Draw the element
|
||||
local element =
|
||||
parent.add{
|
||||
return parent.add{
|
||||
name = event_trigger,
|
||||
type = 'sprite-button',
|
||||
sprite = 'item/'..warp.icon,
|
||||
tooltip = {'warp-list.goto-tooltip',warp_position.x,warp_position.y},
|
||||
style = 'quick_bar_slot_button'
|
||||
}
|
||||
|
||||
-- Change the style
|
||||
local style = element.style
|
||||
style.height = 32
|
||||
style.width = 32
|
||||
|
||||
-- Return the element
|
||||
return element
|
||||
end)
|
||||
:style(Styles.sprite32)
|
||||
:on_click(function(player,element,_)
|
||||
local warp_id = element.parent.caption
|
||||
Warps.teleport_player(warp_id,player)
|
||||
@@ -316,27 +276,16 @@ end)
|
||||
--- Editing state for the warp icon, chose elem used to chosse icon
|
||||
-- @element warp_icon_editing
|
||||
local warp_icon_editing =
|
||||
Gui.element(function(event_trigger,parent,warp)
|
||||
local warp_icon = warp.icon
|
||||
|
||||
-- Draw the element
|
||||
local element =
|
||||
parent.add{
|
||||
Gui.element(function(_,parent,warp)
|
||||
return parent.add{
|
||||
name = warp_icon_button.name,
|
||||
type = 'choose-elem-button',
|
||||
elem_type = 'item',
|
||||
item = warp_icon,
|
||||
item = warp.icon,
|
||||
tooltip = {'warp-list.goto-edit'},
|
||||
}
|
||||
|
||||
-- Change the style
|
||||
local style = element.style
|
||||
style.height = 32
|
||||
style.width = 32
|
||||
|
||||
-- Return the element
|
||||
return element
|
||||
end)
|
||||
:style(Styles.sprite32)
|
||||
|
||||
--- This timer controls when a player is able to warp, eg every 60 seconds
|
||||
-- @element warp_timer
|
||||
@@ -421,12 +370,14 @@ local function update_warp(player,warp_table,warp_id)
|
||||
edit_warp_element.enabled = false
|
||||
warp_flow.clear()
|
||||
warp_editing(warp_flow,warp).focus()
|
||||
warp_table.parent.scroll_to_element(warp_flow,'top-third')
|
||||
icon_flow.clear()
|
||||
warp_icon_editing(icon_flow,warp)
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
-- Update all the warps for a player
|
||||
local function update_all_warps(player,warp_table)
|
||||
local warp_ids = Warps.get_force_warp_ids(player.force.name)
|
||||
if #warp_ids > 0 then
|
||||
@@ -440,30 +391,8 @@ end
|
||||
-- @element warp_list_container
|
||||
local warp_list_container =
|
||||
Gui.element(function(event_trigger,parent)
|
||||
-- Draw the external container
|
||||
local frame =
|
||||
parent.add{
|
||||
name = event_trigger,
|
||||
type = 'frame'
|
||||
}
|
||||
|
||||
-- Set the frame style
|
||||
local frame_style = frame.style
|
||||
frame_style.padding = 2
|
||||
frame_style.minimal_width = 200
|
||||
|
||||
-- Draw the internal container
|
||||
local container =
|
||||
frame.add{
|
||||
name = 'container',
|
||||
type = 'frame',
|
||||
direction = 'vertical',
|
||||
style = 'window_content_frame_packed'
|
||||
}
|
||||
|
||||
-- Set the container style
|
||||
local style = container.style
|
||||
style.vertically_stretchable = false
|
||||
local container = Gui.container(parent,event_trigger,200)
|
||||
|
||||
-- Draw the header
|
||||
local header = Gui.header(
|
||||
@@ -479,7 +408,7 @@ Gui.element(function(event_trigger,parent)
|
||||
add_new_warp_element.visible = check_player_permissions(player,'allow_add_warp')
|
||||
|
||||
-- Draw the scroll table for the warps
|
||||
local scroll_table = Gui.scroll_table(container,258,3)
|
||||
local scroll_table = Gui.scroll_table(container,250,3)
|
||||
|
||||
-- Change the style of the scroll table
|
||||
local scroll_table_style = scroll_table.style
|
||||
@@ -501,7 +430,7 @@ Gui.element(function(event_trigger,parent)
|
||||
update_all_warps(player,scroll_table)
|
||||
|
||||
-- Return the exteral container
|
||||
return frame
|
||||
return container.parent
|
||||
end)
|
||||
:add_to_left_flow()
|
||||
|
||||
@@ -537,8 +466,7 @@ Warps.on_update(function(warp,_,removed_warp)
|
||||
-- Update the gui for selected players
|
||||
local warp_ids = Warps.get_force_warp_ids(force.name)
|
||||
for _,player in pairs(force.connected_players) do
|
||||
local left_flow = Gui.get_left_flow(player)
|
||||
local frame = left_flow[warp_list_container.name]
|
||||
local frame = Gui.get_left_element(player,warp_list_container)
|
||||
local scroll_table = frame.container.scroll.table
|
||||
|
||||
-- Update the gui
|
||||
@@ -552,8 +480,7 @@ end)
|
||||
--- Update the warps when the player joins
|
||||
Event.add(defines.events.on_player_joined_game,function(event)
|
||||
local player = game.players[event.player_index]
|
||||
local left_flow = Gui.get_left_flow(player)
|
||||
local frame = left_flow[warp_list_container.name]
|
||||
local frame = Gui.get_left_element(player,warp_list_container)
|
||||
local scroll_table = frame.container.scroll.table
|
||||
update_all_warps(player,scroll_table)
|
||||
end)
|
||||
@@ -561,8 +488,7 @@ end)
|
||||
--- Makes sure the right buttons are present when roles change
|
||||
local function role_update_event(event)
|
||||
local player = game.players[event.player_index]
|
||||
local left_flow = Gui.get_left_flow(player)
|
||||
local container = left_flow[warp_list_container.name].container
|
||||
local container = Gui.get_left_element(player,warp_list_container).container
|
||||
|
||||
-- Update the warps, incase the user can now edit them
|
||||
local scroll_table = container.scroll.table
|
||||
@@ -592,8 +518,7 @@ Store.watch(player_in_range_store,function(value,player_name)
|
||||
end
|
||||
|
||||
-- Get the warp table
|
||||
local left_flow = Gui.get_left_flow(player)
|
||||
local frame = left_flow[warp_list_container.name]
|
||||
local frame = Gui.get_left_element(player,warp_list_container)
|
||||
local scroll_table = frame.container.scroll.table
|
||||
|
||||
-- Check if the buttons should be active
|
||||
@@ -621,8 +546,7 @@ Store.watch(player_warp_cooldown_store,function(value,player_name,old_value)
|
||||
if value == old_value then return end
|
||||
-- Get the progress bar element
|
||||
local player = game.players[player_name]
|
||||
local left_flow = Gui.get_left_flow(player)
|
||||
local frame = left_flow[warp_list_container.name]
|
||||
local frame = Gui.get_left_element(player,warp_list_container)
|
||||
local warp_timer_element = frame.container[warp_timer.name]
|
||||
|
||||
-- Set the progress
|
||||
@@ -702,8 +626,7 @@ Event.on_nth_tick(math.floor(60/config.update_smoothing),function()
|
||||
end
|
||||
|
||||
-- Change the enabled state of the add warp button
|
||||
local left_flow = Gui.get_left_flow(player)
|
||||
local frame = left_flow[warp_list_container.name]
|
||||
local frame = Gui.get_left_element(player,warp_list_container)
|
||||
local add_warp_element = frame.container.header.alignment[add_new_warp.name]
|
||||
local was_able_to_make_warp = add_warp_element.enabled
|
||||
local can_make_warp = closest_distance > mr2
|
||||
|
||||
Reference in New Issue
Block a user