home *** CD-ROM | disk | FTP | other *** search
/ GameStar Special 2004 January / GSSH0104TT.iso / Extras / Tron20 / tron_tools.exe / TRON_Tools / Tools / Plugins / LithTechWorldExportOptions.mel < prev    next >
Encoding:
Text File  |  2003-03-05  |  6.7 KB  |  171 lines

  1. // this script posts the lta world exporter file translator options.
  2. // the optionsString is of the form:
  3. //    varName1=value1;varName2=value2;...
  4. //
  5. // parameters:
  6. //    $parent - the elf parent layout for this options layout.
  7. //              it is always a scrollLayout.
  8. //    $action - the action that is to be performed with this invokation
  9. //              of this proc.  valid actions are:
  10. //                  "query" - construct the options string and pass
  11. //                            it to the resultCallback.
  12. //                  "post" - post all the elf controls.
  13. //    $initialSettings - the current options string in effect at the
  14. //                       time this script is invoked.
  15. //    $resultCallback - this is the proc to be called with the result
  16. //                      string.  resultCallback( string $optionsString )
  17. //
  18. // returns:
  19. //    1 if successful
  20. //    0 on failure
  21.  
  22. global proc LithTechWorldExportGetPath( string $buttonPath, string $dirPath, string $notUsed )
  23. {
  24.     textFieldButtonGrp -edit -fileName $dirPath $buttonPath;
  25. }
  26.  
  27. global proc LithTechWorldExportUpdateControls()
  28. {
  29.     int $exportAnimations = `checkBox -query -value exportAnimations`;
  30.     int $forceKeys = `checkBox -query -value forceKeys`;
  31.     int $bothTrue = $exportAnimations && $forceKeys;
  32.  
  33.     checkBox -edit -enable $exportAnimations forceKeys;
  34.     intFieldGrp -edit -enable $bothTrue forceKeysFrames;
  35.     checkBox -edit -enable $bothTrue includeKeys;
  36.     checkBox -edit -enable $exportAnimations externalKeys;
  37.  
  38.     int $externalKeys = `checkBox -query -value externalKeys`;
  39.     $bothTrue = $exportAnimations && $externalKeys;
  40.  
  41.     textFieldGrp -edit -enable $bothTrue keyPath;
  42.  
  43.     int $forceKeysFrames = `intFieldGrp -query -value1 forceKeysFrames`;
  44.     if( $forceKeysFrames < 1 )
  45.     {
  46.         intFieldGrp -edit -value1 1 forceKeysFrames;
  47.     }
  48. }
  49.  
  50. global proc int LithTechWorldExportOptions ( string $parent, string $action, string $initialSettings, string $resultCallback )
  51. {
  52.     int $result = 0;
  53.     
  54.     if( $action == "post" )
  55.     {
  56.         setParent $parent;
  57.  
  58.         columnLayout -adjustableColumn true mainLayout;
  59.             string $projPathCtl = `textFieldButtonGrp -label "Project Path:" -fileName "" -buttonLabel "..." projectPath`;
  60.             floatFieldGrp -label "Scale:" -value1 1.0 -precision 3 scale;
  61.             checkBox -label "Export As Detail Brushes" -align "left" -value on detailBrushes;
  62.             checkBox -label "Triangulate Brushes" -align "left" -value off triangulateBrushes;
  63.             checkBox -label "Use Maya Texture Information" -align "left" -value on useTextureInfo;
  64.             checkBox -label "Export Animated World Models" -align "left" -value off -changeCommand "LithTechWorldExportUpdateControls" exportAnimations;
  65.             checkBox -label "Force Keys" -align "left" -value off -changeCommand "LithTechWorldExportUpdateControls" forceKeys;
  66.             intFieldGrp -label "Every" -extraLabel "Frames" -value1 5 -changeCommand "LithTechWorldExportUpdateControls" forceKeysFrames;
  67.             checkBox -label "Include Defined Keys" -align "left" -value off includeKeys;
  68.             checkBox -label "Create External Key File" -align "left" -value off -changeCommand "LithTechWorldExportUpdateControls" externalKeys;
  69.             textFieldGrp -label "Path Offset:" -fileName "" keyPath;
  70.  
  71.         string $projPathButtonCmd = ( "fileBrowserDialog -m 4 -an \"\" -fc \"LithTechWorldExportGetPath " + $projPathCtl + "\"" );
  72.         textFieldButtonGrp -edit -buttonCommand $projPathButtonCmd projectPath;
  73.  
  74.         // now set the current settings
  75.         string $currentOptions = $initialSettings;
  76.         string $optionList[];
  77.         string $optionBreakDown[];
  78.         int $index;
  79.  
  80.         if( size( $currentOptions ) > 0 )
  81.         {
  82.             tokenize( $currentOptions, ";", $optionList );
  83.  
  84.             for( $index = 0; $index < size($optionList); $index++ )
  85.             {
  86.                 tokenize( $optionList[$index], "=", $optionBreakDown );
  87.  
  88.                 if( $optionBreakDown[0] == "useTextureInfo" )
  89.                 {
  90.                     int $optionIntValue = $optionBreakDown[1];
  91.                     checkBox -edit -value $optionIntValue useTextureInfo;
  92.                 }
  93.                 else if( $optionBreakDown[0] == "projectPath" )
  94.                 {
  95.                     textFieldButtonGrp -edit -fileName $optionBreakDown[1] projectPath;
  96.                 }
  97.                 else if( $optionBreakDown[0] == "scale" )
  98.                 {
  99.                     float $optionFloatValue = $optionBreakDown[1];
  100.                     floatFieldGrp -edit -value1 $optionFloatValue scale;
  101.                 }
  102.                 else if( $optionBreakDown[0] == "detailBrushes" )
  103.                 {
  104.                     int $optionIntValue = $optionBreakDown[1];
  105.                     checkBox -edit -value $optionIntValue detailBrushes;
  106.                 }
  107.                 else if( $optionBreakDown[0] == "triangulateBrushes" )
  108.                 {
  109.                     int $optionIntValue = $optionBreakDown[1];
  110.                     checkBox -edit -value $optionIntValue triangulateBrushes;
  111.                 }
  112.                 else if( $optionBreakDown[0] == "exportAnimations" )
  113.                 {
  114.                     int $optionIntValue = $optionBreakDown[1];
  115.                     checkBox -edit -value $optionIntValue exportAnimations;
  116.                 }
  117.                 else if( $optionBreakDown[0] == "forceKeys" )
  118.                 {
  119.                     int $optionIntValue = $optionBreakDown[1];
  120.                     checkBox -edit -value $optionIntValue forceKeys;
  121.                 }
  122.                 else if( $optionBreakDown[0] == "forceKeysFrames" )
  123.                 {
  124.                     int $optionIntValue = $optionBreakDown[1];
  125.                     intFieldGrp -edit -value1 $optionIntValue forceKeysFrames;
  126.                 }
  127.                 else if( $optionBreakDown[0] == "includeKeys" )
  128.                 {
  129.                     int $optionIntValue = $optionBreakDown[1];
  130.                     checkBox -edit -value $optionIntValue includeKeys;
  131.                 }
  132.                 else if( $optionBreakDown[0] == "externalKeys" )
  133.                 {
  134.                     int $optionIntValue = $optionBreakDown[1];
  135.                     checkBox -edit -value $optionIntValue externalKeys;
  136.                 }
  137.                 else if( $optionBreakDown[0] == "keyPath" )
  138.                 {
  139.                     textFieldGrp -edit -fileName $optionBreakDown[1] keyPath;
  140.                 }
  141.             }
  142.         }
  143.  
  144.         LithTechWorldExportUpdateControls;
  145.  
  146.         $result = 1;
  147.     }
  148.     else if( $action == "query" )
  149.     {
  150.         string $currentOptions;
  151.  
  152.         $currentOptions += ( "useTextureInfo=" + `checkBox -query -value useTextureInfo` );
  153.         $currentOptions += ( ";projectPath=" + `textFieldButtonGrp -query -fileName projectPath` );
  154.         $currentOptions += ( ";scale=" + `floatFieldGrp -query -value1 scale` );
  155.         $currentOptions += ( ";detailBrushes=" + `checkBox -query -value detailBrushes` );
  156.         $currentOptions += ( ";triangulateBrushes=" + `checkBox -query -value triangulateBrushes` );
  157.         $currentOptions += ( ";exportAnimations=" + `checkBox -query -value exportAnimations` );
  158.         $currentOptions += ( ";forceKeys=" + `checkBox -query -value forceKeys` );
  159.         $currentOptions += ( ";forceKeysFrames=" + `intFieldGrp -query -value1 forceKeysFrames` );
  160.         $currentOptions += ( ";includeKeys=" + `checkBox -query -value includeKeys` );
  161.         $currentOptions += ( ";externalKeys=" + `checkBox -query -value externalKeys` );
  162.         $currentOptions += ( ";keyPath=" + `textFieldGrp -query -fileName keyPath` );
  163.  
  164.         eval( $resultCallback + " \"" + $currentOptions + "\"" );
  165.  
  166.         $result = 1;
  167.     }
  168.  
  169.     return $result;
  170. }
  171.