PETKA: moved handling events to QSystem

This commit is contained in:
Andrei Prykhodko 2020-05-29 10:39:57 +03:00
parent b1e83d068a
commit 5473724684
3 changed files with 20 additions and 13 deletions

View File

@ -102,20 +102,8 @@ Common::Error PetkaEngine::run() {
case Common::EVENT_QUIT:
case Common::EVENT_RETURN_TO_LAUNCHER:
return Common::kNoError;
case Common::EVENT_MOUSEMOVE:
_qsystem->_currInterface->onMouseMove(event.mouse);
break;
case Common::EVENT_LBUTTONDOWN:
_qsystem->_currInterface->onLeftButtonDown(event.mouse);
break;
case Common::EVENT_LBUTTONUP:
break;
case Common::EVENT_RBUTTONDOWN:
_qsystem->_currInterface->onRightButtonDown(event.mouse);
break;
case Common::EVENT_KEYDOWN:
break;
default:
_qsystem->onEvent(event);
break;
}
}

View File

@ -302,4 +302,20 @@ QObjectStar *QSystem::getStar() const {
return (QObjectStar *)_allObjects.back();
}
void QSystem::onEvent(const Common::Event &event) {
switch (event.type) {
case Common::EVENT_MOUSEMOVE:
_currInterface->onMouseMove(event.mouse);
break;
case Common::EVENT_LBUTTONDOWN:
_currInterface->onLeftButtonDown(event.mouse);
break;
case Common::EVENT_RBUTTONDOWN:
_currInterface->onRightButtonDown(event.mouse);
break;
default:
break;
}
}
}

View File

@ -24,6 +24,7 @@
#define PETKA_Q_SYSTEM_H
#include "common/ptr.h"
#include "common/events.h"
#include "common/stream.h"
#include "common/list.h"
#include "common/hashmap.h"
@ -76,6 +77,8 @@ public:
void setChapayev();
void onEvent(const Common::Event &event);
public:
Common::Array<QMessageObject *> _allObjects;
Common::List<QMessage> _messages;