mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-04-09 07:03:53 +02:00
First implementation of summary of feeding and also fix for big feeding (threat was cut)
This commit is contained in:
parent
b5893c9b85
commit
a726a41d00
@ -106,6 +106,47 @@ local function add_stats(player, food, flask_amount,biter_force_name,evo_before_
|
||||
local threat_jump_difference = math.round(formatted_threat_after_feed - threat_before_science_feed,0)
|
||||
local line_log_stats_to_add = table.concat({ formatted_amount .. " " .. formatted_food .. " by " .. colored_player_name .. " to " .. team_strings[get_enemy_team_of(player.force.name)]})
|
||||
|
||||
if global.science_logs_total_north == nil then
|
||||
global.science_logs_total_north = { 0 }
|
||||
table.insert(global.science_logs_total_north, 0)
|
||||
table.insert(global.science_logs_total_north, 0)
|
||||
table.insert(global.science_logs_total_north, 0)
|
||||
table.insert(global.science_logs_total_north, 0)
|
||||
table.insert(global.science_logs_total_north, 0)
|
||||
table.insert(global.science_logs_total_north, 0)
|
||||
global.science_logs_total_south = { 0 }
|
||||
table.insert(global.science_logs_total_south, 0)
|
||||
table.insert(global.science_logs_total_south, 0)
|
||||
table.insert(global.science_logs_total_south, 0)
|
||||
table.insert(global.science_logs_total_south, 0)
|
||||
table.insert(global.science_logs_total_south, 0)
|
||||
table.insert(global.science_logs_total_south, 0)
|
||||
end
|
||||
|
||||
game.print("food is called : ".. player.force.name)
|
||||
local total_science_of_player_force = nil
|
||||
if player.force.name == "north" then
|
||||
total_science_of_player_force = global.science_logs_total_north
|
||||
else
|
||||
total_science_of_player_force = global.science_logs_total_south
|
||||
end
|
||||
|
||||
if food == "automation-science-pack" then
|
||||
total_science_of_player_force[1] = total_science_of_player_force[1] + flask_amount
|
||||
elseif food == "logistic-science-pack" then
|
||||
total_science_of_player_force[2] = total_science_of_player_force[2] + flask_amount
|
||||
elseif food == "military-science-pack" then
|
||||
total_science_of_player_force[3] = total_science_of_player_force[3] + flask_amount
|
||||
elseif food == "chemical-science-pack" then
|
||||
total_science_of_player_force[4] = total_science_of_player_force[4] + flask_amount
|
||||
elseif food == "production-science-pack" then
|
||||
total_science_of_player_force[5] = total_science_of_player_force[5] + flask_amount
|
||||
elseif food == "utility-science-pack" then
|
||||
total_science_of_player_force[6] = total_science_of_player_force[6] + flask_amount
|
||||
elseif food == "space-science-pack" then
|
||||
total_science_of_player_force[7] = total_science_of_player_force[7] + flask_amount
|
||||
end
|
||||
|
||||
if global.science_logs_text then
|
||||
table.insert(global.science_logs_date,1, formatted_feed_time)
|
||||
table.insert(global.science_logs_text,1, line_log_stats_to_add)
|
||||
|
@ -1,10 +1,86 @@
|
||||
-- science logs tab --
|
||||
|
||||
local Tabs = require 'comfy_panel.main'
|
||||
local tables = require "maps.biter_battles_v2.tables"
|
||||
local food_values = tables.food_values
|
||||
|
||||
local function get_science_text(food_name)
|
||||
return table.concat({"[img=item/", food_name, "][color=",food_values[food_name].color, "]", food_values[food_name].name, "[/color]"})
|
||||
end
|
||||
|
||||
local function add_science_logs(element)
|
||||
local t = element.add { type = "table", name = "science_logs_header_table", column_count = 4 }
|
||||
local column_widths = {tonumber(90), tonumber(340), tonumber(170), tonumber(190)}
|
||||
local science_scrollpanel = element.add { type = "scroll-pane", name = "scroll_pane", direction = "vertical", horizontal_scroll_policy = "never", vertical_scroll_policy = "auto"}
|
||||
science_scrollpanel.style.maximal_height = 530
|
||||
local t_summary = science_scrollpanel.add { type = "table", name = "science_logs_summary_header_table", column_count = 3 }
|
||||
local column_widths = {tonumber(250), tonumber(200), tonumber(200)}
|
||||
local headersSummary = {
|
||||
[1] = "Science",
|
||||
[2] = "Total sent by North",
|
||||
[3] = "Total sent by South",
|
||||
}
|
||||
for _, w in ipairs(column_widths) do
|
||||
local label = t_summary.add { type = "label", caption = headersSummary[_] }
|
||||
label.style.minimal_width = w
|
||||
label.style.maximal_width = w
|
||||
label.style.font = "default-bold"
|
||||
label.style.font_color = { r=0.98, g=0.66, b=0.22 }
|
||||
if _ == 1 then
|
||||
label.style.horizontal_align = "center"
|
||||
end
|
||||
end
|
||||
|
||||
if global.science_logs_category_potion == nil then
|
||||
local science_text = get_science_text("automation-science-pack")
|
||||
global.science_logs_category_potion = { science_text }
|
||||
science_text = get_science_text("logistic-science-pack")
|
||||
table.insert(global.science_logs_category_potion, science_text)
|
||||
science_text = get_science_text("military-science-pack")
|
||||
table.insert(global.science_logs_category_potion, science_text)
|
||||
science_text = get_science_text("chemical-science-pack")
|
||||
table.insert(global.science_logs_category_potion, science_text)
|
||||
science_text = get_science_text("production-science-pack")
|
||||
table.insert(global.science_logs_category_potion, science_text)
|
||||
science_text = get_science_text("utility-science-pack")
|
||||
table.insert(global.science_logs_category_potion, science_text)
|
||||
science_text = get_science_text("space-science-pack")
|
||||
table.insert(global.science_logs_category_potion, science_text)
|
||||
end
|
||||
if global.science_logs_total_north == nil then
|
||||
global.science_logs_total_north = { 0 }
|
||||
table.insert(global.science_logs_total_north, 0)
|
||||
table.insert(global.science_logs_total_north, 0)
|
||||
table.insert(global.science_logs_total_north, 0)
|
||||
table.insert(global.science_logs_total_north, 0)
|
||||
table.insert(global.science_logs_total_north, 0)
|
||||
table.insert(global.science_logs_total_north, 0)
|
||||
global.science_logs_total_south = { 0 }
|
||||
table.insert(global.science_logs_total_south, 0)
|
||||
table.insert(global.science_logs_total_south, 0)
|
||||
table.insert(global.science_logs_total_south, 0)
|
||||
table.insert(global.science_logs_total_south, 0)
|
||||
table.insert(global.science_logs_total_south, 0)
|
||||
table.insert(global.science_logs_total_south, 0)
|
||||
end
|
||||
|
||||
for i = 1, 7, 1 do
|
||||
summary_panel_table = science_scrollpanel.add { type = "table", column_count = 3 }
|
||||
local label = summary_panel_table.add { type = "label", name = "science_logs_category_potion" .. i, caption = global.science_logs_category_potion[i] }
|
||||
label.style.minimal_width = column_widths[1]
|
||||
label.style.maximal_width = column_widths[1]
|
||||
label.style.horizontal_align = "center"
|
||||
local label = summary_panel_table.add { type = "label", name = "science_logs_total_north" .. i, caption = global.science_logs_total_north[i] }
|
||||
label.style.minimal_width = column_widths[2]
|
||||
label.style.maximal_width = column_widths[2]
|
||||
local label = summary_panel_table.add { type = "label", name = "science_logs_total_south" .. i, caption = global.science_logs_total_south[i] }
|
||||
label.style.minimal_width = column_widths[3]
|
||||
label.style.maximal_width = column_widths[3]
|
||||
science_scrollpanel.add({type = "line"})
|
||||
end
|
||||
|
||||
science_scrollpanel.add { type = "label", name = "whitespace1", caption = " " }
|
||||
|
||||
local t = science_scrollpanel.add { type = "table", name = "science_logs_header_table", column_count = 4 }
|
||||
local column_widths = {tonumber(75), tonumber(310), tonumber(165), tonumber(230)}
|
||||
local headers = {
|
||||
[1] = "Time",
|
||||
[2] = "Details",
|
||||
@ -22,10 +98,7 @@ local function add_science_logs(element)
|
||||
end
|
||||
end
|
||||
|
||||
-- List management
|
||||
if global.science_logs_date then
|
||||
local science_scrollpanel = element.add { type = "scroll-pane", name = "scroll_pane", direction = "vertical", horizontal_scroll_policy = "never", vertical_scroll_policy = "auto"}
|
||||
science_scrollpanel.style.maximal_height = 530
|
||||
for i = 1, #global.science_logs_date, 1 do
|
||||
science_panel_table = science_scrollpanel.add { type = "table", column_count = 4 }
|
||||
local label = science_panel_table.add { type = "label", name = "science_logs_date" .. i, caption = global.science_logs_date[i] }
|
||||
|
Loading…
x
Reference in New Issue
Block a user