aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorBendegúz Nagy2016-06-15 10:41:33 +0200
committerBendegúz Nagy2016-08-26 23:02:22 +0200
commitad8fbaa118e26cb57d3d77ddb7a597c2b37a9f76 (patch)
treea93b53da2c994d2e2c9f7391c0b061fc9461322e /engines
parent3ca7622a6ca4563f7c906013d59f9213a55f4c1b (diff)
downloadscummvm-rg350-ad8fbaa118e26cb57d3d77ddb7a597c2b37a9f76.tar.gz
scummvm-rg350-ad8fbaa118e26cb57d3d77ddb7a597c2b37a9f76.tar.bz2
scummvm-rg350-ad8fbaa118e26cb57d3d77ddb7a597c2b37a9f76.zip
DM: Add event manager
Diffstat (limited to 'engines')
-rw-r--r--engines/dm/dm.cpp38
-rw-r--r--engines/dm/dm.h2
-rw-r--r--engines/dm/eventman.cpp68
-rw-r--r--engines/dm/eventman.h28
-rw-r--r--engines/dm/module.mk3
5 files changed, 105 insertions, 34 deletions
diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index 0aa4cb32b0..df6629c3f9 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -50,6 +50,7 @@ DMEngine::~DMEngine() {
delete _console;
delete _displayMan;
delete _dungeonMan;
+ delete _eventMan;
// clear debug channels
DebugMan.clearAllDebugChannels();
@@ -61,6 +62,7 @@ Common::Error DMEngine::run() {
_console = new Console(this);
_displayMan = new DisplayMan(this);
_dungeonMan = new DungeonMan(this);
+ _eventMan = new EventManager(this);
_displayMan->setUpScreens(320, 200);
@@ -77,40 +79,10 @@ Common::Error DMEngine::run() {
_displayMan->loadPalette(gPalCredits);
- CurrMapData &currMap = _dungeonMan->_currMap;
+ _eventMan->initMouse();
+
while (true) {
- Common::Event event;
- while (_system->getEventManager()->pollEvent(event)) {
- if (event.type == Common::EVENT_KEYDOWN && !event.synthetic)
- switch (event.kbd.keycode) {
- case Common::KEYCODE_w:
- _dungeonMan->mapCoordsAfterRelMovement(currMap.partyDir, 1, 0, currMap.partyPosX, currMap.partyPosY);
- break;
- case Common::KEYCODE_a:
- _dungeonMan->mapCoordsAfterRelMovement(currMap.partyDir, 0, -1, currMap.partyPosX, currMap.partyPosY);
- break;
- case Common::KEYCODE_s:
- _dungeonMan->mapCoordsAfterRelMovement(currMap.partyDir, -1, 0, currMap.partyPosX, currMap.partyPosY);
- break;
- case Common::KEYCODE_d:
- _dungeonMan->mapCoordsAfterRelMovement(currMap.partyDir, 0, 1, currMap.partyPosX, currMap.partyPosY);
- break;
- case Common::KEYCODE_q:
- turnDirLeft(currMap.partyDir);
- break;
- case Common::KEYCODE_e:
- turnDirRight(currMap.partyDir);
- break;
- case Common::KEYCODE_UP:
- if (dummyMapIndex < 13)
- _dungeonMan->setCurrentMapAndPartyMap(++dummyMapIndex);
- break;
- case Common::KEYCODE_DOWN:
- if (dummyMapIndex > 0)
- _dungeonMan->setCurrentMapAndPartyMap(--dummyMapIndex);
- break;
- }
- }
+ _eventMan->processInput();
_displayMan->clearScreen(kColorBlack);
_displayMan->drawDungeon(_dungeonMan->_currMap.partyDir, _dungeonMan->_currMap.partyPosX, _dungeonMan->_currMap.partyPosY);
_displayMan->updateScreen();
diff --git a/engines/dm/dm.h b/engines/dm/dm.h
index 817c3ece28..b77f2cce44 100644
--- a/engines/dm/dm.h
+++ b/engines/dm/dm.h
@@ -4,6 +4,7 @@
#include "common/random.h"
#include "engines/engine.h"
#include "gui/debugger.h"
+#include "eventman.h"
namespace DM {
@@ -87,6 +88,7 @@ public:
Common::RandomSource *_rnd;
DisplayMan *_displayMan;
DungeonMan *_dungeonMan;
+ EventManager *_eventMan;
};
class Console : public GUI::Debugger {
diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
new file mode 100644
index 0000000000..44ea32795f
--- /dev/null
+++ b/engines/dm/eventman.cpp
@@ -0,0 +1,68 @@
+#include "eventman.h"
+#include "dm.h"
+#include "common/system.h"
+#include "dungeonman.h"
+
+
+
+using namespace DM;
+
+
+EventManager::EventManager(DMEngine *vm) : _vm(vm) {}
+
+
+void EventManager::initMouse() {
+ _mousePos = Common::Point(0, 0);
+ _dummyMapIndex = 0;
+ // TODO: add cursor creatin, set to hidden
+}
+
+void showMouse(bool visibility) {
+ // TODO: add code
+}
+
+void EventManager::setMousePos(Common::Point pos) {
+ _vm->_system->warpMouse(pos.x, pos.y);
+}
+
+
+void EventManager::processInput() {
+ DungeonMan &dungeonMan = *_vm->_dungeonMan;
+ CurrMapData &currMap = dungeonMan._currMap;
+
+ Common::Event event;
+ while (_vm->_system->getEventManager()->pollEvent(event)) {
+ if (event.type == Common::EVENT_KEYDOWN && !event.synthetic) {
+ switch (event.kbd.keycode) {
+ case Common::KEYCODE_w:
+ dungeonMan.mapCoordsAfterRelMovement(dungeonMan._currMap.partyDir, 1, 0, currMap.partyPosX, currMap.partyPosY);
+ break;
+ case Common::KEYCODE_a:
+ dungeonMan.mapCoordsAfterRelMovement(dungeonMan._currMap.partyDir, 0, -1, currMap.partyPosX, currMap.partyPosY);
+ break;
+ case Common::KEYCODE_s:
+ dungeonMan.mapCoordsAfterRelMovement(dungeonMan._currMap.partyDir, -1, 0, currMap.partyPosX, currMap.partyPosY);
+ break;
+ case Common::KEYCODE_d:
+ dungeonMan.mapCoordsAfterRelMovement(dungeonMan._currMap.partyDir, 0, 1, currMap.partyPosX, currMap.partyPosY);
+ break;
+ case Common::KEYCODE_q:
+ turnDirLeft(currMap.partyDir);
+ break;
+ case Common::KEYCODE_e:
+ turnDirRight(currMap.partyDir);
+ break;
+ case Common::KEYCODE_UP:
+ if (_dummyMapIndex < 13)
+ dungeonMan.setCurrentMapAndPartyMap(++_dummyMapIndex);
+ break;
+ case Common::KEYCODE_DOWN:
+ if (_dummyMapIndex > 0)
+ dungeonMan.setCurrentMapAndPartyMap(--_dummyMapIndex);
+ break;
+ }
+ } else if (event.type == Common::EVENT_MOUSEMOVE) {
+ _mousePos = event.mouse;
+ }
+ }
+}
diff --git a/engines/dm/eventman.h b/engines/dm/eventman.h
new file mode 100644
index 0000000000..eabff49a2b
--- /dev/null
+++ b/engines/dm/eventman.h
@@ -0,0 +1,28 @@
+
+
+#ifndef DM_EVENTMAN_H
+#define DM_EVENTMAN_H
+
+#include "common/events.h"
+
+namespace DM {
+
+class DMEngine;
+
+class EventManager {
+ DMEngine *_vm;
+
+ Common::Point _mousePos;
+ uint16 _dummyMapIndex;
+public:
+ EventManager(DMEngine *vm);
+ void initMouse();
+
+ void setMousePos(Common::Point pos);
+ void processInput();
+};
+
+};
+
+
+#endif DM_EVENTMAN_H
diff --git a/engines/dm/module.mk b/engines/dm/module.mk
index ca425c5ffb..3078fa54ab 100644
--- a/engines/dm/module.mk
+++ b/engines/dm/module.mk
@@ -4,7 +4,8 @@ MODULE_OBJS := \
detection.o \
dm.o \
gfx.o \
- dungeonman.o
+ dungeonman.o \
+ eventman.o
MODULE_DIRS += \
engines/dm