GUI: Support adding games via Drag and Drop
This commit is contained in:
parent
fb26f21d04
commit
d7b2b1b8f9
7 changed files with 23 additions and 16 deletions
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue