Skip to content

Commit

Permalink
Added support for specifying the "join style" for character screen
Browse files Browse the repository at this point in the history
  • Loading branch information
vchelaru committed Feb 28, 2024
1 parent 6339691 commit 4c381fb
Showing 1 changed file with 32 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@

namespace FlatRedBall.Forms.Controls.Games
{
public enum JoinStyle
{
AnyConnectedInput,
ExplicitlyAssignedInput
}
public class PlayerJoinView : FrameworkElement
{
#region Fields/Properties
Expand Down Expand Up @@ -55,6 +60,8 @@ public ReadOnlyCollection<PlayerJoinViewItem> PlayerJoinViewItems

public bool IsSubscribedToGamepadEvents { get; private set; }

public JoinStyle JoinStyle { get; set; } = JoinStyle.AnyConnectedInput;

#endregion


Expand Down Expand Up @@ -246,27 +253,41 @@ private void RefreshPlayerJoinViewItemsList()

#region Join/Unjoin


public override void Activity()
{
var gamepads = InputManager.Xbox360GamePads;

for(int i = 0; i < gamepads.Length; i++)
if(JoinStyle == JoinStyle.AnyConnectedInput)
{
var gamepad = gamepads[i];
var gamepads = InputManager.Xbox360GamePads;

if(gamepad.IsConnected && i < PlayerJoinViewItemsInternal.Count &&
// Keyboard is handled down below
PlayerJoinViewItemsInternal[i].GamepadLayout != GamepadLayout.Keyboard)
for(int i = 0; i < gamepads.Length; i++)
{
TestJoinUnjoin(gamepad, i);
var gamepad = gamepads[i];

if(gamepad.IsConnected && i < PlayerJoinViewItemsInternal.Count &&
// Keyboard is handled down below
PlayerJoinViewItemsInternal[i].GamepadLayout != GamepadLayout.Keyboard)
{
TestJoinUnjoin(gamepad, i);
}
}
}

foreach(var item in PlayerJoinViewItemsInternal)
for (int i = 0; i < PlayerJoinViewItemsInternal.Count; i++)
{
if(item.GamepadLayout == GamepadLayout.Keyboard)
PlayerJoinViewItem item = PlayerJoinViewItemsInternal[i];
if (item.InputDevice != null)
{
TestJoinUnjoinWithKeyboard(item);
if(item.InputDevice is FlatRedBall.Input.Keyboard)
{
TestJoinUnjoinWithKeyboard(item);
}
else if(item.InputDevice is Xbox360GamePad gamepad)
{
TestJoinUnjoin(gamepad, i);

}

}
}

Expand Down

0 comments on commit 4c381fb

Please sign in to comment.