Parcourir la source

exportSequenceFile()

eLandon il y a 4 ans
Parent
commit
089d47f1b0
1 fichiers modifiés avec 62 ajouts et 2 suppressions
  1. 62 2
      SequenceMgr.js

+ 62 - 2
SequenceMgr.js

@@ -72,7 +72,7 @@ function init() {
 	//test if a sequence is already choosen else refresh and unlock sequence enum
 	sequence = local.getChild("parameters").sequence.getKey();
 	// var sequenceIndex = local.getChild("parameters").sequence.get();
-	script.log(sequenceIndex + "  " + sequence);
+	// script.log(sequenceIndex + "  " + sequence);
 	
 	if(sequence == ""){refreshSequenceEnum();}
 	else{
@@ -252,7 +252,67 @@ function importSequenceFile(){
 
 function exportSequenceFile(){
 	script.log("exporting file");
-	local.parameters.sequenceFile.writeFile(JSON.stringify(sequence_structure), true);
+	var exportData = {parameters:{}, values:{groups:{}, keys:{cues:{}, layers:{}}}};
+
+	//collect parameters 
+	var parameters = local.getChild("parameters");
+	var parametersList = util.getObjectProperties(parametersPath, true, false);
+	exportData.parameters["Sequence"] = parameters.sequence.getKey();
+	exportData.parameters["Synchronise"] = parameters.synchronize.get();
+	exportData.parameters["Sync Rate"] = parameters.syncRate.get();
+
+	//collect values
+	var values = local.getChild("values");
+	var groups = values.groups;
+	var groupsList=util.getObjectProperties(groups, true, false);
+	if(groupsList.length){
+		for(var i=0; i<groupsList.length; i++){
+			var exportGroup = exportData.values.groups[groupsList[i]] = {};
+			var currentGroup = groups.getChild(groupsList[i]);
+			var currentGroupLayers = util.getObjectProperties(currentGroup.keys, true, false);
+			if (currentGroupLayers.length){
+				for(var j=0; j<currentGroupLayers.length; j++){
+					// script.log(groupsList[i]+ "  "+ currentGroupLayers[j]);
+					exportGroup[currentGroupLayers[j]] = {key:"", value:0.};
+					exportGroup[currentGroupLayers[j]].value = currentGroup.getChild(currentGroupLayers[j]).get();
+					exportGroup[currentGroupLayers[j]].key = currentGroup.keys.getChild(currentGroupLayers[j]).get();
+				}
+			}
+		}
+	}
+
+	var cues = values.keys.cues;
+	var cuesList=util.getObjectProperties(cues, true, false);
+	if(cuesList.length){
+		for(var i=0; i<cuesList.length; i++){
+			var exportCue = exportData.values.keys.cues[cuesList[i]] = {cue:"", time:0.};
+			exportCue.cue = cuesList[i];
+			exportCue.time = cues.getChild(cuesList[i]).time.get();
+			
+		}
+	}
+
+	var layers = values.keys.layers;
+	var layersList=util.getObjectProperties(layers, true, false);
+	if(layersList.length){
+		for(var i=0; i<layersList.length; i++){
+			var exportLayer = exportData.values.keys.layers[layersList[i]] = {};
+			var currentLayer = layers.getChild(layersList[i]);
+			var currentLayersKeys = util.getObjectProperties(currentLayer, true, false);
+			if (currentLayersKeys.length){
+				for(var j=0; j<currentLayersKeys.length; j++){
+					// script.log(groupsList[i]+ "  "+ currentGroupLayers[j]);
+					exportLayer[currentLayersKeys[j]] = {key:"", value:0., time:0.};
+					exportLayer[currentLayersKeys[j]].value = currentLayer.getChild(currentLayersKeys[j]).value.get();
+					exportLayer[currentLayersKeys[j]].key = currentLayer.getChild(currentLayersKeys[j]).name;
+					exportLayer[currentLayersKeys[j]].key = currentLayer.getChild(currentLayersKeys[j]).time.get();
+				}
+			}
+		}
+	}
+
+	// exportData.groups
+	parameters.importExport.sequenceFile.writeFile(JSON.stringify(exportData), true);
 }