From 7142e57a4a8e1b6bd915929266de38d405167cfb Mon Sep 17 00:00:00 2001 From: glax Date: Thu, 30 Nov 2023 16:01:06 +0100 Subject: [PATCH] json config file --- OSCCollar/OSCCollar.cs | 18 +++++++++++++++++- OSCCollar/OSCCollar.csproj | 1 + 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/OSCCollar/OSCCollar.cs b/OSCCollar/OSCCollar.cs index b210542..4b8fcf6 100644 --- a/OSCCollar/OSCCollar.cs +++ b/OSCCollar/OSCCollar.cs @@ -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() ?? "127.0.0.1"; + int portReceive = jObject.GetValue("portReceive")?.ToObject() ?? 9001; + int portSend = jObject.GetValue("portReceive")?.ToObject() ?? 9000; + double radius = jObject.GetValue("radius")?.ToObject() ?? 100; + double calibrationX = jObject.GetValue("calibrationX")?.ToObject() ?? 0; + double calibrationY = jObject.GetValue("calibrationY")?.ToObject() ?? 0; + bool skipSetup = jObject.GetValue("skipSetup")?.ToObject() ?? true; + var _ = new OSCCollar(ip, portReceive, portSend, radius, calibrationX, calibrationY, skipSetup); + }else + { + var _ = new OSCCollar(); + } } private OscServer Server { get; init; } diff --git a/OSCCollar/OSCCollar.csproj b/OSCCollar/OSCCollar.csproj index 4c837a3..224f096 100644 --- a/OSCCollar/OSCCollar.csproj +++ b/OSCCollar/OSCCollar.csproj @@ -10,6 +10,7 @@ +