From 1efbed540948edcbf3ac2c72c0984def044274cf Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 3 Apr 2016 16:16:35 -0400 Subject: TITANIC: Move most of the root classes into new support/ folder --- engines/titanic/support/screen_manager.h | 248 +++++++++++++++++++++++++++++++ 1 file changed, 248 insertions(+) create mode 100644 engines/titanic/support/screen_manager.h (limited to 'engines/titanic/support/screen_manager.h') diff --git a/engines/titanic/support/screen_manager.h b/engines/titanic/support/screen_manager.h new file mode 100644 index 0000000000..affe2ec0c9 --- /dev/null +++ b/engines/titanic/support/screen_manager.h @@ -0,0 +1,248 @@ +/* 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 TITANIC_SCREEN_MANAGER_H +#define TITANIC_SCREEN_MANAGER_H + +#include "common/scummsys.h" +#include "common/array.h" +#include "titanic/support/direct_draw.h" +#include "titanic/support/font.h" +#include "titanic/input_handler.h" +#include "titanic/support/mouse_cursor.h" +#include "titanic/support/text_cursor.h" +#include "titanic/support/video_surface.h" +#include "titanic/core/resource_key.h" + +namespace Titanic { + +/** + * The original used page flipping with one primary and one back buffer. + * Since we don't need that in ScummVM, the back buffer number below is + * remapped to the primary surface + */ +enum SurfaceNum { + SURFACE_PRIMARY = -1, + SURFACE_BACKBUFFER = -1 +}; + +class TitanicEngine; + +class CScreenManager { + struct VideoSurfaceEntry { + CVideoSurface *_surface; + Rect _bounds; + }; +protected: + TitanicEngine *_vm; +public: + static CScreenManager *_screenManagerPtr; + static CScreenManager *_currentScreenManagerPtr; + + /** + * Set the current screen manager + */ + static CScreenManager *setCurrent(); +public: + Common::Array _backSurfaces; + CVideoSurface *_frontRenderSurface; + CMouseCursor *_mouseCursor; + CTextCursor *_textCursor; + CInputHandler *_inputHandler; + int _fontNumber; +public: + CScreenManager(TitanicEngine *vm); + virtual ~CScreenManager(); + + void fn1() {} + void fn2() {} + + virtual void setWindowHandle(int v); + virtual bool resetWindowHandle(int v); + + /** + * Sets the video mode + */ + virtual void setMode(int width, int height, int bpp, uint numBackSurfaces, bool flag2) = 0; + + /** + * Handles drawing the cursors + */ + virtual void drawCursors() = 0; + + virtual void proc6() = 0; + virtual void proc7() = 0; + virtual CVideoSurface *getSurface(SurfaceNum surfaceNum) const = 0; + virtual void proc9() = 0; + + /** + * Fill an area with a specific color + */ + virtual void fillRect(SurfaceNum surfaceNum, Rect *rect, byte r, byte g, byte b) = 0; + + /** + * Blits a surface onto one of the screen surfaces + */ + virtual void blitFrom(SurfaceNum surfaceNum, CVideoSurface *src, const Point *destPos = nullptr, + const Rect *srcRect = nullptr) = 0; + + virtual void proc12() = 0; + virtual void proc13() = 0; + virtual void proc14() = 0; + virtual void proc15() = 0; + + + /** + * Write out a string + */ + virtual void writeString(int maxWidth, const CString &text, int *v1, int *v2) = 0; + + virtual void getFont() = 0; + virtual void proc18() = 0; + virtual void proc19() = 0; + + /** + * Clear a portion of a specified surface + */ + virtual void clearSurface(SurfaceNum surfaceNum, Rect *_bounds) = 0; + + /** + * Resize the passed surface + */ + virtual void resizeSurface(CVideoSurface *surface, int width, int height) = 0; + + /** + * Creates a surface of a given size + */ + virtual CVideoSurface *createSurface(int w, int h) = 0; + + /** + * Creates a surface from a specified resource + */ + virtual CVideoSurface *createSurface(const CResourceKey &key) = 0; + + virtual void proc24() = 0; + virtual void proc25() = 0; + virtual void showCursor() = 0; + virtual void hideCursor() = 0; + + void setSurfaceBounds(SurfaceNum surfaceNum, const Rect &r); +}; + +class OSScreenManager: CScreenManager { +private: + DirectDrawManager _directDrawManager; + + /** + * Frees any surface buffers + */ + void destroyFrontAndBackBuffers(); + + /** + * Load game cursors + */ + void loadCursors(); + + /** + * Gets an underlying surface + */ + DirectDrawSurface *getDDSurface(SurfaceNum surfaceNum); +public: + int _field48; + int _field4C; + int _field50; + int _field54; + STFont _fonts[4]; +public: + OSScreenManager(TitanicEngine *vm); + virtual ~OSScreenManager(); + + /** + * Sets the video mode + */ + virtual void setMode(int width, int height, int bpp, uint numBackSurfaces, bool flag2); + + /** + * Handles drawing the cursors + */ + virtual void drawCursors(); + + virtual void proc6(); + virtual void proc7(); + virtual CVideoSurface *getSurface(SurfaceNum surfaceNum) const; + virtual void proc9(); + + /** + * Fill an area with a specific color + */ + virtual void fillRect(SurfaceNum surfaceNum, Rect *rect, byte r, byte g, byte b); + + /** + * Blits a surface onto one of the screen surfaces + */ + virtual void blitFrom(SurfaceNum surfaceNum, CVideoSurface *src, const Point *destPos, + const Rect *srcRect = nullptr); + + virtual void proc12(); + virtual void proc13(); + virtual void proc14(); + virtual void proc15(); + + /** + * Write out a string + */ + virtual void writeString(int maxWidth, const CString &text, int *v1, int *v2); + + virtual void getFont(); + virtual void proc18(); + virtual void proc19(); + + /** + * Clear a portion of the screen surface + */ + virtual void clearSurface(SurfaceNum surfaceNum, Rect *bounds); + + /** + * Resize the passed surface + */ + virtual void resizeSurface(CVideoSurface *surface, int width, int height); + + /** + * Creates a surface of a given size + */ + virtual CVideoSurface *createSurface(int w, int h); + + /** + * Creates a surface from a specified resource + */ + virtual CVideoSurface *createSurface(const CResourceKey &key); + + virtual void proc23(); + virtual void proc24(); + virtual void proc25(); + virtual void showCursor(); + virtual void hideCursor(); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_SCREEN_MANAGER_H */ -- cgit v1.2.3 From a88c0b09994562d4576e7dd08db8ad2fe3326f53 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 24 Apr 2016 10:37:34 -0400 Subject: TITANIC: Starting to flesh out CPetText drawing --- engines/titanic/support/screen_manager.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'engines/titanic/support/screen_manager.h') diff --git a/engines/titanic/support/screen_manager.h b/engines/titanic/support/screen_manager.h index affe2ec0c9..d0580d4957 100644 --- a/engines/titanic/support/screen_manager.h +++ b/engines/titanic/support/screen_manager.h @@ -145,7 +145,15 @@ public: virtual void showCursor() = 0; virtual void hideCursor() = 0; + /** + * Set drawing bounds for a specified surface + */ void setSurfaceBounds(SurfaceNum surfaceNum, const Rect &r); + + /** + * Set the current font number + */ + void setFontNumber(int fontNumber) { _fontNumber = fontNumber; } }; class OSScreenManager: CScreenManager { -- cgit v1.2.3 From c75de59a28c94e364a38af39057af720ba8465d4 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 24 Apr 2016 17:16:32 -0400 Subject: TITANIC: Implementing font text bounds calculations --- engines/titanic/support/screen_manager.h | 39 +++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 8 deletions(-) (limited to 'engines/titanic/support/screen_manager.h') diff --git a/engines/titanic/support/screen_manager.h b/engines/titanic/support/screen_manager.h index d0580d4957..baba662564 100644 --- a/engines/titanic/support/screen_manager.h +++ b/engines/titanic/support/screen_manager.h @@ -110,14 +110,25 @@ public: virtual void proc14() = 0; virtual void proc15() = 0; + /** + * Get the text area a string will fit into + * @param str String + * @param maxWidth Maximum width in pixels + * @param sizeOut Optional pointer to output size + * @returns Required height + */ + virtual int getTextBounds(const CString &str, int maxWidth, Point *sizeOut = nullptr) const = 0; + + /** + * Get the current font height + */ + virtual int getFontHeight() const = 0; /** - * Write out a string + * Returns the width of a given string in pixels */ - virtual void writeString(int maxWidth, const CString &text, int *v1, int *v2) = 0; + virtual int stringWidth(const CString &str) = 0; - virtual void getFont() = 0; - virtual void proc18() = 0; virtual void proc19() = 0; /** @@ -216,12 +227,24 @@ public: virtual void proc15(); /** - * Write out a string + * Get the text area a string will fit into + * @param str String + * @param maxWidth Maximum width in pixels + * @param sizeOut Optional pointer to output size + * @returns Required height + */ + virtual int getTextBounds(const CString &str, int maxWidth, Point *sizeOut = nullptr) const; + + /** + * Get the current font height + */ + virtual int getFontHeight() const; + + /** + * Returns the width of a given string in pixels */ - virtual void writeString(int maxWidth, const CString &text, int *v1, int *v2); + virtual int stringWidth(const CString &str); - virtual void getFont(); - virtual void proc18(); virtual void proc19(); /** -- cgit v1.2.3 From 36faf0890fec6bab90531ade42c0eb924b31b64a Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 24 Apr 2016 22:22:12 -0400 Subject: TITANIC: Minor work towards text display --- engines/titanic/support/screen_manager.h | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'engines/titanic/support/screen_manager.h') diff --git a/engines/titanic/support/screen_manager.h b/engines/titanic/support/screen_manager.h index baba662564..b1e949ad58 100644 --- a/engines/titanic/support/screen_manager.h +++ b/engines/titanic/support/screen_manager.h @@ -108,7 +108,11 @@ public: virtual void proc12() = 0; virtual void proc13() = 0; virtual void proc14() = 0; - virtual void proc15() = 0; + + /** + * Set the font color + */ + virtual void setFontColor(byte r, byte g, byte b) = 0; /** * Get the text area a string will fit into @@ -164,7 +168,7 @@ public: /** * Set the current font number */ - void setFontNumber(int fontNumber) { _fontNumber = fontNumber; } + int setFontNumber(int fontNumber); }; class OSScreenManager: CScreenManager { @@ -224,7 +228,11 @@ public: virtual void proc12(); virtual void proc13(); virtual void proc14(); - virtual void proc15(); + + /** + * Set the font color + */ + virtual void setFontColor(byte r, byte g, byte b); /** * Get the text area a string will fit into -- cgit v1.2.3 From 34c32e38e2659406e3556f752fcada8491860e92 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 26 Apr 2016 22:18:21 -0400 Subject: TITANIC: More font logic, beginnings of text cursor --- engines/titanic/support/screen_manager.h | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'engines/titanic/support/screen_manager.h') diff --git a/engines/titanic/support/screen_manager.h b/engines/titanic/support/screen_manager.h index b1e949ad58..7fe60d20b7 100644 --- a/engines/titanic/support/screen_manager.h +++ b/engines/titanic/support/screen_manager.h @@ -106,7 +106,17 @@ public: const Rect *srcRect = nullptr) = 0; virtual void proc12() = 0; - virtual void proc13() = 0; + + /** + * Write a string + * @param surfaceNum Destination surface + * @param destRect Bounds within dest surface + * @param str Line or lines to write + * @param textCursor Optional text cursor pointer + */ + virtual int writeString(int surfaceNum, const Rect &destRect, int val1, + const CString &str, CTextCursor *textCursor) = 0; + virtual void proc14() = 0; /** @@ -226,7 +236,17 @@ public: const Rect *srcRect = nullptr); virtual void proc12(); - virtual void proc13(); + + /** + * Write a string + * @param surfaceNum Destination surface + * @param destRect Bounds within dest surface + * @param str Line or lines to write + * @param textCursor Optional text cursor pointer + */ + virtual int writeString(int surfaceNum, const Rect &destRect, + int val1, const CString &str, CTextCursor *textCursor); + virtual void proc14(); /** -- cgit v1.2.3 From 74e40be66e231a8eada9bc045828e17f044a7c55 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 27 Apr 2016 19:50:58 -0400 Subject: TITANIC: Implementing text cursor drawing --- engines/titanic/support/screen_manager.h | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'engines/titanic/support/screen_manager.h') 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 -- cgit v1.2.3 From a8835043f54daf54a2c03ccdb02f125a62a7ddcd Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 27 Apr 2016 21:01:12 -0400 Subject: TITANIC: PET Text is now partially showing --- engines/titanic/support/screen_manager.h | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'engines/titanic/support/screen_manager.h') diff --git a/engines/titanic/support/screen_manager.h b/engines/titanic/support/screen_manager.h index b963fcd3d6..2e80869085 100644 --- a/engines/titanic/support/screen_manager.h +++ b/engines/titanic/support/screen_manager.h @@ -115,12 +115,14 @@ public: * Write a string * @param surfaceNum Destination surface * @param destRect Bounds within dest surface + * @param yOffset Y offset for drawing, to allow for parts of + * the text to be scrolled off-screen * @param str Line or lines to write * @param textCursor Optional text cursor pointer */ - virtual int writeString(int surfaceNum, const Rect &destRect, int val1, - const CString &str, CTextCursor *textCursor) = 0; - + virtual int writeString(int surfaceNum, const Rect &destRect, + int yOffset, const CString &str, CTextCursor *textCursor) = 0; + virtual void proc14() = 0; /** @@ -252,11 +254,13 @@ public: * Write a string * @param surfaceNum Destination surface * @param destRect Bounds within dest surface + * @param yOffset Y offset for drawing, to allow for parts of + * the text to be scrolled off-screen * @param str Line or lines to write * @param textCursor Optional text cursor pointer */ virtual int writeString(int surfaceNum, const Rect &destRect, - int val1, const CString &str, CTextCursor *textCursor); + int yOffset, const CString &str, CTextCursor *textCursor); virtual void proc14(); -- cgit v1.2.3 From 68f13646e185416bb74812ea489764b9b28b8e22 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 19 Jun 2016 09:58:00 -0400 Subject: TITANIC: Implementing more CGameObject/OSScreenManager draw methods --- engines/titanic/support/screen_manager.h | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'engines/titanic/support/screen_manager.h') diff --git a/engines/titanic/support/screen_manager.h b/engines/titanic/support/screen_manager.h index 2e80869085..21b40cad37 100644 --- a/engines/titanic/support/screen_manager.h +++ b/engines/titanic/support/screen_manager.h @@ -41,8 +41,8 @@ namespace Titanic { * remapped to the primary surface */ enum SurfaceNum { - SURFACE_PRIMARY = -1, - SURFACE_BACKBUFFER = -1 + SURFACE_PRIMARY = -1, // Surface 0 + SURFACE_BACKBUFFER = -1 // Surface -1 }; class TitanicEngine; @@ -109,8 +109,11 @@ public: virtual void blitFrom(SurfaceNum surfaceNum, CVideoSurface *src, const Point *destPos = nullptr, const Rect *srcRect = nullptr) = 0; - virtual void proc12() = 0; - + /** + * Blits a surface onto one of the screen surfaces + */ + virtual void blitFrom(SurfaceNum surfaceNum, const Rect *rect, CVideoSurface *src, int v = 0) = 0; + /** * Write a string * @param surfaceNum Destination surface @@ -248,7 +251,10 @@ public: virtual void blitFrom(SurfaceNum surfaceNum, CVideoSurface *src, const Point *destPos, const Rect *srcRect = nullptr); - virtual void proc12(); + /** + * Blits a surface onto one of the screen surfaces + */ + virtual void blitFrom(SurfaceNum surfaceNum, const Rect *rect, CVideoSurface *src, int v = 0); /** * Write a string -- cgit v1.2.3 From d9e05e215c1ba8ab93530e7263b527c03fcc61c8 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 3 Jul 2016 12:48:05 -0400 Subject: TITANIC: Fleshing out screen manager --- engines/titanic/support/screen_manager.h | 95 +++++++++++++++++++++++++++----- 1 file changed, 81 insertions(+), 14 deletions(-) (limited to 'engines/titanic/support/screen_manager.h') diff --git a/engines/titanic/support/screen_manager.h b/engines/titanic/support/screen_manager.h index 21b40cad37..0736f1393c 100644 --- a/engines/titanic/support/screen_manager.h +++ b/engines/titanic/support/screen_manager.h @@ -89,8 +89,19 @@ public: */ virtual void drawCursors() = 0; - virtual void proc6() = 0; - virtual void proc7() = 0; + /** + * Locks a specified surface number for access and returns a pointer to it + */ + virtual CVideoSurface *lockSurface(SurfaceNum surfaceNum) = 0; + + /** + * Unlocks a previously locked surface + */ + virtual void unlockSurface(CVideoSurface *surface) = 0; + + /** + * Gets a specified surface number + */ virtual CVideoSurface *getSurface(SurfaceNum surfaceNum) const = 0; /** @@ -126,7 +137,16 @@ public: virtual int writeString(int surfaceNum, const Rect &destRect, int yOffset, const CString &str, CTextCursor *textCursor) = 0; - virtual void proc14() = 0; + /** + * Write a string + * @param surfaceNum Destination surface + * @param srcRect Drawing area + * @param destRect Bounds of dest surface + * @param str Line or lines to write + * @param textCursor Optional text cursor pointer + */ + virtual int writeString(int surfaceNum, const Rect &srcRect, + const Rect &destRect, const CString &str, CTextCursor *textCursor) = 0; /** * Set the font color @@ -152,7 +172,10 @@ public: */ virtual int stringWidth(const CString &str) = 0; - virtual void proc19() = 0; + /** + * Draws a frame enclosing the specified area + */ + virtual void frameRect(SurfaceNum surfaceNum, const Rect &rect, byte r, byte g, byte b) = 0; /** * Clear a portion of a specified surface @@ -173,10 +196,27 @@ public: * Creates a surface from a specified resource */ virtual CVideoSurface *createSurface(const CResourceKey &key) = 0; - - virtual void proc24() = 0; - virtual void proc25() = 0; + + /** + * Get the top-left corner of the screen in global screen co-ordinates + * For ScummVM, this is always (0, 0), even in Windowed mode + */ + virtual Point getScreenTopLeft() { return Point(0, 0); } + + /** + * Waits for a vertical screen sync + * For ScummVM, this can be safely ignored + */ + virtual void waitForVSync() {} + + /** + * Show the mouse cursor + */ virtual void showCursor() = 0; + + /** + * Hide the mouse cursor + */ virtual void hideCursor() = 0; /** @@ -228,8 +268,19 @@ public: */ virtual void drawCursors(); - virtual void proc6(); - virtual void proc7(); + /** + * Locks a specified surface number for access and returns a pointer to it + */ + virtual CVideoSurface *lockSurface(SurfaceNum surfaceNum); + + /** + * Unlocks a previously locked surface + */ + virtual void unlockSurface(CVideoSurface *surface); + + /** + * Gets a specified surface number + */ virtual CVideoSurface *getSurface(SurfaceNum surfaceNum) const; /** @@ -268,7 +319,16 @@ public: virtual int writeString(int surfaceNum, const Rect &destRect, int yOffset, const CString &str, CTextCursor *textCursor); - virtual void proc14(); + /** + * Write a string + * @param surfaceNum Destination surface + * @param srcRect Drawing area + * @param destRect Bounds of dest surface + * @param str Line or lines to write + * @param textCursor Optional text cursor pointer + */ + virtual int writeString(int surfaceNum, const Rect &srcRect, + const Rect &destRect, const CString &str, CTextCursor *textCursor); /** * Set the font color @@ -294,7 +354,10 @@ public: */ virtual int stringWidth(const CString &str); - virtual void proc19(); + /** + * Draws a frame enclosing the specified area + */ + virtual void frameRect(SurfaceNum surfaceNum, const Rect &rect, byte r, byte g, byte b); /** * Clear a portion of the screen surface @@ -316,10 +379,14 @@ public: */ virtual CVideoSurface *createSurface(const CResourceKey &key); - virtual void proc23(); - virtual void proc24(); - virtual void proc25(); + /** + * Show the mouse cursor + */ virtual void showCursor(); + + /** + * Hide the mouse cursor + */ virtual void hideCursor(); }; -- cgit v1.2.3