mirror of
https://github.com/thegeneralist01/Scene-Manager-DevRepo
synced 2026-01-11 23:50:29 +01:00
Initial commit
This commit is contained in:
parent
f494dd7a84
commit
b66a97fef8
1 changed files with 54 additions and 0 deletions
54
SceneManager/SettingsValidator.cs
Normal file
54
SceneManager/SettingsValidator.cs
Normal file
|
|
@ -0,0 +1,54 @@
|
||||||
|
using Rage;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SceneManager
|
||||||
|
{
|
||||||
|
// The only reason this class should change is to modify how settings are validated
|
||||||
|
internal class SettingsValidator
|
||||||
|
{
|
||||||
|
internal static void ValidateWaypointSettings()
|
||||||
|
{
|
||||||
|
if (Settings.CollectorRadius > 50 || Settings.CollectorRadius < 1)
|
||||||
|
{
|
||||||
|
Settings.CollectorRadius = 1;
|
||||||
|
Game.LogTrivial($"Invalid value for CollectorRadius in user settings, resetting to default.");
|
||||||
|
}
|
||||||
|
if (Settings.SpeedZoneRadius > 200 || Settings.SpeedZoneRadius < 5)
|
||||||
|
{
|
||||||
|
Settings.SpeedZoneRadius = 5;
|
||||||
|
Game.LogTrivial($"Invalid value for SpeedZoneRadius in user settings, resetting to default.");
|
||||||
|
}
|
||||||
|
if (Settings.CollectorRadius > Settings.SpeedZoneRadius)
|
||||||
|
{
|
||||||
|
Settings.CollectorRadius = 1;
|
||||||
|
Settings.SpeedZoneRadius = 5;
|
||||||
|
Game.LogTrivial($"CollectorRadius is greater than SpeedZoneRadius in user settings, resetting to defaults.");
|
||||||
|
}
|
||||||
|
if (Settings.WaypointSpeed > 100 || Settings.WaypointSpeed < 5)
|
||||||
|
{
|
||||||
|
Settings.WaypointSpeed = 5;
|
||||||
|
Game.LogTrivial($"Invalid value for WaypointSpeed in user settings, resetting to default.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static void ValidateBarrierSettings(InitializationFile ini)
|
||||||
|
{
|
||||||
|
foreach (string displayName in ini.GetKeyNames("Barriers"))
|
||||||
|
{
|
||||||
|
var model = new Model(ini.ReadString("Barriers", displayName.Trim()));
|
||||||
|
if (model.IsValid)
|
||||||
|
{
|
||||||
|
Settings.Barriers.Add(displayName, model);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Game.LogTrivial($"{model.Name} is not valid.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue