From a171c8430b1b1e15db8c823beee942dc31b75c0e Mon Sep 17 00:00:00 2001 From: lolbot-iichan Date: Mon, 15 Jun 2020 00:55:11 +0300 Subject: [PATCH] WINTERMUTE: Add some quick engine actions --- engines/wintermute/base/base_game.cpp | 50 +++++++++++++++++++ engines/wintermute/base/base_game.h | 3 ++ .../base/base_game_custom_actions.h | 44 ++++++++++++++++ engines/wintermute/platform_osystem.cpp | 10 ++++ 4 files changed, 107 insertions(+) create mode 100644 engines/wintermute/base/base_game_custom_actions.h diff --git a/engines/wintermute/base/base_game.cpp b/engines/wintermute/base/base_game.cpp index b66c5f469be..57a4ca99842 100644 --- a/engines/wintermute/base/base_game.cpp +++ b/engines/wintermute/base/base_game.cpp @@ -3786,6 +3786,56 @@ bool BaseGame::handleMouseWheel(int32 delta) { return true; } +////////////////////////////////////////////////////////////////////////// +bool BaseGame::handleCustomActionStart(BaseGameCustomAction action) { + Point32 p; + + switch (action) { + case kClickAtCenter: + p.x = _renderer->getWidth() / 2; + p.y = _renderer->getHeight() / 2; + break; + case kClickAtLeft: + p.x = 30; + p.y = _renderer->getHeight() / 2; + break; + case kClickAtRight: + p.x = _renderer->getWidth() - 30; + p.y = _renderer->getHeight() / 2; + break; + case kClickAtTop: + p.x = _renderer->getWidth() / 2; + p.y = 10; + break; + case kClickAtBottom: + p.x = _renderer->getWidth() / 2; + p.y = _renderer->getHeight() - 35; + break; + default: + return false; + } + + BasePlatform::setCursorPos(p.x, p.y); + setActiveObject(_gameRef->_renderer->getObjectAt(p.x, p.y)); + + return onMouseLeftDown(); +} + +////////////////////////////////////////////////////////////////////////// +bool BaseGame::handleCustomActionEnd(BaseGameCustomAction action) { + switch (action) { + case kClickAtCenter: + case kClickAtLeft: + case kClickAtRight: + case kClickAtTop: + case kClickAtBottom: + return onMouseLeftUp(); + default: + break; + } + + return false; +} ////////////////////////////////////////////////////////////////////////// bool BaseGame::getVersion(byte *verMajor, byte *verMinor, byte *extMajor, byte *extMinor) const { diff --git a/engines/wintermute/base/base_game.h b/engines/wintermute/base/base_game.h index 4d057dffab7..9394a6aa773 100644 --- a/engines/wintermute/base/base_game.h +++ b/engines/wintermute/base/base_game.h @@ -30,6 +30,7 @@ #define WINTERMUTE_BASE_GAME_H #include "engines/wintermute/base/base_object.h" +#include "engines/wintermute/base/base_game_custom_actions.h" #include "engines/wintermute/base/timer.h" #include "engines/wintermute/persistent.h" #include "engines/wintermute/coll_templ.h" @@ -202,6 +203,8 @@ public: bool handleKeypress(Common::Event *event, bool printable = false) override; virtual void handleKeyRelease(Common::Event *event); + bool handleCustomActionStart(BaseGameCustomAction action); + bool handleCustomActionEnd(BaseGameCustomAction action); bool unfreeze(); bool freeze(bool includingMusic = true); diff --git a/engines/wintermute/base/base_game_custom_actions.h b/engines/wintermute/base/base_game_custom_actions.h new file mode 100644 index 00000000000..f717771c35b --- /dev/null +++ b/engines/wintermute/base/base_game_custom_actions.h @@ -0,0 +1,44 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BASE_GAME_CUSTOM_ACTION_H +#define WINTERMUTE_BASE_GAME_CUSTOM_ACTION_H + +namespace Wintermute { + +enum BaseGameCustomAction { + kClickAtCenter = 0, + kClickAtLeft = 1, + kClickAtRight = 2, + kClickAtTop = 3, + kClickAtBottom = 4 +}; + +} // End of namespace Wintermute + +#endif diff --git a/engines/wintermute/platform_osystem.cpp b/engines/wintermute/platform_osystem.cpp index 4bc1702beea..217a7c2f9e7 100644 --- a/engines/wintermute/platform_osystem.cpp +++ b/engines/wintermute/platform_osystem.cpp @@ -109,6 +109,16 @@ void BasePlatform::handleEvent(Common::Event *event) { _gameRef->handleMouseWheel(event->type == Common::EVENT_WHEELUP ? 1 : -1); } break; + case Common::EVENT_CUSTOM_ENGINE_ACTION_START: + if (_gameRef) { + _gameRef->handleCustomActionStart((BaseGameCustomAction)event->customType); + } + break; + case Common::EVENT_CUSTOM_ENGINE_ACTION_END: + if (_gameRef) { + _gameRef->handleCustomActionEnd((BaseGameCustomAction)event->customType); + } + break; case Common::EVENT_SCREEN_CHANGED: if (_gameRef) { _gameRef->_renderer->onWindowChange();