Author Topic: MODULE: [UI] DragDrop 1.0.0: helps to drag things around your AGS game!  (Read 7204 times)

The module works as in the video with AGS engine Android port (the app). Not quite drag and drop ;-D  by pressing and holding an inventory item, but I like it that way. It's practical too. I made the mouse cursor transparent so that it looks like it does on smartphones or iPads.



WoaM and Kathy Rain use a different code that works with the old android port - I actually have the script code because I asked by mail the dev, but I think you should just ask them yourself. If you want to use this module and use the same behavior for mouse and fingers, you need to use the Android SDL Port.

I have a little game that uses this module too here: https://github.com/ericoporto/dungeonhands

It has touch on the webport, but I don't know how well it runs on old devices. :/

What do you mean exactly by Android SDL Port? Do you mean by creating an APK with monkeys plugin or your way with Android Studio? I wanted to try that anyway.
Truly, truly, i say to you, blessed are those who play adventure games, for theirs is the kingdom of heaven.

Updated DragDropCommon module to 1.0.1, fixing default settings, to avoid people stumbling into a missing GUI crash if they forgot to explicitly set a drag mode.

Updated DragDropCommon module to 1.0.1, fixing default settings, to avoid people stumbling into a missing GUI crash if they forgot to explicitly set a drag mode.

Thank u.
Truly, truly, i say to you, blessed are those who play adventure games, for theirs is the kingdom of heaven.

deadsuperhero

  • There's no sense crying over spilled tears.
    • I can help with backgrounds
    • I can help with characters
    • I can help with making music
    • I can help with scripting
This is an amazing module, but I'm absolutely confused by the examples and the reference. Please do not take my following comments as hostile or critical - I have nothing but praise for what you're doing. What's confusing for me is this: the module does a fabulous job when the automation is turned on...but I'm having a very hard time grasping how to do the behavior without automation.

In a nutshell, what I'm trying to do is make draggable GUIs to create a fake desktop. However, I only want to target a specific handful of game GUIs, not all of them. If I have DragDrop.AutoTrackHookKey set to true in my script, every game GUI is draggable in the way that I expect...except, this works with every GUI in the game, not just some of them.

I've tried to follow the examples and use a little scripting to get it to work, but I'm stuck. Here's what I've managed to do so far:

Global Script:
Code: Adventure Game Studio
  1.  
  2. function dragWindow(GUI* Window) { // This is wrong
  3.   if (DragDrop.HookKeyDown()){
  4.     DragDrop.HookObject(1, mouse.x, mouse.y, Window.ID);
  5.   }
  6.   else if (DragDrop.HookKeyUp())
  7.     DragDrop.Drop();{
  8.   }
  9. }
  10.  
  11.  
  12. function checkGUI() // running under repeatedly_execute_always{
  13.   if (GUI.GetAtScreenXY(mouse.x, mouse.y)) {
  14.     hoverOver = GUI.GetAtScreenXY(mouse.x, mouse.y);
  15.       if ((hoverOver == gConfirmation)) {
  16.         dragWindow(hoverOver);
  17.       }
  18.   }
  19.   else {
  20.     hoverOver = null;
  21.   }
  22. }
  23.  
  24.  
  25.  
  26. function game_start()
  27. {
  28.   Mouse.Mode = eModePointer;
  29.   DragDrop.Enabled = true;
  30.   DragDropCommon.ModeEnabled[eDragDropGUI] = true;
  31.   DragDropCommon.DragMove = eDDCmnMoveSelf;
  32.   DragDrop.AutoTrackHookKey = false;
  33.   DragDrop.DefaultHookKey = 0;
  34.   DragDrop.DefaultHookMouseButton = eMouseLeft;
  35.   DragDrop.DragMinDistance = 10;
  36.   DragDrop.DragMinTime = 0;
  37. }
  38.  
  39.  


I've tried a few different variations for my dragGUI function. If I include the DragDrop.Drop() call, dragging doesn't work at all. If I omit it, the window instead just sticks to my cursor the minute I hover over it.
I've tried going over your code examples and post a couple of times, but I'm feeling pretty lost. What's the proper order of operations for hooking a GUI, dragging it, and dropping it?


I guess what's also confusing involves figuring out how to register when the player is holding down the mouse button and dragging the mouse. Is HookKeyDown supposed to be called from within on_mouse_click / on_key_press and nowhere else?
« Last Edit: 07 Jan 2022, 11:56 by deadsuperhero »
Check out my game: Life is a Party!

The fediverse needs great indie game developers! Find me there!

deadsuperhero

  • There's no sense crying over spilled tears.
    • I can help with backgrounds
    • I can help with characters
    • I can help with making music
    • I can help with scripting
I ended up doing a dirty hack for the time being, but I hope to sit down and adapt it properly at some point. :)

Code: Adventure Game Studio
  1. function checkGUI() {
  2.   if (GUI.GetAtScreenXY(mouse.x, mouse.y)) {
  3.     hoverOver = GUI.GetAtScreenXY(mouse.x, mouse.y);
  4.       if ((hoverOver == gExplorer)) {
  5.         DragDrop.AutoTrackHookKey = true;
  6.       }
  7.       else if ((hoverOver == gDetails)) {
  8.         DragDrop.AutoTrackHookKey = true;
  9.       }
  10.       else if ((hoverOver == gResume)) {
  11.         DragDrop.AutoTrackHookKey = true;
  12.       }
  13.       else if ((hoverOver == gConfirmation)) {
  14.        DragDrop.AutoTrackHookKey = true;
  15.       }
  16.       else if ((hoverOver == gDropdown)) {
  17.        DragDrop.AutoTrackHookKey = false;
  18.       }
  19.       else if ((hoverOver == gMainMenu)) {
  20.        DragDrop.AutoTrackHookKey = false;
  21.       }
  22.   }
  23.   else {
  24.     hoverOver = null;
  25.     DragDrop.AutoTrackHookKey = false;
  26.   }
  27. }
  28.  

Hacky, but it works for now.
Check out my game: Life is a Party!

The fediverse needs great indie game developers! Find me there!

I'm sorry, I did not have time to look into this yet, and I definitely should have written a better documentation.

I ended up doing a dirty hack for the time being, but I hope to sit down and adapt it properly at some point. :)

Just as a note, you may use switch for simplier code:
Code: Adventure Game Studio
  1. switch (hoverOver)
  2. {
  3. case gDetails:
  4. case gResume:
  5. // etc
  6.     DragDrop.AutoTrackHookKey = true;
  7.     break;
  8. default:
  9.     DragDrop.AutoTrackHookKey = false;
  10.     break;
  11. }
  12.  
« Last Edit: 08 Jan 2022, 07:11 by Crimson Wizard »

deadsuperhero

  • There's no sense crying over spilled tears.
    • I can help with backgrounds
    • I can help with characters
    • I can help with making music
    • I can help with scripting
I'm sorry, I did not have time to look into this yet, and I definitely should have written a better documentation.
Hey, it's totally okay - again, I appreciate what you've made, and am getting great use out of it!

That switch example is nice - I didn't even know about those!
Check out my game: Life is a Party!

The fediverse needs great indie game developers! Find me there!