using System; using System.Collections.Generic; using GazeLab.Combat; using GazeLab.Core; using GazeLab.Data; using GazeLab.Entities; using UnityEngine; using UnityEngine.UI; namespace GazeLab.UI { /// /// Modular presenter and procedural builder for the redesigned Left-to-Right Branching /// Tech Upgrade Tree, Prerequisite Path Highlighter, Node Inspector, and Station Hardpoint Loadout bar. /// public sealed class TechTreeModalView { private sealed class TechNodeSocketWidget { public GameObject rootGo; public RectTransform rectTransform; public Button button; public DwellButton dwellButton; public Image outerGlowImage; public Image socketRimImage; public Outline outline; public Image iconImage; public Text shortNameLabel; public Text rankBadgeText; public UpgradeTreeNodeSO boundNode; public Vector2 normalizedPos; } private sealed class HardpointSlotWidget { public int slotIndex; public GameObject rootGo; public Image backgroundImage; public Image weaponIconImage; public Text headerText; public Text weaponNameText; public Button swapWeaponButton; public Text swapWeaponLabel; public Button priorityButton; public Text priorityLabel; } private readonly GazeLabHUD hud; private readonly Font font; private readonly GazeLabUIThemeSO theme; private GameObject overlayRoot; private Text stationInfoText; private Button repairButton; private Text repairLabel; private Button instantBuyBtn; private Text instantBuyToggleLabel; private bool instantBuyEnabled = true; private Text headerScrapCountText; private Text headerGoldCountText; private Text headerUraniumCountText; private RectTransform graphCanvasRect; private TechTreeConduitGraphic conduitGraphic; private readonly List nodeSockets = new List(); private readonly List conduitEdgesBuffer = new List(); // Right Inspector Card private RectTransform detailCardRoot; private Image detailTrackBanner; private Text detailCategoryBadge; private Image detailIconBg; private Image detailIcon; private Text detailTitle; private Text detailRankStatus; private Text detailDescription; private Text detailPrereqHeader; private Text detailPrereqChecklist; private Text detailCostText; private Button detailBuyButton; private Text detailBuyBtnLabel; // Bottom Hardpoint Loadout & Wave Launch Bar private readonly List hardpointWidgets = new List(); private Button launchWaveBtn; private Text launchWaveLabel; private UpgradeTreeNodeSO currentlySelectedNode; private UpgradeTreeNodeSO currentlyHoveredNode; public GameObject RootGameObject => overlayRoot; public bool IsOpen => overlayRoot != null && overlayRoot.activeSelf; public TechTreeModalView(GazeLabHUD ownerHud, Font defaultFont, GazeLabUIThemeSO uiTheme) { hud = ownerHud; font = defaultFont; theme = uiTheme != null ? uiTheme : ScriptableObject.CreateInstance(); } public void Build(RectTransform canvasRect) { Transform existing = canvasRect.Find("TechTreeModal"); if (existing != null) { BindExisting(existing.gameObject); return; } RectTransform overlay = hud.CreatePanelElement( canvasRect, "TechTreeModal", Vector2.zero, Vector2.one, theme.modalBackdropColor); overlayRoot = overlay.gameObject; BuildHeaderBar(overlay); BuildSubBarAndLegend(overlay); BuildConstellationGraphArea(overlay); BuildDetailInspectorCard(overlay); BuildBottomLoadoutAndLaunchBar(overlay); overlayRoot.SetActive(false); } public void BindExisting(GameObject modalRoot) { overlayRoot = modalRoot; RectTransform overlay = overlayRoot.GetComponent(); Transform closeBtn = overlay.Find("CloseTreeBtn"); if (closeBtn != null) { Button b = closeBtn.GetComponent