1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-01-10 00:43:27 +02:00

Moved science logs tab to fish tab instead

This commit is contained in:
Masamune 2019-12-31 12:20:37 +01:00
parent ff71c2ac74
commit f2795ee8ec
3 changed files with 76 additions and 102 deletions

View File

@ -3,6 +3,7 @@
local bb_config = require "maps.biter_battles_v2.config"
require "on_tick_schedule"
require "maps.biter_battles_v2.map_settings_tab"
require "maps.biter_battles_v2.sciencelogs_tab"
require "modules.spawners_contain_biters"
require "modules.mineable_wreckage_yields_scrap"

View File

@ -0,0 +1,75 @@
-- science logs tab --
local Tabs = require 'comfy_panel.main'
local function add_science_logs(element)
local t = element.add { type = "table", name = "science_logs_header_table", column_count = 4 }
local column_widths = {tonumber(100), tonumber(400), tonumber(145), tonumber(145)}
for _, w in ipairs(column_widths) do
local label = t.add { type = "label", caption = "" }
label.style.minimal_width = w
label.style.maximal_width = w
end
local headers = {
[1] = "Date",
[2] = "Science details",
[3] = "Evo jump",
[4] = "Threat jump",
}
for k, v in ipairs(headers) do
local label = t.add {
type = "label",
name = "science_logs_panel_header_" .. k,
caption = v
}
label.style.font = "default-bold"
label.style.font_color = { r=0.98, g=0.66, b=0.22 }
end
-- special style on first header
local label = t["science_logs_panel_header_1"]
label.style.minimal_width = 36
label.style.maximal_width = 36
label.style.horizontal_align = "right"
-- List management
local science_panel_table = element.add { type = "scroll-pane", name = "scroll_pane", direction = "vertical", horizontal_scroll_policy = "never", vertical_scroll_policy = "auto"}
science_panel_table.style.maximal_height = 530
science_panel_table = science_panel_table.add { type = "table", name = "science_panel_table", column_count = 4, draw_horizontal_lines = true }
if global.science_logs_date then
for i = 1, #global.science_logs_date, 1 do
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]
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] }
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] }
label.style.minimal_width = column_widths[4]
label.style.maximal_width = column_widths[4]
end
end
end
local build_config_gui = (function (player, frame)
frame.clear()
add_science_logs(frame)
end)
local function on_gui_click(event)
if not event.element then return end
if not event.element.valid then return end
end
comfy_panel_tabs["ScienceLogs"] = build_config_gui
local event = require 'utils.event'
event.add(defines.events.on_gui_click, on_gui_click)

View File

@ -103,20 +103,6 @@ local function draw_manager_button(player)
button.style.bottom_padding = 2
end
local function draw_science_stats_button(player)
if player.gui.top["stats_toggle_button"] then player.gui.top["stats_toggle_button"].destroy() end
local button = player.gui.top.add({type = "sprite-button", name = "stats_toggle_button", caption = "Science logs", tooltip = tooltip})
button.style.font = "heading-2"
button.style.font_color = {r = 0.88, g = 0.55, b = 0.11}
button.style.minimal_height = 38
button.style.minimal_width = 120
button.style.top_padding = 2
button.style.left_padding = 0
button.style.right_padding = 0
button.style.bottom_padding = 2
end
local function draw_manager_gui(player)
if player.gui.center["team_manager_gui"] then player.gui.center["team_manager_gui"].destroy() end
@ -228,86 +214,6 @@ local function draw_manager_gui(player)
button.style.font = "heading-2"
end
local function draw_stats_gui(player)
if player.gui.center["stats_gui"] then player.gui.center["stats_gui"].destroy() end
local frame = player.gui.center.add({type = "frame", name = "stats_gui", caption = "Science logs", direction = "vertical"})
local t = frame.add { type = "table", name = "science_logs_header_table", column_count = 4 }
local column_widths = {tonumber(150), tonumber(400), tonumber(150), tonumber(150)}
for _, w in ipairs(column_widths) do
local label = t.add { type = "label", caption = "" }
label.style.minimal_width = w
label.style.maximal_width = w
end
local headers = {
[1] = "Date",
[2] = "Science details",
[3] = "Evo jump",
[4] = "Threat jump",
}
for k, v in ipairs(headers) do
local label = t.add {
type = "label",
name = "science_logs_panel_header_" .. k,
caption = v
}
label.style.font = "default-bold"
label.style.font_color = { r=0.98, g=0.66, b=0.22 }
end
-- special style on first header
local label = t["science_logs_panel_header_1"]
label.style.minimal_width = 36
label.style.maximal_width = 36
label.style.horizontal_align = "right"
-- List management
local science_panel_table = frame.add { type = "scroll-pane", name = "scroll_pane", direction = "vertical", horizontal_scroll_policy = "never", vertical_scroll_policy = "auto"}
science_panel_table.style.maximal_height = 530
science_panel_table = science_panel_table.add { type = "table", name = "science_panel_table", column_count = 4, draw_horizontal_lines = true }
if global.science_logs_date then
for i = 1, #global.science_logs_date, 1 do
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]
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] }
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] }
label.style.minimal_width = column_widths[4]
label.style.maximal_width = column_widths[4]
end
end
frame.add({type = "label", caption = ""})
local t = frame.add({type = "table", name = "stats_bottom_buttons", column_count = 4})
local button = t.add({
type = "button",
name = "stats_close",
caption = "Close",
tooltip = "Close this window."
})
button.style.font = "heading-2"
end
local function stats_gui_click(event)
local player = game.players[event.player_index]
local name = event.element.name
if name == "stats_close" then
player.gui.center["stats_gui"].destroy()
return
end
end
local function set_custom_team_name(force_name, team_name)
if team_name == "" then global.tm_custom_name[force_name] = nil return end
if not team_name then global.tm_custom_name[force_name] = nil return end
@ -435,13 +341,6 @@ local function on_gui_click(event)
return
end
if name == "stats_toggle_button" then
if player.gui.center["stats_gui"] then player.gui.center["stats_gui"].destroy() return end
draw_stats_gui(player)
end
if player.gui.center["stats_gui"] then stats_gui_click(event) end
if player.gui.center["team_manager_gui"] then team_manager_gui_click(event) end
if player.gui.center["custom_team_name_gui"] then
@ -463,7 +362,6 @@ end
local function on_player_joined_game(event)
draw_manager_button(game.players[event.player_index])
draw_science_stats_button(game.players[event.player_index])
end
local function on_init(surface)