From a7fd140e1f1355768875aab4828255245cc36f65 Mon Sep 17 00:00:00 2001 From: Rich Dunne Date: Wed, 26 Aug 2020 19:16:28 -0600 Subject: [PATCH] Created new Hints class. Implemented Hints.Display method. Added option to SettingsMenu to enable/disable hints in-game. --- SceneManager/EntryPoint.cs | 11 +++++------ SceneManager/Hints.cs | 17 +++++++++++++++++ SceneManager/Menus/BarrierMenu.cs | 7 +++---- SceneManager/Menus/SettingsMenu.cs | 17 +++++++++++------ SceneManager/SceneManager.csproj | 1 + 5 files changed, 37 insertions(+), 16 deletions(-) create mode 100644 SceneManager/Hints.cs diff --git a/SceneManager/EntryPoint.cs b/SceneManager/EntryPoint.cs index 71e2595..1fcc7a3 100644 --- a/SceneManager/EntryPoint.cs +++ b/SceneManager/EntryPoint.cs @@ -17,8 +17,7 @@ namespace SceneManager GetAssemblyVersion(); MenuManager.InstantiateMenus(); - if (Settings.EnableHints) - DisplayHintsToOpenMenu(); + DisplayHintsToOpenMenu(); GameFiber UserInputFiber = new GameFiber(() => GetUserInput.LoopForUserInput()); UserInputFiber.Start(); @@ -36,19 +35,19 @@ namespace SceneManager { if (Settings.ModifierKey == Keys.None && Settings.ModifierButton == ControllerButtons.None) { - Game.DisplayNotification($"~o~Scene Manager\n~y~[Hint]~w~ To open the menu, press the ~b~{Settings.ToggleKey} key ~w~or ~b~{Settings.ToggleButton} button ~w~while on foot"); + Hints.Display($"~o~Scene Manager\n~y~[Hint]~w~ To open the menu, press the ~b~{Settings.ToggleKey} key ~w~or ~b~{Settings.ToggleButton} button ~w~while on foot"); } else if (Settings.ModifierKey == Keys.None) { - Game.DisplayNotification($"~o~Scene Manager\n~y~[Hint]~w~ To open the menu, press the ~b~{Settings.ToggleKey} key ~w~or ~b~{Settings.ModifierButton} ~w~+ ~b~{Settings.ToggleButton} buttons ~w~while on foot"); + Hints.Display($"~o~Scene Manager\n~y~[Hint]~w~ To open the menu, press the ~b~{Settings.ToggleKey} key ~w~or ~b~{Settings.ModifierButton} ~w~+ ~b~{Settings.ToggleButton} buttons ~w~while on foot"); } else if (Settings.ModifierButton == ControllerButtons.None) { - Game.DisplayNotification($"~o~Scene Manager\n~y~[Hint]~w~ To open the menu, press ~b~{Settings.ModifierKey} ~w~+ ~b~{Settings.ToggleKey} ~w~or the ~b~{Settings.ToggleButton} button ~w~while on foot"); + Hints.Display($"~o~Scene Manager\n~y~[Hint]~w~ To open the menu, press ~b~{Settings.ModifierKey} ~w~+ ~b~{Settings.ToggleKey} ~w~or the ~b~{Settings.ToggleButton} button ~w~while on foot"); } else { - Game.DisplayNotification($"~o~Scene Manager\n~y~[Hint]~w~ To open the menu, press the ~b~{Settings.ModifierKey} ~w~+ ~b~{Settings.ToggleKey} keys ~w~or ~b~{Settings.ModifierButton} ~w~+ ~b~{Settings.ToggleButton} buttons ~w~while on foot"); + Hints.Display($"~o~Scene Manager\n~y~[Hint]~w~ To open the menu, press the ~b~{Settings.ModifierKey} ~w~+ ~b~{Settings.ToggleKey} keys ~w~or ~b~{Settings.ModifierButton} ~w~+ ~b~{Settings.ToggleButton} buttons ~w~while on foot"); } } diff --git a/SceneManager/Hints.cs b/SceneManager/Hints.cs new file mode 100644 index 0000000..b1410be --- /dev/null +++ b/SceneManager/Hints.cs @@ -0,0 +1,17 @@ +using Rage; + +namespace SceneManager +{ + class Hints + { + public static bool Enabled { get; set; } = SettingsMenu.hints.Checked; + + public static void Display(string message) + { + if (Enabled) + { + Game.DisplayNotification($"{message}"); + } + } + } +} diff --git a/SceneManager/Menus/BarrierMenu.cs b/SceneManager/Menus/BarrierMenu.cs index 7e65fa5..fc4768e 100644 --- a/SceneManager/Menus/BarrierMenu.cs +++ b/SceneManager/Menus/BarrierMenu.cs @@ -15,7 +15,6 @@ namespace SceneManager public static UIMenu barrierMenu { get; private set; } public static List barriers = new List() { }; - // TODO: Refactor as dictionary private static UIMenuListScrollerItem barrierList = new UIMenuListScrollerItem("Select Barrier", "", new[] { "Large Striped Cone", "Large Cone", "Medium Striped Cone", "Medium Cone", "Roadpole A", "Roadpole B", "Police Barrier", "Road Barrier", "Flare" }); private static string[] barrierObjectNames = new string[] { "prop_mp_cone_01", "prop_roadcone01c", "prop_mp_cone_02", "prop_mp_cone_03", "prop_roadpole_01a", "prop_roadpole_01b", "prop_barrier_work05", "prop_barrier_work06a", "prop_flare_01b" }; private static UIMenuNumericScrollerItem rotateBarrier = new UIMenuNumericScrollerItem("Rotate Barrier", "Rotate the barrier.", 0, 350, 10); @@ -48,12 +47,12 @@ namespace SceneManager public static void CreateShadowBarrier(UIMenu barrierMenu) { - if (EntryPoint.Settings.EnableHints) + if (Settings.EnableHints) { - Game.DisplayNotification($"~o~Scene Manager\n~y~[Hint]~y~ ~w~The shadow cone will disappear if you aim too far away."); + Hints.Display($"~o~Scene Manager\n~y~[Hint]~y~ ~w~The shadow cone will disappear if you aim too far away."); } - //Game.LogTrivial("Creating shadow cone"); + //Game.LogTrivial("Creating shadow barrier"); if (shadowBarrier) shadowBarrier.Delete(); diff --git a/SceneManager/Menus/SettingsMenu.cs b/SceneManager/Menus/SettingsMenu.cs index 2d19bce..e9fdc03 100644 --- a/SceneManager/Menus/SettingsMenu.cs +++ b/SceneManager/Menus/SettingsMenu.cs @@ -7,8 +7,9 @@ namespace SceneManager class SettingsMenu { public static UIMenu settingsMenu { get; private set; } - public static UIMenuCheckboxItem debugGraphics; - public static UIMenuListScrollerItem speedUnits; + public static UIMenuCheckboxItem debugGraphics = new UIMenuCheckboxItem("Enable 3D Waypoints", false), + hints = new UIMenuCheckboxItem("Enable Hints", true); + public static UIMenuListScrollerItem speedUnits = new UIMenuListScrollerItem("Speed Unit of Measure", "", new[] { SpeedUnitsOfMeasure.MPH, SpeedUnitsOfMeasure.KPH }); public enum SpeedUnitsOfMeasure { MPH, @@ -24,8 +25,9 @@ namespace SceneManager public static void BuildSettingsMenu() { - settingsMenu.AddItem(debugGraphics = new UIMenuCheckboxItem("Enable Debug Graphics", false)); - settingsMenu.AddItem(speedUnits = new UIMenuListScrollerItem("Speed Unit of Measure", "", new[] { SpeedUnitsOfMeasure.MPH, SpeedUnitsOfMeasure.KPH })); + settingsMenu.AddItem(debugGraphics); + settingsMenu.AddItem(hints); + settingsMenu.AddItem(speedUnits); settingsMenu.OnCheckboxChange += SettingsMenu_OnCheckboxChange; settingsMenu.OnScrollerChange += SettingsMenu_OnScrollerChange; @@ -35,8 +37,6 @@ namespace SceneManager { if (checkboxItem == debugGraphics) { - // TODO: Fix graphics don't display when new path is created, have to uncheck and re-check the option - // 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 PathMainMenu.GetPaths()) @@ -48,6 +48,11 @@ namespace SceneManager } } } + + if(checkboxItem == hints) + { + Hints.Enabled = hints.Checked ? true : false; + } } private static void SettingsMenu_OnScrollerChange(UIMenu sender, UIMenuScrollerItem scrollerItem, int oldIndex, int newIndex) diff --git a/SceneManager/SceneManager.csproj b/SceneManager/SceneManager.csproj index 445b816..0c98606 100644 --- a/SceneManager/SceneManager.csproj +++ b/SceneManager/SceneManager.csproj @@ -52,6 +52,7 @@ +