ScummVM API documentation
screen_manager.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef TITANIC_SCREEN_MANAGER_H
23 #define TITANIC_SCREEN_MANAGER_H
24 
25 #include "common/scummsys.h"
26 #include "common/array.h"
27 #include "titanic/support/direct_draw.h"
28 #include "titanic/support/font.h"
29 #include "titanic/input_handler.h"
30 #include "titanic/support/mouse_cursor.h"
31 #include "titanic/support/text_cursor.h"
32 #include "titanic/support/video_surface.h"
33 #include "titanic/core/resource_key.h"
34 
35 namespace Titanic {
36 
42 enum SurfaceNum {
43  SURFACE_PRIMARY = -1, // Surface 0
44  SURFACE_BACKBUFFER = -1 // Surface -1
45 };
46 
47 class TitanicEngine;
48 
50  struct VideoSurfaceEntry {
51  CVideoSurface *_surface;
52  Rect _bounds;
53  };
54 protected:
55  TitanicEngine *_vm;
56 public:
57  static CScreenManager *_screenManagerPtr;
58  static CScreenManager *_currentScreenManagerPtr;
59 
63  static CScreenManager *setCurrent();
64 public:
66  Rect _frontSurfaceBounds;
67  CVideoSurface *_frontRenderSurface;
68  CMouseCursor *_mouseCursor;
69  CTextCursor *_textCursor;
70  CInputHandler *_inputHandler;
71  int _fontNumber;
72 public:
74  virtual ~CScreenManager();
75 
76  void fn1() {}
77  void fn2() {}
78 
79  virtual void setWindowHandle(int v);
80  virtual bool resetWindowHandle(int v);
81 
85  virtual void setMode(int width, int height, int bpp, uint numBackSurfaces, bool flag2) = 0;
86 
90  virtual void drawCursors() = 0;
91 
95  virtual CVideoSurface *lockSurface(SurfaceNum surfaceNum) = 0;
96 
100  virtual void unlockSurface(CVideoSurface *surface) = 0;
101 
105  virtual CVideoSurface *getSurface(SurfaceNum surfaceNum) const = 0;
106 
110  virtual CVideoSurface *getFrontRenderSurface() const = 0;
111 
115  virtual void fillRect(SurfaceNum surfaceNum, Rect *rect, byte r, byte g, byte b) = 0;
116 
120  virtual void blitFrom(SurfaceNum surfaceNum, CVideoSurface *src, const Point *destPos = nullptr,
121  const Rect *srcRect = nullptr) = 0;
122 
126  virtual void blitFrom(SurfaceNum surfaceNum, const Rect *rect, CVideoSurface *src, int v = 0) = 0;
127 
137  virtual int writeString(int surfaceNum, const Rect &destRect,
138  int yOffset, const CString &str, CTextCursor *textCursor) = 0;
139 
148  virtual void writeString(int surfaceNum, const Point &destPos,
149  const Rect &clipRect, const CString &str, int maxWidth) = 0;
150 
154  virtual void setFontColor(byte r, byte g, byte b) = 0;
155 
163  virtual int getTextBounds(const CString &str, int maxWidth, Point *sizeOut = nullptr) const = 0;
164 
168  virtual int getFontHeight() const = 0;
169 
173  virtual int stringWidth(const CString &str) = 0;
174 
178  virtual void frameRect(SurfaceNum surfaceNum, const Rect &rect, byte r, byte g, byte b) = 0;
179 
183  virtual void clearSurface(SurfaceNum surfaceNum, Rect *_bounds) = 0;
184 
188  virtual void resizeSurface(CVideoSurface *surface, int width, int height, int bpp = 16) = 0;
189 
193  virtual CVideoSurface *createSurface(int w, int h, int bpp = 16) = 0;
194 
198  virtual CVideoSurface *createSurface(const CResourceKey &key) = 0;
199 
204  virtual Point getScreenTopLeft() { return Point(0, 0); }
205 
210  virtual void waitForVSync() {}
211 
215  virtual void showCursor() = 0;
216 
220  virtual void hideCursor() = 0;
221 
225  void setSurfaceBounds(SurfaceNum surfaceNum, const Rect &r);
226 
230  int setFontNumber(int fontNumber);
231 
235  void preLoad();
236 };
237 
239 private:
240  DirectDrawManager _directDrawManager;
241 
245  void destroyFrontAndBackBuffers();
246 
250  void loadCursors();
251 
255  DirectDrawSurface *getDDSurface(SurfaceNum surfaceNum);
256 public:
257  int _field48;
258  int _field4C;
259  int _field50;
260  int _field54;
261  STFont _fonts[4];
262 public:
264  ~OSScreenManager() override;
265 
269  void setMode(int width, int height, int bpp, uint numBackSurfaces, bool flag2) override;
270 
274  void drawCursors() override;
275 
279  CVideoSurface *lockSurface(SurfaceNum surfaceNum) override;
280 
284  void unlockSurface(CVideoSurface *surface) override;
285 
289  CVideoSurface *getSurface(SurfaceNum surfaceNum) const override;
290 
295  return _frontRenderSurface;
296  }
297 
298 
302  void fillRect(SurfaceNum surfaceNum, Rect *rect, byte r, byte g, byte b) override;
303 
307  void blitFrom(SurfaceNum surfaceNum, CVideoSurface *src, const Point *destPos,
308  const Rect *srcRect = nullptr) override;
309 
313  void blitFrom(SurfaceNum surfaceNum, const Rect *rect, CVideoSurface *src, int v = 0) override;
314 
324  int writeString(int surfaceNum, const Rect &destRect,
325  int yOffset, const CString &str, CTextCursor *textCursor) override;
326 
335  void writeString(int surfaceNum, const Point &destPos,
336  const Rect &clipRect, const CString &str, int lineWidth = 0) override;
337 
341  void setFontColor(byte r, byte g, byte b) override;
342 
350  int getTextBounds(const CString &str, int maxWidth, Point *sizeOut = nullptr) const override;
351 
355  int getFontHeight() const override;
356 
360  int stringWidth(const CString &str) override;
361 
365  void frameRect(SurfaceNum surfaceNum, const Rect &rect, byte r, byte g, byte b) override;
366 
370  void clearSurface(SurfaceNum surfaceNum, Rect *bounds) override;
371 
375  void resizeSurface(CVideoSurface *surface, int width, int height, int bpp = 16) override;
376 
380  CVideoSurface *createSurface(int w, int h, int bpp = 16) override;
381 
385  CVideoSurface *createSurface(const CResourceKey &key) override;
386 
390  void showCursor() override;
391 
395  void hideCursor() override;
396 };
397 
398 } // End of namespace Titanic
399 
400 #endif /* TITANIC_SCREEN_MANAGER_H */
Definition: font.h:42
Definition: resource_key.h:30
virtual void showCursor()=0
virtual void blitFrom(SurfaceNum surfaceNum, CVideoSurface *src, const Point *destPos=nullptr, const Rect *srcRect=nullptr)=0
virtual void resizeSurface(CVideoSurface *surface, int width, int height, int bpp=16)=0
virtual CVideoSurface * createSurface(int w, int h, int bpp=16)=0
void setSurfaceBounds(SurfaceNum surfaceNum, const Rect &r)
CVideoSurface * getFrontRenderSurface() const override
Definition: screen_manager.h:294
Definition: direct_draw_surface.h:45
virtual void waitForVSync()
Definition: screen_manager.h:210
virtual void setMode(int width, int height, int bpp, uint numBackSurfaces, bool flag2)=0
int setFontNumber(int fontNumber)
virtual int getFontHeight() const =0
virtual CVideoSurface * getSurface(SurfaceNum surfaceNum) const =0
virtual void hideCursor()=0
Definition: screen_manager.h:49
virtual void setFontColor(byte r, byte g, byte b)=0
virtual int stringWidth(const CString &str)=0
virtual void frameRect(SurfaceNum surfaceNum, const Rect &rect, byte r, byte g, byte b)=0
Definition: titanic.h:81
virtual int writeString(int surfaceNum, const Rect &destRect, int yOffset, const CString &str, CTextCursor *textCursor)=0
Definition: rect.h:35
Definition: rect.h:45
Definition: arm.h:30
virtual void clearSurface(SurfaceNum surfaceNum, Rect *_bounds)=0
Definition: string.h:40
Definition: text_cursor.h:33
Definition: input_handler.h:35
Definition: direct_draw.h:59
Definition: mouse_cursor.h:54
virtual int getTextBounds(const CString &str, int maxWidth, Point *sizeOut=nullptr) const =0
virtual CVideoSurface * lockSurface(SurfaceNum surfaceNum)=0
static CScreenManager * setCurrent()
Definition: screen_manager.h:238
virtual void fillRect(SurfaceNum surfaceNum, Rect *rect, byte r, byte g, byte b)=0
Definition: video_surface.h:43
virtual Point getScreenTopLeft()
Definition: screen_manager.h:204
virtual CVideoSurface * getFrontRenderSurface() const =0
virtual void drawCursors()=0
virtual void unlockSurface(CVideoSurface *surface)=0