From ef1306764e6443d67612542654f252b376c5993e Mon Sep 17 00:00:00 2001 From: Franklin Wei Date: Mon, 23 Oct 2017 17:19:29 -0400 Subject: puzzles: resync with upstream There have been some improvements with regard to small screen sizes, which will be nice to have. Change-Id: I30c740514156258d2818fde325c1a751500f7611 --- apps/plugins/puzzles/src/emcc.c | 47 +++++++++++++++++++++++++++++------------ 1 file changed, 33 insertions(+), 14 deletions(-) (limited to 'apps/plugins/puzzles/src/emcc.c') diff --git a/apps/plugins/puzzles/src/emcc.c b/apps/plugins/puzzles/src/emcc.c index 23ab333f5d..563fbe2799 100644 --- a/apps/plugins/puzzles/src/emcc.c +++ b/apps/plugins/puzzles/src/emcc.c @@ -122,7 +122,7 @@ void get_random_seed(void **randseed, int *randseedsize) * Fatal error, called in cases of complete despair such as when * malloc() has returned NULL. */ -void fatal(char *fmt, ...) +void fatal(const char *fmt, ...) { char buf[512]; va_list ap; @@ -136,7 +136,7 @@ void fatal(char *fmt, ...) js_error_box(buf); } -void debug_printf(char *fmt, ...) +void debug_printf(const char *fmt, ...) { char buf[512]; va_list ap; @@ -384,7 +384,8 @@ static void js_unclip(void *handle) } static void js_draw_text(void *handle, int x, int y, int fonttype, - int fontsize, int align, int colour, char *text) + int fontsize, int align, int colour, + const char *text) { char fontstyle[80]; int halign; @@ -515,7 +516,7 @@ static void js_end_draw(void *handle) js_canvas_end_draw(); } -static void js_status_bar(void *handle, char *text) +static void js_status_bar(void *handle, const char *text) { js_canvas_set_statusbar(text); } @@ -599,13 +600,14 @@ static void cfg_start(int which) for (i = 0; cfg[i].type != C_END; i++) { switch (cfg[i].type) { case C_STRING: - js_dialog_string(i, cfg[i].name, cfg[i].sval); + js_dialog_string(i, cfg[i].name, cfg[i].u.string.sval); break; case C_BOOLEAN: - js_dialog_boolean(i, cfg[i].name, cfg[i].ival); + js_dialog_boolean(i, cfg[i].name, cfg[i].u.boolean.bval); break; case C_CHOICES: - js_dialog_choices(i, cfg[i].name, cfg[i].sval, cfg[i].ival); + js_dialog_choices(i, cfg[i].name, cfg[i].u.choices.choicenames, + cfg[i].u.choices.selected); break; } } @@ -619,12 +621,29 @@ static void cfg_start(int which) */ void dlg_return_sval(int index, const char *val) { - sfree(cfg[index].sval); - cfg[index].sval = dupstr(val); + config_item *i = cfg + index; + switch (i->type) { + case C_STRING: + sfree(i->u.string.sval); + i->u.string.sval = dupstr(val); + break; + default: + assert(0 && "Bad type for return_sval"); + } } void dlg_return_ival(int index, int val) { - cfg[index].ival = val; + config_item *i = cfg + index; + switch (i->type) { + case C_BOOLEAN: + i->u.boolean.bval = val; + break; + case C_CHOICES: + i->u.choices.selected = val; + break; + default: + assert(0 && "Bad type for return_ival"); + } } /* @@ -638,7 +657,7 @@ static void cfg_end(int use_results) /* * User hit OK. */ - char *err = midend_set_config(me, cfg_which, cfg); + const char *err = midend_set_config(me, cfg_which, cfg); if (err) { /* @@ -748,7 +767,7 @@ void command(int n) break; case 9: /* Solve */ if (thegame.can_solve) { - char *msg = midend_solve(me); + const char *msg = midend_solve(me); if (msg) js_error_box(msg); } @@ -768,7 +787,7 @@ struct savefile_write_ctx { size_t pos; }; -static void savefile_write(void *vctx, void *buf, int len) +static void savefile_write(void *vctx, const void *buf, int len) { struct savefile_write_ctx *ctx = (struct savefile_write_ctx *)vctx; if (ctx->buffer) @@ -845,7 +864,7 @@ void load_game(const char *buffer, int len) */ int main(int argc, char **argv) { - char *param_err; + const char *param_err; float *colours; int i; -- cgit v1.2.3