// =========================================================================== // 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. // =========================================================================== // // hikCharacterControlsUI.mel // // Description: // UI methods for the unified character controls window // /////////////////////////////////////////////////////////////////// // Local Methods... /////////////////////////////////////////////////////////////////// proc int skeletonTabIndex() { return 1; } proc int definitionTabIndex() { return 2; } proc int controlRigTabIndex() { return 3; } proc int customRigTabIndex() { return 4; } proc buildCharacterMenu() // Description: // Build the Character button { iconTextButton -image "HIKmenuButton.png"; popupMenu -button 1 -postMenuCommand "hikUpdateCharacterMenu"; string $labelSkeleton = (uiRes("m_hikGlobalUtils.kEditSkeleton")); string $labelDefinition = (uiRes("m_hikGlobalUtils.kEditDefinition")); string $labelControls = (uiRes("m_hikGlobalUtils.kEditControls")); string $labelCustomRig = (uiRes("m_hikGlobalUtils.kEditCustomRig")); string $labelIK = (uiRes("m_hikGlobalUtils.kIK")); string $labelFK = (uiRes("m_hikGlobalUtils.kFK")); string $labelLiveConnection = (uiRes("m_hikGlobalUtils.kLiveConnection")); // NOTE: if the -checkBox flag is initialized to false, means we have // a post-menu command to update it and the state could be affected // by other methods. // Otherwise, means the menu item is the only way to change the // checkBox state, so the -command method is sufficient. // menuItem -label (uiRes("m_hikGlobalUtils.kRenameCharacter")) -command "hikRenameDefinition" hikRenameDefinition; menuItem -label $labelSkeleton -ltVersion 2017 -subMenu true -tearOff true hikEditSkeletonMenuItem; menuItem -ltVersion 2017 -label (uiRes("m_hikGlobalUtils.kCreateSkeleton")) -command "hikCreateSkeleton;hikOnSwitchContextualTabs"; menuItem -ltVersion 2017 -label (uiRes("m_hikGlobalUtils.kReset")) -command "hikResetSkeleton" hikResetSkeletonMenuItem; menuItem -divider true; menuItem -ltVersion 2017 -label (uiRes("m_hikCharacterControlsUI.kShowHideSkeletonLabels")) -checkBox false -command "hikShowHide(\"Labels\")" hikShowHideSkeletonLabelsMenuItem; menuItem -divider true; menuItem -ltVersion 2017 -label (uiRes("m_hikCharacterControlsUI.kExportSkeletonTemplate")) -command "hikExportSkeleton"; menuItem -ltVersion 2017 -label (uiRes("m_hikCharacterControlsUI.kImportSkeletonTemplate")) -command "hikImportSkeleton"; setParent -menu ..; menuItem -label $labelDefinition -ltVersion 2017 -subMenu true -tearOff true -postMenuCommand "hikUpdateEditDefinitionMenu" hikEditDefinitionMenuItem; menuItem -ltVersion 2017 -label $labelDefinition -command "hikHIKDefinition"; menuItem -ltVersion 2017 -label (uiRes("m_hikGlobalUtils.kEditHIKProperties")) -command "hikEditDefinition"; menuItem -ltVersion 2017 -label (uiRes("m_hikGlobalUtils.kResetHIKProperties")) -command "hikResetDefinition"; menuItem -divider true; menuItem -ltVersion 2017 -label (uiRes("m_hikGlobalUtils.kConfigureMirrorMatching")) -command "hikConfigureMirrorMatching"; menuItem -divider true; menuItem -ltVersion 2017 -label (uiRes("m_hikGlobalUtils.kLoadCharacterDefinition")) -command "hikMapBones"; menuItem -ltVersion 2017 -label (uiRes("m_hikGlobalUtils.kSaveCharacterDefinition")) -command "hikExtractMapTemplate"; menuItem -divider true; menuItem -ltVersion 2017 -label (uiRes("m_hikCharacterControlsUI.kExportCharacterDefintion")) -command "hikExportDefinition"; setParent -menu ..; menuItem -label $labelControls -ltVersion 2017 -subMenu true -tearOff true -postMenuCommand "hikUpdateEditControlRigMenu" hikEditControlRigMenuItem; menuItem -ltVersion 2017 -label (uiRes("m_hikGlobalUtils.kRigLook")) -subMenu true -postMenuCommand "hikUpdateRigLookMenu" -enable true; menuItem -ltVersion 2017 -label (uiRes("m_hikGlobalUtils.kWire")) -checkBox false -command "hikSetRigLook(\"Wire\")" hikWireMenuItem; menuItem -ltVersion 2017 -label (uiRes("m_hikGlobalUtils.kStick")) -checkBox false -command "hikSetRigLook(\"Stick\")" hikStickMenuItem; menuItem -ltVersion 2017 -label (uiRes("m_hikGlobalUtils.kBox")) -checkBox false -command "hikSetRigLook(\"Box\")" hikBoxMenuItem; setParent -menu ..; menuItem -divider true; menuItem -ltVersion 2017 -label (uiRes("m_hikGlobalUtils.kRigAlignSync")) -enable 0 -checkBox 0 hikRigAlignMenuItem; menuItem -divider true; menuItem -ltVersion 2017 -label (uiRes("m_hikGlobalUtils.kDeleteControlRig")) -command "hikDeleteControlRig"; menuItem -divider true; menuItem -ltVersion 2017 -label (uiRes("m_hikGlobalUtils.kLoadUIConfiguration")) -command "hikLoadControlRigUIConfiguration"; menuItem -ltVersion 2017 -label (uiRes("m_hikCharacterControlsUI.kSaveUIConfigurationCtrlRig")) -command "hikUpdateControlRigConfig"; setParent -menu ..; menuItem -label $labelCustomRig -ltVersion 2017 -subMenu true -tearOff true hikEditCustomRigMenuItem; menuItem -label (uiRes("m_hikGlobalUtils.kDeleteCustomRig")) -version 2017 -command "hikDeleteCustomRig( hikGetCurrentCharacter() )"; menuItem -divider true; menuItem -label (uiRes("m_hikGlobalUtils.kImportCustomRigMapping")) -command "hikImportCustomRigMapping( hikGetCurrentCharacter() )"; menuItem -label (uiRes("m_hikGlobalUtils.kExportCustomRigMapping")) -command "hikExportCustomRigMapping( hikGetCurrentCharacter() )"; menuItem -divider true; menuItem -ltVersion 2017 -label (uiRes("m_hikGlobalUtils.kLoadUIConfiguration")) -command "hikLoadCustomRigUIConfiguration"; menuItem -ltVersion 2017 -label (uiRes("m_hikCharacterControlsUI.kSaveUIConfigurationCustomRig")) -command "hikUpdateCustomRigConfig"; setParent -menu ..; menuItem -label (uiRes("m_hikCharacterControlsUI.kBakeMenu")) -subMenu true -postMenuCommand "hikUpdateBakeMenu" hikBakeMenuItem; menuItem hikBakeUIOption1; menuItem -optionBox true hikBakeUIOptionBox1; menuItem -ltVersion 2017 hikBakeUIOption2; menuItem -optionBox true hikBakeUIOptionBox2; setParent -menu ..; menuItem -label (uiRes("m_hikCharacterControlsUI.kAddToSelectionMenu")) -ltVersion 2017 -subMenu true -tearOff true hikAddToSelectionMenuItem; menuItem -ltVersion 2017 -label $labelSkeleton -command "hikAddToSelection(\"Skeleton\")"; menuItem -ltVersion 2017 -label $labelIK -command "hikAddToSelection(\"IK\")"; menuItem -ltVersion 2017 -label $labelFK -command "hikAddToSelection(\"FK\")"; setParent -menu ..; menuItem -label (uiRes("m_hikCharacterControlsUI.kPackageAsset")) -subMenu true hikPackageMenuItem; menuItem -label (uiRes("m_hikCharacterControlsUI.kCurrentCharacterMenu")) -command "hikPackage(\"Current Character\")"; menuItem -label (uiRes("m_hikCharacterControlsUI.kCurrentCharacterRetargetersMenu")) -command "hikPackage(\"Current Character Retargeters\")"; menuItem -label (uiRes("m_hikCharacterControlsUI.kAllCharactersMenu")) -command "hikPackage(\"All Characters\")"; menuItem -label (uiRes("m_hikCharacterControlsUI.kAllCharacterRetargetersMenu")) -command "hikPackage(\"All Character Retargeters\")"; setParent -menu ..; menuItem -label (uiRes("m_hikCharacterControlsUI.kHelpCharacterControls")) -command "showHelp CharacterControls"; } // builds character and source drop-down list ui proc buildCharacterSourceLists() { columnLayout -adjustableColumn true; optionMenuGrp -label (uiRes("m_hikCharacterControlsUI.kCharacter")) -cw 1 60 -w 1 // This makes the textbox not stretch the scrollLayout when the name gets long -adjustableColumn 2 -cc "hikUpdateCurrentCharacterFromUI(); hikUpdateContextualUI()" //-cc _NOL10N("print \"---> change command from character list\\n\"; hikUpdateCurrentCharacterFromUI(); hikUpdateContextualUI()") hikCharacterList; menuItem -label ( hikNoneString() ); optionMenuGrp -label (uiRes("m_hikCharacterControlsUI.kSource")) -cw 1 60 -w 1 -adjustableColumn 2 -cc "hikUpdateCurrentSourceFromUI(); hikUpdateContextualUI()" //-cc _NOL10N("print \"---> change command from source list\\n\"; hikUpdateCurrentSourceFromUI(); hikUpdateContextualUI()") hikSourceList; setParent ..; } proc buildCommonControls() { rowLayout -numberOfColumns 2 -columnWidth 1 50 -adjustableColumn 2 hikCommonControls; // build the Character Menu buildCharacterMenu(); // build the Character and Source drop downs buildCharacterSourceLists(); setParent ..; } proc buildContextualButtons() { formLayout hikContextualButtonLayout; hikBuildSkeletonButtons(); hikBuildDefinitionButtons(); hikBuildControlRigButtons(); hikBuildCustomRigButtons(); setParent ..; } proc buildStartHereWindow() { frameLayout -label (uiRes("m_hikGlobalUtils.kCreate")) -collapse 0 -collapsable 1 humainIKCreateFrameLayout; string $form = `formLayout`; button -label (uiRes("m_hikGlobalUtils.kCreateSkeleton")) -command "hikCreateSkeleton;hikOnSwitchContextualTabs" humainIKCreateSkeleton; button -label (uiRes("m_hikGlobalUtils.kCreateControlRig")) -command "hikCreateControlRig;hikOnSwitchContextualTabs" humainIKCreateControlRig; button -label (uiRes("m_hikGlobalUtils.kCreateCharacterDefinition")) -command "hikCreateDefinition;hikOnSwitchContextualTabs" humainIKCreateCharacterDefinition; button -label (uiRes("m_hikGlobalUtils.kCreateCustomRigMapping")) -command "hikCreateCustomRig( hikGetCurrentCharacter() ); hikOnSwitchContextualTabs" humainIKCreateCustomRigMapping; button -label (uiRes("m_hikGlobalUtils.kQuickRigTool")) -command "QuickRigEditor" humainIKQuickRigTool; formLayout -edit -attachForm humainIKCreateSkeleton "top" 5 -attachForm humainIKCreateSkeleton "left" 30 -attachForm humainIKCreateSkeleton "right" 30 -attachControl humainIKCreateControlRig "top" 5 humainIKCreateSkeleton -attachForm humainIKCreateControlRig "left" 30 -attachForm humainIKCreateControlRig "right" 30 -attachControl humainIKCreateCharacterDefinition "top" 5 humainIKCreateControlRig -attachForm humainIKCreateCharacterDefinition "left" 30 -attachForm humainIKCreateCharacterDefinition "right" 30 -attachControl humainIKCreateCustomRigMapping "top" 5 humainIKCreateCharacterDefinition -attachForm humainIKCreateCustomRigMapping "left" 30 -attachForm humainIKCreateCustomRigMapping "right" 30 -attachControl humainIKQuickRigTool "top" 5 humainIKCreateCustomRigMapping -attachForm humainIKQuickRigTool "left" 30 -attachForm humainIKQuickRigTool "right" 30 $form; setParent ..; setParent ..; frameLayout -label (uiRes("m_hikGlobalUtils.kImportSamples")) -collapse 0 -collapsable 1 humainIKImportSamplesFrameLayout; $form = `formLayout`; button -label (uiRes("m_hikGlobalUtils.kImportHIKExample")) -command "hikImportExamples(\"Dummy_HIK.fbx\");FrameSelected;hikOnSwitchContextualTabs" humainIKImportExample; button -label (uiRes("m_hikGlobalUtils.kImportAnimExample")) -command "hikImportExamples(\"Dummy_HIK_FightAnimation.fbx\");FrameSelected;hikOnSwitchContextualTabs" humainIKAnimExample; formLayout -edit -attachForm humainIKImportExample "top" 5 -attachForm humainIKImportExample "left" 30 -attachForm humainIKImportExample "right" 30 -attachControl humainIKAnimExample "top" 5 humainIKImportExample -attachForm humainIKAnimExample "left" 30 -attachForm humainIKAnimExample "right" 30 $form; setParent ..; setParent ..; formLayout -edit -attachForm humainIKCreateFrameLayout "top" 5 -attachForm humainIKCreateFrameLayout "left" 5 -attachForm humainIKCreateFrameLayout "right" 5 -attachControl humainIKImportSamplesFrameLayout "top" 5 humainIKCreateFrameLayout -attachForm humainIKImportSamplesFrameLayout "left" 5 -attachForm humainIKImportSamplesFrameLayout "right" 5 hikStartHereLayout; } proc buildContextualTabs() { formLayout -width 250 hikStartHereLayout; // fit a minimum width so we avoid the horizontal scrollbar when // the vertical one is displayed buildStartHereWindow(); setParent ..; // TODO: not setting a width disables resizing but shouldn't. needs investigation string $tab = `tabLayout -width 250 // just fits a minimum widget width of 250 + extra for the stance button in the ctrls tab -bs "none" -cc "hikOnSwitchContextualTabs; hikUpdateContextualUI" // -cc _NOL10N("print \"---> change command from tab layout\\n\"; hikUpdateContextualUI") hikContextualTabs`; // Build 'Skeleton' tab, requires a columnLayout for adjusting when a vertical scrollbar appears columnLayout -p $tab -visible false -adjustableColumn true hikSkeletonLayout; hikBuildSkeletonUI(); setParent ..; tabLayout -e -tabLabel hikSkeletonLayout (uiRes("m_hikGlobalUtils.kSkeleton")) $tab; // Build 'Definition' tab formLayout -p $tab -visible false hikDefinitionLayout; hikBuildDefinitionUI(); setParent ..; tabLayout -e -tabLabel hikDefinitionLayout (uiRes("m_hikGlobalUtils.kDefinition")) $tab; // Note: Control Rig requires columnLayout for dynamic resizing // // Build 'Control Rig' tab columnLayout -p $tab -visible false -adjustableColumn true hikControlRigLayout; hikBuildControlRigUI(); setParent ..; tabLayout -e -tabLabel hikControlRigLayout (uiRes("m_hikGlobalUtils.kControls")) $tab; // Note: Custom Rig requires columnLayout for dynamic resizing // Build 'Custom Rig' tab columnLayout -p $tab -visible false -adjustableColumn true hikCustomRigLayout; hikBuildCustomRigUI(); setParent ..; tabLayout -e -tabLabel hikCustomRigLayout (uiRes("m_hikGlobalUtils.kCustomRig")) $tab; setParent ..; } proc cleanupOptionMenu( string $name ) // Description: // Remove all items from the named optionMenu widget // { string $item, $items[] =`optionMenu -query -itemListLong $name`; for( $item in $items ) deleteUI $item; } proc populateOptionMenu( string $optMenu, string $strings[] ) // Description: // Repopulate the named option menu w the names of all available HIK character. // If none exist, add a default label. { // If the string array is empty ... if ( size( $strings ) == 0 ) { // ... append the "none" string to the menu and exit menuItem -parent $optMenu -label ( hikNoneString() ); return; } // Otherwise, add all strings to the menu string $s; for( $s in $strings ) menuItem -parent $optMenu -label $s; } proc initializeOptionVars() // Description: // Initialize all option vars that will be used by the unified // character context // { if( !`optionVar -exists hikCleanAnimLayers` ) { optionVar -intValue hikCleanAnimLayers 1; } /* if( ! `optionVar -exists hikLastSelectedRigLook`) { // intValue of 0 => Wire, 1 => Stick, 2 => Box // Replace the old mayahikLastSelectedRigStyle optionVar // with hikLastSelectedRigLook. So if the old var exists, // set the value from that and delete if( `optionVar -exists mayahikLastSelectedRigStyle` ) { optionVar -intValue hikLastSelectedRigLook `optionVar -q -mayahikLastSelectedRigStyle`; optionVar -remove mayahikLastSelectedRigStyle; } else { optionVar -intValue hikLastSelectedRigLook 0; } } */ } proc disableBakeMenu() { menuItem -e -label "-" -enable false hikBakeUIOption1; menuItem -e -label "-" -enable false hikBakeUIOption2; } proc enableBakeMenu() { menuItem -e -enable true hikBakeUIOption1; menuItem -e -enable true hikBakeUIOption2; } proc schematicWidgetUpdateAspectRatio( ) { global float $gHIKRigAspectRatio; if( hikIsControlRigTabSelected() ) $gHIKRigAspectRatio = `hikCharacterToolWidget -q -aspectRatio`; else if( hikIsCustomRigTabSelected() ) $gHIKRigAspectRatio = `hikCustomRigToolWidget -q -aspectRatio`; } /////////////////////////////////////////////////////////////////// // Global Methods... /////////////////////////////////////////////////////////////////// global proc int hikCharacterControlsWindowExists() // Description: // Return true if the CharacterControls window exists. False otherwise. // { return ( `workspaceControl -exists hikCharacterControlsDock` ); } global proc hikBuildCharacterControlsDockableWindow() { global int $gHIKDockMinWidth; scrollLayout -width $gHIKDockMinWidth -childResizable true -rc "hikResizeTabLayout" hikContent; // Initialize any optionVars used by any tab of the unified character context initializeOptionVars(); // Creates the Character Menu, the Character and Source drop downs buildCommonControls(); // Creates the contextual button options buildContextualButtons(); // Creates the contextual tabs (and the Start Here window which is also a tab) buildContextualTabs(); setParent ..; HIKUiControl -edit -minWidth $gHIKDockMinWidth -ctrlName "hikCharacterControlsDock"; hikCharacterToolCreateCallback( "hikCharacterControlsDock" ); HIKUiControl -edit -maxWidth $gHIKDockMinWidth -ctrlName "hikCharacterControlsDock"; // Add callback to update the status line button on visibility change workspaceControl -edit -visibleChangeCommand "evalDeferred(\"hikUpdateStatusLineUI()\");" hikCharacterControlsDock; // Raise the control just in case the creation fails to do it workspaceControl -edit -raise hikCharacterControlsDock; // Do any tab-specific initialization hikInitializeDefinitionUI(); //print _NOL10N("---> done creating dockable window\n"); hikUpdateCharacterControlsUI(false); } global proc hikCreateCharacterControlsDockableWindow() // Description: // Create the Unified Character Context dockable window // { global int $gHIKDockableWindowWidth; global int $gHIKDockMinWidth; global string $gMainWindow; string $labelCharacterControls = (uiRes("m_hikCharacterControlsUI.kHIKCharacterControlsTitle")); if( hikCharacterControlsWindowExists() == false ) { // On visibility change we need to switch the state of the iconCheckbox especially // to track the "close (x)" button on character panel string $CLcomponent = getUIComponentDockControl("Channel Box / Layer Editor", false); workspaceControl -requiredPlugin "mayaHIK" -requiredPlugin "mayaCharacterization" -tabToControl $CLcomponent -1 -label $labelCharacterControls -uiScript "hikBuildCharacterControlsDockableWindow();" -loadImmediately true -initialWidth $gHIKDockableWindowWidth -minimumWidth $gHIKDockableWindowWidth -raise hikCharacterControlsDock; // refresh the width of the control based on the current tab now that we have it docked hikOnSwitchContextualTabs(); } else { workspaceControl -edit -restore hikCharacterControlsDock; HIKUiControl -edit -maxWidth $gHIKDockMinWidth -ctrlName "hikCharacterControlsDock"; // Do any tab-specific initialization hikInitializeDefinitionUI(); //print _NOL10N("---> done creating dockable window\n"); hikUpdateCharacterControlsUI(false); } } global proc hikSelectLastTab(string $character) { int $hasSkelGen = hikHasSkeletonGenerator($character); int $hasDefinition = hikHasDefinition($character); int $hasCustomRig = hikHasCustomRig($character); int $hasControlTab = hikIsDefinitionLocked($character); // select the last available tab. int $curTab = `tabLayout -q -selectTabIndex hikContextualTabs`; int $lastTab = -1; if( $hasCustomRig ) $lastTab = customRigTabIndex(); else if( $hasControlTab ) $lastTab = controlRigTabIndex(); else if( $hasDefinition ) $lastTab = definitionTabIndex(); else if( $hasSkelGen ) $lastTab = skeletonTabIndex(); if( $lastTab == -1 ) { if( $character != "" ) warning((uiRes("m_hikCharacterControlsUI.kNoTabWarning"))); else hikOnSwitchContextualTabs(); } else if( $curTab != $lastTab ) { tabLayout -e -selectTabIndex $lastTab hikContextualTabs; } else { hikOnSwitchContextualTabs(); } } global proc hikRefreshWidgetScale() { int $curTab = `tabLayout -q -selectTabIndex hikContextualTabs`; if( $curTab == controlRigTabIndex() ) { hikCharacterToolWidget -e -refreshScale; } else if( $curTab == customRigTabIndex() ) { hikCustomRigToolWidget -e -refreshScale; } } global proc hikUpdateStatusLineUI() // Description: // Updates all status line UI associated with the Character Controls window // { global string $gCharacterControlsButton; int $visible = `workspaceControl -q -vis hikCharacterControlsDock`; if($visible == true) { $visible = (`workspaceControl -query -raise hikCharacterControlsDock` && !`workspaceControl -query -collapse hikCharacterControlsDock`); } if(`iconTextCheckBox -ex $gCharacterControlsButton`) { iconTextCheckBox -e -value $visible $gCharacterControlsButton; } } global proc hikToggleWidget() { if(!(`workspaceControl -exists hikCharacterControlsDock`)) { HIKCharacterControlsTool; }else{ if(`workspaceControl -query -visible hikCharacterControlsDock`) { if(`workspaceControl -query -collapse hikCharacterControlsDock`){ workspaceControl -e -restore hikCharacterControlsDock; } else { if(`workspaceControl -query -raise hikCharacterControlsDock`) { workspaceControl -edit -visible false hikCharacterControlsDock; }else{ workspaceControl -edit -restore hikCharacterControlsDock; } } }else{ global int $gHIKCustomRigInitialized; // If the custom rig widget was initialized, but is not accessible, we need to rebuild it. if( $gHIKCustomRigInitialized == 1 && catch( `hikCustomRigToolWidget -q -visible` ) ) { buildCustomRigSchematicWidget(); } workspaceControl -edit -restore hikCharacterControlsDock; } } } global proc hikUpdateCharacterControlsUI(int $updateCurrentSource) // Description: // Updates all UI associated with the Character Controls window // { if( hikCharacterControlsWindowExists() == false ) return; //print _NOL10N("--> hikUpdateCharacterControlsUI\n"); // make sure we start with an up-to-date current character string hikUpdateCurrentCharacterFromScene(); hikUpdateCharacterList(); // refresh the character list drop-down if($updateCurrentSource) { hikSetCurrentSourceFromCharacter( hikGetCurrentCharacter() ); } hikUpdateSourceList(); // refresh the source list drop-down hikUpdateContextualUI(); // refresh the contextual buttons and tabs hikUpdateLiveConnectionUI(); hikUpdateCurrentSkeleton(); } global proc hikUpdateContextualUI() // Description: // Update all UI that is context-sensitive. So the contextual // buttons, the contextual tabs // { if( hikCharacterControlsWindowExists() == false ) return; waitCursor -state true; //print _NOL10N("--> hikUpdateContextualUI\n"); // Hide the start-here window if it isn't to be shown string $character = hikGetCurrentCharacter(); if( $character == "" ) { // hide the tabs, show the start here window tabLayout -e -manage false hikContextualTabs; tabLayout -e -tabsVisible false hikContextualTabs; formLayout -e -manage true hikStartHereLayout; formLayout -e -visible true hikStartHereLayout; // hide all the contextual buttons rowLayout -e -manage false hikSkeletonButtons; rowLayout -e -manage false hikDefinitionButtons; rowLayout -e -manage false hikControlRigButtons; rowLayout -e -manage false hikCustomRigButtons; // disable source drop down since it doesn't apply optionMenuGrp -e -enable false hikSourceList; } else { // show the tabs, hide the start window tabLayout -e -manage true hikContextualTabs; tabLayout -e -tabsVisible true hikContextualTabs; formLayout -e -manage false hikStartHereLayout; formLayout -e -visible false hikStartHereLayout; // enable source drop down again optionMenuGrp -e -enable true hikSourceList; int $hasSkelGen = hikHasSkeletonGenerator($character); int $hasDefinition = hikHasDefinition($character); int $showControlTab = $hasDefinition; columnLayout -e -enable $hasSkelGen -manage $hasSkelGen hikSkeletonLayout; formLayout -e -enable $hasDefinition -manage $hasDefinition hikDefinitionLayout; columnLayout -e -enable $showControlTab -manage $showControlTab hikControlRigLayout; int $hasCustomRig = hikHasCustomRig($character); columnLayout -e -enable $hasCustomRig -manage $hasCustomRig hikCustomRigLayout; // TODO: Replace this with the hide/reveal tabs flags when it's implemented. // For now, if we are hiding a tab, change the tab label to "---" string $invisible = (uiRes("m_hikCharacterControlsUI.kInvisible")); tabLayout -e -tabLabel hikSkeletonLayout ($hasSkelGen ? (uiRes("m_hikGlobalUtils.kSkeleton")) : $invisible) hikContextualTabs; tabLayout -e -tabLabel hikDefinitionLayout ($hasDefinition ? (uiRes("m_hikGlobalUtils.kDefinition")) : $invisible) hikContextualTabs; tabLayout -e -tabLabel hikControlRigLayout ($showControlTab ? (uiRes("m_hikGlobalUtils.kControls")) : $invisible) hikContextualTabs; tabLayout -e -tabLabel hikCustomRigLayout ($hasCustomRig ? (uiRes("m_hikGlobalUtils.kCustomRig")) : $invisible) hikContextualTabs; int $curTab = `tabLayout -q -selectTabIndex hikContextualTabs`; int $isTabValid = 1; if( $curTab == customRigTabIndex() && !$hasCustomRig ) { $curTab = skeletonTabIndex(); $isTabValid = 0; } if( $curTab == controlRigTabIndex() && !$showControlTab ) { $curTab = skeletonTabIndex(); $isTabValid = 0; } if( $curTab == skeletonTabIndex() && !$hasSkelGen ) { $curTab = controlRigTabIndex(); $isTabValid = 0; } if( !$isTabValid ) { tabLayout -e -selectTabIndex $curTab hikContextualTabs; } // Determine which tab is active // int $isSkeleton = ($curTab == skeletonTabIndex()); int $isDefinition = ($curTab == definitionTabIndex()); int $isControl = ($curTab == controlRigTabIndex()); int $isCustom = ($curTab == customRigTabIndex()); rowLayout -e -manage ($isCustom) hikCustomRigButtons; rowLayout -e -manage ($isSkeleton) hikSkeletonButtons; rowLayout -e -manage ($isDefinition) hikDefinitionButtons; rowLayout -e -manage ($isControl) hikControlRigButtons; if( $isSkeleton ) { hikUpdateSkeletonUI(); } else if( $isDefinition ) { hikUpdateDefinitionUI(); } else if( $isControl ) { hikUpdateControlRigUI(); } else if( $isCustom ) { hikUpdateCustomRigUI(); } else { warning((uiRes("m_hikCharacterControlsUI.kUnknownTab"))); } hikResizeTabLayout(); } waitCursor -state false; } global proc hikOnSwitchContextualTabs( ) { global int $gHIKDockSkeletonWidth; global int $gHIKDockDefinitionWidth; global int $gHIKDockMinWidth; int $curTab = `tabLayout -q -selectTabIndex hikContextualTabs`; if( hikGetCurrentCharacter() == "" ) // start here panel { HIKUiControl -edit -maxWidth $gHIKDockMinWidth -minWidth $gHIKDockMinWidth -ctrlName "hikCharacterControlsDock"; } else if( $curTab == skeletonTabIndex() ) { HIKUiControl -edit -maxWidth ($gHIKDockSkeletonWidth+5) -minWidth ($gHIKDockSkeletonWidth+5) -ctrlName "hikCharacterControlsDock"; } else if( $curTab == definitionTabIndex() ) { HIKUiControl -edit -maxWidth $gHIKDockDefinitionWidth -minWidth $gHIKDockDefinitionWidth -ctrlName "hikCharacterControlsDock"; } else if( $curTab == controlRigTabIndex() ) hikOnSwitchControlRig(); else if( $curTab == customRigTabIndex() ) hikOnSwitchCustomRig(); } global proc hikSchematicWidgetNavigationPost( ) { // Be sure that we do not play with the dock control width // when we toggle off the character control. // Or else you will have a still visible dock control with no content // We also need to check if we are using workspaces. (MAYA-71307) if(`workspaceControl -q -raise hikCharacterControlsDock`) { hikOnSwitchContextualTabs(); } hikResizeTabLayout(); } global proc hikResizeTabLayout() { global float $gHIKRigAspectRatio; global int $gHIKSkeletonTabHeight; global int $gHIKDefinitionTabHeight; global int $gHIKControlRigAuxHeight; global int $gHIKCustomRigAuxHeight; global int $gHIKDockMinWidth; int $height; int $width = `scrollLayout -q -width hikContent`; schematicWidgetUpdateAspectRatio( ); int $widgetContainerHeight = ( $width - 16 ) / $gHIKRigAspectRatio; if( hikIsSkeletonTabSelected() ) { $height = $gHIKSkeletonTabHeight; } else if( hikIsDefinitionTabSelected() ) { $height = $gHIKDefinitionTabHeight; } else if( hikIsControlRigTabSelected() ) { optionVar -iv hikControlsTabWidth $width; $height = ( $width - 16 ) / $gHIKRigAspectRatio + $gHIKControlRigAuxHeight; // This checks for the presence of a vertical scrollbar if( $height + 7 + `rowLayout -q -h hikCommonControls` + `formLayout -q -h hikContextualButtonLayout` >= `scrollLayout -q -height hikContent`) { // If we have a scrollbar and we are within 16 pixels from the minimum ( scrollbar width ) we // do not want to expand the image vertically but instead keep it the same size if( $width < $gHIKDockMinWidth + 16 ) { int $verticalOffset = ( $gHIKDockMinWidth - 16 ) / $gHIKRigAspectRatio; columnLayout -e -h $verticalOffset hikControlRigResizableLayout; } else { int $verticalOffset = 16 / $gHIKRigAspectRatio; columnLayout -e -h ( $widgetContainerHeight - $verticalOffset ) hikControlRigResizableLayout; } } else columnLayout -e -h $widgetContainerHeight hikControlRigResizableLayout; } else if( hikIsCustomRigTabSelected() ) { optionVar -iv hikCustomRigTabWidth $width; $height = ( $width - 16 ) / $gHIKRigAspectRatio + $gHIKCustomRigAuxHeight; if( $height + 7 + `rowLayout -q -h hikCommonControls` + `formLayout -q -h hikContextualButtonLayout` >= `scrollLayout -q -height hikContent` ) { if( $width < $gHIKDockMinWidth + 16 ) { int $verticalOffset = ( $gHIKDockMinWidth - 16 ) / $gHIKRigAspectRatio; columnLayout -e -h $verticalOffset hikCustomRigResizableLayout; } else { int $verticalOffset = 16 / $gHIKRigAspectRatio; columnLayout -e -h ( $widgetContainerHeight - $verticalOffset ) hikCustomRigResizableLayout; } } else columnLayout -e -h $widgetContainerHeight hikCustomRigResizableLayout; } else return; tabLayout -e -height $height hikContextualTabs; } global proc hikUpdateCharacterControlsUIEvalDeferred() // Description: // Adds the UI update command to the evalDeferred list // if it is not already there { string $refreshCmd = "hikUpdateCharacterControlsUI(false)"; string $cmds[] = `evalDeferred -list`; for( $cmd in $cmds ) { if( $cmd == $refreshCmd ) { // cmd already queued return; } } // print _NOL10N("---> evalDeferred hikUpdateCharacterControlsUI\n"); evalDeferred $refreshCmd; } global proc hikUpdateCreateMenu() { int $hasControlRig = hikHasControlRig(hikGetCurrentCharacter()); int $hasCustomRig = hikHasCustomRig(hikGetCurrentCharacter()); menuItem -e -enable (!$hasControlRig && !$hasCustomRig) hikCreateControlRigMenuItem; } global proc hikUpdateDefineMenu() { string $hasCustomRig = hikHasCustomRig(hikGetCurrentCharacter()); menuItem -e -enable ($hasCustomRig == false) hikCreateCustomRigMenuItem; } global proc hikUpdateBakeMenu() { string $character = hikGetCurrentCharacter(); if($character == ""){ disableBakeMenu(); return; } enableBakeMenu(); int $isCustomRig = hikHasCustomRig($character); int $keyingMode = `optionVar -q keyFullBody`; string $inputType = hikGetCharacterInputString($character); int $isSrcNone = ($inputType == (uiRes("m_hikGlobalUtils.kNone"))); int $isSrcCtrlRig = ($inputType == (uiRes("m_hikGlobalUtils.kControlRig"))); int $isSrcLive = hikIsCharacterInputTypeLive($character); if($inputType == (uiRes("m_hikGlobalUtils.kStance"))){ disableBakeMenu(); return; } // options for the menu items, indices correspond to skeleton/control rig/custom rig string $labels[]; string $commands[] = {"hikBakeCharacter", "hikBakeToControlRig", "hikBakeCharacter"}; int $enabled[] = {true, true, true}; // if the source is live then disable the control rig and change the baking commands if($isSrcLive){ $commands[0] = $commands[2] = "hikBakeLiveCharacter"; $enabled[1] = false; } // Skeleton Label if(!$isCustomRig && $isSrcLive) $labels[0] = uiRes("m_hikGlobalUtils.kBakeLiveToSkeleton"); else if(!$isCustomRig && $isSrcNone) $labels[0] = uiRes("m_hikGlobalUtils.kBakeSkeleton"); else $labels[0] = uiRes("m_hikGlobalUtils.kBakeToSkeleton"); // Control Rig label if(!$isCustomRig && $isSrcCtrlRig && ($keyingMode == 1 || $keyingMode == 3)) $labels[1] = uiRes("m_hikGlobalUtils.kBakeControlRig"); else if(!$isCustomRig && $isSrcCtrlRig && $keyingMode == 2) $labels[1] = uiRes("m_hikGlobalUtils.kBakeRigBodyPart"); else $labels[1] = uiRes("m_hikGlobalUtils.kBakeToControlRig"); // Custom Rig Label if($isCustomRig && $isSrcLive) $labels[2] = uiRes("m_hikGlobalUtils.kBakeLiveToCustomRig"); else if($isCustomRig && $isSrcNone) $labels[2] = uiRes("m_hikGlobalUtils.kBakeCustomRig"); else $labels[2] = uiRes("m_hikGlobalUtils.kBakeToCustomRig"); // TODO: move the hikBake* methods into the UnifiedCharacterControls folder // and have this refresh happen in that method... string $refreshCmd = "hikSetCurrentSourceFromCharacter(hikGetCurrentCharacter()); hikUpdateSourceList; hikUpdateContextualUI;"; // if we have a custom rig we want to hide the control rig options (and disable the skeleton) and vice versa if($isCustomRig){ menuItem -e -enable $enabled[2] -label $labels[2] -command ($commands[2]+" 0; " + $refreshCmd) hikBakeUIOption2; menuItem -e -command ($commands[2]+" 1; " + $refreshCmd) hikBakeUIOptionBox2; $enabled[0] = false; }else{ menuItem -e -enable $enabled[1] -label $labels[1] -command ($commands[1]+" 0; " + $refreshCmd) hikBakeUIOption2; menuItem -e -command ($commands[1]+" 1; " + $refreshCmd) hikBakeUIOptionBox2; } menuItem -e -enable $enabled[0] -label $labels[0] -command ($commands[0]+" 0; " + $refreshCmd) hikBakeUIOption1; menuItem -e -command ($commands[0]+" 1; " + $refreshCmd) hikBakeUIOptionBox1; } global proc hikUpdateCharacterMenu() // Description: // Update the character button's root menu items // { string $character = hikGetCurrentCharacter(); int $hasSkelGen = hikHasSkeletonGenerator($character); int $hasDef = hikHasDefinition($character); int $lockedDef = hikIsDefinitionLocked($character); int $hasControlRig = hikHasControlRig($character); int $hasCustomRig = hikHasCustomRig($character); menuItem -e -enable $hasDef hikRenameDefinition; int $tabVisible = `tabLayout -q -tabsVisible hikContextualTabs`; menuItem -e -enable ($tabVisible && hikIsSkeletonTabSelected()) hikEditSkeletonMenuItem; menuItem -e -enable ($tabVisible && hikIsDefinitionTabSelected()) hikEditDefinitionMenuItem; menuItem -e -enable ($tabVisible && hikIsControlRigTabSelected()) hikEditControlRigMenuItem; menuItem -e -enable ($tabVisible && hikIsCustomRigTabSelected()) hikEditCustomRigMenuItem; int $enable = ($lockedDef && $hasControlRig || $hasCustomRig); menuItem -e -enable $lockedDef hikBakeMenuItem; menuItem -e -enable $enable hikAddToSelectionMenuItem; menuItem -e -enable $lockedDef hikPackageMenuItem; } global proc hikUpdateEditMenu() { string $character = hikGetCurrentCharacter(); int $hasSkelGen = hikHasSkeletonGenerator($character); int $hasDef = hikHasDefinition($character); int $lockedDef = hikIsDefinitionLocked($character); int $hasCustomRig = hikHasCustomRig($character); int $isSkelVisible = ($hasDef && hikIsSkeletonVisible($character)); int $isLabelVisible = ($isSkelVisible && hikIsSkeletonLabelVisible($character)); menuItem -e -enable $isSkelVisible -checkBox $isLabelVisible hikShowHideSkeletonLabelsMenuItem; menuItem -e -enable $hasSkelGen hikEditSkeletonMenuItem; menuItem -e -enable $hasDef hikEditDefinitionMenuItem; menuItem -e -enable $hasDef hikEditControlRigMenuItem; menuItem -e -enable $hasCustomRig hikEditCustomRigMenuItem; } global proc hikUpdateShowHideMenu() // Description: // Update the character button's Show/Hide sub-menu { string $character = hikGetCurrentCharacter(); int $hasControlRig = hikHasControlRig($character); int $hasDefinition = hikHasDefinition($character); int $isSkelVisible = ($hasDefinition && hikIsSkeletonVisible($character)); int $isLabelVisible = ($isSkelVisible && hikIsSkeletonLabelVisible($character)); int $isIKVisible = ($hasControlRig && hikIsRigIKVisible($character)); int $isFKVisible = ($hasControlRig && hikIsRigFKVisible($character)); menuItem -e -enable $hasDefinition -checkBox $isSkelVisible hikShowHideSkeletonMenuItem; menuItem -e -enable $hasControlRig -checkBox $isIKVisible hikShowHideIKMenuItem; menuItem -e -enable $hasControlRig -checkBox $isFKVisible hikShowHideFKMenuItem; menuItem -e -enable $isSkelVisible -checkBox $isLabelVisible hikShowHideLabelsMenuItem; } global proc hikUpdateCharacterList() // Description: // Updates the character list with all available characters // in the scene and selects the current character in the // drop down. { if( hikCharacterControlsWindowExists() == false ) return; waitCursor -state true; // Get a list of all available HIK character nodes in the scene. // And always make sure "None" can be selected, which will kick us // back to the "Start Here" screen. string $originals[] = stringArrayCatenate( { hikNoneString() }, hikGetSceneCharacters() ); string $characters[]; for ( $i=0; $i -1 ) stringArrayRemoveAtIndex( $inx, $characters ); // Next, form the list of potential sources concatenating ... // ... the nonestring, scene characters $characters = stringArrayCatenate( { hikNoneString() }, $characters ); // ... and remote characters $characters = stringArrayCatenate( $characters, hikGetRemoteCharacters() ); // add a "Stance" item... $characters = stringArrayCatenate( $characters, { (uiRes("m_hikGlobalUtils.kStance")) }); // add a "Control Rig" item if we don't have a custom rig already if( !hikHasCustomRig($curCharacter) ) $characters = stringArrayCatenate( $characters, { ( uiRes("m_hikGlobalUtils.kControlRig") ) } ); // To avoid focus issues that may arise when a key is pressed and the // option menu group has focus, each string that will end up in the // optionMenuGrp is prefixed with a space. $characters = stringArrayAddPrefix( $characters, " " ); // Repopulate the source list menu $optMenu = "hikSourceList|OptionMenu"; cleanupOptionMenu( $optMenu ); populateOptionMenu( $optMenu, $characters ); // Make sure the source is up to date and query it. hikSetCurrentSourceFromCharacter( $curCharacter ); string $source = hikGetCurrentSource(); // If a source is found ... if ( size( $source ) ) { // Check if the skeleton definition is unlocked ... if( !hikIsDefinitionLocked($curCharacter) ) { // ... if so, set the source to 'None' optionMenu -e -sl 1 $optMenu; hikSetCurrentSource(""); } // .. otherwise select the correct item from the list of available sources else { string $items[] = `optionMenu -q -ill $optMenu`; for ( $i=0; $i