diff options
author | Franklin Wei <git@fwei.tk> | 2017-10-23 17:19:29 -0400 |
---|---|---|
committer | Franklin Wei <git@fwei.tk> | 2017-10-23 17:19:29 -0400 |
commit | ef1306764e6443d67612542654f252b376c5993e (patch) | |
tree | 5f064178c1f9a23695b1b52b8bd487434be9006e /apps/plugins/puzzles/src/puzzles.h | |
parent | 7a8c9daf7ef5a8b38d4c4f6625ff2d9d8eb1aa0a (diff) | |
download | rockbox-ef1306764e6443d67612542654f252b376c5993e.tar.gz rockbox-ef1306764e6443d67612542654f252b376c5993e.zip |
puzzles: resync with upstream
There have been some improvements with regard to small screen sizes,
which will be nice to have.
Change-Id: I30c740514156258d2818fde325c1a751500f7611
Diffstat (limited to 'apps/plugins/puzzles/src/puzzles.h')
-rw-r--r-- | apps/plugins/puzzles/src/puzzles.h | 106 |
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 | */ |
138 | enum { C_STRING, C_CHOICES, C_BOOLEAN, C_END }; | 138 | enum { C_STRING, C_CHOICES, C_BOOLEAN, C_END }; |
139 | struct config_item { | 139 | struct 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) |
221 | void debug_printf(char *fmt, ...); | 227 | void debug_printf(const char *fmt, ...); |
222 | #else | 228 | #else |
223 | #define debug(x) | 229 | #define debug(x) |
224 | #endif | 230 | #endif |
225 | 231 | ||
226 | void fatal(char *fmt, ...); | 232 | void fatal(const char *fmt, ...); |
227 | void frontend_default_colour(frontend *fe, float *output); | 233 | void frontend_default_colour(frontend *fe, float *output); |
228 | void deactivate_timer(frontend *fe); | 234 | void deactivate_timer(frontend *fe); |
229 | void activate_timer(frontend *fe); | 235 | void activate_timer(frontend *fe); |
@@ -235,7 +241,7 @@ void get_random_seed(void **randseed, int *randseedsize); | |||
235 | drawing *drawing_new(const drawing_api *api, midend *me, void *handle); | 241 | drawing *drawing_new(const drawing_api *api, midend *me, void *handle); |
236 | void drawing_free(drawing *dr); | 242 | void drawing_free(drawing *dr); |
237 | void draw_text(drawing *dr, int x, int y, int fonttype, int fontsize, | 243 | void 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); |
239 | void draw_rect(drawing *dr, int x, int y, int w, int h, int colour); | 245 | void draw_rect(drawing *dr, int x, int y, int w, int h, int colour); |
240 | void draw_line(drawing *dr, int x1, int y1, int x2, int y2, int colour); | 246 | void draw_line(drawing *dr, int x1, int y1, int x2, int y2, int colour); |
241 | void draw_polygon(drawing *dr, int *coords, int npoints, | 247 | void draw_polygon(drawing *dr, int *coords, int npoints, |
@@ -250,7 +256,7 @@ void start_draw(drawing *dr); | |||
250 | void draw_update(drawing *dr, int x, int y, int w, int h); | 256 | void draw_update(drawing *dr, int x, int y, int w, int h); |
251 | void end_draw(drawing *dr); | 257 | void end_draw(drawing *dr); |
252 | char *text_fallback(drawing *dr, const char *const *strings, int nstrings); | 258 | char *text_fallback(drawing *dr, const char *const *strings, int nstrings); |
253 | void status_bar(drawing *dr, char *text); | 259 | void status_bar(drawing *dr, const char *text); |
254 | blitter *blitter_new(drawing *dr, int w, int h); | 260 | blitter *blitter_new(drawing *dr, int w, int h); |
255 | void blitter_free(drawing *dr, blitter *bl); | 261 | void 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); | |||
305 | int midend_wants_statusbar(midend *me); | 311 | int midend_wants_statusbar(midend *me); |
306 | enum { CFG_SETTINGS, CFG_SEED, CFG_DESC, CFG_FRONTEND_SPECIFIC }; | 312 | enum { CFG_SETTINGS, CFG_SEED, CFG_DESC, CFG_FRONTEND_SPECIFIC }; |
307 | config_item *midend_get_config(midend *me, int which, char **wintitle); | 313 | config_item *midend_get_config(midend *me, int which, char **wintitle); |
308 | char *midend_set_config(midend *me, int which, config_item *cfg); | 314 | const char *midend_set_config(midend *me, int which, config_item *cfg); |
309 | char *midend_game_id(midend *me, char *id); | 315 | const char *midend_game_id(midend *me, const char *id); |
310 | char *midend_get_game_id(midend *me); | 316 | char *midend_get_game_id(midend *me); |
311 | char *midend_get_random_seed(midend *me); | 317 | char *midend_get_random_seed(midend *me); |
312 | int midend_can_format_as_text_now(midend *me); | 318 | int midend_can_format_as_text_now(midend *me); |
313 | char *midend_text_format(midend *me); | 319 | char *midend_text_format(midend *me); |
314 | char *midend_solve(midend *me); | 320 | const char *midend_solve(midend *me); |
315 | int midend_status(midend *me); | 321 | int midend_status(midend *me); |
316 | int midend_can_undo(midend *me); | 322 | int midend_can_undo(midend *me); |
317 | int midend_can_redo(midend *me); | 323 | int midend_can_redo(midend *me); |
318 | void midend_supersede_game_desc(midend *me, char *desc, char *privdesc); | 324 | void midend_supersede_game_desc(midend *me, const char *desc, |
319 | char *midend_rewrite_statusbar(midend *me, char *text); | 325 | const char *privdesc); |
326 | char *midend_rewrite_statusbar(midend *me, const char *text); | ||
320 | void midend_serialise(midend *me, | 327 | void 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); |
323 | char *midend_deserialise(midend *me, | 330 | const 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); |
326 | char *identify_game(char **name, int (*read)(void *ctx, void *buf, int len), | 333 | const char *identify_game(char **name, |
327 | void *rctx); | 334 | int (*read)(void *ctx, void *buf, int len), |
335 | void *rctx); | ||
328 | void midend_request_id_changes(midend *me, void (*notify)(void *), void *ctx); | 336 | void 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 */ |
330 | char *midend_print_puzzle(midend *me, document *doc, int with_soln); | 338 | const char *midend_print_puzzle(midend *me, document *doc, int with_soln); |
331 | int midend_tilesize(midend *me); | 339 | int 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. */ |
386 | void draw_text_outline(drawing *dr, int x, int y, int fonttype, | 394 | void 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 | */ |
643 | struct drawing_api { | 651 | struct 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; | |||
688 | extern const game thegame; | 696 | extern 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 | */ | ||
705 | extern 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 | ||