mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-15 08:34:40 +00:00
clean out unnecessary position set
add a new route for the asset browser to create things in the form of ".on" @ %assetType @ "GUIEditorDropped(" @ %assetDef @ ",\"" @ %pos @ "\");";
demonstrate it with a soundasset creating a GuiAudioCtrl when drug onto the canvas
This commit is contained in:
parent
54a4510bc6
commit
733c9d4b6d
3 changed files with 29 additions and 12 deletions
|
|
@ -2583,11 +2583,23 @@ function GuiEditor::onControlDropped(%this, %payload, %position)
|
||||||
%assetId = %payload.moduleName @ ":" @ %payload.assetName;
|
%assetId = %payload.moduleName @ ":" @ %payload.assetName;
|
||||||
%assetType = AssetDatabase.getAssetType(%assetId);
|
%assetType = AssetDatabase.getAssetType(%assetId);
|
||||||
|
|
||||||
if(%assetType $= "ImageAsset")
|
if(AssetBrowser.isMethod("on" @ %assetType @ "GUIEditorDropped"))
|
||||||
{
|
{
|
||||||
%cmd = "return new guiBitmapCtrl();";
|
%module = %payload.moduleName;
|
||||||
%ctrl = eval( %cmd );
|
%asset = %payload.assetName;
|
||||||
%ctrl.bitmap = %assetId;
|
%assetDef = AssetDatabase.acquireAsset(%module @ ":" @ %asset);
|
||||||
|
%buildCommand = AssetBrowser @ ".on" @ %assetType @ "GUIEditorDropped(" @ %assetDef @ ",\"" @ %pos @ "\");";
|
||||||
|
eval(%buildCommand);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//fallback example
|
||||||
|
if(%assetType $= "ImageAsset")
|
||||||
|
{
|
||||||
|
%cmd = "return new guiBitmapCtrl();";
|
||||||
|
%ctrl = eval( %cmd );
|
||||||
|
%ctrl.bitmap = %assetId;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
||||||
|
|
@ -91,6 +91,17 @@ function AssetBrowser::onSoundAssetEditorDropped(%this, %assetDef, %position)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function AssetBrowser::onSoundAssetGUIEditorDropped(%this, %assetDef, %position)
|
||||||
|
{
|
||||||
|
%assetId = %assetDef.getAssetId();
|
||||||
|
%cmd = "new GuiAudioCtrl(){";
|
||||||
|
%cmd = %cmd @ "SoundAsset =\""@ %assetId @"\";";
|
||||||
|
%cmd = %cmd @ "position =\""@ %position @"\";";
|
||||||
|
%cmd = %cmd @ "};";
|
||||||
|
%ctrl = GuiEditCanvas.createObject(%cmd);
|
||||||
|
echo(%ctrl SPC "created");
|
||||||
|
}
|
||||||
|
|
||||||
function GuiInspectorTypeSoundAssetPtr::onControlDropped( %this, %payload, %position )
|
function GuiInspectorTypeSoundAssetPtr::onControlDropped( %this, %payload, %position )
|
||||||
{
|
{
|
||||||
Canvas.popDialog(EditorDragAndDropLayer);
|
Canvas.popDialog(EditorDragAndDropLayer);
|
||||||
|
|
|
||||||
|
|
@ -291,12 +291,6 @@ function GuiEditCanvas::createObject( %this, %cmd )
|
||||||
function GuiEditCanvas::onFinishCreateObject( %this, %objId )
|
function GuiEditCanvas::onFinishCreateObject( %this, %objId )
|
||||||
{
|
{
|
||||||
GuiEditor.getCurrentAddSet().add( %objId );
|
GuiEditor.getCurrentAddSet().add( %objId );
|
||||||
|
|
||||||
if( %objId.isMemberOfClass( "GuiControl" ) )
|
|
||||||
{
|
|
||||||
%objId.position = "0 0";
|
|
||||||
}
|
|
||||||
|
|
||||||
%this.onObjectCreated( %objId );
|
%this.onObjectCreated( %objId );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue