diff options
Diffstat (limited to 'engines')
-rw-r--r-- | engines/titanic/support/screen_manager.cpp | 2 | ||||
-rw-r--r-- | engines/titanic/support/screen_manager.h | 15 | ||||
-rw-r--r-- | engines/titanic/support/text_cursor.cpp | 56 | ||||
-rw-r--r-- | engines/titanic/support/text_cursor.h | 49 | ||||
-rw-r--r-- | engines/titanic/support/video_surface.h | 2 |
5 files changed, 104 insertions, 20 deletions
diff --git a/engines/titanic/support/screen_manager.cpp b/engines/titanic/support/screen_manager.cpp index 3005bdd446..0c9d3ab4e0 100644 --- a/engines/titanic/support/screen_manager.cpp +++ b/engines/titanic/support/screen_manager.cpp @@ -140,8 +140,6 @@ CVideoSurface *OSScreenManager::getSurface(SurfaceNum surfaceNum) const { return nullptr; } -void OSScreenManager::proc9() {} - void OSScreenManager::fillRect(SurfaceNum surfaceNum, Rect *rect, byte r, byte g, byte b) { DirectDrawSurface *surface = getDDSurface(surfaceNum); if (!surface) diff --git a/engines/titanic/support/screen_manager.h b/engines/titanic/support/screen_manager.h index 7fe60d20b7..b963fcd3d6 100644 --- a/engines/titanic/support/screen_manager.h +++ b/engines/titanic/support/screen_manager.h @@ -92,7 +92,11 @@ public: virtual void proc6() = 0; virtual void proc7() = 0; virtual CVideoSurface *getSurface(SurfaceNum surfaceNum) const = 0; - virtual void proc9() = 0; + + /** + * Return the front render surface + */ + virtual CVideoSurface *getFrontRenderSurface() const = 0; /** * Fill an area with a specific color @@ -222,7 +226,14 @@ public: virtual void proc6(); virtual void proc7(); virtual CVideoSurface *getSurface(SurfaceNum surfaceNum) const; - virtual void proc9(); + + /** + * Return the front render surface + */ + virtual CVideoSurface *getFrontRenderSurface() const { + return _frontRenderSurface; + } + /** * Fill an area with a specific color diff --git a/engines/titanic/support/text_cursor.cpp b/engines/titanic/support/text_cursor.cpp index 7e69a2239a..c3d2f20f84 100644 --- a/engines/titanic/support/text_cursor.cpp +++ b/engines/titanic/support/text_cursor.cpp @@ -23,13 +23,15 @@ #include "common/textconsole.h" #include "titanic/support/text_cursor.h" #include "titanic/support/screen_manager.h" +#include "titanic/titanic.h" namespace Titanic { CTextCursor::CTextCursor(CScreenManager *screenManager) : - _screenManager(screenManager), _priorTicks(300), _active(false), - _field24(0), _size(2, 10), _field44(0), _field48(0), _field4C(0), - _field54(-1) { + _screenManager(screenManager), _active(false), _blinkVisible(false), + _backRenderSurface(nullptr), _frontRenderSurface(nullptr), + _blinkDelay(300), _size(2, 10), _priorBlinkTime(0), + _cursorR(0), _cursorG(0), _cursorB(0), _mode(-1) { screenManager->createSurface(10, 10); } @@ -37,4 +39,52 @@ CTextCursor::~CTextCursor() { delete _surface; } +void CTextCursor::setColor(byte r, byte g, byte b) { + _cursorR = r; + _cursorG = g; + _cursorB = b; +} + +void CTextCursor::show() { + _backRenderSurface = _screenManager->getSurface(SURFACE_BACKBUFFER); + _frontRenderSurface = _screenManager->getFrontRenderSurface(); + _active = true; + _priorBlinkTime = g_vm->_events->getTicksCount(); +} + +void CTextCursor::hide() { + _active = false; +} + +void CTextCursor::draw() { + if (!_active) + return; + + // Handle updating whether the blinking cursor is visible or not + uint newTicks = g_vm->_events->getTicksCount(); + while (newTicks > (_priorBlinkTime + _blinkDelay)) { + _priorBlinkTime += _blinkDelay; + _blinkVisible = !_blinkVisible; + } + + if (_blinkVisible) { + Rect cursorRect = getCursorBounds(); + _surface->blitFrom(Common::Point(0, 0), _backRenderSurface, &cursorRect); + + if (!_screenBounds.isEmpty()) + // Limit the cursor rect to only within designated screen area + cursorRect.constrain(_screenBounds); + + if (!cursorRect.isEmpty()) { + // Draw cursor onto the screen + _backRenderSurface->_ddSurface->fillRect(&cursorRect, + _cursorR, _cursorG, _cursorB); + } + } + + if (_active && _blinkVisible) { + _screenManager->blitFrom(SURFACE_BACKBUFFER, _surface, &_pos); + } +} + } // End of namespace Titanic diff --git a/engines/titanic/support/text_cursor.h b/engines/titanic/support/text_cursor.h index c9fcfa35dd..d8c6ac0653 100644 --- a/engines/titanic/support/text_cursor.h +++ b/engines/titanic/support/text_cursor.h @@ -34,17 +34,20 @@ class CVideoSurface; class CTextCursor { private: CScreenManager *_screenManager; + CVideoSurface *_backRenderSurface; + CVideoSurface *_frontRenderSurface; Point _pos; - Rect _bounds; - uint _priorTicks; - int _field24; + Rect _screenBounds; + uint _blinkDelay; + bool _blinkVisible; Point _size; Point _screenTopLeft; - int _field44; - int _field48; - int _field4C; + uint _priorBlinkTime; + byte _cursorR; + byte _cursorG; + byte _cursorB; CVideoSurface *_surface; - int _field54; + int _mode; public: bool _active; public: @@ -71,24 +74,46 @@ public: /** * Set bounds */ - void setBounds(const Rect &r) { _bounds = r; } + void setBounds(const Rect &r) { _screenBounds = r; } /** * Clear the bounds */ - void clearBounds() { _bounds.clear(); } + void clearBounds() { _screenBounds.clear(); } /** - * Set the prior ticks + * Set the blinking rate */ - void setTicks(uint ticks) { _priorTicks = ticks; } + void setBlinkRate(uint ticks) { _blinkDelay = ticks; } + + /** + * Set the cursor color + */ + void setColor(byte r, byte g, byte b); /** * Returns whether the text cursor is active */ bool isActive() const { return _active; } - int get54() const { return _field54; } + int getMode() const { return _mode; } + + void setMode(int mode) { _mode = mode; } + + /** + * Show the text cursor + */ + void show(); + + /** + * Hide the text cursor + */ + void hide(); + + /** + * Update and draw the cursor if necessary + */ + void draw(); }; } // End of namespace Titanic diff --git a/engines/titanic/support/video_surface.h b/engines/titanic/support/video_surface.h index 2ec2c9ddba..d7061895a5 100644 --- a/engines/titanic/support/video_surface.h +++ b/engines/titanic/support/video_surface.h @@ -55,7 +55,6 @@ protected: protected: CScreenManager *_screenManager; CResourceKey _resourceKey; - DirectDrawSurface *_ddSurface; Graphics::ManagedSurface *_rawSurface; bool _pendingLoad; void *_field40; @@ -66,6 +65,7 @@ protected: int _lockCount; public: CMovie *_movie; + DirectDrawSurface *_ddSurface; bool _blitFlag; bool _blitStyleFlag; public: |