UI controls/widgets that contain state, and/or handling state that might not belong in the ViewModel?
Hi,
I've asked along this topic before, but recently I recorded a video for a UI Engineer friend asking a similar question, and realized the video is way clearer than typing things out. I'm basically struggling to understand how in MVVM/Noesis to model the kinds of interactions you see in the video, especially the missile launch control, where there's clearly some state accruing but it's seemingly all just in the UI, so it shouldn't exactly go on the "ShipViewModel" (pretending they use MVVM in this game for our discussion). I'm not sure where to stick that kind of state.
How would you go about structuring things for that order UI and the transition to picking the missile launch targets -> accruing that UI state somewhere before accepting it and sending it off to the ship/simulation? This is gonna be a common loop for me and I keep banging my head against it.
Here's the video, an example I filmed from the game "Nebulous Fleet Command", and I do apologize for the language but again was originally a video for a friend :)
I appreciate any help!
I've asked along this topic before, but recently I recorded a video for a UI Engineer friend asking a similar question, and realized the video is way clearer than typing things out. I'm basically struggling to understand how in MVVM/Noesis to model the kinds of interactions you see in the video, especially the missile launch control, where there's clearly some state accruing but it's seemingly all just in the UI, so it shouldn't exactly go on the "ShipViewModel" (pretending they use MVVM in this game for our discussion). I'm not sure where to stick that kind of state.
How would you go about structuring things for that order UI and the transition to picking the missile launch targets -> accruing that UI state somewhere before accepting it and sending it off to the ship/simulation? This is gonna be a common loop for me and I keep banging my head against it.
Here's the video, an example I filmed from the game "Nebulous Fleet Command", and I do apologize for the language but again was originally a video for a friend :)
I appreciate any help!
-
-
sfernandez
Site Admin
- Posts: 3363
- Joined:
Re: UI controls/widgets that contain state, and/or handling state that might not belong in the ViewModel?
Hi,
The first popup that shows seems like a normal UI interaction (you decide when to show it, mouse right-click, key binding, whatever...), nothing to do with the ViewModel. Then, you can show other parts of that panel (using a Expander, ToggleButton...?) again with no intervention of the ViewModel, just pure UI changes. But some ViewModel (ShipViewModel?) has to be set as DataContext of that popup panel, as you need to show and modify parts of the game data.
Regarding the launching missiles part, it looks like you would need a custom control that is able to render those lines and targets info. The control will listen to mouse movement and clicks to render the lines and add new targets. The targets can be a collection property exposed by the control that can be bound to the ViewModel. That way your game is notified when new targets are added by the control.
Does that makes sense to you?
The first popup that shows seems like a normal UI interaction (you decide when to show it, mouse right-click, key binding, whatever...), nothing to do with the ViewModel. Then, you can show other parts of that panel (using a Expander, ToggleButton...?) again with no intervention of the ViewModel, just pure UI changes. But some ViewModel (ShipViewModel?) has to be set as DataContext of that popup panel, as you need to show and modify parts of the game data.
Regarding the launching missiles part, it looks like you would need a custom control that is able to render those lines and targets info. The control will listen to mouse movement and clicks to render the lines and add new targets. The targets can be a collection property exposed by the control that can be bound to the ViewModel. That way your game is notified when new targets are added by the control.
Does that makes sense to you?
Who is online
Users browsing this forum: Bing [Bot], Google [Bot] and 2 guests