CGE: Remove hack used to store keycode in CGEEvent

This commit is contained in:
Strangerke 2012-07-04 23:18:29 +02:00
parent 112f03390d
commit b1cc34a080
7 changed files with 23 additions and 18 deletions

View File

@ -518,8 +518,8 @@ Square::Square(CGEEngine *vm) : Sprite(vm, NULL), _vm(vm) {
setShapeList(MB);
}
void Square::touch(uint16 mask, int x, int y) {
Sprite::touch(mask, x, y);
void Square::touch(uint16 mask, int x, int y, Common::KeyCode keyCode) {
Sprite::touch(mask, x, y, keyCode);
if (mask & kMouseLeftUp) {
_vm->XZ(_x + x, _y + y).cell() = 0;
_vm->_commandHandlerTurbo->addCommand(kCmdKill, -1, 0, this);
@ -758,11 +758,11 @@ void System::funTouch() {
_funDel = n;
}
void System::touch(uint16 mask, int x, int y) {
void System::touch(uint16 mask, int x, int y, Common::KeyCode keyCode) {
funTouch();
if (mask & kEventKeyb) {
if (x == Common::KEYCODE_ESCAPE) {
if (keyCode == Common::KEYCODE_ESCAPE) {
// The original was calling keyClick()
// The sound is uselessly annoying and noisy, so it has been removed
_vm->killText();
@ -926,7 +926,7 @@ void CGEEngine::optionTouch(int opt, uint16 mask) {
}
#pragma argsused
void Sprite::touch(uint16 mask, int x, int y) {
void Sprite::touch(uint16 mask, int x, int y, Common::KeyCode keyCode) {
_vm->_sys->funTouch();
if ((mask & kEventAttn) != 0)

View File

@ -92,7 +92,7 @@ public:
void setPal();
void funTouch();
virtual void touch(uint16 mask, int x, int y);
virtual void touch(uint16 mask, int x, int y, Common::KeyCode keyCode);
void tick();
private:
CGEEngine *_vm;
@ -101,7 +101,7 @@ private:
class Square : public Sprite {
public:
Square(CGEEngine *vm);
virtual void touch(uint16 mask, int x, int y);
virtual void touch(uint16 mask, int x, int y, Common::KeyCode keyCode);
private:
CGEEngine *_vm;
};

View File

@ -135,9 +135,11 @@ void Keyboard::newKeyboard(Common::Event &event) {
if ((event.type == Common::EVENT_KEYDOWN) && (_client)) {
CGEEvent &evt = _vm->_eventManager->getNextEvent();
evt._x = event.kbd.keycode; // Keycode
evt._mask = kEventKeyb; // Event mask
evt._spritePtr = _client; // Sprite pointer
evt._x = 0;
evt._y = 0;
evt._keyCode = event.kbd.keycode; // Keycode
evt._mask = kEventKeyb; // Event mask
evt._spritePtr = _client; // Sprite pointer
}
}
@ -204,6 +206,7 @@ void Mouse::newMouse(Common::Event &event) {
CGEEvent &evt = _vm->_eventManager->getNextEvent();
evt._x = event.mouse.x;
evt._y = event.mouse.y;
evt._keyCode = Common::KEYCODE_INVALID;
evt._spritePtr = _vm->spriteAt(evt._x, evt._y);
switch (event.type) {
@ -269,7 +272,7 @@ void EventManager::handleEvents() {
CGEEvent e = _eventQueue[_eventQueueTail];
if (e._mask) {
if (_vm->_mouse->_hold && e._spritePtr != _vm->_mouse->_hold)
_vm->_mouse->_hold->touch(e._mask | kEventAttn, e._x - _vm->_mouse->_hold->_x, e._y - _vm->_mouse->_hold->_y);
_vm->_mouse->_hold->touch(e._mask | kEventAttn, e._x - _vm->_mouse->_hold->_x, e._y - _vm->_mouse->_hold->_y, e._keyCode);
// update mouse cursor position
if (e._mask & kMouseRoll)
@ -278,11 +281,11 @@ void EventManager::handleEvents() {
// activate current touched SPRITE
if (e._spritePtr) {
if (e._mask & kEventKeyb)
e._spritePtr->touch(e._mask, e._x, e._y);
e._spritePtr->touch(e._mask, e._x, e._y, e._keyCode);
else
e._spritePtr->touch(e._mask, e._x - e._spritePtr->_x, e._y - e._spritePtr->_y);
e._spritePtr->touch(e._mask, e._x - e._spritePtr->_x, e._y - e._spritePtr->_y, e._keyCode);
} else if (_vm->_sys)
_vm->_sys->touch(e._mask, e._x, e._y);
_vm->_sys->touch(e._mask, e._x, e._y, e._keyCode);
if (e._mask & kMouseLeftDown) {
_vm->_mouse->_hold = e._spritePtr;

View File

@ -70,6 +70,7 @@ struct CGEEvent {
uint16 _mask;
uint16 _x;
uint16 _y;
Common::KeyCode _keyCode;
Sprite *_spritePtr;
};

View File

@ -29,6 +29,7 @@
#define CGE_VGA13H_H
#include "common/serializer.h"
#include "common/events.h"
#include "graphics/surface.h"
#include "cge/general.h"
#include "cge/bitmap.h"
@ -146,7 +147,7 @@ public:
void step(int nr = -1);
Seq *setSeq(Seq *seq);
CommandHandler::Command *snList(SnList type);
virtual void touch(uint16 mask, int x, int y);
virtual void touch(uint16 mask, int x, int y, Common::KeyCode keyCode);
virtual void tick();
void sync(Common::Serializer &s);
private:

View File

@ -89,11 +89,11 @@ Vmenu::~Vmenu() {
#define CALL_MEMBER_FN(object,ptrToMember) ((object).*(ptrToMember))
void Vmenu::touch(uint16 mask, int x, int y) {
void Vmenu::touch(uint16 mask, int x, int y, Common::KeyCode keyCode) {
if (!_items)
return;
Sprite::touch(mask, x, y);
Sprite::touch(mask, x, y, keyCode);
y -= kTextVMargin - 1;
int n = 0;

View File

@ -58,7 +58,7 @@ public:
MenuBar *_bar;
Vmenu(CGEEngine *vm, Choice *list, int x, int y);
~Vmenu();
virtual void touch(uint16 mask, int x, int y);
virtual void touch(uint16 mask, int x, int y, Common::KeyCode keyCode);
private:
char *_vmgt;
CGEEngine *_vm;