ScummVM API documentation
graphics.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 #ifndef STARTREK_GRAPHICS_H
22 #define STARTREK_GRAPHICS_H
23 
24 #include "startrek/bitmap.h"
25 #include "startrek/font.h"
26 #include "startrek/startrek.h"
27 #include "startrek/sprite.h"
28 
29 #include "common/ptr.h"
30 #include "common/rect.h"
31 #include "common/stream.h"
32 
33 using Common::SharedPtr;
34 using Common::String;
35 
36 namespace StarTrek {
37 
38 class Font;
39 class StarTrekEngine;
40 
41 
42 const int SCREEN_WIDTH = 320;
43 const int SCREEN_HEIGHT = 200;
44 
45 const int MAX_SPRITES = 32;
46 
47 
48 class Graphics {
49 public:
51  ~Graphics();
52 
53  void setBackgroundImage(Common::String imageName);
59  void drawBitmapToBackground(const Common::Rect &origRect, const Common::Rect &drawRect, Bitmap *bitmap);
60 
61  void fillBackgroundRect(const Common::Rect &rect, byte color);
62  byte *getBackgroundPixels();
63  byte *lockScreenPixels();
64  void unlockScreenPixels();
65 
66  void clearScreenAndPriBuffer();
70  void loadPalette(const String &paletteFile);
71  void copyRectBetweenBitmaps(Bitmap *destBitmap, int destX, int destY, Bitmap *srcBitmap, int srcX, int srcY, int width, int height);
72  void fadeinScreen();
73  void fadeoutScreen();
77  void setPaletteFadeLevel(byte *palData, int fadeLevel);
78  void incPaletteFadeLevel();
79  void decPaletteFadeLevel();
80 
81  void loadPri(const Common::String &priFile);
82  void clearPri();
83  void setPri(byte val);
84  byte getPriValue(int x, int y);
85 
86  Common::Point getMousePos();
91  void setMouseBitmap(Common::String bitmapName);
92  void popMouseBitmap();
93  void toggleMouse(bool visible);
94 
102  void lockMousePosition(int16 x, int16 y);
103  void unlockMousePosition();
104  void warpMouse(int16 x, int16 y);
105 
106  void drawSprite(const Sprite &sprite, ::Graphics::Surface *surface);
115  void drawSprite(const Sprite &sprite, ::Graphics::Surface *surface, const Common::Rect &rect, int rectLeft = 0, int rectTop = 0);
116  void drawAllSprites(bool updateScreenFlag = true);
121  void drawAllSpritesInRectToSurface(const Common::Rect &rect, ::Graphics::Surface *surface);
125  void forceDrawAllSprites(bool updateScreenFlag = true);
129  void updateScreen();
133  Sprite *getSpriteAt(int16 x, int16 y);
135  return getSpriteAt(p.x, p.y);
136  }
137 
138  void addSprite(Sprite *sprite);
139  void delSprite(Sprite *sprite);
140 
141  // Save/load the current state of sprites. Can only push once for now.
142  void pushSprites();
143  void popSprites();
144 
145  byte *getFontGfx(char c);
146 
147  void copyBackgroundScreen();
148  void loadEGAData(const char *egaFile);
149  void drawBackgroundImage(const char *filename);
150 
151 public:
152  Font *_font;
153 
154 private:
155  StarTrekEngine *_vm;
156 
157  bool _egaMode;
158  byte *_egaData;
159  byte *_palData;
160  byte *_lutData;
161  byte _priData[SCREEN_WIDTH * SCREEN_HEIGHT / 2];
162 
163  int16 _paletteFadeLevel;
164 
165  Common::Rect _screenRect;
166  Bitmap *_backgroundImage;
167 
168  Sprite *_sprites[MAX_SPRITES];
169  int _numSprites;
170 
171  // Analagous to above, used when pushing/popping
172  Sprite *_pushedSprites[MAX_SPRITES];
173  int _pushedNumSprites;
174 
175  Common::Point _lockedMousePos;
176 };
177 
178 } // End of namespace StarTrek
179 
180 #endif
Definition: str.h:59
Definition: surface.h:66
void lockMousePosition(int16 x, int16 y)
void loadPalette(const String &paletteFile)
Definition: rect.h:144
Definition: font.h:31
void forceDrawAllSprites(bool updateScreenFlag=true)
Definition: sprite.h:44
Definition: bitmap.h:31
void setPaletteFadeLevel(byte *palData, int fadeLevel)
void setMouseBitmap(Common::String bitmapName)
void drawBitmapToBackground(const Common::Rect &origRect, const Common::Rect &drawRect, Bitmap *bitmap)
Sprite * getSpriteAt(int16 x, int16 y)
Definition: formatinfo.h:28
Definition: rect.h:45
Definition: action.h:27
int16 x
Definition: rect.h:46
int16 y
Definition: rect.h:47
Definition: ptr.h:159
Definition: startrek.h:239
void drawAllSpritesInRectToSurface(const Common::Rect &rect, ::Graphics::Surface *surface)