mirror of
https://github.com/thegeneralist01/Scene-Manager-DevRepo
synced 2026-01-11 15:40:29 +01:00
Added Export Path menu item and method.
This commit is contained in:
parent
3e33ce2569
commit
726bcedf8b
1 changed files with 40 additions and 6 deletions
|
|
@ -1,7 +1,6 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Linq;
|
using System.IO;
|
||||||
using System.Windows.Forms;
|
|
||||||
using Rage;
|
using Rage;
|
||||||
using RAGENativeUI;
|
using RAGENativeUI;
|
||||||
using RAGENativeUI.Elements;
|
using RAGENativeUI.Elements;
|
||||||
|
|
@ -11,7 +10,7 @@ namespace SceneManager
|
||||||
class EditPathMenu
|
class EditPathMenu
|
||||||
{
|
{
|
||||||
internal static UIMenu editPathMenu = new UIMenu("Scene Manager", "~o~Edit Path");
|
internal static UIMenu editPathMenu = new UIMenu("Scene Manager", "~o~Edit Path");
|
||||||
private static UIMenuItem editPathWaypoints, deletePath;
|
private static UIMenuItem editPathWaypoints, deletePath, savePath;
|
||||||
internal static UIMenuCheckboxItem disablePath;
|
internal static UIMenuCheckboxItem disablePath;
|
||||||
|
|
||||||
internal static void InstantiateMenu()
|
internal static void InstantiateMenu()
|
||||||
|
|
@ -30,7 +29,8 @@ namespace SceneManager
|
||||||
editPathWaypoints.ForeColor = Color.Gold;
|
editPathWaypoints.ForeColor = Color.Gold;
|
||||||
editPathMenu.AddItem(deletePath = new UIMenuItem("Delete Path"));
|
editPathMenu.AddItem(deletePath = new UIMenuItem("Delete Path"));
|
||||||
deletePath.ForeColor = Color.Gold;
|
deletePath.ForeColor = Color.Gold;
|
||||||
|
editPathMenu.AddItem(savePath = new UIMenuItem("Export Path"));
|
||||||
|
savePath.ForeColor = Color.Gold;
|
||||||
editPathMenu.RefreshIndex();
|
editPathMenu.RefreshIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -64,6 +64,34 @@ namespace SceneManager
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void ExportPath()
|
||||||
|
{
|
||||||
|
// Reference PNWParks's UserInput class from LiveLights
|
||||||
|
string filename = PNWUserInput.GetUserInput("Type the name you would like to save your file as", "Enter a filename", 100);
|
||||||
|
|
||||||
|
// If filename != null or empty, check if export directory exists (GTA V/Plugins/SceneManager/Saved Paths)
|
||||||
|
if(string.IsNullOrWhiteSpace(filename))
|
||||||
|
{
|
||||||
|
Game.LogTrivial($"Invalid filename given. Filename cannot be null, empty, or consist of just white spaces.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Game.LogTrivial($"Filename: {filename}");
|
||||||
|
|
||||||
|
// If directory does not exist, create it
|
||||||
|
var gameDirectory = Directory.GetCurrentDirectory();
|
||||||
|
var pathDirectoryExists = Directory.Exists(gameDirectory + "/plugins/SceneManager/Saved Paths");
|
||||||
|
if (!pathDirectoryExists)
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(gameDirectory + "/plugins/SceneManager/Saved Paths");
|
||||||
|
Game.LogTrivial($"New directory created at '/plugins/SceneManager/Saved Paths'");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create XML in save directory with user's filename, saving all path information
|
||||||
|
//<Path>
|
||||||
|
// <Waypoint number="1" pos="x,y,z" speed="5" drivingFlag="Normal" stop="false" collector="true" collectorRadius="3" speedZoneRadius="5"/>
|
||||||
|
//</Path>
|
||||||
|
}
|
||||||
|
|
||||||
private static void EditPath_OnItemSelected(UIMenu sender, UIMenuItem selectedItem, int index)
|
private static void EditPath_OnItemSelected(UIMenu sender, UIMenuItem selectedItem, int index)
|
||||||
{
|
{
|
||||||
if (selectedItem == editPathWaypoints)
|
if (selectedItem == editPathWaypoints)
|
||||||
|
|
@ -75,6 +103,11 @@ namespace SceneManager
|
||||||
{
|
{
|
||||||
DeletePath();
|
DeletePath();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(selectedItem == savePath)
|
||||||
|
{
|
||||||
|
ExportPath();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void EditPath_OnCheckboxChange(UIMenu sender, UIMenuCheckboxItem checkboxItem, bool @checked)
|
private static void EditPath_OnCheckboxChange(UIMenu sender, UIMenuCheckboxItem checkboxItem, bool @checked)
|
||||||
|
|
@ -92,10 +125,11 @@ namespace SceneManager
|
||||||
var selectItems = new Dictionary<UIMenuItem, RNUIMouseInputHandler.Function>()
|
var selectItems = new Dictionary<UIMenuItem, RNUIMouseInputHandler.Function>()
|
||||||
{
|
{
|
||||||
{ editPathWaypoints, EditPathWaypoints },
|
{ editPathWaypoints, EditPathWaypoints },
|
||||||
{ deletePath, DeletePath }
|
{ deletePath, DeletePath },
|
||||||
|
{ savePath, ExportPath }
|
||||||
};
|
};
|
||||||
|
|
||||||
RNUIMouseInputHandler.Initialize(menu, scrollerItems, checkboxItems, selectItems);
|
RNUIMouseInputHandler.Initialize(menu, scrollerItems);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue