Ver Fonte

Modifies the chooslLevelDlg in the UI module to utilize LevelAssets for the non editor template level selection.

Areloch há 7 anos atrás
pai
commit
db0360cf48

+ 1 - 1
Templates/BaseGame/game/data/clientServer/ClientServer.cs

@@ -46,7 +46,7 @@ function ClientServer::destroy( %this )
       disconnect();
    
    // Destroy the physics plugin.
-   physicsDestroy();
+   //physicsDestroy();
    
    sfxShutdown();
       

+ 48 - 6
Templates/BaseGame/game/data/ui/scripts/chooseLevelDlg.cs

@@ -31,7 +31,11 @@ function ChooseLevelDlg::onWake( %this )
    %this->LevelDescriptionLabel.visible = false;
    %this->LevelDescription.visible = false;
    
-   %count = LevelFilesList.count();
+   %assetQuery = new AssetQuery();
+   if(!AssetDatabase.findAssetType(%assetQuery, "LevelAsset"))
+      return; //if we didn't find ANY, just exit
+      
+   %count = %assetQuery.getCount();
    
    if(%count == 0)
    {
@@ -39,7 +43,7 @@ function ChooseLevelDlg::onWake( %this )
       if(IsDirectory("tools"))
       {
          MessageBoxYesNo("Error", "No levels were found in any modules. Do you want to load the editor and start a new level?", 
-            "fastLoadWorldEdit(1);", 
+            "EditorOpenMission();", 
             "Canvas.popDialog(ChooseLevelDlg); if(isObject(ChooseLevelDlg.returnGui) && ChooseLevelDlg.returnGui.isMethod(\"onReturnTo\")) ChooseLevelDlg.returnGui.onReturnTo();");  
       }
       else
@@ -48,12 +52,18 @@ function ChooseLevelDlg::onWake( %this )
             "Canvas.popDialog(ChooseLevelDlg); if(isObject(ChooseLevelDlg.returnGui) && ChooseLevelDlg.returnGui.isMethod(\"onReturnTo\")) ChooseLevelDlg.returnGui.onReturnTo();");
       }
       
+      %assetQuery.delete();
       return;
    }
    
-   for ( %i=0; %i < %count; %i++ )
-   {
-      %file = LevelFilesList.getKey( %i );
+   for(%i=0; %i < %count; %i++)
+	{
+	   %assetId = %assetQuery.getAsset(%i);
+      
+      %levelAsset = AssetDatabase.acquireAsset(%assetId);
+      
+      %file = %levelAsset.LevelFile;
+      
       if ( !isFile(%file @ ".mis") && !isFile(%file) )
          continue;
          
@@ -66,7 +76,7 @@ function ChooseLevelDlg::onWake( %this )
             continue;      
       }
                   
-      %this.addMissionFile( %file );
+      %this.addLevelAsset( %levelAsset );
    }
    
    // Also add the new level mission as defined in the world editor settings
@@ -218,6 +228,38 @@ function ChooseLevelDlg::addMissionFile( %this, %file )
    CL_levelList.addRow( CL_levelList.rowCount(), %levelName TAB %file TAB %levelDesc TAB %levelPreview );
 }
 
+function ChooseLevelDlg::addLevelAsset( %this, %levelAsset )
+{
+   %file = %levelAsset.LevelFile;
+   
+   /*%levelName = fileBase(%file);
+   %levelDesc = "A Torque level";
+
+   %LevelInfoObject = getLevelInfo(%file);
+
+   if (%LevelInfoObject != 0)
+   {
+      if(%LevelInfoObject.levelName !$= "")
+         %levelName = %LevelInfoObject.levelName;
+      else if(%LevelInfoObject.name !$= "")
+         %levelName = %LevelInfoObject.name;
+
+      if (%LevelInfoObject.desc0 !$= "")
+         %levelDesc = %LevelInfoObject.desc0;
+         
+      if (%LevelInfoObject.preview !$= "")
+         %levelPreview = %LevelInfoObject.preview;
+         
+      %LevelInfoObject.delete();
+   }*/
+   
+   %levelName = %levelAsset.friendlyName;
+   %levelDesc = %levelAsset.description;
+   %levelPreview = %levelAsset.levelPreviewImage;
+   
+   CL_levelList.addRow( CL_levelList.rowCount(), %levelName TAB %file TAB %levelDesc TAB %levelPreview );
+}
+
 function ChooseLevelDlg::onSleep( %this )
 {
    // This is set from the outside, only stays true for a single wake/sleep