From ab46c1033680a9915765d7aa5c65e62b00cbc180 Mon Sep 17 00:00:00 2001 From: joreg Date: Thu, 12 Oct 2023 01:02:17 +0200 Subject: [PATCH] adds support for RANGE attribute --- vrc-oscquery-lib/OSCQueryNode.cs | 11 ++++++++++- vrc-oscquery-lib/OSCQueryService.cs | 15 ++++++++------- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/vrc-oscquery-lib/OSCQueryNode.cs b/vrc-oscquery-lib/OSCQueryNode.cs index a2300f5..8d1425d 100644 --- a/vrc-oscquery-lib/OSCQueryNode.cs +++ b/vrc-oscquery-lib/OSCQueryNode.cs @@ -145,6 +145,9 @@ public OSCQueryNode(string fullPath) [JsonProperty(Attributes.VALUE)] public object[] Value; + [JsonProperty(Attributes.RANGE)] + public Range[] Range; + [JsonIgnore] public string ParentPath { get @@ -173,6 +176,12 @@ public static void AddConverter(JsonConverter c) { NullValueHandling = NullValueHandling.Ignore, }; - + } + + public struct Range + { + public string MIN; + public string MAX; + public string[] VALS; } } \ No newline at end of file diff --git a/vrc-oscquery-lib/OSCQueryService.cs b/vrc-oscquery-lib/OSCQueryService.cs index 07e602a..b1957d9 100644 --- a/vrc-oscquery-lib/OSCQueryService.cs +++ b/vrc-oscquery-lib/OSCQueryService.cs @@ -197,7 +197,7 @@ public void SetValue(string address, object[] value) /// Starting value for param in string form /// Optional longer string to use when displaying a label for the entry /// - public bool AddEndpoint(string path, string oscTypeString, Attributes.AccessValues accessValues, object[] initialValue = null, + public bool AddEndpoint(string path, string oscTypeString, Attributes.AccessValues accessValues, object[] initialValue = null, Range[] range = null, string description = "") { // Exit early if path does not start with slash @@ -211,24 +211,25 @@ public bool AddEndpoint(string path, string oscTypeString, Attributes.AccessValu { Logger.LogWarning($"Path already exists, skipping: {path}"); return false; - } - + } + RootNode.AddNode(new OSCQueryNode(path) { Access = accessValues, Description = description, OscType = oscTypeString, - Value = initialValue - }); + Value = initialValue, + Range = range + }); ; return true; } - public bool AddEndpoint(string path, Attributes.AccessValues accessValues, object[] initialValue = null, string description = "") + public bool AddEndpoint(string path, Attributes.AccessValues accessValues, object[] initialValue = null, Range[] range = null, string description = "") { var typeExists = Attributes.OSCTypeFor(typeof(T), out string oscType); - if (typeExists) return AddEndpoint(path, oscType, accessValues, initialValue, description); + if (typeExists) return AddEndpoint(path, oscType, accessValues, initialValue, range, description); Logger.LogError($"Could not add {path} to OSCQueryService because type {typeof(T)} is not supported."); return false;