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/flip.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/flip.c')
-rw-r--r-- | apps/plugins/puzzles/src/flip.c | 28 |
1 files changed, 12 insertions, 16 deletions
diff --git a/apps/plugins/puzzles/src/flip.c b/apps/plugins/puzzles/src/flip.c index c7126fb7d9..9e5716a118 100644 --- a/apps/plugins/puzzles/src/flip.c +++ b/apps/plugins/puzzles/src/flip.c | |||
@@ -149,24 +149,20 @@ static config_item *game_configure(const game_params *params) | |||
149 | ret[0].name = "Width"; | 149 | ret[0].name = "Width"; |
150 | ret[0].type = C_STRING; | 150 | ret[0].type = C_STRING; |
151 | sprintf(buf, "%d", params->w); | 151 | sprintf(buf, "%d", params->w); |
152 | ret[0].sval = dupstr(buf); | 152 | ret[0].u.string.sval = dupstr(buf); |
153 | ret[0].ival = 0; | ||
154 | 153 | ||
155 | ret[1].name = "Height"; | 154 | ret[1].name = "Height"; |
156 | ret[1].type = C_STRING; | 155 | ret[1].type = C_STRING; |
157 | sprintf(buf, "%d", params->h); | 156 | sprintf(buf, "%d", params->h); |
158 | ret[1].sval = dupstr(buf); | 157 | ret[1].u.string.sval = dupstr(buf); |
159 | ret[1].ival = 0; | ||
160 | 158 | ||
161 | ret[2].name = "Shape type"; | 159 | ret[2].name = "Shape type"; |
162 | ret[2].type = C_CHOICES; | 160 | ret[2].type = C_CHOICES; |
163 | ret[2].sval = ":Crosses:Random"; | 161 | ret[2].u.choices.choicenames = ":Crosses:Random"; |
164 | ret[2].ival = params->matrix_type; | 162 | ret[2].u.choices.selected = params->matrix_type; |
165 | 163 | ||
166 | ret[3].name = NULL; | 164 | ret[3].name = NULL; |
167 | ret[3].type = C_END; | 165 | ret[3].type = C_END; |
168 | ret[3].sval = NULL; | ||
169 | ret[3].ival = 0; | ||
170 | 166 | ||
171 | return ret; | 167 | return ret; |
172 | } | 168 | } |
@@ -175,14 +171,14 @@ static game_params *custom_params(const config_item *cfg) | |||
175 | { | 171 | { |
176 | game_params *ret = snew(game_params); | 172 | game_params *ret = snew(game_params); |
177 | 173 | ||
178 | ret->w = atoi(cfg[0].sval); | 174 | ret->w = atoi(cfg[0].u.string.sval); |
179 | ret->h = atoi(cfg[1].sval); | 175 | ret->h = atoi(cfg[1].u.string.sval); |
180 | ret->matrix_type = cfg[2].ival; | 176 | ret->matrix_type = cfg[2].u.choices.selected; |
181 | 177 | ||
182 | return ret; | 178 | return ret; |
183 | } | 179 | } |
184 | 180 | ||
185 | static char *validate_params(const game_params *params, int full) | 181 | static const char *validate_params(const game_params *params, int full) |
186 | { | 182 | { |
187 | if (params->w <= 0 || params->h <= 0) | 183 | if (params->w <= 0 || params->h <= 0) |
188 | return "Width and height must both be greater than zero"; | 184 | return "Width and height must both be greater than zero"; |
@@ -596,7 +592,7 @@ static char *new_game_desc(const game_params *params, random_state *rs, | |||
596 | return ret; | 592 | return ret; |
597 | } | 593 | } |
598 | 594 | ||
599 | static char *validate_desc(const game_params *params, const char *desc) | 595 | static const char *validate_desc(const game_params *params, const char *desc) |
600 | { | 596 | { |
601 | int w = params->w, h = params->h, wh = w * h; | 597 | int w = params->w, h = params->h, wh = w * h; |
602 | int mlen = (wh*wh+3)/4, glen = (wh+3)/4; | 598 | int mlen = (wh*wh+3)/4, glen = (wh+3)/4; |
@@ -673,7 +669,7 @@ static void rowxor(unsigned char *row1, unsigned char *row2, int len) | |||
673 | } | 669 | } |
674 | 670 | ||
675 | static char *solve_game(const game_state *state, const game_state *currstate, | 671 | static char *solve_game(const game_state *state, const game_state *currstate, |
676 | const char *aux, char **error) | 672 | const char *aux, const char **error) |
677 | { | 673 | { |
678 | int w = state->w, h = state->h, wh = w * h; | 674 | int w = state->w, h = state->h, wh = w * h; |
679 | unsigned char *equations, *solution, *shortest; | 675 | unsigned char *equations, *solution, *shortest; |
@@ -951,7 +947,7 @@ static char *interpret_move(const game_state *state, game_ui *ui, | |||
951 | tx = ui->cx; ty = ui->cy; | 947 | tx = ui->cx; ty = ui->cy; |
952 | ui->cdraw = 1; | 948 | ui->cdraw = 1; |
953 | } | 949 | } |
954 | nullret = ""; | 950 | nullret = UI_UPDATE; |
955 | 951 | ||
956 | if (tx >= 0 && tx < w && ty >= 0 && ty < h) { | 952 | if (tx >= 0 && tx < w && ty >= 0 && ty < h) { |
957 | /* | 953 | /* |
@@ -985,7 +981,7 @@ static char *interpret_move(const game_state *state, game_ui *ui, | |||
985 | ui->cx = min(max(ui->cx, 0), state->w - 1); | 981 | ui->cx = min(max(ui->cx, 0), state->w - 1); |
986 | ui->cy = min(max(ui->cy, 0), state->h - 1); | 982 | ui->cy = min(max(ui->cy, 0), state->h - 1); |
987 | ui->cdraw = 1; | 983 | ui->cdraw = 1; |
988 | nullret = ""; | 984 | nullret = UI_UPDATE; |
989 | } | 985 | } |
990 | 986 | ||
991 | return nullret; | 987 | return nullret; |