Browse Source

fixed group keys naming conflict

eLandon 4 years ago
parent
commit
2d4e45ccf1
1 changed files with 38 additions and 36 deletions
  1. 38 36
      SequenceMgr.js

+ 38 - 36
SequenceMgr.js

@@ -80,7 +80,7 @@ function init() {
 	// script.log(root.sequences.truc.viewStartTime.get();)
 	saveFile.set("sequence_autosave.json");
 	saveFile.setAttribute("readonly", true);
-	// importSequenceFile(saveFile);
+	importSequenceFile(saveFile);
 	
 	// var audioLayer = root.sequences.truc.layers.audio ;
 	// var newClip = audioLayer.clips.addItem();
@@ -502,8 +502,8 @@ function struct_buildValuesFromSeq(){
 					newCue.setCollapsed(true);
 				}
 				else {
-					script.log(util.getObjectProperties(cues, true, false)[0]);
-					cues.removeContainer(util.getObjectProperties(cues, true, false)[0]);
+					// script.log(util.getObjectProperties(cues, true, false)[0]);
+					cues.removeContainer(util.getObjectProperties(cues, true, false)[i]);
 				}
 				// cuesList = ;
 				
@@ -542,18 +542,19 @@ function struct_buildValuesFromSeq(){
 					// newLayer.addFloatParameter("time", "position in time", 0., 0.);
 					local.getChild("values").keys.layerTypes.addStringParameter("newLayer"+i, "", "");
 					newLayer.setCollapsed(true);
-					if (tl_layers[i].getType()!="Audio"){
-						local.getChild("values").newGroup.layers.addFloatParameter("newLayer"+i, "value for this layer at group creation", 0., 0., 1.);
-					}
+					local.getChild("values").newGroup.layers.addFloatParameter("newLayer"+i, "value for this layer at group creation", 0., 0., 1.);
+					// if (tl_layers[i].getType()!="Audio"){
+					// 	local.getChild("values").newGroup.layers.addFloatParameter("newLayer"+i, "value for this layer at group creation", 0., 0., 1.);
+					// }
 					
 				}
 				else {
-					script.log(util.getObjectProperties(layers, true, false)[0]);
-					layers.removeContainer(util.getObjectProperties(layers, true, false)[0]);
-					local.getChild("values").newGroup.layers.removeParameter(util.getObjectProperties(layers, true, false)[0]);
+					// script.log(util.getObjectProperties(layers, true, false)[0]);
+					layers.removeContainer(util.getObjectProperties(layers, true, false)[i]);
+					local.getChild("values").newGroup.layers.removeParameter(util.getObjectProperties(layers, true, false)[i]);
 					local.getChild("values").newGroup.layers.setCollapsed(true);
 					local.getChild("values").newGroup.layers.setCollapsed(false);
-					local.getChild("values").keys.layerTypes.removeParameter(util.getObjectProperties(layers, true, false)[0]);
+					local.getChild("values").keys.layerTypes.removeParameter(util.getObjectProperties(layers, true, false)[i]);
 					local.getChild("values").keys.layerTypes.setCollapsed(true);
 					local.getChild("values").keys.layerTypes.setCollapsed(false);
 				}
@@ -581,7 +582,7 @@ function struct_buildValuesFromSeq(){
 					currentLayerType.setName(tl_layers[i].name);
 					currentLayerType.set(tl_layers[i].getType());
 					var currentTemplate = template.getChild(layerTemplate[i]) ;
-					if (tl_layers[i].getType()!="Audio"){layer_offset+=1;}
+					if (tl_layers[i].getType()=="Audio"){layer_offset+=1;}
 					currentTemplate.setName(tl_layers[i+layer_offset].name);
 				}
 			}
@@ -619,8 +620,8 @@ function struct_buildValuesFromSeq(){
 								newKey.setCollapsed(true);
 							}
 							else {
-								script.log(util.getObjectProperties(currentLayer, true, false)[0]);
-								currentLayer.removeContainer(util.getObjectProperties(currentLayer, true, false)[0]);
+								// script.log(util.getObjectProperties(currentLayer, true, false)[0]);
+								currentLayer.removeContainer(util.getObjectProperties(currentLayer, true, false)[i]);
 							}		
 							
 							
@@ -650,8 +651,8 @@ function struct_buildValuesFromSeq(){
 								newClip.setCollapsed(true);
 							}
 							else {
-								script.log(util.getObjectProperties(currentLayer, true, false)[0]);
-								currentLayer.removeContainer(util.getObjectProperties(currentLayer, true, false)[0]);
+								// script.log(util.getObjectProperties(currentLayer, true, false)[0]);
+								currentLayer.removeContainer(util.getObjectProperties(currentLayer, true, false)[i]);
 							}		
 							
 							
@@ -715,7 +716,7 @@ function struct_buildValuesFromSeq(){
 					for(var removeKeyIndex = 0; removeKeyIndex< groupToRemoveKeyslist.length; removeKeyIndex++) {
 						var tl_removeLayer = tl_seq.layers.getItemWithName( groupToRemoveKeyslist[removeKeyIndex]) ;
 						var tl_removeKey = tl_removeLayer.automation.getItemWithName(groupToRemove.keys.getChild( groupToRemoveKeyslist[removeKeyIndex]).get());
-						script.log(tl_removeKey.name);
+						// script.log(tl_removeKey.name);
 						tl_removeLayer.automation.removeItem(tl_removeKey);
 					}
 					groups.removeContainer(groupList[i]);
@@ -745,23 +746,23 @@ function struct_buildValuesFromSeq(){
 							var keyName = currentGroup.keys.getChild(tl_layer.name).get();
 							// script.log(tl_layer.name + "  " +tl_layer.automation.getItemWithName(keyName).name);
 							//if key dosn't exist anymore, remove it from group
-							if(tl_layer.automation.getItemWithName(keyName).name == undefined){
-								groups = local.getChild("values").groups ;
-								groupList = util.getObjectProperties(groups, true, false);
-								currentGroup = groups.getChild(groupList[i]);
-								currentGroupLayers = util.getObjectProperties (currentGroup.keys, true, false);
-								tl_layer = tl_seq.layers.getItemWithName(currentGroupLayers[j]);
-								keyName = currentGroup.keys.getChild(tl_layer.name).get();
-								script.log("should remove" + currentGroup.name + "  " + currentGroupLayers[j]);
-								currentGroup.keys.removeParameter(currentGroupLayers[j]);
-								currentGroup.removeParameter(currentGroupLayers[j]);
-								currentGroup.setCollapsed(true);
-								currentGroup.setCollapsed(false);
-								hasUpdated = true;
+							// if(tl_layer.automation.getItemWithName(keyName).name == undefined){
+							// 	groups = local.getChild("values").groups ;
+							// 	groupList = util.getObjectProperties(groups, true, false);
+							// 	currentGroup = groups.getChild(groupList[i]);
+							// 	currentGroupLayers = util.getObjectProperties (currentGroup.keys, true, false);
+							// 	tl_layer = tl_seq.layers.getItemWithName(currentGroupLayers[j]);
+							// 	keyName = currentGroup.keys.getChild(tl_layer.name).get();
+							// 	script.log("should remove" + currentGroup.name + "  " + currentGroupLayers[j]);
+							// 	currentGroup.keys.removeParameter(currentGroupLayers[j]);
+							// 	currentGroup.removeParameter(currentGroupLayers[j]);
+							// 	currentGroup.setCollapsed(true);
+							// 	currentGroup.setCollapsed(false);
+							// 	hasUpdated = true;
 								
-							}
+							// }
 							//if key exists, update value from tl and update time from group cue
-							else{
+							if(tl_layer.automation.getItemWithName(keyName).name != undefined){
 								//apply groupTime
 								var tl_key = tl_layer.automation.getItemWithName(keyName);
 								tl_key.position.set(groupTime);
@@ -901,7 +902,7 @@ function createNewGroup(){
 	//Get current sequence time position and create cue at this position, with group name
 	var currentTime = tl_seq.currentTime.get() ;
 	// var currentTime = local.values.newGroup.groupTime.get();
-	script.log(currentTime);
+	// script.log(currentTime);
 	newCue = tl_seq.cues.addItem();
 	newCue.time.set(currentTime);
 	//test for holes in the sequence to rename the cue
@@ -917,7 +918,7 @@ function createNewGroup(){
  
 	
 	
-	currentGroup.addFloatParameter(newCue.name, "cue of the group", currentTime, 0.);
+	currentGroup.addFloatParameter("cue", "cue of the group", currentTime, 0.);
 	var keysContainer = currentGroup.addContainer("keys");
 	keysContainer.setCollapsed(true);
 	tl_seq = root.sequences.getItemWithName(sequence);
@@ -929,11 +930,12 @@ function createNewGroup(){
 				// script.log(sequence_structure.keys.layers[layers[i].name]);
 				var newKey = tl_layers[i].automation.addItem();
 				newKey.position.set(currentTime);
-				script.log([layers[i].name]);  //local.getChild("values").newGroup.layers.getChild().name
+				newKey.setName(currentGroup.name);
+				script.log(currentGroup.name);  //local.getChild("values").newGroup.layers.getChild().name
 				newKey.value.set(local.getChild("values").newGroup.layers.getChild(tl_layers[i].name).get());
 				// newKey.value.set(Math.random());
-				keysContainer.addStringParameter(tl_layers[i].name, "",newKey.name );
-				currentGroup.addFloatParameter(tl_layers[i].name,tl_layers[i].name+" value" , newKey.value.get(), 0., 1.);
+				keysContainer.addStringParameter(tl_layers[i].name, "",currentGroup.name );
+				currentGroup.addFloatParameter(tl_layers[i].name,tl_layers[i].name+" value" , currentGroup.name, 0., 1.);
 				// newKey.addStringParameter("group", "key is part of this group","mongroupe");
 				tl_layers[i].automation.reorderItems();
 			}