diff --git a/SceneManager/EntryPoint.cs b/SceneManager/EntryPoint.cs index 64354e5..08e5fb8 100644 --- a/SceneManager/EntryPoint.cs +++ b/SceneManager/EntryPoint.cs @@ -79,9 +79,9 @@ namespace SceneManager private static void MyTerminationHandler(object sender, EventArgs e) { // Clean up paths - for (int i = 0; i < TrafficMenu.paths.Count; i++) + for (int i = 0; i < PathMainMenu.GetPaths().Count; i++) { - TrafficMenu.DeletePath(TrafficMenu.paths[i], i, "All"); + PathMainMenu.DeletePath(PathMainMenu.GetPaths()[i], i, PathMainMenu.Delete.All); } // Clean up cones diff --git a/SceneManager/GetUserInput.cs b/SceneManager/GetUserInput.cs index 3531000..8a092d8 100644 --- a/SceneManager/GetUserInput.cs +++ b/SceneManager/GetUserInput.cs @@ -20,7 +20,7 @@ namespace SceneManager GetControllerInput(); // Display this message for test versions only - if (MenuManager.mainMenu.Visible) + if (MainMenu.mainMenu.Visible) { Game.DisplaySubtitle($"You are using a test build of Scene Manager. Please report any bugs/crashes in the Discord server."); } @@ -36,12 +36,12 @@ namespace SceneManager { if (Game.IsControllerButtonDown(EntryPoint.Settings.ToggleButton) && AreMenusClosed()) { - MenuManager.mainMenu.Visible = !MenuManager.mainMenu.Visible; + MainMenu.mainMenu.Visible = !MainMenu.mainMenu.Visible; } } else if (Game.IsControllerButtonDownRightNow(EntryPoint.Settings.ModifierButton) && Game.IsControllerButtonDown(EntryPoint.Settings.ToggleButton) && AreMenusClosed()) { - MenuManager.mainMenu.Visible = !MenuManager.mainMenu.Visible; + MainMenu.mainMenu.Visible = !MainMenu.mainMenu.Visible; } } @@ -51,18 +51,18 @@ namespace SceneManager { if (Game.IsKeyDown(EntryPoint.Settings.ToggleKey) && AreMenusClosed()) { - MenuManager.mainMenu.Visible = !MenuManager.mainMenu.Visible; + MainMenu.mainMenu.Visible = !MainMenu.mainMenu.Visible; } } else if (Game.IsKeyDownRightNow(EntryPoint.Settings.ModifierKey) && Game.IsKeyDown(EntryPoint.Settings.ToggleKey) && AreMenusClosed()) { - MenuManager.mainMenu.Visible = !MenuManager.mainMenu.Visible; + MainMenu.mainMenu.Visible = !MainMenu.mainMenu.Visible; } } private static bool AreMenusClosed() { - if(!MenuManager.barrierMenu.Visible && !MenuManager.pathMenu.Visible && !MenuManager.pathCreationMenu.Visible && !MenuManager.editPathMenu.Visible && !MenuManager.editWaypointMenu.Visible && !MenuManager.settingsMenu.Visible) + if(!BarrierMenu.barrierMenu.Visible && !PathMainMenu.pathMainMenu.Visible && !PathCreationMenu.pathCreationMenu.Visible && !EditPathMenu.editPathMenu.Visible && !EditWaypointMenu.editWaypointMenu.Visible && !SettingsMenu.settingsMenu.Visible) { return true; } diff --git a/SceneManager/Menus/BarrierMenu.cs b/SceneManager/Menus/BarrierMenu.cs index 24cf2da..896d6d1 100644 --- a/SceneManager/Menus/BarrierMenu.cs +++ b/SceneManager/Menus/BarrierMenu.cs @@ -11,6 +11,7 @@ namespace SceneManager { class BarrierMenu { + public static UIMenu barrierMenu { get; private set; } public static List barriers = new List() { }; // TODO: Refactor as dictionary @@ -20,16 +21,23 @@ namespace SceneManager private static UIMenuListScrollerItem removeBarrierOptions = new UIMenuListScrollerItem("Remove Barrier", "", new[] { "Last Barrier", "Nearest Barrier", "All Barriers" }); public static Rage.Object shadowBarrier; + internal static void InstantiateMenu() + { + barrierMenu = new UIMenu("Scene Manager", "~o~Barrier Management"); + barrierMenu.ParentMenu = MainMenu.mainMenu; + MenuManager.menuPool.Add(barrierMenu); + } + public static void BuildBarrierMenu() { - MenuManager.barrierMenu.AddItem(removeBarrierOptions, 0); + barrierMenu.AddItem(removeBarrierOptions, 0); removeBarrierOptions.Enabled = false; - MenuManager.barrierMenu.AddItem(rotateBarrier, 0); - MenuManager.barrierMenu.AddItem(barrierList, 0); - MenuManager.barrierMenu.RefreshIndex(); + barrierMenu.AddItem(rotateBarrier, 0); + barrierMenu.AddItem(barrierList, 0); + barrierMenu.RefreshIndex(); - MenuManager.barrierMenu.OnItemSelect += BarrierMenu_OnItemSelected; - MenuManager.barrierMenu.OnScrollerChange += BarrierMenu_OnScrollerChange; + barrierMenu.OnItemSelect += BarrierMenu_OnItemSelected; + barrierMenu.OnScrollerChange += BarrierMenu_OnScrollerChange; } public static void CreateShadowBarrier(UIMenu barrierMenu) @@ -91,7 +99,7 @@ namespace SceneManager { if (scrollerItem == barrierList) { - CreateShadowBarrier(MenuManager.barrierMenu); + CreateShadowBarrier(barrierMenu); if (barrierObjectNames[barrierList.Index] == "prop_flare_01b") { diff --git a/SceneManager/Menus/EditPathMenu.cs b/SceneManager/Menus/EditPathMenu.cs index 18462bb..1dcbd2f 100644 --- a/SceneManager/Menus/EditPathMenu.cs +++ b/SceneManager/Menus/EditPathMenu.cs @@ -7,23 +7,31 @@ namespace SceneManager { class EditPathMenu { + public static UIMenu editPathMenu { get; private set; } private static UIMenuItem editPathWaypoints, deletePath; public static UIMenuCheckboxItem togglePath; + internal static void InstantiateMenu() + { + editPathMenu = new UIMenu("Scene Manager", "~o~Edit Path"); + editPathMenu.ParentMenu = PathMainMenu.pathMainMenu; + MenuManager.menuPool.Add(editPathMenu); + } + public static void BuildEditPathMenu() { - MenuManager.editPathMenu.AddItem(togglePath = new UIMenuCheckboxItem("Disable Path", false)); - MenuManager.editPathMenu.AddItem(editPathWaypoints = new UIMenuItem("Edit Waypoints")); - MenuManager.editPathMenu.AddItem(deletePath = new UIMenuItem("Delete Path")); + editPathMenu.AddItem(togglePath = new UIMenuCheckboxItem("Disable Path", false)); + editPathMenu.AddItem(editPathWaypoints = new UIMenuItem("Edit Waypoints")); + editPathMenu.AddItem(deletePath = new UIMenuItem("Delete Path")); - MenuManager.editPathMenu.RefreshIndex(); - MenuManager.editPathMenu.OnItemSelect += EditPath_OnItemSelected; - MenuManager.editPathMenu.OnCheckboxChange += EditPath_OnCheckboxChange; + editPathMenu.RefreshIndex(); + editPathMenu.OnItemSelect += EditPath_OnItemSelected; + editPathMenu.OnCheckboxChange += EditPath_OnCheckboxChange; } private static void EditPath_OnItemSelected(UIMenu sender, UIMenuItem selectedItem, int index) { - var currentPath = TrafficMenu.paths[TrafficMenu.editPath.Index]; + var currentPath = PathMainMenu.GetPaths()[PathMainMenu.editPath.Index]; if (selectedItem == editPathWaypoints) { @@ -32,7 +40,7 @@ namespace SceneManager if (selectedItem == deletePath) { - TrafficMenu.DeletePath(currentPath, currentPath.PathNum - 1, "Single"); + PathMainMenu.DeletePath(currentPath, currentPath.PathNum - 1, PathMainMenu.Delete.Single); } } @@ -40,7 +48,7 @@ namespace SceneManager { if (checkboxItem == togglePath) { - var currentPath = TrafficMenu.paths[TrafficMenu.editPath.Index]; + var currentPath = PathMainMenu.GetPaths()[PathMainMenu.editPath.Index]; if (togglePath.Checked) { currentPath.DisablePath(); diff --git a/SceneManager/Menus/EditWaypointMenu.cs b/SceneManager/Menus/EditWaypointMenu.cs index 4b8481e..4408643 100644 --- a/SceneManager/Menus/EditWaypointMenu.cs +++ b/SceneManager/Menus/EditWaypointMenu.cs @@ -12,6 +12,7 @@ namespace SceneManager class EditWaypointMenu { #pragma warning disable CS0618 // Type or member is obsolete, clear NUI squiggles + public static UIMenu editWaypointMenu { get; private set; } private static UIMenuItem editUpdateWaypoint, editRemoveWaypoint; private static UIMenuListItem editWaypoint, changeWaypointType, changeWaypointSpeed, changeCollectorRadius; private static UIMenuCheckboxItem collectorWaypoint, updateWaypointPosition; @@ -22,13 +23,21 @@ namespace SceneManager private static List collectorRadii = new List() { 3f, 5f, 10f, 15f, 20f, 30f, 40f, 50f }; private static VehicleDrivingFlags[] drivingFlags = new VehicleDrivingFlags[] { VehicleDrivingFlags.Normal, VehicleDrivingFlags.StopAtDestination }; + internal static void InstantiateMenu() + { + editWaypointMenu = new UIMenu("Scene Manager", "~o~Edit Waypoint"); + editWaypointMenu.ParentMenu = EditPathMenu.editPathMenu; + MenuManager.menuPool.Add(editWaypointMenu); + } + public static void BuildEditWaypointMenu() { // Need to unsubscribe from these or else there will be duplicate firings if the user left the menu, then re-entered - MenuManager.editWaypointMenu.OnItemSelect -= EditWaypoint_OnItemSelected; - MenuManager.editWaypointMenu.OnListChange -= EditWaypoint_OnListChanged; + editWaypointMenu.OnItemSelect -= EditWaypoint_OnItemSelected; + editWaypointMenu.OnListChange -= EditWaypoint_OnListChanged; - var currentPath = TrafficMenu.paths[TrafficMenu.editPath.Index]; + //var currentPath = PathMainMenu.paths[PathMainMenu.editPath.Index]; + var currentPath = PathMainMenu.GetPaths()[PathMainMenu.editPath.Index]; // Populating menu list so user can select which waypoint to edit by index pathWaypoints.Clear(); @@ -37,51 +46,51 @@ namespace SceneManager pathWaypoints.Add(i + 1); } - MenuManager.editWaypointMenu.Clear(); - MenuManager.editWaypointMenu.AddItem(editWaypoint = new UIMenuListItem("Edit Waypoint", pathWaypoints, 0)); - MenuManager.editWaypointMenu.AddItem(changeWaypointType = new UIMenuListItem("Change Waypoint Type", waypointTypes, Array.IndexOf(drivingFlags, currentPath.Waypoints[editWaypoint.Index].DrivingFlag))); - MenuManager.editWaypointMenu.AddItem(changeWaypointSpeed = new UIMenuListItem("Change Waypoint Speed", waypointSpeeds, waypointSpeeds.IndexOf(currentPath.Waypoints[editWaypoint.Index].Speed))); - MenuManager.editWaypointMenu.AddItem(collectorWaypoint = new UIMenuCheckboxItem("Collector Waypoint", TrafficMenu.paths[TrafficMenu.editPath.Index].Waypoints[editWaypoint.Index].Collector)); - MenuManager.editWaypointMenu.AddItem(changeCollectorRadius = new UIMenuListItem("Change Collection Radius", collectorRadii, collectorRadii.IndexOf(currentPath.Waypoints[editWaypoint.Index].CollectorRadius))); - MenuManager.editWaypointMenu.AddItem(updateWaypointPosition = new UIMenuCheckboxItem("Update Waypoint Position", false)); - MenuManager.editWaypointMenu.AddItem(editUpdateWaypoint = new UIMenuItem("Update Waypoint")); - MenuManager.editWaypointMenu.AddItem(editRemoveWaypoint = new UIMenuItem("Remove Waypoint")); + editWaypointMenu.Clear(); + editWaypointMenu.AddItem(editWaypoint = new UIMenuListItem("Edit Waypoint", pathWaypoints, 0)); + editWaypointMenu.AddItem(changeWaypointType = new UIMenuListItem("Change Waypoint Type", waypointTypes, Array.IndexOf(drivingFlags, currentPath.Waypoints[editWaypoint.Index].DrivingFlag))); + editWaypointMenu.AddItem(changeWaypointSpeed = new UIMenuListItem("Change Waypoint Speed", waypointSpeeds, waypointSpeeds.IndexOf(currentPath.Waypoints[editWaypoint.Index].Speed))); + editWaypointMenu.AddItem(collectorWaypoint = new UIMenuCheckboxItem("Collector Waypoint", PathMainMenu.GetPaths()[PathMainMenu.editPath.Index].Waypoints[editWaypoint.Index].Collector)); + editWaypointMenu.AddItem(changeCollectorRadius = new UIMenuListItem("Change Collection Radius", collectorRadii, collectorRadii.IndexOf(currentPath.Waypoints[editWaypoint.Index].CollectorRadius))); + editWaypointMenu.AddItem(updateWaypointPosition = new UIMenuCheckboxItem("Update Waypoint Position", false)); + editWaypointMenu.AddItem(editUpdateWaypoint = new UIMenuItem("Update Waypoint")); + editWaypointMenu.AddItem(editRemoveWaypoint = new UIMenuItem("Remove Waypoint")); - MenuManager.editPathMenu.Visible = false; - MenuManager.editWaypointMenu.RefreshIndex(); - MenuManager.editWaypointMenu.Visible = true; + EditPathMenu.editPathMenu.Visible = false; + editWaypointMenu.RefreshIndex(); + editWaypointMenu.Visible = true; - MenuManager.editWaypointMenu.OnItemSelect += EditWaypoint_OnItemSelected; - MenuManager.editWaypointMenu.OnListChange += EditWaypoint_OnListChanged; + editWaypointMenu.OnItemSelect += EditWaypoint_OnItemSelected; + editWaypointMenu.OnListChange += EditWaypoint_OnListChanged; } private static void EditWaypoint_OnListChanged(UIMenu sender, UIMenuListItem listItem, int index) { - var currentPath = TrafficMenu.paths[TrafficMenu.editPath.Index]; + var currentPath = PathMainMenu.GetPaths()[PathMainMenu.editPath.Index]; var currentWaypoint = currentPath.Waypoints[editWaypoint.Index]; if (listItem == editWaypoint) { - while (MenuManager.editWaypointMenu.MenuItems.Count > 1) + while (editWaypointMenu.MenuItems.Count > 1) { - MenuManager.editWaypointMenu.RemoveItemAt(1); + editWaypointMenu.RemoveItemAt(1); GameFiber.Yield(); } - MenuManager.editWaypointMenu.AddItem(changeWaypointType = new UIMenuListItem("Change Waypoint Type", waypointTypes, Array.IndexOf(drivingFlags, currentWaypoint.DrivingFlag))); - MenuManager.editWaypointMenu.AddItem(changeWaypointSpeed = new UIMenuListItem("Change Waypoint Speed", waypointSpeeds, waypointSpeeds.IndexOf(currentWaypoint.Speed))); - MenuManager.editWaypointMenu.AddItem(collectorWaypoint = new UIMenuCheckboxItem("Attractor Waypoint", currentWaypoint.Collector)); - MenuManager.editWaypointMenu.AddItem(changeCollectorRadius = new UIMenuListItem("Change Collection Radius", collectorRadii, collectorRadii.IndexOf(currentPath.Waypoints[editWaypoint.Index].CollectorRadius))); - MenuManager.editWaypointMenu.AddItem(updateWaypointPosition = new UIMenuCheckboxItem("Update Waypoint Position", false)); - MenuManager.editWaypointMenu.AddItem(editUpdateWaypoint = new UIMenuItem("Update Waypoint")); - MenuManager.editWaypointMenu.AddItem(editRemoveWaypoint = new UIMenuItem("Remove Waypoint")); - MenuManager.editWaypointMenu.RefreshIndex(); + editWaypointMenu.AddItem(changeWaypointType = new UIMenuListItem("Change Waypoint Type", waypointTypes, Array.IndexOf(drivingFlags, currentWaypoint.DrivingFlag))); + editWaypointMenu.AddItem(changeWaypointSpeed = new UIMenuListItem("Change Waypoint Speed", waypointSpeeds, waypointSpeeds.IndexOf(currentWaypoint.Speed))); + editWaypointMenu.AddItem(collectorWaypoint = new UIMenuCheckboxItem("Attractor Waypoint", currentWaypoint.Collector)); + editWaypointMenu.AddItem(changeCollectorRadius = new UIMenuListItem("Change Collection Radius", collectorRadii, collectorRadii.IndexOf(currentPath.Waypoints[editWaypoint.Index].CollectorRadius))); + editWaypointMenu.AddItem(updateWaypointPosition = new UIMenuCheckboxItem("Update Waypoint Position", false)); + editWaypointMenu.AddItem(editUpdateWaypoint = new UIMenuItem("Update Waypoint")); + editWaypointMenu.AddItem(editRemoveWaypoint = new UIMenuItem("Remove Waypoint")); + editWaypointMenu.RefreshIndex(); } } private static void EditWaypoint_OnItemSelected(UIMenu sender, UIMenuItem selectedItem, int index) { - var currentPath = TrafficMenu.paths[TrafficMenu.editPath.Index]; + var currentPath = PathMainMenu.GetPaths()[PathMainMenu.editPath.Index]; var currentWaypoint = currentPath.Waypoints[editWaypoint.Index]; if (selectedItem == editUpdateWaypoint) @@ -104,10 +113,10 @@ namespace SceneManager if (currentPath.Waypoints.Count == 1) { Game.LogTrivial($"Deleting the last waypoint from the path."); - TrafficMenu.DeletePath(currentPath, currentPath.PathNum - 1, "Single"); + PathMainMenu.DeletePath(currentPath, currentPath.PathNum - 1, PathMainMenu.Delete.Single); - MenuManager.editWaypointMenu.Visible = false; - MenuManager.pathMenu.Visible = true; + editWaypointMenu.Visible = false; + PathMainMenu.pathMainMenu.Visible = true; } else { diff --git a/SceneManager/Menus/MainMenu.cs b/SceneManager/Menus/MainMenu.cs index d28ac27..d1dcfbc 100644 --- a/SceneManager/Menus/MainMenu.cs +++ b/SceneManager/Menus/MainMenu.cs @@ -11,26 +11,33 @@ namespace SceneManager { class MainMenu { + public static UIMenu mainMenu { get; private set; } private static UIMenuItem navigateToPathMenu, navigateToBarrierMenu, navigateToSettingsMenu; + internal static void InstantiateMenu() + { + mainMenu = new UIMenu("Scene Manager", ""); + MenuManager.menuPool.Add(mainMenu); + } + public static void BuildMainMenu() { - MenuManager.mainMenu.AddItem(navigateToPathMenu = new UIMenuItem("~o~Path Menu")); - MenuManager.mainMenu.BindMenuToItem(MenuManager.pathMenu, navigateToPathMenu); - MenuManager.mainMenu.AddItem(navigateToBarrierMenu = new UIMenuItem("~o~Barrier Menu")); - MenuManager.mainMenu.BindMenuToItem(MenuManager.barrierMenu, navigateToBarrierMenu); - MenuManager.mainMenu.AddItem(navigateToSettingsMenu = new UIMenuItem("~o~Settings")); - MenuManager.mainMenu.BindMenuToItem(MenuManager.settingsMenu, navigateToSettingsMenu); + mainMenu.AddItem(navigateToPathMenu = new UIMenuItem("~o~Path Menu")); + mainMenu.BindMenuToItem(PathMainMenu.pathMainMenu, navigateToPathMenu); + mainMenu.AddItem(navigateToBarrierMenu = new UIMenuItem("~o~Barrier Menu")); + mainMenu.BindMenuToItem(BarrierMenu.barrierMenu, navigateToBarrierMenu); + mainMenu.AddItem(navigateToSettingsMenu = new UIMenuItem("~o~Settings")); + mainMenu.BindMenuToItem(SettingsMenu.settingsMenu, navigateToSettingsMenu); - MenuManager.mainMenu.RefreshIndex(); - MenuManager.mainMenu.OnItemSelect += MainMenu_OnItemSelected; + mainMenu.RefreshIndex(); + mainMenu.OnItemSelect += MainMenu_OnItemSelected; } private static void MainMenu_OnItemSelected(UIMenu sender, UIMenuItem selectedItem, int index) { if (selectedItem == navigateToBarrierMenu) { - BarrierMenu.CreateShadowBarrier(MenuManager.barrierMenu); + BarrierMenu.CreateShadowBarrier(BarrierMenu.barrierMenu); } } } diff --git a/SceneManager/Menus/PathCreationMenu.cs b/SceneManager/Menus/PathCreationMenu.cs index 7a74059..95f879c 100644 --- a/SceneManager/Menus/PathCreationMenu.cs +++ b/SceneManager/Menus/PathCreationMenu.cs @@ -12,31 +12,38 @@ namespace SceneManager { class PathCreationMenu { - #pragma warning disable CS0618 // Type or member is obsolete, clear NUI squiggles - public static UIMenuItem trafficAddWaypoint, trafficRemoveWaypoint, trafficEndPath; - public static UIMenuListItem waypointType, waypointSpeed, collectorRadius; + public static UIMenu pathCreationMenu { get; private set; } + private static UIMenuItem trafficAddWaypoint, trafficRemoveWaypoint, trafficEndPath; + private static UIMenuListScrollerItem waypointType; + private static UIMenuListScrollerItem waypointSpeed; + private static UIMenuListScrollerItem collectorRadius; private static UIMenuCheckboxItem collectorWaypoint; - private static List waypointSpeeds = new List() { 5f, 10f, 15f, 20f, 30f, 40f, 50f, 60f, 70f }; - //private enum waypointTypes {DriveTo, Stop }; - private static List waypointTypes = new List() { "Drive To", "Stop" }; - private static List collectorRadii = new List() { 3f, 5f, 10f, 15f, 20f, 30f, 40f, 50f }; + private static List waypointTypes = new List() { "Drive To", "Stop" }; + private static List waypointSpeeds = new List() { 5f, 10f, 15f, 20f, 30f, 40f, 50f, 60f, 70f }; + private static List collectorRadii = new List() { 3f, 5f, 10f, 15f, 20f, 30f, 40f, 50f }; private static VehicleDrivingFlags[] drivingFlags = new VehicleDrivingFlags[] { VehicleDrivingFlags.Normal, VehicleDrivingFlags.StopAtDestination }; // Implement custom driving flag for normal - // Called from EditPathMenu + internal static void InstantiateMenu() + { + pathCreationMenu = new UIMenu("Scene Menu", "~o~Path Creation"); + pathCreationMenu.ParentMenu = PathMainMenu.pathMainMenu; + MenuManager.menuPool.Add(pathCreationMenu); + } + public static void BuildPathCreationMenu() { - MenuManager.pathCreationMenu.AddItem(waypointType = new UIMenuListItem("Waypoint Type", waypointTypes, 0)); - MenuManager.pathCreationMenu.AddItem(waypointSpeed = new UIMenuListItem($"Waypoint Speed (in {SettingsMenu.speedUnits.SelectedItem})", waypointSpeeds, 0)); - MenuManager.pathCreationMenu.AddItem(collectorWaypoint = new UIMenuCheckboxItem("Collector", true)); // true if path's first waypoint - MenuManager.pathCreationMenu.AddItem(collectorRadius = new UIMenuListItem("Collection Radius", collectorRadii, 0)); - MenuManager.pathCreationMenu.AddItem(trafficAddWaypoint = new UIMenuItem("Add waypoint")); - MenuManager.pathCreationMenu.AddItem(trafficRemoveWaypoint = new UIMenuItem("Remove last waypoint")); + pathCreationMenu.AddItem(waypointType = new UIMenuListScrollerItem("Waypoint Type", "", waypointTypes)); + pathCreationMenu.AddItem(waypointSpeed = new UIMenuListScrollerItem($"Waypoint Speed (in {SettingsMenu.speedUnits.SelectedItem}", "", waypointSpeeds)); + pathCreationMenu.AddItem(collectorWaypoint = new UIMenuCheckboxItem("Collector", true)); // true if path's first waypoint + pathCreationMenu.AddItem(collectorRadius = new UIMenuListScrollerItem("Collection Radius", "", collectorRadii)); + pathCreationMenu.AddItem(trafficAddWaypoint = new UIMenuItem("Add waypoint")); + pathCreationMenu.AddItem(trafficRemoveWaypoint = new UIMenuItem("Remove last waypoint")); trafficRemoveWaypoint.Enabled = false; - MenuManager.pathCreationMenu.AddItem(trafficEndPath = new UIMenuItem("End path creation")); + pathCreationMenu.AddItem(trafficEndPath = new UIMenuItem("End path creation")); - MenuManager.pathCreationMenu.RefreshIndex(); - MenuManager.pathCreationMenu.OnItemSelect += PathCreation_OnItemSelected; + pathCreationMenu.RefreshIndex(); + pathCreationMenu.OnItemSelect += PathCreation_OnItemSelected; } private static void PathCreation_OnItemSelected(UIMenu sender, UIMenuItem selectedItem, int index) @@ -44,10 +51,10 @@ namespace SceneManager // Do I need to implement a distance restriction? Idiots place waypoints unnecessarily close, possibly causing AI to drive in circles if (selectedItem == trafficAddWaypoint) { - var firstNonNullPath = TrafficMenu.paths.Where(p => p != null && !p.PathFinished).First(); - var pathIndex = TrafficMenu.paths.IndexOf(firstNonNullPath); + var firstNonNullPath = PathMainMenu.GetPaths().Where(p => p != null && !p.PathFinished).First(); + var pathIndex = PathMainMenu.GetPaths().IndexOf(firstNonNullPath); var currentPath = pathIndex + 1; - var currentWaypoint = TrafficMenu.paths[pathIndex].Waypoints.Count + 1; + var currentWaypoint = PathMainMenu.GetPaths()[pathIndex].Waypoints.Count + 1; var drivingFlag = drivingFlags[waypointType.Index]; var blip = CreateWaypointBlip(pathIndex); @@ -57,35 +64,35 @@ namespace SceneManager ? (uint)World.AddSpeedZone(Game.LocalPlayer.Character.Position, 50f, MathHelper.ConvertMilesPerHourToMetersPerSecond(waypointSpeeds[waypointSpeed.Index])) : (uint)World.AddSpeedZone(Game.LocalPlayer.Character.Position, 50f, MathHelper.ConvertKilometersPerHourToMetersPerSecond(waypointSpeeds[waypointSpeed.Index])); - TrafficMenu.paths[pathIndex].Waypoints.Add(new Waypoint(currentPath, currentWaypoint, Game.LocalPlayer.Character.Position, SetDriveSpeedForWaypoint(), drivingFlag, blip, true, collectorRadii[collectorRadius.Index], yieldZone)); + PathMainMenu.GetPaths()[pathIndex].Waypoints.Add(new Waypoint(currentPath, currentWaypoint, Game.LocalPlayer.Character.Position, SetDriveSpeedForWaypoint(), drivingFlag, blip, true, collectorRadii[collectorRadius.Index], yieldZone)); } else { - TrafficMenu.paths[pathIndex].Waypoints.Add(new Waypoint(currentPath, currentWaypoint, Game.LocalPlayer.Character.Position, SetDriveSpeedForWaypoint(), drivingFlag, blip)); + PathMainMenu.GetPaths()[pathIndex].Waypoints.Add(new Waypoint(currentPath, currentWaypoint, Game.LocalPlayer.Character.Position, SetDriveSpeedForWaypoint(), drivingFlag, blip)); } Game.LogTrivial($"[Path {currentPath}] Waypoint {currentWaypoint} ({drivingFlag.ToString()}) added"); // Refresh the trafficMenu after a waypoint is added in order to show Continue Creating Current Path instead of Create New Path - RefreshTrafficMenu(); + PathMainMenu.RefreshMenu(trafficRemoveWaypoint); } if (selectedItem == trafficRemoveWaypoint) { // Loop through each path and find the first one which isn't finished, then delete the path's last waypoint and corresponding blip - for (int i = 0; i < TrafficMenu.paths.Count; i++) + for (int i = 0; i < PathMainMenu.GetPaths().Count; i++) { - if (TrafficMenu.paths.ElementAtOrDefault(i) != null && !TrafficMenu.paths[i].PathFinished) + if (PathMainMenu.GetPaths().ElementAtOrDefault(i) != null && !PathMainMenu.GetPaths()[i].PathFinished) { - Game.LogTrivial($"[Path {i + 1}] {TrafficMenu.paths[i].Waypoints.Last().DrivingFlag.ToString()} waypoint removed"); - TrafficMenu.paths[i].Waypoints.Last().Blip.Delete(); - if (TrafficMenu.paths[i].Waypoints.Last().CollectorRadiusBlip) + Game.LogTrivial($"[Path {i + 1}] {PathMainMenu.GetPaths()[i].Waypoints.Last().DrivingFlag.ToString()} waypoint removed"); + PathMainMenu.GetPaths()[i].Waypoints.Last().Blip.Delete(); + if (PathMainMenu.GetPaths()[i].Waypoints.Last().CollectorRadiusBlip) { - TrafficMenu.paths[i].Waypoints.Last().CollectorRadiusBlip.Delete(); + PathMainMenu.GetPaths()[i].Waypoints.Last().CollectorRadiusBlip.Delete(); } - TrafficMenu.paths[i].Waypoints.RemoveAt(TrafficMenu.paths[i].Waypoints.IndexOf(TrafficMenu.paths[i].Waypoints.Last())); + PathMainMenu.GetPaths()[i].Waypoints.RemoveAt(PathMainMenu.GetPaths()[i].Waypoints.IndexOf(PathMainMenu.GetPaths()[i].Waypoints.Last())); // If the path has no waypoints, disable the menu option to remove a waypoint - if (TrafficMenu.paths[i].Waypoints.Count == 0) + if (PathMainMenu.GetPaths()[i].Waypoints.Count == 0) { trafficRemoveWaypoint.Enabled = false; } @@ -96,10 +103,10 @@ namespace SceneManager if (selectedItem == trafficEndPath) { // Loop through each path and find the first one which isn't finished - for (int i = 0; i < TrafficMenu.paths.Count; i++) + for (int i = 0; i < PathMainMenu.GetPaths().Count; i++) { - var currentPath = TrafficMenu.paths[i]; - if (TrafficMenu.paths.ElementAtOrDefault(i) != null && !currentPath.PathFinished) + var currentPath = PathMainMenu.GetPaths()[i]; + if (PathMainMenu.GetPaths().ElementAtOrDefault(i) != null && !currentPath.PathFinished) { // If the path has one stop waypoint or at least two waypoints, finish the path and start the vehicle collector loop, else show user the error and delete any waypoints they made and clear the invalid path if (currentPath.Waypoints.Count >= 2 || (currentPath.Waypoints.Count == 1 && currentPath.Waypoints[0].DrivingFlag == VehicleDrivingFlags.StopAtDestination)) @@ -114,32 +121,32 @@ namespace SceneManager currentPath.FinishPath(); currentPath.EnablePath(); currentPath.SetPathNumber(i + 1); - TrafficMenu.pathsNum.Insert(i, currentPath.PathNum); + PathMainMenu.AddPathToPathCountList(i, currentPath.PathNum); //GameFiber InitialWaypointVehicleCollectorFiber = new GameFiber(() => TrafficPathing.InitialWaypointVehicleCollector(paths[i])); //InitialWaypointVehicleCollectorFiber.Start(); // For each waypoint in the path's WaypointData, start a collector game fiber and loop while the path and waypoint exist, and while the path is enabled - foreach (Waypoint wd in TrafficMenu.paths[i].Waypoints) + foreach (Waypoint wd in PathMainMenu.GetPaths()[i].Waypoints) { - GameFiber WaypointVehicleCollectorFiber = new GameFiber(() => TrafficPathing.WaypointVehicleCollector(TrafficMenu.paths, TrafficMenu.paths[i], wd)); + GameFiber WaypointVehicleCollectorFiber = new GameFiber(() => TrafficPathing.WaypointVehicleCollector(PathMainMenu.GetPaths(), PathMainMenu.GetPaths()[i], wd)); WaypointVehicleCollectorFiber.Start(); - GameFiber AssignStopForVehiclesFlagFiber = new GameFiber(() => TrafficPathing.AssignStopForVehiclesFlag(TrafficMenu.paths, TrafficMenu.paths[i], wd)); + GameFiber AssignStopForVehiclesFlagFiber = new GameFiber(() => TrafficPathing.AssignStopForVehiclesFlag(PathMainMenu.GetPaths(), PathMainMenu.GetPaths()[i], wd)); AssignStopForVehiclesFlagFiber.Start(); } MenuManager.menuPool.CloseAllMenus(); - MenuManager.pathMenu.Clear(); - TrafficMenu.BuildPathMenu(); - MenuManager.pathMenu.Visible = true; + PathMainMenu.pathMainMenu.Clear(); + PathMainMenu.BuildPathMenu(); + PathMainMenu.pathMainMenu.Visible = true; break; } else { Game.LogTrivial($"[Path Error] A minimum of 2 waypoints is required."); Game.DisplayNotification($"~o~Scene Manager\n~r~[Error]~w~ A minimum of 2 waypoints or one stop waypoint is required to create a path."); - foreach (Waypoint wp in TrafficMenu.paths[i].Waypoints) + foreach (Waypoint wp in PathMainMenu.GetPaths()[i].Waypoints) { wp.Blip.Delete(); if (wp.CollectorRadiusBlip) @@ -147,8 +154,8 @@ namespace SceneManager wp.CollectorRadiusBlip.Delete(); } } - TrafficMenu.paths[i].Waypoints.Clear(); - TrafficMenu.paths.RemoveAt(i); + PathMainMenu.GetPaths()[i].Waypoints.Clear(); + PathMainMenu.GetPaths().RemoveAt(i); break; } } @@ -187,7 +194,7 @@ namespace SceneManager Sprite = (BlipSprite)spriteNumericalEnum }; - if (TrafficMenu.paths[pathIndex].Waypoints.Count == 0) + if (PathMainMenu.GetPaths()[pathIndex].Waypoints.Count == 0) { blip.Color = Color.Orange; } @@ -199,26 +206,36 @@ namespace SceneManager return blip; } - private static void RefreshTrafficMenu() + public static void AddNewPathToPathsCollection(List paths, int pathIndex) { - trafficRemoveWaypoint.Enabled = true; - MenuManager.pathMenu.Clear(); - MenuManager.pathMenu.AddItem(TrafficMenu.createNewPath = new UIMenuItem("Continue Creating Current Path")); - MenuManager.pathMenu.AddItem(TrafficMenu.deleteAllPaths = new UIMenuItem("Delete All Paths")); - MenuManager.pathMenu.AddItem(TrafficMenu.directDriver = new UIMenuListItem("Direct nearest driver to path", TrafficMenu.pathsNum, 0)); - MenuManager.pathMenu.AddItem(TrafficMenu.dismissDriver = new UIMenuListItem("Dismiss nearest driver", TrafficMenu.dismissOptions, 0)); - - if (TrafficMenu.paths.Count == 8) - { - TrafficMenu.createNewPath.Enabled = false; - } - if (TrafficMenu.paths.Count == 0) - { - TrafficMenu.editPath.Enabled = false; - TrafficMenu.deleteAllPaths.Enabled = false; - TrafficMenu.disableAllPaths.Enabled = false; - TrafficMenu.directDriver.Enabled = false; - } + var pathNum = pathIndex + 1; + Game.LogTrivial($"Creating path {pathNum}"); + Game.DisplayNotification($"~o~Scene Manager\n~y~[Creating]~w~ Path {pathNum} started."); + paths.Insert(pathIndex, new Path(pathNum, false)); + trafficRemoveWaypoint.Enabled = false; } + + //private static void RefreshPathMainMenu() + //{ + // trafficRemoveWaypoint.Enabled = true; + // MenuManager.pathMenu.Clear(); + // //MenuManager.pathMenu.AddItem(PathMainMenu.AddNewMenuItem()) + // MenuManager.pathMenu.AddItem(PathMainMenu.createNewPath = new UIMenuItem("Continue Creating Current Path")); + // MenuManager.pathMenu.AddItem(PathMainMenu.deleteAllPaths = new UIMenuItem("Delete All Paths")); + // MenuManager.pathMenu.AddItem(PathMainMenu.directDriver = new UIMenuListScrollerItem("Direct nearest driver to path", "")); + // MenuManager.pathMenu.AddItem(PathMainMenu.dismissDriver = new UIMenuListScrollerItem("Dismiss nearest driver", "")); + + // if (PathMainMenu.GetPaths().Count == 8) + // { + // PathMainMenu.createNewPath.Enabled = false; + // } + // if (PathMainMenu.GetPaths().Count == 0) + // { + // PathMainMenu.editPath.Enabled = false; + // PathMainMenu.deleteAllPaths.Enabled = false; + // PathMainMenu.disableAllPaths.Enabled = false; + // PathMainMenu.directDriver.Enabled = false; + // } + //} } } diff --git a/SceneManager/Menus/TrafficMenu.cs b/SceneManager/Menus/PathMainMenu.cs similarity index 75% rename from SceneManager/Menus/TrafficMenu.cs rename to SceneManager/Menus/PathMainMenu.cs index 5315522..1cd2d39 100644 --- a/SceneManager/Menus/TrafficMenu.cs +++ b/SceneManager/Menus/PathMainMenu.cs @@ -7,31 +7,45 @@ using RAGENativeUI.Elements; namespace SceneManager { - static class TrafficMenu + static class PathMainMenu { - #pragma warning disable CS0618 // Type or member is obsolete, clear NUI squiggles - public static UIMenuItem createNewPath, deleteAllPaths; - public static UIMenuListItem editPath, directDriver, dismissDriver; - public static UIMenuCheckboxItem disableAllPaths; - - public static List pathsNum = new List() { }; - public static List paths = new List() { }; - public static List dismissOptions = new List() { "From path", "From waypoint", "From position" }; + public static UIMenu pathMainMenu { get; private set; } + private static UIMenuItem createNewPath, deleteAllPaths; + public static UIMenuListScrollerItem editPath { get; private set; } + public static UIMenuListScrollerItem directDriver { get; private set; } + public static UIMenuListScrollerItem dismissDriver { get; private set; } + public static UIMenuCheckboxItem disableAllPaths { get; private set; } + + private static List pathsNum = new List(); + private static List paths = new List() { }; + private static List dismissOptions = new List() { "From path", "From waypoint", "From position" }; + public enum Delete + { + Single, + All + } + + internal static void InstantiateMenu() + { + pathMainMenu = new UIMenu("Scene Menu", "~o~Path Manager Main Menu"); + pathMainMenu.ParentMenu = MainMenu.mainMenu; + MenuManager.menuPool.Add(pathMainMenu); + } public static void BuildPathMenu() { // New stuff to mitigate Rebuild method - MenuManager.pathMenu.OnItemSelect -= PathMenu_OnItemSelected; - MenuManager.pathMenu.OnCheckboxChange -= PathMenu_OnCheckboxChange; + pathMainMenu.OnItemSelect -= PathMenu_OnItemSelected; + pathMainMenu.OnCheckboxChange -= PathMenu_OnCheckboxChange; MenuManager.menuPool.CloseAllMenus(); - MenuManager.pathMenu.Clear(); + pathMainMenu.Clear(); - MenuManager.pathMenu.AddItem(createNewPath = new UIMenuItem("Create New Path")); - MenuManager.pathMenu.AddItem(editPath = new UIMenuListItem("Edit Path", pathsNum, 0)); - MenuManager.pathMenu.AddItem(disableAllPaths = new UIMenuCheckboxItem("Disable All Paths", false)); - MenuManager.pathMenu.AddItem(deleteAllPaths = new UIMenuItem("Delete All Paths")); - MenuManager.pathMenu.AddItem(directDriver = new UIMenuListItem("Direct nearest driver to path", pathsNum, 0)); - MenuManager.pathMenu.AddItem(dismissDriver = new UIMenuListItem("Dismiss nearest driver", dismissOptions, 0)); + pathMainMenu.AddItem(createNewPath = new UIMenuItem("Create New Path")); + pathMainMenu.AddItem(editPath = new UIMenuListScrollerItem("Edit Path", "", pathsNum)); + pathMainMenu.AddItem(disableAllPaths = new UIMenuCheckboxItem("Disable All Paths", false)); + pathMainMenu.AddItem(deleteAllPaths = new UIMenuItem("Delete All Paths")); + pathMainMenu.AddItem(directDriver = new UIMenuListScrollerItem("Direct nearest driver to path", "", pathsNum)); + pathMainMenu.AddItem(dismissDriver = new UIMenuListScrollerItem("Dismiss nearest driver", "", dismissOptions)); if (paths.Count == 8) { @@ -45,14 +59,46 @@ namespace SceneManager directDriver.Enabled = false; } - MenuManager.pathMenu.RefreshIndex(); - MenuManager.pathMenu.OnItemSelect += PathMenu_OnItemSelected; - MenuManager.pathMenu.OnCheckboxChange += PathMenu_OnCheckboxChange; + pathMainMenu.RefreshIndex(); + pathMainMenu.OnItemSelect += PathMenu_OnItemSelected; + pathMainMenu.OnCheckboxChange += PathMenu_OnCheckboxChange; // New stuff to mitigate Rebuild method MenuManager.menuPool.RefreshIndex(); } + public static ref List GetPaths() + { + return ref paths; + } + + public static void AddPathToPathCountList(int indexToInsertAt, int pathNum) + { + pathsNum.Insert(indexToInsertAt, pathNum); + } + + public static void RefreshMenu(UIMenuItem trafficRemoveWaypoint) + { + trafficRemoveWaypoint.Enabled = true; + pathMainMenu.Clear(); + pathMainMenu.AddItem(createNewPath = new UIMenuItem("Continue Creating Current Path")); + pathMainMenu.AddItem(deleteAllPaths = new UIMenuItem("Delete All Paths")); + pathMainMenu.AddItem(directDriver = new UIMenuListScrollerItem("Direct nearest driver to path", "")); + pathMainMenu.AddItem(dismissDriver = new UIMenuListScrollerItem("Dismiss nearest driver", "")); + + if (GetPaths().Count == 8) + { + createNewPath.Enabled = false; + } + if (GetPaths().Count == 0) + { + editPath.Enabled = false; + deleteAllPaths.Enabled = false; + disableAllPaths.Enabled = false; + directDriver.Enabled = false; + } + } + private static bool VehicleAndDriverValid(this Vehicle v) { if (v && v.HasDriver && v.Driver && v.Driver.IsAlive) @@ -79,8 +125,7 @@ namespace SceneManager } } - // Refactor string param to enum - public static void DeletePath(Path path, int index, string pathsToDelete) + public static void DeletePath(Path path, int index, Delete pathsToDelete) { // Before deleting a path, we need to dismiss any vehicles controlled by that path and remove the vehicles from ControlledVehicles //Game.LogTrivial($"Deleting path {index+1}"); @@ -96,7 +141,7 @@ namespace SceneManager cv.Value.Vehicle.Driver.IsPersistent = false; cv.Value.Vehicle.Dismiss(); cv.Value.Vehicle.IsPersistent = false; - //TrafficPathing.ControlledVehicles.Remove(cv.Value.LicensePlate); + //Game.LogTrivial($"{cv.vehicle.Model.Name} cleared from path {cv.path}"); TrafficPathing.collectedVehicles.Remove(cv.Value.LicensePlate); } @@ -122,20 +167,19 @@ namespace SceneManager Game.LogTrivial($"Clearing path.WaypointData"); path.Waypoints.Clear(); // Manipulating the menu to reflect specific paths being deleted - if (pathsToDelete == "Single") + if (pathsToDelete == Delete.Single) { paths.RemoveAt(index); //Game.LogTrivial("pathsNum count: " + pathsNum.Count); //Game.LogTrivial("index: " + index); pathsNum.RemoveAt(index); - //RebuildTrafficMenu(); BuildPathMenu(); - MenuManager.pathMenu.Visible = true; + pathMainMenu.Visible = true; Game.LogTrivial($"Path {path.PathNum} deleted."); Game.DisplayNotification($"~o~Scene Manager\n~w~Path {path.PathNum} deleted."); } - MenuManager.editPathMenu.Reset(true, true); + EditPathMenu.editPathMenu.Reset(true, true); EditPathMenu.togglePath.Enabled = true; } @@ -143,8 +187,8 @@ namespace SceneManager { if (selectedItem == createNewPath) { - MenuManager.pathMenu.Visible = false; - MenuManager.pathCreationMenu.Visible = true; + pathMainMenu.Visible = false; + PathCreationMenu.pathCreationMenu.Visible = true; // For each element in paths, determine if the element exists but is not finished yet, or if it doesn't exist, create it. for (int i = 0; i <= paths.Count; i++) @@ -158,10 +202,11 @@ namespace SceneManager } else if (paths.ElementAtOrDefault(i) == null) { - Game.LogTrivial($"Creating path {i + 1}"); - Game.DisplayNotification($"~o~Scene Manager\n~y~[Creating]~w~ Path {i + 1} started."); - paths.Insert(i, new Path(i + 1, false)); - PathCreationMenu.trafficRemoveWaypoint.Enabled = false; + PathCreationMenu.AddNewPathToPathsCollection(paths, i); + //Game.LogTrivial($"Creating path {i + 1}"); + //Game.DisplayNotification($"~o~Scene Manager\n~y~[Creating]~w~ Path {i + 1} started."); + //paths.Insert(i, new Path(i + 1, false)); + //PathCreationMenu.trafficRemoveWaypoint.Enabled = false; if (SettingsMenu.debugGraphics.Checked) { @@ -177,8 +222,8 @@ namespace SceneManager if (selectedItem == editPath) { - MenuManager.pathMenu.Visible = false; - MenuManager.editPathMenu.Visible = true; + pathMainMenu.Visible = false; + EditPathMenu.editPathMenu.Visible = true; } if (selectedItem == deleteAllPaths) @@ -186,17 +231,20 @@ namespace SceneManager // Iterate through each item in paths and delete it for (int i = 0; i < paths.Count; i++) { - DeletePath(paths[i], i, "All"); + DeletePath(paths[i], i, Delete.All); } foreach (Path path in paths) { + foreach(Waypoint wp in path.Waypoints.Where(wp => wp.YieldZone != 0)) + { + World.RemoveSpeedZone(wp.YieldZone); + } path.Waypoints.Clear(); } paths.Clear(); pathsNum.Clear(); - //RebuildTrafficMenu(); BuildPathMenu(); - MenuManager.pathMenu.Visible = true; + pathMainMenu.Visible = true; Game.LogTrivial($"All paths deleted"); Game.DisplayNotification($"~o~Scene Manager\n~w~All paths deleted."); } diff --git a/SceneManager/Menus/SettingsMenu.cs b/SceneManager/Menus/SettingsMenu.cs index ef0048c..e89606a 100644 --- a/SceneManager/Menus/SettingsMenu.cs +++ b/SceneManager/Menus/SettingsMenu.cs @@ -7,6 +7,7 @@ namespace SceneManager { class SettingsMenu { + public static UIMenu settingsMenu { get; private set; } public static UIMenuCheckboxItem debugGraphics; public static UIMenuListScrollerItem speedUnits; public enum SpeedUnitsOfMeasure @@ -15,13 +16,20 @@ namespace SceneManager KPH } + internal static void InstantiateMenu() + { + settingsMenu = new UIMenu("Scene Menu", "~o~Plugin Settings"); + settingsMenu.ParentMenu = MainMenu.mainMenu; + MenuManager.menuPool.Add(settingsMenu); + } + public static void BuildSettingsMenu() { - MenuManager.settingsMenu.AddItem(debugGraphics = new UIMenuCheckboxItem("Enable Debug Graphics", false)); - MenuManager.settingsMenu.AddItem(speedUnits = new UIMenuListScrollerItem("Speed Unit of Measure", "", new[] { SpeedUnitsOfMeasure.MPH, SpeedUnitsOfMeasure.KPH })); + settingsMenu.AddItem(debugGraphics = new UIMenuCheckboxItem("Enable Debug Graphics", false)); + settingsMenu.AddItem(speedUnits = new UIMenuListScrollerItem("Speed Unit of Measure", "", new[] { SpeedUnitsOfMeasure.MPH, SpeedUnitsOfMeasure.KPH })); - MenuManager.settingsMenu.OnCheckboxChange += SettingsMenu_OnCheckboxChange; - MenuManager.settingsMenu.OnScrollerChange += SettingsMenu_OnScrollerChange; + settingsMenu.OnCheckboxChange += SettingsMenu_OnCheckboxChange; + settingsMenu.OnScrollerChange += SettingsMenu_OnScrollerChange; } private static void SettingsMenu_OnCheckboxChange(UIMenu sender, UIMenuCheckboxItem checkboxItem, bool @checked) @@ -32,7 +40,7 @@ namespace SceneManager // TODO: Add branch for this during path creation ... create temp Waypoint list during path creation, then assign to path[i] after creation? if (debugGraphics.Checked) { - foreach (Path path in TrafficMenu.paths) + foreach (Path path in PathMainMenu.GetPaths()) { GameFiber.StartNew(() => { @@ -47,7 +55,8 @@ namespace SceneManager { if (scrollerItem == speedUnits) { - MenuManager.pathCreationMenu.Clear(); + // Clear the menu and rebuild it to reflect the menu item text change + PathCreationMenu.pathCreationMenu.Clear(); PathCreationMenu.BuildPathCreationMenu(); } } diff --git a/SceneManager/SceneManager.csproj b/SceneManager/SceneManager.csproj index 574a416..4a0382b 100644 --- a/SceneManager/SceneManager.csproj +++ b/SceneManager/SceneManager.csproj @@ -63,7 +63,7 @@ - +