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

This commit is contained in:
Areloch 2018-01-28 15:21:03 -06:00
parent 649aed23ac
commit db0360cf48
2 changed files with 49 additions and 7 deletions

View file

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

View file

@ -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