home *** CD-ROM | disk | FTP | other *** search
/ Xentax forum attachments archive / xentax.7z / 11321 / CryRyseImport.7z / ui_.ms
Encoding:
Text File  |  2016-07-20  |  52.9 KB  |  1,412 lines

  1. --joqqyhez@gmail.com
  2.  
  3. --/////////////////////////////////////////  Notes /////////////////////////////////////// 
  4.  
  5. -- C:\Program Files (x86)\Crytek\CRYENGINE Launcher\Crytek\CRYENGINE_5.0\Code\CryEngine\CryCommon\CryFile.h:
  6. -- //////////////////////////////////////////////////////////////////////////
  7. -- // Defines for CryEngine filetypes extensions.
  8. -- //////////////////////////////////////////////////////////////////////////
  9. -- #define CRY_GEOMETRY_FILE_EXT                                        "cgf"
  10. -- #define CRY_SKEL_FILE_EXT                                                "chr" //will be a SKEL soon
  11. -- #define CRY_SKIN_FILE_EXT                                                "skin"
  12. -- #define CRY_CHARACTER_ANIMATION_FILE_EXT                     "caf"
  13. -- #define CRY_CHARACTER_DEFINITION_FILE_EXT                    "cdf"
  14. -- #define CRY_CHARACTER_LIST_FILE_EXT                              "cid"
  15. -- #define CRY_ANIM_GEOMETRY_FILE_EXT                               "cga"
  16. -- #define CRY_ANIM_GEOMETRY_ANIMATION_FILE_EXT             "anm"
  17. -- #define CRY_COMPILED_FILE_EXT                                        "(c)"
  18. -- #define CRY_BINARY_XML_FILE_EXT                                      "binxml"
  19. -- #define CRY_XML_FILE_EXT                                                 "xml"
  20. -- #define CRY_CHARACTER_PARAM_FILE_EXT                             "chrparams"
  21. -- #define CRY_GEOM_CACHE_FILE_EXT                                      "cax"
  22.  
  23. --////////////////////////////////////////////////////////////////////////////////////////
  24.  
  25. global g_scriptsDefault         = getdir #scripts
  26. global g_max_version             = ((MaxVersion())[1])/1000
  27.  
  28. if  g_max_version >= 19 then
  29. (
  30.     clearlistener()
  31.     
  32.     Format "Max Version: %\n" g_max_version
  33.     
  34.     ----------------------------------------------------------------------
  35.     resetMaxFile #noPrompt
  36.     actionMan.executeAction 0 "40829"             -- show statistics
  37.     actionMan.executeAction -844228238 "12"      -- Viewport Lighting and Shadows: High Quality
  38.     ----------------------------------------------------------------------
  39.     escapeEnable
  40.     ----------------------------------------------------------------------
  41.  
  42.     if GetQuietMode() then
  43.     (
  44.         SetQuietMode false --we want prompts enabled
  45.     )
  46.  
  47.     --//////////////////////////////// Script Checker (Runs on Startup ////////////////////////////////
  48.     --///////////////////////////////////////////////////////////////////////////////////////////////
  49.     ---------------------------------------- ini Global - hardcoded filename ----------------------------------------
  50.     global g_iniFileName                 = "cryimport_v3.ini"
  51.     global g_iniFile                         = (    pathConfig.ResolvePathSymbols (pathConfig.AppendPath     sysInfo.tempdir     g_iniFileName)    )
  52.     
  53.     --Create the ini file if it does not exist
  54.     if NOT doesfileexist ::g_iniFile then
  55.     (
  56.         try
  57.         (
  58.             global ini = createFile ::g_iniFile
  59.             close ini
  60.         )
  61.         catch
  62.         (
  63.             format "%" (getCurrentException())
  64.         )
  65.     )
  66.     
  67.     if doesfileexist ::g_iniFile then
  68.     (
  69.         -------------------------------------------------------------------------------------------------------------------    
  70.         global g_dirpath                 = "" -- Path to the GameSDK ( WITHOUT the slash \ or / )
  71.         global g_scriptRoot             = ""
  72.         global g_includePath         = ""    
  73.         fn delete_ini =
  74.         (
  75.             if NOT deleteFile ::g_iniFile then
  76.             (
  77.                 delIniSetting     ::g_iniFile     "paths" "scriptRoot"             ::g_scriptRoot
  78.                 delIniSetting     ::g_iniFile     "paths" "g_includePath"     ::g_includePath
  79.             )
  80.         )
  81.         --/////////////////////////////////////////////////////////////////////////////////////////
  82.         try
  83.         (
  84.             g_dirPath                     = getINISetting     ::g_iniFile     "paths"     "g_dirpath"
  85.             g_scriptRoot                 = getINISetting     ::g_iniFile     "paths"     "scriptRoot"
  86.             g_includePath                 = getINISetting     ::g_iniFile     "paths"     "g_includePath"
  87.             
  88.             setINISetting     ::g_iniFile         "paths"         "g_scriptsDefault"         ::g_scriptsDefault
  89.         )
  90.         catch
  91.         (
  92.             format "%" (getCurrentException())
  93.         )
  94.         --/////////////////////////////////////////////////////////////////////////////////////////
  95.         
  96.         
  97.         g_dirpath                         = getINISetting     g_iniFile     "paths" "g_dirpath"    
  98.         if g_dirpath == "" then
  99.         (
  100.             local set_dirPath = queryBox "You will now be asked to navigate to the root of your game folder (you will only do this once)...continue?"
  101.             
  102.             if set_dirPath then
  103.             (
  104.                 ::g_dirpath         = getSavePath caption:"Choose the Root for the Game (example \GameSDK\Ryse)"                    
  105.                 if ::g_dirpath != undefined AND pathConfig.isLegalPath g_dirpath then
  106.                 (
  107.                     setINISetting ::g_iniFile "paths" "g_dirpath" ::g_dirpath
  108.                 )
  109.                 else
  110.                 (
  111.                     ::g_dirpath             = ""
  112.                 )
  113.             )
  114.             else
  115.             (
  116.                 ::g_dirpath             = ""
  117.             )
  118.         )
  119.         -------------------------------------------------------------------------------------------------------------------
  120.  
  121.         if doesfileexist g_dirpath then
  122.         (
  123.             ::g_scriptRoot                 = getINISetting     ::g_iniFile     "paths"     "scriptRoot"
  124.             ::g_includePath                 = getINISetting     ::g_iniFile     "paths"     "g_includePath"
  125.  
  126.             if ::g_scriptRoot == "" OR ::g_includePath == ""  then
  127.             (
  128.                 local set_scriptPath = queryBox "Navigate to the folder which contains this script that you are just running(you will only do this once)...continue?" beep:true
  129.                 
  130.                 if set_scriptPath then
  131.                 (
  132.                     ::g_scriptRoot             = pathConfig.resolvePathSymbols ((getSavePath caption:"Choose Script Root Directory (the dir where you placed the scripts)" initialDir:sysinfo.currentDir))
  133.                     ::g_includePath             = pathConfig.resolvePathSymbols (::g_scriptRoot + "\\include")
  134.                     
  135.                     if ::g_scriptRoot != undefined AND ::g_includePath != undefined then
  136.                     (    
  137.                         if     doesFileExist ::g_includePath AND \            
  138.                             doesFileExist (    pathConfig.resolvePathSymbols (::g_scriptRoot + "\\ui_.ms")    ) then
  139.                         (
  140.                             setINISetting     ::g_iniFile     "paths" "scriptRoot"             ::g_scriptRoot
  141.                             setINISetting     ::g_iniFile     "paths" "g_includePath"     ::g_includePath
  142.                             
  143.                             messageBox "All set, you are now ready to go - all settings are saved" title:"Success" beep:false
  144.                         )
  145.                     )
  146.                     else
  147.                     (
  148.                         ::g_scriptRoot             = ""
  149.                         ::g_includePath             = ""
  150.                     )
  151.                 )
  152.                 else
  153.                 (
  154.                     ::g_scriptRoot             = ""
  155.                     ::g_includePath             = ""
  156.                 )
  157.             )
  158.         )
  159.         --/////////////////////////////////////////////////////////////////////////////////////////////////
  160.         --/////////////////////////////////////////////////////////////////////////////////////////////////
  161.  
  162.  
  163.         --////////////////////// Preprocessing - Checks that our includes do indeed exist //////////////////////
  164.         fn includes_Exist \
  165.                                 &includeDir: \                        
  166.                                 &include_files: = --we pass a pointer here
  167.         (
  168.             if symbolicPaths.isPathName "$scripts" then
  169.             (
  170.             )
  171.             else
  172.             (
  173.                 return false;
  174.             )
  175.             
  176.             local files = getFiles (includeDir + "*.*")
  177.             
  178.             for f in files do
  179.             (
  180.                 local fname = filenamefrompath f --strip the filename from the path (so we get only the filename + its suffix)
  181.                     
  182.                 for inclF in include_files do
  183.                 (
  184.                     --At least one fail, will be enough to terminate the whole execution of this importer script
  185.                     if (stricmp fname inclF) != 0 then
  186.                     (
  187.                         --//////////// We do a few backup checks, to keep it less rigorous and more tolerant ////////////
  188.                         local deepCheck = findItem files fname
  189.                         if deepCheck != 0 then
  190.                         (
  191.                             continue;
  192.                         )
  193.                         else --even less rigorous
  194.                         (
  195.                             local backupCheck = (matchpattern inclF pattern:"*"+fname+"*")
  196.                             if backupCheck then
  197.                             (
  198.                                 continue;
  199.                             )                        
  200.                         )
  201.                         --Being more tolerant than the above is not desired
  202.                         --///////////////////////////////////////////////////////////////////////////////////////////
  203.                         
  204.                         ------------------------------------------------ *** *** ***--------------------------------------------------
  205.                         --*** *** *** Every check failed and the script will not be able to continue, because reaching this point, will lead to dependencies loading failure! *** *** ***
  206.                         --*** *** *** This is serious, and will lead to a sure failure *** *** ***
  207.                         format "WARNING - We could not confirm the existence of the include files - execution will be aborted\n"                    
  208.                         return false;
  209.                         ------------------------------------------------ *** *** ***--------------------------------------------------
  210.                     )
  211.                 )            
  212.             )
  213.             --if we came here, then all the include files are present, and we can include them
  214.             return true;
  215.         )
  216.         --//////////////////////////////////////////////////////////////////////////////////////////////////
  217.  
  218.  
  219.         if     doesFileExist ::g_includePath AND \
  220.             doesFileExist ( pathConfig.resolvePathSymbols (::g_scriptRoot + "\\ui_.ms") ) AND \
  221.             (isDirectoryWriteable sysInfo.tempdir) then
  222.         (
  223.             try
  224.             (                
  225.                 ----------------------------------------------------
  226.                 --set the system script path to the chosen one (otherwise, the included files will not be found)
  227.                 if (setdir #scripts ::g_includePath)    then
  228.                 (
  229.                     ----------------------------------------------------                
  230.                     format "----------------- >::g_includePath: %\n" ::g_includePath
  231.                     format "----------------- > getdir #scripts: %\n" (getdir #scripts)
  232.                     --If we add more includes to our project (see include calls below), we must add them to this array as well
  233.                     local include_files = #(
  234.                                                     "HEADER_.ms", \
  235.                                                     "general_functions_.ms", \
  236.                                                     "build_resource_db_.ms", \
  237.                                                     "CryMat_XML_headers_.ms", \
  238.                                                     "CryMat_XML_.ms", \
  239.                                                             
  240.                                                     "create_bones_.ms", \
  241.                                                     "load_cryHeaders_.ms", \
  242.                                                     "load_cryFile_.ms", \                                            
  243.                                                     "CAF_headers_.ms", \
  244.                                                     "load_CAF_.ms", \
  245.                                                     "cryFile_btn_loader_.ms" \
  246.                                                 )    
  247.                                                 
  248.                     local FOUND_DEPENDENCIES = includes_Exist \
  249.                                                                                     includeDir:        &::g_includePath \
  250.                                                                                     include_files:    &include_files
  251.                         
  252.                     --Preprocessing - Checks that our includes do indeed exist        
  253.                     if FOUND_DEPENDENCIES AND \
  254.                         (getdir #scripts) == ::g_includePath  then
  255.                     (            
  256.                         --////////////////// Include //////////////////                        
  257.                         include "HEADER_.ms"
  258.                         include "general_functions_.ms"
  259.                         include "build_resource_db_.ms"
  260.                         include "CryMat_XML_headers_.ms"
  261.                         include "CryMat_XML_.ms"
  262.                         --////////////////////////////////////////////
  263.  
  264.                         try
  265.                         (
  266.                             --/////// Destroy dialogs and rollout clauses if applicable ///////                    
  267.                             if ::cryImport != undefined then
  268.                             (
  269.                                 if iskindof ::cryImport RolloutClass then
  270.                                 (
  271.                                     DestroyDialog             ::cryImport
  272.                                 )
  273.                             )
  274.                             if ::rollout_options != undefined then
  275.                             (
  276.                                 if iskindof ::rollout_options RolloutClass then
  277.                                 (
  278.                                     DestroyDialog             ::rollout_options
  279.                                 )
  280.                             )
  281.                             if ::rollout_Report != undefined then
  282.                             (
  283.                                 if iskindof ::rollout_Report RolloutClass then
  284.                                 (
  285.                                     DestroyDialog             ::rollout_Report
  286.                                 )
  287.                             )
  288.                             if ::rollout_animation != undefined then
  289.                             (
  290.                                 if iskindof ::rollout_animation RolloutClass then
  291.                                 (
  292.                                     DestroyDialog             ::rollout_animation
  293.                                 )
  294.                             )
  295.                             if ::rollout_About != undefined then
  296.                             (
  297.                                 if iskindof ::rollout_About RolloutClass then
  298.                                 (
  299.                                     DestroyDialog             ::rollout_About
  300.                                 )
  301.                             )
  302.                             if ::rollout_Alert != undefined then
  303.                             (
  304.                                 if iskindof ::rollout_Alert RolloutClass then
  305.                                 (
  306.                                     DestroyDialog             ::rollout_Alert
  307.                                 )
  308.                             )
  309.                             ----------------------------The Rollout Floater ----------------------------
  310.                             if ::CRYOP != undefined then
  311.                             (
  312.                                 if iskindof ::CRYOP RolloutFloater then
  313.                                 (
  314.                                     closeRolloutFloater              ::CRYOP
  315.                                 )
  316.                             )
  317.                             --//// End of  Destroy dialogs and rollout clauses if applicable ////                        
  318.                         )
  319.                         catch
  320.                         (
  321.                             format "\n*** *** *** *** *** *** Could not destroy dialogs *** *** *** *** *** ***\n"
  322.                             format "%" (getCurrentException())
  323.                             format "*** *** *** *** *** *** END OF Could not destroy dialogs *** *** *** *** *** *** ***\n"
  324.                         )
  325.  
  326.                         rollout cryImport "Cryengine Importer" width:290 height:170 category:3
  327.                         (
  328.                             label 'lbl_version' "Cryengine Importer v 1.0" pos:[20,8] width:130 height:19 align:#left
  329.                             button 'btn_gameDir' "Set Game Directory (GameSDK)..." pos:[8,37] width:265 height:25 toolTip:"This must be the root of your GameSDK for example ...\GameSDK\Ryse (note - do this only if you want to change the dir, this should be set correctly already" align:#left
  330.                             button 'btn_Set_SkeletonListXML' "Set SkeletonList.xml..." pos:[8,62] width:265 height:25 toolTip:"This is done automatically - Default for example is ...\GameSDK\Ryse\Animations\SkeletonList.xml" align:#left
  331.                             label 'lbl_skeletonList_Loaded' "" pos:[11,89] width:260 height:17 align:#left
  332.                             button 'btn_import' "LOAD CryFile..." pos:[8,118] width:265 height:40 toolTip:"Load CryFile (.cgf, .cgfm, .chr, .chrm, .skin, .skinm)" align:#left
  333.                             button 'btn_view_ini' "View ini" pos:[177,4] width:96 height:25 align:#left
  334.                             button 'btn_delete_ini' "del" pos:[152,4] width:25 height:25 align:#left tooltip:"Delete ini file" images:#((    (getdir #maxSysIcons) + "Dark\\Grips\\Cancel_24.png"    ), (    (getdir #maxSysIcons) + "Dark\\Grips\\Cancel_24.png"    ), 1, 1, 1, 1, 1, false)
  335.                             button 'btn_Load_CDF' "LOAD Character Definition..." pos:[8,158] width:265 height:40 toolTip:"This loads the Character Definition File ( .cdf )" align:#left                            
  336.                             checkbox 'chk_deleteISOvertices' "Delete Isolated Vertices" pos:[13,200] width:259 height:19 enabled:true checked:false align:#left                            
  337.                             checkbox 'chk_Dont_Load_Skeleton' "Don't Load Skeleton" pos:[13,220] width:259 height:19 enabled:true checked:false align:#left
  338.                             checkbox 'chk_Skip_LOD_Materials' "Skip $Lod Materials" pos:[13,240] width:252 height:19 enabled:true checked:true align:#left                
  339.                             button 'btn_xmlB_Reader' "xmlB Reader..." pos:[8,270] width:133 height:25 toolTip:"Examine an xmlB file" align:#left
  340.                             button 'btn_CAF_reader' "CAF Reader..." pos:[142,270] width:133 height:25 enabled:false toolTip:"Not implemented yet" align:#left
  341.                             GroupBox 'grp_db_builder' "Database Builder" pos:[9,303] width:265 height:75 align:#left
  342.                             button 'btn_build_mtl_db' "Build .mtl db" pos:[20,320] width:121 height:25 toolTip:"Build an .mtl database" align:#left
  343.                             button 'btn_build_tif_db' "Build .tif db" pos:[142,320] width:121 height:25 toolTip:"Build a .tif database" align:#left
  344.                             button 'btn_build_dds_db' "Build .dds db" pos:[20,345] width:121 height:25 toolTip:"Build a .dds0 database" align:#left
  345.                             dropdownList 'ddl_CryGame' "CryEngine Game" pos:[8,390] width:265 height:40 items:#("Ryse", "Crysis", "Crysis 2", "Crysis 3", "Crysis Warhead", "Crysis Wars", "State of Decay") align:#left enabled:false                                
  346.                             
  347.                                 
  348.                                 
  349.                             --////////////////// Include //////////////////
  350.                             include "create_bones_.ms"
  351.                             include "load_cryHeaders_.ms"
  352.                             include "load_cryFile_.ms"
  353.                                 
  354.                             include "CAF_headers_.ms"
  355.                             include "load_CAF_.ms"
  356.                             include "cryFile_btn_loader_.ms"
  357.                             --/////////////////////////////////////////////
  358.                             
  359.                             fn db_creation_ask \
  360.                                                         &db_type: =
  361.                             (    
  362.                                 local db_filename = (db_type as string) +"_db.txt"
  363.                                 
  364.                                 local confirm = #no    
  365.                                 if doesfileexist (pathConfig.resolvePathSymbols (pathConfig.AppendPath (pathConfig.AppendPath ::g_scriptRoot "\\db") db_filename)) then
  366.                                 (
  367.                                     confirm = yesNoCancelBox (db_filename + " already exists - continue?") \
  368.                                                                             title:"WARNING" \
  369.                                                                             beep:true
  370.                                 )
  371.                                 else
  372.                                 (
  373.                                     confirm = #yes
  374.                                 )
  375.                                 
  376.                                 if confirm == #yes then
  377.                                 (
  378.                                     ::g_db_type = db_type
  379.                                     inst_build_resource_db             = build_resource_db() --create instance
  380.                                     inst_build_resource_db.builder \
  381.                                                                                 g_db_type: &::g_db_type
  382.                                 )
  383.                             )
  384.                             
  385.                             on cryImport open do
  386.                             (                                
  387.                                 if ::g_auto_resourcelist_array.count == 0 then
  388.                                 (
  389.                                     ::g_auto_resourcelist_array = getFilesRecursive \
  390.                                                                                                     root:            (::g_dirPath) \
  391.                                                                                                     specDir:        "Levels" \
  392.                                                                                                     targetFile:    "auto_resourcelist.txt"
  393.                                 )
  394.                                 
  395.                                 if (setdir #scripts ::g_scriptsDefault) then
  396.                                 (
  397.                                     format "Current Scripts Dir set to #scripts: %\n" (getdir #scripts)
  398.                                 )
  399.                                 else
  400.                                 (
  401.                                     format "Current #scripts dir: %\n" (getdir #scripts)
  402.                                 )
  403.                                 
  404.                                 format "-----------------------------::g_scriptRoot: % -----------------------------\n" ::g_scriptRoot
  405.                                 
  406.                                 ::g_CryGame_dropDown_selection     = ddl_CryGame.items[ddl_CryGame.selection]
  407.                                 ::g_skip_Lod_Materials                    = chk_skip_Lod_Materials.state
  408.                                 ::g_Dont_Load_Skeleton                = chk_Dont_Load_Skeleton.state
  409.                                 ::g_dirpath                                     = getINISetting ::g_iniFile "paths" "g_dirpath"
  410.                                 
  411.                                 local skeleton_xml_path = ""                    
  412.                                 
  413.                                 --////////////////////////// Set SkeletonList.xml and also attempt to read it into an array ///////////////////////////
  414.                                 if pathConfig.isLegalPath ::g_dirpath then
  415.                                 (
  416.                                     local skeleton_xml_path         = pathConfig.appendPath     ::g_dirpath         ::g_SkeletonList_xml_NAME                        
  417.                                     
  418.                                     if skeleton_xml_path != undefined then
  419.                                     (
  420.                                         format "Will try to find and read: %\n" skeleton_xml_path
  421.                                         
  422.                                         if doesfileexist skeleton_xml_path then
  423.                                         (
  424.                                             setINISetting     ::g_iniFile     "paths" "SkeletonList"     skeleton_xml_path                    
  425.                                             
  426.                                             inst_xmlB_PROCESSOR = xmlB_PROCESSOR()
  427.                                             --XML
  428.                                             if (stricmp (getFilenameType skeleton_xml_path) ".xml") == 0 then
  429.                                             (
  430.                                                 if Binary_XML_check skeleton_xml_path then
  431.                                                 (
  432.                                                     global g_inst_stored_SkeletonList_XML    = stored_SkeletonList_XML ()    
  433.                                                     format "Attempting to read: %\n" (getFilenameType skeleton_xml_path)
  434.                                                     inst_xmlB_PROCESSOR.cry_general_xmlB_ReaderV \
  435.                                                                                                                         xmlBFile:                    skeleton_xml_path \
  436.                                                                                                                         inst_s_OPTIONS:        inst_s_OPTIONS \
  437.                                                                                                                         type:                        ".xml"
  438.                                                     
  439.                                                     skeleton_xml_path = ""
  440.                                                     ::cryImport.lbl_skeletonList_Loaded.text = "Skeleton List has been loaded"
  441.                                                 )
  442.                                                 else
  443.                                                 (
  444.                                                     format "This is not a valid xmlB file, aborting!: %\n" skeleton_xml_path
  445.                                                     ::cryImport.lbl_skeletonList_Loaded.text = "Could not locate the Skeleton List"
  446.                                                 )
  447.                                             )
  448.                                             else
  449.                                             (
  450.                                                 format "The suffix of the SkeletonList is not .xml: %\n" skeleton_xml_path
  451.                                                 ::cryImport.lbl_skeletonList_Loaded.text = "Could not locate the Skeleton List"
  452.                                             )
  453.                                         )
  454.                                         else
  455.                                         (
  456.                                             format "Cannot find: %\n" skeleton_xml_path
  457.                                             ::cryImport.lbl_skeletonList_Loaded.text = "Could not locate the Skeleton List"
  458.                                         )
  459.                                     )
  460.                                     else
  461.                                     (
  462.                                         format "Could not find: %\n" skeleton_xml_path
  463.                                         ::cryImport.lbl_skeletonList_Loaded.text = "Could not locate the Skeleton List"
  464.                                     )            
  465.                                 )
  466.                                 --///////////////////////////////////////////////////////////////////////////////////////////////////////////////////        
  467.                                 
  468.                                 format "g_skip_Lod_Materials: %\n"                             ::g_skip_Lod_Materials
  469.                                 format "\nGame selected: --------- % ---------\n"         ::g_CryGame_dropDown_selection
  470.                                 format "Skeleton List Path: %\n"                                 (pathConfig.appendPath ::g_dirpath ::g_SkeletonList_xml_NAME)
  471.                                 format "g_Dont_Load_Skeleton: %\n"                             ::g_Dont_Load_Skeleton
  472.                                 format "======= GameSDK path: % =======\n"             ::g_dirpath
  473.                             )
  474.                             on cryImport close do
  475.                             (
  476.                                 if (setdir #scripts ::g_scriptsDefault) then
  477.                                 (
  478.                                     format "Current Scripts Dir set to #scripts: %\n" (getdir #scripts)
  479.                                 )
  480.                                 else
  481.                                 (
  482.                                     format "Current #scripts dir: %\n" (getdir #scripts)
  483.                                 )
  484.                             )
  485.                             on cryImport rolledUp state do
  486.                             (
  487.                                 if NOT state then
  488.                                 (
  489.                                     --closed
  490.                                     CRYOP.size = [CRYOP.size[1], CRYOP.size[2]-cryImport.height]
  491.                                 )
  492.                                 else
  493.                                 (
  494.                                     --open
  495.                                     CRYOP.size = [CRYOP.size[1], CRYOP.size[2]+cryImport.height]
  496.                                 )
  497.                             )                        
  498.                             on btn_delete_ini pressed do
  499.                             (
  500.                                 if (queryBox "This will delete your settings, are you sure you want to continue?") then
  501.                                 (
  502.                                     if (deleteFile ::g_iniFile) then
  503.                                     (
  504.                                         format "% deleted!\n" ::g_iniFile
  505.                                     )
  506.                                     else
  507.                                     (
  508.                                         format "Could not delete % \n" ::g_iniFile
  509.                                     )
  510.                                 )
  511.                             )
  512.                             on btn_gameDir pressed do
  513.                             (
  514.                                 startDir = undefined
  515.                             
  516.                                 g_dirpath             = getINISetting ::g_iniFile "paths" "g_dirpath"
  517.                             
  518.                                 if pathConfig.isLegalPath g_dirpath then
  519.                                 (
  520.                                     startDir = g_dirpath
  521.                                     ::g_dirpath         = getSavePath caption:"Choose Game directory" initialDir:startDir
  522.                                 )
  523.                                 else
  524.                                 (
  525.                                     ::g_dirpath         = getSavePath caption:"Choose Game directory"
  526.                                 )
  527.                                 
  528.                                 --Reread Skeleton List
  529.                                 if ::g_dirpath != undefined then
  530.                                 (
  531.                                     if pathConfig.isLegalPath g_dirpath  then
  532.                                     (
  533.                                         setINISetting ::g_iniFile "paths" "g_dirpath" ::g_dirpath                                    
  534.                                         local skeleton_xml_path         = pathConfig.appendPath     ::g_dirpath         ::g_SkeletonList_xml_NAME                        
  535.                                         
  536.                                         if skeleton_xml_path != undefined then
  537.                                         (
  538.                                             format "Will try to find and read: %\n" skeleton_xml_path
  539.                                             
  540.                                             if doesfileexist skeleton_xml_path then
  541.                                             (
  542.                                                 setINISetting     ::g_iniFile     "paths" "SkeletonList"     skeleton_xml_path                    
  543.                                                 
  544.                                                 inst_xmlB_PROCESSOR = xmlB_PROCESSOR()
  545.                                                 --XML
  546.                                                 if (stricmp (getFilenameType skeleton_xml_path) ".xml") == 0 then
  547.                                                 (
  548.                                                     if Binary_XML_check skeleton_xml_path then
  549.                                                     (
  550.                                                         ::g_inst_stored_SkeletonList_XML    = stored_SkeletonList_XML ()    
  551.                                                         format "Attempting to read: %\n" (getFilenameType skeleton_xml_path)
  552.                                                         inst_xmlB_PROCESSOR.cry_general_xmlB_ReaderV \
  553.                                                                                                                             xmlBFile:                    skeleton_xml_path \
  554.                                                                                                                             inst_s_OPTIONS:        inst_s_OPTIONS \
  555.                                                                                                                             type:                        ".xml"
  556.                                                         
  557.                                                         skeleton_xml_path = ""
  558.                                                         ::cryImport.lbl_skeletonList_Loaded.text = "Skeleton List has been loaded"
  559.                                                     )    
  560.                                                 )            
  561.                                             )
  562.                                         )
  563.                                     )
  564.                                 )
  565.                                 
  566.                             )
  567.                             on btn_Set_SkeletonListXML pressed do
  568.                             (
  569.                                 startDir = undefined
  570.                                 ::g_dirpath = getINISetting ::g_iniFile "paths" "g_dirpath"
  571.                             
  572.                                 if pathConfig.isLegalPath ::g_dirpath then
  573.                                 (
  574.                                     startDir = ::g_dirpath
  575.                                     
  576.                                     SkeletonList_xml_PATH = getOpenFileName \
  577.                                     caption:"cgf/chr/cgfm Model File" \
  578.                                     types:"CryTek Model File (*.xml)|*.xml" historyCategory:"CryTek ObjectPresets" initialDir:startDir
  579.                                     
  580.                                     if SkeletonList_xml_PATH != undefined then
  581.                                     (
  582.                                         if doesfileexist SkeletonList_xml_PATH then
  583.                                         (
  584.                                             setINISetting     ::g_iniFile     "paths" "SkeletonList"     SkeletonList_xml_PATH                        
  585.                                             ::g_SkeletonList_xml_NAME = filenameFromPath SkeletonList_xml_PATH
  586.                                         )
  587.                                     )
  588.                                 )
  589.                                 else
  590.                                 (
  591.                                     ::g_dirpath = getSavePath caption:"Choose Game directory"
  592.                                     
  593.                                     if ::g_dirpath != undefined AND pathConfig.isLegalPath g_dirpath then
  594.                                     (
  595.                                         setINISetting ::g_iniFile "paths" "g_dirpath" ::g_dirpath
  596.                                         
  597.                                         startDir = ::g_dirpath
  598.                                         
  599.                                         SkeletonList_xml_PATH = getOpenFileName \
  600.                                         caption:"cgf/chr/cgfm Model File" \
  601.                                         types:"CryTek Model File (*.xml)|*.xml" historyCategory:"CryTek ObjectPresets" initialDir:startDir
  602.                                         
  603.                                         if SkeletonList_xml_PATH != undefined then
  604.                                         (
  605.                                             if doesfileexist SkeletonList_xml_PATH then
  606.                                             (
  607.                                                 setINISetting     ::g_iniFile     "paths" "SkeletonList"     SkeletonList_xml_PATH                        
  608.                                                 ::g_SkeletonList_xml_NAME = filenameFromPath SkeletonList_xml_PATH
  609.                                             )                    
  610.                                         )
  611.                                     )
  612.                                 )
  613.                             )
  614.                             on btn_import pressed do
  615.                             (
  616.                                 Reset_Arrays()
  617.                                 
  618.                                 g_dirpath = getINISetting ::g_iniFile "paths" "g_dirpath"
  619.                                 
  620.                                 if NOT (doesfileexist g_dirpath) then
  621.                                 (
  622.                                     confirm = yesNoCancelBox "You must choose a root game directory, do you want to do it now?" \
  623.                                                                         title:"WARNING" \
  624.                                                                         beep:true        
  625.                                     if confirm == #yes then
  626.                                     (
  627.                                         g_dirpath = getSavePath caption:"Choose Game directory"
  628.                                         
  629.                                         if g_dirpath != undefined AND pathConfig.isLegalPath g_dirpath then
  630.                                         (
  631.                                             setINISetting ::g_iniFile "paths" "g_dirpath" ::g_dirpath
  632.                                         )
  633.                                     )
  634.                                 )                    
  635.                                 else
  636.                                 (
  637.                                     g_cryFile = getOpenFileName \
  638.                                     caption:"cgf/chr/cgfm Model File" \
  639.                                     types:"CryTek Model File (*.cgf)|*.cgf|(*.cgfm)|*.cgfm|(*.chr)|*.chr|(*.cdf)|*.cdf| \
  640.                                     (*.skin)|*.skin|(*.skinm)|*.skinm|(*.chrm)|*.chrm|(*.caf)|*.caf|(*.img)|*.img|All (*.*)|*.*" \
  641.                                     historyCategory:"CryTek ObjectPresets"
  642.                                     
  643.                                     if ddl_CryGame.selected == "Ryse" then
  644.                                     (
  645.                                         if g_cryFile != undefined then
  646.                                         (
  647.                                             if doesfileexist g_cryFile then
  648.                                             (
  649.                                                 if ((getFilenameType g_cryFile) == ".cgf") OR ((getFilenameType g_cryFile) == ".cgfm") then
  650.                                                 (
  651.                                                     if  NOT (Binary_CryTek_check File:g_cryFile) then --if the xml file is not Crytek Binary XML
  652.                                                     (
  653.                                                         format "This is not a valid CryTek file, aborting!\n"
  654.                                                     )
  655.                                                     else
  656.                                                     (
  657.                                                         setINISetting     ::g_iniFile     "boneinfo" "has_bones"     "0"                    
  658.                                                         cryFile_loader g_cryFile:g_cryFile
  659.                                                     )                    
  660.                                                 )
  661.                                                 else if ((getFilenameType g_cryFile) == ".skin") OR ((getFilenameType g_cryFile) == ".skinm") then
  662.                                                 (
  663.                                                     if  NOT (Binary_CryTek_check File:g_cryFile) then --if the xml file is not Crytek Binary XML
  664.                                                     (
  665.                                                         format "This is not a valid CryTek file, aborting!\n"
  666.                                                     )
  667.                                                     else
  668.                                                     (
  669.                                                         cryFile_loader g_cryFile:g_cryFile
  670.                                                     )                            
  671.                                                 )
  672.                                                 else if ((getFilenameType g_cryFile) == ".chr") OR ((getFilenameType g_cryFile) == ".chrm") then
  673.                                                 (
  674.                                                     if  NOT (Binary_CryTek_check File:g_cryFile) then --if the xml file is not Crytek Binary XML
  675.                                                     (
  676.                                                         format "This is not a valid CryTek file, aborting!\n"
  677.                                                     )
  678.                                                     else
  679.                                                     (
  680.                                                         cryFile_loader g_cryFile:g_cryFile
  681.                                                     )
  682.                                                 )
  683.                                                 else if ((getFilenameType g_cryFile) == ".caf") then
  684.                                                 (
  685.                                                     if  NOT (Binary_CryTek_check File:g_cryFile) then --if the xml file is not Crytek Binary XML
  686.                                                     (
  687.                                                         format "This is not a valid CryTek file, aborting!\n"
  688.                                                     )
  689.                                                     else
  690.                                                     (
  691.                                                         cryFile_loader \
  692.                                                                             g_cryFile:    g_cryFile \
  693.                                                                             caller:        (getFilenameType g_cryFile)
  694.                                                     )
  695.                                                 )
  696.                                                 else if ((getFilenameType g_cryFile) == ".img") then
  697.                                                 (
  698.                                                     if  NOT (Binary_CryTek_check File:g_cryFile) then --if the xml file is not Crytek Binary XML
  699.                                                     (
  700.                                                         format "This is not a valid CryTek file, aborting!\n"
  701.                                                     )
  702.                                                     else
  703.                                                     (
  704.                                                         cryFile_loader \
  705.                                                                             g_cryFile:    g_cryFile \
  706.                                                                             caller:        (getFilenameType g_cryFile)
  707.                                                     )
  708.                                                 )
  709.                                                 else if (getFilenameType g_cryFile) == ".cdf" then
  710.                                                 (
  711.                                                     if  NOT (Binary_XML_check g_cryFile) then --if the xml file is not Crytek Binary XML
  712.                                                     (
  713.                                                         format "This is not a valid CryXmlB file, aborting!\n"
  714.                                                     )
  715.                                                     else
  716.                                                     (
  717.                                                         cryxmlB_loader \
  718.                                                                                 g_MaterialRef_Bool: &g_MaterialRef_Bool
  719.                                                     )                
  720.                                                 )
  721.                                             )
  722.                                         )
  723.                                     )
  724.                                     else if ddl_CryGame.selected == "Crysis" then
  725.                                     (
  726.                                         if doesfileexist g_cryFile then
  727.                                         (
  728.                                             if ((getFilenameType g_cryFile) == ".cgf") then
  729.                                             (
  730.                                                 if  NOT (Binary_CryTek_check File:g_cryFile) then --if the xml file is not Crytek Binary XML
  731.                                                 (
  732.                                                     format "This is not a valid CryTek file, aborting!\n"
  733.                                                 )
  734.                                                 else
  735.                                                 (            
  736.                                                     cryFile_Crysis_loader g_cryFile:g_cryFile
  737.                                                 )                    
  738.                                             )
  739.                                         )
  740.                                         
  741.                                     )
  742.                                 )
  743.                             )
  744.                             on btn_view_ini pressed do
  745.                             (
  746.                                 try
  747.                                 (
  748.                                     ShellLaunch "notepad.exe" ::g_iniFile
  749.                                 )
  750.                                 catch()
  751.                             )
  752.                             on btn_Load_CDF pressed do
  753.                             (
  754.                                 Reset_Arrays()
  755.                                 
  756.                                 ::g_db_type = "mtl" --we set the default mtl library
  757.                                 
  758.                                 g_dirpath = getINISetting ::g_iniFile "paths" "g_dirpath"
  759.                                 
  760.                                 if NOT (doesfileexist g_dirpath) then
  761.                                 (
  762.                                     confirm = yesNoCancelBox "You must choose a root game directory, do you want to do it now?" \
  763.                                                                         title:"WARNING" \
  764.                                                                         beep:true        
  765.                                     if confirm == #yes then
  766.                                     (
  767.                                         ::g_dirpath = getSavePath caption:"Choose Game directory"
  768.                                     )
  769.                                 )                    
  770.                                 else
  771.                                 (
  772.                                     g_cryFile = getOpenFileName \
  773.                                     caption:"cgf/chr/cgfm Model File" \
  774.                                     types:"CryTek Character Definition File (*.cdf)|*.cdf|(*.chrparams)|*.chrparams|(*.xml)|*.xml|All (*.*)|*.*" \
  775.                                     historyCategory:"CryTek ObjectPresets"
  776.                                     
  777.                                     if g_cryFile != undefined then
  778.                                     (            
  779.                                         if doesfileexist g_cryFile then
  780.                                         (
  781.                                             if (stricmp (getFilenameType g_cryFile) ".cdf" ) == 0 OR \
  782.                                                 (stricmp (getFilenameType g_cryFile) ".chrparams" ) == 0 then
  783.                                             (
  784.                                                 if  (Binary_XML_custom_check file:g_cryFile type:"CryXmlB") then --if the xml file is not Crytek Binary XML                
  785.                                                 (
  786.                                                     cryFile_CDF_loader g_cryFile:g_cryFile                                                
  787.                                                 )
  788.                                                 else
  789.                                                 (
  790.                                                     format "This is not a valid CryXmlB file, aborting!\n"
  791.                                                 )
  792.                                             )
  793.                                             else
  794.                                             (
  795.                                                 format "Seem that this is not a valid CDF file, aborting! \nIf you are trying to read an xmlB file, then use the button \"xmlB Reader...\" instead.\n"
  796.                                             )
  797.                                         )
  798.                                     )
  799.                                 )
  800.                             )
  801.                             on chk_deleteISOvertices changed arg do
  802.                             (
  803.                                 format "% chk_deleteISOvertices\n" arg
  804.                             )
  805.                             on chk_Dont_Load_Skeleton changed arg do
  806.                             (
  807.                                 ::g_Dont_Load_Skeleton = chk_Dont_Load_Skeleton.state
  808.                                 
  809.                                 format "% g_Dont_Load_Skeleton\n"             ::g_Dont_Load_Skeleton
  810.                             )
  811.                             on chk_Skip_LOD_Materials changed arg do
  812.                             (
  813.                                 ::g_skip_Lod_Materials = chk_Skip_LOD_Materials.state
  814.                                 
  815.                                 format "% g_skip_Lod_Materials\n"             ::g_skip_Lod_Materials
  816.                             )
  817.                             on btn_xmlB_Reader pressed do
  818.                             (
  819.                                 g_dirpath = getINISetting ::g_iniFile "paths" "g_dirpath"
  820.                                 
  821.                                 if NOT (doesfileexist g_dirpath) then
  822.                                 (
  823.                                     confirm = yesNoCancelBox "You must choose a root game directory, do you want to do it now?" \
  824.                                                                         title:"WARNING" \
  825.                                                                         beep:true
  826.                                 
  827.                                     if confirm == #yes then
  828.                                     (
  829.                                         ::g_dirpath = getSavePath caption:"Choose Game directory"
  830.                                     )
  831.                                 )
  832.                                 
  833.                                 g_cryFile = getOpenFileName \
  834.                                 caption:"cgf/chr/cgfm Model File" \
  835.                                 types:"CryTek MTL (*.mtl)|*.mtl|(*.xml)|*.xml|(*.cdf)|*.cdf|(*.chrparams)|*.chrparams| \
  836.                                 All (*.*)|*.*" \
  837.                                 historyCategory:"CryTek ObjectPresets"
  838.                                 
  839.                                 if ::g_cryFile != undefined AND doesfileexist g_cryFile then
  840.                                 (                                
  841.                                     ::g_xmlB_Report_v2 = true --override report setting
  842.                                     -----------------------------------------------
  843.                                     
  844.                                     setINISetting ::g_iniFile "paths" "last_loaded" g_cryFile
  845.                                     
  846.                                     cryxmlB_loader \
  847.                                                         g_MaterialRef_Bool:        &g_MaterialRef_Bool \
  848.                                     
  849.                                     ------------------------------------------------
  850.                                     ::g_xmlB_Report_v2 = true = false
  851.                                 )
  852.                                 
  853.                                 
  854.                             )
  855.                             on btn_CAF_reader pressed do
  856.                             (
  857.                                 --Not implemented yet
  858.                             )
  859.                             on btn_build_mtl_db pressed do
  860.                             (
  861.                                 ::g_db_type = "mtl"
  862.                                 db_creation_ask \
  863.                                                         db_type: &::g_db_type
  864.                             )
  865.                             on btn_build_tif_db pressed do
  866.                             (
  867.                                 ::g_db_type = "tif"                                
  868.                                 db_creation_ask \
  869.                                                         db_type: &::g_db_type
  870.                             )
  871.                             on btn_build_dds_db pressed do
  872.                             (
  873.                                 ::g_db_type = "dds.0"
  874.                                 db_creation_ask \
  875.                                                         db_type: &::g_db_type
  876.                             )                        
  877.                             on ddl_CryGame selected arg do
  878.                             (
  879.                                 ::g_CryGame_dropDown_selection = ddl_CryGame.items[arg]
  880.                                 format "% selected\n" ::g_CryGame_dropDown_selection
  881.                             )
  882.                         )
  883.                         
  884.                         rollout rollout_options "Material Options" width:290 height:100 category:1
  885.                         (
  886.                             checkbox 'chk_BuildMaterial' "Build Material" pos:[15,5] width:265 height:16 checked:true align:#left
  887.                             checkbox 'chk_Physical_Material' "Physical Material" pos:[15,35] width:248 height:22 checked:true enabled:false toolTip:"If unchecked, Standard Material is used instead (NOT recommended, because it is still highly VIP - Keep it physical)" align:#left
  888.                             checkbox 'chk_UVW_Flip_V' "UVW - Flip V" pos:[15,55] width:107 height:16 checked:true align:#left        
  889.                             GroupBox 'grp_Options' "Texture Rename" pos:[9,85] width:265 height:55 align:#left
  890.                             checkbox 'chk_dds' "Rename .tif* to .dds" pos:[17,105] width:114 height:21 enabled:true checked:true align:#left
  891.                             spinner 'spn_Spec_Map_Amount' "Specular Map Output Amount: " pos:[15,155] width:112 height:16 enabled:false range:[-100,100,-17] type:#float scale:0.1 align:#left
  892.                             spinner 'spn_displacement_map_amt' "Displacement Map Amount: " pos:[15,175] width:112 height:16 enabled:false range:[-100,100,0.1] type:#float scale:0.1 align:#left
  893.                             checkbox 'chk_PhysMat_SSS' "Use Subsurface Scattering / Skin Shader" pos:[15,210] width:265 height:16 checked:false align:#left
  894.                             checkbox 'chk_deepSearch' "Use Deep Search" pos:[15,230] width:265 height:16 checked:true align:#left
  895.                             checkbox 'chk_quickMTL_Match' "Use Quick .mtl Match" pos:[15,250] width:265 height:16 checked:true align:#left
  896.                             checkbox 'chk_MaterialRef' "MaterialRef" pos:[15,270] width:265 height:16 checked:true align:#left
  897.                             
  898.                             on rollout_options open do
  899.                             (                                
  900.                                 if (setdir #scripts ::g_scriptsDefault) then
  901.                                 (
  902.                                     format "Current Scripts Dir set to #scripts: %\n" (getdir #scripts)
  903.                                 )
  904.                                 else
  905.                                 (
  906.                                     format "Current #scripts dir: %\n" (getdir #scripts)
  907.                                 )
  908.                                 
  909.                                 ::g_dds                         = chk_dds.state
  910.                                 ::g_Physical_Material    = chk_Physical_Material.state
  911.                                 ::g_UVW_Flip_V            = chk_UVW_Flip_V.state
  912.                                 
  913.                                 format "\n-----Material Options: -----\n"
  914.                                 format "g_dds % \n"                                         ::g_dds
  915.                                 format "g_Physical_Material % \n"                         ::g_Physical_Material
  916.                                 format "chk_UVW_Flip_V % \n"                             ::g_UVW_Flip_V
  917.                                 
  918.                                 format "chk_PhysMat_SSS % \n"                         chk_PhysMat_SSS.state
  919.                                 format "chk_deepSearch % \n"                             chk_deepSearch.state
  920.                                 format "chk_quickMTL_Match % \n"                     chk_quickMTL_Match.state
  921.                                 format "chk_MaterialRef % \n"                             chk_MaterialRef.state
  922.                                 format "chk_BuildMaterial % \n"                             chk_BuildMaterial.state                                
  923.                                 
  924.                                 if ::g_Physical_Material then
  925.                                 (
  926.                                     spn_Spec_Map_Amount.enabled         = true
  927.                                     spn_displacement_map_amt.enabled     = true
  928.                                 )
  929.                                 else
  930.                                 (
  931.                                     spn_Spec_Map_Amount.enabled         = false
  932.                                     spn_displacement_map_amt.enabled     = false
  933.                                 )
  934.                                 ::inst_PHYS_MAT_ADJUST.spec_output_amount = spn_Spec_Map_Amount.value
  935.                             )
  936.                             on rollout_options close do
  937.                             (
  938.                                 if (setdir #scripts ::g_scriptsDefault) then
  939.                                 (
  940.                                     format "Current Scripts Dir set to #scripts: %\n" (getdir #scripts)
  941.                                 )
  942.                                 else
  943.                                 (
  944.                                     format "Current #scripts dir: %\n" (getdir #scripts)
  945.                                 )
  946.                             )
  947.                             on rollout_options rolledUp state do
  948.                             (
  949.                                 if NOT state then
  950.                                 (
  951.                                     --closed
  952.                                     CRYOP.size = [CRYOP.size[1], CRYOP.size[2]-rollout_options.height]
  953.                                 )
  954.                                 else
  955.                                 (
  956.                                     --open
  957.                                     CRYOP.size = [CRYOP.size[1], CRYOP.size[2]+rollout_options.height]
  958.                                 )
  959.                             )
  960.                             on chk_Physical_Material changed arg do
  961.                             (
  962.                                 ::g_Physical_Material                                         = chk_Physical_Material.state        
  963.                                 format "Physical Material: %\n"                             ::g_Physical_Material 
  964.                                 
  965.                                 if ::g_Physical_Material then
  966.                                 (
  967.                                     spn_Spec_Map_Amount.enabled         = true
  968.                                     chk_PhysMat_SSS.enabled                 = true
  969.                                     spn_displacement_map_amt.enabled     = true
  970.                                 )
  971.                                 else
  972.                                 (
  973.                                     spn_Spec_Map_Amount.enabled         = false
  974.                                     chk_PhysMat_SSS.enabled                 = false
  975.                                     spn_displacement_map_amt.enabled     = false
  976.                                 )
  977.                                 ::inst_PHYS_MAT_ADJUST.spec_output_amount = spn_Spec_Map_Amount.value
  978.                             )
  979.                             on spn_Spec_Map_Amount changed arg do
  980.                             (
  981.                                 ::inst_PHYS_MAT_ADJUST.spec_output_amount = spn_Spec_Map_Amount.value
  982.                             )
  983.                             on chk_dds changed arg do
  984.                             (
  985.                                 ::g_dds                                             = chk_dds.state        
  986.                                 format "Treat .tiff as .dds: %\n"         ::g_dds
  987.                             )
  988.                             on chk_PhysMat_SSS changed arg do
  989.                             (
  990.                                 format "chk_PhysMat_SSS: %\n"         chk_PhysMat_SSS.state
  991.                             )
  992.                             on chk_UVW_Flip_V changed arg do
  993.                             (
  994.                                 ::g_UVW_Flip_V                                 = chk_UVW_Flip_V.state        
  995.                                 format "chk_UVW_Flip_V % \n"             ::g_UVW_Flip_V
  996.                             )
  997.                             on chk_deepSearch changed arg do
  998.                             (    
  999.                                 format "chk_deepSearch % \n" arg
  1000.                             )
  1001.                             on chk_quickMTL_Match changed arg do
  1002.                             (    
  1003.                                 format "chk_quickMTL_Match % \n" arg
  1004.                             )
  1005.                             on chk_MaterialRef changed arg do
  1006.                             (    
  1007.                                 format "chk_MaterialRef % \n" arg
  1008.                             )
  1009.                             on chk_BuildMaterial changed arg do
  1010.                             (
  1011.                                 format "chk_BuildMaterial % \n" arg
  1012.                                 
  1013.                                 if arg then
  1014.                                 (
  1015.                                     chk_Physical_Material.enabled     = true
  1016.                                     grp_Options.enabled                    = true
  1017.                                     chk_UVW_Flip_V.enabled             = true
  1018.                                     chk_PhysMat_SSS.enabled         = true
  1019.                                     chk_deepSearch.enabled             = true
  1020.                                     chk_quickMTL_Match.enabled     = true
  1021.                                     chk_dds.enabled                        = true
  1022.                                     chk_MaterialRef.enabled            = true
  1023.                                     
  1024.                                     spn_Spec_Map_Amount .enabled         = true
  1025.                                     spn_displacement_map_amt.enabled     = true
  1026.  
  1027.                                 )
  1028.                                 else
  1029.                                 (
  1030.                                     chk_Physical_Material.enabled     = false
  1031.                                     grp_Options.enabled                    = false
  1032.                                     chk_UVW_Flip_V.enabled             = false
  1033.                                     chk_PhysMat_SSS.enabled         = false
  1034.                                     chk_deepSearch.enabled             = false
  1035.                                     chk_quickMTL_Match.enabled     = false
  1036.                                     chk_dds.enabled                        = false
  1037.                                     chk_MaterialRef.enabled            = false
  1038.                                     
  1039.                                     spn_Spec_Map_Amount .enabled         = false
  1040.                                     spn_displacement_map_amt.enabled     = false
  1041.                                 )    
  1042.                             )
  1043.                         )
  1044.  
  1045.                         rollout rollout_Report "Report" width:290 height:150 category:9
  1046.                         (
  1047.                             checkbox 'chk_Mesh_Report' "Mesh Report" pos:[17,11] width:80 height:20 align:#left
  1048.                             checkbox 'chk_xmlB_Report' "xmlB Report" pos:[17,31] width:78 height:20 checked:false align:#left
  1049.                             checkbox 'chk_xmlB_Report_v2' "xmlB Report v2" pos:[17,50] width:110 height:20 checked:false align:#left
  1050.                             checkbox 'chk_xmlB_Debug_Report' "xmlB Debug Report" pos:[17,69] width:113 height:20 align:#left
  1051.                             checkbox 'chk_Build_Material_Report' "Build Material Report" pos:[17,89] width:122 height:18 enabled:true checked:false align:#left                        
  1052.                             checkbox 'chk_Read_Comp_cryBones_Report' "Read Compiled Crybones Report" pos:[17,107] width:175 height:20 align:#left
  1053.                             checkbox 'chk_Create_Bones_Report' "Create Bones Report" pos:[17,127] width:175 height:20 checked:false align:#left    
  1054.                             checkbox 'chk_CDF_Report' "CDF Report" pos:[17,147] width:175 height:20 checked:false align:#left
  1055.                             checkbox 'chk_Anim_Report' "Animation Report" pos:[17,167] width:175 height:20 checked:false align:#left
  1056.                             checkbox 'chk_Heuristic_Report' "Heuristic Report" pos:[17,187] width:175 height:20 checked:false align:#left
  1057.                             checkbox 'chk_MaterialRef_Report' "MaterialRef Report" pos:[17,207] width:175 height:20 checked:false align:#left
  1058.                             checkbox 'chk_NameMTLRef_Report' "MTLRef Report" pos:[17,227] width:175 height:20 checked:false align:#left
  1059.                             checkbox 'chk_NametexRef_Report' "TEXRef Report" pos:[17,247] width:175 height:20 checked:false align:#left
  1060.                             checkbox 'chk_BUILDER_Report' "BUILDER Report" pos:[17,267] width:175 height:20 checked:true align:#left
  1061.                             
  1062.                             on rollout_Report open do
  1063.                             (
  1064.                                 if (setdir #scripts ::g_scriptsDefault) then
  1065.                                 (
  1066.                                     format "Current Scripts Dir set to #scripts: %\n" (getdir #scripts)
  1067.                                 )
  1068.                                 else
  1069.                                 (
  1070.                                     format "Current #scripts dir: %\n" (getdir #scripts)
  1071.                                 )
  1072.                                 
  1073.                                 ::g_xmlB_Report_v2                             = chk_xmlB_Report_v2.state        
  1074.                                 ::g_xmlB_Debug_Report                     = chk_xmlB_Debug_Report.state
  1075.                                 ::g_Build_Material_Report                     = chk_Build_Material_Report.state
  1076.                                 ::g_xmlB_Report                                 = chk_xmlB_Report.state
  1077.                                 ::g_Mesh_Report                                 = chk_Mesh_Report.state
  1078.                                 ::g_Read_Comp_cryBones_Report         = chk_Read_Comp_cryBones_Report.state
  1079.                                 ::g_Read_Create_Bones_Report             = chk_Create_Bones_Report.state
  1080.                                 ::g_CDF_Report                                 = chk_CDF_Report.state            
  1081.                                 
  1082.                                 format "\n-----Report Options: -----\n"        
  1083.                                 format "g_xmlB_Report_v2 % \n"                         ::g_xmlB_Report_v2
  1084.                                 format "g_xmlB_Debug_Report % \n"                     ::g_xmlB_Debug_Report
  1085.                                 format "g_Build_Material_Report % \n"                     ::g_Build_Material_Report
  1086.                                 format "g_xmlB_Report % \n"                                 ::g_xmlB_Report
  1087.                                 format "g_Mesh_Report % \n"                             ::g_Mesh_Report
  1088.                                 format "g_Read_Comp_cryBones_Report % \n"         ::g_Read_Comp_cryBones_Report
  1089.                                 format "g_Read_Create_Bones_Report % \n"         ::g_Read_Create_Bones_Report
  1090.                                 format "g_CDF_Report % \n"                                 ::g_CDF_Report
  1091.                                 
  1092.                                 format "chk_Anim_Report % \n"                             chk_Anim_Report.state
  1093.                                 format "chk_Anim_Report % \n"                             chk_Heuristic_Report.state
  1094.                                 format "chk_MaterialRef_Report % \n"                     chk_MaterialRef_Report.state
  1095.                                 format "chk_NameMTLRef_Report % \n"                 chk_NameMTLRef_Report.state
  1096.                                 format "chk_NametexRef_Report % \n"                 chk_NametexRef_Report.state                            
  1097.                             )
  1098.                             on rollout_Report close do
  1099.                             (
  1100.                                 if (setdir #scripts ::g_scriptsDefault) then
  1101.                                 (
  1102.                                     format "Current Scripts Dir set to #scripts: %\n" (getdir #scripts)
  1103.                                 )
  1104.                                 else
  1105.                                 (
  1106.                                     format "Current #scripts dir: %\n" (getdir #scripts)
  1107.                                 )
  1108.                             )
  1109.                             on rollout_Report rolledUp state do
  1110.                             (
  1111.                                 if NOT state then
  1112.                                 (
  1113.                                     --closed
  1114.                                     CRYOP.size = [CRYOP.size[1], CRYOP.size[2]-rollout_Report.height]
  1115.                                 )
  1116.                                 else
  1117.                                 (
  1118.                                     --open
  1119.                                     CRYOP.size = [CRYOP.size[1], CRYOP.size[2]+rollout_Report.height]
  1120.                                 )
  1121.                             )
  1122.                             on chk_xmlB_Report_v2 changed arg do
  1123.                             (
  1124.                                 ::g_xmlB_Report_v2 = chk_xmlB_Report_v2.state        
  1125.                                 format "chk_xmlB_Report_v2: %\n" ::g_xmlB_Report_v2
  1126.                             )
  1127.                             on chk_xmlB_Debug_Report changed arg do
  1128.                             (
  1129.                                 ::g_xmlB_Debug_Report = chk_xmlB_Debug_Report.state        
  1130.                                 format "chk_xmlB_Debug_Report: %\n" ::g_xmlB_Debug_Report
  1131.                             )
  1132.                             on chk_Build_Material_Report changed arg do
  1133.                             (
  1134.                                 ::g_Build_Material_Report = chk_Build_Material_Report.state        
  1135.                                 format "chk_Build_Material_Report: %\n" ::g_Build_Material_Report
  1136.                             )
  1137.                             on chk_xmlB_Report changed arg do
  1138.                             (
  1139.                                 ::g_xmlB_Report = chk_xmlB_Report.state        
  1140.                                 format "chk_xmlB_Report: %\n" ::g_xmlB_Report
  1141.                             )
  1142.                             on chk_Mesh_Report changed arg do
  1143.                             (
  1144.                                 ::g_Mesh_Report = chk_Mesh_Report.state        
  1145.                                 format "chk_Mesh_Report: %\n" ::g_Mesh_Report
  1146.                             )
  1147.                             on chk_Read_Comp_cryBones_Report changed arg do
  1148.                             (
  1149.                                 ::g_chk_Comp_cryBones_Report = chk_Read_Comp_cryBones_Report.state        
  1150.                                 format "chk_Read_Comp_cryBones_Report: %\n" ::g_chk_Comp_cryBones_Report
  1151.                             )
  1152.                             on chk_Create_Bones_Report changed arg do
  1153.                             (
  1154.                                 ::g_Create_Bones_Report = chk_Create_Bones_Report.state        
  1155.                                 format "chk_Create_Bones_Report: %\n" ::g_Create_Bones_Report
  1156.                             )
  1157.                             on chk_CDF_Report changed arg do
  1158.                             (
  1159.                                 ::g_Create_Bones_Report = chk_Create_Bones_Report.state        
  1160.                                 format "chk_Create_Bones_Report: %\n" ::g_Create_Bones_Report
  1161.                             )
  1162.                             on chk_CDF_Report changed arg do
  1163.                             (
  1164.                                 ::g_CDF_Report = chk_CDF_Report.state        
  1165.                                 format "chk_Create_Bones_Report: %\n" ::g_CDF_Report
  1166.                             )
  1167.                             on chk_Anim_Report changed arg do
  1168.                             (                        
  1169.                                 format "chk_Anim_Report: %\n" arg
  1170.                             )
  1171.                             on chk_Heuristic_Report changed arg do
  1172.                             (                        
  1173.                                 format "chk_Heuristic_Report: %\n" arg
  1174.                             )
  1175.                             on chk_MaterialRef_Report changed arg do
  1176.                             (                        
  1177.                                 format "chk_MaterialRef_Report: %\n" arg
  1178.                             )
  1179.                             on chk_NameMTLRef_Report changed arg do
  1180.                             (                        
  1181.                                 format "chk_NameMTLRef_Report: %\n" arg
  1182.                             )    
  1183.                             on chk_NametexRef_Report changed arg do
  1184.                             (                        
  1185.                                 format "chk_NametexRef_Report: %\n" arg
  1186.                             )    
  1187.                             on chk_BUILDER_Report changed arg do
  1188.                             (                        
  1189.                                 format "chk_BUILDER_Report: %\n" arg
  1190.                             )                            
  1191.                         )
  1192.  
  1193.                         rollout rollout_animation "Animation" width:290 height:95 category:4
  1194.                         (
  1195.                             checkbox 'chk_Use_Skin_Wrap' "Use Skin_Wrap" pos:[16,17] width:255 height:21 align:#left enabled:false    
  1196.                             
  1197.                             on rollout_animation open do
  1198.                             (
  1199.                                 if (setdir #scripts ::g_scriptsDefault) then
  1200.                                 (
  1201.                                     format "Current Scripts Dir set to #scripts: %\n" (getdir #scripts)
  1202.                                 )
  1203.                                 else
  1204.                                 (
  1205.                                     format "Current #scripts dir: %\n" (getdir #scripts)
  1206.                                 )
  1207.                             )
  1208.                             on rollout_animation close do
  1209.                             (
  1210.                                 if (setdir #scripts ::g_scriptsDefault) then
  1211.                                 (
  1212.                                     format "Current Scripts Dir set to #scripts: %\n" (getdir #scripts)
  1213.                                 )
  1214.                                 else
  1215.                                 (
  1216.                                     format "Current #scripts dir: %\n" (getdir #scripts)
  1217.                                 )
  1218.                             )
  1219.                             on chk_Use_Skin_Wrap changed arg do
  1220.                             (
  1221.                                 ::g_Use_Skin_Wrap = chk_Use_Skin_Wrap.state        
  1222.                                 format "chk_Use_Skin_Wrap: %\n" ::g_Use_Skin_Wrap
  1223.                             )
  1224.                             on rollout_animation rolledUp state do
  1225.                             (
  1226.                                 if NOT state then
  1227.                                 (
  1228.                                     --closed
  1229.                                     CRYOP.size = [CRYOP.size[1], CRYOP.size[2]-rollout_animation.height]
  1230.                                 )
  1231.                                 else
  1232.                                 (
  1233.                                     --open
  1234.                                     CRYOP.size = [CRYOP.size[1], CRYOP.size[2]+rollout_animation.height]
  1235.                                 )
  1236.                             )
  1237.                         )
  1238.  
  1239.                         rollout rollout_About "About" width:290 height:50 category:10
  1240.                         (
  1241.                             label 'lbl_About' "joqqyhez@gmail.com  2016" pos:[14,13] width:263 height:19 align:#left
  1242.                             label 'lbl_trademark' "CRYENGINE is a Trademark of Crytek GmbH" pos:[13,35] width:266 height:20 align:#left                        
  1243.                             
  1244.                             on rollout_About open do
  1245.                             (
  1246.                                 if (setdir #scripts ::g_scriptsDefault) then
  1247.                                 (
  1248.                                     format "Current Scripts Dir set to #scripts: %\n" (getdir #scripts)
  1249.                                 )
  1250.                                 else
  1251.                                 (
  1252.                                     format "Current #scripts dir: %\n" (getdir #scripts)
  1253.                                 )
  1254.                             )    
  1255.                             on rollout_About close do
  1256.                             (
  1257.                                 if (setdir #scripts ::g_scriptsDefault) then
  1258.                                 (
  1259.                                     format "Current Scripts Dir set to #scripts: %\n" (getdir #scripts)
  1260.                                 )
  1261.                                 else
  1262.                                 (
  1263.                                     format "Current #scripts dir: %\n" (getdir #scripts)
  1264.                                 )
  1265.                             )                        
  1266.                             on rollout_About rolledUp state do
  1267.                             (                            
  1268.                                 if NOT state then
  1269.                                 (
  1270.                                     --closed
  1271.                                     CRYOP.size = [CRYOP.size[1], CRYOP.size[2]-rollout_About.height]
  1272.                                 )
  1273.                                 else
  1274.                                 (
  1275.                                     --open
  1276.                                     CRYOP.size = [CRYOP.size[1], CRYOP.size[2]+rollout_About.height]
  1277.                                 )
  1278.                             )
  1279.                         )
  1280.  
  1281.                         rollout rollout_Alert "Alert" width:290 height:85 category:8
  1282.                         (
  1283.                             listBox 'lbx_Message_Alert' "Message Alert" pos:[12,20] width:267 height:7 align:#left                        
  1284.                             
  1285.                             on rollout_Alert open do
  1286.                             (
  1287.                                 if (setdir #scripts ::g_scriptsDefault) then
  1288.                                 (
  1289.                                     format "Current Scripts Dir set to #scripts: %\n" (getdir #scripts)
  1290.                                 )
  1291.                                 else
  1292.                                 (
  1293.                                     format "Current #scripts dir: %\n" (getdir #scripts)
  1294.                                 )
  1295.                             )    
  1296.                             on rollout_Alert close do
  1297.                             (
  1298.                                 if (setdir #scripts ::g_scriptsDefault) then
  1299.                                 (
  1300.                                     format "Current Scripts Dir set to #scripts: %\n" (getdir #scripts)
  1301.                                 )
  1302.                                 else
  1303.                                 (
  1304.                                     format "Current #scripts dir: %\n" (getdir #scripts)
  1305.                                 )
  1306.                             )    
  1307.                             on rollout_Alert rolledUp state do
  1308.                             (
  1309.                                 if NOT state then
  1310.                                 (
  1311.                                     --closed
  1312.                                     CRYOP.size = [CRYOP.size[1], CRYOP.size[2]-rollout_Alert.height]
  1313.                                 )
  1314.                                 else
  1315.                                 (
  1316.                                     --open
  1317.                                     CRYOP.size = [CRYOP.size[1], CRYOP.size[2]+rollout_Alert.height]
  1318.                                 )
  1319.                             )
  1320.                         )
  1321.                         
  1322.                         rollout rollout_AnimationTracks "Animation Tracks" width:100 height:20 category:5
  1323.                         (
  1324.                             dropdownList 'ddl_Animation_Tracks' "Animation Tracks" pos:[8,20] width:265 height:30 items:#() align:#left
  1325.                             
  1326.                             on rollout_AnimationTracks open do
  1327.                             (
  1328.                                 if (setdir #scripts ::g_scriptsDefault) then
  1329.                                 (
  1330.                                     format "Current Scripts Dir set to #scripts: %\n" (getdir #scripts)
  1331.                                 )
  1332.                                 else
  1333.                                 (
  1334.                                     format "Current #scripts dir: %\n" (getdir #scripts)
  1335.                                 )
  1336.                             )
  1337.                             on rollout_AnimationTracks close do
  1338.                             (
  1339.                                 if (setdir #scripts ::g_scriptsDefault) then
  1340.                                 (
  1341.                                     format "Current Scripts Dir set to #scripts: %\n" (getdir #scripts)
  1342.                                 )
  1343.                                 else
  1344.                                 (
  1345.                                     format "Current #scripts dir: %\n" (getdir #scripts)
  1346.                                 )
  1347.                             )    
  1348.                             on rollout_AnimationTracks rolledUp state do
  1349.                             (
  1350.                                 if NOT state then
  1351.                                 (
  1352.                                     --closed
  1353.                                     CRYOP.size = [CRYOP.size[1], CRYOP.size[2]-rollout_AnimationTracks.height]
  1354.                                 )
  1355.                                 else
  1356.                                 (
  1357.                                     --open
  1358.                                     CRYOP.size = [CRYOP.size[1], CRYOP.size[2]+rollout_AnimationTracks.height]
  1359.                                 )
  1360.                             )
  1361.                         )
  1362.  
  1363.                         --/////////////////////////////// Instanciate the rollouts ///////////////////////////////
  1364.                         CRYOP = newRolloutFloater "CryEngine Importer v 1.0" 290 810
  1365.  
  1366.                         addRollout             ::rollout_options         ::CRYOP  rolledUp:true
  1367.                         addRollout             ::rollout_Report         ::CRYOP rolledUp:true
  1368.                         addRollout             ::cryImport             ::CRYOP rolledUp:false
  1369.                         addRollout             ::rollout_animation     ::CRYOP rolledUp:true
  1370.                         -- addRollout             ::rollout_Alert             ::CRYOP rolledUp:false --set runtime instead inside CryMat_XML_.ms
  1371.                         addRollout             ::rollout_About         ::CRYOP rolledUp:true                    
  1372.  
  1373.                         CreateDialog         ::cryImport     rolledUp:false width:120 height:200        
  1374.                         --//////////////////////////////////////////////////////////////////////////////////////
  1375.                     )
  1376.                     else
  1377.                     (
  1378.                         delete_ini()
  1379.                         MessageBox "Cannot find or load the include files, cannot continue, aborting!" title:"Startup Error" beep:false
  1380.                     )
  1381.                 )
  1382.                 else
  1383.                 (
  1384.                     delete_ini()
  1385.                     format "Could not set the #scripts path - include files will not load - aborting!\n"
  1386.                 )    
  1387.             )
  1388.             catch
  1389.             (
  1390.                 delete_ini()
  1391.                 format "\n\n\n\n*** *** *** *** *** ***  Could not load include files ***  *** *** *** *** *** ***\n"
  1392.                 format "%" (getCurrentException())
  1393.                 format "\n*** *** *** *** *** *** END OF Could not load include files *** *** *** *** *** *** ***\n\n\n\n"
  1394.             )
  1395.         )
  1396.         else
  1397.         (
  1398.             delete_ini()
  1399.             MessageBox "Cannot find scriptpath, cannot continue, aborting!" title:"Startup Error" beep:false    
  1400.         )
  1401.  
  1402.         gc()
  1403.     )
  1404.     else
  1405.     (
  1406.         format "No ini file ( % ) found - aborting! (Make sure your user temp\n" ::g_iniFile
  1407.     )
  1408. )
  1409. else
  1410. (
  1411.     MessageBox "This script requires 3DS Max 2017 or higher!" title:"Startup Error" beep:true
  1412. )