1
Fork 0
mirror of https://github.com/thegeneralist01/Scene-Manager-DevRepo synced 2026-01-11 23:50:29 +01:00
Scene-Manager-DevRepo/SceneManager/Settings.cs
Rich 8bc4de3528
Merge V2.1.1 release (#3)
* Mouse can now be used to fully navigate menus

* Added check for driver's current vehicle when releasing from Stop waypoint in case the ped is not in a vehicle.

* Lines are now only drawn between waypoint markers under the same conditions that waypoint markers are drawn

* Updated marker position to be player's mouse position

* Version update

* Added logic to update waypoint position during driving task if the waypoint position was changed before the driver arrived.

* Removed unused usings.  Refactored debug statements to use Game.LogTrivial instead of Logger.Log

* Removed class

* Removed Logger class

* Consolidated all custom enums to this class.  Added default waypoint settings from .ini

* Modified a hint message

* Fixed collector options not being enabled/disabled when Collector box is checked

* Refactored AITasking into CollectedVehicle.

* Updated reference to vehicle tasking based on AITasking refactor.  Fixed speed zone radius not updating correctly.

* Version update

* Refactored AITasking into CollectedVehicle

* Added check for CollectorRadius being more than SpeedZoneRadius.  Added debug messages when values are reset to default.

* Added hint message if player tries to edit waypoints while 3D waypoints are disabled

* Fixed a bug where a 3D waypoint marker would be drawn even if 3D waypoints were disabled

* Removed unnecessary property setting when a vehicle is being removed from a path.

* Added a check for if the driver loses their task and reassigns it.

* Fixed a bug where the 3D line between waypoints was still being drawn even though 3D waypoints were disabled in the settings menu.

* Updated version

* Added console command to show info about collected vehicles.

* Added ConsoleCommand class, removed AITasking class.

* Removed class after refactoring into CollectedVehicle

* Update README.md

* Update README.md

* Added ini setting for Advanced Barrier Options.  Added enum for TrafficLight state.  Added debug message for invalid barriers.

* Updated version

* Added MousePositionInWorld and RNUIMouseInputHandler classes

* Fixed a crash when a collected ped is arrested.

* Refactored to implement RNUIMouseInputHandler class.

* Removed unused method.

* Updated version

* Disabled deletion/creation of shadow barrier and re-enabled updating position based on mouse position.

* Added check for Driver's current vehicle in driving loop in case the Driver exited Vehicle at some point.  Adjusted some guard clause logic and log messages.

* Removed unused variable

* Renamed some methods to improve clarity

* Updated version.
2020-11-26 07:41:22 -07:00

148 lines
5.6 KiB
C#

using Rage;
using System.Collections.Generic;
using System.Windows.Forms;
namespace SceneManager
{
internal enum State
{
Uninitialized,
Creating,
Finished
}
internal enum SpeedUnits
{
MPH,
KPH
}
internal enum DrivingFlagType
{
Normal = 263075,
Direct = 17040259
}
internal enum DismissOption
{
FromPath = 0,
FromWaypoint = 1,
FromWorld = 2,
FromPlayer = 3,
FromDirected = 4
}
internal enum TrafficLight
{
Green = 0,
Red = 1,
Yellow = 2,
None = 3
}
internal static class Settings
{
internal static readonly InitializationFile ini = new InitializationFile("Plugins/SceneManager.ini");
// Keybindings
internal static Keys ToggleKey = Keys.T;
internal static Keys ModifierKey = Keys.LShiftKey;
internal static ControllerButtons ToggleButton = ControllerButtons.Y;
internal static ControllerButtons ModifierButton = ControllerButtons.A;
// Plugin Settings
internal static bool Enable3DWaypoints = true;
internal static bool EnableMapBlips = true;
internal static bool EnableHints = true;
internal static SpeedUnits SpeedUnit = SpeedUnits.MPH;
internal static float BarrierPlacementDistance = 30f;
internal static bool EnableAdvancedBarricadeOptions = false;
// Default Waypoint Settings
internal static int CollectorRadius = 1;
internal static int SpeedZoneRadius = 5;
internal static bool StopWaypoint = false;
internal static bool DirectDrivingBehavior = false;
internal static int WaypointSpeed = 5;
// Barriers
internal static List<string> barrierKeys = new List<string>();
internal static List<string> barrierValues = new List<string>();
internal static void LoadSettings()
{
Game.LogTrivial("Loading SceneManager.ini settings");
ini.Create();
// Keybindings
ToggleKey = ini.ReadEnum("Keybindings", "ToggleKey", Keys.T);
ModifierKey = ini.ReadEnum("Keybindings", "ModifierKey", Keys.LShiftKey);
ToggleButton = ini.ReadEnum("Keybindings", "ToggleButton", ControllerButtons.A);
ModifierButton = ini.ReadEnum("Keybindings", "ModifierButton", ControllerButtons.DPadDown);
// Plugin Settings
Enable3DWaypoints = ini.ReadBoolean("Plugin Settings", "Enable3DWaypoints", true);
EnableMapBlips = ini.ReadBoolean("Plugin Settings", "EnableMapBlips", true);
EnableHints = ini.ReadBoolean("Plugin Settings", "EnableHints", true);
SpeedUnit = ini.ReadEnum("Plugin Settings", "SpeedUnits", SpeedUnits.MPH);
BarrierPlacementDistance = ini.ReadInt32("Plugin Settings", "BarrierPlacementDistance", 30);
EnableAdvancedBarricadeOptions = ini.ReadBoolean("Plugin Settings", "EnableAdvancedBarricadeOptions", false);
// Default Waypoint Settings
CollectorRadius = ini.ReadInt32("Default Waypoint Settings", "CollectorRadius", 1);
SpeedZoneRadius = ini.ReadInt32("Default Waypoint Settings", "SpeedZoneRadius", 5);
StopWaypoint = ini.ReadBoolean("Default Waypoint Settings", "StopWaypoint", false);
DirectDrivingBehavior = ini.ReadBoolean("Default Waypoint Settings", "DirectDrivingBehavior", false);
WaypointSpeed = ini.ReadInt32("Default Waypoint Settings", "WaypointSpeed", 5);
CheckForValidWaypointSettings();
// Barriers
foreach(string key in ini.GetKeyNames("Barriers"))
{
barrierKeys.Add(key.Trim());
var m = new Model(ini.ReadString("Barriers", key));
if (m.IsValid)
{
barrierValues.Add(m.Name);
}
else
{
Game.LogTrivial($"{m.Name} is not valid.");
}
}
void CheckForValidWaypointSettings()
{
if(CollectorRadius > 50 || CollectorRadius < 1)
{
CollectorRadius = 1;
Game.LogTrivial($"Invalid value for CollectorRadius in user settings, resetting to default.");
}
if(SpeedZoneRadius > 200 || SpeedZoneRadius < 5)
{
SpeedZoneRadius = 5;
Game.LogTrivial($"Invalid value for SpeedZoneRadius in user settings, resetting to default.");
}
if (CollectorRadius > SpeedZoneRadius)
{
CollectorRadius = 1;
SpeedZoneRadius = 5;
Game.LogTrivial($"CollectorRadius is greater than SpeedZoneRadius in user settings, resetting to defaults.");
}
if (WaypointSpeed > 100 || WaypointSpeed < 5)
{
WaypointSpeed = 5;
Game.LogTrivial($"Invalid value for WaypointSpeed in user settings, resetting to default.");
}
}
}
internal static void UpdateSettings(bool threeDWaypointsEnabled, bool mapBlipsEnabled, bool hintsEnabled, SpeedUnits unit)
{
ini.Write("Other Settings", "Enable3DWaypoints", threeDWaypointsEnabled);
ini.Write("Other Settings", "EnableMapBlips", mapBlipsEnabled);
ini.Write("Other Settings", "EnableHints", hintsEnabled);
ini.Write("Other Settings", "SpeedUnits", unit);
}
}
}