Fixes the inspector/component editor to display the components attached to an entity correctly in the inspector.

This commit is contained in:
Areloch 2017-12-03 01:21:30 -06:00
parent 4f78143dc8
commit b5277e0f08
10 changed files with 513 additions and 44 deletions

View file

@ -41,6 +41,12 @@ $Core::UnAvailableTexturePath = "core/images/unavailable";
$Core::WarningTexturePath = "core/images/warnMat";
$Core::CommonShaderPath = "core/shaders";
ModuleDatabase.setModuleExtension("module");
//Core components
ModuleDatabase.scanModules( "core", false );
ModuleDatabase.LoadExplicit( "CoreComponentsModule" );
exec("./helperFunctions.cs");
// We need some of the default GUI profiles in order to get the canvas and

View file

@ -132,6 +132,23 @@ function isNameUnique(%name)
//
function GameConnection::onDrop(%client, %reason)
{
%entityIds = parseMissionGroupForIds("Entity", "");
%entityCount = getWordCount(%entityIds);
for(%i=0; %i < %entityCount; %i++)
{
%entity = getWord(%entityIds, %i);
for(%e=0; %e < %entity.getCount(); %e++)
{
%child = %entity.getObject(%e);
if(%child.getClassName() $= "Entity")
%entityIds = %entityIds SPC %child.getID();
}
%entity.notify("onClientDisconnect", %client);
}
if($missionRunning)
theLevelInfo.onClientLeaveGame();

View file

@ -131,6 +131,22 @@ function serverCmdMissionStartPhase3Ack(%client, %seq)
%client.currentPhase = 3;
// Server is ready to drop into the game
%entityIds = parseMissionGroupForIds("Entity", "");
%entityCount = getWordCount(%entityIds);
for(%i=0; %i < %entityCount; %i++)
{
%entity = getWord(%entityIds, %i);
for(%e=0; %e < %entity.getCount(); %e++)
{
%child = %entity.getObject(%e);
if(%child.getCLassName() $= "Entity")
%entityIds = %entityIds SPC %child.getID();
}
%entity.notify("onClientConnect", %client);
}
//Have any special game-play handling here
if(theLevelInfo.isMethod("onClientEnterGame"))
@ -151,7 +167,7 @@ function serverCmdMissionStartPhase3Ack(%client, %seq)
};
}
if (isDefined("$Game::DefaultCameraClass"))
//if (isDefined("$Game::DefaultCameraClass"))
%client.camera = spawnObject("Camera", Observer);
}

View file

@ -154,13 +154,13 @@ function QuickEditComponentList::onHotTrackItem( %this, %itemID )
SuperTooltipDlg.setTitle(%componentObj.friendlyName);
SuperTooltipDlg.addParam("", %componentObj.description @ "\n");
%fieldCount = %componentObj.getComponentFieldCount();
/*%fieldCount = %componentObj.getComponentFieldCount();
for (%i = 0; %i < %fieldCount; %i++)
{
%name = getField(%componentObj.getComponentField(%i), 0);
SuperTooltipDlg.addParam(%name, %description @ "\n");
}
}*/
%position = %this.getGlobalPosition();
SuperTooltipDlg.processTooltip( %position,0,1 );
%this.opened = true;
@ -219,7 +219,7 @@ function AddComponentQuickEditButton::onClick(%this)
%instance.owner = Inspector.getInspectObject(0);
%instance.owner.add(%instance);
Inspector.schedule( 50, "refresh" );
schedule( 50, 0, "refreshInspector", Inspector.getInspectObject(0) );
EWorldEditor.isDirty = true;
}
@ -227,7 +227,97 @@ function addComponent(%obj, %instance)
{
echo("Adding the component!");
%obj.addComponent(%instance);
Inspector.schedule( 50, "refresh" );
//Inspector.schedule( 50, "refresh" );
schedule( 50, 0, "refreshInspector", Inspector.getInspectObject(0) );
EWorldEditor.isDirty = true;
}
function refreshInspector(%entity)
{
inspector.removeInspect(%entity);
inspector.addInspect(%entity);
}
function GuiInspectorComponentGroup::onConstructComponentField(%this, %component, %fieldName)
{
//echo("Tried to make a component field for component:" @ %component @ " for the " @ %fieldName @ " field.");
%fieldType = %component.getComponentFieldType(%fieldName);
%makeCommand = %this @ ".build" @ %fieldType @ "Field("@ %component @ "," @ %fieldName @ ");";
eval(%makeCommand);
}
function GuiInspectorComponentGroup::onRightMouseUp(%this, %point)
{
if( !isObject( InspectComponentPopup ) )
new PopupMenu( InspectComponentPopup )
{
superClass = "MenuBuilder";
isPopup = true;
item[ 0 ] = "View in Asset Browser" TAB "" TAB "AssetBrowser.editAsset();";
item[ 1 ] = "Delete Component" TAB "" TAB "schedule(10, 0, ComponentEditorRemoveComponent, InspectComponentPopup.componentOwner, InspectComponentPopup.component);";
item[ 2 ] = "Edit Script" TAB "" TAB "AssetBrowser.editAsset();";
item[ 3 ] = "";
};
%comp = %this.getComponent();
InspectComponentPopup.componentOwner = %comp.owner;
InspectComponentPopup.component = %comp;
//Find out our asset!
%componentName = %this.caption;
%assetQuery = new AssetQuery();
if(!AssetDatabase.findAssetType(%assetQuery, "ComponentAsset"))
return; //if we didn't find ANY, just exit
EditAssetPopup.assetId = "";
// Find all the types.
%count = %assetQuery.getCount();
%categories = "";
for (%i = 0; %i < %count; %i++)
{
%assetId = %assetQuery.getAsset(%i);
%componentAsset = AssetDatabase.acquireAsset(%assetId);
%friendlyName = %componentAsset.friendlyName;
if(%friendlyName !$= "" && %friendlyName $= %componentName)
{
EditAssetPopup.assetId = %assetId;
break;
}
%compName = %componentAsset.componentName;
if(%compName !$= "" && %compName $= %componentName)
{
EditAssetPopup.assetId = %assetId;
break;
}
}
if(EditAssetPopup.assetId $= "")
{
//didn't find it
InspectComponentPopup.enableItem(0, false);
InspectComponentPopup.enableItem(2, false);
}
else
{
InspectComponentPopup.enableItem(0, true);
InspectComponentPopup.enableItem(2, true);
}
InspectComponentPopup.showPopup(Canvas);
}
function ComponentEditorRemoveComponent(%entity, %component)
{
%entity.removeComponent(%component, true);
inspector.removeInspect(%entity);
inspector.addInspect(%entity);
}

View file

@ -1302,6 +1302,7 @@ function VisibilityDropdownToggle()
{
EVisibility.setVisible(true);
visibilityToggleBtn.setStateOn(1);
EVisibility.setExtent("200 540");
}
}
@ -1641,6 +1642,31 @@ function EditorTree::onRightMouseUp( %this, %itemId, %mouse, %obj )
object = -1;
};
if(%obj.isMemberOfClass("Entity"))
{
if( !isObject( GameObjectPopup ) )
%popup = new PopupMenu( GameObjectPopup : ETSimGroupContextPopup )
{
//item[ 12 ] = "-";
item[ 12 ] = "Convert to Game Object" TAB "" TAB "EWorldEditor.createGameObject( %this.object );";
item[ 13 ] = "Duplicate Game Object" TAB "" TAB "EWorldEditor.duplicateGameObject( %this.object );";
item[ 14 ] = "Show in Asset Browser" TAB "" TAB "EWorldEditor.showGameObjectInAssetBrowser( %this.object );";
};
if(!isObject(AssetDatabase.acquireAsset(%obj.gameObjectAsset)))
{
GameObjectPopup.enableItem(12, true);
GameObjectPopup.enableItem(13, false);
GameObjectPopup.enableItem(14, false);
}
else
{
GameObjectPopup.enableItem(12, false);
GameObjectPopup.enableItem(13, true);
GameObjectPopup.enableItem(14, true);
}
}
%popup.object = %obj;