Merge branch 'SubScenes_Gamemode_PR' of https://github.com/Areloch/Torque3D into development

This commit is contained in:
JeffR 2024-12-15 18:39:03 -06:00
commit 81ac23fd35
60 changed files with 4200 additions and 525 deletions

View file

@ -42,7 +42,7 @@ $guiContent = new GuiControl() {
minSize = "50 50";
EdgeSnap = false;
text = "";
class = "EWToolsPaletteWindowClass";
class = "ButtonPalette";
new GuiDynamicCtrlArrayControl(ToolsPaletteArray) {
canSaveDynamicFields = "0";

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

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

View file

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

View file

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

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

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

View file

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

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)