1 /* Tower Toppler - Nebulus
2  * Copyright (C) 2000-2012  Andreas R�ver
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.  See the
12  * GNU General Public License for more details.
13 
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
17  */
18 
19 #ifndef SCREEN_H
20 #define SCREEN_H
21 
22 #include "archi.h"
23 #include "sprites.h"
24 
25 #include <SDL.h>
26 
27 /* this module handles nearly all the output onto the screen */
28 
29 /* screen flags for scr_drawall() */
30 typedef enum {
31     SF_NONE,
32     SF_REC,     /* display blinking "REC" */
33     SF_DEMO     /* display "DEMO" */
34 } screenflag;
35 
36 void scr_color_ramp(int *r, int *g, int *b);
37 
38 void scr_savedisplaybmp(char *fname);
39 
40 void scr_setclipping(int x = -1, int y = -1, int w = -1, int h = -1);
41 
42 /* initializes the module, loads the graphics, sets up the display */
43 void scr_init(void);
44 
45 /* call this when changing from windowed to fullscreen */
46 void scr_reinit(void);
47 
48 /* call this when the sprites need to be reloaded */
49 /* the flags for the sprites that need to be reloaded */
50 enum {
51   RL_FONT = 1,
52   RL_OBJECTS = 2,
53   RL_SCROLLER = 4
54 };
55 
56 void scr_reload_sprites(Uint8 what);
57 
58 
59 /* frees graphics */
60 void scr_done(void);
61 
62 /* loads a number of sprites, enters them into the sprite collection
63  and returns the index of the first sprite */
64 void scr_read_palette(file * fi, Uint8 *pal);
65 Uint16 scr_loadsprites(spritecontainer *spr, file * fi, int num, int w, int h, bool sprite, const Uint8 *pal, bool usealpha);
66 
67 
68 /* changes the colors of the slices, doors and battlement
69  */
70 void scr_settowercolor(Uint8 red, Uint8 green, Uint8 blue);
71 void scr_setcrosscolor(Uint8 red, Uint8 green, Uint8 blue);
72 
73 /* all paint routines paint onto an invisible surface, to show this surface
74  call scr_swap() */
75 
76 /* writes some text onto the screen */
77 void scr_writetext(long x, long y, const char *s, int maxchars = -1);
78 
79 /* centers the text horizontally */
80 void scr_writetext_center(long y, const char *s);
81 
82 /* like scr_writetext_center, but tries to break the lines of text so
83  * that they are not longer than the screen is wide
84  */
85 void scr_writetext_broken_center(long y, const char *s);
86 
87 /* output text that can be interleaved with commands. these commands
88  have the form ~ followed by letter followed by a fixed set of parameters.
89  currently the following command(s) are defined:
90 
91  t###: moves the x position to the given coordinate, relative to the
92        screen. The number must have 3 digits
93  T###: moves the x position to the given coordinate, relative to the
94        starting x position. The number must have 3 digits.
95  b#  : displays a tower block. The '#' is a character, as represented
96        in towerblockdata[].ch. Does NOT show robots.
97  e#  : displays tower blocks in level editor style. The '#' is a character,
98        as represented in towerblockdata[].ch.
99  */
100 void scr_writeformattext(long x, long y, const char *s);
101 /* returns the length of formatted text in pixels. */
102 long scr_formattextlength(long x, long y, const char *s);
103 
104 /* returns the number of pixels the first chars characters in
105  text needs in the display (if the string is only n chars long
106  then only n chars are calculated) */
107 int scr_textlength(const char *s, int chars = 32000);
108 
109 /* draws a filled rectangle with color col */
110 void scr_putbar(int x, int y, int br, int h, Uint8 colr, Uint8 colg, Uint8 col, Uint8 alpha);
111 
112 /* darkens all the pixels on the screen a bit */
113 void scr_darkenscreen(void);
114 
115 /* draws a rectangle */
116 void scr_putrect(int x, int y, int br, int h, Uint8 colr, Uint8 colg, Uint8 col, Uint8 alpha);
117 
118 /* put the drawing surface onto a visible surface */
119 void scr_swap(void);
120 
121 /* blits a sprite onto the invisible surface */
122 void scr_blit(SDL_Surface * s, int x, int y);
123 
124 /* draws everything necessary for the towergame */
125 void scr_drawall(long vert, long angle, long time, bool svisible, int subshape, int substart, screenflag flags);
126 
127 /* draws everything for the edit mode */
128 void scr_drawedit(long vert, long angle, bool showtime);
129 
130 /* draws the bonus game layers behind the tower */
131 void scr_draw_bonus1(long horiz, long towerpos);
132 
133 /* draws the bonus game layers before the tower */
134 void scr_draw_bonus2(long horiz, long towerpos);
135 
136 void scr_draw_submarine(long vert, long x, long number);
137 void scr_draw_fish(long vert, long x, long number);
138 void scr_draw_torpedo(long vert, long x);
139 
140 /* returns the number of robots in the currently loaded data set */
141 Uint8 scr_numrobots(void);
142 
143 #endif
144 
145