Skip to content

Commit

Permalink
Added native FXB support
Browse files Browse the repository at this point in the history
Drag+drop file into global content is now tasked.
Added FXB support in Glue.
  • Loading branch information
vchelaru committed Jan 17, 2024
1 parent 4ce2892 commit f49a011
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 1 deletion.
5 changes: 5 additions & 0 deletions Engines/FlatRedBallXNA/FlatRedBall/Content/ContentManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -787,6 +787,11 @@ public T LoadFromFile<T>(string assetName)

#endregion

else if(typeof(T) == typeof(Effect))
{
return base.Load<T>(assetName);
}

#region else, exception!

else
Expand Down
6 changes: 5 additions & 1 deletion FRBDK/Glue/Glue/Managers/DragDropManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1617,7 +1617,11 @@ public void HandleDropExternalFileOnTreeNode(FilePath[] droppedFiles, ITreeNode
}
else
{
AddExistingFileManager.Self.AddSingleFile(fileName, ref userCancelled);
TaskManager.Self.Add(() =>
{
AddExistingFileManager.Self.AddSingleFile(fileName, ref userCancelled);

}, "Add file " + fileName);
}
}

Expand Down
40 changes: 40 additions & 0 deletions FRBDK/Glue/OfficialPlugins/EffectPlugin/MainEffectPlugin.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
using FlatRedBall.Glue.Plugins;
using FlatRedBall.Glue.Plugins.ExportedImplementations;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using OfficialPlugins.EffectPlugin.Managers;
using System.ComponentModel.Composition;

namespace OfficialPlugins.EffectPlugin
{
[Export(typeof(PluginBase))]
public class MainEffectPlugin : PluginBase
{
public override string FriendlyName => "Effect Plugin";

public override void StartUp()
{
this.ReactToLoadedGlux += HandleLoadGlux;
this.ReactToUnloadedGlux += HandleUnloadGlux;
}

private void HandleLoadGlux()
{
var project = GlueState.Self.CurrentGlueProject;
var isFna = false;

if(isFna)
{
this.AddAssetTypeInfo(AssetTypeInfoManager.FxbEffectAssetTypeInfo);
}
}

private void HandleUnloadGlux()
{
this.UnregisterAssetTypeInfos();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using FlatRedBall.Glue.Elements;
using FlatRedBall.IO;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace OfficialPlugins.EffectPlugin.Managers
{
public static class AssetTypeInfoManager
{
static AssetTypeInfo fxbEffectAssetTypeInfo;
public static AssetTypeInfo FxbEffectAssetTypeInfo =>
fxbEffectAssetTypeInfo = fxbEffectAssetTypeInfo ?? CreateFxbEffectAssetTypeInfo();

private static AssetTypeInfo CreateFxbEffectAssetTypeInfo()
{
var originalEffect = AvailableAssetTypes.Self.AllAssetTypes.FirstOrDefault(item =>
item.Extension == "fx" &&
item.QualifiedRuntimeTypeName.QualifiedType == "Microsoft.Xna.Framework.Graphics.Effect");

var fbxEffect = FileManager.CloneObject(originalEffect);

fbxEffect.FriendlyName = "Effect (.fxb)";
fbxEffect.Extension = "fxb";
fbxEffect.MustBeAddedToContentPipeline = false;
fbxEffect.CanBeAddedToContentPipeline = false;
fbxEffect.ContentImporter = null;
fbxEffect.ContentProcessor = null;

return fbxEffect;
}
}
}

0 comments on commit f49a011

Please sign in to comment.