author | andyq <andyq> | 2003-01-21 20:37:00 (UTC) |
---|---|---|
committer | andyq <andyq> | 2003-01-21 20:37:00 (UTC) |
commit | 0a6563fcc2f49857c581d9def24407a3a4ef526c (patch) (unidiff) | |
tree | f1b82a4bd7582ef2cb722cffb87eecff1e1f96e6 /noncore/games/sfcave-sdl/font.cpp | |
parent | 50b5915b48fc5cbacf23e4d2b75d7a266f141a4a (diff) | |
download | opie-0a6563fcc2f49857c581d9def24407a3a4ef526c.zip opie-0a6563fcc2f49857c581d9def24407a3a4ef526c.tar.gz opie-0a6563fcc2f49857c581d9def24407a3a4ef526c.tar.bz2 |
Clean up of code - fixed memory leaks (most of them) and added new custom config menu
Diffstat (limited to 'noncore/games/sfcave-sdl/font.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/games/sfcave-sdl/font.cpp | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/noncore/games/sfcave-sdl/font.cpp b/noncore/games/sfcave-sdl/font.cpp index 2976d48..1988252 100644 --- a/noncore/games/sfcave-sdl/font.cpp +++ b/noncore/games/sfcave-sdl/font.cpp | |||
@@ -1,52 +1,64 @@ | |||
1 | #include "font.h" | 1 | #include "font.h" |
2 | 2 | ||
3 | #include "constants.h" | 3 | #include "constants.h" |
4 | 4 | ||
5 | BFont *FontHandler :: menuSelFont; | 5 | BFont *FontHandler :: menuSelFont; |
6 | BFont *FontHandler :: menuUnSelFont; | 6 | BFont *FontHandler :: menuUnSelFont; |
7 | BFont *FontHandler :: whiteFont; | 7 | BFont *FontHandler :: whiteFont; |
8 | BFont *FontHandler :: colouredFont; | 8 | BFont *FontHandler :: colouredFont; |
9 | BFont *FontHandler :: helpFont; | 9 | BFont *FontHandler :: helpFont; |
10 | 10 | ||
11 | void FontHandler :: init() | 11 | bool FontHandler :: init() |
12 | { | 12 | { |
13 | // Load font images | 13 | // Load font images |
14 | // Convert to fonts | 14 | // Convert to fonts |
15 | menuSelFont = new BFont( IMAGES_PATH "sel_menu_font.bmp" ); | 15 | menuSelFont = new BFont( IMAGES_PATH "sel_menu_font.bmp" ); |
16 | menuUnSelFont = new BFont( IMAGES_PATH "unsel_menu_font.bmp" ); | 16 | menuUnSelFont = new BFont( IMAGES_PATH "unsel_menu_font.bmp" ); |
17 | whiteFont = new BFont( IMAGES_PATH "score_font.bmp" ); | 17 | whiteFont = new BFont( IMAGES_PATH "score_font.bmp" ); |
18 | helpFont = new BFont( IMAGES_PATH "help_font.bmp" ); | 18 | helpFont = new BFont( IMAGES_PATH "help_font.bmp" ); |
19 | colouredFont = 0; | 19 | colouredFont = 0; |
20 | |||
21 | // Check if we are installed correctly (we need fonts to function) | ||
22 | if ( menuSelFont == 0 || menuUnSelFont == 0 || whiteFont == 0 || helpFont == 0 ) | ||
23 | { | ||
24 | printf( "One or more fonts are not installed correctly\n" ); | ||
25 | return false; | ||
26 | } | ||
27 | |||
28 | return true; | ||
20 | } | 29 | } |
21 | 30 | ||
22 | void FontHandler :: cleanUp() | 31 | void FontHandler :: cleanUp() |
23 | { | 32 | { |
33 | if ( menuSelFont ) | ||
24 | delete menuSelFont; | 34 | delete menuSelFont; |
35 | if ( menuUnSelFont ) | ||
25 | delete menuUnSelFont; | 36 | delete menuUnSelFont; |
37 | if ( whiteFont ) | ||
26 | delete whiteFont; | 38 | delete whiteFont; |
39 | if ( helpFont ) | ||
27 | delete helpFont; | 40 | delete helpFont; |
28 | |||
29 | if ( colouredFont ) | 41 | if ( colouredFont ) |
30 | delete colouredFont; | 42 | delete colouredFont; |
31 | } | 43 | } |
32 | 44 | ||
33 | int FontHandler :: TextWidth( int font, const char *text ) | 45 | int FontHandler :: TextWidth( int font, const char *text ) |
34 | { | 46 | { |
35 | return getFont( font )->TextWidth( text ); | 47 | return getFont( font )->TextWidth( text ); |
36 | } | 48 | } |
37 | 49 | ||
38 | int FontHandler :: FontHeight( int font ) | 50 | int FontHandler :: FontHeight( int font ) |
39 | { | 51 | { |
40 | return getFont( font )->FontHeight(); | 52 | return getFont( font )->FontHeight(); |
41 | } | 53 | } |
42 | 54 | ||
43 | void FontHandler :: draw( SDL_Surface *screen, int font, const char *text, int x, int y ) | 55 | void FontHandler :: draw( SDL_Surface *screen, int font, const char *text, int x, int y ) |
44 | { | 56 | { |
45 | if ( x == -1 ) | 57 | if ( x == -1 ) |
46 | getFont( font )->CenteredPutString( screen, y, text ); | 58 | getFont( font )->CenteredPutString( screen, y, text ); |
47 | else | 59 | else |
48 | getFont( font )->PutString( screen, x, y, text ); | 60 | getFont( font )->PutString( screen, x, y, text ); |
49 | } | 61 | } |
50 | 62 | ||
51 | void FontHandler :: changeColor( int font, int r, int g, int b ) | 63 | void FontHandler :: changeColor( int font, int r, int g, int b ) |
52 | { | 64 | { |