Wednesday, 15 March 2017

Xbox One Support

Since starting work on the big refactoring piece I haven't paid too much attention to broadening platform support. However, since Microsoft announced the Xbox Live Creators Program (essentially a replacement for the Xbox 360's Xbox Live Indie Games), I was curious to see how much effort it would be to get XAGE up and running on the Universal Windows Platform. It turned out to be this: two evenings, thanks to MonoGame v3.6.  Using the latest version of Protobuild, XAGE Editor will now automatically create a Visual Studio solution for UWP:


Some of the changes to the engine could be done without breaking anything, though some required introducing more preprocessor soup (#if #else #endif) due to breaking framework changes. Ideally once dotnet core matures then we can move towards NETStandard libraries for all platforms.
  • UWP forces all file IO to be asynchronous, so the simplest solution was to use a synchronous wrapper specifically for the WindowsUniversal libraries. 
  • Minor API changes were needed (e.g. replacing Delegate.CreateDelegate with MethodInfo.CreateDelegate, generic use of SystemException with System.Exception).
  • Replace all Stream.Close() with Stream.Dispose() where a using block is not used for automatic cleanup. 
  • Remove all errant use of System.Console.Write() for debugging.
  • Identifying the main UI thread using Task.CurrentId instead of Thread.CurrentThread.ManagedThreadId (access to threads is not exposed in UWP).
  • Inserting GetTypeInfo() into various reflection method calls and properties due to a very UWP specific workaround.
The result of this work is that XAGE now tentatively supports the Windows 10 Store and the Xbox One family of consoles. I've updated the list of supported platforms accordingly.


Not everything is quite implemented yet (serialization, audio etc) but I'll return to finish this up once the main refactoring is complete.

No comments: