I've been doing some experimentation with creating custom flash UIs/elements in XCOM to make modding UI changes simpler. I'm planning on using this thread to share what I find out and hopefully some of the rest of you can find this useful too.
So far I've been able to create a custom flash movie to act as a UI and displayed it in both the tactical and the strategic game. Here's a screenshot of the strategic version, hooked up to the situation room and triggered by a "Campaign Summary" UI option. The flash object is simple and just drops a blue rectangle on the screen.
Here's what I know or think I know so far:
1. The UDK uses ScaleForm to embed flash into the game.
2. The version of the UDK used by XCOM supports only Flash 8 and ActionScript 2.0.
3. These versions of Flash are quite old and are no longer supported by the CC version of Flash, it doesn't support anything back further than Flash 10.3 and AS 3.0. Flash CS6 supports these versions, but I don't have this version.
4. It looks like even emitting Flash 10.3 SWFs will work in the UDK, at least the simple ones do, I'm assuming that as long as you stay away from any feature that is only present in versions later than 8 it will be ok.
5. ActionScript 3.0, on the other hand, is radically different from 2.0 and I don't think ActionScript created by Flash will work at all in the UDK.
6. Open Source projects like mtasc will compile actionscript 2.0. It might be possible to create a kind of hybrid workflow between Flash CC to author the basic flash layout and then use something like FlashDevelop to handle the scripting part to add actionscript 2 classes to the project.
Getting Flash into XCOM
So far I have two ideas fow how to get custom flash into xcom. The first I've tested, and the second I haven't.
The first option is to import the custom .swf into the UDK and add it to a new blank map via Kismet, then load the map into xcom as a streaming map on top of whatever map you want to display the flash in. Kismet can communicate with both the flash movie and the xcom unrealscript, and the flash map can be loaded either programmatically or via the defaultmaps.ini file.
Pros: Fairly easy to do, and very self-contained. Custom actionscript code can be created and compiled in your own packages associated with the custom map, all you need to do is create the appropriate stubs for the xcomgame or xcomstrategygame classes you want to reference and create the appropriate sequence objects for Kismet. Little hex modding to get it to work, just enough to stream the map when you want it to show up and to unload the map when you're done.
Cons: Any raster images in the .swf will be converted to textures by the UDK import process, which means these textures need to get added to the main Textures.tfc file or the game will crash. AFAIK we don't have any tools for patching the Textures.tfc file. Some .swfs may not have any bitmapped images in them and then this won't matter.
The second option is to mimic what Xcom already does. Import the .swf into the udk as for the first option, except instead of adding it to a blank map, just cook the package to create a "UI" package like the vanilla ones (UICollection_Tactical, UICollection_Strategic, etc). These then need to be referenced by unrealscript to load and play. The existing ones use special uscript classes that are subclasses of the classes FxsScreen or FxsPanel.
Pros: Better/easier texture handling so bitmapped images in the .swf should work better. (Is this true, or do the textures still need to be in the .tfc?)
Cons: More invasive. New class definitions need to be created, probably in their own packages, and these need to be loaded from the vanilla unrealscript. This means injecting new names and imports into the xcomgame/xcomstrategygame packages. The Fxs* base classes also appear to be a little magic, it looks like they involve a lot of native code to do stuff that we can't really see or understand easily. E.g. the AS_* functions to invoke actionscript seem to have some magic associated with them for parameter marshaling, and I don't know if this will even work with custom compiled subclasses or if it'd require access to the native development tools.
This is tricky since the XCOM UDK is so old. I really hope XCOM2 supports a slightly newer UDK that at least supports AS3 (apparently this was added to the version of ScaleForm included in the Nov 2011 UDK, so they only just missed it). Anyone lucky enough to have a Flash CS6 license can probably author a compatible flash file fairly quickly, but the rest of us will probably need to hack together some sort of weird hybrid solution. I've been experimenting with FlashDevelop and trying to construct a swf that when compiled looks sort of like the ones extracted from the xcom packages, but so far I haven't had much luck. I have almost zero knowledge of flash and actionscript internals and how to structure a project, though, so I'm really stumbling around this aspect of it. I need to spend some more time learning flash details to make more progress here.
So that's the status so far. I think I'm really close to being able to generate arbitrary UIs layered on top of XCOM, but I'm just stumbling at the flash scripting part. I'd really like to hear from anyone with more flash experience about how to create a .swf that looks compatible with the UDK. If anyone out there knows a little bit of flash and can help me out, please let me know, I'd appreciate it!
Edited by tracktwo, 07 July 2015 - 04:11 AM.