1/****************************************************************************** 2 NintendoWare for CTR Maya Plugin 3 4 File: NW4C_CommonProc.mel 5 Description: common procedure 6 Date: 2009/09/02 7 Author: Takashi Endo 8 9 Copyright (C)2009-2010 Nintendo Co., Ltd. / HAL Laboratory, Inc. All rights reserved. 10******************************************************************************/ 11 12// NW4C_ShowHelp 13// NW4C_SetCurDirFromFile 14 15/****************************************************************************** 16 show help 17******************************************************************************/ 18global proc NW4C_ShowHelp(string $file, string $label) 19{ 20 string $rootPath = getenv("NW4C_ROOT"); 21 if (size($rootPath) == 0) 22 { 23 error "NW4C_ROOT is not defined"; 24 } 25 if (size(match("/$", $rootPath)) == 0) 26 { 27 $rootPath += "/"; 28 } 29 string $helpPath = $rootPath + "documents/DccPlugin/Maya/" + $file; 30 //if (!`filetest -f $helpPath`) 31 //{ 32 // error ("Help file is not found: " + $helpPath); 33 //} 34 if (size($label) != 0) 35 { 36 $helpPath += "#" + $label; 37 } 38 $helpPath = "file:///" + $helpPath; 39 showHelp -a $helpPath; 40} 41 42/****************************************************************************** 43 get unix file path 44 convert "\" to "/" 45 multi-byte is supported for 8.5- 46******************************************************************************/ 47global proc string NW4C_GetUnixFilePath(string $path) 48{ 49 int $size = size($path); 50 string $dst = ""; 51 int $ic; 52 for ($ic = 1; $ic <= $size; ++$ic) 53 { 54 $c = substring($path, $ic, $ic); 55 if ($c == "\\") 56 { 57 $c = "/"; 58 } 59 $dst += $c; 60 } 61 return $dst; 62} 63 64/****************************************************************************** 65 set current directory from file 66 67 for fileBrowserDialog 68******************************************************************************/ 69global proc NW4C_SetCurDirFromFile(string $path) 70{ 71 if (size($path) == 0) 72 { 73 return; 74 } 75 76 string $projPath = `workspace -q -rd`; 77 string $dirPath = dirname($path); 78 string $checks[] = 79 { 80 $path, 81 $projPath + $path, 82 $dirPath, 83 $projPath + $dirPath 84 }; 85 86 for ($check in $checks) 87 { 88 if (`filetest -d $check`) 89 { 90 workspace -dir $check; 91 return; 92 } 93 } 94} 95