Shift tracking of dynamicObjects from strict child objects for Scenes, to tracking the objects but keeping them in the Cleanup Group to fix prefab loading behavior

Shifted to utilizing SimGroupInterator and persistenceManager to fix saving issues with SubScenes
Shifted to utilizing SimGroupIterator for Scene saving to standardize and minimize object misses
Changed prefab load file logic to add loaded child simgroup to rootscene for consistent tracking and avoiding conflicts with subScene's hijacking the ImmediateGroup var
Reduced duplication of build<type>field callback for inspectors
Added more standard field type lookups to inspector group when creating a field to avoid misses for types like 'F32' or similar.
Folded the added-on MinSize/MaxSize/SimgroupSelect fields for SimGroup editing into a single compound field and fixed bugs with it's behavior so it works as expected now
This commit is contained in:
JeffR 2024-10-27 20:04:13 -05:00
parent 484ece3d28
commit 10d1aeca1f
9 changed files with 221 additions and 128 deletions

View file

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

View file

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

View file

@ -563,6 +563,7 @@ function simGroup::SelectFiteredObjects(%this, %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));
@ -584,22 +585,27 @@ function simGroup::onInspect(%obj, %inspector)
//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("minSize", "F32", "min diagonal size of objects");
%group.addField("maxSize", "F32", "max diagonal size of objects");
%group.addField("select", "SimGroupSelectionButton", "Select filtered objects");
%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 18";
Extent = "300 80";
MinExtent = "8 2";
canSave = "0";
Visible = "1";
@ -607,24 +613,83 @@ function GuiInspectorGroup::buildSimGroupSelectionButtonField(%this, %fieldName,
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 = "16 3";
Extent = "300 18";
Position = "40 60";
Extent = "265 18";
MinExtent = "8 2";
canSave = "0";
Visible = "1";
hovertime = "100";
tooltip = ""; //%tooltip;
tooltipProfile = "EditorToolTipProfile";
text = %fieldName;
text = "Select";
maxLength = "1024";
command = %ownerObj @ ".SelectFiteredObjects("@ %ownerObj.minSize @","@ %ownerObj.maxSize @");";
};
};
%this-->stack.add(%container);
}