Got the toolbox code cleaned up, and the YSetStrcuture tool, already works with this new model.

This commit is contained in:
2015-03-18 16:45:14 -07:00
parent 6d01d35cd0
commit 992891bf28
2 changed files with 108 additions and 70 deletions
File diff suppressed because one or more lines are too long
+106 -68
View File
@@ -1,83 +1,121 @@
#include "../yScripts/y_JSExtensions.jsx"; #include "../yScripts/y_JSExtensions.jsx";
function YSetProjectTool()
{
this.info =
{
name : "YSetStructure",
version : 0.11,
stage : "alpha",
description : "Set the Folder Structure for a new Project",
url : "yorchnet.com"
};
this.appearence =
{
buttonHeight : 30,
buttonWidth : 126
};
this.init = function init()
{
alert("my name is:" + this.info.name);
this.btnLauyout =
"button\
{\
preferredSize: ['" + this.appearence.buttonWidth + "','" + this.appearence.buttonHeight + "'],\
text:'" + this.info.name + "',\
helpTip:'" + this.info.description + "'\
}";
ySetProject_data = new Object(); this. res =
"window\
ySetProject_data.scriptName = 'YSetStructure'; {\
ySetProject_data.scriptDesc = 'Set the Folder Structure for a new Project'; type:'palette',\
ySetProject_data.scriptVer = '0.1a'; text:'" + this.info.name + ' ' + this.info.ver + ' ' + this.info.stage + "',\
ySetProject_data.webLink = 'yorchnet.com'; info: Group \
{\
//if yToolBox Exists add it to its tool list. alignment:['center','bottom'],\
if (typeof(YTB)!=='undefined'){ icon: Image \
YTB.tools.push(ySetProject_data); {\
preferredSize: [15, 18]\
//it should be called from toolbox. },\
/* website: StaticText\
ySetProject_data.buttonWidth=76; {\
ySetProject_data.buttonHeight=30; text:'" + this.info.url + "',\
*/ alignment:['fill','center']\
ySetProject_data.btnLayout = "btn_"+ ySetProject_data.scriptName+": Button { preferredSize: ['"+ YTB.buttonWidth+"','"+ YTB.buttonHeight+"'], text:'"+ySetProject_data.scriptName+"', helpTip:'"+ySetProject_data.scriptDesc+"' }"; },\
}\
}";
} }
this.ySetProject = function ySetProject()
ySetProject_data.res = "window { \ {
type:'palette' , text:'"+ySetProject_data.scriptName+' '+ySetProject_data.scriptVer+"',\ alert("is this working");
\
\
info: Group { \
alignment:['center','bottom'], \
icon: Image {preferredSize: [15, 18]},\
website: StaticText { text:'"+ySetProject_data.webLink+"', alignment:['fill','center'] },\
}\
\
}";
//------------------------------------------------------------------------------------------------------------------------
function ySetProject(){
app.beginUndoGroup('ySetProject'); app.beginUndoGroup('ySetProject');
var preStruct = ["01 MAIN","02 PComp","03 Source Layers" ,"04 Movies","05 Other Projects","06 Audio" , "07 Reference"]; var preStruct = ["01 MAIN","02 PComp","03 Source Layers" ,"04 Movies","05 Other Projects","06 Audio" , "07 Reference"];
var newStruct = []; var newStruct = [];
var projectItems = []; var projectItems = [];
for(i=1;i<=app.project.items.length;i++){ for(i=1;i<=app.project.items.length;i++)
if(app.project.items[i].parentFolder.name=='Root'){ {
projectItems.push(app.project.items[i].name); if(app.project.items[i].parentFolder.name=='Root')
{
projectItems.push(app.project.items[i].name);
}
} }
//to start a new organized project since the beginning
if (projectItems.length == 0)
{
newStruct = preStruct;
}
else
{
for(a=0;a<preStruct.length;a++)
{
if ((projectItems.getOne(preStruct[a]))==-1)
{
newStruct.push(preStruct[a]);
}
}
}
for(i = 0;i<newStruct.length;i++)
{
app.project.items.addFolder(newStruct[i]);
}
saveNow = confirm("Project Succesfully Set, Save Project?",true,"ySetProject");
if(saveNow==true){
app.project.save()
}else{
}
app.endUndoGroup();
} }
//to start a new organized project since the beginning this.activate = this.ySetProject;
if (projectItems.length == 0){ this.init();
newStruct = preStruct; return this;
}else{
for(a=0;a<preStruct.length;a++){
if ((projectItems.getOne(preStruct[a]))==-1){
newStruct.push(preStruct[a]);
};
}
} }
for(i = 0;i<newStruct.length;i++){
app.project.items.addFolder(newStruct[i]);
}
saveNow = confirm("Project Succesfully Set, Save Project?",true,"ySetProject");
if(saveNow==true){
app.project.save()
}else{
}
app.endUndoGroup();
}
//------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------
function build_ySetProject_data_UI(){ //------------------------------------------------------------------------------------------------------------------------
ySetProject_data.window = new Window ( ySetProject_data.res);
ySetProject_data.window.show(); function build_ySetProject_data_UI()
} {
ySetProject_data.activate = ySetProject ; ySetProject_data.window = new Window ( ySetProject_data.res );
ySetProject_data.window.show();
}
//CHECKS that the toolbox exists, and if it doesn´t it runs the script on its own. //CHECKS that the toolbox exists, and if it doesn´t it runs the script on its own.
if (typeof(YTB)=='undefined'){ if (typeof(YTB)=='undefined')
ySetProject_data.activate(); {
}else{ ySetProject_data = new YSetProjectTool();
} ySetProject_data.activate();
}
else
{
YTB.addTool(new YSetProjectTool());
}