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/filling.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/filling.c')
-rw-r--r-- | apps/plugins/puzzles/src/filling.c | 38 |
1 files changed, 17 insertions, 21 deletions
diff --git a/apps/plugins/puzzles/src/filling.c b/apps/plugins/puzzles/src/filling.c index d8d0c8cbb0..7e71eb25b4 100644 --- a/apps/plugins/puzzles/src/filling.c +++ b/apps/plugins/puzzles/src/filling.c | |||
@@ -68,7 +68,7 @@ | |||
68 | 68 | ||
69 | static unsigned char verbose; | 69 | static unsigned char verbose; |
70 | 70 | ||
71 | static void printv(char *fmt, ...) { | 71 | static void printv(const char *fmt, ...) { |
72 | #ifndef PALM | 72 | #ifndef PALM |
73 | if (verbose) { | 73 | if (verbose) { |
74 | va_list va; | 74 | va_list va; |
@@ -161,19 +161,15 @@ static config_item *game_configure(const game_params *params) | |||
161 | ret[0].name = "Width"; | 161 | ret[0].name = "Width"; |
162 | ret[0].type = C_STRING; | 162 | ret[0].type = C_STRING; |
163 | sprintf(buf, "%d", params->w); | 163 | sprintf(buf, "%d", params->w); |
164 | ret[0].sval = dupstr(buf); | 164 | ret[0].u.string.sval = dupstr(buf); |
165 | ret[0].ival = 0; | ||
166 | 165 | ||
167 | ret[1].name = "Height"; | 166 | ret[1].name = "Height"; |
168 | ret[1].type = C_STRING; | 167 | ret[1].type = C_STRING; |
169 | sprintf(buf, "%d", params->h); | 168 | sprintf(buf, "%d", params->h); |
170 | ret[1].sval = dupstr(buf); | 169 | ret[1].u.string.sval = dupstr(buf); |
171 | ret[1].ival = 0; | ||
172 | 170 | ||
173 | ret[2].name = NULL; | 171 | ret[2].name = NULL; |
174 | ret[2].type = C_END; | 172 | ret[2].type = C_END; |
175 | ret[2].sval = NULL; | ||
176 | ret[2].ival = 0; | ||
177 | 173 | ||
178 | return ret; | 174 | return ret; |
179 | } | 175 | } |
@@ -182,13 +178,13 @@ static game_params *custom_params(const config_item *cfg) | |||
182 | { | 178 | { |
183 | game_params *ret = snew(game_params); | 179 | game_params *ret = snew(game_params); |
184 | 180 | ||
185 | ret->w = atoi(cfg[0].sval); | 181 | ret->w = atoi(cfg[0].u.string.sval); |
186 | ret->h = atoi(cfg[1].sval); | 182 | ret->h = atoi(cfg[1].u.string.sval); |
187 | 183 | ||
188 | return ret; | 184 | return ret; |
189 | } | 185 | } |
190 | 186 | ||
191 | static char *validate_params(const game_params *params, int full) | 187 | static const char *validate_params(const game_params *params, int full) |
192 | { | 188 | { |
193 | if (params->w < 1) return "Width must be at least one"; | 189 | if (params->w < 1) return "Width must be at least one"; |
194 | if (params->h < 1) return "Height must be at least one"; | 190 | if (params->h < 1) return "Height must be at least one"; |
@@ -1270,7 +1266,7 @@ static char *new_game_desc(const game_params *params, random_state *rs, | |||
1270 | return sresize(description, j, char); | 1266 | return sresize(description, j, char); |
1271 | } | 1267 | } |
1272 | 1268 | ||
1273 | static char *validate_desc(const game_params *params, const char *desc) | 1269 | static const char *validate_desc(const game_params *params, const char *desc) |
1274 | { | 1270 | { |
1275 | const int sz = params->w * params->h; | 1271 | const int sz = params->w * params->h; |
1276 | const char m = '0' + max(max(params->w, params->h), 3); | 1272 | const char m = '0' + max(max(params->w, params->h), 3); |
@@ -1342,7 +1338,7 @@ static void free_game(game_state *state) | |||
1342 | } | 1338 | } |
1343 | 1339 | ||
1344 | static char *solve_game(const game_state *state, const game_state *currstate, | 1340 | static char *solve_game(const game_state *state, const game_state *currstate, |
1345 | const char *aux, char **error) | 1341 | const char *aux, const char **error) |
1346 | { | 1342 | { |
1347 | if (aux == NULL) { | 1343 | if (aux == NULL) { |
1348 | const int w = state->shared->params.w; | 1344 | const int w = state->shared->params.w; |
@@ -1449,22 +1445,22 @@ static char *interpret_move(const game_state *state, game_ui *ui, | |||
1449 | ui->sel[w*ty+tx] = 1; | 1445 | ui->sel[w*ty+tx] = 1; |
1450 | } | 1446 | } |
1451 | ui->cur_visible = 0; | 1447 | ui->cur_visible = 0; |
1452 | return ""; /* redraw */ | 1448 | return UI_UPDATE; |
1453 | } | 1449 | } |
1454 | 1450 | ||
1455 | if (IS_CURSOR_MOVE(button)) { | 1451 | if (IS_CURSOR_MOVE(button)) { |
1456 | ui->cur_visible = 1; | 1452 | ui->cur_visible = 1; |
1457 | move_cursor(button, &ui->cur_x, &ui->cur_y, w, h, 0); | 1453 | move_cursor(button, &ui->cur_x, &ui->cur_y, w, h, 0); |
1458 | if (ui->keydragging) goto select_square; | 1454 | if (ui->keydragging) goto select_square; |
1459 | return ""; | 1455 | return UI_UPDATE; |
1460 | } | 1456 | } |
1461 | if (button == CURSOR_SELECT) { | 1457 | if (button == CURSOR_SELECT) { |
1462 | if (!ui->cur_visible) { | 1458 | if (!ui->cur_visible) { |
1463 | ui->cur_visible = 1; | 1459 | ui->cur_visible = 1; |
1464 | return ""; | 1460 | return UI_UPDATE; |
1465 | } | 1461 | } |
1466 | ui->keydragging = !ui->keydragging; | 1462 | ui->keydragging = !ui->keydragging; |
1467 | if (!ui->keydragging) return ""; | 1463 | if (!ui->keydragging) return UI_UPDATE; |
1468 | 1464 | ||
1469 | select_square: | 1465 | select_square: |
1470 | if (!ui->sel) { | 1466 | if (!ui->sel) { |
@@ -1473,12 +1469,12 @@ static char *interpret_move(const game_state *state, game_ui *ui, | |||
1473 | } | 1469 | } |
1474 | if (!state->shared->clues[w*ui->cur_y + ui->cur_x]) | 1470 | if (!state->shared->clues[w*ui->cur_y + ui->cur_x]) |
1475 | ui->sel[w*ui->cur_y + ui->cur_x] = 1; | 1471 | ui->sel[w*ui->cur_y + ui->cur_x] = 1; |
1476 | return ""; | 1472 | return UI_UPDATE; |
1477 | } | 1473 | } |
1478 | if (button == CURSOR_SELECT2) { | 1474 | if (button == CURSOR_SELECT2) { |
1479 | if (!ui->cur_visible) { | 1475 | if (!ui->cur_visible) { |
1480 | ui->cur_visible = 1; | 1476 | ui->cur_visible = 1; |
1481 | return ""; | 1477 | return UI_UPDATE; |
1482 | } | 1478 | } |
1483 | if (!ui->sel) { | 1479 | if (!ui->sel) { |
1484 | ui->sel = snewn(w*h, int); | 1480 | ui->sel = snewn(w*h, int); |
@@ -1492,14 +1488,14 @@ static char *interpret_move(const game_state *state, game_ui *ui, | |||
1492 | sfree(ui->sel); | 1488 | sfree(ui->sel); |
1493 | ui->sel = NULL; | 1489 | ui->sel = NULL; |
1494 | } | 1490 | } |
1495 | return ""; | 1491 | return UI_UPDATE; |
1496 | } | 1492 | } |
1497 | 1493 | ||
1498 | if (button == '\b' || button == 27) { | 1494 | if (button == '\b' || button == 27) { |
1499 | sfree(ui->sel); | 1495 | sfree(ui->sel); |
1500 | ui->sel = NULL; | 1496 | ui->sel = NULL; |
1501 | ui->keydragging = FALSE; | 1497 | ui->keydragging = FALSE; |
1502 | return ""; | 1498 | return UI_UPDATE; |
1503 | } | 1499 | } |
1504 | 1500 | ||
1505 | if (button < '0' || button > '9') return NULL; | 1501 | if (button < '0' || button > '9') return NULL; |
@@ -1534,7 +1530,7 @@ static char *interpret_move(const game_state *state, game_ui *ui, | |||
1534 | sfree(ui->sel); | 1530 | sfree(ui->sel); |
1535 | ui->sel = NULL; | 1531 | ui->sel = NULL; |
1536 | /* Need to update UI at least, as we cleared the selection */ | 1532 | /* Need to update UI at least, as we cleared the selection */ |
1537 | return move ? move : ""; | 1533 | return move ? move : UI_UPDATE; |
1538 | } | 1534 | } |
1539 | 1535 | ||
1540 | static game_state *execute_move(const game_state *state, const char *move) | 1536 | static game_state *execute_move(const game_state *state, const char *move) |