From 37dd0bb36bcb2b22aa1cf4405cd9ec22abd8039b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20V=C3=A1squez=20P=C3=A9rez?= Date: Thu, 2 Mar 2017 15:43:15 -0800 Subject: [PATCH] Reorganized everything a little better, and changed the way the avatars load --- jsx/MKN_DC_Customizer.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jsx/MKN_DC_Customizer.jsx b/jsx/MKN_DC_Customizer.jsx index 029bc1f..7ac75e9 100644 --- a/jsx/MKN_DC_Customizer.jsx +++ b/jsx/MKN_DC_Customizer.jsx @@ -1 +1 @@ -{ ///////////////////////////////////////////////////////////////////////// // // MAkinE Disney Customizer // // ©2017 Jorge Vasquez // Author: Jorge Vasquez // // Version History // //////////////////////////////////////////////////////////////////////// var tcd_scriptName = "MAkinE - Disney Customizer "; var tcd_version = "0.1"; // function applyPallette( palette_string ){ var comp = app.project.activeItem; var color_targets = { col_title: comp.layer("TITLE")("Effects")("Fill")("Color"), col_bubble: comp.layer("DONT_TOUCH_bubble")("Effects")("Fill")("Color"), col_bubble_shadow: comp.layer("DONT_TOUCH_bubble_shadow")("Effects")("Fill")("Color"), col_logo_bg : comp.layer("DISNEY_LOGO_Bubble_BG")("Effects")("Fill")("Color"), col_logo_fg: comp.layer("DISNEY_LOGO_Bubble_FG")("Effects")("Fill")("Color"), col_logo_neutral: comp.layer("DISNEY_LOGO_Bubble_GRAY")("Effects")("Fill")("Color"), col_logo_accent: comp.layer("DISNEY_LOGO_Bubble_ACCENT")("Effects")("Fill")("Color"), }; for ( var i in color_targets ) { color_targets[i].setValue(hexToColor(palettes[palette_string][i])); } } function hexToColor(theHex){ var r = theHex >> 16; var g = (theHex & 0x00ff00) >> 8; var b = theHex & 0xff; return [r/255,g/255,b/255,1]; } function tcd_buildUI(thisObj) { if (thisObj instanceof Panel) { var myPal = thisObj; } else { var myPal = new Window("palette",tcd_scriptName + " v" + tcd_version,undefined, {resizeable:true}); } if (myPal != null) { var res = "group { \ alignment: ['fill','fill'], \ alignChildren: ['left','top'], \ orientation: 'column', \ match: Group { \ alignment: ['fill','top'], \ alignChildren: ['fill','top'], \ orientation:'column', \ title: Group { \ alignment: ['fill','top'], \ alignChildren: ['fill','top'], \ paletteText: StaticText {text:'Piece Palette', alignment: ['left','center']}, \ paletteOption: DropDownList {alignment: ['left','center']}, \ titleTxt: StaticText {text:'Show Title', alignment: ['left','center']}, \ titleString: EditText {text: 'SHOW TITLE HERE', alignment: ['fill','center']}, \ } \ } \ \ }"; //doItBtn: Button {text: 'Customize', alignment: ['right','top']} , \ myPal.grp = myPal.add(res); for ( i in paletteOptionNames ) { myPal.grp.match.title.paletteOption.add("item",i); } myPal.grp.match.title.paletteOption.selection = 0; myPal.grp.match.title.paletteOption.minimumSize.width = myPal.grp.match.title.paletteOption.preferredSize.width = 75; myPal.grp.match.title.titleString.onChange = function () { //alert("changing text"); var title = myPalette.grp.match.title.titleString.text; applyShowTitle( title ); } myPal.grp.match.title.paletteOption.onChange = function () { //alert("changing palette"); var id = paletteOptionNames[myPalette.grp.match.title.paletteOption.selection]; setBG( id ); applyPallette( id ); } /* myPal.grp.doItBtn.onClick = function () { var checkError = false; if (checkError == false) tcd_doIt (); } //myPal.grp.doItBtn.onClick = function () */ myPal.layout.layout(true); myPal.layout.resize(); myPal.onResizing = myPal.onResize = function () {this.layout.resize();} } //if (myPal != null) return myPal; } function applyShowTitle( new_title ){ var comp = app.project.activeItem; var title_layer = comp.layer("TITLE"); var ctrl_layer = comp.layer("ctrl_bubble"); title_layer.sourceText.setValue( new_title ); width = title_layer.sourceRectAtTime(0, false).width; var new_scale; var new_center; if ( width >= 1300 ) { new_scale = (1500/width)*100; new_center = [787,540]; } else if ( width > 640 ) { new_scale = 100; new_center = [960,540]; } else { new_scale = 100; new_center = [1040,540]; } comp.layer("DONT_TOUCH_CTRL_CENTER")("Transform")("Position").setValue(new_center); comp.layer("ctrl_bubble")("Transform")("Scale").setValue([new_scale,new_scale]); ctrl_layer("Effects")("width")("Slider").setValue(width + 75); } function setBG ( id ){ new_source = app.project.activeItem.layer("DC_GEN_BG_"+String(id)).source; a = app.project.activeItem.layer("BG"); a.replaceSource(new_source,false) } function tcd_doIt (){ } //function tcd_doIt (palObj) var paletteOptions = ["C","D","E","F","G","H"]; var paletteOptionNames = { Gray : "D", Gold : "F", Magenta : "G", Blue_1 : "C", Blue_2 : "E", Blue_3 : "H" }; var palettes = { A : { col_title: 0xFFFB00, col_bubble: 0x3BCCFD, col_bubble_shadow: 0x2A9BC1, col_logo_bg : 0xFAF800, col_logo_fg: 0xE74DB7, col_logo_neutral: 0x2C313B, col_logo_accent: 0x19EDFF }, C : { col_title: 0xE74DB7, col_bubble: 0xFFFC00, col_bubble_shadow: 0xBBB900, col_logo_bg : 0xE74DB7, col_logo_fg: 0xFAF800, col_logo_neutral: 0x2C313B, col_logo_accent: 0x7c36e1 }, D : { col_title: 0x2a3a51, col_bubble: 0x3ed9bc, col_bubble_shadow: 0x238573, col_logo_bg : 0xE74DB7, col_logo_fg: 0xFAF800, col_logo_neutral: 0x2C313B, col_logo_accent: 0x3ed9bc }, E : { col_title: 0x288492, col_bubble: 0xFFFC00, col_bubble_shadow: 0xBBB900, col_logo_bg : 0xe149ae, col_logo_fg: 0xFFFC00, col_logo_neutral: 0x2C313B, col_logo_accent: 0x19EDFF }, F : { col_title: 0x1BF0FF, col_bubble: 0xE74DB7, col_bubble_shadow: 0xA93886, col_logo_bg : 0x1BF0FF, col_logo_fg: 0xE74DB7, col_logo_neutral: 0x2C313B, col_logo_accent: 0x7c36e1 }, G : { col_title: 0xfffa38, col_bubble: 0x7c36e1, col_bubble_shadow: 0x5525ab, col_logo_bg : 0x44f2fc, col_logo_fg: 0x7c36e1, col_logo_neutral: 0x2C313B, col_logo_accent: 0x2C313B }, H: { col_title: 0x7c36e1, col_bubble: 0xfffa38, col_bubble_shadow: 0xc3bf28, col_logo_bg : 0x7c36e1, col_logo_fg: 0xfffa38, col_logo_neutral: 0x2C313B, col_logo_accent: 0xE74DB7 } } //main var myPalette = tcd_buildUI(this); var tcd_folderName, tcd_addFolder, tcd_origParentFolder, tcd_parentFolder, previousComps, previousFolders; if (parseFloat(app.version) < 8) { alert("This script requires Adobe After Effects CS3 or later.", tcd_scriptName); } else { if (myPalette != null && myPalette instanceof Window) { //myPalette.center(); myPalette.show(); } } } \ No newline at end of file +{ ///////////////////////////////////////////////////////////////////////// // // MAkinE Disney Customizer // // ©2017 Jorge Vasquez // Author: Jorge Vasquez // // Version History // //////////////////////////////////////////////////////////////////////// var tcd_scriptName = "MAkinE - Disney Customizer "; var tcd_version = "0.1"; // function applyAvatar( item ){ //$.writeln( item ); var comp = myPalette.comp; //$.writeln(comp); var avatar_targets = [ comp.layer("Main_Avatar"), comp.layer("Avatar_Echo_1"), comp.layer("Avatar_Echo_2") ]; //$.writeln(avatar_targets); for ( var i = 0 ; i < avatar_targets.length ; i ++ ) { avatar_targets[i].replaceSource(item,false); } } function applyPallette( palette_string ){ var comp = myPalette.comp; var color_targets = { col_title: comp.layer("TITLE")("Effects")("Fill")("Color"), col_bubble: comp.layer("DONT_TOUCH_bubble")("Effects")("Fill")("Color"), col_bubble_shadow: comp.layer("DONT_TOUCH_bubble_shadow")("Effects")("Fill")("Color"), col_logo_bg : comp.layer("DISNEY_LOGO_Bubble_BG")("Effects")("Fill")("Color"), col_logo_fg: comp.layer("DISNEY_LOGO_Bubble_FG")("Effects")("Fill")("Color"), col_logo_neutral: comp.layer("DISNEY_LOGO_Bubble_GRAY")("Effects")("Fill")("Color"), col_logo_accent: comp.layer("DISNEY_LOGO_Bubble_ACCENT")("Effects")("Fill")("Color"), }; for ( var i in color_targets ){ color_targets[i].setValue(hexToColor(palettes[palette_string][i])); } } function getItem( item_name, item_type ){ var result = null; var items = app.project.items; var names = []; for ( i = 1 ; i <= items.length ; i ++ ) { var item = items[i]; var type = item.typeName; if ( ( type == item_type ) && ( item.name == item_name ) ) { result = item; //$.writeln( item.name ); } } return result; } function getFolder( given_name ){ result = getItem( given_name, "Folder" ); return result; } function getComp( given_name ){ result = getItem( given_name, "Composition" ); return result; } function hexToColor(theHex){ var r = theHex >> 16; var g = (theHex & 0x00ff00) >> 8; var b = theHex & 0xff; return [r/255,g/255,b/255,1]; } function tcd_buildUI(thisObj) { if ( getComp("DC_GEN_BUMP_##Base##_5s") == null ) { alert("Make sure to have the DC_GEN_BUMP Template project open before running the script"); return; } if (thisObj instanceof Panel) { var myPal = thisObj; } else { var myPal = new Window("palette",tcd_scriptName + " v" + tcd_version,undefined, {resizeable:true}); } if (myPal != null) { var res = "group { \ alignment: ['fill','fill'], \ alignChildren: ['left','top'], \ orientation: 'column', \ match: Group { \ alignment: ['fill','top'], \ alignChildren: ['fill','top'], \ orientation:'column', \ title: Group { \ alignment: ['fill','top'], \ alignChildren: ['fill','top'], \ paletteText: StaticText {text:'Piece Palette', alignment: ['left','center']}, \ paletteOption: DropDownList {alignment: ['left','center']}, \ titleTxt: StaticText {text:'Show Title', alignment: ['left','center']}, \ titleString: EditText {text: 'PLACEHOLDER TITLE', alignment: ['fill','center']}, \ avatarText: StaticText {text:'Avatar Image', alignment: ['left','center']}, \ avatarOption: DropDownList {alignment: ['left','center']}, \ } \ } \ doItBtn: Button {text: 'Apply to new Comp', alignment: ['center','top']} , \ }"; //doItBtn: Button {text: 'Customize', alignment: ['right','top']} , \ myPal.avatar_folder = getFolder("AVATAR_ICONS_1080x1080"); myPal.comp = getComp("DC_GEN_BUMP_##Base##_5s"); myPal.paletteOptionNames = { Gray : "D", Gold : "F", Magenta : "G", Blue_1 : "C", Blue_2 : "E", Blue_3 : "H" }; myPal.populateAvatars = function() { myPal.grp.match.title.avatarOption.removeAll(); myPal.avatars = []; if ( myPal.avatar_folder != null ) { for ( i = 1 ; i <= myPal.avatar_folder.numItems ; i ++ ) { myPal.avatars.push( myPal.avatar_folder.item(i) ); //$.writeln(myPal.avatars[i-1]); myPal.grp.match.title.avatarOption.add("item", myPal.avatars[i-1].name); //$.writeln( myPal.avatar_folder.item(i).name ); } } myPal.grp.match.title.avatarOption.selection = myPal.avatars.indexOf ( myPal.comp.layer("Main_Avatar").source ); } myPal.grp = myPal.add(res); for ( i in myPal.paletteOptionNames ) { myPal.grp.match.title.paletteOption.add("item",i); } //myPal.avatars = []; myPal.populateAvatars (); myPal.grp.match.title.paletteOption.selection = 0; myPal.grp.match.title.paletteOption.minimumSize.width = myPal.grp.match.title.paletteOption.preferredSize.width = 75; myPal.grp.match.title.titleString.onChange = function () { //alert("changing text"); if( myPal.comp == null ) { return; } app.beginUndoGroup("Change Text"); var title = myPalette.grp.match.title.titleString.text; applyShowTitle( title ); app.endUndoGroup(); } myPal.grp.match.title.paletteOption.onChange = function () { //alert("changing palette"); if( myPal.comp == null ) { return; } app.beginUndoGroup("Change Palette"); var id = myPal.paletteOptionNames[myPalette.grp.match.title.paletteOption.selection]; setBG( id ); applyPallette( id ); app.endUndoGroup(); } myPal.grp.match.title.avatarOption.onChange = function () { try { applyAvatar( myPal.avatars[myPal.grp.match.title.avatarOption.selection.index ] ); } catch(err) { } //applyAvatar( myPal.avatars[myPal.grp.match.title.avatarOption.selection.index] ); } myPal.onDeactivate = function() { myPal.populateAvatars (); } /* myPal.grp.match.title.avatarOption.onActivate = function () { myPal.populateAvatars (); } */ /* //myPal.grp.doItBtn.onClick = function () */ myPal.grp.doItBtn.onClick = function () { var new_comp = myPal.comp.duplicate(); new_comp.name = myPal.comp.name.replace("##Base##",generateName()); } myPal.layout.layout(true); myPal.layout.resize(); myPal.onResizing = myPal.onResize = function () {this.layout.resize();} } //if (myPal != null) return myPal; } function titleCase(str) { str = str.toLowerCase().split(' '); for(var i = 0; i < str.length; i++){ str[i] = str[i].split(''); str[i][0] = str[i][0].toUpperCase(); str[i] = str[i].join(''); } return str.join(' '); } function getTitle(){ var comp = myPalette.comp; var title_layer = comp.layer("TITLE"); var title = title_layer.sourceText.value.text; return title } function formatTitle( s ) { title = titleCase( s ); var exp = new RegExp(" " , 'g'); title = title.replace(" ",""); title = title.replace(exp, ''); return title; } function generateName(){ var name = getTitle(); name = formatTitle ( name ) + "_" + genColorCode (); return name } function genColorCode() { var id = String(myPalette.grp.match.title.paletteOption.selection); cc = ""; switch ( id ) { case "Blue_1": cc = "BLU1"; break; case "Blue_2": cc = "BLU2"; break; case "Blue_3": cc = "BLU3"; break; case "Gray": cc = "GRY"; break; case "Magenta": cc = "MGN"; break; case "Gold": cc = "GLD" break; } return cc; } function applyShowTitle( new_title ){ var comp = myPalette.comp; var title_layer = comp.layer("TITLE"); var ctrl_layer = comp.layer("ctrl_bubble"); title_layer.sourceText.setValue( new_title ); width = title_layer.sourceRectAtTime(0, false).width; var new_scale; var new_center; if ( width >= 1300 ) { new_scale = (1500/width)*100; new_center = [787,540]; } else if ( width > 640 ) { new_scale = 100; new_center = [960,540]; } else { new_scale = 100; new_center = [1040,540]; } comp.layer("DONT_TOUCH_CTRL_CENTER")("Transform")("Position").setValue(new_center); comp.layer("ctrl_bubble")("Transform")("Scale").setValue([new_scale,new_scale]); ctrl_layer("Effects")("width")("Slider").setValue(width + 75); } function setBG ( id ){ new_source = myPalette.comp.layer("DC_GEN_BG_"+String(id)).source; a = myPalette.comp.layer("BG"); a.replaceSource(new_source,false) } var paletteOptions = ["C","D","E","F","G","H"]; var colors = { gray : 0x2C313B, purple : 0x7c36e1, purple_dark : 0x5525ab, yellow : 0xfffa38, yellow_dark : 0xBBB900, magenta : 0xE74DB7, magenta_dark : 0xA93886, cyan : 0x1BF0FF, cyan_darl : 0x128DA6, aqua_dark : 0x238573, aqua : 0x288492, aqua_light : 0x3ED8BB, bluish_gray : 0x2A3B52 } var palettes = { A : { col_title: colors.magenta, col_bubble: colors.yellow, col_bubble_shadow: colors.yellow_dark, col_logo_bg : colors.yellow, col_logo_fg: colors.magenta, col_logo_neutral: colors.gray, col_logo_accent: 0x19EDFF }, C : { col_title: colors.magenta, col_bubble: colors.yellow, col_bubble_shadow: colors.yellow_dark, col_logo_bg : colors.yellow, col_logo_fg: colors.magenta, col_logo_neutral: colors.gray, col_logo_accent: colors.purple }, D : { col_title: colors.bluish_gray, col_bubble: colors.aqua_light, col_bubble_shadow: colors.aqua_dark, col_logo_bg : colors.yellow, col_logo_fg: colors.magenta, col_logo_neutral: colors.gray, col_logo_accent: colors.cyan }, E : { col_title: colors.aqua, col_bubble: colors.yellow, col_bubble_shadow: colors.yellow_dark, col_logo_bg : colors.purple, col_logo_fg: colors.yellow, col_logo_neutral: colors.gray, col_logo_accent: colors.magenta }, F : { col_title: colors.cyan, col_bubble: colors.magenta, col_bubble_shadow: colors.magenta_dark, col_logo_bg : colors.purple, col_logo_fg: colors.cyan, col_logo_neutral: colors.gray, col_logo_accent: colors.magenta }, G : { col_title: colors.yellow, col_bubble: colors.purple, col_bubble_shadow: colors.purple_dark, col_logo_bg : colors.purple, col_logo_fg: colors.yellow, col_logo_neutral: colors.gray, col_logo_accent: colors.cyan }, H: { col_title: colors.purple, col_bubble: colors.yellow, col_bubble_shadow: colors.yellow_dark, col_logo_bg : colors.purple, col_logo_fg: colors.yellow, col_logo_neutral: colors.gray, col_logo_accent: 0xE74DB7 } } //main var myPalette = tcd_buildUI(this); var tcd_folderName, tcd_addFolder, tcd_origParentFolder, tcd_parentFolder, previousComps, previousFolders; if (parseFloat(app.version) < 8) { alert("This script requires Adobe After Effects CS3 or later.", tcd_scriptName); } else { if (myPalette != null && myPalette instanceof Window) { //myPalette.center(); myPalette.show(); } } } \ No newline at end of file