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/twiddle.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/twiddle.c')
-rw-r--r-- | apps/plugins/puzzles/src/twiddle.c | 46 |
1 files changed, 19 insertions, 27 deletions
diff --git a/apps/plugins/puzzles/src/twiddle.c b/apps/plugins/puzzles/src/twiddle.c index 224c0418f1..cbf6f761ef 100644 --- a/apps/plugins/puzzles/src/twiddle.c +++ b/apps/plugins/puzzles/src/twiddle.c | |||
@@ -80,9 +80,9 @@ static game_params *dup_params(const game_params *params) | |||
80 | static int game_fetch_preset(int i, char **name, game_params **params) | 80 | static int game_fetch_preset(int i, char **name, game_params **params) |
81 | { | 81 | { |
82 | static struct { | 82 | static struct { |
83 | char *title; | 83 | const char *title; |
84 | game_params params; | 84 | game_params params; |
85 | } presets[] = { | 85 | } const presets[] = { |
86 | { "3x3 rows only", { 3, 3, 2, TRUE, FALSE } }, | 86 | { "3x3 rows only", { 3, 3, 2, TRUE, FALSE } }, |
87 | { "3x3 normal", { 3, 3, 2, FALSE, FALSE } }, | 87 | { "3x3 normal", { 3, 3, 2, FALSE, FALSE } }, |
88 | { "3x3 orientable", { 3, 3, 2, FALSE, TRUE } }, | 88 | { "3x3 orientable", { 3, 3, 2, FALSE, TRUE } }, |
@@ -156,41 +156,33 @@ static config_item *game_configure(const game_params *params) | |||
156 | ret[0].name = "Width"; | 156 | ret[0].name = "Width"; |
157 | ret[0].type = C_STRING; | 157 | ret[0].type = C_STRING; |
158 | sprintf(buf, "%d", params->w); | 158 | sprintf(buf, "%d", params->w); |
159 | ret[0].sval = dupstr(buf); | 159 | ret[0].u.string.sval = dupstr(buf); |
160 | ret[0].ival = 0; | ||
161 | 160 | ||
162 | ret[1].name = "Height"; | 161 | ret[1].name = "Height"; |
163 | ret[1].type = C_STRING; | 162 | ret[1].type = C_STRING; |
164 | sprintf(buf, "%d", params->h); | 163 | sprintf(buf, "%d", params->h); |
165 | ret[1].sval = dupstr(buf); | 164 | ret[1].u.string.sval = dupstr(buf); |
166 | ret[1].ival = 0; | ||
167 | 165 | ||
168 | ret[2].name = "Rotating block size"; | 166 | ret[2].name = "Rotating block size"; |
169 | ret[2].type = C_STRING; | 167 | ret[2].type = C_STRING; |
170 | sprintf(buf, "%d", params->n); | 168 | sprintf(buf, "%d", params->n); |
171 | ret[2].sval = dupstr(buf); | 169 | ret[2].u.string.sval = dupstr(buf); |
172 | ret[2].ival = 0; | ||
173 | 170 | ||
174 | ret[3].name = "One number per row"; | 171 | ret[3].name = "One number per row"; |
175 | ret[3].type = C_BOOLEAN; | 172 | ret[3].type = C_BOOLEAN; |
176 | ret[3].sval = NULL; | 173 | ret[3].u.boolean.bval = params->rowsonly; |
177 | ret[3].ival = params->rowsonly; | ||
178 | 174 | ||
179 | ret[4].name = "Orientation matters"; | 175 | ret[4].name = "Orientation matters"; |
180 | ret[4].type = C_BOOLEAN; | 176 | ret[4].type = C_BOOLEAN; |
181 | ret[4].sval = NULL; | 177 | ret[4].u.boolean.bval = params->orientable; |
182 | ret[4].ival = params->orientable; | ||
183 | 178 | ||
184 | ret[5].name = "Number of shuffling moves"; | 179 | ret[5].name = "Number of shuffling moves"; |
185 | ret[5].type = C_STRING; | 180 | ret[5].type = C_STRING; |
186 | sprintf(buf, "%d", params->movetarget); | 181 | sprintf(buf, "%d", params->movetarget); |
187 | ret[5].sval = dupstr(buf); | 182 | ret[5].u.string.sval = dupstr(buf); |
188 | ret[5].ival = 0; | ||
189 | 183 | ||
190 | ret[6].name = NULL; | 184 | ret[6].name = NULL; |
191 | ret[6].type = C_END; | 185 | ret[6].type = C_END; |
192 | ret[6].sval = NULL; | ||
193 | ret[6].ival = 0; | ||
194 | 186 | ||
195 | return ret; | 187 | return ret; |
196 | } | 188 | } |
@@ -199,17 +191,17 @@ static game_params *custom_params(const config_item *cfg) | |||
199 | { | 191 | { |
200 | game_params *ret = snew(game_params); | 192 | game_params *ret = snew(game_params); |
201 | 193 | ||
202 | ret->w = atoi(cfg[0].sval); | 194 | ret->w = atoi(cfg[0].u.string.sval); |
203 | ret->h = atoi(cfg[1].sval); | 195 | ret->h = atoi(cfg[1].u.string.sval); |
204 | ret->n = atoi(cfg[2].sval); | 196 | ret->n = atoi(cfg[2].u.string.sval); |
205 | ret->rowsonly = cfg[3].ival; | 197 | ret->rowsonly = cfg[3].u.boolean.bval; |
206 | ret->orientable = cfg[4].ival; | 198 | ret->orientable = cfg[4].u.boolean.bval; |
207 | ret->movetarget = atoi(cfg[5].sval); | 199 | ret->movetarget = atoi(cfg[5].u.string.sval); |
208 | 200 | ||
209 | return ret; | 201 | return ret; |
210 | } | 202 | } |
211 | 203 | ||
212 | static char *validate_params(const game_params *params, int full) | 204 | static const char *validate_params(const game_params *params, int full) |
213 | { | 205 | { |
214 | if (params->n < 2) | 206 | if (params->n < 2) |
215 | return "Rotating block size must be at least two"; | 207 | return "Rotating block size must be at least two"; |
@@ -432,7 +424,7 @@ static char *new_game_desc(const game_params *params, random_state *rs, | |||
432 | return ret; | 424 | return ret; |
433 | } | 425 | } |
434 | 426 | ||
435 | static char *validate_desc(const game_params *params, const char *desc) | 427 | static const char *validate_desc(const game_params *params, const char *desc) |
436 | { | 428 | { |
437 | const char *p; | 429 | const char *p; |
438 | int w = params->w, h = params->h, wh = w*h; | 430 | int w = params->w, h = params->h, wh = w*h; |
@@ -543,7 +535,7 @@ static int compare_int(const void *av, const void *bv) | |||
543 | } | 535 | } |
544 | 536 | ||
545 | static char *solve_game(const game_state *state, const game_state *currstate, | 537 | static char *solve_game(const game_state *state, const game_state *currstate, |
546 | const char *aux, char **error) | 538 | const char *aux, const char **error) |
547 | { | 539 | { |
548 | return dupstr("S"); | 540 | return dupstr("S"); |
549 | } | 541 | } |
@@ -663,7 +655,7 @@ static char *interpret_move(const game_state *state, game_ui *ui, | |||
663 | if (button == CURSOR_DOWN && (ui->cur_y+n) < (h)) | 655 | if (button == CURSOR_DOWN && (ui->cur_y+n) < (h)) |
664 | ui->cur_y++; | 656 | ui->cur_y++; |
665 | ui->cur_visible = 1; | 657 | ui->cur_visible = 1; |
666 | return ""; | 658 | return UI_UPDATE; |
667 | } | 659 | } |
668 | 660 | ||
669 | if (button == LEFT_BUTTON || button == RIGHT_BUTTON) { | 661 | if (button == LEFT_BUTTON || button == RIGHT_BUTTON) { |
@@ -687,7 +679,7 @@ static char *interpret_move(const game_state *state, game_ui *ui, | |||
687 | dir = (button == CURSOR_SELECT2) ? -1 : +1; | 679 | dir = (button == CURSOR_SELECT2) ? -1 : +1; |
688 | } else { | 680 | } else { |
689 | ui->cur_visible = 1; | 681 | ui->cur_visible = 1; |
690 | return ""; | 682 | return UI_UPDATE; |
691 | } | 683 | } |
692 | } else if (button == 'a' || button == 'A' || button==MOD_NUM_KEYPAD+'7') { | 684 | } else if (button == 'a' || button == 'A' || button==MOD_NUM_KEYPAD+'7') { |
693 | x = y = 0; | 685 | x = y = 0; |