Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion vrc-oscquery-lib/OSCQueryNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
}
}
15 changes: 8 additions & 7 deletions vrc-oscquery-lib/OSCQueryService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ public void SetValue(string address, object[] value)
/// <param name="initialValue">Starting value for param in string form</param>
/// <param name="description">Optional longer string to use when displaying a label for the entry</param>
/// <returns></returns>
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
Expand All @@ -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<T>(string path, Attributes.AccessValues accessValues, object[] initialValue = null, string description = "")
public bool AddEndpoint<T>(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;
Expand Down