@ -0,0 +1,204 @@
( function ( thisObj )
{
buildUI ( thisObj ) ;
function buildUI ( thisObj )
{
/ *
Code for Import https : / / s c r i p t u i . j o o n a s . m e — ( T r i p l e c l i c k t o s e l e c t ) :
{ "activeId" : 15 , "items" : { "item-0" : { "id" : 0 , "type" : "Dialog" , "parentId" : false , "style" : { "enabled" : true , "varName" : "window" , "windowType" : "Window" , "creationProps" : { "su1PanelCoordinates" : false , "maximizeButton" : false , "minimizeButton" : false , "independent" : false , "closeButton" : false , "borderless" : false , "resizeable" : true } , "text" : "MMaker - RPP Marker Creator" , "preferredSize" : [ 256 , 0 ] , "margins" : 16 , "orientation" : "column" , "spacing" : 10 , "alignChildren" : [ "left" , "center" ] } } , "item-1" : { "id" : 1 , "type" : "Group" , "parentId" : 0 , "style" : { "enabled" : true , "varName" : null , "preferredSize" : [ 0 , 0 ] , "margins" : 0 , "orientation" : "row" , "spacing" : 10 , "alignChildren" : [ "left" , "center" ] , "alignment" : null } } , "item-2" : { "id" : 2 , "type" : "StaticText" , "parentId" : 1 , "style" : { "enabled" : true , "varName" : null , "creationProps" : { "truncate" : "none" , "multiline" : false , "scrolling" : false } , "softWrap" : false , "text" : "Load .rpp" , "justify" : "left" , "preferredSize" : [ 0 , 0 ] , "alignment" : null , "helpTip" : null } } , "item-3" : { "id" : 3 , "type" : "Button" , "parentId" : 1 , "style" : { "enabled" : true , "varName" : "fileOpener" , "text" : "..." , "justify" : "center" , "preferredSize" : [ 24 , 24 ] , "alignment" : null , "helpTip" : null } } , "item-5" : { "id" : 5 , "type" : "StaticText" , "parentId" : 0 , "style" : { "enabled" : true , "varName" : null , "creationProps" : { "truncate" : "none" , "multiline" : false , "scrolling" : false } , "softWrap" : false , "text" : "JSON Data" , "justify" : "left" , "preferredSize" : [ 0 , 0 ] , "alignment" : null , "helpTip" : null } } , "item-6" : { "id" : 6 , "type" : "Group" , "parentId" : 0 , "style" : { "enabled" : true , "varName" : null , "preferredSize" : [ 0 , 0 ] , "margins" : 0 , "orientation" : "row" , "spacing" : 10 , "alignChildren" : [ "left" , "center" ] , "alignment" : null } } , "item-7" : { "id" : 7 , "type" : "StaticText" , "parentId" : 6 , "style" : { "enabled" : true , "varName" : null , "creationProps" : { "truncate" : "none" , "multiline" : false , "scrolling" : false } , "softWrap" : false , "text" : "Track Name" , "justify" : "left" , "preferredSize" : [ 0 , 0 ] , "alignment" : null , "helpTip" : null } } , "item-9" : { "id" : 9 , "type" : "EditText" , "parentId" : 0 , "style" : { "enabled" : true , "varName" : "jsonData" , "creationProps" : { "noecho" : false , "readonly" : false , "multiline" : true , "scrollable" : true , "borderless" : false , "enterKeySignalsOnChange" : false } , "softWrap" : false , "text" : "" , "justify" : "left" , "preferredSize" : [ 224 , 96 ] , "alignment" : null , "helpTip" : null } } , "item-10" : { "id" : 10 , "type" : "Button" , "parentId" : 0 , "style" : { "enabled" : true , "varName" : "runButton" , "text" : "Go!" , "justify" : "center" , "preferredSize" : [ 64 , 0 ] , "alignment" : "center" , "helpTip" : null } } , "item-11" : { "id" : 11 , "type" : "DropDownList" , "parentId" : 6 , "style" : { "enabled" : true , "varName" : "trackName" , "text" : "DropDownList" , "listItems" : "" , "preferredSize" : [ 140 , 0 ] , "alignment" : null , "selection" : 0 , "helpTip" : null } } , "item-12" : { "id" : 12 , "type" : "Group" , "parentId" : 0 , "style" : { "enabled" : true , "varName" : null , "preferredSize" : [ 0 , 0 ] , "margins" : 0 , "orientation" : "row" , "spacing" : 10 , "alignChildren" : [ "left" , "center" ] , "alignment" : null } } , "item-13" : { "id" : 13 , "type" : "StaticText" , "parentId" : 12 , "style" : { "enabled" : true , "varName" : null , "creationProps" : { "truncate" : "none" , "multiline" : false , "scrolling" : false } , "softWrap" : false , "text" : "Frame Offset" , "justify" : "left" , "preferredSize" : [ 0 , 0 ] , "alignment" : null , "helpTip" : null } } , "item-15" : { "id" : 15 , "type" : "Button" , "parentId" : 0 , "style" : { "enabled" : true , "varName" : "aboutButton" , "text" : "?" , "justify" : "center" , "preferredSize" : [ 24 , 24 ] , "alignment" : "right" , "helpTip" : null } } , "item-16" : { "id" : 16 , "type" : "EditText" , "parentId" : 12 , "style" : { "enabled" : true , "varName" : "frameOffset" , "creationProps" : { "noecho" : false , "readonly" : false , "multiline" : false , "scrollable" : false , "borderless" : false , "enterKeySignalsOnChange" : false } , "softWrap" : false , "text" : "-3" , "justify" : "left" , "preferredSize" : [ 32 , 0 ] , "alignment" : null , "helpTip" : null } } } , "order" : [ 0 , 1 , 2 , 3 , 5 , 9 , 6 , 7 , 11 , 12 , 13 , 16 , 10 , 15 ] , "settings" : { "importJSON" : true , "indentSize" : false , "cepExport" : false , "includeCSSJS" : true , "showDialog" : true , "functionWrapper" : false , "afterEffectsDockable" : false , "itemReferenceList" : "None" } }
* /
/ / W I N D O W
/ / = = = = = =
var window = ( thisObj instanceof Panel ) ? thisObj : new Window ( "window" , undefined , undefined , { closeButton : true , resizeable : false } ) ;
/ / w i n d o w . t e x t = " M M a k e r - R P P M a r k e r C r e a t o r " ;
window . preferredSize . width = 224 ;
window . orientation = "column" ;
window . alignChildren = [ "left" , "center" ] ;
window . spacing = 10 ;
window . margins = 16 ;
/ / G R O U P 1
/ / = = = = = =
var group1 = window . add ( "group" , undefined , { name : "group1" } ) ;
group1 . orientation = "row" ;
group1 . alignChildren = [ "left" , "center" ] ;
group1 . spacing = 10 ;
group1 . margins = 0 ;
var statictext1 = group1 . add ( "statictext" , undefined , undefined , { name : "statictext1" } ) ;
statictext1 . text = "Load .rpp" ;
var fileOpener = group1 . add ( "button" , undefined , undefined , { name : "fileOpener" } ) ;
fileOpener . text = "..." ;
fileOpener . preferredSize . width = 24 ;
fileOpener . preferredSize . height = 24 ;
/ / W I N D O W
/ / = = = = = =
var statictext2 = window . add ( "statictext" , undefined , undefined , { name : "statictext2" } ) ;
statictext2 . text = "JSON Data" ;
var jsonData = window . add ( 'edittext {properties: {name: "jsonData", multiline: true, scrollable: true}}' ) ;
jsonData . preferredSize . width = 160 ;
jsonData . preferredSize . height = 48 ;
/ / G R O U P 2
/ / = = = = = =
var group2 = window . add ( "group" , undefined , { name : "group2" } ) ;
group2 . orientation = "row" ;
group2 . alignChildren = [ "left" , "center" ] ;
group2 . spacing = 10 ;
group2 . margins = 0 ;
var statictext3 = group2 . add ( "statictext" , undefined , undefined , { name : "statictext3" } ) ;
statictext3 . text = "Track Name" ;
var trackName = group2 . add ( "dropdownlist" , undefined , undefined , { name : "trackName" } ) ;
trackName . selection = 0 ;
trackName . preferredSize . width = 96 ;
/ / G R O U P 3
/ / = = = = = =
var group3 = window . add ( "group" , undefined , { name : "group3" } ) ;
group3 . orientation = "row" ;
group3 . alignChildren = [ "left" , "center" ] ;
group3 . spacing = 10 ;
group3 . margins = 0 ;
var statictext4 = group3 . add ( "statictext" , undefined , undefined , { name : "statictext4" } ) ;
statictext4 . text = "Frame Offset" ;
var frameOffset = group3 . add ( 'edittext {properties: {name: "frameOffset"}}' ) ;
frameOffset . text = "-2" ;
frameOffset . preferredSize . width = 32 ;
/ / W I N D O W
/ / = = = = = =
var runButton = window . add ( "button" , undefined , undefined , { name : "runButton" } ) ;
runButton . text = "Go!" ;
runButton . preferredSize . width = 64 ;
runButton . alignment = [ "center" , "center" ] ;
var aboutButton = window . add ( "button" , undefined , undefined , { name : "aboutButton" } ) ;
aboutButton . text = "?" ;
aboutButton . preferredSize . width = 24 ;
aboutButton . preferredSize . height = 24 ;
aboutButton . alignment = [ "right" , "center" ] ;
window . onResizing = window . onResize = function ( )
{
this . layout . resize ( ) ;
} ;
if ( window instanceof Window )
{
window . center ( ) ;
window . show ( ) ;
}
else
{
window . layout . layout ( true ) ;
window . layout . resize ( ) ;
}
fileOpener . addEventListener ( "mousedown" , function ( evt )
{
rppFile = ( new File ( ) ) . openDlg ( "Select .rpp file ..." , "*.rpp" , false ) ;
if ( rppFile != null )
{
if ( trackName . items . length > 0 )
{
trackName . removeAll ( ) ;
}
stdOut = system . callSystem ( "python \"Scripts\\ScriptUI Panels\\MMaker_RPPJSON.py\" \"" + rppFile . fsName + "\"" )
jsonData . text = stdOut ;
trackNames = getObjectKeys ( JSON . parse ( jsonData . text ) ) ;
for ( var i = 0 ; i < trackNames . length ; i ++ )
{
currentTrack = trackNames [ i ] ;
currentTrack = currentTrack . substring ( 1 ) ;
trackName . add ( "item" , currentTrack ) ;
}
}
} ) ;
runButton . addEventListener ( "mousedown" , function ( evt )
{
try
{
app . beginUndoGroup ( "Add markers" ) ;
var comp = app . project . activeItem ;
jsonParsed = JSON . parse ( jsonData . text ) ;
if ( trackName . selection != null )
{
flipItem = "!" + trackName . selection . text ;
}
else
{
alert ( "Please select a track." ) ;
return ;
}
if ( isNaN ( parseInt ( frameOffset . text ) ) )
{
alert ( "Please enter a valid number for the frame offset." ) ;
return ;
}
else
{
timeConst = parseInt ( frameOffset . text ) / ( 1 / comp . frameDuration ) ;
}
if ( typeof jsonParsed [ flipItem ] != 'undefined' )
{
for ( var i = 0 ; i < jsonParsed [ flipItem ] . length ; i ++ )
{
newMarker = new MarkerValue ( "" ) ;
marker _params = { } ;
newMarker . label = 0 ;
marker _params . label = newMarker . label ;
newMarker . setParameters ( marker _params ) ;
comp . markerProperty . setValueAtTime ( jsonParsed [ flipItem ] [ i ] + timeConst , newMarker ) ;
}
}
else
{
alert ( "Track does not exist!" ) ;
return ;
}
app . endUndoGroup ( ) ;
}
catch ( e )
{
alert ( e ) ;
}
} ) ;
aboutButton . addEventListener ( "mousedown" , function ( evt )
{
alert ( "Script by MMaker\nmmaker.moe" ) ;
} ) ;
}
/ / h t t p s : / / g i s t . g i t h u b . c o m / l t f s c h o e n / 7 9 a b 3 e 9 8 7 2 3 e 6 1 6 6 0 1 1 7
var getObjectKeys = function ( associativeArrayObject ) {
var arrayWithKeys = [ ] , associativeArrayObject ;
for ( key in associativeArrayObject ) {
/ / A v o i d r e t u r n i n g t h e s e k e y s f r o m t h e A s s o c i a t i v e A r r a y t h a t a r e s t o r e d i n i t f o r s o m e r e a s o n
if ( key !== undefined && key !== "toJSONString" && key !== "parseJSON" ) {
arrayWithKeys . push ( key ) ;
}
}
return arrayWithKeys ;
}
} ) ( this ) ;