using DevilLink2.Gameplay; using DevilLink2.Presentation; using UnityEngine; using UnityEngine.UI; namespace DevilLink2.UI { /// One-time UGUI composition, in prototype coordinates. Does not create a Canvas or generate assets. public static class UIBuilder { public const string RootName = "DevilLink2UI"; public static Color Navy = Hex("05080F"), Panel = Hex("131C2E"), Gold = Hex("FFD34D"), LightGold = Hex("FFF0BF"), Muted = Hex("93A5C6"), TextColor = Hex("DCE6F7"); public static Color Hex(string value) { ColorUtility.TryParseHtmlString("#" + value, out var color); return color; } public static UIManager Build(RectTransform frame, BoardDemoBootstrap bootstrap, BoardView boardView, Text existingTitle = null) { var existing = frame.Find(RootName); if (existing) return existing.GetComponent(); var root = Rect(RootName, frame, 0, 0, 430, 932); root.anchorMin = root.anchorMax = root.pivot = new Vector2(.5f, .5f); root.anchoredPosition = Vector2.zero; root.gameObject.AddComponent().Apply(); var start = Start(root); var lobby = Lobby(root, Resources.Load("DevilLink2LobbyArt")); // Keep the original board in a sibling container so rebuilding the shell cannot destroy it. var gameplayRoot = frame.Find("DevilLink2GameplayScreen") as RectTransform; if (!gameplayRoot) { gameplayRoot = Rect("DevilLink2GameplayScreen", frame, 0, 0, 430, 932); gameplayRoot.anchorMin = gameplayRoot.anchorMax = gameplayRoot.pivot = new Vector2(.5f, .5f); gameplayRoot.anchoredPosition = Vector2.zero; gameplayRoot.gameObject.AddComponent().Apply(); } var gameplay = gameplayRoot.GetComponent(); if (!gameplay) gameplay = gameplayRoot.gameObject.AddComponent(); boardView.transform.SetParent(gameplayRoot, false); var oldOverlay = frame.Find("InteractionOverlay"); if (oldOverlay) oldOverlay.SetParent(gameplayRoot, false); if (!existingTitle) existingTitle = gameplayRoot.Find("Title")?.GetComponent() ?? gameplayRoot.Find("ModeTitle")?.GetComponent(); Text title = existingTitle ? existingTitle : Label("ModeTitle", gameplayRoot, "", 13, Color.white, 102, 10, 316, 32); if (existingTitle) { title.transform.SetParent(gameplayRoot, false); Place(title.rectTransform, 102, 10, 316, 32); title.fontSize = 13; } var back = gameplayRoot.Find("Lobby")?.GetComponent