mirror of
https://github.com/thegeneralist01/Scene-Manager-DevRepo
synced 2026-01-11 15:40:29 +01:00
Refactored driver options to separate menu
This commit is contained in:
parent
4e2fbe7afe
commit
1be5bea839
1 changed files with 39 additions and 33 deletions
|
|
@ -4,8 +4,10 @@ using System.Linq;
|
||||||
using Rage;
|
using Rage;
|
||||||
using RAGENativeUI;
|
using RAGENativeUI;
|
||||||
using RAGENativeUI.Elements;
|
using RAGENativeUI.Elements;
|
||||||
using SceneManager.Objects;
|
using SceneManager.Managers;
|
||||||
|
using SceneManager.Paths;
|
||||||
using SceneManager.Utils;
|
using SceneManager.Utils;
|
||||||
|
using SceneManager.Waypoints;
|
||||||
|
|
||||||
namespace SceneManager.Menus
|
namespace SceneManager.Menus
|
||||||
{
|
{
|
||||||
|
|
@ -14,14 +16,14 @@ namespace SceneManager.Menus
|
||||||
private static int MAX_PATH_LIMIT { get; } = 10;
|
private static int MAX_PATH_LIMIT { get; } = 10;
|
||||||
internal static List<string> ImportedPaths { get; } = new List<string>();
|
internal static List<string> ImportedPaths { get; } = new List<string>();
|
||||||
private static string[] DismissOptions { get; } = new string[] { "From path", "From waypoint", "From world" };
|
private static string[] DismissOptions { get; } = new string[] { "From path", "From waypoint", "From world" };
|
||||||
internal static UIMenu Menu { get; } = new UIMenu("Scene Manager", "~o~Path Manager Main Menu");
|
internal static UIMenu Menu { get; } = new UIMenu("Scene Manager", "~o~Path Manager");
|
||||||
internal static UIMenuItem CreateNewPath { get; } = new UIMenuItem("Create New Path");
|
internal static UIMenuItem CreateNewPath { get; } = new UIMenuItem("Create New Path");
|
||||||
internal static UIMenuListScrollerItem<string> ImportPath { get; } = new UIMenuListScrollerItem<string>("Import Path", "Import a saved path", ImportedPaths);
|
internal static UIMenuListScrollerItem<string> ImportPath { get; } = new UIMenuListScrollerItem<string>("Import Path", "Import a saved path from ~b~plugins/SceneManager/Saved Paths", ImportedPaths);
|
||||||
internal static UIMenuItem DeleteAllPaths { get; } = new UIMenuItem("Delete All Paths");
|
internal static UIMenuItem DeleteAllPaths { get; } = new UIMenuItem("Delete All Paths");
|
||||||
internal static UIMenuNumericScrollerItem<int> EditPath { get; private set; }
|
internal static UIMenuListScrollerItem<string> EditPath { get; private set; }
|
||||||
internal static UIMenuListScrollerItem<string> DirectOptions { get; } = new UIMenuListScrollerItem<string>("Direct driver to path's", "", new[] { "First waypoint", "Nearest waypoint" });
|
//internal static UIMenuListScrollerItem<string> DirectOptions { get; } = new UIMenuListScrollerItem<string>("Direct driver to path's", "", new[] { "First waypoint", "Nearest waypoint" });
|
||||||
internal static UIMenuNumericScrollerItem<int> DirectDriver { get; private set; }
|
//internal static UIMenuListScrollerItem<string> DirectDriver { get; private set; }
|
||||||
internal static UIMenuListScrollerItem<string> DismissDriver { get; } = new UIMenuListScrollerItem<string>("Dismiss nearest driver", $"~b~From path: ~w~AI will be released from the path\n~b~From waypoint: ~w~AI will skip their current waypoint task\n~b~From world: ~w~AI will be removed from the world.", DismissOptions);
|
//internal static UIMenuListScrollerItem<string> DismissDriver { get; } = new UIMenuListScrollerItem<string>("Dismiss nearest driver", $"~b~From path: ~w~Driver will be released from the path\n~b~From waypoint: ~w~Driver will skip their current waypoint task\n~b~From world: ~w~Driver will be removed from the world.", DismissOptions);
|
||||||
internal static UIMenuCheckboxItem DisableAllPaths { get; } = new UIMenuCheckboxItem("Disable All Paths", false);
|
internal static UIMenuCheckboxItem DisableAllPaths { get; } = new UIMenuCheckboxItem("Disable All Paths", false);
|
||||||
|
|
||||||
internal static void Initialize()
|
internal static void Initialize()
|
||||||
|
|
@ -34,7 +36,7 @@ namespace SceneManager.Menus
|
||||||
Menu.OnMenuOpen += PathMenu_OnMenuOpen;
|
Menu.OnMenuOpen += PathMenu_OnMenuOpen;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static void BuildPathMenu()
|
internal static void Build()
|
||||||
{
|
{
|
||||||
MenuManager.MenuPool.CloseAllMenus();
|
MenuManager.MenuPool.CloseAllMenus();
|
||||||
Menu.Clear();
|
Menu.Clear();
|
||||||
|
|
@ -43,20 +45,21 @@ namespace SceneManager.Menus
|
||||||
CreateNewPath.ForeColor = Color.Gold;
|
CreateNewPath.ForeColor = Color.Gold;
|
||||||
Menu.AddItem(ImportPath);
|
Menu.AddItem(ImportPath);
|
||||||
ImportPath.ForeColor = Color.Gold;
|
ImportPath.ForeColor = Color.Gold;
|
||||||
ImportPath.Enabled = true;
|
ImportPath.Enabled = Settings.ImportedPaths.Count() > 0;
|
||||||
Menu.AddItem(EditPath = new UIMenuNumericScrollerItem<int>("Edit Path", "", 1, PathManager.Paths.Count, 1));
|
Menu.AddItem(EditPath = new UIMenuListScrollerItem<string>("Edit Path", "Options to ~b~edit path waypoints~w~, ~b~disable the path~w~, ~b~export the path~w~, or ~b~delete the path~w~.", PathManager.Paths.Select(x => x.Name)));
|
||||||
EditPath.ForeColor = Color.Gold;
|
EditPath.ForeColor = Color.Gold;
|
||||||
Menu.AddItem(DisableAllPaths);
|
Menu.AddItem(DisableAllPaths);
|
||||||
DisableAllPaths.Enabled = true;
|
DisableAllPaths.Enabled = true;
|
||||||
Menu.AddItem(DeleteAllPaths);
|
Menu.AddItem(DeleteAllPaths);
|
||||||
DeleteAllPaths.Enabled = true;
|
DeleteAllPaths.Enabled = true;
|
||||||
DeleteAllPaths.ForeColor = Color.Gold;
|
DeleteAllPaths.ForeColor = Color.Gold;
|
||||||
Menu.AddItem(DirectOptions);
|
//Menu.AddItem(DirectOptions);
|
||||||
Menu.AddItem(DirectDriver = new UIMenuNumericScrollerItem<int>("Direct nearest driver to path", "", 1, PathManager.Paths.Count, 1)); // This must instantiate here because the Paths.Count value changes
|
//DirectOptions.Enabled = true;
|
||||||
DirectDriver.ForeColor = Color.Gold;
|
//Menu.AddItem(DirectDriver = new UIMenuListScrollerItem<string>("Direct nearest driver to path", "", PathManager.Paths.Select(x => x.Name))); // This must instantiate here because the Paths change
|
||||||
DirectDriver.Enabled = true;
|
//DirectDriver.ForeColor = Color.Gold;
|
||||||
Menu.AddItem(DismissDriver);
|
//DirectDriver.Enabled = true;
|
||||||
DismissDriver.ForeColor = Color.Gold;
|
//Menu.AddItem(DismissDriver);
|
||||||
|
//DismissDriver.ForeColor = Color.Gold;
|
||||||
|
|
||||||
if (PathManager.Paths.Count == MAX_PATH_LIMIT)
|
if (PathManager.Paths.Count == MAX_PATH_LIMIT)
|
||||||
{
|
{
|
||||||
|
|
@ -68,7 +71,8 @@ namespace SceneManager.Menus
|
||||||
EditPath.Enabled = false;
|
EditPath.Enabled = false;
|
||||||
DeleteAllPaths.Enabled = false;
|
DeleteAllPaths.Enabled = false;
|
||||||
DisableAllPaths.Enabled = false;
|
DisableAllPaths.Enabled = false;
|
||||||
DirectDriver.Enabled = false;
|
//DirectOptions.Enabled = false;
|
||||||
|
//DirectDriver.Enabled = false;
|
||||||
}
|
}
|
||||||
if(Settings.ImportedPaths.Count == 0)
|
if(Settings.ImportedPaths.Count == 0)
|
||||||
{
|
{
|
||||||
|
|
@ -97,37 +101,39 @@ namespace SceneManager.Menus
|
||||||
|
|
||||||
if (selectedItem == DeleteAllPaths)
|
if (selectedItem == DeleteAllPaths)
|
||||||
{
|
{
|
||||||
Utils.DeleteAllPaths.Delete();
|
PathManager.DeleteAllPaths();
|
||||||
DisableAllPaths.Checked = false;
|
DisableAllPaths.Checked = false;
|
||||||
BuildPathMenu();
|
Build();
|
||||||
Menu.Visible = true;
|
Menu.Visible = true;
|
||||||
|
BarrierMenu.BuildMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (selectedItem == DirectDriver)
|
//if (selectedItem == DirectDriver)
|
||||||
{
|
//{
|
||||||
if(Utils.DirectDriver.ValidateOptions(DirectOptions, PathManager.Paths[DirectDriver.Index], out Vehicle nearbyVehicle, out Waypoint targetWaypoint))
|
// if(Utils.DirectDriver.ValidateOptions(DirectOptions, PathManager.Paths[DirectDriver.Index], out Vehicle nearbyVehicle, out Waypoint targetWaypoint))
|
||||||
{
|
// {
|
||||||
Utils.DirectDriver.Direct(nearbyVehicle, PathManager.Paths[DirectDriver.Index], targetWaypoint);
|
// Utils.DirectDriver.Direct(nearbyVehicle, PathManager.Paths[DirectDriver.Index], targetWaypoint);
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|
||||||
if (selectedItem == DismissDriver)
|
//if (selectedItem == DismissDriver)
|
||||||
{
|
//{
|
||||||
Utils.DismissDriver.Dismiss(DismissDriver.Index);
|
// Utils.DismissDriver.Dismiss(DismissDriver.Index);
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void PathMenu_OnCheckboxChange(UIMenu sender, UIMenuCheckboxItem checkboxItem, bool @checked)
|
private static void PathMenu_OnCheckboxChange(UIMenu sender, UIMenuCheckboxItem checkboxItem, bool @checked)
|
||||||
{
|
{
|
||||||
if (checkboxItem == DisableAllPaths)
|
if (checkboxItem == DisableAllPaths)
|
||||||
{
|
{
|
||||||
TogglePaths.Toggle(DisableAllPaths.Checked);
|
PathManager.ToggleAllPaths(DisableAllPaths.Checked);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void PathMenu_OnMenuOpen(UIMenu menu)
|
private static void PathMenu_OnMenuOpen(UIMenu menu)
|
||||||
{
|
{
|
||||||
var scrollerItems = new List<UIMenuScrollerItem> { DirectOptions, DirectDriver, DismissDriver, EditPath };
|
//var scrollerItems = new List<UIMenuScrollerItem> { DirectOptions, DirectDriver, DismissDriver, EditPath };
|
||||||
|
var scrollerItems = new List<UIMenuScrollerItem> { EditPath };
|
||||||
GameFiber.StartNew(() => UserInput.InitializeMenuMouseControl(menu, scrollerItems), "RNUI Mouse Input Fiber");
|
GameFiber.StartNew(() => UserInput.InitializeMenuMouseControl(menu, scrollerItems), "RNUI Mouse Input Fiber");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -142,7 +148,7 @@ namespace SceneManager.Menus
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
PathCreationMenu.BuildPathCreationMenu();
|
//PathCreationMenu.BuildPathCreationMenu();
|
||||||
Menu.Visible = false;
|
Menu.Visible = false;
|
||||||
PathCreationMenu.Menu.Visible = true;
|
PathCreationMenu.Menu.Visible = true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue