So, I found a bit of a workaround for loading graphical content via resources, at least on Windows.
The idea is to implement a simple IServiceProvider and IGraphicsDeviceService that can be created from a graphics device, like so:
internal class SimpleServiceProvider : IServiceProvider
{
GraphicsDeviceService _graphicsDevice;
public SimpleServiceProvider(GraphicsDevice graphics)
{
_graphicsDevice = new GraphicsDeviceService(graphics);
}
public object GetService(Type serviceType)
{
if (serviceType == typeof(IGraphicsDeviceService))
return _graphicsDevice;
return null;
}
}
internal class GraphicsDeviceService : IGraphicsDeviceService
{
GraphicsDevice _device;
public GraphicsDeviceService(GraphicsDevice device)
{
_device = device;
_device.DeviceReset += DeviceReset;
_device.DeviceResetting += DeviceResetting;
_device.Disposing += DeviceDisposing;
}
public event EventHandler<EventArgs> DeviceCreated;
public event EventHandler<EventArgs> DeviceDisposing;
public event EventHandler<EventArgs> DeviceReset;
public event EventHandler<EventArgs> DeviceResetting;
public GraphicsDevice GraphicsDevice
{
get { return _device; }
}
}
Using this setup, you can (assuming you have some sort of handle to your graphics device), load content via the ResourceContentManager, like so:
SimpleServiceProvider service = new SimpleServiceProvider(graphics);
ResourceContentManager manager = new ResourceContentManager(service, Resources.ResourceManager);
SpriteFont font = manager.Load<SpriteFont>("BasicFont");
Cheers!