Selaa lähdekoodia

group creation management

can set values for each layer and global group time
added method to rebuild values UI
added method to create group using module values
eLandon 4 vuotta sitten
vanhempi
commit
0723fe53dc
3 muutettua tiedostoa jossa 69 lisäystä ja 33 poistoa
  1. 59 27
      SequenceMgr.js
  2. 9 5
      module.json
  3. 1 1
      testSequenceMgr.noisette

+ 59 - 27
SequenceMgr.js

@@ -11,7 +11,7 @@ keys are grouped by name, and groups can be saved/loaded to a file
 // var parameterPath = local.parameters;
 // var valuesPath = local.values;
 
-var newKey = script.addTrigger("newKey", "adds a key at current cursor position" );
+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 moveKey = script.addTrigger("moveKey","truc");
@@ -34,7 +34,7 @@ var sequence_structure = {	params: {},
 function init() {
 	script.log("LOADED SEQUENCE GROUPING MANAGEMENT MODULE ");
 	// script.log();
-	testSequenceFile();
+	if(testSequenceFile()){loadSequenceFile();}
 	
 	// printMethodsAndProperties(local.parameters.sequenceFile);
 
@@ -76,19 +76,7 @@ function moduleParameterChanged(param){
 }
 
 function moduleValueChanged(value){
-
-
-	//
-	// if (value.name == "addGroup"){
-	// 	script.log("in values");
-	//
-	// 	var meth = util.getObjectProperties(key);
-	// 	if(meth.length){
-	// 		for(var i=0; i< meth.length; i++){
-	// 			script.log(meth[i]);
-	// 		}
-	// 	}
-	// }
+	if (value.name == "addGroup"){createNewGroup(sequence_structure.params.sequence);}
 }
 
 function scriptParameterChanged(param){
@@ -107,12 +95,7 @@ function scriptParameterChanged(param){
 	// 	root.sequences.sequence.layers.mapping.automation.key2.position.set(10.);
 	// }
 	if (param.is(printKeys) ){printKeys();}
-	if(param.is(newKey)){
-		var key = root.sequences.sequence.layers.mapping.automation.addItem();
-		key.position.set(root.sequences.sequence.currentTime.get());
-		key.value.set(Math.random());
-		root.sequences.sequence.layers.mapping.automation.reorderItems();
-	}
+	if(param.is(rebuildValues)){rebuildValuesStructure();	}
 
 	if (param.is(refreshKeys)){
 		script.log("refreshKeys");
@@ -176,22 +159,24 @@ function testSequenceFile(){
 		//if all is well, let's load in sequence_structure
 		else {
 			script.log("ready to import");
+			return 1;
 			// loadSequenceFile();
 		}
 	}
 	else {
 		script.log("no file to load");
 		refreshSequenceEnum();
+		return 0;
 	}	
 }
 
 function loadSequenceFile(){
 	script.log("loading file");
-			sequence_structure = data;
+			sequence_structure = local.parameters.sequenceFile.readFile(true);
 			//lock enum with curent sequence name
 			var sequenceList = local.parameters.sequence;
 			sequenceList.removeOptions();
-			sequenceList.addOption(data.params.sequence, 0);
+			sequenceList.addOption(sequence_structure.params.sequence, 0);
 			local.parameters.sequence.setAttribute("readonly",true);
 }
 
@@ -217,12 +202,33 @@ function printKeys(){
 a nogroup container shows keys that are not grouped
 */
 
-function clearValues(){
-	var values = local.values.getItems();
-
+// function clearValues(){
+	// var values = local.values.getItems();
+// }
+
+function rebuildValuesStructure() {
+	script.log("updating values structure");
+	//empty current structure 
+	local.getChild("Values").removeContainer("newGroup");
+	local.getChild("Values").removeContainer("groups");
+	local.getChild("Values").removeContainer("ungrouped");
+
+	//rebuild containers
+	var ng_cont = local.values.addContainer("New group");
+	var g_cont = local.values.addContainer("groups");
+	var ug_cont = local.values.addContainer("ungrouped");
+	
+	// rebuild new group
+	ng_cont.addTrigger("add group", "adds a new group at cursor time with below values");
+	ng_cont.addFloatParameter("group time", "time position where the group will be created ", 0., 0.);
+	var layer_cont = ng_cont.addContainer("layers values");
+	var layers = util.getObjectProperties(sequence_structure.keys.layers) ;
+	for (var i=0; i<layers.length; i++){
+		layer_cont.addFloatParameter(layers[i], "", 0., 0., 1.);
+	}
+	
 }
 
-
 ///////////////////////		TIMELINE FUNCTIONS		///////////////////////
 
 function refreshKeysList(){
@@ -263,4 +269,30 @@ function refreshKeysList(){
 	}
 
 	// myFile.writeFile(JSON.stringify(tl_keyframes), 1);
+}
+
+function createNewGroup(seqName){
+	//create a cue and a key in each layer at cursor position in selected sequence
+	
+	var seq = root.sequences.getItemWithName(seqName);
+	var currentTime = seq.currentTime.get() ;
+	// var currentTime = local.values.newGroup.groupTime.get();
+	script.log(currentTime);
+	newCue = seq.cues.addItem();
+	newCue.time.set(currentTime);
+	var layers = seq.layers.getItems();
+	script.log(layers.length);
+	// var struc_layers = util.getObjectProperties(sequence_structure.keys.layers);
+	if(layers.length){
+		for(var i=0;i<layers.length; i++ ){
+			// script.log(sequence_structure.keys.layers[layers[i].name]);
+			newKey = layers[i].automation.addItem();
+			newKey.position.set(currentTime);
+			script.log(local.values.newGroup.layersValues[layers[i].name].get());
+			newKey.value.set(local.values.newGroup.layersValues[layers[i].name].get());
+			layers[i].automation.reorderItems();
+		}
+	}
+	// seq = seq.getItems();
+
 }

+ 9 - 5
module.json

@@ -1,5 +1,5 @@
 {
-	"name": "keysMgr",
+	"name": "sequenceMgr",
 	"type": "Serial",
 	"path": "LIEN",
 	"version": "0.0.1",
@@ -42,12 +42,16 @@
 		}
 	},
 	"scripts": [
-		"keysMgr.js"
+		"SequenceMgr.js"
 	],
 	"values": {
-		"addGroup": {
-			"type": "Trigger",
-			"description": "create a new key group"
+		"New group":{
+			"type": "Container",
+			"collapsed": false,
+			"Create": {
+				"type": "Trigger",
+				"description": "create a new key group"
+			}
 		},
 		"groups": {
 			"type": "Container",

Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 1 - 1
testSequenceMgr.noisette