1/****************************************************************************** 2 NintendoWare for CTR Maya Plugin 3 4 File: NW4C_SetFrameExtensionList.mel 5 Description: set frame extension list to file node 6 Date: 2010/04/28 7 Author: Takashi Endo 8 9 Copyright (C)2009-2010 Nintendo Co., Ltd. / HAL Laboratory, Inc. All rights reserved. 10******************************************************************************/ 11 12/****************************************************************************** 13 frame extension list 14******************************************************************************/ 15global proc string nw4cSetFrameExtensionList_Get_FrameExtensionList(string $node) 16{ 17 string $val = (`attributeQuery -n $node -ex "nw4cFeList"`) ? 18 (string)`getAttr ($node + ".nw4cFeList")` : ""; 19 return $val; 20} 21 22global proc nw4cSetFrameExtensionList_Add_FrameExtensionList(string $node) 23{ 24 if (!`attributeQuery -n $node -ex "nw4cFeList"`) 25 { 26 addAttr -ln "nw4cFeList" -dt "string" -h 1 $node; 27 } 28} 29 30global proc nw4cSetFrameExtensionList_Set_FrameExtensionList(string $node, string $val) 31{ 32 nw4cSetFrameExtensionList_Add_FrameExtensionList($node); 33 setAttr ($node + ".nw4cFeList") -typ "string" $val; 34} 35 36proc SetJob_FrameExtensionList(string $node) 37{ 38 if (!`attributeQuery -n $node -ex "nw4cFeList"`) 39 { 40 return; 41 } 42 scriptJob -p nw4cSetFrameExtensionList_List -rp -ac ($node + ".nw4cFeList") 43 ("textFieldGrp -e -tx (`nw4cSetFrameExtensionList_Get_FrameExtensionList " 44 + $node + "`) nw4cSetFrameExtensionList_List"); 45} 46 47global proc nw4cSetFrameExtensionList_ListCB(string $mainNode) 48{ 49 string $val = `textFieldGrp -q -tx nw4cSetFrameExtensionList_List`; 50 $val = strip($val); 51 if (match("^-", $val) != "" || 52 match("-$", $val) != "") 53 { 54 error ("Frame extension list is wrong: " + $val); 55 } 56 if (!`getAttr ($mainNode + ".ufe")`) 57 { 58 error ("Turn on use frame extension attribute: " + $mainNode); 59 } 60 nw4cSetFrameExtensionList_Set_FrameExtensionList($mainNode, $val); 61 SetJob_FrameExtensionList($mainNode); 62} 63 64/****************************************************************************** 65 update window 66******************************************************************************/ 67global proc nw4cSetFrameExtensionList_UpdateWindow() 68{ 69 //----------------------------------------------------------------------------- 70 // get selection 71 string $files[] = `ls -sl -typ file`; 72 if (size($files) == 0) 73 { 74 string $mats[] = `ls -sl -mat`; 75 for ($mat in $mats) 76 { 77 string $hist[] = `listHistory $mat`; 78 for ($node in $hist) 79 { 80 if (`nodeType $node` == "file") 81 { 82 $files[size($files)] = $node; 83 //break; 84 } 85 } 86 } 87 } 88 int $enableFlag = (size($files) == 1); 89 90 //----------------------------------------------------------------------------- 91 // set node name 92 string $nodeName; 93 if ($enableFlag) 94 { 95 $nodeName = $files[0]; 96 } 97 else if (size($files) > 1) 98 { 99 $nodeName = "(Multi node is selected)"; 100 } 101 else 102 { 103 $nodeName = "(None)"; 104 } 105 text -e -l $nodeName nw4cSetFrameExtensionList_NodeName; 106 107 //----------------------------------------------------------------------------- 108 // set current attr & change command 109 if ($enableFlag) 110 { 111 string $node = $files[0]; 112 113 textFieldGrp -e -tx `nw4cSetFrameExtensionList_Get_FrameExtensionList $node` 114 -cc ("nw4cSetFrameExtensionList_ListCB " + $node) 115 nw4cSetFrameExtensionList_List; 116 117 SetJob_FrameExtensionList($node); 118 } 119 120 //----------------------------------------------------------------------------- 121 // set enable state 122 control -e -en $enableFlag nw4cSetFrameExtensionList_List; 123 control -e -en $enableFlag nw4cSetFrameExtensionList_Sample; 124} 125 126/****************************************************************************** 127 main 128******************************************************************************/ 129global proc NW4C_SetFrameExtensionList() 130{ 131 //----------------------------------------------------------------------------- 132 // create window 133 int $wd = 400; 134 int $ht = 228; 135 if (!`window -exists nw4cSetFrameExtensionList_Win`) 136 { 137 window -t "NW4C Set Frame Extension List" -wh $wd $ht -mxb 0 -mb 1 138 nw4cSetFrameExtensionList_Win; 139 menu -l "Help"; 140 menuItem -l ("Help on " + `window -q -t nw4cSetFrameExtensionList_Win` + "...") 141 -c "NW4C_ShowHelp \"html/NW4C_SetFrameExtensionList.html\" \"\""; 142 143 columnLayout -adj 1 -cat "both" 4 -cal "center" -rs 4; 144 145 //----------------------------------------------------------------------------- 146 // node name 147 frameLayout -l "Selected File Node" -cll 0 -cl 0 -bv 1 -bs "etchedIn"; 148 columnLayout -adj 1 -cal "center" -rs 8; 149 150 text -l "" nw4cSetFrameExtensionList_NodeName; 151 152 setParent ..; // columnLayout 153 setParent ..; // frameLayout 154 155 //----------------------------------------------------------------------------- 156 // set 157 frameLayout -l "Set" -cll 0 -cl 0 -bv 1 -bs "etchedIn"; 158 string $setForm = `formLayout -nd 100`; 159 textFieldGrp -l "" -tx "" -cw2 1 360 -adj 2 160 nw4cSetFrameExtensionList_List; 161 text -l "ex. \"1,2,3\" or \"1-3\" or \"1-3,10\"" -al "center" 162 nw4cSetFrameExtensionList_Sample; 163 formLayout -e 164 -af nw4cSetFrameExtensionList_List "left" 0 165 -af nw4cSetFrameExtensionList_List "top" 8 166 -af nw4cSetFrameExtensionList_List "right" 10 167 -an nw4cSetFrameExtensionList_List "bottom" 168 169 -af nw4cSetFrameExtensionList_Sample "left" 8 170 -ac nw4cSetFrameExtensionList_Sample "top" 8 nw4cSetFrameExtensionList_List 171 -af nw4cSetFrameExtensionList_Sample "right" 8 172 -af nw4cSetFrameExtensionList_Sample "bottom" 8 173 $setForm; 174 setParent ..; // formLayout 175 setParent ..; // frameLayout 176 177 //----------------------------------------------------------------------------- 178 // close button 179 string $closeCmd = "deleteUI nw4cSetFrameExtensionList_Win"; 180 string $form = `formLayout -nd 100`; 181 string $closeBtn = `button -h 26 -l "Close" -c $closeCmd`; 182 formLayout -e 183 -af $closeBtn "top" 0 184 -af $closeBtn "left" 0 185 -af $closeBtn "bottom" 0 186 -af $closeBtn "right" 0 187 $form; 188 setParent ..; // formLayout 189 190 setParent ..; // columnLayout 191 192 //setFocus $closeBtn; 193 setFocus nw4cSetFrameExtensionList_List; 194 195 //----------------------------------------------------------------------------- 196 // set selection change job 197 scriptJob -p nw4cSetFrameExtensionList_Win 198 -e "SelectionChanged" "nw4cSetFrameExtensionList_UpdateWindow"; 199 } 200 if (`window -q -w nw4cSetFrameExtensionList_Win` < $wd) 201 { 202 window -e -w $wd nw4cSetFrameExtensionList_Win; 203 } 204 if (`window -q -h nw4cSetFrameExtensionList_Win` < $ht) 205 { 206 window -e -h $ht nw4cSetFrameExtensionList_Win; 207 } 208 //window -e -wh $wd $ht nw4cSetFrameExtensionList_Win; 209 210 //----------------------------------------------------------------------------- 211 // update window 212 nw4cSetFrameExtensionList_UpdateWindow(); 213 214 //----------------------------------------------------------------------------- 215 // show window 216 showWindow nw4cSetFrameExtensionList_Win; 217} 218 219