X-Git-Url: https://git.artsoft.org/?p=rocksndiamonds.git;a=blobdiff_plain;f=src%2Fevents.c;h=90f6615a20f61ee0647a61f58f03b0b586d17791;hp=7b2ba984732b8fa857478f9bfc44d26d9259d041;hb=f11d2545f41637e871283f7624dccc8243d05138;hpb=0c08866e0fd391ec7e01562ad2ea3b5645ebfc13 diff --git a/src/events.c b/src/events.c index 7b2ba984..90f6615a 100644 --- a/src/events.c +++ b/src/events.c @@ -268,8 +268,12 @@ void HandleOtherEvents(Event *event) HandleJoystickEvent(event); break; - case SDL_SYSWMEVENT: - HandleWindowManagerEvent(event); + case SDL_DROPFILE: + HandleDropFileEvent(event); + break; + + case SDL_DROPTEXT: + HandleDropTextEvent(event); break; default: @@ -1522,9 +1526,43 @@ void HandleClientMessageEvent(ClientMessageEvent *event) CloseAllAndExit(0); } -void HandleWindowManagerEvent(Event *event) +static void HandleDropFileEventExt(char *filename) { - SDLHandleWindowManagerEvent(event); + Error(ERR_DEBUG, "DROP FILE EVENT: '%s'", filename); + + // check and extract dropped zip files into correct user data directory + if (strSuffixLower(filename, ".zip")) + { + int tree_type = GetZipFileTreeType(filename); + char *directory = TREE_USERDIR(tree_type); + + if (directory == NULL) + { + Error(ERR_WARN, "zip file '%s' has invalid content!", filename); + + return; + } + + ExtractZipFileIntoDirectory(filename, directory, tree_type); +} + +static void HandleDropTextEventExt(char *text) +{ + Error(ERR_DEBUG, "DROP TEXT EVENT: '%s'", text); +} + +void HandleDropFileEvent(Event *event) +{ + HandleDropFileEventExt(event->drop.file); + + SDL_free(event->drop.file); +} + +void HandleDropTextEvent(Event *event) +{ + HandleDropTextEventExt(event->drop.file); + + SDL_free(event->drop.file); } void HandleButton(int mx, int my, int button, int button_nr)