mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-01-24 03:47:58 +02:00
Merge pull request #127 from Masamune0/mutagenLogFilters
Mutagen log filters : bug fix and 3 filters added (force, science, evo jump)
This commit is contained in:
commit
5a87b8e01b
@ -427,7 +427,9 @@ end
|
||||
Public.raise_evo = function()
|
||||
if global.freeze_players then return end
|
||||
if not global.training_mode and (#game.forces.north.connected_players == 0 or #game.forces.south.connected_players == 0) then return end
|
||||
if not global.total_passive_feed_redpotion then global.total_passive_feed_redpotion = 0 end
|
||||
local amount = math.ceil(global.difficulty_vote_value * global.evo_raise_counter)
|
||||
global.total_passive_feed_redpotion = global.total_passive_feed_redpotion + amount
|
||||
local biter_teams = {["north_biters"] = "north", ["south_biters"] = "south"}
|
||||
local a_team_has_players = false
|
||||
for bf, pf in pairs(biter_teams) do
|
||||
|
@ -107,7 +107,27 @@ local function add_stats(player, food, flask_amount,biter_force_name,evo_before_
|
||||
local threat_jump = table.concat({threat_before_science_feed .. " to ".. formatted_threat_after_feed})
|
||||
local evo_jump_difference = math.round(formatted_evo_after_feed - evo_before_science_feed,1)
|
||||
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)]})
|
||||
local line_log_stats_to_add = table.concat({ formatted_amount .. " " .. formatted_food .. " by " .. colored_player_name .. " to " })
|
||||
local team_name_fed_by_science = get_enemy_team_of(player.force.name)
|
||||
|
||||
if global.science_logs_total_north == nil then
|
||||
global.science_logs_total_north = { 0 }
|
||||
global.science_logs_total_south = { 0 }
|
||||
for a = 1, flask_amount, 7 do
|
||||
table.insert(global.science_logs_total_north, 0)
|
||||
table.insert(global.science_logs_total_south, 0)
|
||||
end
|
||||
end
|
||||
|
||||
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
|
||||
|
||||
local indexScience = tables.food_long_to_short[food].indexScience
|
||||
total_science_of_player_force[indexScience] = total_science_of_player_force[indexScience] + flask_amount
|
||||
|
||||
if global.science_logs_text then
|
||||
table.insert(global.science_logs_date,1, formatted_feed_time)
|
||||
@ -116,6 +136,8 @@ local function add_stats(player, food, flask_amount,biter_force_name,evo_before_
|
||||
table.insert(global.science_logs_evo_jump_difference,1, evo_jump_difference)
|
||||
table.insert(global.science_logs_threat,1, threat_jump)
|
||||
table.insert(global.science_logs_threat_jump_difference,1, threat_jump_difference)
|
||||
table.insert(global.science_logs_fed_team,1, team_name_fed_by_science)
|
||||
table.insert(global.science_logs_food_name,1, food)
|
||||
else
|
||||
global.science_logs_date = { formatted_feed_time }
|
||||
global.science_logs_text = { line_log_stats_to_add }
|
||||
@ -123,6 +145,8 @@ local function add_stats(player, food, flask_amount,biter_force_name,evo_before_
|
||||
global.science_logs_evo_jump_difference = { evo_jump_difference }
|
||||
global.science_logs_threat = { threat_jump }
|
||||
global.science_logs_threat_jump_difference = { threat_jump_difference }
|
||||
global.science_logs_fed_team = { team_name_fed_by_science }
|
||||
global.science_logs_food_name = { food }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,10 +1,124 @@
|
||||
-- science logs tab --
|
||||
|
||||
local Tabs = require 'comfy_panel.main'
|
||||
local tables = require "maps.biter_battles_v2.tables"
|
||||
local event = require 'utils.event'
|
||||
local bb_config = require "maps.biter_battles_v2.config"
|
||||
local food_values = tables.food_values
|
||||
local food_long_and_short = tables.food_long_and_short
|
||||
local food_long_to_short = tables.food_long_to_short
|
||||
local forces_list = tables.forces_list
|
||||
local science_list = tables.science_list
|
||||
local evofilter_list = tables.evofilter_list
|
||||
local food_value_table_version = tables.food_value_table_version
|
||||
|
||||
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 function initialize_dropdown_users_choice()
|
||||
global.dropdown_users_choice_force = {}
|
||||
global.dropdown_users_choice_science = {}
|
||||
global.dropdown_users_choice_evo_filter = {}
|
||||
end
|
||||
|
||||
local function get_science_text(food_name,food_short_name)
|
||||
return table.concat({"[img=item/", food_name, "][color=",food_values[food_name].color, "]", food_short_name, "[/color]"})
|
||||
end
|
||||
|
||||
local function add_science_logs(player, element)
|
||||
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
|
||||
|
||||
if global.science_logs_category_potion == nil then
|
||||
global.science_logs_category_potion = { }
|
||||
for i = 1, 7 do
|
||||
table.insert(global.science_logs_category_potion, get_science_text(food_long_and_short[i].long_name, food_long_and_short[i].short_name))
|
||||
end
|
||||
end
|
||||
if global.science_logs_total_north == nil then
|
||||
global.science_logs_total_north = { 0 }
|
||||
global.science_logs_total_south = { 0 }
|
||||
for i = 1, 7 do
|
||||
table.insert(global.science_logs_total_north, 0)
|
||||
table.insert(global.science_logs_total_south, 0)
|
||||
end
|
||||
end
|
||||
|
||||
local t_summary = science_scrollpanel.add { type = "table", name = "science_logs_summary_header_table", column_count = 8 }
|
||||
local width_summary_columns = tonumber(94)
|
||||
local width_summary_first_column = tonumber(110)
|
||||
local column_widths = {width_summary_first_column, width_summary_columns, width_summary_columns, width_summary_columns, width_summary_columns, width_summary_columns, width_summary_columns, width_summary_columns}
|
||||
local headersSummary = {
|
||||
[1] = "",
|
||||
[2] = global.science_logs_category_potion[1],
|
||||
[3] = global.science_logs_category_potion[2],
|
||||
[4] = global.science_logs_category_potion[3],
|
||||
[5] = global.science_logs_category_potion[4],
|
||||
[6] = global.science_logs_category_potion[5],
|
||||
[7] = global.science_logs_category_potion[6],
|
||||
[8] = global.science_logs_category_potion[7]
|
||||
}
|
||||
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
|
||||
end
|
||||
|
||||
summary_panel_table = science_scrollpanel.add { type = "table", column_count = 8 }
|
||||
local label = summary_panel_table.add { type = "label", name = "science_logs_total_north_header", caption = "Total sent by north" }
|
||||
label.style.minimal_width = width_summary_first_column
|
||||
label.style.maximal_width = width_summary_first_column
|
||||
for i = 1, 7 do
|
||||
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 = width_summary_columns
|
||||
label.style.maximal_width = width_summary_columns
|
||||
end
|
||||
science_scrollpanel.add({type = "line"})
|
||||
|
||||
summary_panel_table2 = science_scrollpanel.add { type = "table", column_count = 8 }
|
||||
local label = summary_panel_table2.add { type = "label", name = "science_logs_total_south_header", caption = "Total sent by south" }
|
||||
label.style.minimal_width = width_summary_first_column
|
||||
label.style.maximal_width = width_summary_first_column
|
||||
for i = 1, 7 do
|
||||
local label = summary_panel_table2.add { type = "label", name = "science_logs_total_south" .. i, caption = global.science_logs_total_south[i] }
|
||||
label.style.minimal_width = width_summary_columns
|
||||
label.style.maximal_width = width_summary_columns
|
||||
end
|
||||
science_scrollpanel.add({type = "line"})
|
||||
|
||||
summary_panel_table3 = science_scrollpanel.add { type = "table", column_count = 8 }
|
||||
local label = summary_panel_table3.add { type = "label", name = "science_logs_total_passive_feed_header", caption = "Total passive feed" }
|
||||
label.style.minimal_width = width_summary_first_column
|
||||
label.style.maximal_width = width_summary_first_column
|
||||
for i = 1, 7 do
|
||||
local text_passive_feed = "0"
|
||||
if global.total_passive_feed_redpotion ~= nil then
|
||||
text_passive_feed = math.round(global.total_passive_feed_redpotion * food_value_table_version[1] / food_value_table_version[i],1)
|
||||
end
|
||||
local label = summary_panel_table3.add { type = "label", name = "science_logs_passive_feed" .. i, caption = text_passive_feed }
|
||||
label.style.minimal_width = width_summary_columns
|
||||
label.style.maximal_width = width_summary_columns
|
||||
end
|
||||
science_scrollpanel.add({type = "line"})
|
||||
|
||||
if global.dropdown_users_choice_force == nil then
|
||||
initialize_dropdown_users_choice()
|
||||
end
|
||||
if global.dropdown_users_choice_force[player.name] == nil then
|
||||
global.dropdown_users_choice_force[player.name] = 1
|
||||
end
|
||||
if global.dropdown_users_choice_science[player.name] == nil then
|
||||
global.dropdown_users_choice_science[player.name] = 1
|
||||
end
|
||||
if global.dropdown_users_choice_evo_filter[player.name] == nil then
|
||||
global.dropdown_users_choice_evo_filter[player.name] = 1
|
||||
end
|
||||
|
||||
local t_filter = science_scrollpanel.add { type = "table", name = "science_logs_filter_table", column_count = 3 }
|
||||
|
||||
local dropdown_force = t_filter.add { name = "dropdown-force", type = "drop-down", items = forces_list, selected_index = global.dropdown_users_choice_force[player.name] }
|
||||
local dropdown_science = t_filter.add { name = "dropdown-science", type = "drop-down", items = science_list, selected_index = global.dropdown_users_choice_science[player.name] }
|
||||
local dropdown_evofilter = t_filter.add { name = "dropdown-evofilter", type = "drop-down", items = evofilter_list, selected_index = global.dropdown_users_choice_evo_filter[player.name] }
|
||||
|
||||
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,33 +136,89 @@ local function add_science_logs(element)
|
||||
end
|
||||
end
|
||||
|
||||
-- List management
|
||||
local n = bb_config.north_side_team_name
|
||||
local s = bb_config.south_side_team_name
|
||||
if global.tm_custom_name["north"] then n = global.tm_custom_name["north"] end
|
||||
if global.tm_custom_name["south"] then s = global.tm_custom_name["south"] end
|
||||
local team_strings = {
|
||||
["north"] = table.concat({"[color=120, 120, 255]", n, "[/color]"}),
|
||||
["south"] = table.concat({"[color=255, 65, 65]", s, "[/color]"})
|
||||
}
|
||||
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] }
|
||||
label.style.minimal_width = column_widths[1]
|
||||
label.style.maximal_width = column_widths[1]
|
||||
label.style.horizontal_align = "center"
|
||||
local label = science_panel_table.add { type = "label", name = "science_logs_text" .. i, caption = global.science_logs_text[i] }
|
||||
label.style.minimal_width = column_widths[2]
|
||||
label.style.maximal_width = column_widths[2]
|
||||
local label = science_panel_table.add { type = "label", name = "science_logs_evo_jump" .. i, caption = global.science_logs_evo_jump[i].." [color=200,200,200](+"..global.science_logs_evo_jump_difference[i]..")[/color]" }
|
||||
label.style.minimal_width = column_widths[3]
|
||||
label.style.maximal_width = column_widths[3]
|
||||
local label = science_panel_table.add { type = "label", name = "science_logs_threat" .. i, caption = global.science_logs_threat[i].." [color=200,200,200](+"..global.science_logs_threat_jump_difference[i]..")[/color]" }
|
||||
label.style.minimal_width = column_widths[4]
|
||||
label.style.maximal_width = column_widths[4]
|
||||
science_scrollpanel.add({type = "line"})
|
||||
local real_force_name = global.science_logs_fed_team[i]
|
||||
local custom_force_name = team_strings[real_force_name];
|
||||
local easy_food_name = food_long_to_short[global.science_logs_food_name[i]].short_name
|
||||
|
||||
if dropdown_force.selected_index == 1 or real_force_name:match(dropdown_force.get_item(dropdown_force.selected_index)) then
|
||||
if dropdown_science.selected_index == 1
|
||||
or (dropdown_science.selected_index == 2 and (easy_food_name:match("space") or easy_food_name:match("utility") or easy_food_name:match("production")))
|
||||
or (dropdown_science.selected_index == 3 and (easy_food_name:match("space") or easy_food_name:match("utility") or easy_food_name:match("production")or easy_food_name:match("chemical")))
|
||||
or (dropdown_science.selected_index == 4 and (easy_food_name:match("space") or easy_food_name:match("utility") or easy_food_name:match("production")or easy_food_name:match("chemical") or easy_food_name:match("military")))
|
||||
or easy_food_name:match(dropdown_science.get_item(dropdown_science.selected_index))
|
||||
then
|
||||
if dropdown_evofilter.selected_index == 1
|
||||
or (dropdown_evofilter.selected_index == 2 and (global.science_logs_evo_jump_difference[i] > 0))
|
||||
or (dropdown_evofilter.selected_index == 3 and (global.science_logs_evo_jump_difference[i] >= 10))
|
||||
or (dropdown_evofilter.selected_index == 4 and (global.science_logs_evo_jump_difference[i] >= 5))
|
||||
or (dropdown_evofilter.selected_index == 5 and (global.science_logs_evo_jump_difference[i] >= 4))
|
||||
or (dropdown_evofilter.selected_index == 6 and (global.science_logs_evo_jump_difference[i] >= 3))
|
||||
or (dropdown_evofilter.selected_index == 7 and (global.science_logs_evo_jump_difference[i] >= 2))
|
||||
or (dropdown_evofilter.selected_index == 8 and (global.science_logs_evo_jump_difference[i] >= 1))
|
||||
then
|
||||
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] }
|
||||
label.style.minimal_width = column_widths[1]
|
||||
label.style.maximal_width = column_widths[1]
|
||||
label.style.horizontal_align = "center"
|
||||
local label = science_panel_table.add { type = "label", name = "science_logs_text" .. i, caption = global.science_logs_text[i] .. custom_force_name }
|
||||
label.style.minimal_width = column_widths[2]
|
||||
label.style.maximal_width = column_widths[2]
|
||||
local label = science_panel_table.add { type = "label", name = "science_logs_evo_jump" .. i, caption = global.science_logs_evo_jump[i].." [color=200,200,200](+"..global.science_logs_evo_jump_difference[i]..")[/color]" }
|
||||
label.style.minimal_width = column_widths[3]
|
||||
label.style.maximal_width = column_widths[3]
|
||||
local label = science_panel_table.add { type = "label", name = "science_logs_threat" .. i, caption = global.science_logs_threat[i].." [color=200,200,200](+"..global.science_logs_threat_jump_difference[i]..")[/color]" }
|
||||
label.style.minimal_width = column_widths[4]
|
||||
label.style.maximal_width = column_widths[4]
|
||||
science_scrollpanel.add({type = "line"})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function comfy_panel_get_active_frame(player)
|
||||
if not player.gui.left.comfy_panel then return false end
|
||||
if not player.gui.left.comfy_panel.tabbed_pane.selected_tab_index then return player.gui.left.comfy_panel.tabbed_pane.tabs[1].content end
|
||||
return player.gui.left.comfy_panel.tabbed_pane.tabs[player.gui.left.comfy_panel.tabbed_pane.selected_tab_index].content
|
||||
end
|
||||
|
||||
local build_config_gui = (function (player, frame)
|
||||
frame.clear()
|
||||
add_science_logs(frame)
|
||||
local frame_sciencelogs = comfy_panel_get_active_frame(player)
|
||||
frame_sciencelogs.clear()
|
||||
add_science_logs(player, frame_sciencelogs)
|
||||
end)
|
||||
|
||||
|
||||
local function on_gui_selection_state_changed(event)
|
||||
local player = game.players[event.player_index]
|
||||
local name = event.element.name
|
||||
if global.dropdown_users_choice_force == nil then
|
||||
initialize_dropdown_users_choice()
|
||||
end
|
||||
if name == "dropdown-force" then
|
||||
global.dropdown_users_choice_force[player.name] = event.element.selected_index
|
||||
end
|
||||
if name == "dropdown-science" then
|
||||
global.dropdown_users_choice_science[player.name] = event.element.selected_index
|
||||
end
|
||||
if name == "dropdown-evofilter" then
|
||||
global.dropdown_users_choice_evo_filter[player.name] = event.element.selected_index
|
||||
end
|
||||
build_config_gui(player, frame_sciencelogs)
|
||||
end
|
||||
|
||||
event.add(defines.events.on_gui_selection_state_changed, on_gui_selection_state_changed)
|
||||
|
||||
comfy_panel_tabs["MutagenLog"] = build_config_gui
|
@ -46,4 +46,28 @@ Public.food_names = {
|
||||
["space-science-pack"] = true
|
||||
}
|
||||
|
||||
Public.food_long_and_short = {
|
||||
[1] = {short_name= "automation", long_name = "automation-science-pack"},
|
||||
[2] = {short_name= "logistic", long_name = "logistic-science-pack"},
|
||||
[3] = {short_name= "military", long_name = "military-science-pack"},
|
||||
[4] = {short_name= "chemical", long_name = "chemical-science-pack"},
|
||||
[5] = {short_name= "production", long_name = "production-science-pack"},
|
||||
[6] = {short_name= "utility", long_name = "utility-science-pack"},
|
||||
[7] = {short_name= "space", long_name = "space-science-pack"}
|
||||
}
|
||||
|
||||
Public.food_long_to_short = {
|
||||
["automation-science-pack"] = {short_name= "automation", indexScience = 1},
|
||||
["logistic-science-pack"] = {short_name= "logistic", indexScience = 2},
|
||||
["military-science-pack"] = {short_name= "military", indexScience = 3},
|
||||
["chemical-science-pack"] = {short_name= "chemical", indexScience = 4},
|
||||
["production-science-pack"] = {short_name= "production", indexScience = 5},
|
||||
["utility-science-pack"] = {short_name= "utility", indexScience = 6},
|
||||
["space-science-pack"] = {short_name= "space", indexScience = 7}
|
||||
}
|
||||
Public.forces_list = { "all teams", "north", "south" }
|
||||
Public.science_list = { "all science", "very high tier (space, utility, production)", "high tier (space, utility, production, chemical)", "mid+ tier (space, utility, production, chemical, military)","space","utility","production","chemical","military", "logistic", "automation" }
|
||||
Public.evofilter_list = { "all evo jump", "no 0 evo jump", "10+ only","5+ only","4+ only","3+ only","2+ only","1+ only" }
|
||||
Public.food_value_table_version = { Public.food_values["automation-science-pack"].value, Public.food_values["logistic-science-pack"].value, Public.food_values["military-science-pack"].value, Public.food_values["chemical-science-pack"].value, Public.food_values["production-science-pack"].value, Public.food_values["utility-science-pack"].value, Public.food_values["space-science-pack"].value}
|
||||
|
||||
return Public
|
Loading…
x
Reference in New Issue
Block a user