summaryrefslogtreecommitdiff
path: root/apps/plugins/puzzles/src/puzzles.h
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/puzzles/src/puzzles.h')
-rw-r--r--apps/plugins/puzzles/src/puzzles.h106
1 files changed, 61 insertions, 45 deletions
diff --git a/apps/plugins/puzzles/src/puzzles.h b/apps/plugins/puzzles/src/puzzles.h
index 73b31ea7f9..47f4b7edd5 100644
--- a/apps/plugins/puzzles/src/puzzles.h
+++ b/apps/plugins/puzzles/src/puzzles.h
@@ -137,30 +137,36 @@ typedef struct psdata psdata;
137 */ 137 */
138enum { C_STRING, C_CHOICES, C_BOOLEAN, C_END }; 138enum { C_STRING, C_CHOICES, C_BOOLEAN, C_END };
139struct config_item { 139struct config_item {
140 /* 140 /* Not dynamically allocated */
141 * `name' is never dynamically allocated. 141 const char *name;
142 */ 142 /* Value from the above C_* enum */
143 char *name;
144 /*
145 * `type' contains one of the above values.
146 */
147 int type; 143 int type;
148 /* 144 union {
149 * For C_STRING, `sval' is always dynamically allocated and 145 struct { /* if type == C_STRING */
150 * non-NULL. For C_BOOLEAN and C_END, `sval' is always NULL. 146 /* Always dynamically allocated and non-NULL */
151 * For C_CHOICES, `sval' is non-NULL, _not_ dynamically 147 char *sval;
152 * allocated, and contains a set of option strings separated by 148 } string;
153 * a delimiter. The delimeter is also the first character in 149 struct { /* if type == C_CHOICES */
154 * the string, so for example ":Foo:Bar:Baz" gives three 150 /*
155 * options `Foo', `Bar' and `Baz'. 151 * choicenames is non-NULL, not dynamically allocated, and
156 */ 152 * contains a set of option strings separated by a
157 char *sval; 153 * delimiter. The delimiter is also the first character in
158 /* 154 * the string, so for example ":Foo:Bar:Baz" gives three
159 * For C_BOOLEAN, this is TRUE or FALSE. For C_CHOICES, it 155 * options `Foo', `Bar' and `Baz'.
160 * indicates the chosen index from the `sval' list. In the 156 */
161 * above example, 0==Foo, 1==Bar and 2==Baz. 157 const char *choicenames;
162 */ 158 /*
163 int ival; 159 * Indicates the chosen index from the options in
160 * choicenames. In the above example, 0==Foo, 1==Bar and
161 * 2==Baz.
162 */
163 int selected;
164 } choices;
165 struct {
166 /* just TRUE or FALSE */
167 int bval;
168 } boolean;
169 } u;
164}; 170};
165 171
166/* 172/*
@@ -218,12 +224,12 @@ game_params *preset_menu_lookup_by_id(struct preset_menu *menu, int id);
218/* We can't use #ifdef DEBUG, because Cygwin defines it by default. */ 224/* We can't use #ifdef DEBUG, because Cygwin defines it by default. */
219#ifdef DEBUGGING 225#ifdef DEBUGGING
220#define debug(x) (debug_printf x) 226#define debug(x) (debug_printf x)
221void debug_printf(char *fmt, ...); 227void debug_printf(const char *fmt, ...);
222#else 228#else
223#define debug(x) 229#define debug(x)
224#endif 230#endif
225 231
226void fatal(char *fmt, ...); 232void fatal(const char *fmt, ...);
227void frontend_default_colour(frontend *fe, float *output); 233void frontend_default_colour(frontend *fe, float *output);
228void deactivate_timer(frontend *fe); 234void deactivate_timer(frontend *fe);
229void activate_timer(frontend *fe); 235void activate_timer(frontend *fe);
@@ -235,7 +241,7 @@ void get_random_seed(void **randseed, int *randseedsize);
235drawing *drawing_new(const drawing_api *api, midend *me, void *handle); 241drawing *drawing_new(const drawing_api *api, midend *me, void *handle);
236void drawing_free(drawing *dr); 242void drawing_free(drawing *dr);
237void draw_text(drawing *dr, int x, int y, int fonttype, int fontsize, 243void draw_text(drawing *dr, int x, int y, int fonttype, int fontsize,
238 int align, int colour, char *text); 244 int align, int colour, const char *text);
239void draw_rect(drawing *dr, int x, int y, int w, int h, int colour); 245void draw_rect(drawing *dr, int x, int y, int w, int h, int colour);
240void draw_line(drawing *dr, int x1, int y1, int x2, int y2, int colour); 246void draw_line(drawing *dr, int x1, int y1, int x2, int y2, int colour);
241void draw_polygon(drawing *dr, int *coords, int npoints, 247void draw_polygon(drawing *dr, int *coords, int npoints,
@@ -250,7 +256,7 @@ void start_draw(drawing *dr);
250void draw_update(drawing *dr, int x, int y, int w, int h); 256void draw_update(drawing *dr, int x, int y, int w, int h);
251void end_draw(drawing *dr); 257void end_draw(drawing *dr);
252char *text_fallback(drawing *dr, const char *const *strings, int nstrings); 258char *text_fallback(drawing *dr, const char *const *strings, int nstrings);
253void status_bar(drawing *dr, char *text); 259void status_bar(drawing *dr, const char *text);
254blitter *blitter_new(drawing *dr, int w, int h); 260blitter *blitter_new(drawing *dr, int w, int h);
255void blitter_free(drawing *dr, blitter *bl); 261void blitter_free(drawing *dr, blitter *bl);
256/* save puts the portion of the current display with top-left corner 262/* save puts the portion of the current display with top-left corner
@@ -305,29 +311,31 @@ int midend_which_preset(midend *me);
305int midend_wants_statusbar(midend *me); 311int midend_wants_statusbar(midend *me);
306enum { CFG_SETTINGS, CFG_SEED, CFG_DESC, CFG_FRONTEND_SPECIFIC }; 312enum { CFG_SETTINGS, CFG_SEED, CFG_DESC, CFG_FRONTEND_SPECIFIC };
307config_item *midend_get_config(midend *me, int which, char **wintitle); 313config_item *midend_get_config(midend *me, int which, char **wintitle);
308char *midend_set_config(midend *me, int which, config_item *cfg); 314const char *midend_set_config(midend *me, int which, config_item *cfg);
309char *midend_game_id(midend *me, char *id); 315const char *midend_game_id(midend *me, const char *id);
310char *midend_get_game_id(midend *me); 316char *midend_get_game_id(midend *me);
311char *midend_get_random_seed(midend *me); 317char *midend_get_random_seed(midend *me);
312int midend_can_format_as_text_now(midend *me); 318int midend_can_format_as_text_now(midend *me);
313char *midend_text_format(midend *me); 319char *midend_text_format(midend *me);
314char *midend_solve(midend *me); 320const char *midend_solve(midend *me);
315int midend_status(midend *me); 321int midend_status(midend *me);
316int midend_can_undo(midend *me); 322int midend_can_undo(midend *me);
317int midend_can_redo(midend *me); 323int midend_can_redo(midend *me);
318void midend_supersede_game_desc(midend *me, char *desc, char *privdesc); 324void midend_supersede_game_desc(midend *me, const char *desc,
319char *midend_rewrite_statusbar(midend *me, char *text); 325 const char *privdesc);
326char *midend_rewrite_statusbar(midend *me, const char *text);
320void midend_serialise(midend *me, 327void midend_serialise(midend *me,
321 void (*write)(void *ctx, void *buf, int len), 328 void (*write)(void *ctx, const void *buf, int len),
322 void *wctx); 329 void *wctx);
323char *midend_deserialise(midend *me, 330const char *midend_deserialise(midend *me,
324 int (*read)(void *ctx, void *buf, int len), 331 int (*read)(void *ctx, void *buf, int len),
325 void *rctx); 332 void *rctx);
326char *identify_game(char **name, int (*read)(void *ctx, void *buf, int len), 333const char *identify_game(char **name,
327 void *rctx); 334 int (*read)(void *ctx, void *buf, int len),
335 void *rctx);
328void midend_request_id_changes(midend *me, void (*notify)(void *), void *ctx); 336void midend_request_id_changes(midend *me, void (*notify)(void *), void *ctx);
329/* Printing functions supplied by the mid-end */ 337/* Printing functions supplied by the mid-end */
330char *midend_print_puzzle(midend *me, document *doc, int with_soln); 338const char *midend_print_puzzle(midend *me, document *doc, int with_soln);
331int midend_tilesize(midend *me); 339int midend_tilesize(midend *me);
332 340
333/* 341/*
@@ -385,7 +393,7 @@ void pos2c(int w, int h, int pos, int *cx, int *cy);
385 * by one pixel; useful for highlighting. Outline is omitted if -1. */ 393 * by one pixel; useful for highlighting. Outline is omitted if -1. */
386void draw_text_outline(drawing *dr, int x, int y, int fonttype, 394void draw_text_outline(drawing *dr, int x, int y, int fonttype,
387 int fontsize, int align, 395 int fontsize, int align,
388 int text_colour, int outline_colour, char *text); 396 int text_colour, int outline_colour, const char *text);
389 397
390/* Copies text left-justified with spaces. Length of string must be 398/* Copies text left-justified with spaces. Length of string must be
391 * less than buffer size. */ 399 * less than buffer size. */
@@ -587,17 +595,17 @@ struct game {
587 int can_configure; 595 int can_configure;
588 config_item *(*configure)(const game_params *params); 596 config_item *(*configure)(const game_params *params);
589 game_params *(*custom_params)(const config_item *cfg); 597 game_params *(*custom_params)(const config_item *cfg);
590 char *(*validate_params)(const game_params *params, int full); 598 const char *(*validate_params)(const game_params *params, int full);
591 char *(*new_desc)(const game_params *params, random_state *rs, 599 char *(*new_desc)(const game_params *params, random_state *rs,
592 char **aux, int interactive); 600 char **aux, int interactive);
593 char *(*validate_desc)(const game_params *params, const char *desc); 601 const char *(*validate_desc)(const game_params *params, const char *desc);
594 game_state *(*new_game)(midend *me, const game_params *params, 602 game_state *(*new_game)(midend *me, const game_params *params,
595 const char *desc); 603 const char *desc);
596 game_state *(*dup_game)(const game_state *state); 604 game_state *(*dup_game)(const game_state *state);
597 void (*free_game)(game_state *state); 605 void (*free_game)(game_state *state);
598 int can_solve; 606 int can_solve;
599 char *(*solve)(const game_state *orig, const game_state *curr, 607 char *(*solve)(const game_state *orig, const game_state *curr,
600 const char *aux, char **error); 608 const char *aux, const char **error);
601 int can_format_as_text_ever; 609 int can_format_as_text_ever;
602 int (*can_format_as_text_now)(const game_params *params); 610 int (*can_format_as_text_now)(const game_params *params);
603 char *(*text_format)(const game_state *state); 611 char *(*text_format)(const game_state *state);
@@ -642,7 +650,7 @@ struct game {
642 */ 650 */
643struct drawing_api { 651struct drawing_api {
644 void (*draw_text)(void *handle, int x, int y, int fonttype, int fontsize, 652 void (*draw_text)(void *handle, int x, int y, int fonttype, int fontsize,
645 int align, int colour, char *text); 653 int align, int colour, const char *text);
646 void (*draw_rect)(void *handle, int x, int y, int w, int h, int colour); 654 void (*draw_rect)(void *handle, int x, int y, int w, int h, int colour);
647 void (*draw_line)(void *handle, int x1, int y1, int x2, int y2, 655 void (*draw_line)(void *handle, int x1, int y1, int x2, int y2,
648 int colour); 656 int colour);
@@ -655,7 +663,7 @@ struct drawing_api {
655 void (*unclip)(void *handle); 663 void (*unclip)(void *handle);
656 void (*start_draw)(void *handle); 664 void (*start_draw)(void *handle);
657 void (*end_draw)(void *handle); 665 void (*end_draw)(void *handle);
658 void (*status_bar)(void *handle, char *text); 666 void (*status_bar)(void *handle, const char *text);
659 blitter *(*blitter_new)(void *handle, int w, int h); 667 blitter *(*blitter_new)(void *handle, int w, int h);
660 void (*blitter_free)(void *handle, blitter *bl); 668 void (*blitter_free)(void *handle, blitter *bl);
661 void (*blitter_save)(void *handle, blitter *bl, int x, int y); 669 void (*blitter_save)(void *handle, blitter *bl, int x, int y);
@@ -688,6 +696,14 @@ extern const int gamecount;
688extern const game thegame; 696extern const game thegame;
689#endif 697#endif
690 698
699/*
700 * Special string value to return from interpret_move in the case
701 * where the game UI has been updated but no actual move is being
702 * appended to the undo chain. Must be declared as a non-const char,
703 * but should never actually be modified by anyone.
704 */
705extern char UI_UPDATE[];
706
691/* A little bit of help to lazy developers */ 707/* A little bit of help to lazy developers */
692#define DEFAULT_STATUSBAR_TEXT "Use status_bar() to fill this in." 708#define DEFAULT_STATUSBAR_TEXT "Use status_bar() to fill this in."
693 709