Merge pull request #361 from Areloch/LevelAssetLoadConsistency

Updates some level asset functions and script handling
This commit is contained in:
Brian Roberts 2020-10-17 16:21:01 -05:00 committed by GitHub
commit 3851612b91
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 29 deletions

View file

@ -362,22 +362,29 @@ void LevelAsset::unloadDependencies()
}
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();
}
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*, (), ,
"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();
}
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();
}

View file

@ -83,9 +83,9 @@ function ChooseLevelDlg::onWake( %this )
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);
@ -140,45 +140,33 @@ function ChooseLevelDlg::addMissionFile( %this, %file )
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)
{
%index = %this.getSelectedRow();
%levelEntry = LevelListEntries.getKey(%index);
%levelAsset = LevelListEntries.getKey(%index);
// 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
%levelPreview = getField(%levelEntry, 3);
%levelPreview = %levelAsset.getPreviewImagePath();
// Test against all of the different image formats
// 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
ChooseLevelWindow->CurrentPreview.setBitmap("data/ui/images/no-preview");
// Get the description
%levelDesc = getField(%levelEntry, 2);
%levelDesc = %levelAsset.description;
if(%levelDesc !$= "")
{