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
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
color_clamp=5, --- @setting color_clamp the amount required for the text to show as green or red
color_flux=0.1, --- @setting color_flux the ammount of flucuation allowed in production before icon change
show_eta = true, --- @setting show_eta when true the eta for research completion will be shown
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 amount of fluctuation allowed in production before the icon changes color
'automation-science-pack',
'logistic-science-pack',
'military-science-pack',

View File

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

View File

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

View File

@@ -187,7 +187,8 @@ Gui.element(function(_, parent)
-- Add the external links
local external_links = title_table(scroll_pane, 235, {'readme.servers-external'}, 2)
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'})
end

View File

@@ -440,6 +440,14 @@ Gui.element{
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
-- @element rocket_list_container
local section =
@@ -450,7 +458,8 @@ Gui.element(function(_, parent, section_name, table_size)
{'rocket-info.section-caption-'..section_name},
{'rocket-info.section-tooltip-'..section_name},
true,
section_name..'-header'
section_name..'-header',
header_toggle.name
)
-- Right aligned button to toggle the section
@@ -535,11 +544,6 @@ end
Event.add(defines.events.on_rocket_launched, function(event)
local force = event.rocket_silo.force
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)
--- Update only the progress gui for a force

View File

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