Jump to content


Photo

GM DragAcceptFiles Extension - Open Source


  • Please log in to reply
12 replies to this topic

#1 Master Xilo

Master Xilo

    GMC Member

  • GMC Member
  • 379 posts
  • Version:GM8

Posted 21 July 2011 - 09:52 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
hotlink-hosted on Dropbox,stats, d


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:

Posted Image


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, 16 July 2012 - 02:17 PM.

  • 3

#2 IceMetalPunk

IceMetalPunk

    InfiniteIMPerfection

  • Retired Staff
  • 9259 posts
  • Version:Unknown

Posted 21 July 2011 - 10:20 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

#3 Master Xilo

Master Xilo

    GMC Member

  • GMC Member
  • 379 posts
  • Version:GM8

Posted 21 July 2011 - 10:36 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:25 PM.

  • 0

#4 IceMetalPunk

IceMetalPunk

    InfiniteIMPerfection

  • Retired Staff
  • 9259 posts
  • Version:Unknown

Posted 21 July 2011 - 11:33 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

#5 Master Xilo

Master Xilo

    GMC Member

  • GMC Member
  • 379 posts
  • Version:GM8

Posted 22 July 2011 - 08:19 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:22 PM.

  • 0

#6 slam drago

slam drago

    The slam drag

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

Posted 29 August 2011 - 09:18 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:33 AM.

  • 0

#7 DefuzionGames

DefuzionGames

    GMC Member

  • GMC Member
  • 1417 posts
  • Version:Unknown

Posted 27 January 2012 - 12:48 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
  • 379 posts
  • Version:GM8

Posted 27 January 2012 - 09:13 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:44 AM.

  • 0

#9 DefuzionGames

DefuzionGames

    GMC Member

  • GMC Member
  • 1417 posts
  • Version:Unknown

Posted 27 January 2012 - 01:42 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
  • 379 posts
  • Version:GM8

Posted 27 January 2012 - 10:17 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 - 12:47 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

#12 Master Xilo

Master Xilo

    GMC Member

  • GMC Member
  • 379 posts
  • Version:GM8

Posted 27 July 2012 - 03:53 PM

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

#13 AlienEaters

AlienEaters

    GMC Member

  • New Member
  • 6 posts
  • Version:GM8.1

Posted 29 April 2013 - 02:35 AM

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


  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users