Jump to content


Photo

GM DragAcceptFiles Extension - Open Source


  • Please log in to reply
14 replies to this topic

#1 Master Xilo

Master Xilo

    GMC Member

  • GMC Member
  • 396 posts
  • Version:GM8

Posted 21 July 2011 - 10:06 PM

The Game Maker window doesn't accept files or folders to be dropped onto it - the mouse cursor turns into a stop sign if you try. That means people using your application always have to navigate through an open file dialog and search their file to go on working on their latest creation - a map, a picture, whatever - made with your program.
Professional applications allow dropping one file after the other, or even multiple files together onto the program window to quickly switch the file you're working on.
If you're like me, you always have an explorer window with the files you currently work on open anyways. Its much more annoying to navigate through a dialog, copy pasting the path of that folder than being able to simply drag n' drop the next file.
One of the Game Maker's strengths is its easy to learn drag and drop programmability. Why should dragging and dropping with Game Maker stop there?

Well it doesn't anymore! This GM DragAcceptFiles Extension (name inspired by the WinApi command of the same name) instantly enables the Game Maker window to receive files dropped onto it - without writing a single line of code for this.

It then provides just three functions necessary for reading back the paths of the files and folders dropped:
 

  • daf_get_file_count() Returns the amount of files that have been dropped on the window since the last call to daf_clear_files() or since the game has been started.
  • daf_get_file(index) Returns the full path of the indexth file dragged and dropped on the window. index should be between 0 and daf_get_file_count()-1, otherwise an empty string is returned.
  • daf_clear_files() This last command is used to clear the list of dropped files.

Download
The following package includes the extension (coming with a help included), a .gm81 example (+ compiled version), the .ged source file and all the other source files used in the creation of this extension:


  • The help .html, .css, .hpp (Microsoft HTML Help Workshop Project file) and compiled .chm files.
  • The tiny gml function internally used for initialization.
  • The whole MS Visual Studio 2010 Project of the dll, ready to be changed and recompiled.

Download the GM DragAcceptFiles Extension, including source files and example
 


This extension doesn't only serve as an extension by itself - by coming with all source files, this is also meant to be an example for people new to the wonderful world of Game Maker extension creation. Honestly, I've never seen an easier way to extend a game engine/programming environment. Setting up new libraries in C++ on MSVC is really annoying so people won't do it for small libs or to just recompile something they would have liked to play with a little. Instead of using these hard to set up libraries, many people reinvent the wheel over and over.

I'll be happy to answer any questions regarding the source code and to help with any problems that might occur during recompilation (à la "Where can I find the ... program?").

More Usage Examples
Screenshot of the included demo:

myshuppainting111622014.png


To show the name of the last file dropped in a message box put the following code in the step event of any object:

if (daf_get_file_count() > 0)
{
show_message(daf_get_file(daf_get_file_count() - 1));
daf_clear_files();
}


I hope you like it!

- Paul

Alternatives
Existing dlls (do you know of any more? any extensions? any open source ones?) doing (pretty much) the same:

Tags
game maker drag and drop files Onto Gm Window, drag-and-drop, d&d, winapi, wrapper, game maker drop files, game maker drop, game maker drag


Edited by Master Xilo, 23 August 2015 - 02:10 PM.

  • 7

#2 IceMetalPunk

IceMetalPunk

    InfiniteIMPerfection

  • GMC Elder
  • 9603 posts
  • Version:GM:Studio

Posted 21 July 2011 - 10:34 PM

Well, this is useful, but I'm going to ask here something I asked in the last Drag-and-Drop DLL's topic: is there a way to reverse the process and let us drag-and-drop things from the GM window into another program or Explorer?

-IMP ;) :)
  • 0

:GM123: Are you an artist who likes creating original creature designs? Maybe you can help out with Elementa here! Give it a look; you might like the idea :)

:bunny: :excl: :bunny: :excl: :bunny: :excl: :bunny: :excl: :bunny: :excl: :bunny: :excl: :bunny: :excl: :bunny: :excl: :bunny: :excl: :bunny:


#3 Master Xilo

Master Xilo

    GMC Member

  • GMC Member
  • 396 posts
  • Version:GM8

Posted 21 July 2011 - 10:50 PM

Thanks for the reply.

There is a way to drag from an application
  • http://www.codeproject.com/KB/shell/explorerdragdrop.aspx
  • http://msdn.microsoft.com/en-us/library/bb776905%28v=vs.85%29.aspx
  • http://msdn.microsoft.com/en-us/library/ms678486%28VS.85%29.aspx
  • http://www.codeproject.com/kb/tips/ExplorerDelayDrop.aspx
  • http://www.catch22.net/tuts/dragdrop/1
I think I could make that possible with Game Maker too.

Edited by Master Xilo, 22 July 2011 - 04:39 PM.

  • 0

#4 IceMetalPunk

IceMetalPunk

    InfiniteIMPerfection

  • GMC Elder
  • 9603 posts
  • Version:GM:Studio

Posted 21 July 2011 - 11:47 PM

I think I could make that possible with Game Maker too.

That would be great, and I would love you forever :D .

-IMP ;) :)
  • 0

:GM123: Are you an artist who likes creating original creature designs? Maybe you can help out with Elementa here! Give it a look; you might like the idea :)

:bunny: :excl: :bunny: :excl: :bunny: :excl: :bunny: :excl: :bunny: :excl: :bunny: :excl: :bunny: :excl: :bunny: :excl: :bunny: :excl: :bunny:


#5 Master Xilo

Master Xilo

    GMC Member

  • GMC Member
  • 396 posts
  • Version:GM8

Posted 22 July 2011 - 08:33 PM

OK, I got it. I'll make this a new extension, featuring file and text data drag and drop + clipboard operations to and away from the Game Maker window. It'll also be possible to differentiate between copying and moving when dragging.

Edited by Master Xilo, 22 July 2011 - 08:36 PM.

  • 0

#6 slam drago

slam drago

    The slam drag

  • New Member
  • 422 posts
  • Version:GM:Studio

Posted 29 August 2011 - 09:32 PM

Does this work in XP? I used one DragnDrop DLL and it crashed my computer.
EDIT: W00T it works!!!!! :)

Edited by slam drago, 30 August 2011 - 12:47 AM.

  • 0
My newest website. Check it out!
I support Cryset Games. Make money playing and making games!
(\__/)
(='.'=) This is Bunny. Copy and paste Bunny into your
(")_(") signature to help him gain world domination.
My avatar is best viewed in the lighter GMC theme.

#7 DefuzionGames

DefuzionGames

    GMC Member

  • GMC Member
  • 1460 posts
  • Version:Unknown

Posted 27 January 2012 - 01:02 AM

AVG found a virus on the dll this extension uses called Win32/Heri

Can you please reupload a virus free one?
  • 0

#8 Master Xilo

Master Xilo

    GMC Member

  • GMC Member
  • 396 posts
  • Version:GM8

Posted 27 January 2012 - 09:27 AM

Thanks for reporting this. This is of course a false-positive.

Maybe it doesn't like that I left out the DOS stub header in the dll file (The part with "This program cannot be run in DOS mode") - AntiVir didn't like that either so I switched to MSSE and just started to compile everything without this header as it reduces filesize a bit.

I have recompiled it without this removed (same download link). Please tell me whether it still complains now.

Edited by Master Xilo, 27 January 2012 - 09:58 AM.

  • 0

#9 DefuzionGames

DefuzionGames

    GMC Member

  • GMC Member
  • 1460 posts
  • Version:Unknown

Posted 27 January 2012 - 01:56 PM

is it possible to modify this so that you can drag and drop text aswell. For example say you highlight some text on a web browser and then drag that onto the gm window. Thanks
  • 0

#10 Master Xilo

Master Xilo

    GMC Member

  • GMC Member
  • 396 posts
  • Version:GM8

Posted 27 January 2012 - 10:31 PM

I have been working on a more advanced version of this which allows dropping files and text into the GM window and even drag these types of media out of the gamemaker window into another application (see my posts above), however WINAPI/Com doesn't seem to like the way I use it, there are still too much bugs/unexpected behaviour. I'll look into that.
  • 0

#11 SenJe0

SenJe0

    GMC Member

  • GMC Member
  • 733 posts

Posted 27 July 2012 - 01:01 PM

I have been working on a more advanced version of this which allows dropping files and text into the GM window and even drag these types of media out of the gamemaker window into another application (see my posts above), however WINAPI/Com doesn't seem to like the way I use it, there are still too much bugs/unexpected behaviour. I'll look into that.

Would love to see this done. Please do it. Thanks.
  • 0
When I finish University, I would like to work for a BIG software Company like;SENJEN COMPANY. I'm obsessed with them! Period!

#12 Master Xilo

Master Xilo

    GMC Member

  • GMC Member
  • 396 posts
  • Version:GM8

Posted 27 July 2012 - 04:07 PM

Done.
http://gmc.yoyogames...howtopic=548635
  • 0

#13 AlienEaters

AlienEaters

    Met Programmer

  • GMC Member
  • 168 posts
  • Version:GM:Studio

Posted 29 April 2013 - 02:49 AM

You make some very cool stuff. I used parmeter_string to get files before.


  • 0
Elodin - "Where does the moon go when it leaves the sky?"

#14 Ruub

Ruub

    Finn The Human

  • GMC Member
  • 762 posts
  • Version:GM:Studio

Posted 26 August 2013 - 09:34 PM

seems amazing! The demo works, but I can't look into the example. I'm going to try and work it out tomorrow, but if you happen to catch this, could you upload a gm8 version or a gm:s version?

 

<3 

 

edit: Got it working in GM:S, but sprite_add is pretty much 'disabled', so it has no use for me :/ still nice thou


Edited by Ruub, 12 September 2013 - 04:42 PM.

  • 0

#15 aaron13ps

aaron13ps

    GMC Member

  • GMC Member
  • 28 posts
  • Version:GM:Studio

Posted 27 November 2015 - 12:17 AM

I guess you no longer give this out? The download link goes to nothing in particular. Unless its hidden between the lines, I cant download it. This might be because its 2 years old? Is there an updated version of this? (For Studio)?


Edited by aaron13ps, 27 November 2015 - 12:18 AM.

  • 0