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

  1. // this script posts the lta world importer 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 LithTechWorldImportGetPath( string $buttonPath, string $dirPath, string $notUsed )
  23. {
  24.     textFieldButtonGrp -edit -fileName $dirPath $buttonPath;
  25. }
  26.  
  27. global proc LithTechWorldImportUpdateControls()
  28. {
  29.     int $useTexInfo = `checkBox -query -value useTexInfo`;
  30.     textFieldButtonGrp -edit -enable $useTexInfo baseTexPath;
  31.     radioButtonGrp -edit -enable $useTexInfo importTexTga;
  32.  
  33.     int $prefabs = `checkBox -query -value prefabs`;
  34.     textFieldButtonGrp -edit -enable $prefabs projectPath;
  35. }
  36.  
  37. global proc int LithTechWorldImportOptions ( string $parent, string $action, string $initialSettings, string $resultCallback )
  38. {
  39.     int $result = 0;
  40.     
  41.     if( $action == "post" )
  42.     {
  43.         setParent $parent;
  44.  
  45.         columnLayout -adjustableColumn true mainLayout;
  46.             floatFieldGrp -label "Scale:" -value1 1.0 -precision 3 scale;
  47.             checkBox -label "Import Objects" -align "left" -value off objects;
  48.             checkBox -label "Use LithTech Texture Information" -align "left" -value on -changeCommand "LithTechWorldImportUpdateControls" useTexInfo;
  49.             radioButtonGrp -numberOfRadioButtons 2 -labelArray2 "DTX" "TGA" -select 2 importTexTga;
  50.             string $texPathCtl = `textFieldButtonGrp -label "Base Texture Path:" -fileName "" -buttonLabel "..." baseTexPath`;
  51.             string $texPathButtonCmd = ( "fileBrowserDialog -m 4 -an \"\" -fc \"LithTechWorldImportGetPath " + $texPathCtl + "\"" );
  52.             textFieldButtonGrp -edit -buttonCommand $texPathButtonCmd baseTexPath;
  53.             checkBox -label "Import Prefabs as References" -align "left" -value on -changeCommand "LithTechWorldImportUpdateControls" prefabs;
  54.             string $projectPathCtl = `textFieldButtonGrp -label "Project Path:" -fileName "" -buttonLabel "..." projectPath`;
  55.             string $projectPathButtonCmd = ( "fileBrowserDialog -m 4 -an \"\" -fc \"LithTechWorldImportGetPath " + $projectPathCtl + "\"" );
  56.             textFieldButtonGrp -edit -buttonCommand $projectPathButtonCmd projectPath;
  57.  
  58.         // now set the current settings
  59.         string $currentOptions = $initialSettings;
  60.         string $optionList[];
  61.         string $optionBreakDown[];
  62.         int $index;
  63.  
  64.         if( size( $currentOptions ) > 0 )
  65.         {
  66.             tokenize( $currentOptions, ";", $optionList );
  67.  
  68.             for( $index = 0; $index < size($optionList); $index++ )
  69.             {
  70.                 tokenize( $optionList[$index], "=", $optionBreakDown );
  71.  
  72.                 if( $optionBreakDown[0] == "useTexInfo" )
  73.                 {
  74.                     int $optionIntValue = $optionBreakDown[1];
  75.                     checkBox -edit -value $optionIntValue useTexInfo;
  76.                 }
  77.                 else if( $optionBreakDown[0] == "objects" )
  78.                 {
  79.                     int $optionIntValue = $optionBreakDown[1];
  80.                     checkBox -edit -value $optionIntValue objects;
  81.                 }
  82.                 else if( $optionBreakDown[0] == "baseTexPath" )
  83.                 {
  84.                     textFieldButtonGrp -edit -fileName $optionBreakDown[1] baseTexPath;
  85.                 }
  86.                 else if( $optionBreakDown[0] == "scale" )
  87.                 {
  88.                     float $optionFloatValue = $optionBreakDown[1];
  89.                     floatFieldGrp -edit -value1 $optionFloatValue scale;
  90.                 }
  91.                 else if( $optionBreakDown[0] == "importTexDtx" )
  92.                 {
  93.                     int $optionIntValue = $optionBreakDown[1];
  94.                     radioButtonGrp -edit -select 1 importTexTga;
  95.                 }
  96.                 else if( $optionBreakDown[0] == "prefabs" )
  97.                 {
  98.                     int $optionIntValue = $optionBreakDown[1];
  99.                     checkBox -edit -value $optionIntValue prefabs;
  100.                 }
  101.                 else if( $optionBreakDown[0] == "projectPath" )
  102.                 {
  103.                     textFieldButtonGrp -edit -fileName $optionBreakDown[1] projectPath;
  104.                 }
  105.             }
  106.         }
  107.  
  108.         LithTechWorldImportUpdateControls;
  109.  
  110.         $result = 1;
  111.     }
  112.     else if( $action == "query" )
  113.     {
  114.         string $currentOptions;
  115.  
  116.         int $importTexDtxValue = `radioButtonGrp -query -select importTexTga`;
  117.  
  118.         $currentOptions += ( "objects=" + `checkBox -query -value objects` );
  119.         $currentOptions += ( ";useTexInfo=" + `checkBox -query -value useTexInfo` );
  120.         $currentOptions += ( ";baseTexPath=" + `textFieldButtonGrp -query -fileName baseTexPath` );
  121.         $currentOptions += ( ";scale=" + `floatFieldGrp -query -value1 scale` );
  122.         $currentOptions += ( ";importTexDtx=" + ($importTexDtxValue == 1) );
  123.         $currentOptions += ( ";prefabs=" + `checkBox -query -value prefabs` );
  124.         $currentOptions += ( ";projectPath=" + `textFieldButtonGrp -query -fileName projectPath` );
  125.         eval( $resultCallback + " \"" + $currentOptions + "\"" );
  126.  
  127.         $result = 1;
  128.     }
  129.  
  130.     return $result;
  131. }
  132.