From 27782700a5631a25129b12779abb540a906f6a96 Mon Sep 17 00:00:00 2001 From: Sven Hesse Date: Thu, 28 Jun 2012 17:45:02 +0200 Subject: GOB: Add some PreGob and Once Upon A Time cursor functions --- engines/gob/pregob/onceupon/onceupon.cpp | 1 + engines/gob/pregob/onceupon/onceupon.h | 2 ++ engines/gob/pregob/pregob.cpp | 47 ++++++++++++++++++++++++++++++++ engines/gob/pregob/pregob.h | 14 ++++++++++ 4 files changed, 64 insertions(+) (limited to 'engines/gob/pregob') diff --git a/engines/gob/pregob/onceupon/onceupon.cpp b/engines/gob/pregob/onceupon/onceupon.cpp index 35127cbfb3..7f7dffa7ec 100644 --- a/engines/gob/pregob/onceupon/onceupon.cpp +++ b/engines/gob/pregob/onceupon/onceupon.cpp @@ -23,6 +23,7 @@ #include "gob/gob.h" #include "gob/util.h" #include "gob/dataio.h" +#include "gob/surface.h" #include "gob/draw.h" #include "gob/video.h" diff --git a/engines/gob/pregob/onceupon/onceupon.h b/engines/gob/pregob/onceupon/onceupon.h index 816d4dc051..c1c4d6fa0d 100644 --- a/engines/gob/pregob/onceupon/onceupon.h +++ b/engines/gob/pregob/onceupon/onceupon.h @@ -29,6 +29,8 @@ namespace Gob { +class Surface; + namespace OnceUpon { class OnceUpon : public PreGob { diff --git a/engines/gob/pregob/pregob.cpp b/engines/gob/pregob/pregob.cpp index aea290214c..18aac50352 100644 --- a/engines/gob/pregob/pregob.cpp +++ b/engines/gob/pregob/pregob.cpp @@ -20,9 +20,12 @@ * */ +#include "graphics/cursorman.h" + #include "gob/gob.h" #include "gob/global.h" #include "gob/util.h" +#include "gob/surface.h" #include "gob/palanim.h" #include "gob/draw.h" #include "gob/video.h" @@ -90,4 +93,48 @@ void PreGob::setPalette(const byte *palette, uint16 size) { _vm->_video->setFullPalette(_vm->_global->_pPaletteDesc); } +void PreGob::addCursor() { + CursorMan.pushCursor(0, 0, 0, 0, 0, 0); +} + +void PreGob::removeCursor() { + CursorMan.popCursor(); +} + +void PreGob::setCursor(Surface &sprite, int16 hotspotX, int16 hotspotY) { + CursorMan.replaceCursor(sprite.getData(), sprite.getWidth(), sprite.getHeight(), hotspotX, hotspotY, 0); +} + +void PreGob::setCursor(Surface &sprite, int16 left, int16 top, int16 right, int16 bottom, + int16 hotspotX, int16 hotspotY) { + + const int width = right - left + 1; + const int height = bottom - top + 1; + + if ((width <= 0) || (height <= 0)) + return; + + Surface cursor(width, height, 1); + + cursor.blit(sprite, left, top, right, bottom, 0, 0); + + setCursor(cursor, hotspotX, hotspotX); +} + +void PreGob::showCursor() { + CursorMan.showMouse(true); + + _vm->_draw->_showCursor = 4; +} + +void PreGob::hideCursor() { + CursorMan.showMouse(false); + + _vm->_draw->_showCursor = 0; +} + +bool PreGob::isCursorVisible() const { + return CursorMan.isVisible(); +} + } // End of namespace Gob diff --git a/engines/gob/pregob/pregob.h b/engines/gob/pregob/pregob.h index 6418d6fd8a..e0f7ca907d 100644 --- a/engines/gob/pregob/pregob.h +++ b/engines/gob/pregob/pregob.h @@ -26,6 +26,7 @@ namespace Gob { class GobEngine; +class Surface; class PreGob { public: @@ -49,6 +50,19 @@ protected: */ void setPalette(const byte *palette, uint16 size); ///< Change the palette + void addCursor(); + void removeCursor(); + + void setCursor(Surface &sprite, int16 hotspotX, int16 hotspotY); + void setCursor(Surface &sprite, int16 left, int16 top, int16 right, int16 bottom, + int16 hotspotX, int16 hotspotY); + + void showCursor(); + void hideCursor(); + + bool isCursorVisible() const; + + GobEngine *_vm; private: -- cgit v1.2.3