Failed to connect up the `destroy' signal in error_box(), causing
[sgt/puzzles] / nullgame.c
1 /*
2 * nullgame.c [FIXME]: Template defining the null game (in which no
3 * moves are permitted and nothing is ever drawn). This file exists
4 * solely as a basis for constructing new game definitions - it
5 * helps to have something which will compile from the word go and
6 * merely doesn't _do_ very much yet.
7 *
8 * Parts labelled FIXME actually want _removing_ (e.g. the dummy
9 * field in each of the required data structures, and this entire
10 * comment itself) when converting this source file into one
11 * describing a real game.
12 */
13
14 #include <stdio.h>
15 #include <stdlib.h>
16 #include <string.h>
17 #include <assert.h>
18 #include <ctype.h>
19 #include <math.h>
20
21 #include "puzzles.h"
22
23 const char *const game_name = "Null Game";
24 const int game_can_configure = FALSE;
25
26 enum {
27 COL_BACKGROUND,
28 NCOLOURS
29 };
30
31 struct game_params {
32 int FIXME;
33 };
34
35 struct game_state {
36 int FIXME;
37 };
38
39 game_params *default_params(void)
40 {
41 game_params *ret = snew(game_params);
42
43 ret->FIXME = 0;
44
45 return ret;
46 }
47
48 int game_fetch_preset(int i, char **name, game_params **params)
49 {
50 return FALSE;
51 }
52
53 void free_params(game_params *params)
54 {
55 sfree(params);
56 }
57
58 game_params *dup_params(game_params *params)
59 {
60 game_params *ret = snew(game_params);
61 *ret = *params; /* structure copy */
62 return ret;
63 }
64
65 game_params *decode_params(char const *string)
66 {
67 game_params *ret = snew(game_params);
68
69 ret->FIXME = 0;
70
71 return ret;
72 }
73
74 char *encode_params(game_params *params)
75 {
76 return dupstr("FIXME");
77 }
78
79 config_item *game_configure(game_params *params)
80 {
81 return NULL;
82 }
83
84 game_params *custom_params(config_item *cfg)
85 {
86 return NULL;
87 }
88
89 char *validate_params(game_params *params)
90 {
91 return NULL;
92 }
93
94 char *new_game_seed(game_params *params, random_state *rs)
95 {
96 return dupstr("FIXME");
97 }
98
99 char *validate_seed(game_params *params, char *seed)
100 {
101 return NULL;
102 }
103
104 game_state *new_game(game_params *params, char *seed)
105 {
106 game_state *state = snew(game_state);
107
108 state->FIXME = 0;
109
110 return state;
111 }
112
113 game_state *dup_game(game_state *state)
114 {
115 game_state *ret = snew(game_state);
116
117 ret->FIXME = state->FIXME;
118
119 return ret;
120 }
121
122 void free_game(game_state *state)
123 {
124 sfree(state);
125 }
126
127 game_ui *new_ui(game_state *state)
128 {
129 return NULL;
130 }
131
132 void free_ui(game_ui *ui)
133 {
134 }
135
136 game_state *make_move(game_state *from, game_ui *ui, int x, int y, int button)
137 {
138 return NULL;
139 }
140
141 /* ----------------------------------------------------------------------
142 * Drawing routines.
143 */
144
145 struct game_drawstate {
146 int FIXME;
147 };
148
149 void game_size(game_params *params, int *x, int *y)
150 {
151 *x = *y = 200; /* FIXME */
152 }
153
154 float *game_colours(frontend *fe, game_state *state, int *ncolours)
155 {
156 float *ret = snewn(3 * NCOLOURS, float);
157
158 frontend_default_colour(fe, &ret[COL_BACKGROUND * 3]);
159
160 *ncolours = NCOLOURS;
161 return ret;
162 }
163
164 game_drawstate *game_new_drawstate(game_state *state)
165 {
166 struct game_drawstate *ds = snew(struct game_drawstate);
167
168 ds->FIXME = 0;
169
170 return ds;
171 }
172
173 void game_free_drawstate(game_drawstate *ds)
174 {
175 sfree(ds);
176 }
177
178 void game_redraw(frontend *fe, game_drawstate *ds, game_state *oldstate,
179 game_state *state, game_ui *ui,
180 float animtime, float flashtime)
181 {
182 /*
183 * The initial contents of the window are not guaranteed and
184 * can vary with front ends. To be on the safe side, all games
185 * should start by drawing a big background-colour rectangle
186 * covering the whole window.
187 */
188 draw_rect(fe, 0, 0, 200, 200, COL_BACKGROUND);
189 }
190
191 float game_anim_length(game_state *oldstate, game_state *newstate)
192 {
193 return 0.0F;
194 }
195
196 float game_flash_length(game_state *oldstate, game_state *newstate)
197 {
198 return 0.0F;
199 }
200
201 int game_wants_statusbar(void)
202 {
203 return FALSE;
204 }