mirror of
https://github.com/jwetzell/QControlKit.git
synced 2026-08-22 07:29:07 +00:00
Add "nest level" and children cue updating
-start on sorting
This commit is contained in:
+141
-24
@@ -10,7 +10,7 @@ using QControlKit.Constants;
|
|||||||
|
|
||||||
namespace QControlKit
|
namespace QControlKit
|
||||||
{
|
{
|
||||||
public class QCue
|
public class QCue : IComparable
|
||||||
{
|
{
|
||||||
|
|
||||||
public QWorkspace workspace;
|
public QWorkspace workspace;
|
||||||
@@ -19,6 +19,7 @@ namespace QControlKit
|
|||||||
public Dictionary<string, QCue> childCuesUIDMap;
|
public Dictionary<string, QCue> childCuesUIDMap;
|
||||||
|
|
||||||
public int sortIndex;
|
public int sortIndex;
|
||||||
|
public int nestLevel;
|
||||||
|
|
||||||
private bool needsSortChildCues;//?
|
private bool needsSortChildCues;//?
|
||||||
private bool needsNotifyCueUpdated;//?
|
private bool needsNotifyCueUpdated;//?
|
||||||
@@ -70,6 +71,38 @@ namespace QControlKit
|
|||||||
updatePropertiesWithDictionary(dict);
|
updatePropertiesWithDictionary(dict);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public QCue(JToken dict, QWorkspace workspace, int nestLevel)
|
||||||
|
{
|
||||||
|
init();
|
||||||
|
this.workspace = workspace;
|
||||||
|
this.nestLevel = nestLevel + 1;
|
||||||
|
//this breaks things???
|
||||||
|
//it definitely is in the original but somehow the recursion is not working as I expect..
|
||||||
|
//but cue population still works without this as child cues are populated later
|
||||||
|
|
||||||
|
/*JToken children = dict[QOSCKey.Cues];
|
||||||
|
if(children != null && children.Type == JTokenType.Array)
|
||||||
|
{
|
||||||
|
Log.Debug($"[cue] new cue being created with {children.Count()} childCues");
|
||||||
|
foreach (var aChildDict in children)
|
||||||
|
{
|
||||||
|
string uid = (string)aChildDict[QOSCKey.UID];
|
||||||
|
//Log.Debug($"[cue] childDict with uid: {uid} being processed");
|
||||||
|
if (uid == null)
|
||||||
|
continue;
|
||||||
|
string name = dict[QOSCKey.UID].ToString();
|
||||||
|
Log.Debug($"[cue] calling new cue from {name}");
|
||||||
|
|
||||||
|
//QCue child = new QCue(aChildDict, workspace);
|
||||||
|
|
||||||
|
*//*childCues.Add(child);
|
||||||
|
childCuesUIDMap.Add(uid, child);*//*
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
|
||||||
|
updatePropertiesWithDictionary(dict);
|
||||||
|
}
|
||||||
|
|
||||||
public void init()
|
public void init()
|
||||||
{
|
{
|
||||||
cueData = new Dictionary<string, object> {
|
cueData = new Dictionary<string, object> {
|
||||||
@@ -102,11 +135,36 @@ namespace QControlKit
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//isEqual?
|
public override bool Equals(Object obj)
|
||||||
//hash?
|
{
|
||||||
//compare?
|
//Check for null and compare run-time types.
|
||||||
//TODO
|
if ((obj == null) || !this.GetType().Equals(obj.GetType()))
|
||||||
public bool isEqualToCue(QCue cue) { throw new NotImplementedException(); }
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return isEqualToCue((QCue)obj);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override int GetHashCode()
|
||||||
|
{
|
||||||
|
return uid.GetHashCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int CompareTo(object obj)
|
||||||
|
{
|
||||||
|
if (obj.GetType().Equals(this.GetType()))
|
||||||
|
return sortIndex.CompareTo(((QCue)obj).sortIndex);
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool isEqualToCue(QCue cue) {
|
||||||
|
return cue.uid.Equals(uid);
|
||||||
|
}
|
||||||
|
|
||||||
public void setWorkspace(QWorkspace workspace)
|
public void setWorkspace(QWorkspace workspace)
|
||||||
{
|
{
|
||||||
if(this.workspace != workspace)
|
if(this.workspace != workspace)
|
||||||
@@ -114,11 +172,13 @@ namespace QControlKit
|
|||||||
this.workspace = workspace;
|
this.workspace = workspace;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addChildCue(QCue cue)
|
public void addChildCue(QCue cue)
|
||||||
{
|
{
|
||||||
string uid = propertyForKey(QOSCKey.UID).ToString();
|
string childUid = propertyForKey(QOSCKey.UID).ToString();
|
||||||
addChildCue(cue, uid);
|
addChildCue(cue, childUid);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addChildCue(QCue cue, string uid)
|
public void addChildCue(QCue cue, string uid)
|
||||||
{
|
{
|
||||||
if (uid.Length == 0)
|
if (uid.Length == 0)
|
||||||
@@ -128,9 +188,33 @@ namespace QControlKit
|
|||||||
//some sorting of the childCues needs to be done? //TODO
|
//some sorting of the childCues needs to be done? //TODO
|
||||||
//reset sorting index
|
//reset sorting index
|
||||||
}
|
}
|
||||||
public void removeChildCue(QCue cue) { throw new NotImplementedException(); }
|
|
||||||
public void removeAllChildCues() { throw new NotImplementedException(); }
|
public void removeChildCue(QCue cue) {
|
||||||
public void removeChildCuesWithIDs(List<string> uids) { throw new NotImplementedException(); }
|
if (cue.uid.Length == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
childCues.Remove(cue);
|
||||||
|
childCuesUIDMap.Remove(cue.uid);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeAllChildCues() {
|
||||||
|
childCuesUIDMap.Clear();
|
||||||
|
childCues.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeChildCuesWithIDs(List<string> uids) {
|
||||||
|
foreach (string aUid in uids)
|
||||||
|
{
|
||||||
|
if (!childCuesUIDMap.ContainsKey(aUid))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
QCue cue = childCuesUIDMap[aUid];
|
||||||
|
|
||||||
|
Log.Debug($"Removing Child Cue From {listName} : {cue.uid} + {cue.listName}");
|
||||||
|
childCues.Remove(cue);
|
||||||
|
childCuesUIDMap.Remove(aUid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//copied: yes
|
//copied: yes
|
||||||
//implemented: no
|
//implemented: no
|
||||||
@@ -554,9 +638,18 @@ namespace QControlKit
|
|||||||
JToken value = obj.Value;
|
JToken value = obj.Value;
|
||||||
if (obj.Key.Equals(QOSCKey.Cues))
|
if (obj.Key.Equals(QOSCKey.Cues))
|
||||||
{
|
{
|
||||||
|
//Log.Debug($"Cues OSC Key found in update message...updating child cues");
|
||||||
if (value.Type != JTokenType.Array)
|
if (value.Type != JTokenType.Array)
|
||||||
continue;
|
continue;
|
||||||
updateChildCuesWithPropertiesArray(value, false);
|
updateChildCuesWithPropertiesArray(value, false);
|
||||||
|
workspace.Print();
|
||||||
|
}
|
||||||
|
else if(obj.Key.Equals(QOSCKey.Children) && IsGroup)
|
||||||
|
{
|
||||||
|
//Log.Debug($"Children OSC Key found in update message for {uid} ...updating child and removing deleted ones.");
|
||||||
|
if (value.Type != JTokenType.Array)
|
||||||
|
continue;
|
||||||
|
updateChildCuesWithPropertiesArray(value, true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -565,6 +658,7 @@ namespace QControlKit
|
|||||||
{
|
{
|
||||||
cueUpdated = true;
|
cueUpdated = true;
|
||||||
propertiesUpdated.Add(obj.Key);
|
propertiesUpdated.Add(obj.Key);
|
||||||
|
//Log.Debug($"[cue] cue property {obj.Key} updated with {obj.Value}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -581,26 +675,31 @@ namespace QControlKit
|
|||||||
if (!workspace.connected)
|
if (!workspace.connected)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
List<string> previousUids = null;
|
List<string> previousUids = new List<string>();
|
||||||
|
|
||||||
if (removeUnused)
|
if (removeUnused)
|
||||||
|
{
|
||||||
previousUids = allChildCueUids();
|
previousUids = allChildCueUids();
|
||||||
|
}
|
||||||
|
|
||||||
int index = 0;
|
int index = 0;
|
||||||
|
|
||||||
foreach (var dict in value)
|
foreach (var dict in value)
|
||||||
{
|
{
|
||||||
string uid = (string)dict[QOSCKey.UID];
|
string childUid = (string)dict[QOSCKey.UID];
|
||||||
if (uid == null)
|
if (childUid == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (removeUnused)
|
if (removeUnused)
|
||||||
previousUids.Remove(uid);
|
{
|
||||||
|
previousUids.Remove(childUid);
|
||||||
|
}
|
||||||
|
|
||||||
QCue child = cueWithID(uid, false);
|
QCue child = cueWithID(childUid, false);
|
||||||
|
|
||||||
if (child != null)
|
if (child != null)
|
||||||
{
|
{
|
||||||
bool didUpdateProperties = updatePropertiesWithDictionary(dict);
|
bool didUpdateProperties = child.updatePropertiesWithDictionary(dict);
|
||||||
if (didUpdateProperties)
|
if (didUpdateProperties)
|
||||||
needsNotifyCueUpdated = true;
|
needsNotifyCueUpdated = true;
|
||||||
|
|
||||||
@@ -614,13 +713,25 @@ namespace QControlKit
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
child = new QCue(dict, workspace);
|
child = new QCue(dict, workspace, nestLevel);
|
||||||
child.sortIndex = index;
|
child.sortIndex = index;
|
||||||
addChildCue(child, uid);
|
addChildCue(child, childUid);
|
||||||
needsNotifyCueUpdated = true;
|
needsNotifyCueUpdated = true;
|
||||||
}
|
}
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (previousUids.Count() > 0 && removeUnused)
|
||||||
|
{
|
||||||
|
removeChildCuesWithIDs(previousUids);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (needsSortChildCues)
|
||||||
|
{
|
||||||
|
//something about cues needing to be sorted?
|
||||||
|
}
|
||||||
|
|
||||||
return needsNotifyCueUpdated;
|
return needsNotifyCueUpdated;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
@@ -728,21 +839,25 @@ namespace QControlKit
|
|||||||
|
|
||||||
Dictionary<string,QCue> newChildCuesUIDMap = new Dictionary<string, QCue>();
|
Dictionary<string,QCue> newChildCuesUIDMap = new Dictionary<string, QCue>();
|
||||||
int index = 0;
|
int index = 0;
|
||||||
string uid = null;
|
string childUid = null;
|
||||||
|
|
||||||
foreach(var aCue in (List<QCue>)value)
|
foreach(var aCue in (List<QCue>)value)
|
||||||
{
|
{
|
||||||
uid = aCue.uid;
|
childUid = aCue.uid;
|
||||||
if (uid == null)
|
if (childUid == null)
|
||||||
continue;
|
continue;
|
||||||
aCue.sortIndex = index;
|
aCue.sortIndex = index;
|
||||||
newChildCuesUIDMap.Add(uid, aCue);
|
newChildCuesUIDMap.Add(childUid, aCue);
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
childCues = (List<QCue>)value;
|
childCues = (List<QCue>)value;
|
||||||
childCuesUIDMap = newChildCuesUIDMap;
|
childCuesUIDMap = newChildCuesUIDMap;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
else if (key.Equals(QOSCKey.Children))
|
||||||
|
{
|
||||||
|
Log.Debug($"Children Cues property updated for: {this.displayName} : {this.uid}");
|
||||||
|
}
|
||||||
else if(key.Equals(QOSCKey.PlaybackPositionId))
|
else if(key.Equals(QOSCKey.PlaybackPositionId))
|
||||||
{
|
{
|
||||||
if (!IsCueList)
|
if (!IsCueList)
|
||||||
@@ -844,7 +959,7 @@ namespace QControlKit
|
|||||||
{
|
{
|
||||||
string indent = new string(' ', level*2);
|
string indent = new string(' ', level*2);
|
||||||
|
|
||||||
Log.Information($"{indent}\u00b7{displayName}");
|
Log.Information($"{indent}\u00b7{displayName} - {uid}");
|
||||||
if (IsGroup)
|
if (IsGroup)
|
||||||
{
|
{
|
||||||
level++;
|
level++;
|
||||||
@@ -858,6 +973,8 @@ namespace QControlKit
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ namespace QControlKit
|
|||||||
root.setProperty(QIdentifiers.RootCue, QOSCKey.UID, false);
|
root.setProperty(QIdentifiers.RootCue, QOSCKey.UID, false);
|
||||||
root.setProperty("Cue Lists", QOSCKey.Name, false);
|
root.setProperty("Cue Lists", QOSCKey.Name, false);
|
||||||
root.setProperty(QCueType.CueList, QOSCKey.Type, false);
|
root.setProperty(QCueType.CueList, QOSCKey.Type, false);
|
||||||
|
root.nestLevel = -1;
|
||||||
|
|
||||||
if (version == null || version.Length <= 0)
|
if (version == null || version.Length <= 0)
|
||||||
version = "3.0.0";
|
version = "3.0.0";
|
||||||
@@ -331,19 +332,21 @@ namespace QControlKit
|
|||||||
|
|
||||||
public void fetchDefaultPropertiesForCue(QCue cue)
|
public void fetchDefaultPropertiesForCue(QCue cue)
|
||||||
{
|
{
|
||||||
string[] keys = new string[] { QOSCKey.UID, QOSCKey.Number, QOSCKey.Name,
|
List<string> keys = new List<string> { QOSCKey.UID, QOSCKey.Number, QOSCKey.Name,
|
||||||
QOSCKey.ListName, QOSCKey.Type, QOSCKey.ColorName,
|
QOSCKey.ListName, QOSCKey.Type, QOSCKey.ColorName,
|
||||||
QOSCKey.Flagged, QOSCKey.Armed, QOSCKey.Notes };
|
QOSCKey.Flagged, QOSCKey.Armed, QOSCKey.Notes };
|
||||||
fetchPropertiesForCue(cue, keys, false);
|
fetchPropertiesForCue(cue, keys.ToArray(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void fetchBasicPropertiesForCue(QCue cue)
|
public void fetchBasicPropertiesForCue(QCue cue)
|
||||||
{
|
{
|
||||||
string[] keys = new string[] { QOSCKey.Name, QOSCKey.ListName, QOSCKey.Number, QOSCKey.FileTarget, QOSCKey.CueTargetNumber,
|
List<string> keys = new List<string> { QOSCKey.Name, QOSCKey.ListName, QOSCKey.Number, QOSCKey.FileTarget, QOSCKey.CueTargetNumber,
|
||||||
QOSCKey.HasFileTargets, QOSCKey.HasCueTargets, QOSCKey.Armed, QOSCKey.ColorName,
|
QOSCKey.HasFileTargets, QOSCKey.HasCueTargets, QOSCKey.Armed, QOSCKey.ColorName,
|
||||||
QOSCKey.ContinueMode, QOSCKey.Flagged, QOSCKey.PreWait, QOSCKey.PostWait,
|
QOSCKey.ContinueMode, QOSCKey.Flagged, QOSCKey.PreWait, QOSCKey.PostWait,
|
||||||
QOSCKey.Duration, QOSCKey.AllowsEditingDuration, QOSCKey.Notes };
|
QOSCKey.Duration, QOSCKey.AllowsEditingDuration, QOSCKey.Notes };
|
||||||
fetchPropertiesForCue(cue, keys, false);
|
if (cue.IsGroup)
|
||||||
|
keys.Add(QOSCKey.Children);
|
||||||
|
fetchPropertiesForCue(cue, keys.ToArray(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void fetchPropertiesForCue(QCue cue, string[] keys, bool includeChildren)
|
public void fetchPropertiesForCue(QCue cue, string[] keys, bool includeChildren)
|
||||||
@@ -504,11 +507,12 @@ namespace QControlKit
|
|||||||
cueList.setProperty(args.cueID, QOSCKey.PlaybackPositionId, false);
|
cueList.setProperty(args.cueID, QOSCKey.PlaybackPositionId, false);
|
||||||
|
|
||||||
QCue selectedCue = cueWithID(args.cueID);
|
QCue selectedCue = cueWithID(args.cueID);
|
||||||
|
|
||||||
|
//TODO: need to implement when playbackposition is "none"
|
||||||
if (selectedCue != null)
|
if (selectedCue != null)
|
||||||
{
|
{
|
||||||
Log.Debug($"[workspace] cue list <{cueList.displayName}> playback position changed to <{selectedCue.displayName}>");
|
Log.Debug($"[workspace] cue list <{cueList.displayName}> playback position changed to <{selectedCue.displayName}>");
|
||||||
CueListChangedPlaybackPosition?.Invoke(this, new QCueListChangedPlaybackPositionArgs { cueListID = cueList.uid, cueID = selectedCue.uid });
|
CueListChangedPlaybackPosition?.Invoke(this, new QCueListChangedPlaybackPositionArgs { cueListID = cueList.uid, cueID = selectedCue.uid });
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -532,10 +536,9 @@ namespace QControlKit
|
|||||||
{
|
{
|
||||||
QCue cue = cueWithID(args.cueID);
|
QCue cue = cueWithID(args.cueID);
|
||||||
|
|
||||||
if (cue == null)
|
if (cue == null || cue.ignoreUpdates)
|
||||||
return;
|
|
||||||
if (cue.ignoreUpdates)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
cue.updatePropertiesWithDictionary(args.data);
|
cue.updatePropertiesWithDictionary(args.data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user