Multiplayer Input - Selecting Items in a Listbox - Best Practices
Posted: 21 Apr 2020, 06:29
Hi team,
Another best practice question. I need to extend a Listbox to handle multiplayer input. It's a character select screen. Each user can move through the list but they can't highlight/select the same item. If they try to move onto a selected item, it jumps to the next one. Is there an easy way to do this without having to add lots of custom code to the Listbox? What would be the best approach?
Right now my Listbox supports one player. It looks like:
I'm aware there's a SelectionMode="Multiple" property on Listbox. I figure I'll need to use that. I see there is a SelectedItemsCollection but I don't know how I'm supposed to bind to it so I can use it in my ViewModel. And there doesn't seem to be a SelectedIndexes/Indices either.
While testing I removed SelectedItem and SelectedIndex. Then I added SelectionMode. When I ran the game, I could no longer move through the Listbox with my gamepad. How do I get it to move through it again?
My next question is about multiplayer. It seems Noesis doesn't distinguish between which gamepad the input comes from. Is this correct? If so, we have some code in our engine that we can use to do that. But what's the best way to hook them up with the Listbox events and be MVVM friendly? Would it be a good approach for my ViewModel to know about the game engine inputs? Then on Listbox SelectionChanged, do a check to see which gamepad did the selection? We also thought about having individual Views for each gamepad. Would this be a good approach?
Thank you for your help,
R
Another best practice question. I need to extend a Listbox to handle multiplayer input. It's a character select screen. Each user can move through the list but they can't highlight/select the same item. If they try to move onto a selected item, it jumps to the next one. Is there an easy way to do this without having to add lots of custom code to the Listbox? What would be the best approach?
Right now my Listbox supports one player. It looks like:
Code: Select all
<ListBox x:Name="theListBox"
ItemsSource="{Binding Players}"
SelectedItem="{Binding SelectedItem}"
SelectedIndex="{Binding SelectedIndex}"
....other stuff....
>
I'm aware there's a SelectionMode="Multiple" property on Listbox. I figure I'll need to use that. I see there is a SelectedItemsCollection but I don't know how I'm supposed to bind to it so I can use it in my ViewModel. And there doesn't seem to be a SelectedIndexes/Indices either.
While testing I removed SelectedItem and SelectedIndex. Then I added SelectionMode. When I ran the game, I could no longer move through the Listbox with my gamepad. How do I get it to move through it again?
My next question is about multiplayer. It seems Noesis doesn't distinguish between which gamepad the input comes from. Is this correct? If so, we have some code in our engine that we can use to do that. But what's the best way to hook them up with the Listbox events and be MVVM friendly? Would it be a good approach for my ViewModel to know about the game engine inputs? Then on Listbox SelectionChanged, do a check to see which gamepad did the selection? We also thought about having individual Views for each gamepad. Would this be a good approach?
Thank you for your help,
R