mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-31 04:51:40 +09:00
Added missing comments to gui defines
This commit is contained in:
@@ -210,6 +210,7 @@ local function update_action_bar(player)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Adds a player to the player list
|
||||||
local function add_player(list_table,player,role_name)
|
local function add_player(list_table,player,role_name)
|
||||||
open_action_bar(list_table,player.name)
|
open_action_bar(list_table,player.name)
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
--- Adds a rocket infomation gui which shows general stats, milestones and build progress of rockets
|
||||||
local Gui = require 'expcore.gui'
|
local Gui = require 'expcore.gui'
|
||||||
local Roles = require 'expcore.roles'
|
local Roles = require 'expcore.roles'
|
||||||
local Event = require 'utils.event'
|
local Event = require 'utils.event'
|
||||||
@@ -240,7 +241,12 @@ local function generate_container(player,element)
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Creates a text label followed by a data label, or updates them if already present
|
--[[ Creates a text label followed by a data label, or updates them if already present
|
||||||
|
element
|
||||||
|
> "data_name_extra"-label
|
||||||
|
> "data_name_extra"
|
||||||
|
>> label
|
||||||
|
]]
|
||||||
local function create_label_value_pair(element,data_name,value,tooltip,extra)
|
local function create_label_value_pair(element,data_name,value,tooltip,extra)
|
||||||
local data_name_extra = extra and data_name..extra or data_name
|
local data_name_extra = extra and data_name..extra or data_name
|
||||||
if element[data_name_extra] then
|
if element[data_name_extra] then
|
||||||
@@ -272,7 +278,7 @@ local function create_label_value_pair_time(element,data_name,raw_value,no_hours
|
|||||||
create_label_value_pair(element,data_name,value,tooltip,extra)
|
create_label_value_pair(element,data_name,value,tooltip,extra)
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Adds the data to the stats section
|
--- Adds the different data values to the stats section
|
||||||
local function generate_stats(player,frame)
|
local function generate_stats(player,frame)
|
||||||
if not config.stats.show_stats then return end
|
if not config.stats.show_stats then return end
|
||||||
local element = frame.container.stats.table
|
local element = frame.container.stats.table
|
||||||
@@ -338,7 +344,7 @@ local function generate_milestones(player,frame)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Creats the different action buttons
|
--- Creats the different buttons used with the rocket silos
|
||||||
local function generate_progress_buttons(player,element,rocket_silo_data)
|
local function generate_progress_buttons(player,element,rocket_silo_data)
|
||||||
local silo_name = rocket_silo_data.name
|
local silo_name = rocket_silo_data.name
|
||||||
local status = rocket_silo_data.entity.status == 21
|
local status = rocket_silo_data.entity.status == 21
|
||||||
@@ -379,7 +385,17 @@ local function generate_progress_buttons(player,element,rocket_silo_data)
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Creates build progress section
|
--[[ Creates build progress section
|
||||||
|
element
|
||||||
|
> toggle-"silo_name" (generate_progress_buttons)
|
||||||
|
> launch-"silo_name" (generate_progress_buttons)
|
||||||
|
> label-x-"silo_name"
|
||||||
|
>> "silo_name"
|
||||||
|
> label-y-"silo_name"
|
||||||
|
>> "silo_name"
|
||||||
|
> "silo_name"
|
||||||
|
>> label
|
||||||
|
]]
|
||||||
local function generate_progress(player,frame)
|
local function generate_progress(player,frame)
|
||||||
if not config.progress.show_progress then return end
|
if not config.progress.show_progress then return end
|
||||||
local element = frame.container.progress.table
|
local element = frame.container.progress.table
|
||||||
@@ -478,6 +494,7 @@ local function generate_progress(player,frame)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Registers the new left gui
|
||||||
local rocket_info =
|
local rocket_info =
|
||||||
Gui.new_left_frame('gui/rocket-info')
|
Gui.new_left_frame('gui/rocket-info')
|
||||||
:set_sprites('entity/rocket-silo')
|
:set_sprites('entity/rocket-silo')
|
||||||
@@ -500,6 +517,7 @@ end)
|
|||||||
generate_progress(player,element)
|
generate_progress(player,element)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
--- Event used to update the stats and the hui when a rocket is launched
|
||||||
Event.add(defines.events.on_rocket_launched,function(event)
|
Event.add(defines.events.on_rocket_launched,function(event)
|
||||||
local entity = event.rocket_silo
|
local entity = event.rocket_silo
|
||||||
local silo_name = get_silo_name(entity)
|
local silo_name = get_silo_name(entity)
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
--- Adds a science info gui that shows production usage and net for the different science packs as well as an eta
|
||||||
local Gui = require 'expcore.gui'
|
local Gui = require 'expcore.gui'
|
||||||
local Event = require 'utils.event'
|
local Event = require 'utils.event'
|
||||||
local Colors = require 'resources.color_presets'
|
local Colors = require 'resources.color_presets'
|
||||||
@@ -8,6 +9,7 @@ local config = require 'config.science'
|
|||||||
local null_time_short = {'science-info.eta-time',format_time(0,{hours=true,minutes=true,seconds=true,time=true,null=true})}
|
local null_time_short = {'science-info.eta-time',format_time(0,{hours=true,minutes=true,seconds=true,time=true,null=true})}
|
||||||
local null_time_long = format_time(0,{hours=true,minutes=true,seconds=true,long=true,null=true})
|
local null_time_long = format_time(0,{hours=true,minutes=true,seconds=true,long=true,null=true})
|
||||||
|
|
||||||
|
--- Gets the production stats for a certain science pack
|
||||||
local function get_production_stats(player,science_pack)
|
local function get_production_stats(player,science_pack)
|
||||||
local force = player.force
|
local force = player.force
|
||||||
local stats = force.item_production_statistics
|
local stats = force.item_production_statistics
|
||||||
@@ -33,6 +35,7 @@ local function get_production_stats(player,science_pack)
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Gets the font colour for a certain level of production
|
||||||
local function get_font_colour(value,secondary)
|
local function get_font_colour(value,secondary)
|
||||||
if value > 5 then
|
if value > 5 then
|
||||||
return Colors.light_green
|
return Colors.light_green
|
||||||
@@ -45,6 +48,18 @@ local function get_font_colour(value,secondary)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--[[ Generates the main structure for the gui
|
||||||
|
element
|
||||||
|
> container
|
||||||
|
>> header
|
||||||
|
>> scroll
|
||||||
|
>>> non_made
|
||||||
|
>>> table
|
||||||
|
>> footer (when eta is enabled)
|
||||||
|
>>> eta-label
|
||||||
|
>>> eta
|
||||||
|
>>>> label
|
||||||
|
]]
|
||||||
local function generate_container(player,element)
|
local function generate_container(player,element)
|
||||||
Gui.set_padding(element,1,2,2,2)
|
Gui.set_padding(element,1,2,2,2)
|
||||||
element.style.minimal_width = 200
|
element.style.minimal_width = 200
|
||||||
@@ -141,7 +156,13 @@ local function generate_container(player,element)
|
|||||||
return flow_table, eta
|
return flow_table, eta
|
||||||
end
|
end
|
||||||
|
|
||||||
local function add_data_pair(element,name,value,secondary,tooltip)
|
--[[ Adds two labels where one is right aligned and the other is a unit
|
||||||
|
element
|
||||||
|
> "name"
|
||||||
|
>> label
|
||||||
|
> spm-"name"
|
||||||
|
]]
|
||||||
|
local function add_data_label(element,name,value,secondary,tooltip)
|
||||||
local data_colour = get_font_colour(value,secondary)
|
local data_colour = get_font_colour(value,secondary)
|
||||||
local caption = format_number(math.round(value,1),true)
|
local caption = format_number(math.round(value,1),true)
|
||||||
|
|
||||||
@@ -192,6 +213,15 @@ local function add_data_pair(element,name,value,secondary,tooltip)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--[[ Adds a science pack to the list
|
||||||
|
element
|
||||||
|
> icon-"science_pack"
|
||||||
|
> delta-"science_pack"
|
||||||
|
>> table
|
||||||
|
>>> pos-"science_pack" (add_data_label)
|
||||||
|
>>> neg-"science_pack" (add_data_label)
|
||||||
|
> net-"science_pack" (add_data_label)
|
||||||
|
]]
|
||||||
local function generate_science_pack(player,element,science_pack)
|
local function generate_science_pack(player,element,science_pack)
|
||||||
local stats = get_production_stats(player,science_pack)
|
local stats = get_production_stats(player,science_pack)
|
||||||
if stats.total_made > 0 then
|
if stats.total_made > 0 then
|
||||||
@@ -253,13 +283,14 @@ local function generate_science_pack(player,element,science_pack)
|
|||||||
Gui.set_padding(delta_table)
|
Gui.set_padding(delta_table)
|
||||||
end
|
end
|
||||||
|
|
||||||
add_data_pair(delta.table,'pos-'..science_pack,stats.minute_made,nil,{'science-info.pos-tooltip',stats.total_made})
|
add_data_label(delta.table,'pos-'..science_pack,stats.minute_made,nil,{'science-info.pos-tooltip',stats.total_made})
|
||||||
add_data_pair(delta.table,'neg-'..science_pack,-stats.minute_used,nil,{'science-info.neg-tooltip',stats.total_used})
|
add_data_label(delta.table,'neg-'..science_pack,-stats.minute_used,nil,{'science-info.neg-tooltip',stats.total_used})
|
||||||
add_data_pair(element,'net-'..science_pack,stats.minute_net,stats.minute_made,{'science-info.net-tooltip',stats.total_net})
|
add_data_label(element,'net-'..science_pack,stats.minute_net,stats.minute_made,{'science-info.net-tooltip',stats.total_net})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function generate_eta(player,element)
|
--- Updates the eta label that was created with generate_container
|
||||||
|
local function update_eta(player,element)
|
||||||
if not config.show_eta then return end
|
if not config.show_eta then return end
|
||||||
local force = player.force
|
local force = player.force
|
||||||
local research = force.current_research
|
local research = force.current_research
|
||||||
@@ -304,6 +335,7 @@ local function generate_eta(player,element)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Registerse the new science info gui
|
||||||
local science_info =
|
local science_info =
|
||||||
Gui.new_left_frame('gui/science-info')
|
Gui.new_left_frame('gui/science-info')
|
||||||
:set_sprites('entity/lab')
|
:set_sprites('entity/lab')
|
||||||
@@ -316,7 +348,7 @@ Gui.new_left_frame('gui/science-info')
|
|||||||
generate_science_pack(player,table,science_pack)
|
generate_science_pack(player,table,science_pack)
|
||||||
end
|
end
|
||||||
|
|
||||||
generate_eta(player,eta)
|
update_eta(player,eta)
|
||||||
end)
|
end)
|
||||||
:on_update(function(player,element)
|
:on_update(function(player,element)
|
||||||
local container = element.container
|
local container = element.container
|
||||||
@@ -327,9 +359,10 @@ end)
|
|||||||
generate_science_pack(player,table,science_pack)
|
generate_science_pack(player,table,science_pack)
|
||||||
end
|
end
|
||||||
|
|
||||||
generate_eta(player,eta)
|
update_eta(player,eta)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
--- Updates the gui every 1 second
|
||||||
Event.on_nth_tick(60,science_info 'update_all')
|
Event.on_nth_tick(60,science_info 'update_all')
|
||||||
|
|
||||||
return science_info
|
return science_info
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
--- Adds a task list to the game which players can add remove and edit items on
|
||||||
local Gui = require 'expcore.gui'
|
local Gui = require 'expcore.gui'
|
||||||
local Store = require 'expcore.store'
|
local Store = require 'expcore.store'
|
||||||
local Global = require 'utils.global'
|
local Global = require 'utils.global'
|
||||||
@@ -365,6 +366,7 @@ local function generate_container(player,element)
|
|||||||
return flow_table
|
return flow_table
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Registeres the task list
|
||||||
local task_list =
|
local task_list =
|
||||||
Gui.new_left_frame('gui/task-list')
|
Gui.new_left_frame('gui/task-list')
|
||||||
:set_sprites('utility/not_enough_repair_packs_icon')
|
:set_sprites('utility/not_enough_repair_packs_icon')
|
||||||
@@ -392,6 +394,7 @@ end)
|
|||||||
|
|
||||||
update_all = task_list 'update_all'
|
update_all = task_list 'update_all'
|
||||||
|
|
||||||
|
--- When a new task is added it will udpate the task list for everyone on that force
|
||||||
Store.register(task_store,function(value,task_id)
|
Store.register(task_store,function(value,task_id)
|
||||||
local details = task_details[task_id]
|
local details = task_details[task_id]
|
||||||
local force = game.forces[details.force]
|
local force = game.forces[details.force]
|
||||||
|
|||||||
Reference in New Issue
Block a user