// =========================================================================== // Copyright 2018 Autodesk, Inc. All rights reserved. // // Use of this software is subject to the terms of the Autodesk license // agreement provided at the time of installation or download, or which // otherwise accompanies this software in either electronic or hard copy form. // =========================================================================== // // // Creation Date: Nov 1999 // // Description: // This script builds the pulldown and popup menus for the TraX // editor. // // Input Arguments: // None. // // Return Value: // None. // // Note: // None. // global int $gCurrentCharacterState = 0; proc string [] getCliplistSchedulers(string $clipList[]) // Build up a concise list of schedulers for the provided clip list { string $schedulerList[]; int $numSchedulers = 0; string $clip; for ($clip in $clipList) { if (`nodeType $clip` != "animClip") continue; string $scheduler = getClipScheduler($clip); if ($scheduler == "") continue; if (stringArrayContains($scheduler, $schedulerList)) continue; $schedulerList[$numSchedulers] = $scheduler; $numSchedulers++; } return $schedulerList; } global proc copyClipChannelOffsets() { string $clips[] = `ls -selection -type animClip`; int $numClips = size($clips); if ($numClips < 2) { error (uiRes("m_ClipEdMenu.kSelSrcDestClips")); } string $ch1[] = `clip -query -character $clips[0]`; int $ii; for ($ii = 1; $ii < $numClips; $ii++) { string $ch2[] = `clip -query -character $clips[$ii]`; if ($ch1[0] == $ch2[0]) { copyAbsoluteChannelsClipData($clips[$ii], $clips[0]); } else { string $warnFormat = (uiRes("m_ClipEdMenu.kWarnClipsDiffChars")); warning `format -stringArg $clips[0] -stringArg $clips[$ii] $warnFormat`; } } } proc int validateClipSelection(string $schedulerList[], string $clipList[]) { int $clipListValid = true; string $scheduler; for ($scheduler in $schedulerList) { string $blendDataList[] = `clipSchedule -query -blend $scheduler`; string $blendData; for ($blendData in $blendDataList) { string $valList[]; tokenize $blendData "," $valList; int $clip1 = $valList[2]; int $clip2 = $valList[3]; string $clipName1 = `clipSchedule -clipIndex $clip1 -query -name $scheduler`; string $clipName2 = `clipSchedule -clipIndex $clip2 -query -name $scheduler`; // We should either have both of the clips for a blend in our // selection list or neither of them int $clip1Selected = stringArrayContains($clipName1, $clipList); if (stringArrayContains($clipName2, $clipList) != $clip1Selected) { $clipListValid = false; break; } } } return $clipListValid; } proc updateCharacterSummary (string $clipList[], int $add) { if (0 == size($clipList)) { if ($add) { error (uiRes("m_ClipEdMenu.kSelClipsToGroup")); } else { error (uiRes("m_ClipEdMenu.kSelClipsToUnGroup")); } } string $schedulerList[] = getCliplistSchedulers($clipList); int $numSchedulers = size($schedulerList); // Create clipSchedule commands for each scheduler // string $commandList[]; int $numCommands = 0; for ($scheduler in $schedulerList) { $commandList[$numCommands] = "clipSchedule -group " + $add; $numCommands++; } // Append clip information to the clipSchedule commands // for ($clip in $clipList) { if (`nodeType $clip` != "animClip") { continue; } string $scheduler = getClipScheduler ($clip); if ($scheduler == "") { continue; } int $index = stringArrayFind( $scheduler, 0, $schedulerList ); if ($index == -1) { continue; } $commandList[$index] = $commandList[$index] + " -groupIndex " + getClipIndex ($clip, $scheduler); } // Finalize the clipSchedule commands for each scheduler // $numCommands = 0; for ($scheduler in $schedulerList) { $commandList[$numCommands] = $commandList[$numCommands] + " " + $scheduler; eval $commandList[$numCommands]; $numCommands++; } } global proc createCharacterSummary (string $clipList[]) { if (size($clipList) == 0) { $clipList = getSelectedClips("noOptions"); } updateCharacterSummary ($clipList, true); } global proc removeFromCharacterSummary (string $clipList[]) { if (size($clipList) == 0) { $clipList = getSelectedClips("noOptions"); } updateCharacterSummary ($clipList, false); } global proc createCharacterQuickSelect () // // Procedure Name: // defineCharacter // // Description: // Creates a set using the selected items, // so that users can define all the nodes // in the DAG that make up their "characters". // // Input Arguments: // None. // // Return Value: // None. { // Prompt the user for a new character name // string $OK = (uiRes("m_ClipEdMenu.kOKButton")); string $cancel = (uiRes("m_ClipEdMenu.kCancelButton")); string $result = `promptDialog -title (uiRes("m_ClipEdMenu.kCreateCharQuickSel")) -message (uiRes("m_ClipEdMenu.kCreateCharQuickSelMsg")) -text "Set" -button $OK -button $cancel -defaultButton $OK -cancelButton $cancel -dismissString $cancel`; // If the result was "OK", then proceed // if ( $result == $OK ) { // Also, notice that the `type` is being set // to "clipSelectSet" - just trying to pick // a name that users probably won't type // string $characterName = `promptDialog -q`; string $newName = `sets -text "clipSelectSet" -name $characterName`; string $resultStr = (uiRes("m_ClipEdMenu.kCreatedQuickSet")); string $infoStr = `format -stringArg $newName $resultStr`; print $infoStr; } } global proc createQuickClipMenu( string $parent ) // // Creates entries in the "Select Character" subMenu // in the Edit Menu. { setParent -menu $parent; menu -edit -deleteAllItems $parent; // Get a list of all character sets in the // system, then generate an entry per set // string $charSets[] = `ls -sets`; for( $character in $charSets ) { if( `sets -query -text $character` == "clipSelectSet" ) { menuItem -label $character -command ( "select -replace " + $character ); } } if( `menu -query -numberOfItems $parent` == 0 ) // // No characters defined - create a default menu item // to inform the user { menuItem -label (uiRes("m_ClipEdMenu.kNoQucikSel")) -enable false; } } global proc selectTraxCharacter (string $clipN[]) { string $sch = getClipScheduler($clipN[0]); int $clipIndex = getClipIndex($clipN[0], $sch); string $charNodeName[] = `clipSchedule -clipIndex $clipIndex -query -character $sch`; select -cl; selectNodesInCharacter( $charNodeName[0] ); } global proc selectCacheGeometry(string $clipName) { string $geom[]; if (size($clipName) == 0) { string $selCache[] = `ls -sl -type cacheFile`; if (size($selCache) == 0) { error((uiRes("m_ClipEdMenu.kMustSelectCacheClip"))); } $geom = `cacheFile -q -geometry`; } else { $geom = `cacheFile -q -geometry $clipName`; } select -add $geom; } global proc traxTrim (int $which, string $selected[]) // // Trim the selected clips in the editor. // If $which == 0, trim before. Else, trim after. // { int $nclips = size($selected); string $selCacheClips[]; string $selClips[]; if ($nclips == 0) { $selClips = getSelectedClips("allowCache"); $selCacheClips = `ls -sl -type cacheFile`; if (0 == size($selClips)&& 0 == size($selCacheClips) ) { error (uiRes("m_ClipEdMenu.kSelClipToTrim")); } } else { for ($clip in $selected) { if (nodeType($clip) == "cacheFile") { $selCacheClips[size($selCacheClips)] = $clip; } else { $selClips[size($selClips)] = $clip; } } } string $clip; for ($clip in $selClips) { string $sch = getClipScheduler($clip); int $clipIndex = getClipIndex($clip, $sch); if ($which == 0) { clipTrimBefore($sch, $clipIndex); } else { clipTrimAfter($sch, $clipIndex); } } float $time = `currentTime -q`; for( $cacheClip in $selCacheClips) { if ($which == 0) { cacheClipTrimBefore($cacheClip,$time); } else { cacheClipTrimAfter($cacheClip,$time); } } } global proc buildClipEditorFileMenu (string $editor, string $parent) { setParent -menu $parent; if (`menu -query -numberOfItems $parent` != 0) return; menuItem -label (uiRes("m_ClipEdMenu.kImportClip")) -annotation (uiRes("m_ClipEdMenu.kImportClipAnnot")) -command ("doImportClipArgList(\"4\",{\"0\",\"0\"})") openClipItem; menuItem -label (uiRes("m_ClipEdMenu.kFileImportClipToChar")) -annotation (uiRes("m_ClipEdMenu.kFileImportClipToCharAnnot")) -command ("performImportClipToChar 0") -dragMenuCommand ("performImportClipToChar 2") openClipToCharItem; menuItem -optionBox true -annotation (uiRes("m_ClipEdMenu.kImportClipCharOptAnnot")) -command ("performImportClipToChar 1") openClipToCharOBItem; menuItem -label (uiRes("m_ClipEdMenu.kImportAudio")) -annotation (uiRes("m_ClipEdMenu.kImportAudioAnnot")) -command ("optionVar -stringValue defaultFileImportType \"audio\";Import") importAudioFileItem; menuItem -optionBox true -annotation (uiRes("m_ClipEdMenu.kImportAudioOptAnnot")) -command ("optionVar -stringValue defaultFileImportType \"audio\";ImportOptions") importAudioFileOptions; menuItem -l (uiRes("m_ClipEdMenu.kImportGeomCache")) -annotation (getRunTimeCommandAnnotation("attachGeometryCache")) -c "attachGeometryCache" attachGeometryCacheItem; string $exportEdCmd = ("doExportClipArgList 1 {\\\""+$editor+"\\\"}"); menuItem -label (uiRes("m_ClipEdMenu.kExportClip")) -annotation (uiRes("m_ClipEdMenu.kExportClipAnnot")) -command ("evalEcho(\""+$exportEdCmd+"\")") SaveClipItem; menuItem -label (uiRes("m_ClipEdMenu.kCharMapper")) -annotation (uiRes("m_ClipEdMenu.kCharMapperAnnot")) -command "optionVar -intValue MClabels 0; mapcharWindow"; menuItem -label (uiRes("m_ClipEdMenu.kExportCharMap")) -annotation (uiRes("m_ClipEdMenu.kExportCharMapAnnot")) -dragMenuCommand ("performExportCharacterMap 2") -command ("performExportCharacterMap 0") SaveCharacterMapItem; menuItem -optionBox true -annotation (uiRes("m_ClipEdMenu.kExportCharMapOptAnnot")) -command ("performExportCharacterMap 1") SaveCharacterMapDialogItem; menuItem -divider true; string $clipTabName = (uiRes("m_ClipEdMenu.kCharacterClips")); menuItem -label (uiRes("m_ClipEdMenu.kVisor")) -enable 1 -annotation (uiRes("m_ClipEdMenu.kVisorAnnot")) -command ("{VisorWindow; string $pnl=visorPanelName();if(size($pnl)>0) visorPanelMenuCommand( $pnl, \"selectOrCreateTabByLabel "+$clipTabName+"\");}") //-dragMenuCommand("foo") openLibClipItem; } global proc buildClipEditorCreateMenu (string $editor, string $parent) { setParent -menu $parent; if (`menu -query -numberOfItems $parent` != 0) return; menuItem -label (uiRes("m_ClipEdMenu.kCreateClip")) -annotation (uiRes("m_ClipEdMenu.kCreateClipAnnot")) -command ("CreateClip; doReload " + $editor) -dragMenuCommand("performCreateClip 2") createClipItem; string $cmd = "CreateClipOptions"; menuItem -optionBox true -annotation (getRunTimeCommandAnnotation($cmd)) -command $cmd createClipDialogItem; menuItem -label (uiRes("m_ClipEdMenu.kConstraintClip")) -annotation (uiRes("m_ClipEdMenu.kConstraintClipAnnot")) -command ("CreateConstraintClip; doReload " + $editor) -dragMenuCommand("performCreateConstraintClip 2") createConstraintClipItem; $cmd = "CreateConstraintClipOptions"; menuItem -optionBox true -annotation (getRunTimeCommandAnnotation($cmd)) -command $cmd createConstraintClipDialogItem; menuItem -label (uiRes("m_ClipEdMenu.kExprClip")) -annotation (uiRes("m_ClipEdMenu.kExprClipAnnot")) -command ("CreateExpressionClip; doReload " + $editor) -dragMenuCommand("performCreateExpClip 2") createExpressionClipItem; $cmd = "CreateExpressionClipOptions"; menuItem -optionBox true -annotation (getRunTimeCommandAnnotation($cmd)) -command $cmd createExpressionClipDialogItem; menuItem -label (uiRes("m_ClipEdMenu.kPose")) -annotation (uiRes("m_ClipEdMenu.kPoseAnnot")) -command ("performCreatePose 0") -dragMenuCommand("performCreatePose 2") createPoseItem; menuItem -optionBox true -annotation (uiRes("m_ClipEdMenu.kPoseOptAnnot")) -command ("performCreatePose 1") createPoseDialogItem; menuItem -label (uiRes("m_ClipEdMenu.kCreateBlend")) -annotation (uiRes("m_ClipEdMenu.kCreateBlendAnnot")) -command ("performBlendClip 0 " + $editor) -dragMenuCommand("performBlendClip 2 " + $editor) blendClipsItem; menuItem -optionBox true -annotation (uiRes("m_ClipEdMenu.kCreateBlendOptAnnot")) -command ("performBlendClip 1 " + $editor) blendClipsDialogItem; $cmd = "CreateCharacter"; menuItem -label (uiRes("m_ClipEdMenu.kCharSet")) -annotation (getRunTimeCommandAnnotation($cmd)) -command $cmd -dragMenuCommand "performCreateCharacter 2" createCharacterItem; menuItem -optionBox true -annotation (uiRes("m_ClipEdMenu.kCharSetOptAnnot")) -command "performCreateCharacter 1" createCharacterDialogItem; menuItem -label (uiRes("m_ClipEdMenu.kTimeWarp")) -annotation (uiRes("m_ClipEdMenu.kTimeWarpAnnot")) -command ("performCreateClipTimeWarp 0 " + $editor) -dragMenuCommand ("performCreateClipTimeWarp 2" + $editor) createClipTimeWarpItem; menuItem -optionBox true -annotation (uiRes("m_ClipEdMenu.kTimeWarpOptAnnot")) -command ("performCreateClipTimeWarp 1 " + $editor) createClipTimeWarpDialogItem; menuItem -label (uiRes("m_ClipEdMenu.kQuickSelSet")) -annotation (uiRes("m_ClipEdMenu.kQuickSelSetAnnot")) -command ("createCharacterQuickSelect") -dragMenuCommand ("createCharacterQuickSelect") createClipQuickSelectSetItem; menuItem -l (uiRes("m_ClipEdMenu.kCreateCache")) -annotation (getRunTimeCommandAnnotation("geometryCache")) -c "geometryCache" -dmc "performCreateGeometryCache 2 \"add\"" geometryCacheItem; menuItem -optionBox true -annotation (getRunTimeCommandAnnotation("geometryCacheOpt")) -c "geometryCacheOpt" geometryCacheOptItem; } global proc buildClipEditorEditMenu (string $editor, string $parent) { int $dimWhenNoSelect = 0; setParent -menu $parent; if (`menu -query -numberOfItems $parent` != 0) return; string $cmd = "Undo"; menuItem -label (uiRes("m_ClipEdMenu.kUndo")) -enableCommandRepeat false -annotation (getRunTimeCommandAnnotation($cmd)) -command ($cmd) undoItem; if( $dimWhenNoSelect ) dimWhen -false "UndoAvailable" ($parent+"|undoItem"); $cmd = "Redo"; menuItem -label (uiRes("m_ClipEdMenu.kRedo")) -enableCommandRepeat false -annotation (getRunTimeCommandAnnotation($cmd)) -command ($cmd) redoItem; if( $dimWhenNoSelect ) dimWhen -false "RedoAvailable" ($parent+"|redoItem"); menuItem -divider true; string $removeCmd = "doCutClipArgList 1 { \""+ $editor+"\" }"; menuItem -label (uiRes("m_ClipEdMenu.kCut")) -annotation (uiRes("m_ClipEdMenu.kCutAnnot")) -command $removeCmd -dragMenuCommand $removeCmd; string $copyCmd = "doCopyClipArgList 1 { \""+ $editor+"\" }"; menuItem -label (uiRes("m_ClipEdMenu.kCopy")) -annotation (uiRes("m_ClipEdMenu.kCopyAnnot")) -command $copyCmd -dragMenuCommand $copyCmd; menuItem -label (uiRes("m_ClipEdMenu.kPaste")) -annotation (uiRes("m_ClipEdMenu.kPasteAnnot")) -command ("performPasteClip 0") -dragMenuCommand ("performPasteClip 2"); menuItem -optionBox true -annotation (uiRes("m_ClipEdMenu.kPasteClipOptAnnot")) -command ("performPasteClip 1") pasteClipDialogItem; menuItem -divider true; string $splitString = ("performSplitClip 1 \\\""+$editor+"\\\""); string $splitCmd = ("evalEcho(\""+$splitString+"\")"); menuItem -label (uiRes("m_ClipEdMenu.kSplit")) -annotation (uiRes("m_ClipEdMenu.kSplitAnnot")) -command ("performSplitClip 0 "+$editor) splitClipItem; menuItem -optionBox true -annotation (uiRes("m_ClipEdMenu.kSplitOptAnnot")) -command $splitCmd splitClipDialogItem; menuItem -label (uiRes("m_ClipEdMenu.kEditMerge")) -annotation (uiRes("m_ClipEdMenu.kEditMergeAnnot")) -command ("performBakeClip 0 " + $editor) -dragMenuCommand("performBakeClip 2 " + $editor) bakeClipsItem; menuItem -optionBox true -annotation (uiRes("m_ClipEdMenu.kEditMergeOptAnnot")) -command ("performBakeClip 1 " + $editor) bakeClipsDialogItem; menuItem -label (uiRes("m_ClipEdMenu.kEditMergeCache")) -annotation (uiRes("m_ClipEdMenu.kEditMergeCacheAnnot")) -command ("performMergeCacheClip 0 " + $editor) -dragMenuCommand("performMergeCacheClip 2 " + $editor) mergeCacheClipsItem; menuItem -optionBox true -annotation (uiRes("m_ClipEdMenu.kEditMergeCacheOptAnnot")) -command ("performMergeCacheClip 1 " + $editor) mergeCacheClipsDialogItem; menuItem -divider true; menuItem -label (uiRes("m_ClipEdMenu.kEditTrimBefore")) -annotation (uiRes("m_ClipEdMenu.kEditTrimBeforeAnnot")) -image "trimBefore.png" -command ("traxTrim 0 {}"); menuItem -label (uiRes("m_ClipEdMenu.kEditTrimAfter")) -image "trimAfter.png" -annotation (uiRes("m_ClipEdMenu.kEditTrimAfterAnnot")) -command ("traxTrim 1 {}"); menuItem -divider true; string $duplicateCmd = "performDuplicateClip( 0, \"\")"; string $duplicateDragCmd = "performDuplicateClip( 2, \"\")"; string $duplicateOptionCmd = "performDuplicateClip( 1, \"\")"; menuItem -label (uiRes("m_ClipEdMenu.kDuplicate")) -annotation (uiRes("m_ClipEdMenu.kDuplicateAnnot")) -command $duplicateCmd -dragMenuCommand $duplicateDragCmd duplicateClipItem; menuItem -optionBox true -annotation (uiRes("m_ClipEdMenu.kDupClipOptAnnot")) -command $duplicateOptionCmd duplicateClipDialogItem; menuItem -label (uiRes("m_ClipEdMenu.kCopyChannelOffsets")) -annotation (uiRes("m_ClipEdMenu.kCopyChannelOffsetsAnnot")) -command "copyClipChannelOffsets" copyChannelOffsetsItem; menuItem -divider true; string $menu = `menuItem -label (uiRes("m_ClipEdMenu.kQuickSelectSets")) -subMenu true selectClipItem`; menuItem -edit -postMenuCommand ( "createQuickClipMenu " + $menu ) $menu; setParent -menu ..; menuItem -label (uiRes("m_ClipEdMenu.kEditGroup")) -annotation (uiRes("m_ClipEdMenu.kEditGroupAnnot")) -command ("createCharacterSummary {}") -dragMenuCommand ("createCharacterSummary {}") groupClipItem; menuItem -label (uiRes("m_ClipEdMenu.kEditUngroup")) -annotation (uiRes("m_ClipEdMenu.kEditUngroupAnnot")) -command ("removeFromCharacterSummary {}") -dragMenuCommand ("removeFromCharacterSummary {}`") ungroupClipItem; menuItem -divider true; menuItem -label ( (uiRes("m_ClipEdMenu.kSetHierarchyRoot")) ) -annotation ( (uiRes("m_ClipEdMenu.kSetHierarchyRootAnnot")) ) -command ( "performSetOffsetObject; performSetHierarchyRoot; " ) ; } global proc buildClipEditorLibraryMenu (string $editor, string $parent) { int $dimWhenNoSelect = 0; setParent -menu $parent; if (`menu -query -numberOfItems $parent` != 0) return; menuItem -label (uiRes("m_ClipEdMenu.kInsertClip")) -annotation (uiRes("m_ClipEdMenu.kInsertClipAnnot")) -subMenu true insertLibraryClipItem; menu -edit -postMenuCommand "createClipLibraryMenu clip insertLibraryClipItem" insertLibraryClipItem; setParent -menu ..; menuItem -label (uiRes("m_ClipEdMenu.kInsertPose")) -annotation (uiRes("m_ClipEdMenu.kInsertPoseAnnot")) -subMenu true insertLibraryPoseItem; menu -edit -postMenuCommand "createClipLibraryMenu pose insertLibraryPoseItem" insertLibraryPoseItem; setParent -menu ..; } global proc frameTimelineRange (string $editor) { float $start, $end; $start = `playbackOptions -query -min`; $end = `playbackOptions -query -max`; clipEditor -edit -frameRange $start $end $editor; } global proc frameAllSceneClips( string $editor ) { string $selected[] = `ls -sl`; select -cl; toggleAutoLoad $editor true; optionVar -intValue traxAutoLoadSel 1; string $characters[] = `ls -type "character"`; for ( $character in $characters ) { string $scheduler = `character -q -sc $character`; if ( size( $scheduler ) > 0 ) { string $clips[] = `clipSchedule -q -n $scheduler`; if( size( $clips ) > 0 ) { select -add $character; } } } toggleAutoLoad $editor false; optionVar -intValue traxAutoLoadSel 0; select $selected; } global proc selectSourceClip(string $selectedClips[]) { string $sourceClips; for ($clip in $selectedClips) { string $sch = getClipScheduler($clip); int $clipIndex = getClipIndex($clip, $sch); string $clipName = `clipSchedule -clipIndex $clipIndex -query -name $sch`; string $sourceClip = `clip -query -sourceClipName $clipName`; $sourceClips += ($sourceClip+" "); } string $cmd = ("select -replace "+$sourceClips); evalEcho $cmd; } // // This method is called from the clipEditor command when the display // state of the editor changes. // global proc setCurrentCharacterList (string $editor, int $state) { global int $gCurrentCharacterState; string $popupMenuName = ($editor + "PopupMenu"); string $currentListItem = ($editor + "currentListItem"); // If the menu has not been created, do nothing. if (!`popupMenu -exists $popupMenuName`) return; // Set the menuItem state. if (`menuItem -exists $currentListItem`) { menuItem -edit -checkBox $state $currentListItem; $gCurrentCharacterState = $state; } } // // This method is called from the menu item when the "List Current Characters" // item is selected. // global proc toggleCurrentCharacterList (string $curMenuItem, string $editor) { if (`menuItem -query -checkBox $curMenuItem`) clipEditor -edit -listCurrentCharacters $editor; else clipEditor -edit -listAllCharacters $editor; } global proc buildClipEditorViewMenu (string $editor, string $parent) { global int $gCurrentCharacterState; setParent -menu $parent; // Make sure the current character toggle is up to date. if (`menu -query -numberOfItems $parent` != 0) { setCurrentCharacterList($editor, $gCurrentCharacterState); return; } menuItem -label (uiRes("m_ClipEdMenu.kFrameAll")) -enable 1 -annotation (uiRes("m_ClipEdMenu.kFrameAllAnnot")) -command ("FrameAll") frameAllItem; menuItem -label (uiRes("m_ClipEdMenu.kFrameSelection")) -annotation (uiRes("m_ClipEdMenu.kFrameSelectionAnnot")) -command ("FrameSelected"); menuItem -label (uiRes("m_ClipEdMenu.kFramePlayback")) -enable 1 -annotation (uiRes("m_ClipEdMenu.kFramePlaybackAnnot")) -command ("frameTimelineRange " + $editor) frameTimelineItem; menuItem -label (uiRes("m_ClipEdMenu.kCenterCurrentTime")) -annotation (uiRes("m_ClipEdMenu.kCenterCurrentTimeAnnot")) -command ("clipEditor -edit -lookAt currentTime " + $editor); menuItem -label (uiRes("m_ClipEdMenu.kFrameAllSceneClips")) -enable 1 -annotation (uiRes("m_ClipEdMenu.kFrameAllClipsAnnot")) -command ("frameAllSceneClips " + $editor + "; FrameAll;"); menuItem -divider true; menuItem -label (uiRes("m_ClipEdMenu.kGraphAnimCurves")) -enable 1 -annotation (uiRes("m_ClipEdMenu.kGraphAnimCurvesAnnot")) -command ("clipGraphEditor "+$editor) graphCurvesClipItem; } global proc buildClipEditorClipMenu (string $editor, string $parent) { setParent -menu $parent; if (`menu -query -numberOfItems $parent` != 0) return; string $attrEditorMenuItemName = `format -s (localizedUIComponentLabel("Attribute Editor")) (uiRes("m_ClipEdMenu.kAttrEditorMenuItemFormat"))`; menuItem -label $attrEditorMenuItemName -annotation (uiRes("m_ClipEdMenu.kClipAttrEdAnnot")) -command ("openAEWindow") -dragMenuCommand ("openAEWindow") clipPropItem; menuItem -divider true; string $enableCmd = "doEnableClipArgList 2 { \"2\", \"1\" }"; menuItem -label (uiRes("m_ClipEdMenu.kEnableDisblae")) -annotation (uiRes("m_ClipEdMenu.kEnableDisableAnnot")) -command $enableCmd -dragMenuCommand $enableCmd enableClipItem; string $activateCmd = "doActivateClipArgList 1 { \""+ $editor+"\",\"2\"}"; menuItem -label (uiRes("m_ClipEdMenu.kActDeactKeys")) -annotation (uiRes("m_ClipEdMenu.kActDeactKeysAnnot")) -command $activateCmd -dragMenuCommand $activateCmd activateClipItem; menuItem -divider true; menuItem -label (uiRes("m_ClipEdMenu.kRemEmptyTracks")) -annotation (uiRes("m_ClipEdMenu.kRemEmptyTracksAnnot")) -command ("removeEmptyTracks " + $editor) removeTrackItem; menuItem -divider true; menuItem -label (uiRes("m_ClipEdMenu.kMatchClips")) -annotation (uiRes("m_ClipEdMenu.kMatchClipsAnnot")) -command ( "performMatchClip 0" ) -dragMenuCommand ( "performMatchClip 0" ) matchClipsItem; menuItem -optionBox true -annotation (uiRes("m_ClipEdMenu.kMatchClipsOptAnnot")) -command ( "performMatchClip 1" ) matchClipsDialogItem; } global proc buildClipMainPopupMenuItems(string $editor, string $menuName, string $collectionName) { setParent -menu $menuName; if (`menu -query -numberOfItems $menuName` != 0) return; string $menuItem = `menuItem -label (uiRes("m_ClipEdMenu.kFile")) -subMenu true -allowOptionBoxes true FileCascade`; menuItem -edit -postMenuCommand ("buildClipEditorFileMenu " + $editor + " " + $menuItem) $menuItem; setParent -menu ..; $menuItem = `menuItem -label (uiRes("m_ClipEdMenu.kEdit")) -subMenu true -allowOptionBoxes true EditCascade`; menuItem -edit -postMenuCommand ("buildClipEditorEditMenu " + $editor + " " + $menuItem) $menuItem; setParent -menu ..; $menuItem = `menuItem -label (uiRes("m_ClipEdMenu.kView")) -subMenu true -allowOptionBoxes true ViewCascade`; menuItem -edit -postMenuCommand ("buildClipEditorViewMenu " + $editor + " " + $menuItem) $menuItem; setParent -menu ..; $menuItem = `menuItem -label (uiRes("m_ClipEdMenu.kModify")) -subMenu true -allowOptionBoxes true ModifyCascade`; menuItem -edit -postMenuCommand ("buildClipEditorClipMenu " + $editor + " " + $menuItem) $menuItem; setParent -menu ..; $menuItem = `menuItem -label (uiRes("m_ClipEdMenu.kCreate")) -subMenu true -allowOptionBoxes true CreateCascade`; menuItem -edit -postMenuCommand ("buildClipEditorCreateMenu " + $editor + " " + $menuItem) $menuItem; setParent -menu ..; $menuItem = `menuItem -label (uiRes("m_ClipEdMenu.kLibrary")) -subMenu true -allowOptionBoxes true LibraryCascade`; menuItem -edit -postMenuCommand ("buildClipEditorLibraryMenu " + $editor + " " + $menuItem) $menuItem; setParent -menu ..; $menuItem = `menuItem -label (uiRes("m_ClipEdMenu.kList")) -allowOptionBoxes false -subMenu true -tearOff true ListCascade`; defineListMenu "useCharacters" $editor $editor $menuItem ""; setParent -menu ..; } global proc buildClipEditorMenu(string $editor, string $parent, string $collectionName) { string $menu = `menu -label (uiRes("m_ClipEdMenu.kFileMenu")) -tearOff true -familyImage "menuIconEdit.png" -allowOptionBoxes true`; menu -edit -postMenuCommand ("buildClipEditorFileMenu " + $editor + " " + $menu) $menu; setParent -menu ..; $menu = `menu -label (uiRes("m_ClipEdMenu.kEditMenu")) -tearOff true -familyImage "menuIconEdit.png" -allowOptionBoxes true`; menu -edit -postMenuCommand ("buildClipEditorEditMenu " + $editor + " " + $menu) $menu; setParent -menu ..; $menu = `menu -label (uiRes("m_ClipEdMenu.kViewMenu")) -tearOff true -allowOptionBoxes true -familyImage "menuIconEdit.png"`; menu -edit -postMenuCommand ("buildClipEditorViewMenu " + $editor + " " + $menu) $menu; setParent -menu ..; $menu = `menu -label (uiRes("m_ClipEdMenu.kModifyMenu")) -tearOff true -allowOptionBoxes true -familyImage "menuIconEdit.png"`; menu -edit -postMenuCommand ("buildClipEditorClipMenu " + $editor + " " + $menu) $menu; setParent -menu ..; $menu = `menu -label (uiRes("m_ClipEdMenu.kCreateMenu")) -tearOff true -allowOptionBoxes true -familyImage "menuIconEdit.png"`; menu -edit -postMenuCommand ("buildClipEditorCreateMenu " + $editor + " " + $menu) $menu; setParent -menu ..; $menu = `menu -label (uiRes("m_ClipEdMenu.kLibraryMenu")) -tearOff true -familyImage "menuIconEdit.png" -allowOptionBoxes true`; menu -edit -postMenuCommand ("buildClipEditorLibraryMenu " + $editor + " " + $menu) $menu; setParent -menu ..; $menuItem = `menu -label (uiRes("m_ClipEdMenu.kListMenu")) -tearOff true -familyImage "menuIconOptions.png"`; defineListMenu "useCharacters" $editor $editor $menuItem ""; setParent -menu ..; } global proc buildTrackMenuItems(string $editor, string $menu, string $menuContext[]) { setParent -menu $menu; string $clipClipboard[]; string $character = $menuContext[2]; string $toTrack = $menuContext[1]; string $toGroup = $menuContext[3]; string $pasteCmd = "doPasteClipArgList 5 {\"byMapOrAttrName\", \"currentTime\", \"" + $character + "\", \"0\", \"\", \"" + $toTrack + "\", \"" + $toGroup + "\"}"; string $importCmd = "doImportClipArgList 5 {\"1\", \"1\", \"" + $character + "\", \"" + $toTrack + "\", \"" + $toGroup + "\"}"; int $enablePaste = 0; int $enableImport = 0; if (size($character)) { $clipClipboard = `clip -query -copy $character`; $enablePaste = (size($clipClipboard) > 0); $enableImport = 1; menuItem -label (uiRes("m_ClipEdMenu.kPasteClip")) -enable $enablePaste -annotation (uiRes("m_ClipEdMenu.kPasteClipAnnot")) -command $pasteCmd -dragMenuCommand $pasteCmd; menuItem -label (uiRes("m_ClipEdMenu.kImportClipToChar")) -enable $enableImport -annotation (uiRes("m_ClipEdMenu.kImportClipToCharAnnot")) -command $importCmd; string $scheduler; $scheduler = `character -query -scheduler $character`; if( $scheduler != "" ) { int $trackNumber = $toTrack; // If the trackNumber is not at least one, we clicked on a header. if( $trackNumber >= 1 ) { menuItem -label (uiRes("m_ClipEdMenu.kInsertTrackAbove")) -annotation (uiRes("m_ClipEdMenu.kInsertTrackAboveAnnot")) -command ("clipSchedule -insertTrack " + $trackNumber + " " + $scheduler); menuItem -label (uiRes("m_ClipEdMenu.kInsertTrackBelow")) -annotation (uiRes("m_ClipEdMenu.kInsertTrackBelowAnnot")) -command ("clipSchedule -insertTrack " + ( $trackNumber + 1 ) + " " + $scheduler); int $locked = `clipSchedule -track $trackNumber -query -lock $scheduler`; menuItem -label (uiRes("m_ClipEdMenu.kRemTrack")) -annotation (uiRes("m_ClipEdMenu.kRemTrackAnnot")) -enable (!$locked) -command ("clearAndRemoveTrack " + $trackNumber + " " + $scheduler); } } } } proc int isTrackModifiable( string $clip ) { string $ch[] = `clip -query -character $clip`; // Determine if the clip is on a locked track string $clipScheduler = `character -query -scheduler $ch[0]`; int $clipIndex = `clipSchedule -name $clip -query -clipIndex $clipScheduler`; int $trackNumber = `clipSchedule -clipIndex $clipIndex -query -track $clipScheduler`; int $locked = `clipSchedule -track $trackNumber -query -lock $clipScheduler`; return !$locked; } proc int selectionCanBeMerged(string $selClips[]) { int $selClipCount = size($selClips); if ($selClipCount > 1) { return 1; } if ($selClipCount == 1) { // is there a pre or post cycle? // float $preCycle = `getAttr ($selClips[0]+".preCycle")`; float $postCycle = `getAttr ($selClips[0]+".postCycle")`; if ($preCycle > 0 || $postCycle > 0) { return 1; } } return 0; } proc int selectionCanBeBlended(string $selClips[]) { int $selClipCount = size($selClips); if ($selClipCount == 2) { return 1; } return 0; } proc int characterHasOffsetObject( string $clip ) { string $scheduler = getClipScheduler( $clip ); if ( size( $scheduler ) == 0 ) return false; string $chars[] = `clipSchedule -q -character $scheduler`; return ( size( $chars ) && size( `character -q -aoo $chars[0]` ) ) ? true : false; } global proc clipUpdatePivots( string $clip ) { // Ensure the startFrame is correct and recompute the clip's startPosition string $sched = getClipScheduler( $clip ); for ( $c in `clipSchedule -q -name $sched` ) { string $name = ( $c + ".startFrame" ); setAttr $name `getAttr $name`; } } global proc buildClipMenuItems(string $editor, string $menu, string $clip) { setParent -menu $menu; // Determine the status of the clip: enable, relative, active // // Determine the status of the selected clips: enable, relative, active // int $ii; int $absState = 0; // 0 == all relative, 1 == all absolute, 2 == mixed int $enableState = 0; // 0 == all off, 1 == all on, 2 == mixed int $activeState = 0; // 0 == all inactive, 1 == all active, 2 == mixed string $selClips[] = getSelectedClips("allowCache"); if (AWNumberOfOccurrencesInStringArray($clip,$selClips) == 0) { if (nodeType($clip) == "animClip") { $selClips[size($selClips)] = $clip; } } if (size($selClips) == 0) { buildCacheClipMenuItems($editor,$menu,$clip); return; } string $selClipsAsString; for ($ii = 0; $ii < size($selClips); $ii++) { string $clipName = $selClips[$ii]; if ($ii > 0) { $selClipsAsString += (", "); } $selClipsAsString += ("\""+$clipName+"\""); string $ch[] = `clip -query -character $clipName`; if ($ii == 0) { $absState = getClipAbsState($clipName); $enableState = (0 == `getAttr ($clipName+".enable")`); if (size($ch)) { string $activeClip = `clip -query -active $ch[0]`; string $sourceClip = `clip -query -sourceClipName $clipName`; $activeState = ($activeClip != $sourceClip); } } else { if ($enableState == `getAttr ($clipName+".enable")`) { $enableState = 2; } if ($absState != getClipAbsState($clipName)) { $absState = 2; } if (size($ch)) { string $activeClip = `clip -query -active $ch[0]`; string $sourceClip = `clip -query -sourceClipName $clipName`; int $currActive = ($activeClip == $sourceClip); if ($activeState == $currActive) { $activeState = 2; } } } } int $modifyable = isTrackModifiable( $clip ); string $toggleEnableCmd = "doEnableClipArgList 2 {\""+$enableState+"\", \"1\", \"" + $clip + "\"}"; menuItem -label (uiRes("m_ClipEdMenu.kEnableClip")) -checkBox ($enableState == 0) -enable ($enableState != 2 && $modifyable) -annotation (uiRes("m_ClipEdMenu.kEnableClipAnnot")) -command $toggleEnableCmd -dragMenuCommand $toggleEnableCmd toggleEnableClipItem; if ($absState != 2 || (0 == $modifyable) || size($selClips) != 1) { int $newAbsState = ($absState == 0); string $toggleOffsetCmd = "toggleClipOffset 2 {\""+$newAbsState+"\", \"1\", \"" + $clip + "\"}"; menuItem -label (uiRes("m_ClipEdMenu.kRelativeClip")) -checkBox ($absState == 0) -enable ($absState != 2 && $modifyable) -annotation (uiRes("m_ClipEdMenu.kRelativeClipAnnot")) -command $toggleOffsetCmd -dragMenuCommand $toggleOffsetCmd toggleOffsetClipItem; } else { string $allRelativeCmd = "toggleClipOffset 2 {\"0\", \"1\", \"" + $clip + "\"}"; string $allAbsoluteCmd = "toggleClipOffset 2 {\"1\", \"1\", \"" + $clip + "\"}"; menuItem -label (uiRes("m_ClipEdMenu.kAllRelativeClip")) -annotation (uiRes("m_ClipEdMenu.kAllRelativeClipAnnot")) -command $allRelativeCmd -dragMenuCommand $allRelativeCmd; menuItem -label (uiRes("m_ClipEdMenu.kAllAbsoluteClip")) -annotation (uiRes("m_ClipEdMenu.kAllAbsoluteClipAnnot")) -command $allAbsoluteCmd -dragMenuCommand $allAbsoluteCmd; } string $showClipAttrEdit = ("showEditor "+$selClips[0]); menuItem -label (uiRes("m_ClipEdMenu.kEditPerChannelOffsets")) -annotation (uiRes("m_ClipEdMenu.kEditChannelOffsetsAnnot")) -command $showClipAttrEdit; string $activateCmd = "doActivateClipArgList 2 {\""+$activeState+"\", \"1\", \"" + $clip + "\"}"; menuItem -label (uiRes("m_ClipEdMenu.kActivateKeys")) -checkBox ($activeState==0) -enable ($activeState != 2 && $modifyable) -annotation (uiRes("m_ClipEdMenu.kActivateKeysAnnot")) -command $activateCmd -dragMenuCommand $activateCmd activateClipItem; menuItem -label (uiRes("m_ClipEdMenu.kGroup")) -annotation (uiRes("m_ClipEdMenu.kGroupAnnot")) -enable ($modifyable) -command ("createCharacterSummary {\"" + $clip + "\"}") -dragMenuCommand ("createCharacterSummary {\"" + $clip + "\"}") groupClipItem; menuItem -label (uiRes("m_ClipEdMenu.kUngroup")) -annotation (uiRes("m_ClipEdMenu.kUngroupAnnot")) -enable ($modifyable) -command ("removeFromCharacterSummary {\"" + $clip + "\"}") -dragMenuCommand ("removeFromCharacterSummary {\"" + $clip + "\"}") ungroupClipItem; menuItem -divider true; string $removeCmd = "doCutClipArgList 2 {\"" + $editor + "\", \"" + $clip + "\"}"; menuItem -label (uiRes("m_ClipEdMenu.kCutClip")) -annotation (uiRes("m_ClipEdMenu.kCutClipAnnot")) -enable ($modifyable) -command $removeCmd -dragMenuCommand $removeCmd; string $copyCmd = "doCopyClipArgList 2 {\"" + $editor + "\", \"" + $clip + "\"}"; menuItem -label (uiRes("m_ClipEdMenu.kCopyClip")) -annotation (uiRes("m_ClipEdMenu.kCopyClipAnnot")) -enable ($modifyable) -command $copyCmd -dragMenuCommand $copyCmd; string $splitCmd = "string $clips[] = `doSplitClipArgList 3 {\"currTimeMethod\", \"0\", \"\", \"keepSourceMethod\", \"" + $clip + "\"}`; clipUpdatePivots( $clips[1] );"; menuItem -label (uiRes("m_ClipEdMenu.kSplitClip")) -annotation (uiRes("m_ClipEdMenu.kSplitClipAnnot")) -enable ($modifyable) -command $splitCmd; { string $duplicateCmd = "performDuplicateClip( 0, \"" + $clip + "\"); clipUpdatePivots(\"" + $clip + "\");"; string $duplicateDragCmd = "performDuplicateClip( 2, \"" + $clip + "\"); clipUpdatePivots(\"" + $clip + "\");"; string $duplicateOptionCmd = "performDuplicateClip( 1, \"" + $clip + "\"); clipUpdatePivots(\"" + $clip + "\");"; menuItem -label (uiRes("m_ClipEdMenu.kDuplicateClip")) -annotation (uiRes("m_ClipEdMenu.kDuplicateClipAnnot")) -enable ($modifyable) -command $duplicateCmd -dragMenuCommand $duplicateDragCmd; menuItem -optionBox true -annotation (uiRes("m_ClipEdMenu.kDuplicateClipOptAnnot")) -enable ($modifyable) -command $duplicateOptionCmd; } string $clips[] = getSelectedClips( "noOptions" ); { menuItem -label (uiRes( "m_ClipEdMenu.kMatchClips" )) -annotation (uiRes("m_ClipEdMenu.kMatchClipsAnnot2")) -enable (size($clips) > 1) -command "performMatchClip 0;"; menuItem -optionBox true -annotation (uiRes( "m_ClipEdMenu.kMatchClipsOptAnnot" )) -enable (size($clips) > 1) -command "performMatchClip 1;"; } menuItem -divider true; { string $label = (uiRes("m_ClipEdMenu.kShowHideClipGhost")); if ( size( $clips ) == 0 ) { menuItem -label $label -annotation $label -enable false ; } else { int $show, $status = clipsAreGhosted( $clips ); switch($status) { case 0: // none of the clips are ghosted case 2: // some of the clips are ghosted $label = (uiRes("m_ClipEdMenu.kShowClipGhost")); $show = true; break; case 1: // all of the clips are ghosted $label = (uiRes("m_ClipEdMenu.kHideClipGhost")); $show = false; break; } string $array = ( "{ \"" + stringArrayToString( $clips, "\", \"" ) + "\" }" ); string $cmd = `format -s $array -s $show "performCreateClipGhost(^1s); performShowHideClipGhost(^1s, ^2s);"`; menuItem -label $label -annotation $label -enable (characterHasOffsetObject($clip)) -command ($cmd) ; } } menuItem -divider true; int $mergeEnabled = selectionCanBeMerged($selClips); menuItem -label (uiRes("m_ClipEdMenu.kMerge")) -enable ($mergeEnabled && $modifyable) -annotation (uiRes("m_ClipEdMenu.kMergeAnnot")) -command ("select -add "+$clip+"; performBakeClip 0 " + $editor) -dragMenuCommand("performBakeClip 2 " + $editor) bakeClipsItem; menuItem -optionBox true -enable ($mergeEnabled && $modifyable) -annotation (uiRes("m_ClipEdMenu.kMergeOptAnnot")) -command ("performBakeClip 1 " + $editor) bakeClipsDialogItem; menuItem -label (uiRes("m_ClipEdMenu.kMergeCache")) -enable ($mergeEnabled && $modifyable) -annotation (uiRes("m_ClipEdMenu.kMergeCacheAnnot")) -command ("select -add "+$clip+"; performMergeCacheClip 0 " + $editor) -dragMenuCommand("performMergeCacheClip 2 " + $editor) mergeCacheClipsItem; menuItem -optionBox true -enable ($mergeEnabled && $modifyable) -annotation (uiRes("m_ClipEdMenu.kMergeCacheOptAnnot")) -command ("performMergeCacheClip 1 " + $editor) mergeCacheClipsDialogItem; int $blendEnabled = selectionCanBeBlended($selClips); menuItem -label (uiRes("m_ClipEdMenu.kBlend")) -enable ($blendEnabled && $modifyable) -annotation (uiRes("m_ClipEdMenu.kBlendAnnot")) -command ("performBlendClip 0 " + $editor) -dragMenuCommand("performBlendClip 2 " + $editor) blendClipsItem; menuItem -optionBox true -enable ($blendEnabled && $modifyable) -annotation (uiRes("m_ClipEdMenu.kBlendOptAnnot")) -command ("performBlendClip 1 " + $editor) blendClipsDialogItem; menuItem -divider true; menuItem -label (uiRes("m_ClipEdMenu.kTrimBefore")) -annotation (uiRes("m_ClipEdMenu.kTrimBeforeAnnot")) -enable ($modifyable) -command ("traxTrim 0 {\"" + $clip + "\"}"); menuItem -label (uiRes("m_ClipEdMenu.kTrimAfter")) -annotation (uiRes("m_ClipEdMenu.kTrimAfterAnnot")) -enable ($modifyable) -command ("traxTrim 1 {\"" + $clip + "\"}"); menuItem -divider true; string $attrEditorMenuItemName = `format -s (localizedUIComponentLabel("Attribute Editor")) (uiRes("m_ClipEdMenu.kAttrEditorMenuItemFormat"))`; menuItem -label $attrEditorMenuItemName -annotation (uiRes("m_ClipEdMenu.kAttrEdAnnot")) -enable ($modifyable) -command ("showEditor " + $clip) -dragMenuCommand ("showEditor " + $clip) clipPropItem; string $graphWeightCmd = "clipWeightGraph {\"" + $clip + "\"}"; menuItem -label (uiRes("m_ClipEdMenu.kGraphWeight")) -enable ($modifyable) -annotation (uiRes("m_ClipEdMenu.kGraphWeightAnnot")) -command $graphWeightCmd; string $selectCharacterCmd = "selectTraxCharacter {\"" + $clip + "\"}"; menuItem -label (uiRes("m_ClipEdMenu.kSelCharSetMembers")) -annotation (uiRes("m_ClipEdMenu.kSelCharSetMembersAnnot")) -enable ($modifyable) -command $selectCharacterCmd; menuItem -divider true; menuItem -label (uiRes("m_ClipEdMenu.kKeyIntoClip")) -annotation (uiRes("m_ClipEdMenu.kKeyIntoClipAnnot")) -enable ($modifyable) -command ("doKeyIntoClip(1, {\"" + $clip + "\"})") -image "keyIntoclip.png" -dragMenuCommand("doKeyIntoClip(1, { \"\"})"); menuItem -label (uiRes("m_ClipEdMenu.kCreateTimeWarp")) -annotation (uiRes("m_ClipEdMenu.kCreateTimeWarpAnnot")) -enable ($modifyable) -command ("doCreateClipTimeWarp {\"" + $clip + "\"} true") -dragMenuCommand("doCreateClipTimeWarp {\"" + $clip + "\"} true") clipTimeWarpItem; menuItem -label (uiRes("m_ClipEdMenu.kCreateWeightCurve")) -annotation (uiRes("m_ClipEdMenu.kCreateWeightCurveAnnot")) -enable ($modifyable) -command ("doCreateClipWeightCurve {\"" + $clip + "\"}") -dragMenuCommand("doCreateClipWeightCurve {\"" + $clip + "\"}") clipWeightCurveItem; menuItem -divider true; menuItem -label (uiRes("m_ClipEdMenu.kSelectSourceClip")) -annotation (uiRes("m_ClipEdMenu.kSelectSourceClipAnnot")) -enable ($modifyable) -command ("selectSourceClip {"+ $selClipsAsString + "}"); } global proc buildCacheClipMenuItems(string $editor, string $menu, string $clip) { setParent -menu $menu; int $ii; int $enableState = 0; // 0 == all off, 1 == all on, 2 == mixed string $selClips[] = `ls -sl -type cacheFile`; if (AWNumberOfOccurrencesInStringArray($clip,$selClips) == 0) { $selClips[size($selClips)] = $clip; } string $selClipsAsString; for ($ii = 0; $ii < size($selClips); $ii++) { string $clipName = $selClips[$ii]; if ($ii > 0) { $selClipsAsString += (", "); } $selClipsAsString += ("\""+$clipName+"\""); if ($ii == 0) { $enableState = (0 == `getAttr ($clipName+".enable")`); } else { if ($enableState == `getAttr ($clipName+".enable")`) { $enableState = 2; } } } // int $modifyable = isTrackModifiable( $clip ); int $modifyable = 1; string $toggleEnableCmd = "doEnableClipArgList 2 {\""+$enableState+"\", \"1\", \"" + $clip + "\"}"; menuItem -label (uiRes("m_ClipEdMenu.kCacheEnableClip")) -checkBox ($enableState == 0) -enable ($enableState != 2 && $modifyable) -annotation (uiRes("m_ClipEdMenu.kCacheEnableClipAnnot")) -command $toggleEnableCmd -dragMenuCommand $toggleEnableCmd toggleEnableClipItem; menuItem -divider true; string $splitCmd = "doSplitClipArgList 3 {\"currTimeMethod\", \"0\", \"\", \"keepSourceMethod\", \"" + $clip + "\"}; clipUpdatePivots( \"" + $clip + "\");"; menuItem -label (uiRes("m_ClipEdMenu.kSplitCacheClip")) -annotation (uiRes("m_ClipEdMenu.kSplitCacheClipAnnot")) -enable ($modifyable) -command $splitCmd; menuItem -label (uiRes("m_ClipEdMenu.kCacheTrimBefore")) -annotation (uiRes("m_ClipEdMenu.kCacheTrimBeforeAnnot")) -enable ($modifyable) -command ("traxTrim 0 {\"" + $clip + "\"}"); menuItem -label (uiRes("m_ClipEdMenu.kCacheTrimAfter")) -annotation (uiRes("m_ClipEdMenu.kCacheTrimAfterAnnot")) -enable ($modifyable) -command ("traxTrim 1 {\"" + $clip + "\"}"); menuItem -divider true; menuItem -l (uiRes("m_ClipEdMenu.kSelGeomForCache")) -annotation (uiRes("m_ClipEdMenu.kSelGeomForCacheAnnot")) -c ("selectCacheGeometry "+$clip) selectGeometryForCacheItem; menuItem -l (uiRes("m_ClipEdMenu.kReplaceCache")) -annotation (getRunTimeCommandAnnotation("geometryReplaceCache")) -c "geometryReplaceCache" -dmc "performCreateGeometryCache 2 \"replace\"" geometryReplaceCacheItem; menuItem -optionBox true -annotation (getRunTimeCommandAnnotation("geometryReplaceCacheOpt")) -c "geometryReplaceCacheOpt" geometryReplaceCacheOptItem; menuItem -l (uiRes("m_ClipEdMenu.kReplaceCacheFrames")) -annotation( getRunTimeCommandAnnotation("geometryReplaceCacheFrames") ) -c "geometryReplaceCacheFrames" geometryReplaceCacheFramesItem; menuItem -optionBox true -annotation ( getRunTimeCommandAnnotation("geometryReplaceCacheFramesOpt") ) -c "geometryReplaceCacheFramesOpt" geometryReplaceCacheFramesOptItem; menuItem -divider true; string $attrEditorMenuItemName = `format -s (localizedUIComponentLabel("Attribute Editor")) (uiRes("m_ClipEdMenu.kAttrEditorMenuItemFormat"))`; menuItem -label $attrEditorMenuItemName -annotation (uiRes("m_ClipEdMenu.kCacheAttrEdAnnot")) -enable ( $modifyable ) -command ( "showEditor " + $clip ) -dragMenuCommand ( "showEditor " + $clip ) clipPropItem; string $cacheGraphWeightCmd = "cacheClipWeightGraph {\"" + $clip + "\"}"; menuItem -label (uiRes("m_ClipEdMenu.kCacheGraphWeight")) -enable ($modifyable) -annotation (uiRes("m_ClipEdMenu.kCacheGraphWeightAnnot")) -command $cacheGraphWeightCmd; menuItem -divider true; menuItem -label (uiRes("m_ClipEdMenu.kCreateWeightCacheCurve")) -annotation (uiRes("m_ClipEdMenu.kCreateWeightCacheCurveAnnot")) -enable ($modifyable) -command ("doCreateCacheClipWeightCurve {\"" + $clip + "\"}") -dragMenuCommand("doCreateCacheClipWeightCurve {\"" + $clip + "\"}") cacheClipWeightCurveItem; } // // query if clip is in selection list // proc int isClipSelected( string $clipEditor, string $clip[] ) { string $selectedClips[] = `clipEditor -query -selectClip $clipEditor`; int $numClips = size($selectedClips); int $i; for ($i=0; $i < $numClips; $i+=2) { if ( $clip[0] == $selectedClips[$i] && $clip[1] == $selectedClips[$i+1] ) return 1; } return 0; } // // verify highlighted clip is in selection; if not select it. // proc selectHighlightedClip( string $clipEditor ) { string $hlClip[] = `clipEditor -query -highlightedClip $clipEditor`; if ($hlClip[0] != "") { if (!isClipSelected( $clipEditor, $hlClip )) { clipEditor -edit -deselectAll $clipEditor; clipEditor -edit -selectClip $hlClip[0] $hlClip[1] $clipEditor; } } } global proc buildClipEditorMenuItems(string $editor, string $menu, string $collectionName) { if (`popupMenu -edit -exists $menu`) { // check if mouse over a context-sensitive object // string $menuContext[] = `clipEditor -query -menuContext $editor`; // yes, it is. check what type of object it is // popupMenu -edit -deleteAllItems $menu; switch ($menuContext[0]) { case "timeSlider": case "nothing": buildClipMainPopupMenuItems ($editor, $menu, $collectionName); break; case "track": buildTrackMenuItems ($editor, $menu, $menuContext); break; case "clip": buildClipMenuItems ($editor, $menu, $menuContext[1]); break; } } } global proc ClipEdMenu(string $editor) { // Load in the common menu elements library // loadAnimMenuLibrary; // Find the name of the control that the menu will be attached to // string $parent = `clipEditor -query -control $editor`; string $popupMenuName = ($editor + "PopupMenu"); string $collectionNameMenu = "Menu"; string $collectionNamePopup = "Popup"; // Create the popup menu // if (!`popupMenu -exists $popupMenuName`) { string $fullMenuName = `popupMenu -parent $parent -allowOptionBoxes true $popupMenuName`; popupMenu -edit -parent $parent -postMenuCommand ("buildClipEditorMenuItems " + $editor + " " + $fullMenuName + " " + $collectionNamePopup) $popupMenuName; } buildClipEditorMenu $editor "ClipEditorMenu" $collectionNameMenu; } // // This method is called from the clipEditor command when the track // height of the editor changes. // global proc setClipEdTrackHeight(int $height) { // If the height is not 1 or 2, just return. if (($height != 1) && ($height != 2)) return; // Set the optionVar to the height. optionVar -intValue traxEditorTrackHeight $height; int $radioSmallValue = 1; int $radioLargeValue = 0; if (`optionVar -query traxEditorTrackHeight` == 2) { $radioSmallValue = 0; $radioLargeValue = 1; } // Look for all menu itmems which are track height radios and set their // button values. string $items[] = `lsUI -editors`; for ($pitem in $items) { string $regExpr = "clipEditorPanel.*ClipEditor"; string $s = match($regExpr, $pitem); if (`strcmp $s $pitem` == 0) { string $popupMenuName = ($pitem + "PopupMenu"); if (`popupMenu -exists $popupMenuName`) { string $radioSmallStr = ($pitem + "TraxRadioSmallName"); string $radioLargeStr = ($pitem + "TraxRadioLargeName"); menuItem -edit -radioButton $radioSmallValue $radioSmallStr; menuItem -edit -radioButton $radioLargeValue $radioLargeStr; } } } } // // Procedure Name: // createClipLibraryMenu // // Description: // Create the menu that lists source clips from the clipLibrary // // Input Arguments: // $parent - parent menu // // Return Value: // None // global proc createClipLibraryMenu( string $type, string $parent ) { setParent -menu $parent; menu -edit -deleteAllItems $parent; if (! `exists "getCharacterPoses"`) { source addVisorFolders; } if (! `exists "clipInstanceMenuCommand"`) { source hypergraphAnimClipMenu; } // Get clips in the editor // string $characters[] = getCharactersLoadedInTrax(); string $charClips[]; string $unusedClips[]; string $typeString; if ($type == "pose") { $charClips = `getCharacterPoses`; $unusedClips = `getLibraryPoses`; $typeString = (uiRes("m_ClipEdMenu.kPoses")); } else { $charClips = `getCharacterClips`; $unusedClips = `getLibraryClips`; $typeString = (uiRes("m_ClipEdMenu.kClips")); } int $total = size($charClips) + size($unusedClips); if( $total == 0 ) { string $noCharFmt = (uiRes("m_ClipEdMenu.kNoSomethings")); menuItem -label `format -stringArg $typeString $noCharFmt` -enable false; } else { string $cmd; string $annotation; string $clipName; string $annotFmt = (uiRes("m_ClipEdMenu.kInsertClipName")); for( $clipName in $charClips ) { $annotation = `format -stringArg $clipName $annotFmt`; $cmd = ("clipInstanceMenuCommand "+$clipName); menuItem -label $clipName -command $cmd -annotation $annotation; } if (size($unusedClips)) { menuItem -divider true; for( $clipName in $unusedClips ) { if (size($characters) == 1) { $cmd = ( "clip -copy " + $clipName + "; doPasteClipArgList 3 { \"byMapOrNodeName\", \"currentTime\", \""+$characters[0]+"\" }" ); } else { $cmd = ( "clip -copy " + $clipName + "; doPasteClipArgList 2 { \"byMapOrNodeName\", \"currentTime\" }" ); } $annotation = `format -stringArg $clipName $annotFmt`; menuItem -label $clipName -command $cmd -annotation $annotation; } } } }