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/emcc.c | |
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/emcc.c')
-rw-r--r-- | apps/plugins/puzzles/src/emcc.c | 47 |
1 files changed, 33 insertions, 14 deletions
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) | |||
122 | * Fatal error, called in cases of complete despair such as when | 122 | * Fatal error, called in cases of complete despair such as when |
123 | * malloc() has returned NULL. | 123 | * malloc() has returned NULL. |
124 | */ | 124 | */ |
125 | void fatal(char *fmt, ...) | 125 | void fatal(const char *fmt, ...) |
126 | { | 126 | { |
127 | char buf[512]; | 127 | char buf[512]; |
128 | va_list ap; | 128 | va_list ap; |
@@ -136,7 +136,7 @@ void fatal(char *fmt, ...) | |||
136 | js_error_box(buf); | 136 | js_error_box(buf); |
137 | } | 137 | } |
138 | 138 | ||
139 | void debug_printf(char *fmt, ...) | 139 | void debug_printf(const char *fmt, ...) |
140 | { | 140 | { |
141 | char buf[512]; | 141 | char buf[512]; |
142 | va_list ap; | 142 | va_list ap; |
@@ -384,7 +384,8 @@ static void js_unclip(void *handle) | |||
384 | } | 384 | } |
385 | 385 | ||
386 | static void js_draw_text(void *handle, int x, int y, int fonttype, | 386 | static void js_draw_text(void *handle, int x, int y, int fonttype, |
387 | int fontsize, int align, int colour, char *text) | 387 | int fontsize, int align, int colour, |
388 | const char *text) | ||
388 | { | 389 | { |
389 | char fontstyle[80]; | 390 | char fontstyle[80]; |
390 | int halign; | 391 | int halign; |
@@ -515,7 +516,7 @@ static void js_end_draw(void *handle) | |||
515 | js_canvas_end_draw(); | 516 | js_canvas_end_draw(); |
516 | } | 517 | } |
517 | 518 | ||
518 | static void js_status_bar(void *handle, char *text) | 519 | static void js_status_bar(void *handle, const char *text) |
519 | { | 520 | { |
520 | js_canvas_set_statusbar(text); | 521 | js_canvas_set_statusbar(text); |
521 | } | 522 | } |
@@ -599,13 +600,14 @@ static void cfg_start(int which) | |||
599 | for (i = 0; cfg[i].type != C_END; i++) { | 600 | for (i = 0; cfg[i].type != C_END; i++) { |
600 | switch (cfg[i].type) { | 601 | switch (cfg[i].type) { |
601 | case C_STRING: | 602 | case C_STRING: |
602 | js_dialog_string(i, cfg[i].name, cfg[i].sval); | 603 | js_dialog_string(i, cfg[i].name, cfg[i].u.string.sval); |
603 | break; | 604 | break; |
604 | case C_BOOLEAN: | 605 | case C_BOOLEAN: |
605 | js_dialog_boolean(i, cfg[i].name, cfg[i].ival); | 606 | js_dialog_boolean(i, cfg[i].name, cfg[i].u.boolean.bval); |
606 | break; | 607 | break; |
607 | case C_CHOICES: | 608 | case C_CHOICES: |
608 | js_dialog_choices(i, cfg[i].name, cfg[i].sval, cfg[i].ival); | 609 | js_dialog_choices(i, cfg[i].name, cfg[i].u.choices.choicenames, |
610 | cfg[i].u.choices.selected); | ||
609 | break; | 611 | break; |
610 | } | 612 | } |
611 | } | 613 | } |
@@ -619,12 +621,29 @@ static void cfg_start(int which) | |||
619 | */ | 621 | */ |
620 | void dlg_return_sval(int index, const char *val) | 622 | void dlg_return_sval(int index, const char *val) |
621 | { | 623 | { |
622 | sfree(cfg[index].sval); | 624 | config_item *i = cfg + index; |
623 | cfg[index].sval = dupstr(val); | 625 | switch (i->type) { |
626 | case C_STRING: | ||
627 | sfree(i->u.string.sval); | ||
628 | i->u.string.sval = dupstr(val); | ||
629 | break; | ||
630 | default: | ||
631 | assert(0 && "Bad type for return_sval"); | ||
632 | } | ||
624 | } | 633 | } |
625 | void dlg_return_ival(int index, int val) | 634 | void dlg_return_ival(int index, int val) |
626 | { | 635 | { |
627 | cfg[index].ival = val; | 636 | config_item *i = cfg + index; |
637 | switch (i->type) { | ||
638 | case C_BOOLEAN: | ||
639 | i->u.boolean.bval = val; | ||
640 | break; | ||
641 | case C_CHOICES: | ||
642 | i->u.choices.selected = val; | ||
643 | break; | ||
644 | default: | ||
645 | assert(0 && "Bad type for return_ival"); | ||
646 | } | ||
628 | } | 647 | } |
629 | 648 | ||
630 | /* | 649 | /* |
@@ -638,7 +657,7 @@ static void cfg_end(int use_results) | |||
638 | /* | 657 | /* |
639 | * User hit OK. | 658 | * User hit OK. |
640 | */ | 659 | */ |
641 | char *err = midend_set_config(me, cfg_which, cfg); | 660 | const char *err = midend_set_config(me, cfg_which, cfg); |
642 | 661 | ||
643 | if (err) { | 662 | if (err) { |
644 | /* | 663 | /* |
@@ -748,7 +767,7 @@ void command(int n) | |||
748 | break; | 767 | break; |
749 | case 9: /* Solve */ | 768 | case 9: /* Solve */ |
750 | if (thegame.can_solve) { | 769 | if (thegame.can_solve) { |
751 | char *msg = midend_solve(me); | 770 | const char *msg = midend_solve(me); |
752 | if (msg) | 771 | if (msg) |
753 | js_error_box(msg); | 772 | js_error_box(msg); |
754 | } | 773 | } |
@@ -768,7 +787,7 @@ struct savefile_write_ctx { | |||
768 | size_t pos; | 787 | size_t pos; |
769 | }; | 788 | }; |
770 | 789 | ||
771 | static void savefile_write(void *vctx, void *buf, int len) | 790 | static void savefile_write(void *vctx, const void *buf, int len) |
772 | { | 791 | { |
773 | struct savefile_write_ctx *ctx = (struct savefile_write_ctx *)vctx; | 792 | struct savefile_write_ctx *ctx = (struct savefile_write_ctx *)vctx; |
774 | if (ctx->buffer) | 793 | if (ctx->buffer) |
@@ -845,7 +864,7 @@ void load_game(const char *buffer, int len) | |||
845 | */ | 864 | */ |
846 | int main(int argc, char **argv) | 865 | int main(int argc, char **argv) |
847 | { | 866 | { |
848 | char *param_err; | 867 | const char *param_err; |
849 | float *colours; | 868 | float *colours; |
850 | int i; | 869 | int i; |
851 | 870 | ||