require("PGBase") require("GameManager/Utilities") ---@class GUIManager GUIManager = {} GUIManager.__index = GUIManager ---Creates a new GUI Manager. ---@return GUIManager function GUIManager:New() local self = setmetatable({}, GUIManager) return self end ---Initializes the GUI Manager for Skirmish mode. ---@param isSpectator boolean Whether to initialize in spectator mode. function GUIManager:InitSkirmish(isSpectator) self:InitTactical() if isSpectator then GUI_Component_Visibility(UI_CreditsT1, true) GUI_Component_Visibility(UI_IconT1, true) GUI_Component_Visibility(UI_CreditsT2, true) GUI_Component_Visibility(UI_IconT2, true) GUI_Component_Visibility(UI_PlanetaryPop, false) GUI_Component_Visibility(UI_CreditsTactical, false) end end ---Initializes the GUI Manager for Tactical mode. function GUIManager:InitTactical() GUI_Component_Visibility(UI_GameTime, true) end ---Resets the GUI Manager. function GUIManager:Reset() GUI_Component_Text(UI_GameTime, "") GUI_Text_Color(UI_GameTime, 1, 1, 1, 1) GUI_Component_Visibility(UI_GameTime, false) GUI_Component_Text(UI_CreditsT1, "") GUI_Text_Color(UI_CreditsT1, 1, 1, 1, 1) GUI_Component_Visibility(UI_CreditsT1, false) GUI_Button_Icon(UI_IconT1, "", 1, 1, 1, 1) GUI_Component_Visibility(UI_IconT1, false) GUI_Component_Text(UI_CreditsT2, "") GUI_Text_Color(UI_CreditsT2, 1, 1, 1, 1) GUI_Component_Visibility(UI_CreditsT2, false) GUI_Button_Icon(UI_IconT2, "", 1, 1, 1, 1) GUI_Component_Visibility(UI_IconT2, false) GUI_Component_Visibility(UI_PlanetaryPop, true) GUI_Component_Visibility(UI_CreditsTactical, true) end ---Services Game Time display. ---@param gameTime number The current game time. function GUIManager:DisplayGameTime(gameTime) local timeText = FormatTime(gameTime) local text = string.format("Time: %s", timeText) GUI_Component_Text(UI_GameTime, text) end ---Displays credits for the specified team ---@param team TeamStruct The team. ---@param credits number The team credits. ---@param income number The team income. function GUIManager:DisplayTeamCredits(team, credits, income) local uiText, uiIcon = "", "" if team.Number == 1 then uiText = UI_CreditsT1 uiIcon = UI_IconT1 elseif team.Number == 2 then uiText = UI_CreditsT2 uiIcon = UI_IconT2 else return end local positiveText = "+" if income < 0 then positiveText = "" end local text = string.format("Team %d: $ %d (%s%d)", team.Number, credits, positiveText, income) local icon = team.Faction.Icon local color = team.Faction.Color GUI_Button_Icon(uiIcon, icon, color.R, color.G, color.B, 1) GUI_Component_Text(uiText, text) GUI_Text_Color(uiText, color.R, color.G, color.B, 1) end