This project is read-only.

Multiplayer support in Nuclex.UserInterface

Dec 26, 2009 at 4:55 AM

I just ran across Nuclex and I'm impressed with a lot of the functionality it provides.  One thing that I don't see, however, is a way to use Nuclex.UserInterface to create a control hierarchy that more than one player can use at the same time.  As an example, let's say I was attempting to create a character-select screen (such as the kind you see in a fighting game).  I'd define a new type of control whose "OnButtonPressed()" assigned a given character to the player.  However, if more than one player was playing at once, I'd need to know which player to assign the character to.  I would have expected the various Control callbacks to specify a PlayerIndex as well as as the button or key that that player had pressed.  Am I just missing something, or is there no way to do this right now?

Thanks in advance for your help, as well as for putting together an excellent framework.


Dec 27, 2009 at 10:33 AM

I have to admit that I didn't think of such a use case yet. There is only a single focused control, so all players would be controlling the same cursor - if the XnaInputCapturer even polled more than one game pad, which it isn't designed to do currently.

Adding such a feature for the PC would present some difficulties as well because the GUI would need some means of mapping input to a player (so it knows which player's control focus to change). There might even be one input device belonging to two players (if player 1 and 2 shared the keyboard, for example.)

You *could* create a single CharacterSelectorControl that displays the entire stripe of characters and both player's cursors, then use a custom IInputCapturer that sends certain inputs directly to the CharacterSelectorControl.

I'll think about whether there's a way to support this in the current design. Maybe some optional IPlayerMapper or something could be assigned to the GUI to allow it to assign input devices to players without getting in the way of single player developers. :)