mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-15 16:44:36 +00:00
Merge branch 'SubScenes_Gamemode_PR' of https://github.com/Areloch/Torque3D into development
This commit is contained in:
commit
81ac23fd35
60 changed files with 4200 additions and 525 deletions
|
|
@ -325,6 +325,8 @@ function replaceInFile(%fileName, %fromWord, %toWord)
|
|||
//Go through our scriptfile and replace the old namespace with the new
|
||||
%editedFileContents = "";
|
||||
|
||||
%lineArray = new ArrayObject(){};
|
||||
|
||||
%file = new FileObject();
|
||||
if ( %file.openForRead( %fileName ) )
|
||||
{
|
||||
|
|
@ -334,6 +336,8 @@ function replaceInFile(%fileName, %fromWord, %toWord)
|
|||
%line = trim( %line );
|
||||
|
||||
%editedFileContents = %editedFileContents @ strreplace(%line, %fromWord, %toWord) @ "\n";
|
||||
|
||||
%lineArray.add(strreplace(%line, %fromWord, %toWord));
|
||||
}
|
||||
|
||||
%file.close();
|
||||
|
|
@ -341,12 +345,18 @@ function replaceInFile(%fileName, %fromWord, %toWord)
|
|||
|
||||
if(%editedFileContents !$= "")
|
||||
{
|
||||
%file.openForWrite(%fileName);
|
||||
|
||||
%file.writeline(%editedFileContents);
|
||||
|
||||
%file.close();
|
||||
if( %file.openForWrite(%fileName) )
|
||||
{
|
||||
for(%i=0; %i < %lineArray.getCount(); %i++)
|
||||
{
|
||||
%file.writeline(%lineArray.getKey(%i));
|
||||
}
|
||||
|
||||
%file.close();
|
||||
}
|
||||
}
|
||||
|
||||
%lineArray.delete();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -1,52 +1,22 @@
|
|||
function callGamemodeFunction(%gameModeFuncName, %arg0, %arg1, %arg2, %arg3, %arg4, %arg5, %arg6)
|
||||
{
|
||||
%activeSceneCount = getSceneCount();
|
||||
|
||||
%hasGameMode = 0;
|
||||
for(%i=0; %i < %activeSceneCount; %i++)
|
||||
%validGameModeCall = false;
|
||||
%gamemodeList = getGameModesList();
|
||||
%gameModeCount = %gamemodeList.count();
|
||||
for(%i=0; %i < %gameModeCount; %i++)
|
||||
{
|
||||
%gamemodeName = getScene(%i).gameModeName;
|
||||
if(%gamemodeName !$= "")
|
||||
%gameModeObj = %gamemodeList.getKey(%i);
|
||||
%active = %gamemodeList.getValue(%i);
|
||||
|
||||
if(!isObject(%gameModeObj) || !%active)
|
||||
continue;
|
||||
|
||||
if(%gameModeObj.isMethod(%gameModeFuncName))
|
||||
{
|
||||
//if the scene defines a game mode, go ahead and envoke it here
|
||||
if(isObject(%gamemodeName) && %gamemodeName.isMethod(%gameModeFuncName))
|
||||
{
|
||||
eval(%gamemodeName @ "."@%gameModeFuncName@"(\""@%arg0@"\", \""@%arg1@"\", \""@%arg2@"\", \""@%arg3@"\", \""@%arg4@"\", \""@%arg5@"\", \""@%arg6@"\");" );
|
||||
%hasGameMode = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
//if we don't have an object, attempt the static call
|
||||
if(isMethod(%gamemodeName, %gameModeFuncName))
|
||||
{
|
||||
eval(%gamemodeName @ "::"@%gameModeFuncName@"(\""@%arg0@"\", \""@%arg1@"\", \""@%arg2@"\", \""@%arg3@"\", \""@%arg4@"\", \""@%arg5@"\", \""@%arg6@"\");" );
|
||||
%hasGameMode = 1;
|
||||
}
|
||||
}
|
||||
eval(%gameModeObj @ "."@%gameModeFuncName@"(\""@%arg0@"\", \""@%arg1@"\", \""@%arg2@"\", \""@%arg3@"\", \""@%arg4@"\", \""@%arg5@"\", \""@%arg6@"\");" );
|
||||
%validGameModeCall = true;
|
||||
}
|
||||
}
|
||||
|
||||
//if none of our scenes have gamemodes, we need to kick off a default
|
||||
if(%hasGameMode == 0)
|
||||
{
|
||||
%defaultModeName = ProjectSettings.value("Gameplay/GameModes/defaultModeName");
|
||||
if(%defaultModeName !$= "")
|
||||
{
|
||||
if(isObject(%defaultModeName) && %defaultModeName.isMethod(%gameModeFuncName))
|
||||
{
|
||||
eval(%defaultModeName @ "."@%gameModeFuncName@"(\""@%arg0@"\", \""@%arg1@"\", \""@%arg2@"\", \""@%arg3@"\", \""@%arg4@"\", \""@%arg5@"\", \""@%arg6@"\");" );
|
||||
%hasGameMode = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(isMethod(%defaultModeName, %gameModeFuncName))
|
||||
{
|
||||
eval(%defaultModeName @ "::"@%gameModeFuncName@"(\""@%arg0@"\", \""@%arg1@"\", \""@%arg2@"\", \""@%arg3@"\", \""@%arg4@"\", \""@%arg5@"\", \""@%arg6@"\");" );
|
||||
%hasGameMode = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return %hasGameMode;
|
||||
return %validGameModeCall;
|
||||
}
|
||||
|
|
@ -9,25 +9,12 @@ function ExampleModule::onDestroy(%this)
|
|||
//This is called when the server is initially set up by the game application
|
||||
function ExampleModule::initServer(%this)
|
||||
{
|
||||
%this.queueExec("./scripts/server/ExampleGameMode");
|
||||
%this.queueExec("./scripts/shared/ExampleGameMode");
|
||||
}
|
||||
|
||||
//This is called when the server is created for an actual game/map to be played
|
||||
function ExampleModule::onCreateGameServer(%this)
|
||||
{
|
||||
//These are common managed data files. For any datablock-based stuff that gets generated by the editors
|
||||
//(that doesn't have a specific associated file, like data for a player class) will go into these.
|
||||
//So we'll register them now if they exist.
|
||||
if(isFile("./scripts/managedData/managedDatablocks." @ $TorqueScriptFileExtension))
|
||||
%this.registerDatablock("./scripts/managedData/managedDatablocks");
|
||||
if(isFile("./scripts/managedData/managedForestItemData." @ $TorqueScriptFileExtension))
|
||||
%this.registerDatablock("./scripts/managedData/managedForestItemData");
|
||||
if(isFile("./scripts/managedData/managedForestBrushData." @ $TorqueScriptFileExtension))
|
||||
%this.registerDatablock("./scripts/managedData/managedForestBrushData");
|
||||
if(isFile("./scripts/managedData/managedParticleData." @ $TorqueScriptFileExtension))
|
||||
%this.registerDatablock("./scripts/managedData/managedParticleData");
|
||||
if(isFile("./scripts/managedData/managedParticleEmitterData." @ $TorqueScriptFileExtension))
|
||||
%this.registerDatablock("./scripts/managedData/managedParticleEmitterData");
|
||||
}
|
||||
|
||||
//This is called when the server is shut down due to the game/map being exited
|
||||
|
|
@ -38,7 +25,7 @@ function ExampleModule::onDestroyGameServer(%this)
|
|||
//This is called when the client is initially set up by the game application
|
||||
function ExampleModule::initClient(%this)
|
||||
{
|
||||
%this.queueExec("./scripts/client/inputCommands");
|
||||
%this.queueExec("./scripts/client/inputCommands");
|
||||
|
||||
//client scripts
|
||||
exec("./scripts/client/defaultkeybinds");
|
||||
|
|
@ -46,6 +33,8 @@ function ExampleModule::initClient(%this)
|
|||
%prefPath = getPrefpath();
|
||||
if(isScriptFile(%prefPath @ "/keybinds"))
|
||||
exec(%prefPath @ "/keybinds");
|
||||
|
||||
%this.queueExec("./scripts/shared/ExampleGameMode");
|
||||
}
|
||||
|
||||
//This is called when a client connects to a server
|
||||
|
|
|
|||
|
|
@ -8,4 +8,5 @@
|
|||
ForestFile="@assetFile=ExampleLevel.forest"
|
||||
NavmeshFile="@assetFile=ExampleLevel.nav"
|
||||
staticObjectAssetDependency0="@asset=Prototyping:FloorGray"
|
||||
gameModesNames="ExampleGameMode;"
|
||||
VersionId="1"/>
|
||||
|
|
|
|||
|
|
@ -1,11 +1,5 @@
|
|||
function ExampleGameMode::onCreateGame()
|
||||
{
|
||||
// Note: The Game object will be cleaned up by MissionCleanup. Therefore its lifetime is
|
||||
// limited to that of the mission.
|
||||
new ScriptObject(ExampleGameMode){};
|
||||
|
||||
return ExampleGameMode;
|
||||
}
|
||||
if(!isObject(ExampleGameMode))
|
||||
new GameMode(ExampleGameMode){};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// The server has started up so do some game start up
|
||||
|
|
@ -159,6 +153,30 @@ function ExampleGameMode::onInitialControlSet(%this)
|
|||
|
||||
}
|
||||
|
||||
function ExampleGameMode::onSceneLoaded(%this)
|
||||
{
|
||||
echo("===================================");
|
||||
echo("ExampleGameMode - Scene is loaded");
|
||||
}
|
||||
|
||||
function ExampleGameMode::onSceneUnloaded(%this)
|
||||
{
|
||||
echo("===================================");
|
||||
echo("ExampleGameMode - Scene is unloaded");
|
||||
}
|
||||
|
||||
function ExampleGameMode::onSubsceneLoaded(%this)
|
||||
{
|
||||
echo("===================================");
|
||||
echo("ExampleGameMode - Subscene is loaded");
|
||||
}
|
||||
|
||||
function ExampleGameMode::onSubsceneUnloaded(%this)
|
||||
{
|
||||
echo("===================================");
|
||||
echo("ExampleGameMode - Subscene is unloaded");
|
||||
}
|
||||
|
||||
function ExampleGameMode::spawnCamera(%this, %client, %spawnPoint)
|
||||
{
|
||||
// Set the control object to the default camera
|
||||
|
|
@ -9,8 +9,8 @@ $guiContent = new GuiControl(ChooseLevelMenu) {
|
|||
tooltipProfile = "GuiToolTipProfile";
|
||||
isContainer = "1";
|
||||
canSaveDynamicFields = "1";
|
||||
currentMenuIdx = "0";
|
||||
launchInEditor = "0";
|
||||
previewButtonSize = "445 120";
|
||||
|
||||
new GuiInputCtrl(ChooseLevelInputHandler) {
|
||||
ignoreMouseEvents = "1";
|
||||
|
|
@ -43,39 +43,50 @@ $guiContent = new GuiControl(ChooseLevelMenu) {
|
|||
extent = "310 41";
|
||||
horizSizing = "center";
|
||||
profile = "GuiDefaultProfile";
|
||||
visible = "0";
|
||||
tooltipProfile = "GuiToolTipProfile";
|
||||
hidden = "1";
|
||||
|
||||
new GuiButtonCtrl() {
|
||||
text = "Level";
|
||||
text = "Game Mode";
|
||||
groupNum = "1";
|
||||
extent = "150 41";
|
||||
profile = "GuiMenuButtonProfile";
|
||||
command = "ChooseLevelMenu.openMenu(0);";
|
||||
tooltipProfile = "GuiToolTipProfile";
|
||||
internalName = "GameModeBtn";
|
||||
class = "ChooseLevelMenuButton";
|
||||
};
|
||||
new GuiButtonCtrl() {
|
||||
text = "Server Config";
|
||||
text = "Level";
|
||||
groupNum = "1";
|
||||
position = "160 0";
|
||||
extent = "150 41";
|
||||
profile = "GuiMenuButtonProfile";
|
||||
command = "ChooseLevelMenu.openMenu(1);";
|
||||
tooltipProfile = "GuiToolTipProfile";
|
||||
internalName = "LevelBtn";
|
||||
class = "ChooseLevelMenuButton";
|
||||
};
|
||||
new GuiButtonCtrl() {
|
||||
text = "Server Config";
|
||||
groupNum = "1";
|
||||
position = "320 0";
|
||||
extent = "150 41";
|
||||
profile = "GuiMenuButtonProfile";
|
||||
visible = "0";
|
||||
command = "ChooseLevelMenu.openMenu(2);";
|
||||
tooltipProfile = "GuiToolTipProfile";
|
||||
internalName = "ConfigBtn";
|
||||
class = "ChooseLevelMenuButton";
|
||||
hidden = "1";
|
||||
};
|
||||
};
|
||||
new GuiControl(ChooseLevelMenuNavButtonOverlay) {
|
||||
position = "0 61";
|
||||
extent = "1281 60";
|
||||
horizSizing = "width";
|
||||
profile = "GuiNonModalDefaultProfile";
|
||||
visible = "0";
|
||||
tooltipProfile = "GuiToolTipProfile";
|
||||
isContainer = "1";
|
||||
hidden = "1";
|
||||
|
||||
new GuiBitmapCtrl(ChooseLevelMenuPrevNavIcon) {
|
||||
BitmapAsset = "UI:Keyboard_Black_Q_image";
|
||||
|
|
@ -94,13 +105,67 @@ $guiContent = new GuiControl(ChooseLevelMenu) {
|
|||
tooltipProfile = "GuiToolTipProfile";
|
||||
};
|
||||
};
|
||||
new GuiContainer(LevelSelectContainer) {
|
||||
new GuiContainer(GameModeSelectContainer) {
|
||||
position = "196 119";
|
||||
extent = "888 566";
|
||||
horizSizing = "center";
|
||||
profile = "GuiNonModalDefaultProfile";
|
||||
tooltipProfile = "GuiToolTipProfile";
|
||||
|
||||
new GuiScrollCtrl(GameModePreviewScroll) {
|
||||
hScrollBar = "alwaysOff";
|
||||
vScrollBar = "dynamic";
|
||||
extent = "445 562";
|
||||
vertSizing = "height";
|
||||
profile = "GuiMenuScrollProfile";
|
||||
tooltipProfile = "GuiToolTipProfile";
|
||||
|
||||
new GuiStackControl(GameModePreviewArray) {
|
||||
padding = "5";
|
||||
position = "1 1";
|
||||
extent = "443 60";
|
||||
horizSizing = "width";
|
||||
vertSizing = "height";
|
||||
profile = "GuiMenuDefaultProfile";
|
||||
tooltipProfile = "GuiToolTipProfile";
|
||||
};
|
||||
};
|
||||
new GuiBitmapCtrl(GameModePreviewBitmap) {
|
||||
position = "448 0";
|
||||
extent = "440 440";
|
||||
horizSizing = "left";
|
||||
profile = "GuiNonModalDefaultProfile";
|
||||
visible = "0";
|
||||
tooltipProfile = "GuiToolTipProfile";
|
||||
hidden = "1";
|
||||
};
|
||||
new GuiTextCtrl(GameModeNameText) {
|
||||
text = "DeathMatchGame";
|
||||
position = "448 445";
|
||||
extent = "440 20";
|
||||
horizSizing = "left";
|
||||
profile = "MenuSubHeaderText";
|
||||
tooltipProfile = "GuiToolTipProfile";
|
||||
internalName = "GameModeNameTxt";
|
||||
};
|
||||
new GuiMLTextCtrl(GameModeDescriptionText) {
|
||||
position = "448 473";
|
||||
extent = "440 19";
|
||||
horizSizing = "left";
|
||||
profile = "GuiMLTextProfile";
|
||||
tooltipProfile = "GuiToolTipProfile";
|
||||
internalName = "GameModeDescTxt";
|
||||
};
|
||||
};
|
||||
new GuiContainer(LevelSelectContainer) {
|
||||
position = "196 119";
|
||||
extent = "888 566";
|
||||
horizSizing = "center";
|
||||
profile = "GuiNonModalDefaultProfile";
|
||||
visible = "0";
|
||||
tooltipProfile = "GuiToolTipProfile";
|
||||
hidden = "1";
|
||||
|
||||
new GuiScrollCtrl(LevelPreviewScroll) {
|
||||
hScrollBar = "alwaysOff";
|
||||
vScrollBar = "dynamic";
|
||||
|
|
@ -112,7 +177,7 @@ $guiContent = new GuiControl(ChooseLevelMenu) {
|
|||
new GuiStackControl(LevelPreviewArray) {
|
||||
padding = "5";
|
||||
position = "0 1";
|
||||
extent = "445 120";
|
||||
extent = "445 60";
|
||||
horizSizing = "width";
|
||||
vertSizing = "height";
|
||||
profile = "GuiMenuDefaultProfile";
|
||||
|
|
@ -120,7 +185,7 @@ $guiContent = new GuiControl(ChooseLevelMenu) {
|
|||
};
|
||||
};
|
||||
new GuiBitmapCtrl(LevelPreviewBitmap) {
|
||||
BitmapAsset = "";
|
||||
BitmapAsset = "UI:no_preview_image";
|
||||
position = "448 0";
|
||||
extent = "440 440";
|
||||
horizSizing = "left";
|
||||
|
|
@ -128,7 +193,7 @@ $guiContent = new GuiControl(ChooseLevelMenu) {
|
|||
tooltipProfile = "GuiToolTipProfile";
|
||||
};
|
||||
new GuiTextCtrl(LevelNameText) {
|
||||
text = "";
|
||||
text = "Example Level";
|
||||
position = "448 445";
|
||||
extent = "440 20";
|
||||
horizSizing = "left";
|
||||
|
|
@ -214,7 +279,7 @@ $guiContent = new GuiControl(ChooseLevelMenu) {
|
|||
tooltipProfile = "GuiToolTipProfile";
|
||||
};
|
||||
new GuiTextEditCtrl(serverNameCTRL) {
|
||||
text = "";
|
||||
text = "Torque 3D Server";
|
||||
position = "606 4";
|
||||
extent = "295 22";
|
||||
horizSizing = "left";
|
||||
|
|
@ -240,7 +305,6 @@ $guiContent = new GuiControl(ChooseLevelMenu) {
|
|||
tooltipProfile = "GuiToolTipProfile";
|
||||
};
|
||||
new GuiTextEditCtrl(serverPassCTRL) {
|
||||
text = "";
|
||||
position = "606 4";
|
||||
extent = "295 22";
|
||||
horizSizing = "left";
|
||||
|
|
@ -313,8 +377,8 @@ $guiContent = new GuiControl(ChooseLevelMenu) {
|
|||
profile = "GuiMenuPanelProfile";
|
||||
tooltipProfile = "GuiToolTipProfile";
|
||||
|
||||
new GuiIconButtonCtrl(ChooseLevelStartBtn) {
|
||||
BitmapAsset = "UI:Keyboard_Black_Return_image";
|
||||
new GuiIconButtonCtrl(ChooseLevelNextBtn) {
|
||||
BitmapAsset = "UI:Keyboard_Black_Blank_image";
|
||||
sizeIconToButton = "1";
|
||||
makeIconSquare = "1";
|
||||
textLocation = "Center";
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ function ChooseLevelMenu::onAdd( %this )
|
|||
if(!isObject(ChooseLevelAssetQuery))
|
||||
new AssetQuery(ChooseLevelAssetQuery);
|
||||
|
||||
%this.previewButtonSize = "445 120";
|
||||
$LevelPreviewButtonSize = "445 60";
|
||||
}
|
||||
|
||||
function ChooseLevelMenu::fillPrefEntries( %this )
|
||||
|
|
@ -40,8 +40,85 @@ function ChooseLevelMenu::fillPrefEntries( %this )
|
|||
function ChooseLevelMenu::onWake(%this)
|
||||
{
|
||||
%this.fillPrefEntries();
|
||||
|
||||
refreshGameModesList();
|
||||
refreshLevelsList();
|
||||
|
||||
if(!$pref::HostMultiPlayer)
|
||||
ChooseLevelTitleText.setText("SINGLE PLAYER");
|
||||
else
|
||||
ChooseLevelTitleText.setText("CREATE SERVER");
|
||||
|
||||
ChooseLevelMenuTabList-->ConfigBtn.visible = $pref::HostMultiPlayer;
|
||||
|
||||
ChooseLevelMenuTabList.visible = true;//$pref::HostMultiPlayer;
|
||||
ChooseLevelMenuNavButtonOverlay.visible = true;//$pref::HostMultiPlayer;
|
||||
|
||||
%this.schedule(32, openMenu, 0);
|
||||
}
|
||||
|
||||
function refreshGameModesList()
|
||||
{
|
||||
GameModePreviewArray.clear();
|
||||
|
||||
$pref::Server::GameMode = "";
|
||||
ChooseLevelMenuTabList-->LevelBtn.active = false;
|
||||
|
||||
//popilate the gamemodes list first
|
||||
%gamemodeList = getGameModesList();
|
||||
%gameModeCount = %gamemodeList.count();
|
||||
|
||||
for (%i=0; %i<%gameModeCount; %i++)
|
||||
{
|
||||
%gameModeObj = %gamemodeList.getKey(%i);
|
||||
if(isObject(%gameModeObj))
|
||||
{
|
||||
%gameModeName = %gameModeObj.gameModeName;
|
||||
if(%gameModeName $= "")
|
||||
%gameModeName = %gameModeObj.getName();
|
||||
|
||||
%preview = new GuiContainer() {
|
||||
position = "0 0";
|
||||
extent = $LevelPreviewButtonSize;
|
||||
horizSizing = "right";
|
||||
vertSizing = "bottom";
|
||||
gameModeObj = %gameModeObj;
|
||||
gameModeDesc = %gameModeObj.description;
|
||||
previewImage = %gameModeObj.previewImage;
|
||||
cansave = false;
|
||||
|
||||
new GuiToggleButtonCtrl() {
|
||||
position = $LevelPreviewButtonSize.y SPC 0;
|
||||
extent = $LevelPreviewButtonSize.x - $LevelPreviewButtonSize.y - 5 SPC $LevelPreviewButtonSize.y;
|
||||
profile = GuiMenuButtonProfile;
|
||||
horizSizing = "right";
|
||||
vertSizing = "bottom";
|
||||
internalName = "button";
|
||||
class = "GameModePreviewButton";
|
||||
text = %gameModeName;
|
||||
command = "ToggleGameMode(" @ %i @ ");"; //allow doubleclick to quick action it
|
||||
textMargin = 120;
|
||||
};
|
||||
|
||||
new GuiBitmapCtrl() {
|
||||
position = "0 0";
|
||||
extent = $LevelPreviewButtonSize.y SPC $LevelPreviewButtonSize.y;
|
||||
internalName = "checkbox";
|
||||
bitmapAsset = "UI:toggleMarker_image";
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
GameModePreviewArray.add(%preview);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function refreshLevelsList()
|
||||
{
|
||||
LevelPreviewArray.clear();
|
||||
|
||||
//fetch the levelAssets
|
||||
ChooseLevelAssetQuery.clear();
|
||||
AssetDatabase.findAssetType(ChooseLevelAssetQuery, "LevelAsset");
|
||||
|
||||
|
|
@ -57,6 +134,8 @@ function ChooseLevelMenu::onWake(%this)
|
|||
return;
|
||||
}
|
||||
|
||||
//filter the levelAssets by the gamemode selected
|
||||
%filteredIndex = 0;
|
||||
for(%i=0; %i < %count; %i++)
|
||||
{
|
||||
%assetId = ChooseLevelAssetQuery.getAsset(%i);
|
||||
|
|
@ -71,6 +150,46 @@ function ChooseLevelMenu::onWake(%this)
|
|||
if ( !isFile(%file) )
|
||||
continue;
|
||||
|
||||
if( %levelAsset.isSubScene )
|
||||
continue;
|
||||
|
||||
//filter for selected gamemode
|
||||
%levelGameModes = %levelAsset.gameModesNames;
|
||||
|
||||
//If the level has no gamemodes defined, we just assume the default case of it being a wildcard to whatever gamemode
|
||||
//is available
|
||||
if(%levelGameModes $= "")
|
||||
{
|
||||
%foundGameModeMatch = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
%foundGameModeMatch = false;
|
||||
for(%gm = 0; %gm < getTokenCount(%levelGameModes, ";"); %gm++)
|
||||
{
|
||||
%gameModeName = getToken(%levelGameModes, ";", %gm);
|
||||
|
||||
for(%g=0; %g < GameModePreviewArray.getCount(); %g++)
|
||||
{
|
||||
%gmb = GameModePreviewArray.getObject(%g);
|
||||
if(!isObject(%gmb.gameModeObj) || (!%gmb.gameModeObj.active && !%gmb.gameModeObj.alwaysActive))
|
||||
continue;
|
||||
|
||||
if(%gameModeName $= %gmb.gameModeObj.getName())
|
||||
{
|
||||
%foundGameModeMatch = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(%foundGameModeMatch)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(!%foundGameModeMatch)
|
||||
continue;
|
||||
|
||||
%levelPreviewImg = %levelAsset.getPreviewImagePath();
|
||||
|
||||
if (!isFile(%levelPreviewImg))
|
||||
|
|
@ -78,7 +197,7 @@ function ChooseLevelMenu::onWake(%this)
|
|||
|
||||
%preview = new GuiIconButtonCtrl() {
|
||||
position = "0 0";
|
||||
extent = %this.previewButtonSize;
|
||||
extent = $LevelPreviewButtonSize;
|
||||
buttonType = "PushButton";
|
||||
profile = GuiMenuButtonLeftJustProfile;
|
||||
horizSizing = "right";
|
||||
|
|
@ -86,7 +205,7 @@ function ChooseLevelMenu::onWake(%this)
|
|||
internalName = "button";
|
||||
class = "LevelPreviewButton";
|
||||
//command = "$selectedLevelAsset = " @ %assetId @ ";";
|
||||
altCommand = "ChooseLevelBegin(1);"; //allow doubleclick to quick action it
|
||||
altCommand = "ChooseLevelBegin(" @ %filteredIndex @ ");"; //allow doubleclick to quick action it
|
||||
text = %levelAsset.levelName;
|
||||
bitmapAsset = %levelPreviewImg;
|
||||
levelAsset = %levelAsset;
|
||||
|
|
@ -101,26 +220,19 @@ function ChooseLevelMenu::onWake(%this)
|
|||
};
|
||||
|
||||
LevelPreviewArray.add(%preview);
|
||||
|
||||
%filteredIndex++;
|
||||
}
|
||||
|
||||
|
||||
GameModePreviewArray.listPosition = 0;
|
||||
LevelPreviewArray.listPosition = 0;
|
||||
|
||||
// Also add the new level mission as defined in the world editor settings
|
||||
// if we are choosing a level to launch in the editor.
|
||||
if ( %this.launchInEditor )
|
||||
if ( ChooseLevelMenu.launchInEditor )
|
||||
{
|
||||
%this.addMissionFile( "tools/levels/DefaultEditorLevel.mis" );
|
||||
ChooseLevelMenu.addMissionFile( "tools/levels/DefaultEditorLevel.mis" );
|
||||
}
|
||||
|
||||
if(!$pref::HostMultiPlayer)
|
||||
ChooseLevelTitleText.setText("SINGLE PLAYER");
|
||||
else
|
||||
ChooseLevelTitleText.setText("CREATE SERVER");
|
||||
|
||||
ChooseLevelMenuTabList.visible = $pref::HostMultiPlayer;
|
||||
ChooseLevelMenuNavButtonOverlay.visible = $pref::HostMultiPlayer;
|
||||
|
||||
%this.schedule(32, openMenu, 0);
|
||||
}
|
||||
|
||||
if(!isObject( ChooseLevelActionMap ) )
|
||||
|
|
@ -133,8 +245,8 @@ if(!isObject( ChooseLevelActionMap ) )
|
|||
ChooseLevelActionMap.bind( keyboard, e, ChooseLevelMenuNextMenu);
|
||||
ChooseLevelActionMap.bind( gamepad, btn_r, ChooseLevelMenuNextMenu);
|
||||
|
||||
ChooseLevelActionMap.bind( keyboard, Space, ChooseLevelBegin );
|
||||
ChooseLevelActionMap.bind( gamepad, btn_a, ChooseLevelBegin );
|
||||
ChooseLevelActionMap.bind( keyboard, Space, ChooseLevelMenuOption );
|
||||
ChooseLevelActionMap.bind( gamepad, btn_a, ChooseLevelMenuOption );
|
||||
}
|
||||
|
||||
function ChooseLevelMenu::syncGUI(%this)
|
||||
|
|
@ -155,10 +267,31 @@ function ChooseLevelMenu::syncGUI(%this)
|
|||
|
||||
ChooseLevelBackBtn.setBitmap(BaseUIActionMap.getCommandButtonBitmap(%device, "BaseUIBackOut"));
|
||||
|
||||
ChooseLevelStartBtn.setBitmap(ChooseLevelActionMap.getCommandButtonBitmap(%device, "ChooseLevelBegin"));
|
||||
if(ChooseLevelMenu.currentMenuIdx == 0)
|
||||
ChooseLevelNextBtn.text = "Toggle Mode";
|
||||
else
|
||||
ChooseLevelNextBtn.text = "Start Game";
|
||||
|
||||
ChooseLevelNextBtn.setBitmap(ChooseLevelActionMap.getCommandButtonBitmap(%device, "ChooseLevelMenuOption"));
|
||||
|
||||
ChooseLevelMenuPrevNavIcon.setBitmap(ChooseLevelActionMap.getCommandButtonBitmap(%device, "ChooseLevelMenuPrevMenu"));
|
||||
ChooseLevelMenuNextNavIcon.setBitmap(ChooseLevelActionMap.getCommandButtonBitmap(%device, "ChooseLevelMenuNextMenu"));
|
||||
|
||||
%hasActiveGameMode = false;
|
||||
for(%i=0; %i < GameModePreviewArray.getCount(); %i++)
|
||||
{
|
||||
%btn = GameModePreviewArray.getObject(%i);
|
||||
if(!isObject(%btn.gameModeObj))
|
||||
continue;
|
||||
|
||||
if((%btn.gameModeObj.isActive() || %btn.gameModeObj.isAlwaysActive()) == true)
|
||||
{
|
||||
%hasActiveGameMode = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ChooseLevelMenuTabList-->LevelBtn.active = %hasActiveGameMode;
|
||||
}
|
||||
|
||||
function LevelPreviewArray::syncGUI(%this)
|
||||
|
|
@ -169,14 +302,42 @@ function LevelPreviewArray::syncGUI(%this)
|
|||
$selectedLevelAsset = %btn.levelAssetId;
|
||||
}
|
||||
|
||||
function GameModePreviewArray::syncGUI(%this)
|
||||
{
|
||||
for(%i=0; %i < %this.getCount(); %i++)
|
||||
{
|
||||
%btn = %this.getObject(%i);
|
||||
%btn-->button.setHighlighted(false);
|
||||
|
||||
%bitmapAst = (%btn.gameModeObj.active || %btn.gameModeObj.alwaysActive) ? "UI:toggleMarker_h_image" : "UI:toggleMarker_image";
|
||||
%btn-->checkbox.setBitmap(%bitmapAst);
|
||||
}
|
||||
|
||||
%btn = %this.getObject(%this.listPosition);
|
||||
%btn-->button.setHighlighted(true);
|
||||
|
||||
//$pref::Server::GameMode = %btn.gameModeObject;
|
||||
}
|
||||
|
||||
function ChooseLevelMenuPrevMenu(%val)
|
||||
{
|
||||
if(%val && $pref::HostMultiPlayer)
|
||||
if(%val)
|
||||
{
|
||||
%currentIdx = ChooseLevelMenu.currentMenuIdx;
|
||||
ChooseLevelMenu.currentMenuIdx -= 1;
|
||||
|
||||
ChooseLevelMenu.currentMenuIdx = mClamp(ChooseLevelMenu.currentMenuIdx, 0, 1);
|
||||
%endIndex = 1;
|
||||
if($pref::HostMultiPlayer)
|
||||
%endIndex = 2;
|
||||
|
||||
ChooseLevelMenu.currentMenuIdx = mClamp(ChooseLevelMenu.currentMenuIdx, 0, %endIndex);
|
||||
|
||||
//bail if we're trying to step into a hidden or disabled menu
|
||||
if(!ChooseLevelMenu.isMenuAvailable(ChooseLevelMenu.currentMenuIdx))
|
||||
{
|
||||
ChooseLevelMenu.currentMenuIdx = %currentIdx;
|
||||
return;
|
||||
}
|
||||
|
||||
if(%currentIdx == ChooseLevelMenu.currentMenuIdx)
|
||||
return;
|
||||
|
|
@ -187,12 +348,23 @@ function ChooseLevelMenuPrevMenu(%val)
|
|||
|
||||
function ChooseLevelMenuNextMenu(%val)
|
||||
{
|
||||
if(%val && $pref::HostMultiPlayer)
|
||||
if(%val)
|
||||
{
|
||||
%currentIdx = ChooseLevelMenu.currentMenuIdx;
|
||||
ChooseLevelMenu.currentMenuIdx += 1;
|
||||
|
||||
ChooseLevelMenu.currentMenuIdx = mClamp(ChooseLevelMenu.currentMenuIdx, 0, 1);
|
||||
%endIndex = 1;
|
||||
if($pref::HostMultiPlayer)
|
||||
%endIndex = 2;
|
||||
|
||||
ChooseLevelMenu.currentMenuIdx = mClamp(ChooseLevelMenu.currentMenuIdx, 0, %endIndex);
|
||||
|
||||
//bail if we're trying to step into a hidden or disabled menu
|
||||
if(!ChooseLevelMenu.isMenuAvailable(ChooseLevelMenu.currentMenuIdx))
|
||||
{
|
||||
ChooseLevelMenu.currentMenuIdx = %currentIdx;
|
||||
return;
|
||||
}
|
||||
|
||||
if(%currentIdx == ChooseLevelMenu.currentMenuIdx)
|
||||
return;
|
||||
|
|
@ -201,15 +373,17 @@ function ChooseLevelMenuNextMenu(%val)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
function ChooseLevelMenu::openMenu(%this, %menuIdx)
|
||||
{
|
||||
LevelSelectContainer.setVisible(%menuIdx == 0);
|
||||
ServerConfigContainer.setVisible(%menuIdx == 1);
|
||||
|
||||
GameModeSelectContainer.setVisible(%menuIdx == 0);
|
||||
LevelSelectContainer.setVisible(%menuIdx == 1);
|
||||
ServerConfigContainer.setVisible(%menuIdx == 2);
|
||||
|
||||
if(%menuIdx == 0)
|
||||
$MenuList = LevelPreviewArray;
|
||||
$MenuList = GameModePreviewArray;
|
||||
else if(%menuIdx == 1)
|
||||
$MenuList = LevelPreviewArray;
|
||||
else if(%menuIdx == 2)
|
||||
$MenuList = ServerConfigList;
|
||||
|
||||
%this.currentMenuIdx = %menuIdx;
|
||||
|
|
@ -220,37 +394,78 @@ function ChooseLevelMenu::openMenu(%this, %menuIdx)
|
|||
%this.syncGui();
|
||||
}
|
||||
|
||||
function ChooseLevelBegin(%val)
|
||||
function ChooseLevelMenu::isMenuAvailable(%this, %menuIdx)
|
||||
{
|
||||
if(%menuIdx == 0)
|
||||
%btn = %this-->GameModeBtn;
|
||||
else if(%menuIdx == 1)
|
||||
%btn = %this-->LevelBtn;
|
||||
else if(%menuIdx == 2)
|
||||
%btn = %this-->ConfigBtn;
|
||||
|
||||
return %btn.isActive() && %btn.isVisible();
|
||||
}
|
||||
|
||||
function ChooseLevelMenuOption(%val)
|
||||
{
|
||||
if(%val)
|
||||
{
|
||||
// So we can't fire the button when loading is in progress.
|
||||
if ( isObject( ServerGroup ) )
|
||||
return;
|
||||
|
||||
Canvas.popDialog();
|
||||
|
||||
%entry = LevelPreviewArray.getObject(LevelPreviewArray.listPosition);
|
||||
|
||||
if(!AssetDatabase.isDeclaredAsset(%entry.levelAssetId))
|
||||
{
|
||||
MessageBoxOK("Error", "Selected level preview does not have a valid level asset!");
|
||||
return;
|
||||
}
|
||||
|
||||
$selectedLevelAsset = %entry.levelAssetId;
|
||||
if(ChooseLevelMenu.currentMenuIdx == 0)
|
||||
ToggleGameMode(ChooseLevelMenu.listPosition);
|
||||
else if(ChooseLevelMenu.currentMenuIdx == 1)
|
||||
ChooseLevelBegin(ChooseLevelMenu.listPosition);
|
||||
}
|
||||
}
|
||||
|
||||
// Launch the chosen level with the editor open?
|
||||
if ( ChooseLevelMenu.launchInEditor )
|
||||
{
|
||||
activatePackage( "BootEditor" );
|
||||
ChooseLevelMenu.launchInEditor = false;
|
||||
StartGame(%entry.levelAssetId, "SinglePlayer");
|
||||
}
|
||||
else
|
||||
{
|
||||
StartGame(%entry.levelAssetId);
|
||||
}
|
||||
function ToggleGameMode(%index)
|
||||
{
|
||||
if(%index $= "")
|
||||
%index = $MenuList.listPosition;
|
||||
|
||||
%entry = GameModePreviewArray.getObject(%index);
|
||||
if(!isObject(%entry) || !isObject(%entry.gameModeObj))
|
||||
{
|
||||
MessageBoxOK("Error", "Selected game mode does not have a valid mode");
|
||||
return;
|
||||
}
|
||||
|
||||
%entry.gameModeObj.active = !%entry.gameModeObj.active;
|
||||
|
||||
refreshLevelsList();
|
||||
|
||||
$MenuList.syncGui();
|
||||
ChooseLevelMenu.syncGui();
|
||||
|
||||
}
|
||||
|
||||
function ChooseLevelBegin(%index)
|
||||
{
|
||||
// So we can't fire the button when loading is in progress.
|
||||
if ( isObject( ServerGroup ) )
|
||||
return;
|
||||
|
||||
Canvas.popDialog();
|
||||
|
||||
%entry = LevelPreviewArray.getObject(%index);
|
||||
|
||||
if(!AssetDatabase.isDeclaredAsset(%entry.levelAssetId))
|
||||
{
|
||||
MessageBoxOK("Error", "Selected level preview does not have a valid level asset!");
|
||||
return;
|
||||
}
|
||||
|
||||
$selectedLevelAsset = %entry.levelAssetId;
|
||||
|
||||
// Launch the chosen level with the editor open?
|
||||
if ( ChooseLevelMenu.launchInEditor )
|
||||
{
|
||||
activatePackage( "BootEditor" );
|
||||
ChooseLevelMenu.launchInEditor = false;
|
||||
StartGame(%entry.levelAssetId, "SinglePlayer");
|
||||
}
|
||||
else
|
||||
{
|
||||
StartGame(%entry.levelAssetId);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -270,6 +485,23 @@ function ChooseLevelMenu::onSleep( %this )
|
|||
}
|
||||
}
|
||||
|
||||
function GameModePreviewButton::onHighlighted(%this, %highlighted)
|
||||
{
|
||||
if(%highlighted)
|
||||
{
|
||||
$MenuList.listPosition = $MenuList.getObjectIndex(%this.getParent());
|
||||
|
||||
GameModePreviewBitmap.bitmapAsset = %this.previewImage;
|
||||
|
||||
GameModePreviewBitmap.visible = (%this.previewImage !$= "");
|
||||
|
||||
GameModeNameText.text = %this.text;
|
||||
GameModeDescriptionText.setText(%this.gameModeDesc);
|
||||
|
||||
GameModePreviewScroll.scrollToObject(%this);
|
||||
}
|
||||
}
|
||||
|
||||
function LevelPreviewButton::onHighlighted(%this, %highlighted)
|
||||
{
|
||||
if(%highlighted)
|
||||
|
|
|
|||
BIN
Templates/BaseGame/game/data/UI/images/toggleMarker.png
Normal file
BIN
Templates/BaseGame/game/data/UI/images/toggleMarker.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 6.6 KiB |
BIN
Templates/BaseGame/game/data/UI/images/toggleMarker_h.png
Normal file
BIN
Templates/BaseGame/game/data/UI/images/toggleMarker_h.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 6.6 KiB |
|
|
@ -0,0 +1,3 @@
|
|||
<ImageAsset
|
||||
AssetName="toggleMarker_h_image"
|
||||
imageFile="@assetFile=toggleMarker_h.png"/>
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
<ImageAsset
|
||||
AssetName="toggleMarker_image"
|
||||
imageFile="@assetFile=toggleMarker.png"/>
|
||||
|
|
@ -87,6 +87,7 @@ function initializeAssetBrowser()
|
|||
exec("./scripts/looseFileAudit." @ $TorqueScriptFileExtension);
|
||||
exec("./scripts/creator." @ $TorqueScriptFileExtension);
|
||||
exec("./scripts/setAssetTarget." @ $TorqueScriptFileExtension);
|
||||
exec("./scripts/utils." @ $TorqueScriptFileExtension);
|
||||
|
||||
//Processing for the different asset types
|
||||
exec("./scripts/assetTypes/component." @ $TorqueScriptFileExtension);
|
||||
|
|
@ -110,6 +111,7 @@ function initializeAssetBrowser()
|
|||
exec("./scripts/assetTypes/looseFiles." @ $TorqueScriptFileExtension);
|
||||
exec("./scripts/assetTypes/prefab." @ $TorqueScriptFileExtension);
|
||||
exec("./scripts/assetTypes/creatorObj." @ $TorqueScriptFileExtension);
|
||||
exec("./scripts/assetTypes/gameMode." @ $TorqueScriptFileExtension);
|
||||
|
||||
new ScriptObject( AssetBrowserPlugin )
|
||||
{
|
||||
|
|
|
|||
|
|
@ -79,7 +79,6 @@ function AssetBrowser_addModuleWindow::CreateNewModule(%this)
|
|||
%line = strreplace( %line, "@@", %newModuleName );
|
||||
|
||||
%file.writeline(%line);
|
||||
echo(%line);
|
||||
}
|
||||
|
||||
%file.close();
|
||||
|
|
|
|||
|
|
@ -0,0 +1,35 @@
|
|||
AssetBrowser::registerObjectType("GameModeType", "Gamemode Objects", "Gamemode");
|
||||
|
||||
function GameModeType::setupCreateNew()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
function GameModeType::onCreateNew()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
function GameModeType::buildBrowserElement(%this, %className, %previewData)
|
||||
{
|
||||
//echo("DatablockObjectType::buildBrowserElement() - " @ %datablock @ ", " @ %name @ ", " @ %previewData);
|
||||
%previewData.assetName = %this.getName();
|
||||
%previewData.assetPath = %this.getFileName();
|
||||
|
||||
%previewData.previewImage = "ToolsModule:genericAssetIcon_image";
|
||||
|
||||
//Lets see if we have a icon for specifically for this datablock type
|
||||
%dataClass = %this.getClassName();
|
||||
%dataClass = strreplace(%dataClass, "Data", "");
|
||||
|
||||
%previewImage = "tools/classIcons/" @ %dataClass @ ".png";
|
||||
if(isFile(%previewImage))
|
||||
{
|
||||
%previewData.previewImage = %previewImage;
|
||||
}
|
||||
|
||||
//%previewData.assetFriendlyName = %assetDef.assetName;
|
||||
%previewData.assetDesc = %this;
|
||||
%previewData.tooltip = "\nGameMode Name: " @ %previewData.assetName @
|
||||
"\nPath: " @ %previewData.assetPath;
|
||||
}
|
||||
|
|
@ -3,6 +3,8 @@ function AssetBrowser::setupCreateNewLevelAsset(%this)
|
|||
NewAssetPropertiesInspector.startGroup("Level");
|
||||
NewAssetPropertiesInspector.addField("LevelName", "Level Name", "String", "Human-readable name of new level", "", "", %this.newAssetSettings);
|
||||
NewAssetPropertiesInspector.addField("levelPreviewImage", "Level Preview Image", "Image", "Preview Image for the level", "", "", %this.newAssetSettings);
|
||||
|
||||
NewAssetPropertiesInspector.addField("isSubScene", "Is SubScene", "bool", "Is this levelAsset intended as a subScene", "", "", %this.newAssetSettings);
|
||||
|
||||
NewAssetPropertiesInspector.endGroup();
|
||||
}
|
||||
|
|
@ -20,14 +22,16 @@ function AssetBrowser::createLevelAsset(%this)
|
|||
|
||||
%assetPath = NewAssetTargetAddress.getText() @ "/";
|
||||
|
||||
%misExtension = AssetBrowser.newAssetSettings.isSubScene ? ".subMis" : ".mis";
|
||||
|
||||
%tamlpath = %assetPath @ %assetName @ ".asset.taml";
|
||||
%levelPath = %assetPath @ %assetName @ ".mis";
|
||||
%levelPath = %assetPath @ %assetName @ %misExtension;
|
||||
|
||||
%asset = new LevelAsset()
|
||||
{
|
||||
AssetName = %assetName;
|
||||
versionId = 1;
|
||||
LevelFile = %assetName @ ".mis";
|
||||
LevelFile = %assetName @ %misExtension;
|
||||
DecalsFile = %assetName @ ".mis.decals";
|
||||
PostFXPresetFile = %assetName @ ".postfxpreset." @ $TorqueScriptFileExtension;
|
||||
ForestFile = %assetName @ ".forest";
|
||||
|
|
@ -35,6 +39,7 @@ function AssetBrowser::createLevelAsset(%this)
|
|||
LevelName = AssetBrowser.newAssetSettings.levelName;
|
||||
AssetDescription = AssetBrowser.newAssetSettings.description;
|
||||
PreviewImage = AssetBrowser.newAssetSettings.levelPreviewImage;
|
||||
isSubScene = AssetBrowser.newAssetSettings.isSubScene;
|
||||
};
|
||||
|
||||
TamlWrite(%asset, %tamlpath);
|
||||
|
|
@ -58,15 +63,32 @@ function AssetBrowser::createLevelAsset(%this)
|
|||
|
||||
%moduleDef = ModuleDatabase.findModule(%moduleName, 1);
|
||||
%addSuccess = AssetDatabase.addDeclaredAsset(%moduleDef, %tamlpath);
|
||||
|
||||
if(!%addSuccess)
|
||||
{
|
||||
error("AssetBrowser::createLevelAsset() - failed to add declared asset: " @ %tamlpath @ " for module: " @ %moduleDef);
|
||||
}
|
||||
|
||||
AssetBrowser.refresh();
|
||||
|
||||
return %tamlpath;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
//SubScene derivative
|
||||
//==============================================================================
|
||||
function AssetBrowser::setupCreateNewSubScene(%this)
|
||||
{
|
||||
%this.newAssetSettings.isSubScene = true;
|
||||
%this.newAssetSettings.assetType = "LevelAsset";
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
|
||||
function AssetBrowser::editLevelAsset(%this, %assetDef)
|
||||
{
|
||||
schedule( 1, 0, "EditorOpenMission", %assetDef);
|
||||
if(!%assetDef.isSubScene)
|
||||
schedule( 1, 0, "EditorOpenMission", %assetDef);
|
||||
}
|
||||
|
||||
//Renames the asset
|
||||
|
|
@ -150,4 +172,100 @@ function AssetBrowser::buildLevelAssetPreview(%this, %assetDef, %previewData)
|
|||
"Asset Type: Level Asset\n" @
|
||||
"Asset Definition ID: " @ %assetDef @ "\n" @
|
||||
"Level File path: " @ %assetDef.getLevelPath();
|
||||
}
|
||||
|
||||
function createAndAssignLevelAsset(%moduleName, %assetName)
|
||||
{
|
||||
$createAndAssignField.apply(%moduleName @ ":" @ %assetName);
|
||||
}
|
||||
|
||||
function EWorldEditor::createSelectedAsSubScene( %this, %object )
|
||||
{
|
||||
//create new level asset here
|
||||
AssetBrowser.setupCreateNewAsset("SubScene", AssetBrowser.selectedModule, "finishCreateSelectedAsSubScene");
|
||||
%this.contextActionObject = %object;
|
||||
}
|
||||
|
||||
function finishCreateSelectedAsSubScene(%assetId)
|
||||
{
|
||||
echo("finishCreateSelectedAsSubScene");
|
||||
|
||||
%subScene = new SubScene() {
|
||||
levelAsset = %assetId;
|
||||
};
|
||||
|
||||
%levelAssetDef = AssetDatabase.acquireAsset(%assetId);
|
||||
%levelFilePath = %levelAssetDef.getLevelPath();
|
||||
|
||||
//write out to file
|
||||
EWorldEditor.contextActionObject.save(%levelFilePath);
|
||||
|
||||
AssetDatabase.releaseAsset(%assetId);
|
||||
|
||||
getRootScene().add(%subScene);
|
||||
|
||||
EWorldEditor.contextActionObject.delete();
|
||||
|
||||
%subScene.load();
|
||||
|
||||
%subScene.recalculateBounds();
|
||||
|
||||
%scalar = $SubScene::createScalar;
|
||||
if(%scalar $= "")
|
||||
%scalar = 1.5;
|
||||
|
||||
//pad for loading boundary
|
||||
%subScene.scale = VectorScale(%subScene.scale, %scalar);
|
||||
}
|
||||
|
||||
function GuiInspectorTypeLevelAssetPtr::onControlDropped( %this, %payload, %position )
|
||||
{
|
||||
Canvas.popDialog(EditorDragAndDropLayer);
|
||||
|
||||
// Make sure this is a color swatch drag operation.
|
||||
if( !%payload.parentGroup.isInNamespaceHierarchy( "AssetPreviewControlType_AssetDrop" ) )
|
||||
return;
|
||||
|
||||
%assetType = %payload.assetType;
|
||||
%module = %payload.moduleName;
|
||||
%assetName = %payload.assetName;
|
||||
|
||||
if(%assetType $= "LevelAsset")
|
||||
{
|
||||
%cmd = %this @ ".apply(\""@ %module @ ":" @ %assetName @ "\");";
|
||||
eval(%cmd);
|
||||
}
|
||||
|
||||
EWorldEditor.isDirty = true;
|
||||
}
|
||||
|
||||
function AssetBrowser::onLevelAssetEditorDropped(%this, %assetDef, %position)
|
||||
{
|
||||
%assetId = %assetDef.getAssetId();
|
||||
|
||||
if(!%assetDef.isSubScene)
|
||||
{
|
||||
errorf("Cannot drag-and-drop LevelAsset into WorldEditor");
|
||||
return;
|
||||
}
|
||||
|
||||
%newSubScene = new SubScene()
|
||||
{
|
||||
position = %position;
|
||||
levelAsset = %assetId;
|
||||
};
|
||||
|
||||
getScene(0).add(%newSubScene);
|
||||
|
||||
%newSubScene.load();
|
||||
%newSubScene.recalculateBounds();
|
||||
|
||||
EWorldEditor.clearSelection();
|
||||
EWorldEditor.selectObject(%newSubScene);
|
||||
|
||||
EWorldEditor.dropSelection();
|
||||
|
||||
EWorldEditor.isDirty = true;
|
||||
|
||||
MECreateUndoAction::submit(%newSubScene );
|
||||
}
|
||||
|
|
@ -176,6 +176,31 @@ function AssetBrowser::performRenameAsset(%this, %originalAssetName, %newName)
|
|||
%buildCommand = %this @ ".rename" @ EditAssetPopup.assetType @ "(" @ %assetDef @ "," @ %newName @ ");";
|
||||
eval(%buildCommand);
|
||||
}
|
||||
else
|
||||
{
|
||||
//do generic action here
|
||||
%oldAssetId = %moduleName @ ":" @ %originalAssetName;
|
||||
%assetDef = AssetDatabase.acquireAsset(%oldAssetId);
|
||||
|
||||
%assetFileName = fileName(%assetDef.getFileName());
|
||||
%assetFilePath = filePath(%assetDef.getFileName());
|
||||
|
||||
%pattern = %assetFilePath @ "/" @ %assetFileName @ ".*";
|
||||
|
||||
echo("Searching for matches of asset files following pattern: " @ %pattern);
|
||||
|
||||
//get list of files that match the name in the same dir
|
||||
//do a rename on them
|
||||
for (%file = findFirstFileMultiExpr(%pattern); %file !$= ""; %file = findNextFileMultiExpr(%pattern))
|
||||
{
|
||||
if(%file !$= %assetFileName)
|
||||
renameAssetLooseFile(%file, %newName);
|
||||
}
|
||||
|
||||
//update the assetDef
|
||||
replaceInFile(%assetDef.getFileName(), %originalAssetName, %newName);
|
||||
renameAssetFile(%assetDef, %newName);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
|
|
@ -117,7 +117,8 @@ function AssetBrowser::buildPopupMenus(%this)
|
|||
//item[ 0 ] = "Create Component" TAB AddNewComponentAssetPopup;
|
||||
item[ 0 ] = "Create Script" TAB "" TAB "AssetBrowser.setupCreateNewAsset(\"ScriptAsset\", AssetBrowser.selectedModule);";
|
||||
item[ 1 ] = "Create State Machine" TAB "" TAB "AssetBrowser.setupCreateNewAsset(\"StateMachineAsset\", AssetBrowser.selectedModule);";
|
||||
//item[ 3 ] = "-";
|
||||
item[ 2 ] = "-";
|
||||
item[ 3 ] = "Create Game Mode" TAB "" TAB "AssetBrowser.setupCreateNewAsset(\"GameMode\", AssetBrowser.selectedModule);";
|
||||
//item[ 3 ] = "Create Game Object" TAB "" TAB "AssetBrowser.createNewGameObjectAsset(\"NewGameObject\", AssetBrowser.selectedModule);";
|
||||
};
|
||||
//%this.AddNewScriptAssetPopup.insertSubMenu(0, "Create Component", AddNewComponentAssetPopup);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,176 @@
|
|||
//This file implements game mode logic for an Example gamemode. The primary functions:
|
||||
//@@::onMissionStart
|
||||
//@@::onMissionReset
|
||||
//@@::onMissionEnd
|
||||
//Are the primary hooks for the server to start, restart and end any active gamemodes
|
||||
//onMissionStart, for example is called from core/clientServer/scripts/server/levelLoad.cs
|
||||
//It's called once the server has successfully loaded the level, and has parsed
|
||||
//through any active scenes to get GameModeNames defined by them. It then iterates
|
||||
//over them and calls these callbacks to envoke gamemode behaviors. This allows multiple
|
||||
//gamemodes to be in effect at one time. Modules can implement as many gamemodes as you want.
|
||||
//
|
||||
//For levels that can be reused for multiple gammodes, the general setup would be a primary level file
|
||||
//with the Scene in it having the main geometry, weapons, terrain, etc. You would then have subScenes that
|
||||
//each contain what's necessary for the given gamemode, such as a subScene that just adds the flags and capture
|
||||
//triggers for a CTF mode. The subscene would then have it's GameModeName defined to run the CTF gamemode logic
|
||||
//and the levelLoad code will execute it.
|
||||
|
||||
if(!isObject(@@))
|
||||
{
|
||||
new GameMode(@@){};
|
||||
}
|
||||
|
||||
//This function is called when the level finishes loading. It sets up the initial configuration, variables and
|
||||
//spawning and dynamic objects, timers or rules needed for the gamemode to run
|
||||
function @@::onMissionStart(%this)
|
||||
{
|
||||
//set up the game and game variables
|
||||
%this.initGameVars();
|
||||
|
||||
if (%this.isActive())
|
||||
{
|
||||
error("@@::onMissionStart: End the game first!");
|
||||
return;
|
||||
}
|
||||
|
||||
%this.setActive(true);
|
||||
}
|
||||
|
||||
//This function is called when the level ends. It can be envoked due to the gamemode ending
|
||||
//but is also kicked off when the game server is shut down as a form of cleanup for anything the gamemode
|
||||
//created or is managing like the above mentioned dynamic objects or timers
|
||||
function @@::onMissionEnded(%this)
|
||||
{
|
||||
if (!%this.isActive())
|
||||
{
|
||||
error("@@::onMissionEnded: No game running!");
|
||||
return;
|
||||
}
|
||||
|
||||
%this.setActive(false);
|
||||
}
|
||||
|
||||
//This function is called in the event the server resets and is used to re-initialize the gamemode
|
||||
function @@::onMissionReset(%this)
|
||||
{
|
||||
// Called by resetMission(), after all the temporary mission objects
|
||||
// have been deleted.
|
||||
%this.initGameVars();
|
||||
}
|
||||
|
||||
//This sets up our gamemode's duration time
|
||||
function @@::initGameVars(%this)
|
||||
{
|
||||
// Set the gameplay parameters
|
||||
%this.duration = 30 * 60;
|
||||
}
|
||||
|
||||
//This is called when the timer runs out, allowing the gamemode to end
|
||||
function @@::onGameDurationEnd(%this)
|
||||
{
|
||||
//we don't end if we're currently editing the level
|
||||
if (%this.duration && !(EditorIsActive() && GuiEditorIsActive()))
|
||||
%this.onMissionEnded();
|
||||
}
|
||||
|
||||
//This is called to actually spawn a control object for the player to utilize
|
||||
//A player character, spectator camera, etc.
|
||||
function @@::spawnControlObject(%this, %client)
|
||||
{
|
||||
//In this example, we just spawn a camera
|
||||
/*if (!isObject(%client.camera))
|
||||
{
|
||||
if(!isObject(Observer))
|
||||
{
|
||||
datablock CameraData(Observer)
|
||||
{
|
||||
mode = "Observer";
|
||||
};
|
||||
}
|
||||
|
||||
%client.camera = spawnObject("Camera", Observer);
|
||||
}
|
||||
|
||||
// If we have a camera then set up some properties
|
||||
if (isObject(%client.camera))
|
||||
{
|
||||
MissionCleanup.add( %this.camera );
|
||||
%client.camera.scopeToClient(%client);
|
||||
|
||||
%client.setControlObject(%client.camera);
|
||||
|
||||
%client.camera.setTransform("0 0 1 0 0 0 0");
|
||||
}*/
|
||||
|
||||
}
|
||||
|
||||
//This is called when the client has finished loading the mission, but aren't "in" it yet
|
||||
//allowing for some last-second prepwork
|
||||
function @@::onClientMissionLoaded(%this)
|
||||
{
|
||||
$clientLoaded++;
|
||||
if ($clientLoaded == $clientConneted)
|
||||
$gameReady = true;
|
||||
}
|
||||
|
||||
//This is called when the client has initially established a connection to the game server
|
||||
//It's used for setting up anything ahead of time for the client, such as loading in client-passed
|
||||
//config stuffs, saved data or the like that should be handled BEFORE the client has actually entered
|
||||
//the game itself
|
||||
function @@::onClientConnect(%this, %client)
|
||||
{
|
||||
$clientConneted++;
|
||||
getPlayer(%client);
|
||||
}
|
||||
|
||||
|
||||
//This is called when a client enters the game server. It's used to spawn a player object
|
||||
//set up any client-specific properties such as saved configs, values, their name, etc
|
||||
//These callbacks are activated in core/clientServer/scripts/server/levelDownload.cs
|
||||
function @@::onClientEnterGame(%this, %client)
|
||||
{
|
||||
$Game::DefaultPlayerClass = "Player";
|
||||
$Game::DefaultPlayerDataBlock = "DefaultPlayerData";
|
||||
$Game::DefaultPlayerSpawnGroups = "spawn_player CameraSpawnPoints PlayerSpawnPoints PlayerDropPoints";
|
||||
|
||||
$Game::DefaultCameraClass = "Camera";
|
||||
$Game::DefaultCameraDataBlock = "Observer";
|
||||
$Game::DefaultCameraSpawnGroups = "spawn_player CameraSpawnPoints PlayerSpawnPoints PlayerDropPoints";
|
||||
|
||||
|
||||
//Spawn NPCs for the map and stuff here?
|
||||
|
||||
// This function currently relies on some helper functions defined in
|
||||
// core/scripts/spawn.cs. For custom spawn behaviors one can either
|
||||
// override the properties on the SpawnSphere's or directly override the
|
||||
// functions themselves.
|
||||
}
|
||||
|
||||
function @@::onSceneLoaded(%this)
|
||||
{
|
||||
}
|
||||
|
||||
function @@::onSceneUnloaded(%this)
|
||||
{
|
||||
}
|
||||
|
||||
function @@::onSubsceneLoaded(%this)
|
||||
{
|
||||
}
|
||||
|
||||
function @@::onSubsceneUnloaded(%this)
|
||||
{
|
||||
}
|
||||
|
||||
//This is called when the player leaves the game server. It's used to clean up anything that
|
||||
//was spawned or setup for the client when it connected, in onClientEnterGame
|
||||
//These callbacks are activated in core/clientServer/scripts/server/levelDownload.cs
|
||||
function @@::onClientLeaveGame(%this, %client)
|
||||
{
|
||||
// Cleanup the camera
|
||||
if (isObject(%this.camera))
|
||||
%this.camera.delete();
|
||||
// Cleanup the player
|
||||
if (isObject(%this.player))
|
||||
%this.player.delete();
|
||||
}
|
||||
|
|
@ -9,24 +9,23 @@ function @@::onDestroy(%this)
|
|||
//This is called when the server is initially set up by the game application
|
||||
function @@::initServer(%this)
|
||||
{
|
||||
//--FILE EXEC BEGIN--
|
||||
//--FILE EXEC END--
|
||||
}
|
||||
|
||||
//This is called when the server is created for an actual game/map to be played
|
||||
function @@::onCreateGameServer(%this)
|
||||
{
|
||||
//--DATABLOCK EXEC BEGIN--
|
||||
//These are common managed data files. For any datablock-based stuff that gets generated by the editors
|
||||
//(that doesn't have a specific associated file, like data for a player class) will go into these.
|
||||
//So we'll register them now if they exist.
|
||||
if(isFile("./scripts/managedData/managedDatablocks." @ $TorqueScriptFileExtension))
|
||||
%this.registerDatablock("./scripts/managedData/managedDatablocks");
|
||||
if(isFile("./scripts/managedData/managedForestItemData." @ $TorqueScriptFileExtension))
|
||||
%this.registerDatablock("./scripts/managedData/managedForestItemData");
|
||||
if(isFile("./scripts/managedData/managedForestBrushData." @ $TorqueScriptFileExtension))
|
||||
%this.registerDatablock("./scripts/managedData/managedForestBrushData");
|
||||
if(isFile("./scripts/managedData/managedParticleEmitterData." @ $TorqueScriptFileExtension))
|
||||
%this.registerDatablock("./scripts/managedData/managedParticleEmitterData");
|
||||
if(isFile("./scripts/managedData/managedParticleData." @ $TorqueScriptFileExtension))
|
||||
%this.registerDatablock("./scripts/managedData/managedParticleData");
|
||||
%this.registerDatablock("./scripts/managedData/managedDatablocks");
|
||||
%this.registerDatablock("./scripts/managedData/managedForestItemData");
|
||||
%this.registerDatablock("./scripts/managedData/managedForestBrushData");
|
||||
%this.registerDatablock("./scripts/managedData/managedParticleEmitterData");
|
||||
%this.registerDatablock("./scripts/managedData/managedParticleData");
|
||||
//--DATABLOCK EXEC END--
|
||||
}
|
||||
|
||||
//This is called when the server is shut down due to the game/map being exited
|
||||
|
|
@ -37,6 +36,8 @@ function @@::onDestroyGameServer(%this)
|
|||
//This is called when the client is initially set up by the game application
|
||||
function @@::initClient(%this)
|
||||
{
|
||||
//--FILE EXEC BEGIN--
|
||||
//--FILE EXEC END--
|
||||
}
|
||||
|
||||
//This is called when a client connects to a server
|
||||
|
|
|
|||
253
Templates/BaseGame/game/tools/assetBrowser/scripts/utils.tscript
Normal file
253
Templates/BaseGame/game/tools/assetBrowser/scripts/utils.tscript
Normal file
|
|
@ -0,0 +1,253 @@
|
|||
function testRpl()
|
||||
{
|
||||
ToolUtilityScripts::appendLineToFunction("data/prototyping/prototyping.tscript", "Prototyping", "onDestroyGameServer", "//AAAAAAAAAAAAAAAAAAAAA");
|
||||
}
|
||||
|
||||
function Tools::appendLineToFunction(%file, %nameSpace, %functionName, %appendLine)
|
||||
{
|
||||
%fileOutput = new ArrayObject(){};
|
||||
%fileObj = new FileObject(){};
|
||||
|
||||
%insideFunction = false;
|
||||
%scopeDepth = 0;
|
||||
|
||||
if ( %fileObj.openForRead( %file ) )
|
||||
{
|
||||
while ( !%fileObj.isEOF() )
|
||||
{
|
||||
%line = %fileObj.readLine();
|
||||
|
||||
if(strIsMatchExpr("*function *(*)*", %line))
|
||||
{
|
||||
%fileOutput.add(%line);
|
||||
|
||||
%start = strpos(%line, "function ");
|
||||
%end = strpos(%line, "(", %start);
|
||||
|
||||
%scannedFunctionName = "";
|
||||
|
||||
if(%start != -1 && %end != -1)
|
||||
{
|
||||
%scannedFunctionName = getSubStr(%line, %start + 9, %end-%start-9);
|
||||
}
|
||||
|
||||
%matchesFunctionSig = false;
|
||||
if(%nameSpace !$= "")
|
||||
{
|
||||
if(%scannedFunctionName $= (%nameSpace @ "::" @ %functionName))
|
||||
%matchesFunctionSig = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(%scannedFunctionName $= %functionName)
|
||||
%matchesFunctionSig = true;
|
||||
}
|
||||
|
||||
if(!%matchesFunctionSig)
|
||||
continue;
|
||||
|
||||
%insideFunction = true;
|
||||
|
||||
if(strIsMatchExpr("*{*", %line))
|
||||
{
|
||||
%scopeDepth++;
|
||||
}
|
||||
if(strIsMatchExpr("*}*", %line))
|
||||
{
|
||||
%scopeDepth--;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(%insideFunction && strIsMatchExpr("*{*", %line))
|
||||
{
|
||||
%scopeDepth++;
|
||||
}
|
||||
if(%insideFunction && strIsMatchExpr("*}*", %line))
|
||||
{
|
||||
%scopeDepth--;
|
||||
|
||||
if(%scopeDepth == 0) //we've fully backed out of the function scope, so resolve back to the parent
|
||||
{
|
||||
%insideFunction = false;
|
||||
|
||||
%fileOutput.add(%appendLine);
|
||||
}
|
||||
}
|
||||
|
||||
%fileOutput.add(%line);
|
||||
}
|
||||
}
|
||||
%fileObj.close();
|
||||
}
|
||||
|
||||
if ( %fileObj.openForWrite( %file ) )
|
||||
{
|
||||
for(%i=0; %i < %fileOutput.count(); %i++)
|
||||
{
|
||||
%line = %fileOutput.getKey(%i);
|
||||
|
||||
%fileObj.writeLine(%line);
|
||||
}
|
||||
%fileObj.close();
|
||||
}
|
||||
}
|
||||
|
||||
function Tools::findInFile(%file, %findText, %startingLineId)
|
||||
{
|
||||
if(%startingLineId $= "")
|
||||
%startingLineId = 0;
|
||||
|
||||
%fileObj = new FileObject(){};
|
||||
|
||||
if ( %fileObj.openForRead( %file ) )
|
||||
{
|
||||
%lineId = 0;
|
||||
while ( !%fileObj.isEOF() )
|
||||
{
|
||||
if(%lineId >= %startingLineId)
|
||||
{
|
||||
%line = %fileObj.readLine();
|
||||
|
||||
if(strIsMatchExpr(%findText, %line))
|
||||
{
|
||||
return %lineId;
|
||||
}
|
||||
}
|
||||
|
||||
%lineId++;
|
||||
}
|
||||
%fileObj.close();
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
function Tools::findInFunction(%file, %nameSpace, %functionName, %findText)
|
||||
{
|
||||
%fileObj = new FileObject(){};
|
||||
|
||||
%insideFunction = false;
|
||||
%scopeDepth = 0;
|
||||
|
||||
if ( %fileObj.openForRead( %file ) )
|
||||
{
|
||||
%lineId = -1;
|
||||
while ( !%fileObj.isEOF() )
|
||||
{
|
||||
%line = %fileObj.readLine();
|
||||
%lineId++;
|
||||
|
||||
if(strIsMatchExpr("*function *(*)*", %line))
|
||||
{
|
||||
%start = strpos(%line, "function ");
|
||||
%end = strpos(%line, "(", %start);
|
||||
|
||||
%scannedFunctionName = "";
|
||||
|
||||
if(%start != -1 && %end != -1)
|
||||
{
|
||||
%scannedFunctionName = getSubStr(%line, %start + 9, %end-%start-9);
|
||||
}
|
||||
|
||||
%matchesFunctionSig = false;
|
||||
if(%nameSpace !$= "")
|
||||
{
|
||||
if(%scannedFunctionName $= (%nameSpace @ "::" @ %functionName))
|
||||
%matchesFunctionSig = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(%scannedFunctionName $= %functionName)
|
||||
%matchesFunctionSig = true;
|
||||
}
|
||||
|
||||
if(!%matchesFunctionSig)
|
||||
continue;
|
||||
|
||||
%insideFunction = true;
|
||||
|
||||
if(strIsMatchExpr("*{*", %line))
|
||||
{
|
||||
%scopeDepth++;
|
||||
}
|
||||
if(strIsMatchExpr("*}*", %line))
|
||||
{
|
||||
%scopeDepth--;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(%insideFunction && strIsMatchExpr("*{*", %line))
|
||||
{
|
||||
%scopeDepth++;
|
||||
}
|
||||
if(%insideFunction && strIsMatchExpr("*}*", %line))
|
||||
{
|
||||
%scopeDepth--;
|
||||
|
||||
if(%scopeDepth == 0) //we've fully backed out of the function scope, so resolve back to the parent
|
||||
{
|
||||
%insideFunction = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(%insideFunction && strIsMatchExpr(%findText, %line))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
%fileObj.close();
|
||||
}
|
||||
|
||||
return %lineId;
|
||||
}
|
||||
|
||||
function Tools::insertInFile(%file, %insertLineId, %insertText, %insertBefore)
|
||||
{
|
||||
%fileOutput = new ArrayObject(){};
|
||||
%fileObj = new FileObject(){};
|
||||
|
||||
if ( %fileObj.openForRead( %file ) )
|
||||
{
|
||||
%lineId = 0;
|
||||
while ( !%fileObj.isEOF() )
|
||||
{
|
||||
%line = %fileObj.readLine();
|
||||
|
||||
if(%insertLineId == %lineId)
|
||||
{
|
||||
if(!%insertBefore || %insertBefore $= "")
|
||||
{
|
||||
%fileOutput.add(%line);
|
||||
%fileOutput.add(%insertText);
|
||||
}
|
||||
else
|
||||
{
|
||||
%fileOutput.add(%insertText);
|
||||
%fileOutput.add(%line);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
%fileOutput.add(%line);
|
||||
}
|
||||
|
||||
%lineId++;
|
||||
}
|
||||
%fileObj.close();
|
||||
}
|
||||
|
||||
if ( %fileObj.openForWrite( %file ) )
|
||||
{
|
||||
for(%i=0; %i < %fileOutput.count(); %i++)
|
||||
{
|
||||
%line = %fileOutput.getKey(%i);
|
||||
|
||||
%fileObj.writeLine(%line);
|
||||
}
|
||||
%fileObj.close();
|
||||
}
|
||||
}
|
||||
|
|
@ -301,6 +301,10 @@ function ESettingsWindow::getGeneralSettings(%this)
|
|||
SettingsInspector.addSettingsField("WorldEditor/AutosaveInterval", "Autosave Interval(in minutes)", "int", "");
|
||||
SettingsInspector.endGroup();
|
||||
|
||||
SettingsInspector.startGroup("SubScenes");
|
||||
SettingsInspector.addSettingsField("WorldEditor/subSceneCreateScalar", "SubScene Creation Scalar", "float", "Amount to scale SubScene's bounds by when creating from scene objects.", "1.5");
|
||||
SettingsInspector.endGroup();
|
||||
|
||||
SettingsInspector.startGroup("Paths");
|
||||
//SettingsInspector.addSettingsField("WorldEditor/torsionPath", "Torsion Path", "filename", "");
|
||||
SettingsInspector.endGroup();
|
||||
|
|
|
|||
|
|
@ -1,20 +1,24 @@
|
|||
function GuiVariableInspector::onInspectorFieldModified(%this, %targetObj, %fieldName, %index, %oldValue, %newValue)
|
||||
{
|
||||
echo("FIELD CHANGED: " @ %fieldName @ " from " @ %oldValue @ " to " @ %newValue);
|
||||
//echo("FIELD CHANGED: " @ %fieldName @ " from " @ %oldValue @ " to " @ %newValue);
|
||||
}
|
||||
|
||||
function GuiInspectorVariableGroup::onConstructField(%this, %fieldName, %fieldLabel, %fieldTypeName, %fieldDesc, %fieldDefaultVal, %fieldDataVals, %callbackName, %ownerObj)
|
||||
{
|
||||
%inspector = %this.getParent();
|
||||
%makeCommand = %this @ ".build" @ %fieldTypeName @ "Field(\""@ %fieldName @ "\",\"" @ %fieldLabel @ "\",\"" @ %fieldDesc @ "\",\"" @
|
||||
%fieldDefaultVal @ "\",\"" @ %fieldDataVals @ "\",\"" @ %inspector @ "." @ %callbackName @ "\",\"" @ %ownerObj @"\");";
|
||||
eval(%makeCommand);
|
||||
return GuiInspectorGroup::onConstructField(%this, %fieldName, %fieldLabel, %fieldTypeName, %fieldDesc, %fieldDefaultVal, %fieldDataVals, %callbackName, %ownerObj);
|
||||
}
|
||||
|
||||
function GuiInspectorGroup::onConstructField(%this, %fieldName, %fieldLabel, %fieldTypeName, %fieldDesc, %fieldDefaultVal, %fieldDataVals, %callbackName, %ownerObj)
|
||||
{
|
||||
%inspector = %this.getParent();
|
||||
%makeCommand = %this @ ".build" @ %fieldTypeName @ "Field(\""@ %fieldName @ "\",\"" @ %fieldLabel @ "\",\"" @ %fieldDesc @ "\",\"" @
|
||||
%fieldDefaultVal @ "\",\"" @ %fieldDataVals @ "\",\"" @ %inspector @ "." @ %callbackName @ "\",\"" @ %ownerObj @"\");";
|
||||
eval(%makeCommand);
|
||||
if(%this.isMethod("build" @ %fieldTypeName @ "Field"))
|
||||
{
|
||||
%inspector = %this.getParent();
|
||||
%makeCommand = %this @ ".build" @ %fieldTypeName @ "Field(\""@ %fieldName @ "\",\"" @ %fieldLabel @ "\",\"" @ %fieldDesc @ "\",\"" @
|
||||
%fieldDefaultVal @ "\",\"" @ %fieldDataVals @ "\",\"" @ %inspector @ "." @ %callbackName @ "\",\"" @ %ownerObj @"\");";
|
||||
%ret = eval(%makeCommand);
|
||||
|
||||
if(%ret == true || %ret $= "")
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
AssetName="DefaultEditorLevel"
|
||||
LevelFile="@assetFile=DefaultEditorLevel.mis"
|
||||
LevelName="DefaultEditorLevel"
|
||||
PostFXPresetFile="@assetFile=tools/levels/DefaultEditorLevel.postfxpreset.tscript"
|
||||
description="An empty room"
|
||||
previewImageAsset0="@asset=ToolsModule:DefaultEditorLevel_preview_image"
|
||||
previewImageAsset1="@asset=ToolsModule:DefaultEditorLevel_preview_image"
|
||||
|
|
|
|||
|
|
@ -1,33 +1,20 @@
|
|||
//--- OBJECT WRITE BEGIN ---
|
||||
new Scene(EditorTemplateLevel) {
|
||||
canSave = "1";
|
||||
canSaveDynamicFields = "1";
|
||||
Enabled = "1";
|
||||
isEditing = "1";
|
||||
enabled = "1";
|
||||
|
||||
new LevelInfo(theLevelInfo) {
|
||||
nearClip = "0.1";
|
||||
visibleDistance = "1000";
|
||||
visibleGhostDistance = "0";
|
||||
decalBias = "0.0015";
|
||||
fogColor = "0.6 0.6 0.7 1";
|
||||
fogDensity = "0";
|
||||
FogColor = "0.6 0.6 0.7 1";
|
||||
fogDensityOffset = "700";
|
||||
fogAtmosphereHeight = "0";
|
||||
canvasClearColor = "0 0 0 255";
|
||||
ambientLightBlendPhase = "1";
|
||||
ambientLightBlendCurve = "0 0 -1 -1";
|
||||
soundAmbience = "AudioAmbienceDefault";
|
||||
soundDistanceModel = "Linear";
|
||||
canSave = "1";
|
||||
canSaveDynamicFields = "1";
|
||||
Enabled = "1";
|
||||
enabled = "1";
|
||||
};
|
||||
new ScatterSky(DynamicSky) {
|
||||
sunScale = "0.991102 0.921582 0.83077 1";
|
||||
zOffset = "-3000";
|
||||
azimuth = "25";
|
||||
brightness = "5";
|
||||
flareType = "LightFlareExample1";
|
||||
MoonMatAsset = "Core_Rendering:moon_wglow";
|
||||
useNightCubemap = "1";
|
||||
nightCubemap = "nightCubemap";
|
||||
|
|
@ -44,12 +31,11 @@ new Scene(EditorTemplateLevel) {
|
|||
persistentId = "289ad401-3140-11ed-aae8-c0cb519281fc";
|
||||
reflectionPath = "tools/levels/DefaultEditorLevel/probes/";
|
||||
};
|
||||
|
||||
new GroundPlane() {
|
||||
scaleU = "32";
|
||||
scaleV = "32";
|
||||
MaterialAsset = "Prototyping:FloorGray";
|
||||
Enabled = "1";
|
||||
enabled = "1";
|
||||
position = "0 0 0";
|
||||
rotation = "1 0 0 0";
|
||||
scale = "1 1 1";
|
||||
|
|
|
|||
|
|
@ -375,6 +375,8 @@
|
|||
name="orthoShowGrid">1</Setting>
|
||||
<Setting
|
||||
name="startupMode">Blank Level</Setting>
|
||||
<Setting
|
||||
name="subSceneCreateScalar">2</Setting>
|
||||
<Setting
|
||||
name="torsionPath">AssetWork_Debug.exe</Setting>
|
||||
<Setting
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ $guiContent = new GuiControl() {
|
|||
minSize = "50 50";
|
||||
EdgeSnap = false;
|
||||
text = "";
|
||||
class = "EWToolsPaletteWindowClass";
|
||||
class = "ButtonPalette";
|
||||
|
||||
new GuiDynamicCtrlArrayControl(ToolsPaletteArray) {
|
||||
canSaveDynamicFields = "0";
|
||||
|
|
|
|||
|
|
@ -472,7 +472,7 @@ $guiContent = new GuiControl() {
|
|||
Profile = "ToolsGuiButtonProfile";
|
||||
HorizSizing = "left";
|
||||
VertSizing = "bottom";
|
||||
Position = "290 22";
|
||||
Position = "269 22";
|
||||
Extent = "16 16";
|
||||
MinExtent = "8 2";
|
||||
canSave = "1";
|
||||
|
|
@ -496,7 +496,7 @@ $guiContent = new GuiControl() {
|
|||
Profile = "ToolsGuiButtonProfile";
|
||||
HorizSizing = "left";
|
||||
VertSizing = "bottom";
|
||||
Position = "311 22";
|
||||
Position = "290 22";
|
||||
Extent = "16 16";
|
||||
MinExtent = "8 2";
|
||||
canSave = "1";
|
||||
|
|
@ -512,6 +512,30 @@ $guiContent = new GuiControl() {
|
|||
useModifiers = "1";
|
||||
};
|
||||
|
||||
new GuiBitmapButtonCtrl(EWAddSceneGroupButton) {
|
||||
canSaveDynamicFields = "0";
|
||||
internalName = "AddSceneGroup";
|
||||
Enabled = "1";
|
||||
isContainer = "0";
|
||||
Profile = "ToolsGuiButtonProfile";
|
||||
HorizSizing = "left";
|
||||
VertSizing = "bottom";
|
||||
Position = "311 22";
|
||||
Extent = "16 16";
|
||||
MinExtent = "8 2";
|
||||
canSave = "1";
|
||||
Visible = "1";
|
||||
tooltipprofile = "ToolsGuiToolTipProfile";
|
||||
ToolTip = "Add Scene Group";
|
||||
hovertime = "1000";
|
||||
bitmapAsset = "ToolsModule:add_simgroup_btn_n_image";
|
||||
buttonType = "PushButton";
|
||||
groupNum = "-1";
|
||||
text = "";
|
||||
useMouseEvents = "0";
|
||||
useModifiers = "1";
|
||||
};
|
||||
|
||||
new GuiBitmapButtonCtrl() {
|
||||
canSaveDynamicFields = "0";
|
||||
internalName = "DeleteSelection";
|
||||
|
|
|
|||
|
|
@ -69,6 +69,7 @@ function initializeWorldEditor()
|
|||
exec("./scripts/probeBake.ed." @ $TorqueScriptFileExtension);
|
||||
exec("./scripts/visibility/visibilityLayer.ed." @ $TorqueScriptFileExtension);
|
||||
exec("./scripts/visibility/probeViz." @ $TorqueScriptFileExtension);
|
||||
exec("./scripts/buttonPalette." @ $TorqueScriptFileExtension);
|
||||
|
||||
exec("tools/gui/postFxEditor." @ $TorqueScriptFileExtension );
|
||||
exec("tools/gui/renderTargetVisualizer.ed." @ $TorqueScriptFileExtension);
|
||||
|
|
@ -77,6 +78,8 @@ function initializeWorldEditor()
|
|||
loadDirectory(expandFilename("./scripts/editors"));
|
||||
loadDirectory(expandFilename("./scripts/interfaces"));
|
||||
|
||||
exec("./scripts/interfaces/subSceneEditing.tscript");
|
||||
|
||||
// Create the default editor plugins before calling buildMenus.
|
||||
|
||||
new ScriptObject( WorldEditorPlugin )
|
||||
|
|
|
|||
|
|
@ -1069,11 +1069,13 @@ function WorldEditorInspectorPlugin::onWorldEditorStartup( %this )
|
|||
//connect editor windows
|
||||
GuiWindowCtrl::attach( EWInspectorWindow, EWTreeWindow);
|
||||
|
||||
%map = new ActionMap();
|
||||
%map = new ActionMap();
|
||||
|
||||
/*
|
||||
%map.bindCmd( keyboard, "1", "EWorldEditorNoneModeBtn.performClick();", "" ); // Select
|
||||
%map.bindCmd( keyboard, "2", "EWorldEditorMoveModeBtn.performClick();", "" ); // Move
|
||||
%map.bindCmd( keyboard, "3", "EWorldEditorRotateModeBtn.performClick();", "" ); // Rotate
|
||||
%map.bindCmd( keyboard, "4", "EWorldEditorScaleModeBtn.performClick();", "" ); // Scale
|
||||
%map.bindCmd( keyboard, "4", "EWorldEditorScaleModeBtn.performClick();", "" ); // Scale*/
|
||||
%map.bindCmd( keyboard, "f", "FitToSelectionBtn.performClick();", "" );// Fit Camera to Selection
|
||||
%map.bindCmd( keyboard, "z", "EditorGuiStatusBar.setCamera(\"Standard Camera\");", "" );// Free camera
|
||||
%map.bindCmd( keyboard, "n", "ToggleNodeBar->renderHandleBtn.performClick();", "" );// Render Node
|
||||
|
|
@ -1093,21 +1095,38 @@ function WorldEditorInspectorPlugin::onWorldEditorStartup( %this )
|
|||
function WorldEditorInspectorPlugin::onActivated( %this )
|
||||
{
|
||||
Parent::onActivated( %this );
|
||||
|
||||
//Clears the button pallete stack
|
||||
EWToolsPaletteWindow.setStackCtrl(ToolsPaletteArray); //legacy ctrl adhereance
|
||||
EWToolsPaletteWindow.clearButtons();
|
||||
|
||||
EWToolsPaletteWindow.setActionMap(WorldEditorInspectorPlugin.map);
|
||||
|
||||
//Adds a button to the pallete stack
|
||||
//Name Icon Click Command Tooltip text Keybind
|
||||
EWToolsPaletteWindow.addButton("Select", "ToolsModule:arrow_n_image", "EWorldEditorNoneModeBtn::onClick();", "", "Select Arrow", "1");
|
||||
EWToolsPaletteWindow.addButton("Move", "ToolsModule:translate_n_image", "EWorldEditorMoveModeBtn::onClick();", "", "Move Selection", "2");
|
||||
EWToolsPaletteWindow.addButton("Rotate", "ToolsModule:rotate_n_image", "EWorldEditorRotateModeBtn::onClick();", "", "Rotate Selection", "3");
|
||||
EWToolsPaletteWindow.addButton("Scale", "ToolsModule:Scale_n_image", "EWorldEditorScaleModeBtn::onClick();", "", "Scale Selection", "4");
|
||||
|
||||
EWToolsPaletteWindow.refresh();
|
||||
|
||||
EditorGui-->InspectorWindow.setVisible( true );
|
||||
EditorGui-->TreeWindow.setVisible( true );
|
||||
EditorGui-->WorldEditorToolbar.setVisible( true );
|
||||
%this.map.push();
|
||||
//%this.map.push();
|
||||
}
|
||||
|
||||
function WorldEditorInspectorPlugin::onDeactivated( %this )
|
||||
{
|
||||
Parent::onDeactivated( %this );
|
||||
|
||||
EWToolsPaletteWindow.popActionMap();
|
||||
|
||||
EditorGui-->InspectorWindow.setVisible( false );
|
||||
EditorGui-->TreeWindow.setVisible( false );
|
||||
EditorGui-->WorldEditorToolbar.setVisible( false );
|
||||
%this.map.pop();
|
||||
//%this.map.pop();
|
||||
}
|
||||
|
||||
function WorldEditorInspectorPlugin::onEditMenuSelect( %this, %editMenu )
|
||||
|
|
@ -2044,7 +2063,7 @@ function EditorTree::onRightMouseUp( %this, %itemId, %mouse, %obj )
|
|||
%popup.item[ 0 ] = "Delete" TAB "" TAB "EditorMenuEditDelete();";
|
||||
%popup.item[ 1 ] = "Group" TAB "" TAB "EWorldEditor.addSimGroup( true );";
|
||||
%popup.item[ 2 ] = "-";
|
||||
%popup.item[ 3 ] = "Make select a Sub-Level" TAB "" TAB "MakeSelectionASublevel();";
|
||||
%popup.item[ 3 ] = "Make selected a Sub-Level" TAB "" TAB "MakeSelectionASublevel();";
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -2140,6 +2159,14 @@ function EditorTree::onRightMouseUp( %this, %itemId, %mouse, %obj )
|
|||
%popup.enableItem(15, true);
|
||||
}
|
||||
}
|
||||
else if(%obj.getClassName() $= "SimGroup" ||
|
||||
%obj.getClassName() $= "SceneGroup")
|
||||
{
|
||||
//if it's ACTUALLY a SimGroup or SceneGroup, have the ability to
|
||||
//upconvert to SubScene
|
||||
%popup.item[ 12 ] = "-";
|
||||
%popup.item[ 13 ] = "Convert to SubScene" TAB "" TAB "EWorldEditor.createSelectedAsSubScene( " @ %popup.object @ " );";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2179,7 +2206,7 @@ function EditorTree::isValidDragTarget( %this, %id, %obj )
|
|||
if( %obj.name $= "CameraBookmarks" )
|
||||
return EWorldEditor.areAllSelectedObjectsOfType( "CameraBookmark" );
|
||||
else
|
||||
return ( %obj.getClassName() $= "SimGroup" || %obj.isMemberOfClass("Scene"));
|
||||
return ( %obj.getClassName() $= "SimGroup" || %obj.isMemberOfClass("Scene") || %obj.isMemberOfClass("SceneGroup"));
|
||||
}
|
||||
|
||||
function EditorTree::onBeginReparenting( %this )
|
||||
|
|
@ -2620,6 +2647,77 @@ function EWorldEditor::addSimGroup( %this, %groupCurrentSelection )
|
|||
%this.syncGui();
|
||||
}
|
||||
|
||||
function EWorldEditor::addSceneGroup( %this, %groupCurrentSelection )
|
||||
{
|
||||
%activeSelection = %this.getActiveSelection();
|
||||
if ( %groupCurrentSelection && %activeSelection.getObjectIndex( getScene(0) ) != -1 )
|
||||
{
|
||||
toolsMessageBoxOK( "Error", "Cannot add Scene to a new SceneGroup" );
|
||||
return;
|
||||
}
|
||||
|
||||
// Find our parent.
|
||||
|
||||
%parent = getScene(0);
|
||||
if( !%groupCurrentSelection && isObject( %activeSelection ) && %activeSelection.getCount() > 0 )
|
||||
{
|
||||
%firstSelectedObject = %activeSelection.getObject( 0 );
|
||||
if( %firstSelectedObject.isMemberOfClass( "SimGroup" ) )
|
||||
%parent = %firstSelectedObject;
|
||||
else if( %firstSelectedObject.getId() != getScene(0).getId() )
|
||||
%parent = %firstSelectedObject.parentGroup;
|
||||
}
|
||||
|
||||
// If we are about to do a group-selected as well,
|
||||
// starting recording an undo compound.
|
||||
|
||||
if( %groupCurrentSelection )
|
||||
Editor.getUndoManager().pushCompound( "Group Selected" );
|
||||
|
||||
// Create the SimGroup.
|
||||
|
||||
%object = new SceneGroup()
|
||||
{
|
||||
parentGroup = %parent;
|
||||
};
|
||||
MECreateUndoAction::submit( %object );
|
||||
|
||||
// Put selected objects into the group, if requested.
|
||||
|
||||
if( %groupCurrentSelection && isObject( %activeSelection ) )
|
||||
{
|
||||
%undo = UndoActionReparentObjects::create( EditorTree );
|
||||
|
||||
%numObjects = %activeSelection.getCount();
|
||||
for( %i = 0; %i < %numObjects; %i ++ )
|
||||
{
|
||||
%sel = %activeSelection.getObject( %i );
|
||||
%undo.add( %sel, %sel.parentGroup, %object );
|
||||
%object.add( %sel );
|
||||
}
|
||||
|
||||
%undo.addToManager( Editor.getUndoManager() );
|
||||
}
|
||||
|
||||
// Stop recording for group-selected.
|
||||
|
||||
if( %groupCurrentSelection )
|
||||
Editor.getUndoManager().popCompound();
|
||||
|
||||
// When not grouping selection, make the newly created SimGroup the
|
||||
// current selection.
|
||||
|
||||
if( !%groupCurrentSelection )
|
||||
{
|
||||
EWorldEditor.clearSelection();
|
||||
EWorldEditor.selectObject( %object );
|
||||
}
|
||||
|
||||
// Refresh the Gui.
|
||||
|
||||
%this.syncGui();
|
||||
}
|
||||
|
||||
function EWorldEditor::toggleLockChildren( %this, %simGroup )
|
||||
{
|
||||
foreach( %child in %simGroup )
|
||||
|
|
@ -2887,6 +2985,16 @@ function EWAddSimGroupButton::onCtrlClick( %this )
|
|||
EWorldEditor.addSimGroup( true );
|
||||
}
|
||||
|
||||
function EWAddSceneGroupButton::onDefaultClick( %this )
|
||||
{
|
||||
EWorldEditor.addSceneGroup();
|
||||
}
|
||||
|
||||
function EWAddSceneGroupButton::onCtrlClick( %this )
|
||||
{
|
||||
EWorldEditor.addSceneGroup( true );
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
function EWToolsToolbar::reset( %this )
|
||||
|
|
|
|||
|
|
@ -0,0 +1,160 @@
|
|||
function ButtonPalette::setStackCtrl(%this, %ctrl)
|
||||
{
|
||||
%this.stackCtrl = %ctrl;
|
||||
}
|
||||
|
||||
function ButtonPalette::getStackCtrl(%this)
|
||||
{
|
||||
if(isObject(%this.stackCtrl))
|
||||
return %this.stackCtrl;
|
||||
else
|
||||
return %this;
|
||||
}
|
||||
|
||||
function ButtonPalette::setActionMap(%this, %actionMap)
|
||||
{
|
||||
%this.actionMap = %actionMap;
|
||||
%this.actionMap.push();
|
||||
}
|
||||
|
||||
function ButtonPalette::getActionMap(%this)
|
||||
{
|
||||
return %this.actionMap;
|
||||
}
|
||||
|
||||
function ButtonPalette::popActionMap(%this, %actionMap)
|
||||
{
|
||||
%this.actionMap.pop();
|
||||
}
|
||||
|
||||
function ButtonPalette::clearButtons(%this)
|
||||
{
|
||||
%stackCtrl = %this.getStackCtrl();
|
||||
%stackCtrl.clear();
|
||||
|
||||
for(%i=0; %i < %this.numButtons; %i++)
|
||||
{
|
||||
if(isObject(%this.actionMap))
|
||||
{
|
||||
%this.actionMap.unbind("keyboard", getField(%this.buttons[%i], 5));
|
||||
}
|
||||
|
||||
%this.buttons[%i] = "";
|
||||
}
|
||||
|
||||
%this.numButtons = 0;
|
||||
}
|
||||
|
||||
//Name, Icon, Click Command, Variable, Tooltip text, Keybind
|
||||
function ButtonPalette::addButton(%this, %name, %iconAsset, %command, %syncVariable, %toolTip, %keybind)
|
||||
{
|
||||
if(%this.numButtons $= "")
|
||||
%this.numButtons = 0;
|
||||
|
||||
for(%i=0; %i < %this.numButtons; %i++)
|
||||
{
|
||||
%buttonInfo = %this.buttons[%i];
|
||||
|
||||
//echo("Testing button info: " @ getField(%buttonInfo, 0) @ " against new button name: " @ %name);
|
||||
if(getField(%buttonInfo, 0) $= %name) //no duplicates
|
||||
return;
|
||||
}
|
||||
|
||||
%this.buttons[%this.numButtons] = %name TAB %iconAsset TAB %command TAB %syncVariable TAB %toolTip TAB %keybind;
|
||||
|
||||
%this.numButtons++;
|
||||
}
|
||||
|
||||
function ButtonPalette::removeButton(%this, %name)
|
||||
{
|
||||
%found = false;
|
||||
for(%i=0; %i < %this.numButtons; %i++)
|
||||
{
|
||||
if(getField(%this.buttons[%i], 0) $= %name)
|
||||
{
|
||||
%found = true;
|
||||
|
||||
if(isObject(%this.actionMap))
|
||||
{
|
||||
%this.actionMap.unbind("keyboard", getField(%this.buttons[%i], 5));
|
||||
}
|
||||
}
|
||||
|
||||
if(%found)
|
||||
{
|
||||
%this.buttons[%i] = %this.buttons[%i+1];
|
||||
}
|
||||
}
|
||||
|
||||
if(%found)
|
||||
%this.numButtons--;
|
||||
|
||||
return %found;
|
||||
}
|
||||
|
||||
function ButtonPalette::findButton(%this, %name)
|
||||
{
|
||||
%stackCtrl = %this.getStackCtrl();
|
||||
for(%i=0; %i < %stackCtrl.getCount(); %i++)
|
||||
{
|
||||
%btnObj = %stackCtrl.getObject(%i);
|
||||
|
||||
if(%btnObj.buttonName $= %name)
|
||||
return %btnObj;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
function ButtonPalette::refresh(%this)
|
||||
{
|
||||
%stackCtrl = %this.getStackCtrl();
|
||||
%stackCtrl.clear();
|
||||
|
||||
%this.visible = true;
|
||||
%extents = "25 25";
|
||||
|
||||
if(%this.numButtons == 0)
|
||||
{
|
||||
%this.visible = false;
|
||||
return;
|
||||
}
|
||||
|
||||
for(%i=0; %i < %this.numButtons; %i++)
|
||||
{
|
||||
%buttonInfo = %this.buttons[%i];
|
||||
|
||||
%paletteButton = new GuiBitmapButtonCtrl() {
|
||||
canSaveDynamicFields = "0";
|
||||
internalName = getField(%buttonInfo, 0) @ "_paletteButton";
|
||||
Enabled = "1";
|
||||
isContainer = "0";
|
||||
Profile = "ToolsGuiButtonProfile";
|
||||
HorizSizing = "right";
|
||||
VertSizing = "bottom";
|
||||
Position = "0 0";
|
||||
Extent = "25 19";
|
||||
MinExtent = "8 2";
|
||||
canSave = "1";
|
||||
Visible = "1";
|
||||
tooltipprofile = "ToolsGuiToolTipProfile";
|
||||
ToolTip = getField(%buttonInfo, 4) SPC "(" @ getField(%buttonInfo, 5) @ ")";
|
||||
hovertime = "1000";
|
||||
bitmapAsset = getField(%buttonInfo, 1);
|
||||
buttonType = "RadioButton";
|
||||
useMouseEvents = "0";
|
||||
buttonName = getField(%buttonInfo, 0);
|
||||
command = getField(%buttonInfo, 2);
|
||||
variable = getField(%buttonInfo, 3);
|
||||
};
|
||||
|
||||
%extents.y += 23;
|
||||
|
||||
if(isObject(%this.actionMap))
|
||||
%this.actionMap.bindCmd( keyboard, getField(%buttonInfo, 5), %paletteButton @ ".performClick();", "" );
|
||||
|
||||
%stackCtrl.add(%paletteButton);
|
||||
}
|
||||
|
||||
%this.extent.y = %extents.y;
|
||||
}
|
||||
|
|
@ -34,6 +34,7 @@ EditorSettings.setDefaultValue( "orthoFOV", "50" );
|
|||
EditorSettings.setDefaultValue( "orthoShowGrid", "1" );
|
||||
EditorSettings.setDefaultValue( "AutosaveInterval", "5" );
|
||||
EditorSettings.setDefaultValue( "forceSidebarToSide", "1" );
|
||||
EditorSettings.setDefaultValue( "subSceneCreateScalar", $SubScene::createScalar );
|
||||
|
||||
if( isFile( "C:/Program Files/Torsion/Torsion.exe" ) )
|
||||
EditorSettings.setDefaultValue( "torsionPath", "C:/Program Files/Torsion/Torsion.exe" );
|
||||
|
|
|
|||
|
|
@ -554,3 +554,142 @@ function simGroup::onInspectPostApply(%this)
|
|||
%this.callOnChildren("setHidden",%this.hidden);
|
||||
%this.callOnChildren("setLocked",%this.locked);
|
||||
}
|
||||
|
||||
function simGroup::SelectFiteredObjects(%this, %min, %max)
|
||||
{
|
||||
EWorldEditor.clearSelection();
|
||||
%this.callOnChildren("filteredSelect", %min, %max );
|
||||
}
|
||||
|
||||
function SceneObject::filteredSelect(%this, %min, %max)
|
||||
{
|
||||
echo("SceneObject::filteredSelect() - min: " @ %min @ " max: " @ %max);
|
||||
%box = %this.getWorldBox();
|
||||
%xlength = mAbs(getWord(%box,0) - getWord(%box,3));
|
||||
%ylength = mAbs(getWord(%box,1) - getWord(%box,4));
|
||||
%Zlength = mAbs(getWord(%box,2) - getWord(%box,5));
|
||||
%diagSq = mPow(%xlength,2)+mPow(%ylength,2)+mPow(%Zlength,2);
|
||||
if (%diagSq > mPow(%min,2) && %diagSq < mPow(%max,2))
|
||||
{
|
||||
EWorldEditor.selectObject(%this);
|
||||
}
|
||||
}
|
||||
|
||||
function simGroup::onInspect(%obj, %inspector)
|
||||
{
|
||||
//Find the 'Editing' group in the inspector
|
||||
%group = %inspector.findExistentGroup("Editing");
|
||||
if(isObject(%group))
|
||||
{
|
||||
//We add a field of the type 'SimGroupSelectionButton'. This isn't a 'real' type, so when the inspector group tries to add it
|
||||
//it will route down through GuiInspectorGroup(the namespace of %group) and call onConstructField in an attemp to see if there's any
|
||||
//script defined functions that can build a field of that type.
|
||||
//We happen to define the required 'build @ <fieldTypeName> @ Field()' function below, allowing us to build out the custom field type
|
||||
%group.addField("Select Objects", "SimGroupSelectionButton", "Select filtered objects");
|
||||
}
|
||||
}
|
||||
|
||||
function GuiInspectorGroup::buildSimGroupSelectionButtonField(%this, %fieldName, %fieldLabel, %fieldDesc,
|
||||
%fieldDefaultVal, %fieldDataVals, %callback, %ownerObj)
|
||||
{
|
||||
|
||||
//Set defaults if needbe
|
||||
if(%ownerObj.minSize $= "")
|
||||
%ownerObj.minSize = 0.1;
|
||||
if(%ownerObj.maxSize $= "")
|
||||
%ownerObj.maxSize = 1;
|
||||
|
||||
%container = new GuiControl() {
|
||||
canSaveDynamicFields = "0";
|
||||
Profile = "EditorContainerProfile";
|
||||
HorizSizing = "right";
|
||||
VertSizing = "bottom";
|
||||
Position = "0 0";
|
||||
Extent = "300 80";
|
||||
MinExtent = "8 2";
|
||||
canSave = "0";
|
||||
Visible = "1";
|
||||
hovertime = "100";
|
||||
tooltip = "";// %tooltip;
|
||||
tooltipProfile = "EditorToolTipProfile";
|
||||
|
||||
new GuiTextCtrl() {
|
||||
profile = GuiInspectorFieldProfile;
|
||||
text = %fieldLabel;
|
||||
Position = "16 2";
|
||||
Extent = "300 18";
|
||||
HorizSizing = "right";
|
||||
VertSizing = "bottom";
|
||||
};
|
||||
|
||||
new GuiControl() {
|
||||
Position = "40 20";
|
||||
Extent = "270 18";
|
||||
HorizSizing = "right";
|
||||
VertSizing = "bottom";
|
||||
|
||||
new GuiTextCtrl() {
|
||||
profile = GuiInspectorFieldProfile;
|
||||
text = "Minimum Size:";
|
||||
Position = "0 2";
|
||||
Extent = "150 18";
|
||||
HorizSizing = "right";
|
||||
VertSizing = "bottom";
|
||||
};
|
||||
|
||||
new GuiTextEditCtrl() {
|
||||
profile = GuiInspectorTextEditProfile;
|
||||
variable = %ownerObj @ ".minSize";
|
||||
Position = "150 2";
|
||||
Extent = "150 18";
|
||||
HorizSizing = "left";
|
||||
VertSizing = "bottom";
|
||||
};
|
||||
};
|
||||
|
||||
new GuiControl() {
|
||||
Position = "40 40";
|
||||
Extent = "270 18";
|
||||
HorizSizing = "right";
|
||||
VertSizing = "bottom";
|
||||
|
||||
new GuiTextCtrl() {
|
||||
profile = GuiInspectorFieldProfile;
|
||||
text = "Maximum Size:";
|
||||
Position = "0 2";
|
||||
Extent = "150 18";
|
||||
HorizSizing = "right";
|
||||
VertSizing = "bottom";
|
||||
};
|
||||
|
||||
new GuiTextEditCtrl() {
|
||||
profile = GuiInspectorTextEditProfile;
|
||||
variable = %ownerObj @ ".maxSize";
|
||||
Position = "150 2";
|
||||
Extent = "150 18";
|
||||
HorizSizing = "left";
|
||||
VertSizing = "bottom";
|
||||
};
|
||||
};
|
||||
|
||||
new GuiButtonCtrl() {
|
||||
canSaveDynamicFields = "0";
|
||||
Profile = "ToolsGuiButtonProfile";
|
||||
HorizSizing = "right";
|
||||
VertSizing = "bottom";
|
||||
Position = "40 60";
|
||||
Extent = "265 18";
|
||||
MinExtent = "8 2";
|
||||
canSave = "0";
|
||||
Visible = "1";
|
||||
hovertime = "100";
|
||||
tooltip = ""; //%tooltip;
|
||||
tooltipProfile = "EditorToolTipProfile";
|
||||
text = "Select";
|
||||
maxLength = "1024";
|
||||
command = %ownerObj @ ".SelectFiteredObjects("@ %ownerObj.minSize @","@ %ownerObj.maxSize @");";
|
||||
};
|
||||
};
|
||||
|
||||
%this-->stack.add(%container);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,54 @@
|
|||
function SubScene::onSelected(%this)
|
||||
{
|
||||
EWToolsPaletteWindow.clearButtons();
|
||||
|
||||
//Adds a button to the pallete stack
|
||||
EWToolsPaletteWindow.addButton("Select", "ToolsModule:arrow_n_image", "EWorldEditorNoneModeBtn::onClick();", "", "Select Arrow", "1");
|
||||
EWToolsPaletteWindow.addButton("Move", "ToolsModule:translate_n_image", "SubSceneMoveModeBtn::onClick();", "", "Move Selection", "2");
|
||||
EWToolsPaletteWindow.addButton("Rotate", "ToolsModule:rotate_n_image", "SubSceneRotateModeBtn::onClick();", "", "Rotate Selection", "3");
|
||||
EWToolsPaletteWindow.addButton("Scale", "ToolsModule:Scale_n_image", "EWorldEditorScaleModeBtn::onClick();", "", "Scale Selection", "4");
|
||||
|
||||
EWToolsPaletteWindow.addButton("SubSceneMove", "ToolsModule:translate_n_image", "SubSceneChildMoveModeBtn::onClick();", "", "Move SubScene + Children", "5");
|
||||
EWToolsPaletteWindow.addButton("SubSceneRotate", "ToolsModule:rotate_n_image", "SubSceneChildRotateModeBtn::onClick();", "", "Rotate SubScene + Children", "6");
|
||||
|
||||
EWToolsPaletteWindow.refresh();
|
||||
}
|
||||
|
||||
function SubScene::onUnselected(%this)
|
||||
{
|
||||
EWToolsPaletteWindow.clearButtons();
|
||||
|
||||
//Adds a button to the pallete stack
|
||||
EWToolsPaletteWindow.addButton("Select", "ToolsModule:arrow_n_image", "EWorldEditorNoneModeBtn::onClick();", "", "Select Arrow", "1");
|
||||
EWToolsPaletteWindow.addButton("Move", "ToolsModule:translate_n_image", "EWorldEditorMoveModeBtn::onClick();", "", "Move Selection", "2");
|
||||
EWToolsPaletteWindow.addButton("Rotate", "ToolsModule:rotate_n_image", "EWorldEditorRotateModeBtn::onClick();", "", "Rotate Selection", "3");
|
||||
EWToolsPaletteWindow.addButton("Scale", "ToolsModule:Scale_n_image", "EWorldEditorScaleModeBtn::onClick();", "", "Scale Selection", "4");
|
||||
|
||||
$SubScene::transformChildren = false;
|
||||
|
||||
EWToolsPaletteWindow.refresh();
|
||||
}
|
||||
|
||||
function SubSceneMoveModeBtn::onClick(%this)
|
||||
{
|
||||
EWorldEditorMoveModeBtn::onClick();
|
||||
$SubScene::transformChildren = false;
|
||||
}
|
||||
|
||||
function SubSceneRotateModeBtn::onClick(%this)
|
||||
{
|
||||
EWorldEditorRotateModeBtn::onClick();
|
||||
$SubScene::transformChildren = false;
|
||||
}
|
||||
|
||||
function SubSceneChildMoveModeBtn::onClick()
|
||||
{
|
||||
EWorldEditorMoveModeBtn::onClick();
|
||||
$SubScene::transformChildren = true;
|
||||
}
|
||||
|
||||
function SubSceneChildRotateModeBtn::onClick()
|
||||
{
|
||||
EWorldEditorRotateModeBtn::onClick();
|
||||
$SubScene::transformChildren = true;
|
||||
}
|
||||
|
|
@ -329,9 +329,6 @@ function EditorSaveMission()
|
|||
|
||||
if(EWorldEditor.isDirty || ETerrainEditor.isMissionDirty)
|
||||
{
|
||||
//Inform objects a save is happening, in case there is any special pre-save behavior a class needs to do
|
||||
getScene(0).callOnChildren("onSaving", $Server::MissionFile);
|
||||
|
||||
getScene(0).save($Server::MissionFile);
|
||||
|
||||
}
|
||||
|
|
@ -604,18 +601,20 @@ function EditorOpenSceneAppend(%levelAsset)
|
|||
|
||||
function MakeSelectionASublevel()
|
||||
{
|
||||
/*%size = EWorldEditor.getSelectionSize();
|
||||
%size = EWorldEditor.getSelectionSize();
|
||||
if ( %size == 0 )
|
||||
return;
|
||||
|
||||
//Make a new Scene object
|
||||
|
||||
//Make a group for the objects to go into to be processed as into a
|
||||
//subscene
|
||||
%group = new SimGroup();
|
||||
for(%i=0; %i < %size; %i++)
|
||||
{
|
||||
|
||||
%group.add(EWorldEditor.getSelectedObject(%i));
|
||||
}
|
||||
%a = EWorldEditor.getSelectedObject(0);
|
||||
%b = EWorldEditor.getSelectedObject(1);*/
|
||||
|
||||
//Now that we have a group, process it into a subscene
|
||||
EWorldEditor.createSelectedAsSubScene(%group);
|
||||
}
|
||||
|
||||
function updateEditorRecentLevelsList(%levelAssetId)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue