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

239 lines
7.2 KiB
Lua
Raw Normal View History

-- This file is part of thesixthroc's Pirate Ship softmod, licensed under GPLv3 and stored at https://github.com/danielmartin0/ComfyFactorio-Pirates.
2021-10-13 10:21:53 +02:00
2022-03-19 23:20:55 +02:00
-- local Memory = require 'maps.pirates.memory'
-- local Common = require 'maps.pirates.common'
2021-10-13 10:21:53 +02:00
local CoreData = require 'maps.pirates.coredata'
2022-03-19 23:20:55 +02:00
-- local Utils = require 'maps.pirates.utils_local'
-- local Math = require 'maps.pirates.math'
-- local Surfaces = require 'maps.pirates.surfaces.surfaces'
-- local Lobby = require 'maps.pirates.surfaces.lobby'
local _inspect = require 'utils.inspect'.inspect
-- local Boats = require 'maps.pirates.structures.boats.boats'
2021-10-13 10:21:53 +02:00
local GuiCommon = require 'maps.pirates.gui.common'
local Public = {}
local window_name = 'info'
2022-02-24 21:39:03 +02:00
local width = 430
2021-10-13 10:21:53 +02:00
function Public.toggle_window(player)
2022-03-19 23:20:55 +02:00
local flow, flow2, flow3, flow4
2021-10-13 10:21:53 +02:00
if player.gui.screen[window_name .. '_piratewindow'] then player.gui.screen[window_name .. '_piratewindow'].destroy() return end
2022-03-19 23:20:55 +02:00
2021-10-13 10:21:53 +02:00
flow = player.gui.screen.add{
type = 'tabbed-pane',
name = window_name .. '_piratewindow',
direction = 'vertical'
}
flow.location = {x = 90, y = 90}
flow.selected_tab_index = 1
flow.style = 'frame_tabbed_pane'
2022-02-24 21:39:03 +02:00
flow.style.width = width
2021-10-13 10:21:53 +02:00
flow.style.height = 420
flow2 = Public.flow_add_info_tab(flow, {'pirates.gui_info_info'})
2021-10-13 10:21:53 +02:00
2022-03-19 23:20:55 +02:00
flow3 = flow2.parent.last_info_flow_1.last_info_flow_2
flow4 = flow3.add{type = "label", caption = {"pirates.softmod_info_body_1"}}
flow4.style.font_color = GuiCommon.friendly_font_color
flow4.style.single_line = false
flow4.style.font = 'debug'
flow4.style.top_margin = -2
flow4.style.bottom_margin = 0
-- flow4.style.bottom_margin = 16
2021-10-13 10:21:53 +02:00
Public.flow_add_info_sections(flow2, {'game_description'})
flow2 = Public.flow_add_info_tab(flow, {'pirates.gui_info_updates'})
2021-10-13 10:21:53 +02:00
2022-05-06 14:43:59 +02:00
Public.flow_add_info_sections(flow2, {'updates'})
-- Public.flow_add_info_sections(flow2, {'updates', 'bugs'})
2021-10-13 10:21:53 +02:00
flow2 = Public.flow_add_info_tab(flow, {'pirates.gui_info_tips'})
2021-10-13 10:21:53 +02:00
Public.flow_add_info_sections(flow2, {'new_players', 'tips'})
flow2 = Public.flow_add_info_tab(flow, {'pirates.gui_info_credits'})
2021-10-13 10:21:53 +02:00
Public.flow_add_info_sections(flow2, {'credits'})
end
function Public.flow_add_info_sections(flow, sections_list)
local flow2
for j = 1, #sections_list do
local i = sections_list[j]
2022-03-19 23:20:55 +02:00
2021-10-13 10:21:53 +02:00
flow2 = flow.add{type = "label", caption = {"pirates.softmod_info_" .. i .. "_1"}}
flow2.style.font_color = GuiCommon.friendly_font_color
flow2.style.single_line = false
flow2.style.font = 'heading-3'
flow2.style.bottom_margin = -4
flow2 = flow.add{type = "label", caption = {"pirates.softmod_info_" .. i .. "_2"}}
flow2.style.font_color = GuiCommon.friendly_font_color
flow2.style.single_line = false
flow2.style.font = 'default'
flow2.style.bottom_margin = 12
flow2.style.left_margin = 8
end
end
function Public.flow_add_info_tab(flow, tab_name)
local tab, contents, ret, flow3, flow4, flow5
tab = flow.add{type='tab', caption=tab_name}
tab.style = 'frame_tab'
contents = flow.add({
type = 'frame',
direction = 'vertical',
})
contents.style.vertically_stretchable = true
2022-02-24 21:39:03 +02:00
contents.style.width = width
2021-10-13 10:21:53 +02:00
contents.style.natural_height = 2000
contents.style.top_margin = -8
contents.style.bottom_margin = -12
contents.style.left_margin = -7
contents.style.right_margin = -11
flow3 = contents.add({
type = 'flow',
name = 'header_flow_1',
direction = 'horizontal',
})
flow3.style.horizontally_stretchable = true
flow3.style.horizontal_align = 'center'
flow4 = flow3.add({
type = 'flow',
name = 'header_flow_2',
direction = 'vertical',
})
flow4.style.horizontally_stretchable = true
flow4.style.horizontal_align = 'center'
flow5 = flow4.add{type = "label", caption = {"", {"pirates.softmod_info_header_before_version_number"}, CoreData.version_string, {"pirates.softmod_info_header_after_version_number"}}}
flow5.style.font_color = GuiCommon.friendly_font_color
flow5.style.font = 'heading-1'
flow5.style.bottom_margin = 2
flow5 = flow4.add{type = "label", caption = {"pirates.softmod_info_body_promote"}}
flow5.style.font_color = GuiCommon.friendly_font_color
flow5.style.single_line = false
flow5.style.font = 'default-small'
flow5.style.top_margin = -12
flow5.style.bottom_margin = 8
ret = contents.add({
type = 'flow',
name = 'main_flow_1',
direction = 'vertical',
})
ret.style.horizontally_stretchable = true
2022-03-11 12:40:55 +02:00
flow3 = contents.add({
type = 'flow',
name = 'last_info_flow_1',
direction = 'horizontal',
})
flow3.style.horizontally_stretchable = true
flow3.style.horizontal_align = 'center'
flow4 = flow3.add({
type = 'flow',
name = 'last_info_flow_2',
direction = 'vertical',
})
flow4.style.horizontally_stretchable = true
flow4.style.horizontal_align = 'center'
2021-10-13 10:21:53 +02:00
flow3 = contents.add({
type = 'flow',
direction = 'vertical',
})
flow3.style.vertically_stretchable = true
flow3.style.horizontally_stretchable = true
flow3 = contents.add({
type = 'flow',
direction = 'horizontal',
})
flow3.style.horizontally_stretchable = true
flow3.style.horizontal_align = 'center'
flow4 = flow3.add{type = "label", caption = {"pirates.softmod_info_body_clicky"}}
flow4.style.font_color = GuiCommon.friendly_font_color
flow4.style.single_line = false
flow4.style.font = 'default'
flow4.style.bottom_margin = 4
flow4.style.top_margin = 3
flow.add_tab(tab, contents)
return ret
end
function Public.click(event)
local player = game.players[event.element.player_index]
2022-03-19 23:20:55 +02:00
-- local name = 'info'
2021-10-13 10:21:53 +02:00
local element = event.element
local eventtype = element.type
if not player.gui.screen[window_name .. '_piratewindow'] then return end
2022-03-19 23:20:55 +02:00
-- local memory = Memory.get_crew_memory()
2021-10-13 10:21:53 +02:00
if eventtype ~= 'tab' and (
element.name == (window_name .. '_piratewindow') or
(element.parent and element.parent.name == (window_name .. '_piratewindow')) or
(element.parent and element.parent.parent and element.parent.parent.name == (window_name .. '_piratewindow')) or
(element.parent and element.parent.parent and element.parent.parent.parent and element.parent.parent.parent.name == (window_name .. '_piratewindow')) or
(element.parent and element.parent.parent and element.parent.parent.parent and element.parent.parent.parent.parent and element.parent.parent.parent.parent.name == (window_name .. '_piratewindow')) or
(element.parent and element.parent.parent and element.parent.parent.parent and element.parent.parent.parent.parent and element.parent.parent.parent.parent.parent and element.parent.parent.parent.parent.parent.name == (window_name .. '_piratewindow'))
2022-03-19 23:20:55 +02:00
) then
2021-10-13 10:21:53 +02:00
Public.toggle_window(player)
end
end
2022-03-13 03:44:32 +02:00
2022-03-19 23:20:55 +02:00
-- function Public.regular_update(player)
2022-03-13 03:44:32 +02:00
2022-03-19 23:20:55 +02:00
-- end
2022-03-13 03:44:32 +02:00
function Public.full_update(player)
2022-03-20 13:41:23 +02:00
if Public.regular_update then Public.regular_update(player) end
2021-10-13 10:21:53 +02:00
if not player.gui.screen[window_name .. '_piratewindow'] then return end
local flow = player.gui.screen[window_name .. '_piratewindow']
local flow2 = flow
-- warning, if you make these too small, it loses 'Click to dismiss.'
if flow2.selected_tab_index == 1 then
2022-02-24 21:39:03 +02:00
flow2.style.height = 400
2021-10-13 10:21:53 +02:00
elseif flow2.selected_tab_index == 2 then
2022-05-30 11:07:49 +02:00
flow2.style.height = 520
2021-10-13 10:21:53 +02:00
elseif flow2.selected_tab_index == 3 then
2022-06-01 22:01:00 +02:00
flow2.style.height = 580
2021-10-13 10:21:53 +02:00
elseif flow2.selected_tab_index == 4 then
2022-05-07 22:41:45 +02:00
flow2.style.height = 360
2021-10-13 10:21:53 +02:00
end
end
return Public