Document the new --game and --load options on Unix.
[sgt/puzzles] / nullgame.c
... / ...
CommitLineData
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
23enum {
24 COL_BACKGROUND,
25 NCOLOURS
26};
27
28struct game_params {
29 int FIXME;
30};
31
32struct game_state {
33 int FIXME;
34};
35
36static game_params *default_params(void)
37{
38 game_params *ret = snew(game_params);
39
40 ret->FIXME = 0;
41
42 return ret;
43}
44
45static int game_fetch_preset(int i, char **name, game_params **params)
46{
47 return FALSE;
48}
49
50static void free_params(game_params *params)
51{
52 sfree(params);
53}
54
55static game_params *dup_params(game_params *params)
56{
57 game_params *ret = snew(game_params);
58 *ret = *params; /* structure copy */
59 return ret;
60}
61
62static void decode_params(game_params *params, char const *string)
63{
64}
65
66static char *encode_params(game_params *params, int full)
67{
68 return dupstr("FIXME");
69}
70
71static config_item *game_configure(game_params *params)
72{
73 return NULL;
74}
75
76static game_params *custom_params(config_item *cfg)
77{
78 return NULL;
79}
80
81static char *validate_params(game_params *params, int full)
82{
83 return NULL;
84}
85
86static char *new_game_desc(game_params *params, random_state *rs,
87 char **aux, int interactive)
88{
89 return dupstr("FIXME");
90}
91
92static char *validate_desc(game_params *params, char *desc)
93{
94 return NULL;
95}
96
97static game_state *new_game(midend *me, game_params *params, char *desc)
98{
99 game_state *state = snew(game_state);
100
101 state->FIXME = 0;
102
103 return state;
104}
105
106static game_state *dup_game(game_state *state)
107{
108 game_state *ret = snew(game_state);
109
110 ret->FIXME = state->FIXME;
111
112 return ret;
113}
114
115static void free_game(game_state *state)
116{
117 sfree(state);
118}
119
120static char *solve_game(game_state *state, game_state *currstate,
121 char *aux, char **error)
122{
123 return NULL;
124}
125
126static char *game_text_format(game_state *state)
127{
128 return NULL;
129}
130
131static game_ui *new_ui(game_state *state)
132{
133 return NULL;
134}
135
136static void free_ui(game_ui *ui)
137{
138}
139
140static char *encode_ui(game_ui *ui)
141{
142 return NULL;
143}
144
145static void decode_ui(game_ui *ui, char *encoding)
146{
147}
148
149static void game_changed_state(game_ui *ui, game_state *oldstate,
150 game_state *newstate)
151{
152}
153
154struct game_drawstate {
155 int tilesize;
156 int FIXME;
157};
158
159static char *interpret_move(game_state *state, game_ui *ui, game_drawstate *ds,
160 int x, int y, int button)
161{
162 return NULL;
163}
164
165static game_state *execute_move(game_state *state, char *move)
166{
167 return NULL;
168}
169
170/* ----------------------------------------------------------------------
171 * Drawing routines.
172 */
173
174static void game_compute_size(game_params *params, int tilesize,
175 int *x, int *y)
176{
177 *x = *y = 10 * tilesize; /* FIXME */
178}
179
180static void game_set_size(drawing *dr, game_drawstate *ds,
181 game_params *params, int tilesize)
182{
183 ds->tilesize = tilesize;
184}
185
186static float *game_colours(frontend *fe, int *ncolours)
187{
188 float *ret = snewn(3 * NCOLOURS, float);
189
190 frontend_default_colour(fe, &ret[COL_BACKGROUND * 3]);
191
192 *ncolours = NCOLOURS;
193 return ret;
194}
195
196static game_drawstate *game_new_drawstate(drawing *dr, game_state *state)
197{
198 struct game_drawstate *ds = snew(struct game_drawstate);
199
200 ds->tilesize = 0;
201 ds->FIXME = 0;
202
203 return ds;
204}
205
206static void game_free_drawstate(drawing *dr, game_drawstate *ds)
207{
208 sfree(ds);
209}
210
211static void game_redraw(drawing *dr, game_drawstate *ds, game_state *oldstate,
212 game_state *state, int dir, game_ui *ui,
213 float animtime, float flashtime)
214{
215 /*
216 * The initial contents of the window are not guaranteed and
217 * can vary with front ends. To be on the safe side, all games
218 * should start by drawing a big background-colour rectangle
219 * covering the whole window.
220 */
221 draw_rect(dr, 0, 0, 10*ds->tilesize, 10*ds->tilesize, COL_BACKGROUND);
222}
223
224static float game_anim_length(game_state *oldstate, game_state *newstate,
225 int dir, game_ui *ui)
226{
227 return 0.0F;
228}
229
230static float game_flash_length(game_state *oldstate, game_state *newstate,
231 int dir, game_ui *ui)
232{
233 return 0.0F;
234}
235
236static int game_timing_state(game_state *state, game_ui *ui)
237{
238 return TRUE;
239}
240
241static void game_print_size(game_params *params, float *x, float *y)
242{
243}
244
245static void game_print(drawing *dr, game_state *state, int tilesize)
246{
247}
248
249#ifdef COMBINED
250#define thegame nullgame
251#endif
252
253const struct game thegame = {
254 "Null Game", NULL, NULL,
255 default_params,
256 game_fetch_preset,
257 decode_params,
258 encode_params,
259 free_params,
260 dup_params,
261 FALSE, game_configure, custom_params,
262 validate_params,
263 new_game_desc,
264 validate_desc,
265 new_game,
266 dup_game,
267 free_game,
268 FALSE, solve_game,
269 FALSE, game_text_format,
270 new_ui,
271 free_ui,
272 encode_ui,
273 decode_ui,
274 game_changed_state,
275 interpret_move,
276 execute_move,
277 20 /* FIXME */, game_compute_size, game_set_size,
278 game_colours,
279 game_new_drawstate,
280 game_free_drawstate,
281 game_redraw,
282 game_anim_length,
283 game_flash_length,
284 FALSE, FALSE, game_print_size, game_print,
285 FALSE, /* wants_statusbar */
286 FALSE, game_timing_state,
287 0, /* flags */
288};