瀏覽代碼

added layersType

to allow import/export with types
eLandon 4 年之前
父節點
當前提交
1510c85ec0
共有 2 個文件被更改,包括 60 次插入25 次删除
  1. 50 22
      SequenceMgr.js
  2. 10 3
      module.json

+ 50 - 22
SequenceMgr.js

@@ -24,7 +24,7 @@ var saveDelta = 0.;
 var debug = true;
 var debugFile;
 
-var parametersPath = local.parameters ;
+var parametersPath = local.getChild("parameters") ;
 
 var sequence = '' ;
 var sequencePath = local.getChild("parameters").sequence ;
@@ -43,22 +43,27 @@ var layers = local.getChild("values").keys.layers ;
 
 var rebuildValues = script.addTrigger("rebuild values", "adds a key at current cursor position" );
 var refreshKeys = script.addTrigger("refresh keys", "truc");
-var printKeys = script.addTrigger("printKeys","truc");
+var TrigprintKeys = script.addTrigger("printKeys","truc");
 var clearSeq = script.addTrigger("clear Sequence","truc");
 
+var UIposGet = script.addTrigger("get UIPos", "");
+var UIpos = script.addFloatParameter("UIpos", "", 0., 0.);
 
-var sequence_structure = {	params: {}, 
-							groups:{},
-							keys:{
-								cues:{},
-								layers:{}
-							}
-						};
+// var sequence_structure = {	params: {}, 
+// 							groups:{},
+// 							keys:{
+// 								cues:{},
+// 								layers:{}
+// 							}
+						// };
 						 //WAS tl_groups
 	/*group0 : { inCue : {pan : "key", tilt : "key", zoom : "key", dim : "key", focus : "key"},
 							 							outCue : {pan : "key", tilt : "key", zoom : "key", dim : "key", focus : "key"}
 													}*/
-								
+							
+													
+
+
 /////////////////////		SCRIPT FUNCTIONS	//////////////////////////////
 
 
@@ -68,12 +73,13 @@ function init() {
 	//adapt update rate
 	updateSyncRate();
 	updateSynchronize();
-
+	// script.log(root.sequences.truc.viewStartTime.get();)
 	saveFile.set("sequence_autosave.json");
 	saveFile.setAttribute("readonly", true);
-	importSequenceFile(saveFile);
+	// importSequenceFile(saveFile);
 	// layers = local.getChild("values").keys.layers ;
-	// printMethodsAndProperties(local.getChild("values").groups.group0.cue.get());
+	// script.log(root.sequences.truc.layers.speed.getType());
+	// printMethodsAndProperties(root.sequences.truc.layers.audio);
 	// script.log(local.getChild("values").groups.group0.cue.get());
 	//test if a sequence is already choosen else refresh and unlock sequence enum
 	sequence = local.getChild("parameters").sequence.getKey();
@@ -92,7 +98,10 @@ function init() {
 
 function scriptParameterChanged(param){
 	
-	if (param.is(printKeys) ){printKeys();}
+	if (param.is(TrigprintKeys) ){printKeys();}
+	else if(param.is(UIpos)) {script.log("uipos"); root.sequences.truc.viewUIPosition(UIpos.get());}
+
+	if (param.is(UIposGet)){script.log("getUIpos");}
 
 	else if(param.is(rebuildValues)){struct_buildValuesFromSeq();}
 
@@ -176,8 +185,8 @@ function printKeys(){
 
 // Module callback
 function moduleParameterChanged(param){
-	
-
+	parametersPath = local.getChild("parameters") ;
+	script.log("received module param :" + param.name);
 	if (param.is(parametersPath.importExport.sequenceFile)) {}
 
 	else if (param.is(parametersPath.importExport.importSequence)){importSequenceFile(parametersPath.importExport.sequenceFile);}
@@ -211,11 +220,13 @@ function moduleParameterChanged(param){
 }
 
 function updateSynchronize(){
+	// var parametersPath = local.getChild("parameters") ;
 	doSync = parametersPath.synchronize.get();
 	script.log(doSync ? "sync ON" : "sync OFF" );
 }
 
 function updateSyncRate(){
+	// var parametersPath = local.getChild("parameters") ;
 	syncRatems = parametersPath.syncRate.get() / 1000.;
 	script.log("new sync rate : " + syncRatems);
 	// script.setUpdateRate(syncRatems);
@@ -373,13 +384,18 @@ function exportSequenceFile(fileObj){
 			var exportLayer = exportData.values.keys.layers[layersList[i]] = {};
 			var currentLayer = layers.getChild(layersList[i]);
 			var currentLayersKeys = util.getObjectProperties(currentLayer, true, false);
+			// exportLayer["type"] = currentLayer.getType();
 			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]].time = currentLayer.getChild(currentLayersKeys[j]).time.get();
+					
+					if(currentLayersKeys[j]!="type"){
+						script.log(currentLayersKeys[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]].time = currentLayer.getChild(currentLayersKeys[j]).time.get();
+					}
 				}
 			}
 		}
@@ -482,13 +498,19 @@ function struct_buildValuesFromSeq(){
 				if(addRemove){
 					var newLayer = layers.addContainer("newLayer"+i);
 					// newLayer.addFloatParameter("time", "position in time", 0., 0.);
+					local.getChild("values").keys.layerTypes.addStringParameter("newLayer"+i, "", "");
 					newLayer.setCollapsed(true);
 					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.removeContainer(util.getObjectProperties(layers, true, false)[0]);
+					local.getChild("values").newGroup.layers.removeParameter(util.getObjectProperties(layers, true, false)[0]);
+					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.setCollapsed(true);
+					local.getChild("values").keys.layerTypes.setCollapsed(false);
 				}
 				// cuesList = ;
 				
@@ -499,13 +521,19 @@ function struct_buildValuesFromSeq(){
 		if(layersChanged){
 			layers = local.getChild("values").keys.layers ;
 			var layerList = util.getObjectProperties(layers, true, false);
+			layerTypes = local.getChild("values").keys.layerTypes ;
+			var layerTypeList = util.getObjectProperties(layerTypes, true, false);
 			var template = local.getChild("values").newGroup.layers;
 			var layerTemplate = util.getObjectProperties(template, true, false);
 
 			if(tl_layers.length){
 				for (var i=0; i<tl_layers.length; i++){
 					var currentLayer = layers.getChild(layerList[i]);
+					// currentLayer.getChild("type").set(tl_layers[i].getType());
 					currentLayer.setName(tl_layers[i].name);
+					var currentLayerType = layerTypes.getChild(layerTypeList[i]);
+					currentLayerType.setName(tl_layers[i].name);
+					currentLayerType.set(tl_layers[i].getType());
 					var currentTemplate = template.getChild(layerTemplate[i]) ;
 					currentTemplate.setName(tl_layers[i].name);
 				}

+ 10 - 3
module.json

@@ -1,7 +1,7 @@
 {
 	"name": "sequenceMgr",
 	"path": "LIEN",
-	"type": "OSC",
+	"type": "Serial",
 	"version": "0.0.1",
 	"description": "augment control over sequence keys, with saving/recalling mecanism, grouping ",
 	"url": "",
@@ -10,14 +10,17 @@
 	"hasOutput": false,
 	"hideDefaultCommands": true,
 	"hideDefaultParameters": [
+		"autoFeedback",
 		"protocol",
+		"pass_through",
+		"baseAddress",
+		"clearValues",
 		"autoAdd",
 		"messageStructure",
 		"firstValueIsTheName",
 		"port",
 		"baudRate",
-		"isConnected",
-		"pass_through"
+		"isConnected"
 	],
 	"defaults": {},
 	"parameters": {
@@ -92,6 +95,10 @@
 			"layers": {
 				"type": "Container",
 				"collapsed": false
+			},
+			"layerTypes": {
+				"type": "Container",
+				"collapsed": true
 			}
 		}
 	},