2024-09-07 23:19:03 +01:00
---@diagnostic disable: inject-field
2024-09-10 11:29:44 +01:00
-- This file is part of thesixthroc's Pirate Ship softmod, licensed under GPLv3 and stored at https://github.com/ComfyFactory/ComfyFactorio and https://github.com/danielmartin0/ComfyFactorio-Pirates.
2022-06-01 19:50:36 +01:00
2021-10-13 09:21:53 +01:00
2022-03-19 21:20:55 +00:00
-- local Memory = require 'maps.pirates.memory'
-- local Common = require 'maps.pirates.common'
2021-10-13 09:21:53 +01:00
local CoreData = require ' maps.pirates.coredata '
2022-03-19 21:20:55 +00: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 09:21:53 +01:00
local GuiCommon = require ' maps.pirates.gui.common '
local Public = { }
local window_name = ' info '
2024-09-07 17:37:24 +01:00
local width = 400
2021-10-13 09:21:53 +01:00
function Public . toggle_window ( player )
2022-03-19 21:20:55 +00:00
local flow , flow2 , flow3 , flow4
2021-10-13 09:21:53 +01:00
if player.gui . screen [ window_name .. ' _piratewindow ' ] then player.gui . screen [ window_name .. ' _piratewindow ' ] . destroy ( ) return end
2022-03-19 21:20:55 +00:00
2021-10-13 09:21:53 +01: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 19:39:03 +00:00
flow.style . width = width
2021-10-13 09:21:53 +01:00
flow.style . height = 420
2022-05-29 12:36:27 +01:00
flow2 = Public.flow_add_info_tab ( flow , { ' pirates.gui_info_info ' } )
2021-10-13 09:21:53 +01:00
2022-03-19 21:20:55 +00: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 09:21:53 +01:00
Public.flow_add_info_sections ( flow2 , { ' game_description ' } )
2022-05-29 12:36:27 +01:00
flow2 = Public.flow_add_info_tab ( flow , { ' pirates.gui_info_updates ' } )
2021-10-13 09:21:53 +01:00
2022-05-06 13:43:59 +01:00
Public.flow_add_info_sections ( flow2 , { ' updates ' } )
-- Public.flow_add_info_sections(flow2, {'updates', 'bugs'})
2021-10-13 09:21:53 +01:00
2022-05-29 12:36:27 +01:00
flow2 = Public.flow_add_info_tab ( flow , { ' pirates.gui_info_tips ' } )
2021-10-13 09:21:53 +01:00
Public.flow_add_info_sections ( flow2 , { ' new_players ' , ' tips ' } )
2022-05-29 12:36:27 +01:00
flow2 = Public.flow_add_info_tab ( flow , { ' pirates.gui_info_credits ' } )
2021-10-13 09:21:53 +01: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 21:20:55 +00:00
2021-10-13 09:21:53 +01: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 19:39:03 +00:00
contents.style . width = width
2021-10-13 09:21:53 +01: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 10:40:55 +00: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 09:21:53 +01: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 " } }
2024-09-07 23:19:03 +01:00
flow4.style . font = ' default-small '
2021-10-13 09:21:53 +01:00
flow4.style . font_color = GuiCommon.friendly_font_color
flow4.style . single_line = false
flow4.style . bottom_margin = 4
flow4.style . top_margin = 3
flow.add_tab ( tab , contents )
return ret
end
function Public . click ( event )
2022-10-10 20:21:14 +03:00
if not event.element then return end
if not event.element . valid then return end
2021-10-13 09:21:53 +01:00
local player = game.players [ event.element . player_index ]
2022-03-19 21:20:55 +00:00
-- local name = 'info'
2021-10-13 09:21:53 +01:00
local element = event.element
local eventtype = element.type
if not player.gui . screen [ window_name .. ' _piratewindow ' ] then return end
2022-03-19 21:20:55 +00:00
-- local memory = Memory.get_crew_memory()
2021-10-13 09:21:53 +01: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 21:20:55 +00:00
) then
2021-10-13 09:21:53 +01:00
Public.toggle_window ( player )
end
end
2022-03-13 01:44:32 +00:00
2022-03-19 21:20:55 +00:00
-- function Public.regular_update(player)
2022-03-13 01:44:32 +00:00
2022-03-19 21:20:55 +00:00
-- end
2022-03-13 01:44:32 +00:00
function Public . full_update ( player )
2022-03-20 11:41:23 +00:00
if Public.regular_update then Public.regular_update ( player ) end
2021-10-13 09:21:53 +01: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.'
2024-09-07 17:37:24 +01:00
-- This is really really dumb, to have to change these manually. But sadly we couldn't get the window to look like that and also be expandable.
2021-10-13 09:21:53 +01:00
if flow2.selected_tab_index == 1 then
2024-09-07 17:37:24 +01:00
flow2.style . height = 360
2021-10-13 09:21:53 +01:00
elseif flow2.selected_tab_index == 2 then
2022-07-30 15:28:28 +01:00
flow2.style . height = 490
2021-10-13 09:21:53 +01:00
elseif flow2.selected_tab_index == 3 then
2022-06-01 21:01:00 +01:00
flow2.style . height = 580
2021-10-13 09:21:53 +01:00
elseif flow2.selected_tab_index == 4 then
2022-06-02 16:15:28 +01:00
flow2.style . height = 340
2021-10-13 09:21:53 +01:00
end
end
return Public