diff options
author | Simei Yin | 2017-07-20 19:08:53 +0200 |
---|---|---|
committer | Simei Yin | 2017-07-20 19:10:01 +0200 |
commit | 0fb4a1ddd228cdcedb1313aa8df6ac2b9ba97530 (patch) | |
tree | 874c73d908c3a61e63845124125cecdaf71a81b8 | |
parent | caa51ef49af5f6e92169a2f8095c08325823cb44 (diff) | |
download | scummvm-rg350-0fb4a1ddd228cdcedb1313aa8df6ac2b9ba97530.tar.gz scummvm-rg350-0fb4a1ddd228cdcedb1313aa8df6ac2b9ba97530.tar.bz2 scummvm-rg350-0fb4a1ddd228cdcedb1313aa8df6ac2b9ba97530.zip |
SLUDGE: Objectify input and event handler
-rw-r--r-- | engines/sludge/backdrop.cpp | 19 | ||||
-rw-r--r-- | engines/sludge/builtin.cpp | 26 | ||||
-rw-r--r-- | engines/sludge/cursors.cpp | 9 | ||||
-rw-r--r-- | engines/sludge/event.cpp | 355 | ||||
-rw-r--r-- | engines/sludge/event.h | 90 | ||||
-rw-r--r-- | engines/sludge/freeze.cpp | 37 | ||||
-rw-r--r-- | engines/sludge/freeze.h | 3 | ||||
-rw-r--r-- | engines/sludge/graphics.cpp | 11 | ||||
-rw-r--r-- | engines/sludge/graphics.h | 2 | ||||
-rw-r--r-- | engines/sludge/loadsave.cpp | 5 | ||||
-rw-r--r-- | engines/sludge/main_loop.cpp | 100 | ||||
-rw-r--r-- | engines/sludge/module.mk | 1 | ||||
-rw-r--r-- | engines/sludge/movie.cpp | 7 | ||||
-rw-r--r-- | engines/sludge/region.cpp | 10 | ||||
-rw-r--r-- | engines/sludge/region.h | 2 | ||||
-rw-r--r-- | engines/sludge/sludge.cpp | 4 | ||||
-rw-r--r-- | engines/sludge/sludge.h | 2 | ||||
-rw-r--r-- | engines/sludge/sludger.cpp | 221 | ||||
-rw-r--r-- | engines/sludge/sludger.h | 18 | ||||
-rw-r--r-- | engines/sludge/sprites.cpp | 9 |
20 files changed, 527 insertions, 404 deletions
diff --git a/engines/sludge/backdrop.cpp b/engines/sludge/backdrop.cpp index e9f0c2296f..9bc2a56be7 100644 --- a/engines/sludge/backdrop.cpp +++ b/engines/sludge/backdrop.cpp @@ -28,24 +28,23 @@ #include "graphics/palette.h" #include "sludge/allfiles.h" -#include "sludge/newfatal.h" +#include "sludge/backdrop.h" +#include "sludge/event.h" #include "sludge/fileset.h" #include "sludge/graphics.h" -#include "sludge/backdrop.h" +#include "sludge/imgloader.h" #include "sludge/moreio.h" +#include "sludge/newfatal.h" #include "sludge/statusba.h" -#include "sludge/talk.h" #include "sludge/zbuffer.h" #include "sludge/sludge.h" #include "sludge/sludger.h" +#include "sludge/talk.h" #include "sludge/variable.h" #include "sludge/version.h" -#include "sludge/imgloader.h" namespace Sludge { -extern InputType input; - Parallax::Parallax() { _parallaxLayers.clear(); } @@ -219,11 +218,11 @@ void GraphicsManager::killLightMap() { bool GraphicsManager::reserveBackdrop() { _cameraX = 0; _cameraY = 0; - input.mouseX = (int)((float)input.mouseX * _cameraZoom); - input.mouseY = (int)((float)input.mouseY * _cameraZoom); + _vm->_evtMan->mouseX() = (int)((float)_vm->_evtMan->mouseX() * _cameraZoom); + _vm->_evtMan->mouseY() = (int)((float)_vm->_evtMan->mouseY() * _cameraZoom); _cameraZoom = 1.0; - input.mouseX = (int)((float)input.mouseX / _cameraZoom); - input.mouseY = (int)((float)input.mouseY / _cameraZoom); + _vm->_evtMan->mouseX() = (int)((float)_vm->_evtMan->mouseX() / _cameraZoom); + _vm->_evtMan->mouseY() = (int)((float)_vm->_evtMan->mouseY() / _cameraZoom); return true; } diff --git a/engines/sludge/builtin.cpp b/engines/sludge/builtin.cpp index fe327f4070..d88ecb31db 100644 --- a/engines/sludge/builtin.cpp +++ b/engines/sludge/builtin.cpp @@ -51,6 +51,7 @@ #include "sludge/sludge.h" #include "sludge/utf8.h" #include "sludge/graphics.h" +#include "sludge/event.h" namespace Sludge { @@ -63,7 +64,6 @@ extern int lastFramesPerSecond, thumbWidth, thumbHeight; extern bool allowAnyFilename; extern bool captureAllKeys; extern int16 fontSpace; -extern EventHandlers *currentEvents; extern VariableStack *noStack; extern StatusStuff *nowStatus; extern ScreenRegion *overRegion; @@ -71,7 +71,6 @@ extern int numBIFNames, numUserFunc; extern Common::String *allUserFunc; extern Common::String *allBIFNames; -extern InputType input; extern float speechSpeed; extern byte brightnessLevel; @@ -135,6 +134,7 @@ struct builtInFunctionData { #define builtIn(a) static BuiltReturn builtIn_ ## a (int numParams, LoadedFunction *fun) #define UNUSEDALL (void) (0 && sizeof(numParams) && sizeof (fun)); + static BuiltReturn sayCore(int numParams, LoadedFunction *fun, bool sayIt) { int fileNum = -1; Common::String newText; @@ -209,25 +209,25 @@ builtIn(setCursor) { builtIn(getMouseX) { UNUSEDALL - setVariable(fun->reg, SVT_INT, input.mouseX + g_sludge->_gfxMan->getCamX()); + setVariable(fun->reg, SVT_INT, g_sludge->_evtMan->mouseX() + g_sludge->_gfxMan->getCamX()); return BR_CONTINUE; } builtIn(getMouseY) { UNUSEDALL - setVariable(fun->reg, SVT_INT, input.mouseY + g_sludge->_gfxMan->getCamY()); + setVariable(fun->reg, SVT_INT, g_sludge->_evtMan->mouseY() + g_sludge->_gfxMan->getCamY()); return BR_CONTINUE; } builtIn(getMouseScreenX) { UNUSEDALL - setVariable(fun->reg, SVT_INT, input.mouseX * g_sludge->_gfxMan->getCamZoom()); + setVariable(fun->reg, SVT_INT, g_sludge->_evtMan->mouseX() * g_sludge->_gfxMan->getCamZoom()); return BR_CONTINUE; } builtIn(getMouseScreenY) { UNUSEDALL - setVariable(fun->reg, SVT_INT, input.mouseY * g_sludge->_gfxMan->getCamZoom()); + setVariable(fun->reg, SVT_INT, g_sludge->_evtMan->mouseY() * g_sludge->_gfxMan->getCamZoom()); return BR_CONTINUE; } @@ -1839,7 +1839,7 @@ builtIn(onLeftMouse) { UNUSEDALL int functionNum; if (getFuncNumForCallback(numParams, fun, functionNum)) { - currentEvents->leftMouseFunction = functionNum; + g_sludge->_evtMan->setEventFunction(kLeftMouse, functionNum); return BR_CONTINUE; } return BR_ERROR; @@ -1849,7 +1849,7 @@ builtIn(onLeftMouseUp) { UNUSEDALL int functionNum; if (getFuncNumForCallback(numParams, fun, functionNum)) { - currentEvents->leftMouseUpFunction = functionNum; + g_sludge->_evtMan->setEventFunction(kLeftMouseUp, functionNum); return BR_CONTINUE; } return BR_ERROR; @@ -1859,7 +1859,7 @@ builtIn(onRightMouse) { UNUSEDALL int functionNum; if (getFuncNumForCallback(numParams, fun, functionNum)) { - currentEvents->rightMouseFunction = functionNum; + g_sludge->_evtMan->setEventFunction(kRightMouse, functionNum); return BR_CONTINUE; } return BR_ERROR; @@ -1869,7 +1869,7 @@ builtIn(onRightMouseUp) { UNUSEDALL int functionNum; if (getFuncNumForCallback(numParams, fun, functionNum)) { - currentEvents->rightMouseUpFunction = functionNum; + g_sludge->_evtMan->setEventFunction(kRightMouseUp, functionNum); return BR_CONTINUE; } return BR_ERROR; @@ -1879,7 +1879,7 @@ builtIn(onFocusChange) { UNUSEDALL int functionNum; if (getFuncNumForCallback(numParams, fun, functionNum)) { - currentEvents->focusFunction = functionNum; + g_sludge->_evtMan->setEventFunction(kFocus, functionNum); return BR_CONTINUE; } return BR_ERROR; @@ -1889,7 +1889,7 @@ builtIn(onMoveMouse) { UNUSEDALL int functionNum; if (getFuncNumForCallback(numParams, fun, functionNum)) { - currentEvents->moveMouseFunction = functionNum; + g_sludge->_evtMan->setEventFunction(kMoveMouse, functionNum); return BR_CONTINUE; } return BR_ERROR; @@ -1899,7 +1899,7 @@ builtIn(onKeyboard) { UNUSEDALL int functionNum; if (getFuncNumForCallback(numParams, fun, functionNum)) { - currentEvents->spaceFunction = functionNum; + g_sludge->_evtMan->setEventFunction(kSpace, functionNum); return BR_CONTINUE; } return BR_ERROR; diff --git a/engines/sludge/cursors.cpp b/engines/sludge/cursors.cpp index 1960844646..87a2bf7179 100644 --- a/engines/sludge/cursors.cpp +++ b/engines/sludge/cursors.cpp @@ -22,10 +22,11 @@ #include "sludge/allfiles.h" #include "sludge/cursors.h" +#include "sludge/event.h" #include "sludge/graphics.h" +#include "sludge/people.h" #include "sludge/sprites.h" #include "sludge/sprbanks.h" -#include "sludge/people.h" #include "sludge/sludge.h" #include "sludge/sludger.h" @@ -35,8 +36,6 @@ PersonaAnimation *mouseCursorAnim; int mouseCursorFrameNum = 0; int mouseCursorCountUp = 0; -extern InputType input; - void pickAnimCursor(PersonaAnimation *pp) { deleteAnim(mouseCursorAnim); mouseCursorAnim = pp; @@ -63,12 +62,12 @@ void displayCursor() { if (flipMe != 2) { if (flipMe) { g_sludge->_gfxMan->flipFontSprite( - input.mouseX, input.mouseY, + g_sludge->_evtMan->mouseX(), g_sludge->_evtMan->mouseY(), mouseCursorAnim->theSprites->bank.sprites[spriteNum], mouseCursorAnim->theSprites->bank.myPalette /* ( spritePalette&) NULL*/); } else { g_sludge->_gfxMan->fontSprite( - input.mouseX, input.mouseY, + g_sludge->_evtMan->mouseX(), g_sludge->_evtMan->mouseY(), mouseCursorAnim->theSprites->bank.sprites[spriteNum], mouseCursorAnim->theSprites->bank.myPalette /* ( spritePalette&) NULL*/); } diff --git a/engines/sludge/event.cpp b/engines/sludge/event.cpp new file mode 100644 index 0000000000..5ab237b3c8 --- /dev/null +++ b/engines/sludge/event.cpp @@ -0,0 +1,355 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "common/events.h" +#include "common/keyboard.h" + +#include "sludge/event.h" +#include "sludge/freeze.h" +#include "sludge/graphics.h" +#include "sludge/newfatal.h" +#include "sludge/region.h" +#include "sludge/sludge.h" +#include "sludge/sludger.h" +#include "sludge/variable.h" + +namespace Sludge { + +extern Variable *launchResult; +extern VariableStack *noStack; +extern ScreenRegion *overRegion; +extern ScreenRegion *lastRegion; + +EventManager::EventManager(SludgeEngine *vm) { + _vm = vm; + + _weAreDoneSoQuit = 0; + + + for (uint i = 0; i < EVENT_FUNC_NB; ++i) { + _mainHandlers.func[i] = 0; + } + _currentEvents = &_mainHandlers; +} + +EventManager::~EventManager() { + +} + +void EventManager::checkInput() { + float cameraZoom = _vm->_gfxMan->getCamZoom(); +#if 0 + static bool fakeRightclick = false; +#endif + Common::Event event; + + /* Check for events */ + while (g_system->getEventManager()->pollEvent(event)) { + switch (event.type) { +#if 0 + case SDL_VIDEORESIZE: + realWinWidth = event.resize.w; + realWinHeight = event.resize.h; + setGraphicsWindow(false, true, true); + break; +#endif + case Common::EVENT_MOUSEMOVE: + _input.justMoved = true; + _input.mouseX = event.mouse.x * cameraZoom; + _input.mouseY = event.mouse.y * cameraZoom; + break; + + case Common::EVENT_LBUTTONDOWN: + _input.leftClick = true; + _input.mouseX = event.mouse.x * cameraZoom; + _input.mouseY = event.mouse.y * cameraZoom; +#if 0 + if (SDL_GetModState() & KMOD_CTRL) { + input.rightClick = true; + fakeRightclick = true; + } else { + input.leftClick = true; + fakeRightclick = false; + } +#endif + break; + + case Common::EVENT_RBUTTONDOWN: + _input.rightClick = true; + _input.mouseX = event.mouse.x * cameraZoom; + _input.mouseY = event.mouse.y * cameraZoom; + break; + + case Common::EVENT_LBUTTONUP: + _input.leftRelease = true; + _input.mouseX = event.mouse.x * cameraZoom; + _input.mouseY = event.mouse.y * cameraZoom; + break; + + case Common::EVENT_RBUTTONUP: + _input.rightRelease = true; + _input.mouseX = event.mouse.x * cameraZoom; + _input.mouseY = event.mouse.y * cameraZoom; + break; + + case Common::EVENT_KEYDOWN: + switch (event.kbd.keycode) { + + case Common::KEYCODE_BACKSPACE: + // fall through + case Common::KEYCODE_DELETE: + _input.keyPressed = Common::KEYCODE_DELETE; + break; + default: + _input.keyPressed = event.kbd.keycode; + break; + } + break; + + case Common::EVENT_QUIT: + _weAreDoneSoQuit = 1; + // TODO: if reallyWantToQuit, popup a message box to confirm + break; + + default: + break; + } + } +} + +bool EventManager::handleInput() { + static int l = 0; + + if (!g_sludge->launchMe.empty()) { + if (l) { + // Still paused because of spawned thingy... + } else { + l = 1; + + setVariable(*launchResult, SVT_INT, 0/*launch(launchMe) > 31*/); //TODO:false value + g_sludge->launchMe.clear(); + launchResult = nullptr; + } + return true; + } else { + l = 0; + } + + if (!overRegion) + getOverRegion(); + + if (_input.justMoved) { + if (_currentEvents->func[kMoveMouse]) { + if (!startNewFunctionNum(_currentEvents->func[kMoveMouse], 0, nullptr, noStack)) + return false; + } + } + _input.justMoved = false; + + if (lastRegion != overRegion && _currentEvents->func[kFocus]) { + VariableStack *tempStack = new VariableStack; + if (!checkNew(tempStack)) + return false; + + initVarNew(tempStack->thisVar); + if (overRegion) { + setVariable(tempStack->thisVar, SVT_OBJTYPE, overRegion->thisType->objectNum); + } else { + setVariable(tempStack->thisVar, SVT_INT, 0); + } + tempStack->next = nullptr; + if (!startNewFunctionNum(_currentEvents->func[kFocus], 1, nullptr, tempStack)) + return false; + } + if (_input.leftRelease && _currentEvents->func[kLeftMouseUp]) { + if (!startNewFunctionNum(_currentEvents->func[kLeftMouseUp], 0, nullptr, noStack)) + return false; + } + if (_input.rightRelease && _currentEvents->func[kRightMouseUp]) { + if (!startNewFunctionNum(_currentEvents->func[kRightMouseUp], 0, nullptr, noStack)) + return false; + } + if (_input.leftClick && _currentEvents->func[kLeftMouse]) + if (!startNewFunctionNum(_currentEvents->func[kLeftMouse], 0, nullptr, noStack)) + return false; + if (_input.rightClick && _currentEvents->func[kRightMouse]) { + if (!startNewFunctionNum(_currentEvents->func[kRightMouse], 0, nullptr, noStack)) + return false; + } + if (_input.keyPressed && _currentEvents->func[kSpace]) { + Common::String tempString = ""; + switch (_input.keyPressed) { + case 127: + tempString = "BACKSPACE"; + break; + case 9: + tempString = "TAB"; + break; + case 13: + tempString = "ENTER"; + break; + case 27: + tempString = "ESCAPE"; + break; + /* + case 1112: tempString = copyString ("ALT+F1"); break; + case 1113: tempString = copyString ("ALT+F2"); break; + case 1114: tempString = copyString ("ALT+F3"); break; + case 1115: tempString = copyString ("ALT+F4"); break; + case 1116: tempString = copyString ("ALT+F5"); break; + case 1117: tempString = copyString ("ALT+F6"); break; + case 1118: tempString = copyString ("ALT+F7"); break; + case 1119: tempString = copyString ("ALT+F8"); break; + case 1120: tempString = copyString ("ALT+F9"); break; + case 1121: tempString = copyString ("ALT+F10"); break; + case 1122: tempString = copyString ("ALT+F11"); break; + case 1123: tempString = copyString ("ALT+F12"); break; + + case 2019: tempString = copyString ("PAUSE"); break; + */ + case 63276: + tempString = "PAGE UP"; + break; + case 63277: + tempString = "PAGE DOWN"; + break; + case 63275: + tempString = "END"; + break; + case 63273: + tempString = "HOME"; + break; + case 63234: + tempString = "LEFT"; + break; + case 63232: + tempString = "UP"; + break; + case 63235: + tempString = "RIGHT"; + break; + case 63233: + tempString = "DOWN"; + break; + /* + case 2045: tempString = copyString ("INSERT"); break; + case 2046: tempString = copyString ("DELETE"); break; + */ + case 63236: + tempString = "F1"; + break; + case 63237: + tempString = "F2"; + break; + case 63238: + tempString = "F3"; + break; + case 63239: + tempString = "F4"; + break; + case 63240: + tempString = "F5"; + break; + case 63241: + tempString = "F6"; + break; + case 63242: + tempString = "F7"; + break; + case 63243: + tempString = "F8"; + break; + case 63244: + tempString = "F9"; + break; + case 63245: + tempString = "F10"; + break; + case 63246: + tempString = "F11"; + break; + case 63247: + tempString = "F12"; + break; + + default: + if (_input.keyPressed >= 256) { + char tmp[7] = "ABCDEF"; + sprintf(tmp, "%i", _input.keyPressed); + tempString = tmp; + //} + } else { + char tmp[2] = " "; + tmp[0] = _input.keyPressed; + tempString = tmp; + } + } + + if (!tempString.empty()) { + VariableStack *tempStack = new VariableStack; + if (!checkNew(tempStack)) + return false; + initVarNew(tempStack->thisVar); + makeTextVar(tempStack->thisVar, tempString); + tempStack->next = nullptr; + if (!startNewFunctionNum(_currentEvents->func[kSpace], 1, nullptr, tempStack)) + return false; + } + } + _input.rightClick = false; + _input.leftClick = false; + _input.rightRelease = false; + _input.leftRelease = false; + _input.keyPressed = 0; + lastRegion = overRegion; + return true; +} + +void EventManager::loadHandlers(Common::SeekableReadStream *stream) { + for (uint i = 0; i < EVENT_FUNC_NB; ++i) { + _currentEvents->func[i] = stream->readUint16BE(); + } +} + +void EventManager::saveHandlers(Common::WriteStream *stream) { + for (uint i = 0; i < EVENT_FUNC_NB; ++i) { + stream->writeUint16BE(_currentEvents->func[i]); + } +} + +bool EventManager::freeze(FrozenStuffStruct *frozenStuff) { + frozenStuff->currentEvents = _currentEvents; + _currentEvents = new EventHandlers; + if (!checkNew(_currentEvents)) + return false; + for (uint i = 0; i < EVENT_FUNC_NB; ++i) { + _currentEvents->func[i] = 0; + } + return true; +} + +void EventManager::restore(FrozenStuffStruct *frozenStuff) { + delete _currentEvents; + _currentEvents = frozenStuff->currentEvents; +} + +} /* namespace Sludge */ diff --git a/engines/sludge/event.h b/engines/sludge/event.h new file mode 100644 index 0000000000..e85752987b --- /dev/null +++ b/engines/sludge/event.h @@ -0,0 +1,90 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef SLUDGE_EVENT_H +#define SLUDGE_EVENT_H + +#include "common/stream.h" + +namespace Sludge { + +struct FrozenStuffStruct; + +struct InputType { + bool leftClick, rightClick, justMoved, leftRelease, rightRelease; + int mouseX, mouseY, keyPressed; +}; + +enum EventFunctions { + kLeftMouse, + kLeftMouseUp, + kRightMouse, + kRightMouseUp, + kMoveMouse, + kFocus, + kSpace, + EVENT_FUNC_NB +}; + +struct EventHandlers { + int func[EVENT_FUNC_NB]; +}; + +class SludgeEngine; + +class EventManager { +public: + EventManager(SludgeEngine *vm); + virtual ~EventManager(); + + // Input + void checkInput(); + bool handleInput(); + + int mouseX() const { return _input.mouseX; } + int mouseY() const { return _input.mouseY; } + int &mouseX() { return _input.mouseX; } + int &mouseY() { return _input.mouseY; } + + // Events + void setEventFunction(EventFunctions event, int funcNum) { _currentEvents->func[event] = funcNum; } ; + void loadHandlers(Common::SeekableReadStream *stream); + void saveHandlers(Common::WriteStream *stream); + bool freeze(FrozenStuffStruct *frozenStuff); + void restore(FrozenStuffStruct *frozenStuff); + + // Quit + bool quit() { return _weAreDoneSoQuit; } + +private: + SludgeEngine *_vm; + InputType _input; + + int _weAreDoneSoQuit; + + EventHandlers _mainHandlers; + EventHandlers *_currentEvents; +}; + +} /* namespace Sludge */ + +#endif /* ENGINES_SLUDGE_EVENT_H_ */ diff --git a/engines/sludge/freeze.cpp b/engines/sludge/freeze.cpp index 776a6f80a8..1bc2ad96f7 100644 --- a/engines/sludge/freeze.cpp +++ b/engines/sludge/freeze.cpp @@ -20,20 +20,21 @@ * */ #include "sludge/allfiles.h" +#include "sludge/backdrop.h" +#include "sludge/event.h" +#include "sludge/fonttext.h" +#include "sludge/freeze.h" +#include "sludge/graphics.h" #include "sludge/newfatal.h" +#include "sludge/objtypes.h" +#include "sludge/people.h" +#include "sludge/region.h" #include "sludge/sprites.h" #include "sludge/sprbanks.h" -#include "sludge/people.h" #include "sludge/sludge.h" #include "sludge/sludger.h" -#include "sludge/objtypes.h" -#include "sludge/region.h" -#include "sludge/backdrop.h" -#include "sludge/talk.h" -#include "sludge/fonttext.h" #include "sludge/statusba.h" -#include "sludge/freeze.h" -#include "sludge/graphics.h" +#include "sludge/talk.h" #include "sludge/zbuffer.h" namespace Sludge { @@ -42,8 +43,6 @@ extern OnScreenPerson *allPeople; extern ScreenRegion *allScreenRegions; extern ScreenRegion *overRegion; extern SpeechStruct *speech; -extern InputType input; -extern EventHandlers *currentEvents; extern PersonaAnimation *mouseCursorAnim; extern int mouseCursorFrameNum; @@ -109,11 +108,7 @@ bool GraphicsManager::freeze() { newFreezer->speech = speech; initSpeech(); - newFreezer->currentEvents = currentEvents; - currentEvents = new EventHandlers; - if (!checkNew(currentEvents)) - return false; - memset(currentEvents, 0, sizeof(EventHandlers)); + _vm->_evtMan->freeze(newFreezer); newFreezer->next = _frozenStuff; _frozenStuff = newFreezer; @@ -142,11 +137,11 @@ void GraphicsManager::unfreeze(bool killImage) { _cameraX = _frozenStuff->cameraX; _cameraY = _frozenStuff->cameraY; - input.mouseX = (int)(input.mouseX * _cameraZoom); - input.mouseY = (int)(input.mouseY * _cameraZoom); + _vm->_evtMan->mouseX() = (int)(_vm->_evtMan->mouseX() * _cameraZoom); + _vm->_evtMan->mouseY() = (int)(_vm->_evtMan->mouseY() * _cameraZoom); _cameraZoom = _frozenStuff->cameraZoom; - input.mouseX = (int)(input.mouseX / _cameraZoom); - input.mouseY = (int)(input.mouseY / _cameraZoom); + _vm->_evtMan->mouseX() = (int)(_vm->_evtMan->mouseX() / _cameraZoom); + _vm->_evtMan->mouseY() = (int)(_vm->_evtMan->mouseY() / _cameraZoom); killAllPeople(); allPeople = _frozenStuff->allPeople; @@ -184,8 +179,8 @@ void GraphicsManager::unfreeze(bool killImage) { restoreBarStuff(_frozenStuff->frozenStatus); - delete currentEvents; - currentEvents = _frozenStuff->currentEvents; + _vm->_evtMan->restore(_frozenStuff); + killAllSpeech(); delete speech; diff --git a/engines/sludge/freeze.h b/engines/sludge/freeze.h index 7373d02613..830c2d8a72 100644 --- a/engines/sludge/freeze.h +++ b/engines/sludge/freeze.h @@ -27,11 +27,14 @@ namespace Sludge { struct OnScreenPerson; +struct PersonaAnimation; struct ScreenRegion; struct SpeechStruct; struct StatusStuff ; struct EventHandlers; +class Parallax; + struct FrozenStuffStruct { OnScreenPerson *allPeople; ScreenRegion *allScreenRegions; diff --git a/engines/sludge/graphics.cpp b/engines/sludge/graphics.cpp index d2d8e9d954..626c8a20c7 100644 --- a/engines/sludge/graphics.cpp +++ b/engines/sludge/graphics.cpp @@ -23,6 +23,7 @@ #include "engines/util.h" #include "sludge/backdrop.h" +#include "sludge/event.h" #include "sludge/freeze.h" #include "sludge/graphics.h" #include "sludge/newfatal.h" @@ -33,8 +34,6 @@ namespace Sludge { -extern InputType input; - GraphicsManager::GraphicsManager(SludgeEngine *vm) { _vm = vm; @@ -172,8 +171,8 @@ void GraphicsManager::aimCamera(int cameraX, int cameraY) { } void GraphicsManager::zoomCamera(int z) { - input.mouseX = input.mouseX * _cameraZoom; - input.mouseY = input.mouseY * _cameraZoom; + _vm->_evtMan->mouseX() = _vm->_evtMan->mouseX() * _cameraZoom; + _vm->_evtMan->mouseY() = _vm->_evtMan->mouseY() * _cameraZoom; _cameraZoom = (float)z * 0.01; if ((float)_winWidth / _cameraZoom > _sceneWidth) @@ -181,8 +180,8 @@ void GraphicsManager::zoomCamera(int z) { if ((float)_winHeight / _cameraZoom > _sceneHeight) _cameraZoom = (float)_winHeight / _sceneHeight; - input.mouseX = input.mouseX / _cameraZoom; - input.mouseY = input.mouseY / _cameraZoom; + _vm->_evtMan->mouseX() = _vm->_evtMan->mouseX() / _cameraZoom; + _vm->_evtMan->mouseY() = _vm->_evtMan->mouseY() / _cameraZoom; } void GraphicsManager::saveColors(Common::WriteStream *stream) { diff --git a/engines/sludge/graphics.h b/engines/sludge/graphics.h index 1914ea741e..69d1f5f4ed 100644 --- a/engines/sludge/graphics.h +++ b/engines/sludge/graphics.h @@ -23,6 +23,8 @@ #ifndef SLUDGE_GRAPHICS_H #define SLUDGE_GRAPHICS_H +#include "common/stream.h" + #include "graphics/surface.h" #include "graphics/transparent_surface.h" diff --git a/engines/sludge/loadsave.cpp b/engines/sludge/loadsave.cpp index 79dde932e3..8eb59fc3f8 100644 --- a/engines/sludge/loadsave.cpp +++ b/engines/sludge/loadsave.cpp @@ -24,6 +24,7 @@ #include "sludge/allfiles.h" #include "sludge/sprites.h" +#include "sludge/event.h" #include "sludge/fonttext.h" #include "sludge/newfatal.h" #include "sludge/variable.h" @@ -387,7 +388,7 @@ bool saveGame(const Common::String &fname) { g_sludge->_gfxMan->saveHSI(fp); // Save event handlers - saveHandlers(fp); + g_sludge->_evtMan->saveHandlers(fp); // Save regions saveRegions(fp); @@ -558,7 +559,7 @@ bool loadGame(const Common::String &fname) { brightnessLevel = fp->readByte(); g_sludge->_gfxMan->loadHSI(fp, 0, 0, true); - loadHandlers(fp); + g_sludge->_evtMan->loadHandlers(fp); loadRegions(fp); mouseCursorAnim = new PersonaAnimation ; diff --git a/engines/sludge/main_loop.cpp b/engines/sludge/main_loop.cpp index 1c5beb8ab5..a4851d76b9 100644 --- a/engines/sludge/main_loop.cpp +++ b/engines/sludge/main_loop.cpp @@ -22,13 +22,12 @@ #include "common/config-manager.h" #include "common/debug.h" -#include "common/events.h" -#include "common/keyboard.h" #include "graphics/surface.h" #include "sludge/allfiles.h" #include "sludge/backdrop.h" +#include "sludge/event.h" #include "sludge/floor.h" #include "sludge/graphics.h" #include "sludge/helpers.h" @@ -52,98 +51,10 @@ namespace Sludge { HWND hMainWindow = NULL; -int realWinWidth = 640, realWinHeight = 480; - -extern InputType input; extern VariableStack *noStack; int dialogValue = 0; -int weAreDoneSoQuit; - -void checkInput() { - int winWidth = g_system->getWidth(); - int winHeight = g_system->getHeight(); - float cameraZoom = g_sludge->_gfxMan->getCamZoom(); -#if 0 - static bool fakeRightclick = false; -#endif - Common::Event event; - - /* Check for events */ - while (g_system->getEventManager()->pollEvent(event)) { - switch (event.type) { -#if 0 - case SDL_VIDEORESIZE: - realWinWidth = event.resize.w; - realWinHeight = event.resize.h; - setGraphicsWindow(false, true, true); - break; -#endif - case Common::EVENT_MOUSEMOVE: - input.justMoved = true; - input.mouseX = event.mouse.x * ((float)winWidth / cameraZoom) / realWinWidth; - input.mouseY = event.mouse.y * ((float)winHeight / cameraZoom) / realWinHeight; - break; - - case Common::EVENT_LBUTTONDOWN: - input.leftClick = true; - input.mouseX = event.mouse.x * ((float)winWidth / cameraZoom) / realWinWidth; - input.mouseY = event.mouse.y * ((float)winHeight / cameraZoom) / realWinHeight; -#if 0 - if (SDL_GetModState() & KMOD_CTRL) { - input.rightClick = true; - fakeRightclick = true; - } else { - input.leftClick = true; - fakeRightclick = false; - } -#endif - break; - - case Common::EVENT_RBUTTONDOWN: - input.rightClick = true; - input.mouseX = event.mouse.x * ((float)winWidth / cameraZoom) / realWinWidth; - input.mouseY = event.mouse.y * ((float)winHeight / cameraZoom) / realWinHeight; - break; - - case Common::EVENT_LBUTTONUP: - input.leftRelease = true; - input.mouseX = event.mouse.x * ((float)winWidth / cameraZoom) / realWinWidth; - input.mouseY = event.mouse.y * ((float)winHeight / cameraZoom) / realWinHeight; - break; - - case Common::EVENT_RBUTTONUP: - input.rightRelease = true; - input.mouseX = event.mouse.x * ((float)winWidth / cameraZoom) / realWinWidth; - input.mouseY = event.mouse.y * ((float)winHeight / cameraZoom) / realWinHeight; - break; - - case Common::EVENT_KEYDOWN: - switch (event.kbd.keycode) { - - case Common::KEYCODE_BACKSPACE: - // fall through - case Common::KEYCODE_DELETE: - input.keyPressed = Common::KEYCODE_DELETE; - break; - default: - input.keyPressed = event.kbd.keycode; - break; - } - break; - - case Common::EVENT_QUIT: - weAreDoneSoQuit = 1; - // TODO: if reallyWantToQuit, popup a message box to confirm - break; - - default: - break; - } - } -} - int main_loop(const char *filename) { if (!initSludge(filename)) { @@ -173,11 +84,12 @@ int main_loop(const char *filename) { g_sludge->_timer.init(); - weAreDoneSoQuit = 0; - while (!weAreDoneSoQuit) { - checkInput(); + while (!g_sludge->_evtMan->quit()) { + g_sludge->_evtMan->checkInput(); walkAllPeople(); - handleInput(); + if (g_sludge->_evtMan->handleInput()) { + runSludge(); + } sludgeDisplay(); handleSoundLists(); g_sludge->_timer.waitFrame(); diff --git a/engines/sludge/module.mk b/engines/sludge/module.mk index ce45549990..4d05e826a5 100644 --- a/engines/sludge/module.mk +++ b/engines/sludge/module.mk @@ -7,6 +7,7 @@ MODULE_OBJS := \ console.o \ cursors.o \ detection.o \ + event.o \ fileset.o \ floor.o \ freeze.o \ diff --git a/engines/sludge/movie.cpp b/engines/sludge/movie.cpp index 66e338e980..0162a7086b 100644 --- a/engines/sludge/movie.cpp +++ b/engines/sludge/movie.cpp @@ -27,13 +27,6 @@ namespace Sludge { -// in main.c -int checkInput(); -extern int weAreDoneSoQuit; - -// Sludger.cpp -bool handleInput(); - // sound_openal.cpp void playMovieStream(int a); #if 0 diff --git a/engines/sludge/region.cpp b/engines/sludge/region.cpp index d7fba70d42..af9e2b8cac 100644 --- a/engines/sludge/region.cpp +++ b/engines/sludge/region.cpp @@ -22,6 +22,7 @@ #include "sludge/allfiles.h" #include "sludge/backdrop.h" +#include "sludge/event.h" #include "sludge/graphics.h" #include "sludge/moreio.h" #include "sludge/newfatal.h" @@ -34,7 +35,6 @@ namespace Sludge { ScreenRegion *allScreenRegions = NULL; ScreenRegion *overRegion = NULL; -extern InputType input; void showBoxes() { ScreenRegion*huntRegion = allScreenRegions; @@ -147,10 +147,10 @@ void getOverRegion() { int cameraY = g_sludge->_gfxMan->getCamY(); ScreenRegion *thisRegion = allScreenRegions; while (thisRegion) { - if ((input.mouseX >= thisRegion->x1 - cameraX) - && (input.mouseY >= thisRegion->y1 - cameraY) - && (input.mouseX <= thisRegion->x2 - cameraX) - && (input.mouseY <= thisRegion->y2 - cameraY)) { + if ((g_sludge->_evtMan->mouseX() >= thisRegion->x1 - cameraX) + && (g_sludge->_evtMan->mouseY() >= thisRegion->y1 - cameraY) + && (g_sludge->_evtMan->mouseX() <= thisRegion->x2 - cameraX) + && (g_sludge->_evtMan->mouseY() <= thisRegion->y2 - cameraY)) { overRegion = thisRegion; return; } diff --git a/engines/sludge/region.h b/engines/sludge/region.h index afbe80ef32..74294814f6 100644 --- a/engines/sludge/region.h +++ b/engines/sludge/region.h @@ -22,6 +22,8 @@ #ifndef SLUDGE_REGION_H #define SLUDGE_REGION_H +#include "sludge/objtypes.h" + namespace Sludge { struct ScreenRegion { diff --git a/engines/sludge/sludge.cpp b/engines/sludge/sludge.cpp index 10b9aa3c23..fef2ebf77d 100644 --- a/engines/sludge/sludge.cpp +++ b/engines/sludge/sludge.cpp @@ -25,6 +25,7 @@ #include "common/debug-channels.h" #include "common/error.h" +#include "sludge/event.h" #include "sludge/graphics.h" #include "sludge/sludge.h" #include "sludge/main_loop.h" @@ -67,6 +68,7 @@ SludgeEngine::SludgeEngine(OSystem *syst, const SludgeGameDescription *gameDesc) _languageMan = new LanguageManager(); _objMan = new ObjectManager(this); _gfxMan = new GraphicsManager(this); + _evtMan = new EventManager(this); } SludgeEngine::~SludgeEngine() { @@ -89,6 +91,8 @@ SludgeEngine::~SludgeEngine() { _pixelFormat = nullptr; // Dispose managers + delete _evtMan; + _evtMan = nullptr; delete _gfxMan; _gfxMan = nullptr; delete _objMan; diff --git a/engines/sludge/sludge.h b/engines/sludge/sludge.h index 78cf1dfc10..74d5c079f2 100644 --- a/engines/sludge/sludge.h +++ b/engines/sludge/sludge.h @@ -38,6 +38,7 @@ namespace Sludge { extern SludgeEngine *g_sludge; +class EventManager; class GraphicsManager; class SludgeConsole; @@ -74,6 +75,7 @@ public: LanguageManager *_languageMan; ObjectManager *_objMan; GraphicsManager *_gfxMan; + EventManager *_evtMan; SludgeEngine(OSystem *syst, const SludgeGameDescription *gameDesc); virtual ~SludgeEngine(); diff --git a/engines/sludge/sludger.cpp b/engines/sludge/sludger.cpp index 12d76b9924..b890c78893 100644 --- a/engines/sludge/sludger.cpp +++ b/engines/sludge/sludger.cpp @@ -71,18 +71,14 @@ bool captureAllKeys = false; byte brightnessLevel = 255; -EventHandlers mainHandlers; -EventHandlers *currentEvents = &mainHandlers; - -extern ScreenRegion *overRegion; extern SpeechStruct *speech; extern LoadedFunction *saverFunc; LoadedFunction *allRunningFunctions = NULL; ScreenRegion *lastRegion = NULL; VariableStack *noStack = NULL; -InputType input; Variable *globalVars; + int numGlobals; const char *sludgeText[] = { "?????", "RETURN", "BRANCH", "BR_ZERO", @@ -94,26 +90,6 @@ const char *sludgeText[] = { "?????", "RETURN", "BRANCH", "BR_ZERO", "INC_LOCAL", "DEC_LOCAL", "INC_GLOBAL", "DEC_GLOBAL", "INDEXSET", "INDEXGET", "INC_INDEX", "DEC_INDEX", "QUICK_PUSH" }; -void loadHandlers(Common::SeekableReadStream *stream) { - currentEvents->leftMouseFunction = stream->readUint16BE(); - currentEvents->leftMouseUpFunction = stream->readUint16BE(); - currentEvents->rightMouseFunction = stream->readUint16BE(); - currentEvents->rightMouseUpFunction = stream->readUint16BE(); - currentEvents->moveMouseFunction = stream->readUint16BE(); - currentEvents->focusFunction = stream->readUint16BE(); - currentEvents->spaceFunction = stream->readUint16BE(); -} - -void saveHandlers(Common::WriteStream *stream) { - stream->writeUint16BE(currentEvents->leftMouseFunction); - stream->writeUint16BE(currentEvents->leftMouseUpFunction); - stream->writeUint16BE(currentEvents->rightMouseFunction); - stream->writeUint16BE(currentEvents->rightMouseUpFunction); - stream->writeUint16BE(currentEvents->moveMouseFunction); - stream->writeUint16BE(currentEvents->focusFunction); - stream->writeUint16BE(currentEvents->spaceFunction); -} - Common::File *openAndVerify(const Common::String &filename, char extra1, char extra2, const char *er, int &fileVersion) { Common::File *fp = new Common::File(); @@ -1019,199 +995,4 @@ int startNewFunctionNum(uint funcNum, uint numParamsExpected, int lastFramesPerSecond = -1; int thisFramesPerSecond = -1; -bool handleInput() { - static int l = 0; - - if (!g_sludge->launchMe.empty()) { - if (l) { - // Still paused because of spawned thingy... - } else { - l = 1; - - setVariable(*launchResult, SVT_INT, 0/*launch(launchMe) > 31*/); //TODO:false value - g_sludge->launchMe.clear(); - launchResult = NULL; - } - return true; - } else { - l = 0; - } - - if (!overRegion) - getOverRegion(); - - if (input.justMoved) { - if (currentEvents->moveMouseFunction) { - if (!startNewFunctionNum(currentEvents->moveMouseFunction, 0, NULL, - noStack)) - return false; - } - } - input.justMoved = false; - - if (lastRegion != overRegion && currentEvents->focusFunction) { - VariableStack *tempStack = new VariableStack; - if (!checkNew(tempStack)) - return false; - - initVarNew(tempStack->thisVar); - if (overRegion) { - setVariable(tempStack->thisVar, SVT_OBJTYPE, - overRegion->thisType->objectNum); - } else { - setVariable(tempStack->thisVar, SVT_INT, 0); - } - tempStack->next = NULL; - if (!startNewFunctionNum(currentEvents->focusFunction, 1, NULL, - tempStack)) - return false; - } - if (input.leftRelease && currentEvents->leftMouseUpFunction) { - if (!startNewFunctionNum(currentEvents->leftMouseUpFunction, 0, NULL, - noStack)) - return false; - } - if (input.rightRelease && currentEvents->rightMouseUpFunction) { - if (!startNewFunctionNum(currentEvents->rightMouseUpFunction, 0, NULL, - noStack)) - return false; - } - if (input.leftClick && currentEvents->leftMouseFunction) - if (!startNewFunctionNum(currentEvents->leftMouseFunction, 0, NULL, - noStack)) - return false; - if (input.rightClick && currentEvents->rightMouseFunction) { - if (!startNewFunctionNum(currentEvents->rightMouseFunction, 0, NULL, - noStack)) - return false; - } - if (input.keyPressed && currentEvents->spaceFunction) { - Common::String tempString = ""; - switch (input.keyPressed) { - case 127: - tempString = "BACKSPACE"; - break; - case 9: - tempString = "TAB"; - break; - case 13: - tempString = "ENTER"; - break; - case 27: - tempString = "ESCAPE"; - break; - /* - case 1112: tempString = copyString ("ALT+F1"); break; - case 1113: tempString = copyString ("ALT+F2"); break; - case 1114: tempString = copyString ("ALT+F3"); break; - case 1115: tempString = copyString ("ALT+F4"); break; - case 1116: tempString = copyString ("ALT+F5"); break; - case 1117: tempString = copyString ("ALT+F6"); break; - case 1118: tempString = copyString ("ALT+F7"); break; - case 1119: tempString = copyString ("ALT+F8"); break; - case 1120: tempString = copyString ("ALT+F9"); break; - case 1121: tempString = copyString ("ALT+F10"); break; - case 1122: tempString = copyString ("ALT+F11"); break; - case 1123: tempString = copyString ("ALT+F12"); break; - - case 2019: tempString = copyString ("PAUSE"); break; - */ - case 63276: - tempString = "PAGE UP"; - break; - case 63277: - tempString = "PAGE DOWN"; - break; - case 63275: - tempString = "END"; - break; - case 63273: - tempString = "HOME"; - break; - case 63234: - tempString = "LEFT"; - break; - case 63232: - tempString = "UP"; - break; - case 63235: - tempString = "RIGHT"; - break; - case 63233: - tempString = "DOWN"; - break; - /* - case 2045: tempString = copyString ("INSERT"); break; - case 2046: tempString = copyString ("DELETE"); break; - */ - case 63236: - tempString = "F1"; - break; - case 63237: - tempString = "F2"; - break; - case 63238: - tempString = "F3"; - break; - case 63239: - tempString = "F4"; - break; - case 63240: - tempString = "F5"; - break; - case 63241: - tempString = "F6"; - break; - case 63242: - tempString = "F7"; - break; - case 63243: - tempString = "F8"; - break; - case 63244: - tempString = "F9"; - break; - case 63245: - tempString = "F10"; - break; - case 63246: - tempString = "F11"; - break; - case 63247: - tempString = "F12"; - break; - - default: - if (input.keyPressed >= 256) { - char tmp[7] = "ABCDEF"; - sprintf(tmp, "%i", input.keyPressed); - tempString = tmp; - //} - } else { - char tmp[2] = " "; - tmp[0] = input.keyPressed; - tempString = tmp; - } - } - - if (!tempString.empty()) { - VariableStack *tempStack = new VariableStack; - if (!checkNew(tempStack)) - return false; - initVarNew(tempStack->thisVar); - makeTextVar(tempStack->thisVar, tempString); - tempStack->next = NULL; - if (!startNewFunctionNum(currentEvents->spaceFunction, 1, NULL, tempStack)) - return false; - } - } - input.rightClick = false; - input.leftClick = false; - input.rightRelease = false; - input.leftRelease = false; - input.keyPressed = 0; - lastRegion = overRegion; - return runSludge(); -} - } // End of namespace Sludge diff --git a/engines/sludge/sludger.h b/engines/sludge/sludger.h index fe00cc6300..91efb24ce9 100644 --- a/engines/sludge/sludger.h +++ b/engines/sludge/sludger.h @@ -39,16 +39,6 @@ typedef struct _FILETIME { struct Variable; struct VariableStack; -struct EventHandlers { - int leftMouseFunction; - int leftMouseUpFunction; - int rightMouseFunction; - int rightMouseUpFunction; - int moveMouseFunction; - int focusFunction; - int spaceFunction; -}; - struct LineOfCode { sludgeCommand theCommand; int32 param; @@ -68,20 +58,14 @@ struct LoadedFunction { byte freezerLevel; }; -struct InputType { - bool leftClick, rightClick, justMoved, leftRelease, rightRelease; - int mouseX, mouseY, keyPressed; -}; - bool initSludge(const Common::String &); +bool runSludge(); void displayBase(); void sludgeDisplay(); int startNewFunctionNum(uint, uint, LoadedFunction *, VariableStack*&, bool = true); bool handleInput(); void restartFunction(LoadedFunction *fun); bool loadFunctionCode(LoadedFunction *newFunc); -void loadHandlers(Common::SeekableReadStream *stream); -void saveHandlers(Common::WriteStream *stream); void finishFunction(LoadedFunction *fun); void abortFunction(LoadedFunction *fun); diff --git a/engines/sludge/sprites.cpp b/engines/sludge/sprites.cpp index 6a0421ed98..6134d1d0c9 100644 --- a/engines/sludge/sprites.cpp +++ b/engines/sludge/sprites.cpp @@ -24,6 +24,7 @@ #include "graphics/transparent_surface.h" #include "sludge/allfiles.h" +#include "sludge/event.h" #include "sludge/fileset.h" #include "sludge/graphics.h" #include "sludge/people.h" @@ -38,7 +39,6 @@ namespace Sludge { -extern InputType input; void GraphicsManager::forgetSpriteBank(SpriteBank &forgetme) { if (forgetme.myPalette.pal) { delete[] forgetme.myPalette.pal; @@ -406,13 +406,14 @@ bool GraphicsManager::scaleSprite(Sprite &single, const SpritePalette &fontPal, } // Are we pointing at the sprite? - if (input.mouseX >= x1 && input.mouseX <= x2 && input.mouseY >= y1 && input.mouseY <= y2) { + if (_vm->_evtMan->mouseX() >= x1 && _vm->_evtMan->mouseX() <= x2 + && _vm->_evtMan->mouseY() >= y1 && _vm->_evtMan->mouseY() <= y2) { if (thisPerson->extra & EXTRA_RECTANGULAR) return true; // check if point to non transparent part - int pixelx = (int)(single.surface.w * (input.mouseX - x1) / (x2 - x1)); - int pixely = (int)(single.surface.h * (input.mouseY - y1) / (y2 - y1)); + int pixelx = (int)(single.surface.w * (_vm->_evtMan->mouseX() - x1) / (x2 - x1)); + int pixely = (int)(single.surface.h * (_vm->_evtMan->mouseY() - y1) / (y2 - y1)); uint32 *colorPtr = (uint32 *)single.surface.getBasePtr(pixelx, pixely); uint8 a, r, g, b; |