Browse Source

import/export from tl

eLandon 4 years ago
parent
commit
3abac35b39
1 changed files with 31 additions and 13 deletions
  1. 31 13
      SequenceMgr.js

+ 31 - 13
SequenceMgr.js

@@ -162,6 +162,7 @@ function update(deltaTime){
 			seq_followCursor() ;
 		}
 	}
+	else{script.log("no sequence selected");}
 }
 
 
@@ -283,17 +284,17 @@ function refreshSequenceEnum(){
 function importSequenceFile(loadFile){
 
 	doSync = false ;
-	script.log("loading file");
+	script.log("loading file "+loadFile.get());
 	loadData = loadFile.readFile(true);
 
 	//load parameters
 	var parameters = local.getChild("parameters");
-	parameters.syncRate.set(loadData.parameters.SyncRate);
-	parameters.synchronize.set(loadData.parameters.Synchronize);
-	parameters.monitorKeysCues.set(loadData.parameters.monitorKeysCues);
+	parameters.syncRate.set(loadData.parameters['Sync Rate']);
+	parameters.synchronize.set(loadData.parameters['Synchronize']);
+	parameters.monitorKeysCues.set(loadData.parameters['monitorKeysCues']);
 	sequence = loadData.parameters.Sequence;
-	if(1){
-
+	if(true){
+		
 		parameters.sequence.removeOptions();
 		parameters.sequence.addOption(sequence,0);
 		parameters.sequence.setAttribute("readonly", true);
@@ -305,28 +306,34 @@ function importSequenceFile(loadFile){
 			tl_sequence = root.sequences.addItem();
 			tl_sequence.setName(sequence);
 		}
-
+		script.log(tl_sequence.name);
 		//recreate cues
 		tl_sequence.cues.removeAll();
-		var cuesList = util.getObjectProperties(loadData.values.keys.cues, true, false);
+		var cuesList = util.getObjectProperties(loadData.values.keys['cues'], false, true);
+		script.log("create cues : "+ cuesList.length);
 		if(cuesList.length){
 			for(var i=0; i<cuesList.length; i++){
 				var cue = tl_sequence.cues.addItem();
 				cue.setName(cuesList[i]);
-				cue.time.set(loadData.values.keys.cues[cuesList[i]].time);
+				cue.time.set(loadData.values.keys.cues[cuesList[i]]);
+				script.log("created cue "+ cuesList[i]);
 			}
 		}
 
 		//recreate layers and keys
 		tl_sequence.layers.removeAll();
-		var layersList = util.getObjectProperties(loadData.values.keys.layers, true, false);
+		printMethodsAndProperties(loadData.values.keys['layers']);
+		var layersList = util.getObjectProperties(loadData.values.keys['layers'], true, false);
+		script.log("create layers : "+ layersList.length);
 		if(layersList.length){
 			for(var i=0; i<layersList.length; i++ ){
+				
 				var layerType = loadData.values.keys.layers[layersList[i]].type ;
 				var layer = tl_sequence.layers.addItem(layerType);
-
+				script.log("create layer : ("+ layerType+") "+layersList[i]);
 				layer.setName(layersList[i]);
 				var keysList = util.getObjectProperties(loadData.values.keys.layers[layersList[i]], true, false);
+				script.log("create keys : "+ keysList.length);
 				if(keysList.length){
 					if (layerType != "Audio"){
 						for(var j=0; j<keysList.length; j++){						
@@ -359,14 +366,25 @@ function importSequenceFile(loadFile){
 				var cue = group.addFloatParameter("cue", "", 0., 0.);
 				group.setName(groupList[i]);
 				cue.set(loadData.values.groups[groupList[i]].time);
+				if(loadData.values.groups[groupList[i]].timeOut!=undefined){
+					var cueOut = group.addFloatParameter("cueOut", "", 0., 0.);
+					cueOut.set(loadData.values.groups[groupList[i]].timeOut);
+				}
 
 				var groupKeysList = util.getObjectProperties(loadData.values.groups[groupList[i]].groupKeys, true, false);
 				if (groupKeysList.length){
 					var keysContainer = group.addContainer("keys");
 					keysContainer.setCollapsed(true);
+					var keysContainerOut ;
+					if(loadData.values.groups[groupList[i]].timeOut!=undefined){
+						keysContainerOut = group.addContainer("keysOut");
+					}
 					for (var j=0; j<groupKeysList.length; j++){
 						group.addFloatParameter(groupKeysList[j], "", 0., 0., 1.);
 						keysContainer.addStringParameter(groupKeysList[j], "", loadData.values.groups[groupList[i]]['groupKeys'][groupKeysList[j]]['key']);
+						if(loadData.values.groups[groupList[i]].timeOut!=undefined){
+							keysContainerOut.addStringParameter(groupKeysList[j], "", loadData.values.groups[groupList[i]]['groupKeys'][groupKeysList[j]]['key']+"o");
+						}
 					}
 				}
 			}
@@ -402,11 +420,11 @@ function exportSequenceFile(fileObj){
 			var exportGroup = exportData.values.groups[groupsList[i]] = {cue:"", time:0., groupKeys:{}};
 			var currentGroup = groups.getChild(groupsList[i]);
 			
-			exportGroup.cue = currentGroup.cue.name;
+			exportGroup.cue = currentGroup.name;
 			exportGroup.time = currentGroup.cue.get();
 			var isInOut = currentGroup.getChild("keysOut") ;
 			if(isInOut){
-				exportGroup.cueOut = currentGroup.cueOut.name;
+				exportGroup.cueOut = currentGroup.name+"o";
 				exportGroup.timeOut = currentGroup.cueOut.get();
 			}