Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Item Drag Drop sample #15

Closed
orosbogdan opened this issue Sep 6, 2024 · 3 comments
Closed

Item Drag Drop sample #15

orosbogdan opened this issue Sep 6, 2024 · 3 comments

Comments

@orosbogdan
Copy link

I think it would be amazing if you could provide a few items that can be moved around in the inventory demo.
Any maybe an example on how we can drag items from inventory to the skillbar in the HUD.

@Videogamers0
Copy link
Owner

Videogamers0 commented Sep 7, 2024

7b1543a

Unfortunately MGUI doesn't provide a drag+drop framework, so you'd have to subscribe and react to mouse events yourself to implement the desired behavior. I've added a simple example of this to the FF7Inventory dialog. You can now drag an item from the inventory and drop it onto a party member in the list on the left to use the item on the party member.

In the sample, drag+drop is mainly implemented by doing the following:

  1. Detect when an item in the inventory is pressed and when it is released. You can find this logic in MGListBox's constructor, mainly lines 687 to 711.

  2. Detect when a party member in the party list is hovered. You can find this logic in FF7Inventory.xaml.cs 's constructor, mainly lines 208 to 239.

If a party member is hovered, while an inventory item is currently pressed but not released, we render an additional transparent yellow overlay onto the party member (line #234). When the left-mouse button is released, we prioritize using the pressed inventory item instead of the selected inventory item (line #213)

@orosbogdan
Copy link
Author

7b1543a

Unfortunately MGUI doesn't provide a drag+drop framework, so you'd have to subscribe and react to mouse events yourself to implement the desired behavior. I've added a simple example of this to the FF7Inventory dialog. You can now drag an item from the inventory and drop it onto a party member in the list on the left to use the item on the party member.

In the sample, drag+drop is mainly implemented by doing the following:

  1. Detect when an item in the inventory is pressed and when it is released. You can find this logic in MGListBox's constructor, mainly lines 687 to 711.
  2. Detect when a party member in the party list is hovered. You can find this logic in FF7Inventory.xaml.cs 's constructor, mainly lines 208 to 239.

If a party member is hovered, while an inventory item is currently pressed but not released, we render an additional transparent yellow overlay onto the party member (line #234). When the left-mouse button is released, we prioritize using the pressed inventory item instead of the selected inventory item (line #213)

Awesome, thank you for the sample.

I wanted to ask as well if MGUI is compatible with Android Touch Input ? I have seen only things related to mouse/keyboard in the documentation. If it's not, could you suggest a good starting point for implementing it ?

Also does MGUI work with visual studio's intellisense for autocomplete ?

@Videogamers0
Copy link
Owner

No, I've never worked with Microsoft.Xna.Framework.Input.Touch. If the touch input registers as a mouse click it would probably work fine out of the box. But gestures would need their own specific logic.

VS intellisense should work as long as you set the default namespace to xmlns="clr-namespace:MGUI.Core.UI.XAML;assembly=MGUI.Core". See here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants