ソースを参照

Adds script function to access full path of the level asset's preview image file
Updates script function descriptions to be correct
Updates chooseLevelDlg functions to be more efficient and consistent, and use the exposed get methods for getting preview images and the like properly

Areloch 5 年 前
コミット
837983c767

+ 13 - 6
Engine/source/T3D/assets/LevelAsset.cpp

@@ -362,22 +362,29 @@ void LevelAsset::unloadDependencies()
 }
 }
 
 
 DefineEngineMethod(LevelAsset, getLevelPath, const char*, (),,
 DefineEngineMethod(LevelAsset, getLevelPath, const char*, (),,
-   "Creates a new script asset using the targetFilePath.\n"
-   "@return The bool result of calling exec")
+   "Gets the full path of the asset's defined level file.\n"
+   "@return The string result of the level path")
 {
 {
    return object->getLevelPath();
    return object->getLevelPath();
 }
 }
 
 
+DefineEngineMethod(LevelAsset, getPreviewImagePath, const char*, (), ,
+   "Gets the full path of the asset's defined preview image file.\n"
+   "@return The string result of the level preview image path")
+{
+   return object->getImagePath();
+}
+
 DefineEngineMethod(LevelAsset, getPostFXPresetPath, const char*, (), ,
 DefineEngineMethod(LevelAsset, getPostFXPresetPath, const char*, (), ,
-   "Creates a new script asset using the targetFilePath.\n"
-   "@return The bool result of calling exec")
+   "Gets the full path of the asset's defined postFX preset file.\n"
+   "@return The string result of the postFX preset path")
 {
 {
    return object->getPostFXPresetPath();
    return object->getPostFXPresetPath();
 }
 }
 
 
 DefineEngineMethod(LevelAsset, getDecalsPath, const char*, (), ,
 DefineEngineMethod(LevelAsset, getDecalsPath, const char*, (), ,
-   "Creates a new script asset using the targetFilePath.\n"
-   "@return The bool result of calling exec")
+   "Gets the full path of the asset's defined decal file.\n"
+   "@return The string result of the decal path")
 {
 {
    return object->getDecalsPath();
    return object->getDecalsPath();
 }
 }

+ 11 - 23
Templates/BaseGame/game/data/ui/guis/chooseLevelDlg.cs

@@ -83,9 +83,9 @@ function ChooseLevelDlg::onWake( %this )
 
 
    for(%i=0; %i < LevelListEntries.count(); %i++)
    for(%i=0; %i < LevelListEntries.count(); %i++)
    {
    {
-      %levelEntry = LevelListEntries.getKey(%i);
+      %levelAsset = LevelListEntries.getKey(%i);
       
       
-      LevelList.addRow(getField(%levelEntry, 0), "", -1, -30);
+      LevelList.addRow(%levelAsset.LevelName, "", -1, -30);
    }
    }
    
    
    LevelList.setSelected(0);
    LevelList.setSelected(0);
@@ -140,45 +140,33 @@ function ChooseLevelDlg::addMissionFile( %this, %file )
 
 
 function ChooseLevelDlg::addLevelAsset( %this, %levelAsset )
 function ChooseLevelDlg::addLevelAsset( %this, %levelAsset )
 {
 {
-   %file = %levelAsset.getAssetId();
-   
-   %levelName = %levelAsset.LevelName;
-   %levelDesc = %levelAsset.description;
-   %levelPreview = %levelAsset.levelPreviewImage;
-   
-   LevelListEntries.add( %levelName TAB %file TAB %levelDesc TAB %levelPreview );
+   LevelListEntries.add( %levelAsset );
 }
 }
 
 
 function LevelList::onChange(%this)
 function LevelList::onChange(%this)
 {
 {
    %index = %this.getSelectedRow();
    %index = %this.getSelectedRow();
    
    
-   %levelEntry = LevelListEntries.getKey(%index);
+   %levelAsset = LevelListEntries.getKey(%index);
    
    
    // Get the name
    // Get the name
-   ChooseLevelWindow->LevelName.text = getField(%levelEntry, 0);
+   ChooseLevelWindow->LevelName.text = %levelAsset.LevelName;
    
    
-   // Get the level file
-   $selectedLevelAsset = getField(%levelEntry, 1);
+   // Get the level id
+   $selectedLevelAsset = %levelAsset.getAssetId();
    
    
    // Find the preview image
    // Find the preview image
-   %levelPreview = getField(%levelEntry, 3);
+   %levelPreview = %levelAsset.getPreviewImagePath();
    
    
    // Test against all of the different image formats
    // Test against all of the different image formats
    // This should probably be moved into an engine function
    // This should probably be moved into an engine function
-   if (isFile(%levelPreview @ ".png") ||
-       isFile(%levelPreview @ ".jpg") ||
-       isFile(%levelPreview @ ".bmp") ||
-       isFile(%levelPreview @ ".gif") ||
-       isFile(%levelPreview @ ".jng") ||
-       isFile(%levelPreview @ ".mng") ||
-       isFile(%levelPreview @ ".tga"))
-      ChooseLevelWindow->CurrentPreview.setBitmap(%previewFile);
+   if (isFile(%levelPreview))
+      ChooseLevelWindow->CurrentPreview.setBitmap(%levelPreview);
    else
    else
       ChooseLevelWindow->CurrentPreview.setBitmap("data/ui/images/no-preview");
       ChooseLevelWindow->CurrentPreview.setBitmap("data/ui/images/no-preview");
 
 
    // Get the description
    // Get the description
-   %levelDesc = getField(%levelEntry, 2);
+   %levelDesc = %levelAsset.description;
    
    
    if(%levelDesc !$= "")
    if(%levelDesc !$= "")
    {
    {