maint: added livewatch asset

This commit is contained in:
Chris
2025-08-31 18:14:07 -04:00
parent 7f5d95787b
commit ae2371a6fa
385 changed files with 150792 additions and 0 deletions

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 022d5fba93224fc08eff4e5e45aebd17
timeCreated: 1637776221

View File

@@ -0,0 +1,95 @@
using System;
using UnityEngine;
namespace Ingvar.LiveWatch
{
[Serializable]
public struct SearchQueryResult
{
public bool IsPositive;
public bool IsWholeSelection;
public int SelectionStartIndex;
public int SelectionEndIndex;
public int IndexOfResultInTotalList;
public static SearchQueryResult True() => new ()
{ IsPositive = true, IsWholeSelection = true};
public static SearchQueryResult True(int selectionStart, int selectionEnd) => new ()
{ IsPositive = true, SelectionStartIndex = selectionStart, SelectionEndIndex = selectionEnd};
public static SearchQueryResult False() => new ()
{ IsPositive = false };
public static SearchQueryResult And(SearchQueryResult left, SearchQueryResult right)
{
if (!left.IsPositive || !right.IsPositive)
{
return SearchQueryResult.False();
}
if (left.IsWholeSelection && right.IsWholeSelection)
{
return SearchQueryResult.True();
}
if (!left.IsWholeSelection && right.IsWholeSelection)
{
return left;
}
if (left.IsWholeSelection && !right.IsWholeSelection)
{
return right;
}
if (!left.IsWholeSelection && !right.IsWholeSelection)
{
var greater = right.SelectionEndIndex >= left.SelectionEndIndex ? right : left;
var lesser = greater.Equals(right) ? left : right;
if (lesser.SelectionEndIndex < greater.SelectionStartIndex)
{
return SearchQueryResult.False();
}
else
{
return SearchQueryResult.True(lesser.SelectionEndIndex, greater.SelectionEndIndex);
}
}
return SearchQueryResult.False();
}
public static SearchQueryResult Or(SearchQueryResult left, SearchQueryResult right)
{
if (!left.IsPositive && !right.IsPositive)
{
return SearchQueryResult.False();
}
if (left.IsWholeSelection || right.IsWholeSelection)
{
return SearchQueryResult.True();
}
if (left.IsPositive && !right.IsPositive)
{
return left;
}
if (!left.IsPositive && right.IsPositive)
{
return right;
}
var startIndex = Mathf.Min(left.SelectionStartIndex, right.SelectionStartIndex);
var endIndex = Mathf.Min(left.SelectionEndIndex, right.SelectionEndIndex);
return SearchQueryResult.True(startIndex, endIndex);
}
public static SearchQueryResult Inverse(SearchQueryResult result)
{
return result.IsPositive ? SearchQueryResult.False() : SearchQueryResult.True();
}
}
}

View File

@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 1ae5070b6cc44484ab755658884825c4
timeCreated: 1676574950
AssetOrigin:
serializedVersion: 1
productId: 324001
packageName: LiveWatch Lite | Debug with full history of changes
packageVersion: 1.0.1
assetPath: Assets/LiveWatchLite/Scripts/WatchVariable/EditorMeta/SearchQueryResult.cs
uploadId: 770587

View File

@@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Serialization;
namespace Ingvar.LiveWatch
{
[Serializable]
public class VariableEditorMeta
{
public bool IsExpanded;
[NonSerialized] public int LastStringToNumberValue = -1;
[NonSerialized] public Dictionary<string, int> StringToNumberValues;
[NonSerialized] public VariableSearchResultMeta SearchResult;
[NonSerialized] public int LastNonShrinkableIndexOfKey = -1;
}
}

View File

@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: da5ca5ec46ce416a8466282e16742c2f
timeCreated: 1637094877
AssetOrigin:
serializedVersion: 1
productId: 324001
packageName: LiveWatch Lite | Debug with full history of changes
packageVersion: 1.0.1
assetPath: Assets/LiveWatchLite/Scripts/WatchVariable/EditorMeta/VariableEditorMeta.cs
uploadId: 770587

View File

@@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
namespace Ingvar.LiveWatch
{
public struct VariableSearchResultMeta
{
public bool IsValueResults => ValueResults is { Count: > 0 };
public SearchQueryResult NameResult;
public Dictionary<int, SearchQueryResult> ValueResults;
public void Clear()
{
NameResult.IsPositive = false;
ValueResults?.Clear();
}
}
}

View File

@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 965ed9a778a14c5ba3a060daa54f5864
timeCreated: 1669563007
AssetOrigin:
serializedVersion: 1
productId: 324001
packageName: LiveWatch Lite | Debug with full history of changes
packageVersion: 1.0.1
assetPath: Assets/LiveWatchLite/Scripts/WatchVariable/EditorMeta/VariableSearchResultMeta.cs
uploadId: 770587

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 06222973d68545f5b7191e5cfd7fed52
timeCreated: 1643054777

View File

@@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using UnityEngine.Serialization;
namespace Ingvar.LiveWatch
{
[Serializable]
public class VariableRuntimeMeta
{
public Type ValueType;
public Action UpdateCall;
public bool IsSortingRequired;
public bool IsSetUp;
public bool IsDictionaryKey;
public bool IsDictionaryValue;
public bool IsCollectionValue;
public bool IsUpdatedAtLeastOnce;
public bool UpdateOnce;
public bool AlwaysShrinkable;
public int DecimalPlaces = 2;
public bool IsOrderSet;
public float SortOrder;
}
}

View File

@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: ec2651567fd7427fb1806ec0d5eb2598
timeCreated: 1643054765
AssetOrigin:
serializedVersion: 1
productId: 324001
packageName: LiveWatch Lite | Debug with full history of changes
packageVersion: 1.0.1
assetPath: Assets/LiveWatchLite/Scripts/WatchVariable/RuntimeMeta/VariableRuntimeMeta.cs
uploadId: 770587

View File

@@ -0,0 +1,134 @@
using System;
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using UnityEngine;
namespace Ingvar.LiveWatch
{
[Serializable]
public class WatchStorage : ISerializationCallbackReceiver
{
public int Count => _dictionary.Count;
public Dictionary<string, WatchVariable> Items => _dictionary;
public List<string> SortedNames => _sortedNames;
public bool IsSortable { get; set; }
private readonly Dictionary<string, WatchVariable> _dictionary = new();
private readonly List<string> _sortedNames = new();
private object _lockObject = new ();
[SerializeField] private List<string> _keys = new();
[SerializeField] private List<WatchVariable> _values = new();
public void Add(WatchVariable variable)
{
lock (_lockObject)
{
_dictionary.TryAdd(variable.Name, variable);
_sortedNames.Add(variable.Name);
}
}
public WatchVariable Get(string variableName)
{
return _dictionary[variableName];
}
public bool TryGet(string variableName, out WatchVariable watchVariable)
{
return _dictionary.TryGetValue(variableName, out watchVariable);
}
public void Remove(string variableName)
{
lock (_lockObject)
{
_dictionary.Remove(variableName, out _);
_sortedNames.Add(variableName);
}
}
public bool Contains(string variableName)
{
return _dictionary.ContainsKey(variableName);
}
public WatchVariable GetRelative(string fullVariableName)
{
var innerNames = fullVariableName.Split(Watch.PathSeparator);
var currentStorage = this;
WatchVariable variable = default;
foreach (var name in innerNames)
{
variable = currentStorage.Get(name);
currentStorage = variable.Childs;
}
return variable;
}
public bool TryGetRelative(string fullVariableName, out WatchVariable watchVariable)
{
watchVariable = default;
var innerNames = fullVariableName.Split(Watch.PathSeparator);
var currentStorage = this;
foreach (var name in innerNames)
{
var hasVariable = currentStorage.TryGet(name, out watchVariable);
if (!hasVariable)
{
return false;
}
currentStorage = watchVariable.Childs;
}
return true;
}
public void Clear()
{
_dictionary.Clear();
_sortedNames.Clear();
}
#region Serialization
public void OnBeforeSerialize()
{
_keys.Clear();
_values.Clear();
foreach (var pair in _dictionary)
{
_keys.Add(pair.Key);
_values.Add(pair.Value);
}
}
public void OnAfterDeserialize()
{
_dictionary.Clear();
_sortedNames.Clear();
var count = Math.Min(_keys.Count, _values.Count);
if (count == 0)
return;
for (var i = 0; i < count; i++)
{
_dictionary.TryAdd(_keys[i], _values[i]);
_sortedNames.Add(_keys[i]);
}
WatchServices.VariableSortUpdater.SortWatches(this);
}
#endregion
}
}

View File

@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 1d3b4419da964ae69953a3b8a1be1cea
timeCreated: 1643227700
AssetOrigin:
serializedVersion: 1
productId: 324001
packageName: LiveWatch Lite | Debug with full history of changes
packageVersion: 1.0.1
assetPath: Assets/LiveWatchLite/Scripts/WatchVariable/WatchStorage.cs
uploadId: 770587

View File

@@ -0,0 +1,55 @@
using System;
namespace Ingvar.LiveWatch
{
[Serializable]
public struct WatchValue<T> : IEquatable<WatchValue<T>> where T : IEquatable<T>
{
public T Value;
public bool IsEmpty;
public string ValueText { get; set; }
public WatchValue(T value)
{
Value = value;
IsEmpty = false;
ValueText = null;
}
public static WatchValue<T> Empty()
{
return new WatchValue<T>()
{
IsEmpty = true,
};
}
public bool Equals(WatchValue<T> other)
{
return this == other;
}
public static bool operator ==(WatchValue<T> left, WatchValue<T> right)
{
if (!left.IsEmpty && !right.IsEmpty)
return left.Value.Equals(right.Value);
return left.IsEmpty == right.IsEmpty;
}
public static bool operator !=(WatchValue<T> left, WatchValue<T> right)
{
return !(left == right);
}
public override bool Equals(object obj)
{
return base.Equals(obj);
}
public override int GetHashCode()
{
return base.GetHashCode();
}
}
}

View File

@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 64f721fe01054db1a13eecf1fcbd3ef4
timeCreated: 1686989457
AssetOrigin:
serializedVersion: 1
productId: 324001
packageName: LiveWatch Lite | Debug with full history of changes
packageVersion: 1.0.1
assetPath: Assets/LiveWatchLite/Scripts/WatchVariable/WatchValue.cs
uploadId: 770587

View File

@@ -0,0 +1,155 @@
using System;
using System.Collections.Generic;
namespace Ingvar.LiveWatch
{
[Serializable]
public class WatchValueList
{
public WatchValueType Type = WatchValueType.NotSet;
public RepetitiveValueList<WatchValue<float>> FloatList = new ();
public RepetitiveValueList<WatchValue<double>> DoubleList = new ();
public RepetitiveValueList<WatchValue<int>> IntList = new ();
public RepetitiveValueList<WatchValue<bool>> BoolList = new ();
public RepetitiveValueList<WatchValue<string>> StringList = new ();
public List<int> OriginalKeys
{
get
{
return Type switch
{
WatchValueType.Float => FloatList.OriginalKeys,
WatchValueType.Double => DoubleList.OriginalKeys,
WatchValueType.Int => IntList.OriginalKeys,
WatchValueType.Bool => BoolList.OriginalKeys,
WatchValueType.String or WatchValueType.NotSet => StringList.OriginalKeys,
_ => throw new ArgumentOutOfRangeException()
};
}
}
public int Count
{
get
{
return Type switch
{
WatchValueType.Float => FloatList?.Count ?? 0,
WatchValueType.Double => DoubleList?.Count ?? 0,
WatchValueType.Int => IntList?.Count ?? 0,
WatchValueType.Bool => BoolList?.Count ?? 0,
WatchValueType.String or WatchValueType.NotSet => StringList?.Count ?? 0,
_ => throw new ArgumentOutOfRangeException()
};
}
}
public void Clear()
{
if (Type is WatchValueType.NotSet or WatchValueType.Float)
FloatList.Clear();
if (Type is WatchValueType.NotSet or WatchValueType.Double)
DoubleList.Clear();
if (Type is WatchValueType.NotSet or WatchValueType.Int)
IntList.Clear();
if (Type is WatchValueType.NotSet or WatchValueType.Bool)
BoolList.Clear();
if (Type is WatchValueType.NotSet or WatchValueType.String)
StringList.Clear();
}
public bool IsOriginalAt(int index)
{
return Type switch
{
WatchValueType.Float => FloatList.IsOriginalAt(index),
WatchValueType.Double => DoubleList.IsOriginalAt(index),
WatchValueType.Int => IntList.IsOriginalAt(index),
WatchValueType.Bool => BoolList.IsOriginalAt(index),
WatchValueType.String or WatchValueType.NotSet => StringList.IsOriginalAt(index),
_ => throw new ArgumentOutOfRangeException()
};
}
public int GetOriginalKey(int index)
{
return Type switch
{
WatchValueType.Float => FloatList.GetOriginalIndex(index),
WatchValueType.Double => DoubleList.GetOriginalIndex(index),
WatchValueType.Int => IntList.GetOriginalIndex(index),
WatchValueType.Bool => BoolList.GetOriginalIndex(index),
WatchValueType.String or WatchValueType.NotSet => StringList.GetOriginalIndex(index),
_ => throw new ArgumentOutOfRangeException()
};
}
public bool IsEmptyAt(int index)
{
return Type switch
{
WatchValueType.Float => !FloatList.AnyAt(index) || FloatList[index].IsEmpty,
WatchValueType.Double => !DoubleList.AnyAt(index) || DoubleList[index].IsEmpty,
WatchValueType.Int => !IntList.AnyAt(index) || IntList[index].IsEmpty,
WatchValueType.Bool => !BoolList.AnyAt(index) || BoolList[index].IsEmpty,
WatchValueType.String or WatchValueType.NotSet => !StringList.AnyAt(index) || StringList[index].IsEmpty,
_ => throw new ArgumentOutOfRangeException()
};
}
public bool AnyAt(int index)
{
return Type switch
{
WatchValueType.Float => FloatList.AnyAt(index),
WatchValueType.Double => DoubleList.AnyAt(index),
WatchValueType.Int => IntList.AnyAt(index),
WatchValueType.Bool => BoolList.AnyAt(index),
WatchValueType.String or WatchValueType.NotSet => StringList.AnyAt(index),
_ => throw new ArgumentOutOfRangeException()
};
}
public void Expand(int count)
{
if (Type is WatchValueType.Float or WatchValueType.NotSet)
FloatList.Expand(count);
if (Type is WatchValueType.Double or WatchValueType.NotSet)
DoubleList.Expand(count);
if (Type is WatchValueType.Int or WatchValueType.NotSet)
IntList.Expand(count);
if (Type is WatchValueType.Bool or WatchValueType.NotSet)
BoolList.Expand(count);
if (Type is WatchValueType.String or WatchValueType.NotSet)
StringList.Expand(count);
}
public void PushEmpty()
{
if (Type is WatchValueType.String or WatchValueType.NotSet)
StringList.Add(WatchValue<string>.Empty());
if (Type is WatchValueType.Float or WatchValueType.NotSet)
FloatList.Add(WatchValue<float>.Empty());
if (Type is WatchValueType.Double or WatchValueType.NotSet)
DoubleList.Add(WatchValue<double>.Empty());
if (Type is WatchValueType.Int or WatchValueType.NotSet)
IntList.Add(WatchValue<int>.Empty());
if (Type is WatchValueType.Bool or WatchValueType.NotSet)
BoolList.Add(WatchValue<bool>.Empty());
}
}
}

View File

@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 4f792bb3d24444668b46d0d355e5ab9d
timeCreated: 1639768623
AssetOrigin:
serializedVersion: 1
productId: 324001
packageName: LiveWatch Lite | Debug with full history of changes
packageVersion: 1.0.1
assetPath: Assets/LiveWatchLite/Scripts/WatchVariable/WatchValueList.cs
uploadId: 770587

View File

@@ -0,0 +1,13 @@

namespace Ingvar.LiveWatch
{
public enum WatchValueType
{
NotSet,
Float,
Double,
Int,
Bool,
String,
}
}

View File

@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 347dbe39de0d4191af57fc559b206deb
timeCreated: 1642780701
AssetOrigin:
serializedVersion: 1
productId: 324001
packageName: LiveWatch Lite | Debug with full history of changes
packageVersion: 1.0.1
assetPath: Assets/LiveWatchLite/Scripts/WatchVariable/WatchValueType.cs
uploadId: 770587

View File

@@ -0,0 +1,31 @@
using System;
using UnityEngine;
namespace Ingvar.LiveWatch
{
[Serializable]
public class WatchVariable : ISerializationCallbackReceiver
{
public string Name;
public WatchValueList Values = new ();
[SerializeReference] public WatchVariable Parent;
[SerializeReference] public WatchStorage Childs = new ();
public VariableEditorMeta EditorMeta = new ();
public VariableRuntimeMeta RuntimeMeta = new ();
public bool HasChilds => Childs.Count > 0;
public bool HasValues => Values.Count > 0;
public void OnBeforeSerialize()
{
}
public void OnAfterDeserialize()
{
foreach (var child in Childs.Items.Values)
{
child.Parent = this;
}
}
}
}

View File

@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: cbc3537ef6fe43a8ababb29682647da2
timeCreated: 1636112412
AssetOrigin:
serializedVersion: 1
productId: 324001
packageName: LiveWatch Lite | Debug with full history of changes
packageVersion: 1.0.1
assetPath: Assets/LiveWatchLite/Scripts/WatchVariable/WatchVariable.cs
uploadId: 770587