From b1cc34a080ff31fb22ab466624a99c0cdaeb51c1 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 4 Jul 2012 23:18:29 +0200 Subject: CGE: Remove hack used to store keycode in CGEEvent --- engines/cge/cge_main.cpp | 10 +++++----- engines/cge/cge_main.h | 4 ++-- engines/cge/events.cpp | 17 ++++++++++------- engines/cge/events.h | 1 + engines/cge/vga13h.h | 3 ++- engines/cge/vmenu.cpp | 4 ++-- engines/cge/vmenu.h | 2 +- 7 files changed, 23 insertions(+), 18 deletions(-) (limited to 'engines/cge') diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index fbe37e58a0..a70e32de7e 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -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) diff --git a/engines/cge/cge_main.h b/engines/cge/cge_main.h index b98fec531d..bde8306f36 100644 --- a/engines/cge/cge_main.h +++ b/engines/cge/cge_main.h @@ -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; }; diff --git a/engines/cge/events.cpp b/engines/cge/events.cpp index 98a39a947b..1530c870ef 100644 --- a/engines/cge/events.cpp +++ b/engines/cge/events.cpp @@ -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; diff --git a/engines/cge/events.h b/engines/cge/events.h index 6bbd52e4a5..522aa67905 100644 --- a/engines/cge/events.h +++ b/engines/cge/events.h @@ -70,6 +70,7 @@ struct CGEEvent { uint16 _mask; uint16 _x; uint16 _y; + Common::KeyCode _keyCode; Sprite *_spritePtr; }; diff --git a/engines/cge/vga13h.h b/engines/cge/vga13h.h index beca19f667..a816f7756f 100644 --- a/engines/cge/vga13h.h +++ b/engines/cge/vga13h.h @@ -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: diff --git a/engines/cge/vmenu.cpp b/engines/cge/vmenu.cpp index a317a765d4..84b557f4a6 100644 --- a/engines/cge/vmenu.cpp +++ b/engines/cge/vmenu.cpp @@ -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; diff --git a/engines/cge/vmenu.h b/engines/cge/vmenu.h index 89ef7a9484..928b48f11c 100644 --- a/engines/cge/vmenu.h +++ b/engines/cge/vmenu.h @@ -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; -- cgit v1.2.3 From 14a59b97b289416bc124985e7b5f3b45d8e7a7e0 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 4 Jul 2012 23:36:11 +0200 Subject: CGE: Silent some CppCheck warnings --- engines/cge/bitmap.cpp | 3 +++ engines/cge/vmenu.cpp | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'engines/cge') diff --git a/engines/cge/bitmap.cpp b/engines/cge/bitmap.cpp index 309b89bdda..4f85957b3d 100644 --- a/engines/cge/bitmap.cpp +++ b/engines/cge/bitmap.cpp @@ -123,12 +123,15 @@ Bitmap::~Bitmap() { Bitmap &Bitmap::operator=(const Bitmap &bmp) { debugC(1, kCGEDebugBitmap, "&Bitmap::operator ="); + if (this == &bmp) + return *this; uint8 *v0 = bmp._v; _w = bmp._w; _h = bmp._h; _m = NULL; _map = 0; + _vm = bmp._vm; delete[] _v; if (v0 == NULL) { diff --git a/engines/cge/vmenu.cpp b/engines/cge/vmenu.cpp index 84b557f4a6..910e54d267 100644 --- a/engines/cge/vmenu.cpp +++ b/engines/cge/vmenu.cpp @@ -63,7 +63,7 @@ Vmenu *Vmenu::_addr = NULL; int Vmenu::_recent = -1; Vmenu::Vmenu(CGEEngine *vm, Choice *list, int x, int y) - : Talk(vm, VMGather(list), kTBRect), _menu(list), _bar(NULL), _vm(vm) { + : Talk(vm, VMGather(list), kTBRect), _menu(list), _bar(NULL), _vmgt(NULL), _vm(vm) { Choice *cp; _addr = this; -- cgit v1.2.3