Jump to content

R&D XCOM UI/Flash modding


tracktwo

Recommended Posts

Attempt #2

 

Getting mouse input back into unrealscript from flash turned out to be not so big of a deal once I figured out how to organize things in Firaxis' system. When using the built in screen/panel system, mouse input is managed by the interface manager, UIFxsMovie. To communicate between your flash movie and your UI_FxsScreen or UI_FxsPanel sub-class, you just need the following:

[snip]

Very interesting summary, much appreciated. I'm sure this'll come in handy.

 

I knew a bit about how FlashRaiseMouseEvent() and OnMouseEvent() process stuff, but setting up everything is quite a different matter altogether :smile:

 

As a general reminder, a good UI is also navigable using non-mouse inputs (i.e. keyboard, gamepad). From what I can see these types of input typically aren't funneled through the Flash movie like it's done for mouse events. Rather they're handled directly on the UnrealScript side in the corresponding UI class using OnMouseEvent()'s sister function OnUnrealCommand(), which usually contains a big old switch statement for determining the input command and then doing some further processing.

This typically includes one or more ActionScript interface calls (either via the Invoke() method or via a special AS linker function [further reading]) to pass information to the Flash movie. A typical use case would be changing the currently focused interactive component in your menu (e.g. buttons, list items) using functions like SelectNext(), SelectPrevious(), SetSelectedIndex(), etc. in response to directional inputs (e.g. cursor keys, D-pad).

Edited by XMarksTheSpot
Link to comment
Share on other sites

@XMarksTheSpot I'm tackling keyboard/pad input next but I expect this to be much more straightforward as the control is from uscript to flash, like you say. It really shouldn't be much different than any other call into flash from uscript. I hope.

 

@DubiousIntent I know I owe a big update to the wiki. Thanks for getting the initial stuff put up there, I'll try to flesh it out. Last time I tried editing the wiki I couldn't submit any changes without the page timing out, though. Hopefully it's better now.

Link to comment
Share on other sites

...

@DubiousIntent I know I owe a big update to the wiki. Thanks for getting the initial stuff put up there, I'll try to flesh it out. Last time I tried editing the wiki I couldn't submit any changes without the page timing out, though. Hopefully it's better now.

You don't OWE us anything, but the community would greatly benefit from your insights.

 

I've found it best to draft things off-line (link to MediaWiki syntax), post to the wiki, and then "tweak" the results. But I'm usually available to take your plaintext material and put it into wiki markup for anyone needing help with that. Feel free to send it to me PM or post here.

 

-Dubious-

Link to comment
Share on other sites

Keyboard/Gamepad input is fairly easy to manage, as expected. Just provide the OnUnrealCommand(int Cmd, int Arg) function in your UI class and you'll get keyboard and gamepad events whenever your UI element is focused. Mouse events also come in through here, but in most cases you're probably better off handling this at the flash level so it is easier to figure out what was clicked on.

 

The list of input constants is in the class UI_FxsInput. For example, many UI screens will respond to all of the escape key, the gamepad B/Circle button, and the right mouse button to close the UI. This corresponds to entries for commands 301, 405, and 510.

 

Also a neat trick: by using the standard screen/panel system, the UI elements all coexist in the same movie instance as sub-clips. This means that if your UI is layered on top of another UI (as the campaign manager is currently layered on top of the situation room) you can actually access all of the flash elements of the other UI from actionscript. For example, the main text box in the situation room can be accessed through _level0.theInterfaceMgr.gfxSituationRoomHUD.theScreen.continentBody. "theInterfaceMgr" is the main interface movie (UIInterfaceMgr). You can derive the rest of the path by looking at the UI class in question (gfxSituationRoomHUD is the s_screenId field in UISituationRoom and theScreen is the s_name field) and the actual flash itself (continentBody is a child element of "theScreen" when you look at the flash file in JPEXS). So one possible way to add new flash to an existing UI is to layer an invisible flash screen on top of it and tinker with the screen "below" through actionscript.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...