diff options
-rw-r--r-- | backends/events/sdl/sdl-events.cpp | 6 | ||||
-rw-r--r-- | common/events.h | 13 | ||||
-rw-r--r-- | gui/dialog.cpp | 6 | ||||
-rw-r--r-- | gui/dialog.h | 4 | ||||
-rw-r--r-- | gui/gui-manager.cpp | 2 | ||||
-rw-r--r-- | gui/launcher.cpp | 7 | ||||
-rw-r--r-- | gui/launcher.h | 1 |
7 files changed, 23 insertions, 16 deletions
diff --git a/backends/events/sdl/sdl-events.cpp b/backends/events/sdl/sdl-events.cpp index ff5f4b9ce3..404528ba25 100644 --- a/backends/events/sdl/sdl-events.cpp +++ b/backends/events/sdl/sdl-events.cpp @@ -640,6 +640,12 @@ bool SdlEventSource::dispatchSDLEvent(SDL_Event &ev, Common::Event &event) { case SDL_JOYDEVICEREMOVED: return handleJoystickRemoved(ev.jdevice); + + case SDL_DROPFILE: + event.type = Common::EVENT_DROP_FILE; + event.path = Common::String(ev.drop.file); + SDL_free(ev.drop.file); + return true; #else case SDL_VIDEOEXPOSE: if (_graphicsManager) diff --git a/common/events.h b/common/events.h index a514ea291e..4b35725225 100644 --- a/common/events.h +++ b/common/events.h @@ -72,21 +72,21 @@ enum EventType { * use events to ask for the save game dialog or to pause the engine. * An associated enumerated type can accomplish this. **/ - EVENT_PREDICTIVE_DIALOG = 12 + EVENT_PREDICTIVE_DIALOG = 12, #ifdef ENABLE_KEYMAPPER - , // IMPORTANT NOTE: This is part of the WIP Keymapper. If you plan to use // this, please talk to tsoliman and/or LordHoto. EVENT_CUSTOM_BACKEND_ACTION = 18, EVENT_CUSTOM_BACKEND_HARDWARE = 21, EVENT_GUI_REMAP_COMPLETE_ACTION = 22, - EVENT_KEYMAPPER_REMAP = 19 + EVENT_KEYMAPPER_REMAP = 19, #endif #ifdef ENABLE_VKEYBD - , - EVENT_VIRTUAL_KEYBOARD = 20 + EVENT_VIRTUAL_KEYBOARD = 20, #endif + + EVENT_DROP_FILE = 23 }; typedef uint32 CustomEventType; @@ -127,6 +127,9 @@ struct Event { CustomEventType customType; #endif + /* The path of the file or directory dragged to the ScummVM window */ + Common::String path; + Event() : type(EVENT_INVALID), kbdRepeat(false) { #ifdef ENABLE_KEYMAPPER customType = 0; diff --git a/gui/dialog.cpp b/gui/dialog.cpp index 560c29174a..781de330e2 100644 --- a/gui/dialog.cpp +++ b/gui/dialog.cpp @@ -21,10 +21,7 @@ */ #include "common/rect.h" - -#ifdef ENABLE_KEYMAPPER #include "common/events.h" -#endif #include "gui/gui-manager.h" #include "gui/dialog.h" @@ -359,9 +356,8 @@ void Dialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) { } } -#ifdef ENABLE_KEYMAPPER void Dialog::handleOtherEvent(Common::Event evt) { } -#endif + /* * Determine the widget at location (x,y) if any. Assumes the coordinates are * in the local coordinate system, i.e. relative to the top left of the dialog. diff --git a/gui/dialog.h b/gui/dialog.h index efa6f76e03..70b17910fa 100644 --- a/gui/dialog.h +++ b/gui/dialog.h @@ -30,11 +30,9 @@ #include "gui/object.h" #include "gui/ThemeEngine.h" -#ifdef ENABLE_KEYMAPPER namespace Common { struct Event; } -#endif namespace GUI { @@ -105,9 +103,7 @@ protected: virtual void handleKeyUp(Common::KeyState state); virtual void handleMouseMoved(int x, int y, int button); virtual void handleCommand(CommandSender *sender, uint32 cmd, uint32 data); -#ifdef ENABLE_KEYMAPPER virtual void handleOtherEvent(Common::Event evt); -#endif Widget *findWidget(int x, int y); // Find the widget at pos x,y if any Widget *findWidget(const char *name); diff --git a/gui/gui-manager.cpp b/gui/gui-manager.cpp index 5e27eb66ef..cff8e8c5cd 100644 --- a/gui/gui-manager.cpp +++ b/gui/gui-manager.cpp @@ -597,9 +597,7 @@ void GuiManager::processEvent(const Common::Event &event, Dialog *const activeDi screenChange(); break; default: - #ifdef ENABLE_KEYMAPPER activeDialog->handleOtherEvent(event); - #endif break; } } diff --git a/gui/launcher.cpp b/gui/launcher.cpp index fd65e37cdd..14e0e96a3b 100644 --- a/gui/launcher.cpp +++ b/gui/launcher.cpp @@ -528,6 +528,13 @@ void LauncherDialog::handleKeyUp(Common::KeyState state) { updateButtons(); } +void LauncherDialog::handleOtherEvent(Common::Event evt) { + Dialog::handleOtherEvent(evt); + if (evt.type == Common::EVENT_DROP_FILE) { + doGameDetection(evt.path); + } +} + bool LauncherDialog::doGameDetection(const Common::String &path) { // Allow user to add a new game to the list. // 2) try to auto detect which game is in the directory, if we cannot diff --git a/gui/launcher.h b/gui/launcher.h index 9f0a1c8e95..5bb386f9a0 100644 --- a/gui/launcher.h +++ b/gui/launcher.h @@ -51,6 +51,7 @@ public: virtual void handleKeyDown(Common::KeyState state); virtual void handleKeyUp(Common::KeyState state); + virtual void handleOtherEvent(Common::Event evt); bool doGameDetection(const Common::String &path); protected: EditTextWidget *_searchWidget; |