]> git.mxchange.org Git - quix0rs-blobwars.git/blob - src/CGraphics.h
Don't link pak tool with SDL.
[quix0rs-blobwars.git] / src / CGraphics.h
1 /*
2 Copyright (C) 2004-2011 Parallel Realities
3
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
13 See the GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
18
19 */
20
21 class Graphics {
22
23         private:
24
25                 Engine *engine;
26                 SDL_Rect gRect;
27                 TTF_Font *font[5];
28                 SDL_Color fontForeground, fontBackground;
29
30                 List spriteList;
31
32                 int fontSize;
33                 
34                 int waterAnim;
35                 int slimeAnim;
36                 int lavaAnim;
37
38                 int currentLoading;
39
40                 int screenShotNumber;
41                 char screenshot[100];
42                 char chatString[1024];
43                 
44                 SDL_Surface *medalMessage;
45                 int medalMessageTimer;
46                 int medalType;
47
48                 SDL_Surface *fadeBlack;
49                 SDL_Surface *infoMessage;
50
51         public:
52                 struct SurfaceCache {
53                         char *text;
54                         SDL_Surface *surface;
55                         SurfaceCache(): text(NULL), surface(NULL) {}    
56                 };
57
58                 bool takeRandomScreenShots;
59
60                 SDL_Surface *screen, *background;
61                 SDL_Surface *tile[MAX_TILES];
62                 
63                 SDL_Surface *medal[4];
64                 SDL_Surface *license[2];
65                 
66                 SDL_Surface *infoBar;
67
68                 int red, yellow, green, darkGreen, skyBlue, blue, cyan, white, lightGrey, grey, darkGrey, black;
69
70         Graphics();
71         void free();
72         void destroy();
73         void registerEngine(Engine *engine);
74         void mapColors();
75         Sprite *getSpriteHead();
76         void setTransparent(SDL_Surface *sprite);
77         void updateScreen();
78         bool canShowMedalMessage() const;
79         void delay(int time);
80         void RGBtoHSV(float r, float g, float b, float *h, float *s, float *v);
81         void HSVtoRGB(float *r, float *g, float *b, float h, float s, float v);
82         SDL_Surface *loadImage(const char *filename, bool srcalpha = false);
83         SDL_Surface *loadImage(const char *filename, int hue, int sat, int value);
84         SDL_Surface *quickSprite(const char *name, SDL_Surface *image);
85         void fade(int amount);
86         void fadeToBlack();
87         void loadMapTiles(const char *baseDir);
88         void loadFont(int i, const char *filename, int pixelSize);
89         Sprite *addSprite(const char *name);
90         Sprite *getSprite(const char *name, bool required);
91         void animateSprites();
92         int getWaterAnim() const;
93         int getSlimeAnim() const;
94         int getLavaAnim() const;
95         int getLavaAnim(int current);
96         void loadBackground(const char *filename);
97         void putPixel(int x, int y, Uint32 pixel, SDL_Surface *dest);
98         Uint32 getPixel(SDL_Surface *surface, int x, int y);
99         void drawLine(float startX, float startY, float endX, float endY, int color, SDL_Surface *dest);
100         void blit(SDL_Surface *image, int x, int y, SDL_Surface *dest, bool centered);
101         void drawBackground();
102         void drawBackground(SDL_Rect *r);
103         void drawRect(int x, int y, int w, int h, int color, SDL_Surface *dest);
104         void drawRect(int x, int y, int w, int h, int color, int borderColor, SDL_Surface *dest);
105         void setFontColor(int red, int green, int blue, int red2, int green2, int blue2);
106         void setFontSize(int size);
107         SDL_Surface *getString(const char *in, bool transparent);
108         void drawString(const char *in, int x, int y, int alignment, SDL_Surface *dest);
109         void drawString(const char *in, int x, int y, int alignment, SDL_Surface *dest, SurfaceCache &cache);
110         void clearChatString();
111         void createChatString(const char *in);
112         void showMedalMessage(int type, const char *in);
113         void drawChatString(SDL_Surface *surface, int y);
114         void drawWidgetRect(int x, int y, int w, int h);
115         SDL_Surface *createSurface(int width, int height);
116         SDL_Surface *alphaRect(int width, int height, Uint8 red, Uint8 green, Uint8 blue);
117         void colorize(SDL_Surface *image, int red, int green, int blue);
118         void lock(SDL_Surface *surface);
119         void unlock(SDL_Surface *surface);
120         void resetLoading();
121         void showLoading(int amount, int max);
122         void showErrorAndExit(const char *error, const char *param);
123         void showLicenseErrorAndExit();
124         void showRootWarning();
125
126 };