json config file

This commit is contained in:
glax 2023-11-30 16:01:06 +01:00
parent f0ccd7be48
commit 7142e57a4a
2 changed files with 18 additions and 1 deletions

View File

@ -1,4 +1,5 @@
using BuildSoft.OscCore;
using Newtonsoft.Json.Linq;
namespace VRC_Console;
@ -7,7 +8,22 @@ public class OSCCollar
public static void Main(string[] args)
{
OSCCollar collar = new OSCCollar();
string configFilePath = Path.Combine(Directory.GetCurrentDirectory(), "config.json");
if (File.Exists(configFilePath))
{
var jObject = JObject.Parse(File.ReadAllText(configFilePath));
string ip = jObject.GetValue("ip")?.ToObject<string>() ?? "127.0.0.1";
int portReceive = jObject.GetValue("portReceive")?.ToObject<int>() ?? 9001;
int portSend = jObject.GetValue("portReceive")?.ToObject<int>() ?? 9000;
double radius = jObject.GetValue("radius")?.ToObject<int>() ?? 100;
double calibrationX = jObject.GetValue("calibrationX")?.ToObject<int>() ?? 0;
double calibrationY = jObject.GetValue("calibrationY")?.ToObject<int>() ?? 0;
bool skipSetup = jObject.GetValue("skipSetup")?.ToObject<bool>() ?? true;
var _ = new OSCCollar(ip, portReceive, portSend, radius, calibrationX, calibrationY, skipSetup);
}else
{
var _ = new OSCCollar();
}
}
private OscServer Server { get; init; }

View File

@ -10,6 +10,7 @@
<ItemGroup>
<PackageReference Include="BuildSoft.OscCore" Version="1.2.1.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>
</Project>