1 /*
2  * Biloba
3  * Copyright (C) 2004-2008 Guillaume Demougeot, Colin Leroy
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
18  */
19 
20 #ifndef __UTILS_H__
21 #define __UTILS_H__
22 
23 #include <SDL.h>
24 #include <assert.h>
25 #include "llist.h"
26 #include "font.h"
27 
28 //#define DEBUG 1
29 
30 #define SDL_USEREVENT_QUIT    (SDL_USEREVENT + 0)
31 #define SDL_USEREVENT_REFRESH (SDL_USEREVENT + 1)
32 
33 #ifndef FALSE
34 #define FALSE 0
35 #endif
36 #ifndef TRUE
37 #define TRUE 1
38 #endif
39 
40 #ifndef MAEMO
41 #define FLAGS (SDL_HWSURFACE | SDL_DOUBLEBUF)
42 #define XS    800
43 #define YS    600
44 #define X_OFFSET 150
45 #define Y_OFFSET 50
46 #else
47 #define FLAGS (SDL_HWSURFACE | SDL_DOUBLEBUF | SDL_FULLSCREEN)
48 #define XS    800
49 #define YS    480
50 #define X_OFFSET 150
51 #define Y_OFFSET 5
52 #endif
53 
54 #define BPP   16
55 
56 #define PAWN_OFFSET 10
57 #define ARROW_OFFSET_FROM_CENTER 15
58 #define G_MSG_X 65
59 #define G_MSG_Y (YS - 25)
60 
61 #define G_TALK_X 65
62 #define G_TALK_Y (YS - 45)
63 #define MAX_MSG_LEN (((XS -  G_TALK_X) / CHARWIDTH) - 2)
64 
65 #define HELP_X 10
66 #define HELP_Y 10
67 #define MAX_TILES_X 9
68 #define MAX_TILES_Y 9
69 
70 #ifndef __MINGW32__
71 #ifndef MYDATADIR
72 #define PREFIX "."
73 #else
74 #define PREFIX MYDATADIR
75 #endif
76 #define DIR_SEP "/"
77 #else
78 #define PREFIX "."
79 #define DIR_SEP "\\"
80 #endif
81 
82 #define PLAYER_NAME_LEN	32
83 #define GAME_NAME_LEN 	32
84 #define SERVER_LEN 	64
85 #define SAVED_LEN	256
86 
87 extern char *progpath;
88 extern char *langpath;
89 
90 SDL_Surface * screen;
91 
92 int get_x(int x);
93 int get_y(int y);
94 
95 void put_image(SDL_Surface *surface, int x, int y);
96 
97 int should_quit(void);
98 void game_init(int bool);
99 int game_inited(void);
100 void game_suspend(int bool);
101 int game_suspended(void);
102 int game_num_players(void);
103 int game_num_net_players(void);
104 void set_num_players(int num);
105 
106 #ifndef min
107 int min (int a, int b);
108 #endif
109 #ifndef max
110 int max (int a, int b);
111 #endif
112 int is_in_box(int x, int y, int a, int b, int c, int d);
113 
114 void set_playing(int playing);
115 int is_playing(void);
116 
117 SDL_Event get_sdl_event(int event_type);
118 
119 SDL_Surface *biloba_load_image(const char *name);
120 
121 void set_language(void);
122 int event_poll(void);
123 int handle_generic_event(SDL_Event *event);
124 int delay_with_event_poll(int msec_timeout);
125 
126 const char *get_desktop_folder(void);
127 const char *get_home_folder(void);
128 int folder_exists(const char *folder);
129 #ifdef MAEMO
130 void SetWMName(const char *name, int is_fullscreen);
131 #endif
132 
133 #endif
134