Fixed gui editor drag and drop behavior for image, shape, and sound

Ensure BitmapFile is given a proper default
This commit is contained in:
JeffR 2025-05-30 20:21:13 -05:00
parent 5397c168bc
commit 0e6c33f78a
7 changed files with 29 additions and 7 deletions

View file

@ -264,7 +264,7 @@ public:
{ \
imageAssetId = query.mAssetList[0]; \
} \
else if(Torque::FS::IsFile(_in) || (_in[0] == '$' || _in[0] == '#')) \
else if(Torque::FS::IsFile(_in) || (_in[0] == '$' || _in[0] == '#')) \
{ \
imageAssetId = ImageAsset::getAssetIdByFilename(_in); \
if (imageAssetId == ImageAsset::smNoImageAssetFallback) \

View file

@ -132,6 +132,7 @@ GuiBitmapButtonCtrl::GuiBitmapButtonCtrl()
mBitmapName = StringTable->EmptyString();
mBitmap = NULL;
mBitmapAsset.registerRefreshNotify(this);
mBitmapFile = String::EmptyString;
}
//-----------------------------------------------------------------------------

View file

@ -2515,7 +2515,7 @@ function GuiEditor::onControlDropped(%this, %payload, %position)
%assetId = %payload.moduleName @ ":" @ %payload.assetName;
%assetType = AssetDatabase.getAssetType(%assetId);
AssetBrowser.callAssetTypeFunc(%assetType, "GUIEditorDropped", %payload.moduleName, %payload.assetName, %pos);
%ctrl = AssetBrowser.callAssetTypeFunc(%assetType, "onGUIEditorDropped", %payload.moduleName, %payload.assetName, %pos);
}
else
{

View file

@ -319,18 +319,18 @@ function GenericAsset::onSaveProperties(%this)
//Called when the asset's Preview has been dragged and dropped into the world editor
//This would usually spawn an associated instance, or a scene object that can utilize the
//asset in question(ie, Dropping a SoundAsset spawns a SoundEmitter)
function GenericAsset::onWorldEditorDropped(%this, %position)
/*function GenericAsset::onWorldEditorDropped(%this, %position)
{
echo("GenericAsset::onWorldEditorDropped() - " @ %this @ ", " @ %position);
}
}*/
//Called when the asset's Preview has been dragged and dropped into the GUI editor
//This would usually spawn an associated instance, or a gui object that can utilize the
//asset in question(ie, Dropping a SoundAsset spawns a guiAudioCtrl)
function GenericAsset::onGuiEditorDropped(%this, %position)
/*function GenericAsset::onGuiEditorDropped(%this, %position)
{
echo("GenericAsset::onGuiEditorDropped() - " @ %this @ ", " @ %position);
}
}*/
//An example case of handling other specialized editors, such as dropping a Datablock
//Preview into the DatablockEditor. This would be very case-by-case

View file

@ -84,6 +84,18 @@ function ImageAsset::onSaveProperties(%this)
{
GenericAsset::onSaveProperties(%this);
}
function ImageAsset::onGuiEditorDropped(%this, %position)
{
%assetId = %this.getAssetId();
%cmd = "new GuiBitmapCtrl(){";
%cmd = %cmd @ "BitmapAsset =\""@ %assetId @"\";";
%cmd = %cmd @ "position =\""@ %position @"\";";
%cmd = %cmd @ "};";
%ctrl = GuiEditCanvas.createObject(%cmd);
return %ctrl;
}
function GuiInspectorTypeImageAssetPtr::onControlDropped( %this, %payload, %position )
{

View file

@ -148,9 +148,16 @@ function ShapeAsset::onWorldEditorDropped(%assetDef, %position)
MECreateUndoAction::submit(%newStatic );
}
function ShapeAsset::onGUIEditorDropped(%assetDef, %position)
function ShapeAsset::onGUIEditorDropped(%this, %position)
{
%assetId = %this.getAssetId();
%cmd = "new GuiObjectView(){";
%cmd = %cmd @ "ModelAsset =\""@ %assetId @"\";";
%cmd = %cmd @ "position =\""@ %position @"\";";
%cmd = %cmd @ "};";
%ctrl = GuiEditCanvas.createObject(%cmd);
return %ctrl;
}
function GuiInspectorTypeShapeAssetPtr::onControlDropped( %this, %payload, %position )

View file

@ -87,6 +87,8 @@ function SoundAsset::onGUIEditorDropped(%this, %position)
%cmd = %cmd @ "};";
%ctrl = GuiEditCanvas.createObject(%cmd);
//echo(%ctrl SPC "created");
return %ctrl;
}
function GuiInspectorTypeSoundAssetPtr::onControlDropped( %this, %payload, %position )