Merge branch 'patch/6.0.9'

This commit is contained in:
Cooldude2606
2020-05-28 20:26:07 +01:00
6 changed files with 36 additions and 32 deletions

View File

@@ -2,9 +2,9 @@
-- @config Science -- @config Science
return { -- list of all science packs to be shown in the gui return { -- list of all science packs to be shown in the gui
show_eta=true, --- @setting show_eta when true the eta for research completion will be shown show_eta = true, --- @setting show_eta when true the eta for research completion will be shown
color_clamp=5, --- @setting color_clamp the amount required for the text to show as green or red color_cutoff = 0.8, --- @setting color_cutoff the amount that production can fall before the text changes color
color_flux=0.1, --- @setting color_flux the ammount of flucuation allowed in production before icon change color_flux = 0.1, --- @setting color_flux the amount of fluctuation allowed in production before the icon changes color
'automation-science-pack', 'automation-science-pack',
'logistic-science-pack', 'logistic-science-pack',
'military-science-pack', 'military-science-pack',

View File

@@ -105,7 +105,7 @@ local header = Gui.header(
]] ]]
Gui.header = Gui.header =
Gui.element(function(_, parent, caption, tooltip, add_alignment, name) Gui.element(function(_, parent, caption, tooltip, add_alignment, name, label_name)
-- Draw the header -- Draw the header
local header = local header =
parent.add{ parent.add{
@@ -123,7 +123,7 @@ Gui.element(function(_, parent, caption, tooltip, add_alignment, name)
-- Draw the caption label -- Draw the caption label
if caption then if caption then
header.add{ header.add{
name = 'header_label', name = label_name or 'header_label',
type = 'label', type = 'label',
style = 'heading_1_label', style = 'heading_1_label',
caption = caption, caption = caption,

View File

@@ -187,21 +187,21 @@ end
-- Functions used to format production values -- Functions used to format production values
-- @section formating -- @section formating
--- Returns a color value bassed on the value that was given --- Returns a color value based on the value that was given
-- @tparam number clamp value which seperates the different colours -- @tparam number cutoff value which separates the different colours
-- @tparam number active_value first value tested, tested against clamp -- @tparam number active_value first value tested, tested against cutoff
-- @tparam number passive_value second value tested, tested against 0 -- @tparam number passive_value second value tested, tested against 0 when active is 0
-- @treturn table contains r, g,b keys -- @treturn table contains r,g,b keys
function Production.get_color(clamp, active_value, passive_value) function Production.get_color(cutoff, active_value, passive_value)
if active_value > clamp then if active_value > cutoff then
return Colors.light_green return Colors.light_green
elseif active_value < -clamp then elseif active_value < -cutoff then
return Colors.indian_red return Colors.indian_red
elseif active_value ~= 0 then elseif active_value ~= 0 then
return Colors.orange return Colors.orange
elseif passive_value and passive_value > 0 then elseif passive_value and passive_value > 0 then
return Colors.orange return Colors.orange
elseif passive_value and passive_value ~= 0 then elseif passive_value and passive_value < 0 then
return Colors.indian_red return Colors.indian_red
else else
return Colors.grey return Colors.grey

View File

@@ -187,7 +187,8 @@ Gui.element(function(_, parent)
-- Add the external links -- Add the external links
local external_links = title_table(scroll_pane, 235, {'readme.servers-external'}, 2) local external_links = title_table(scroll_pane, 235, {'readme.servers-external'}, 2)
for _, key in ipairs{'discord', 'website', 'patreon', 'status', 'github'} do for _, key in ipairs{'discord', 'website', 'patreon', 'status', 'github'} do
Gui.centered_label(external_links, 110, key:gsub("^%l", string.upper)) local upper_key = key:gsub("^%l", string.upper)
Gui.centered_label(external_links, 110, upper_key)
Gui.centered_label(external_links, 460, {'links.'..key}, {'readme.servers-open-in-browser'}) Gui.centered_label(external_links, 460, {'links.'..key}, {'readme.servers-open-in-browser'})
end end

View File

@@ -440,6 +440,14 @@ Gui.element{
end end
end) end)
-- Used to assign an event to the header label to trigger a toggle
-- @element header_toggle
local header_toggle = Gui.element()
:on_click(function(_, element, event)
event.element = element.parent.alignment[toggle_section.name]
toggle_section:raise_custom_event(event)
end)
-- Draw a section header and main scroll -- Draw a section header and main scroll
-- @element rocket_list_container -- @element rocket_list_container
local section = local section =
@@ -450,7 +458,8 @@ Gui.element(function(_, parent, section_name, table_size)
{'rocket-info.section-caption-'..section_name}, {'rocket-info.section-caption-'..section_name},
{'rocket-info.section-tooltip-'..section_name}, {'rocket-info.section-tooltip-'..section_name},
true, true,
section_name..'-header' section_name..'-header',
header_toggle.name
) )
-- Right aligned button to toggle the section -- Right aligned button to toggle the section
@@ -535,11 +544,6 @@ end
Event.add(defines.events.on_rocket_launched, function(event) Event.add(defines.events.on_rocket_launched, function(event)
local force = event.rocket_silo.force local force = event.rocket_silo.force
update_rocket_gui_all(force.name) update_rocket_gui_all(force.name)
if force.rockets_launched == 1 then
for _, player in pairs(force.players) do
Gui.update_top_flow(player)
end
end
end) end)
--- Update only the progress gui for a force --- Update only the progress gui for a force

View File

@@ -56,8 +56,8 @@ Gui.element(function(_, parent, production_label_data)
end) end)
-- Get the data that is used with the production label -- Get the data that is used with the production label
local function get_production_label_data(name, tooltip, value, secondary) local function get_production_label_data(name, tooltip, value, cutout, secondary)
local data_colour = Production.get_color(config.color_clamp, value, secondary) local data_colour = Production.get_color(config.color_cutoff * cutout, value, secondary)
local surfix, caption = Production.format_number(value) local surfix, caption = Production.format_number(value)
return { return {
@@ -147,10 +147,9 @@ local function get_science_pack_data(player, science_pack)
-- Check that some packs have been made -- Check that some packs have been made
local total = Production.get_production_total(force, science_pack) local total = Production.get_production_total(force, science_pack)
if total.made == 0 then return end
local minute = Production.get_production(force, science_pack, defines.flow_precision_index.one_minute) local minute = Production.get_production(force, science_pack, defines.flow_precision_index.one_minute)
if total.made == 0 then local hour = Production.get_production(force, science_pack, defines.flow_precision_index.one_hour)
return
end
-- Get the icon style -- Get the icon style
local icon_style = 'slot_button' local icon_style = 'slot_button'
@@ -170,17 +169,17 @@ local function get_science_pack_data(player, science_pack)
positive = get_production_label_data( positive = get_production_label_data(
'pos-'..science_pack, 'pos-'..science_pack,
{'science-info.pos-tooltip', total.made}, {'science-info.pos-tooltip', total.made},
minute.made minute.made, hour.made
), ),
negative = get_production_label_data( negative = get_production_label_data(
'neg-'..science_pack, 'neg-'..science_pack,
{'science-info.neg-tooltip', total.used}, {'science-info.neg-tooltip', total.used},
-minute.used -minute.used, hour.used
), ),
net = get_production_label_data( net = get_production_label_data(
'net-'..science_pack, 'net-'..science_pack,
{'science-info.net-tooltip', total.net}, {'science-info.net-tooltip', total.net},
minute.net, minute.net, minute.net > 0 and hour.net or 0,
minute.made+minute.used minute.made+minute.used
) )
} }
@@ -337,7 +336,7 @@ Event.on_nth_tick(60, function()
local scroll_table = container.scroll.table local scroll_table = container.scroll.table
local pack_data = force_pack_data[force_name] local pack_data = force_pack_data[force_name]
if not pack_data then if not pack_data then
-- No data in chache so it needs to be generated -- No data in cache so it needs to be generated
pack_data = {} pack_data = {}
force_pack_data[force_name] = pack_data force_pack_data[force_name] = pack_data
for _, science_pack in ipairs(config) do for _, science_pack in ipairs(config) do
@@ -347,8 +346,8 @@ Event.on_nth_tick(60, function()
end end
else else
-- Data found in chache is no need to generate it -- Data found in cache is no need to generate it
for _, next_data in ipairs(pack_data) do for _, next_data in pairs(pack_data) do
update_science_pack(scroll_table, next_data) update_science_pack(scroll_table, next_data)
end end