aboutsummaryrefslogtreecommitdiff
path: root/engines/dm/eventman.cpp
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/dm/eventman.cpp
parent3ca7622a6ca4563f7c906013d59f9213a55f4c1b (diff)
downloadscummvm-rg350-ad8fbaa118e26cb57d3d77ddb7a597c2b37a9f76.tar.gz
scummvm-rg350-ad8fbaa118e26cb57d3d77ddb7a597c2b37a9f76.tar.bz2
scummvm-rg350-ad8fbaa118e26cb57d3d77ddb7a597c2b37a9f76.zip
DM: Add event manager
Diffstat (limited to 'engines/dm/eventman.cpp')
-rw-r--r--engines/dm/eventman.cpp68
1 files changed, 68 insertions, 0 deletions
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;
+ }
+ }
+}