Implementation of Subscenes, SceneGroups and Gamemodes

Standardizes Gamemodes to be an actual class with data and utility functions that can be parsed
Adds inspector field handling for selecting gamemodes
Updated Scene class to work with Gamemodes for the gamemode field
Updates editor suite elements to be able to create SubScenes, SceneGroups and Gamemodes
Adds ability to convert SimGroup to SubScene
Updates BaseUI's chooselevel menu to have gamemode selection and filters shown levels based on selected gamemode
This commit is contained in:
Areloch 2024-09-01 16:39:00 -05:00
parent 0d07823ecd
commit ae8eca48e1
36 changed files with 2963 additions and 173 deletions

View file

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

View file

@ -2007,7 +2007,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
{
@ -2103,6 +2103,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 @ " );";
}
}
}
}
@ -2142,7 +2150,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 )
@ -2582,6 +2590,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 )
@ -2847,6 +2926,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 )

View file

@ -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" );

View file

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