/****************************************************************************** NintendoWare for CTR Maya Plugin File: NW4C_SetFrameExtensionList.mel Description: set frame extension list to file node Date: 2010/04/28 Author: Takashi Endo Copyright (C)2009-2010 Nintendo Co., Ltd. / HAL Laboratory, Inc. All rights reserved. ******************************************************************************/ /****************************************************************************** frame extension list ******************************************************************************/ global proc string nw4cSetFrameExtensionList_Get_FrameExtensionList(string $node) { string $val = (`attributeQuery -n $node -ex "nw4cFeList"`) ? (string)`getAttr ($node + ".nw4cFeList")` : ""; return $val; } global proc nw4cSetFrameExtensionList_Add_FrameExtensionList(string $node) { if (!`attributeQuery -n $node -ex "nw4cFeList"`) { addAttr -ln "nw4cFeList" -dt "string" -h 1 $node; } } global proc nw4cSetFrameExtensionList_Set_FrameExtensionList(string $node, string $val) { nw4cSetFrameExtensionList_Add_FrameExtensionList($node); setAttr ($node + ".nw4cFeList") -typ "string" $val; } proc SetJob_FrameExtensionList(string $node) { if (!`attributeQuery -n $node -ex "nw4cFeList"`) { return; } scriptJob -p nw4cSetFrameExtensionList_List -rp -ac ($node + ".nw4cFeList") ("textFieldGrp -e -tx (`nw4cSetFrameExtensionList_Get_FrameExtensionList " + $node + "`) nw4cSetFrameExtensionList_List"); } global proc nw4cSetFrameExtensionList_ListCB(string $mainNode) { string $val = `textFieldGrp -q -tx nw4cSetFrameExtensionList_List`; $val = strip($val); if (match("^-", $val) != "" || match("-$", $val) != "") { error ("Frame extension list is wrong: " + $val); } if (!`getAttr ($mainNode + ".ufe")`) { error ("Turn on use frame extension attribute: " + $mainNode); } nw4cSetFrameExtensionList_Set_FrameExtensionList($mainNode, $val); SetJob_FrameExtensionList($mainNode); } /****************************************************************************** update window ******************************************************************************/ global proc nw4cSetFrameExtensionList_UpdateWindow() { //----------------------------------------------------------------------------- // get selection string $files[] = `ls -sl -typ file`; if (size($files) == 0) { string $mats[] = `ls -sl -mat`; for ($mat in $mats) { string $hist[] = `listHistory $mat`; for ($node in $hist) { if (`nodeType $node` == "file") { $files[size($files)] = $node; //break; } } } } int $enableFlag = (size($files) == 1); //----------------------------------------------------------------------------- // set node name string $nodeName; if ($enableFlag) { $nodeName = $files[0]; } else if (size($files) > 1) { $nodeName = "(Multi node is selected)"; } else { $nodeName = "(None)"; } text -e -l $nodeName nw4cSetFrameExtensionList_NodeName; //----------------------------------------------------------------------------- // set current attr & change command if ($enableFlag) { string $node = $files[0]; textFieldGrp -e -tx `nw4cSetFrameExtensionList_Get_FrameExtensionList $node` -cc ("nw4cSetFrameExtensionList_ListCB " + $node) nw4cSetFrameExtensionList_List; SetJob_FrameExtensionList($node); } //----------------------------------------------------------------------------- // set enable state control -e -en $enableFlag nw4cSetFrameExtensionList_List; control -e -en $enableFlag nw4cSetFrameExtensionList_Sample; } /****************************************************************************** main ******************************************************************************/ global proc NW4C_SetFrameExtensionList() { //----------------------------------------------------------------------------- // create window int $wd = 400; int $ht = 228; if (!`window -exists nw4cSetFrameExtensionList_Win`) { window -t "NW4C Set Frame Extension List" -wh $wd $ht -mxb 0 -mb 1 nw4cSetFrameExtensionList_Win; menu -l "Help"; menuItem -l ("Help on " + `window -q -t nw4cSetFrameExtensionList_Win` + "...") -c "NW4C_ShowHelp \"html/NW4C_SetFrameExtensionList.html\" \"\""; columnLayout -adj 1 -cat "both" 4 -cal "center" -rs 4; //----------------------------------------------------------------------------- // node name frameLayout -l "Selected File Node" -cll 0 -cl 0 -bv 1 -bs "etchedIn"; columnLayout -adj 1 -cal "center" -rs 8; text -l "" nw4cSetFrameExtensionList_NodeName; setParent ..; // columnLayout setParent ..; // frameLayout //----------------------------------------------------------------------------- // set frameLayout -l "Set" -cll 0 -cl 0 -bv 1 -bs "etchedIn"; string $setForm = `formLayout -nd 100`; textFieldGrp -l "" -tx "" -cw2 1 360 -adj 2 nw4cSetFrameExtensionList_List; text -l "ex. \"1,2,3\" or \"1-3\" or \"1-3,10\"" -al "center" nw4cSetFrameExtensionList_Sample; formLayout -e -af nw4cSetFrameExtensionList_List "left" 0 -af nw4cSetFrameExtensionList_List "top" 8 -af nw4cSetFrameExtensionList_List "right" 10 -an nw4cSetFrameExtensionList_List "bottom" -af nw4cSetFrameExtensionList_Sample "left" 8 -ac nw4cSetFrameExtensionList_Sample "top" 8 nw4cSetFrameExtensionList_List -af nw4cSetFrameExtensionList_Sample "right" 8 -af nw4cSetFrameExtensionList_Sample "bottom" 8 $setForm; setParent ..; // formLayout setParent ..; // frameLayout //----------------------------------------------------------------------------- // close button string $closeCmd = "deleteUI nw4cSetFrameExtensionList_Win"; string $form = `formLayout -nd 100`; string $closeBtn = `button -h 26 -l "Close" -c $closeCmd`; formLayout -e -af $closeBtn "top" 0 -af $closeBtn "left" 0 -af $closeBtn "bottom" 0 -af $closeBtn "right" 0 $form; setParent ..; // formLayout setParent ..; // columnLayout //setFocus $closeBtn; setFocus nw4cSetFrameExtensionList_List; //----------------------------------------------------------------------------- // set selection change job scriptJob -p nw4cSetFrameExtensionList_Win -e "SelectionChanged" "nw4cSetFrameExtensionList_UpdateWindow"; } if (`window -q -w nw4cSetFrameExtensionList_Win` < $wd) { window -e -w $wd nw4cSetFrameExtensionList_Win; } if (`window -q -h nw4cSetFrameExtensionList_Win` < $ht) { window -e -h $ht nw4cSetFrameExtensionList_Win; } //window -e -wh $wd $ht nw4cSetFrameExtensionList_Win; //----------------------------------------------------------------------------- // update window nw4cSetFrameExtensionList_UpdateWindow(); //----------------------------------------------------------------------------- // show window showWindow nw4cSetFrameExtensionList_Win; }