diff --git a/MapModS/Map/Transition.cs b/MapModS/Map/Transition.cs index c3d1457..1e16f8f 100644 --- a/MapModS/Map/Transition.cs +++ b/MapModS/Map/Transition.cs @@ -226,6 +226,7 @@ private static string GetActualSceneName(string objName) public class ExtraMapData : MonoBehaviour { public Color origColor; + public Color origTransitionColor; public string sceneName; } diff --git a/MapModS/UI/GUI.cs b/MapModS/UI/GUI.cs index 3f9ba79..8593752 100644 --- a/MapModS/UI/GUI.cs +++ b/MapModS/UI/GUI.cs @@ -44,7 +44,7 @@ private static void GameMap_Start(On.GameMap.orig_Start orig, GameMap self) private static void GameMap_WorldMap (On.GameMap.orig_WorldMap orig, GameMap self) { orig(self); - TransitionText.ShowInstructions(); + TransitionText.ShowWorldMap(self); } private static void SetupMapMarkers(On.GameMap.orig_SetupMapMarkers orig, GameMap self) diff --git a/MapModS/UI/InputListener.cs b/MapModS/UI/InputListener.cs index 5d0eacf..3d68080 100644 --- a/MapModS/UI/InputListener.cs +++ b/MapModS/UI/InputListener.cs @@ -70,10 +70,10 @@ protected void Update() PauseMenu.SizeClicked("Size"); } - if (Input.GetKeyDown(KeyCode.T) && MapModS.LS.mapMode == Settings.MapMode.TransitionRando) - { - TransitionText.GetRoute(); - } + //if (Input.GetKeyDown(KeyCode.T) && MapModS.LS.mapMode == Settings.MapMode.TransitionRando) + //{ + // TransitionText.GetRoute(); + //} } } } diff --git a/MapModS/UI/TransitionText.cs b/MapModS/UI/TransitionText.cs index 5a5450b..415f71b 100644 --- a/MapModS/UI/TransitionText.cs +++ b/MapModS/UI/TransitionText.cs @@ -37,13 +37,43 @@ public static void Show() SetTexts(); } - public static void ShowInstructions() + public static void ShowWorldMap(GameMap gameMap) { bool isActive = !LockToggleEnable && MapModS.LS.ModEnabled && RandomizerMod.RandomizerMod.RS.GenerationSettings.TransitionSettings.Mode != RandomizerMod.Settings.TransitionSettings.TransitionMode.None && MapModS.LS.mapMode == MapMode.TransitionRando; _instructionPanel.SetActive(isActive, isActive); + + // The following stores the colors of the rooms prior to selection + if (gameMap == null) return; + + foreach (Transform areaObj in gameMap.transform) + { + foreach (Transform roomObj in areaObj.transform) + { + Transition.ExtraMapData extra = roomObj.GetComponent(); + + if (extra == null) continue; + + SpriteRenderer sr = roomObj.GetComponent(); + + // For AdditionalMaps room objects, the child has the SR + if (extra.sceneName.Contains("White_Palace")) + { + foreach (Transform roomObj2 in roomObj.transform) + { + if (!roomObj2.name.Contains("RWP")) continue; + sr = roomObj2.GetComponent(); + break; + } + } + + if (sr == null) continue; + + extra.origTransitionColor = sr.color; + } + } } public static void Hide() @@ -116,6 +146,12 @@ public static void Update() return; } + // Use menu selection button for control + if (InputHandler.Instance != null && InputHandler.Instance.inputActions.menuSubmit.WasPressed) + { + GetRoute(); + } + frameCounter = (frameCounter + 1) % 24; if (frameCounter == 0) @@ -123,6 +159,7 @@ public static void Update() if (GetRoomClosestToMiddle(selectedScene, out selectedScene)) { SetInstructionsText(); + SetRoomColors(); } } } @@ -132,6 +169,9 @@ private static double DistanceToMiddle(Transform transform) return Math.Pow(transform.position.x, 2) + Math.Pow(transform.position.y, 2); } + private static readonly Vector4 selectionColor = new(255, 255, 0, 0.5f); + + // This method also handles highlighting the selected room public static bool GetRoomClosestToMiddle(string previousScene, out string selectedScene) { selectedScene = null; @@ -165,6 +205,49 @@ public static bool GetRoomClosestToMiddle(string previousScene, out string selec return selectedScene != previousScene; } + private static void SetRoomColors() + { + GameObject go_GameMap = GameManager.instance.gameMap; + + if (go_GameMap == null) return; + + foreach (Transform areaObj in go_GameMap.transform) + { + foreach (Transform roomObj in areaObj.transform) + { + if (!roomObj.gameObject.activeSelf) continue; + + Transition.ExtraMapData extra = roomObj.GetComponent(); + + if (extra == null) continue; + + SpriteRenderer sr = roomObj.GetComponent(); + + // For AdditionalMaps room objects, the child has the SR + if (extra.sceneName.Contains("White_Palace")) + { + foreach (Transform roomObj2 in roomObj.transform) + { + if (!roomObj2.name.Contains("RWP")) continue; + sr = roomObj2.GetComponent(); + break; + } + } + + if (sr == null) continue; + + if (extra.sceneName == selectedScene) + { + sr.color = selectionColor; + } + else + { + sr.color = extra.origTransitionColor; + } + } + } + } + public static void SetInstructionsText() { string instructionsText = $"Selected room: {selectedScene}."; @@ -175,7 +258,7 @@ public static void SetInstructionsText() } else { - instructionsText += " Press CTRL-T to find new route / switch starting transition for current route."; + instructionsText += $" Press [Menu Select] to find new route / switch starting transition for current route."; } _instructionPanel.GetText("Instructions").UpdateText(instructionsText);