diff --git a/engines/stark/cursor.cpp b/engines/stark/cursor.cpp new file mode 100644 index 00000000000..f2ef36350c8 --- /dev/null +++ b/engines/stark/cursor.cpp @@ -0,0 +1,48 @@ +/* ResidualVM - A 3D game interpreter + * + * ResidualVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the AUTHORS + * 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 "engines/stark/cursor.h" + +#include "engines/stark/gfx/driver.h" +#include "engines/stark/gfx/texture.h" + +namespace Stark { + +Cursor::Cursor(Gfx::Driver *gfx) : + _gfx(gfx) { + // TODO: This is just a quick solution to get anything drawn, we will need load-code for the actual pointers. + _cursorTexture = _gfx->createTextureFromString("X", 0xFF00FF00); +} + +Cursor::~Cursor() { + delete _cursorTexture; +} + +void Cursor::setMousePosition(Common::Point pos) { + _mousePos = pos; +} + +void Cursor::render() { + _gfx->drawSurface(_cursorTexture, _mousePos); +} + +} // End of namespace Stark diff --git a/engines/stark/cursor.h b/engines/stark/cursor.h new file mode 100644 index 00000000000..a47d0bca421 --- /dev/null +++ b/engines/stark/cursor.h @@ -0,0 +1,61 @@ +/* ResidualVM - A 3D game interpreter + * + * ResidualVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the AUTHORS + * 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 STARK_CURSOR_H +#define STARK_CURSOR_H + +#include "common/rect.h" +#include "common/scummsys.h" + +namespace Stark { + +namespace Gfx { +class Driver; +class Texture; +} + +/** + * Manager for the current game Cursor + */ +class Cursor { +public: + Cursor(Gfx::Driver *gfx); + ~Cursor(); + + /** + * Render the Cursor + */ + void render(); + + /** Update the mouse position */ + void setMousePosition(Common::Point pos); + +private: + Gfx::Driver *_gfx; + + Common::Point _mousePos; + Gfx::Texture *_cursorTexture; +}; + +} // End of namespace Stark + +#endif // STARK_CURSOR_H diff --git a/engines/stark/module.mk b/engines/stark/module.mk index 438d34038f0..ee460238768 100644 --- a/engines/stark/module.mk +++ b/engines/stark/module.mk @@ -3,6 +3,7 @@ MODULE := engines/stark MODULE_OBJS := \ actor.o \ console.o \ + cursor.o \ detection.o \ gfx/driver.o \ gfx/opengls.o \ diff --git a/engines/stark/services/userinterface.cpp b/engines/stark/services/userinterface.cpp index 6c1707bf5d1..de7d9940341 100644 --- a/engines/stark/services/userinterface.cpp +++ b/engines/stark/services/userinterface.cpp @@ -35,12 +35,9 @@ namespace Stark { UserInterface::UserInterface(Gfx::Driver *driver) { _gfx = driver; - // TODO: This is just a quick solution to get anything drawn, we will need load-code for the actual pointers. - _cursorTexture = _gfx->createTextureFromString("X", 0xFF00FF00); } UserInterface::~UserInterface() { - delete _cursorTexture; } void UserInterface::skipCurrentSpeeches() { @@ -82,14 +79,7 @@ void UserInterface::scrollLocation(int32 dX, int32 dY) { location->setScrollPosition(scroll); } -void UserInterface::setMousePosition(Common::Point pos) { - _mousePos = pos; -} - void UserInterface::render() { - if (_cursorTexture) { - _gfx->drawSurface(_cursorTexture, _mousePos); - } Common::String debugStr; Global *global = StarkServices::instance().global; @@ -99,7 +89,7 @@ void UserInterface::render() { debugStr += Common::String::format("location: %02x %02x ", current->getLevel()->getIndex(), current->getLocation()->getIndex()); debugStr += current->getLevel()->getName() + ", " + current->getLocation()->getName(); - debugStr += Common::String::format(" chapter: %d mouse(%d, %d)", chapter, _mousePos.x, _mousePos.y); + debugStr += Common::String::format(" chapter: %d", chapter); Gfx::Texture *debugTexture = _gfx->createTextureFromString(debugStr, 0xF0FF0F00); diff --git a/engines/stark/services/userinterface.h b/engines/stark/services/userinterface.h index ec0cbbc77b5..9e17364f404 100644 --- a/engines/stark/services/userinterface.h +++ b/engines/stark/services/userinterface.h @@ -24,7 +24,6 @@ #define STARK_SERVICES_USER_INTERFACE_H #include "common/scummsys.h" -#include "common/rect.h" namespace Stark { @@ -47,14 +46,9 @@ public: /** Scroll the current location by an offset */ void scrollLocation(int32 dX, int32 dY); - /** Update the mouse position */ - void setMousePosition(Common::Point pos); - /** Draw the mouse pointer, and any additional currently active UI */ void render(); private: - Common::Point _mousePos; - Gfx::Texture *_cursorTexture; Gfx::Driver *_gfx; }; diff --git a/engines/stark/stark.cpp b/engines/stark/stark.cpp index ac4374d82b6..cf4199b0565 100644 --- a/engines/stark/stark.cpp +++ b/engines/stark/stark.cpp @@ -23,6 +23,7 @@ #include "engines/stark/stark.h" #include "engines/stark/console.h" +#include "engines/stark/cursor.h" #include "engines/stark/debug.h" #include "engines/stark/resources/level.h" #include "engines/stark/resources/location.h" @@ -52,6 +53,7 @@ StarkEngine::StarkEngine(OSystem *syst, const ADGameDescription *gameDesc) : _gfx(nullptr), _scene(nullptr), _console(nullptr), + _cursor(nullptr), _global(nullptr), _userInterface(nullptr), _archiveLoader(nullptr), @@ -73,6 +75,7 @@ StarkEngine::StarkEngine(OSystem *syst, const ADGameDescription *gameDesc) : StarkEngine::~StarkEngine() { delete _userInterface; + delete _cursor; delete _dialogPlayer; delete _randomSource; delete _scene; @@ -100,6 +103,7 @@ Common::Error StarkEngine::run() { _randomSource = new Common::RandomSource("stark"); _scene = new Scene(_gfx); _dialogPlayer = new DialogPlayer(); + _cursor = new Cursor(_gfx); _userInterface = new UserInterface(_gfx); // Setup the public services @@ -150,7 +154,7 @@ void StarkEngine::mainLoop() { _userInterface->skipCurrentSpeeches(); } else if (e.type == Common::EVENT_MOUSEMOVE) { _userInterface->scrollLocation(e.relMouse.x, e.relMouse.y); - _userInterface->setMousePosition(e.mouse); + _cursor->setMousePosition(e.mouse); } /*if (event.type == Common::EVENT_KEYDOWN || event.type == Common::EVENT_KEYUP) { handleControls(event.type, event.kbd.keycode, event.kbd.flags, event.kbd.ascii); @@ -194,6 +198,7 @@ void StarkEngine::updateDisplayScene() { _dialogPlayer->renderText(); _userInterface->render(); + _cursor->render(); // Swap buffers _gfx->flipBuffer(); diff --git a/engines/stark/stark.h b/engines/stark/stark.h index 0c233909a21..bfea22aab40 100644 --- a/engines/stark/stark.h +++ b/engines/stark/stark.h @@ -30,7 +30,6 @@ namespace Common { class RandomSource; } - namespace Stark { namespace Gfx { @@ -43,6 +42,7 @@ enum StarkGameFeatures { class ArchiveLoader; class Console; +class Cursor; class DialogPlayer; class Global; class UserInterface; @@ -83,6 +83,7 @@ private: const ADGameDescription *_gameDescription; + Cursor *_cursor; Scene *_scene; };