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/keen.c | 39 ++++++++++++++++++--------------------- 1 file changed, 18 insertions(+), 21 deletions(-) (limited to 'apps/plugins/puzzles/src/keen.c') diff --git a/apps/plugins/puzzles/src/keen.c b/apps/plugins/puzzles/src/keen.c index fdaae32e5d..ec7af12985 100644 --- a/apps/plugins/puzzles/src/keen.c +++ b/apps/plugins/puzzles/src/keen.c @@ -183,23 +183,19 @@ static config_item *game_configure(const game_params *params) ret[0].name = "Grid size"; ret[0].type = C_STRING; sprintf(buf, "%d", params->w); - ret[0].sval = dupstr(buf); - ret[0].ival = 0; + ret[0].u.string.sval = dupstr(buf); ret[1].name = "Difficulty"; ret[1].type = C_CHOICES; - ret[1].sval = DIFFCONFIG; - ret[1].ival = params->diff; + ret[1].u.choices.choicenames = DIFFCONFIG; + ret[1].u.choices.selected = params->diff; ret[2].name = "Multiplication only"; ret[2].type = C_BOOLEAN; - ret[2].sval = NULL; - ret[2].ival = params->multiplication_only; + ret[2].u.boolean.bval = params->multiplication_only; ret[3].name = NULL; ret[3].type = C_END; - ret[3].sval = NULL; - ret[3].ival = 0; return ret; } @@ -208,14 +204,14 @@ static game_params *custom_params(const config_item *cfg) { game_params *ret = snew(game_params); - ret->w = atoi(cfg[0].sval); - ret->diff = cfg[1].ival; - ret->multiplication_only = cfg[2].ival; + ret->w = atoi(cfg[0].u.string.sval); + ret->diff = cfg[1].u.choices.selected; + ret->multiplication_only = cfg[2].u.boolean.bval; return ret; } -static char *validate_params(const game_params *params, int full) +static const char *validate_params(const game_params *params, int full) { if (params->w < 3 || params->w > 9) return "Grid size must be between 3 and 9"; @@ -731,7 +727,7 @@ static char *encode_block_structure(char *p, int w, int *dsf) return q; } -static char *parse_block_structure(const char **p, int w, int *dsf) +static const char *parse_block_structure(const char **p, int w, int *dsf) { int a = w*w; int pos = 0; @@ -1207,11 +1203,11 @@ done * Gameplay. */ -static char *validate_desc(const game_params *params, const char *desc) +static const char *validate_desc(const game_params *params, const char *desc) { int w = params->w, a = w*w; int *dsf; - char *ret; + const char *ret; const char *p = desc; int i; @@ -1349,7 +1345,7 @@ static void free_game(game_state *state) } static char *solve_game(const game_state *state, const game_state *currstate, - const char *aux, char **error) + const char *aux, const char **error) { int w = state->par.w, a = w*w; int i, ret; @@ -1616,7 +1612,7 @@ static char *interpret_move(const game_state *state, game_ui *ui, ui->hpencil = 0; } ui->hcursor = 0; - return ""; /* UI activity occurred */ + return UI_UPDATE; } if (button == RIGHT_BUTTON) { /* @@ -1636,19 +1632,19 @@ static char *interpret_move(const game_state *state, game_ui *ui, ui->hshow = 0; } ui->hcursor = 0; - return ""; /* UI activity occurred */ + return UI_UPDATE; } } if (IS_CURSOR_MOVE(button)) { move_cursor(button, &ui->hx, &ui->hy, w, w, 0); ui->hshow = ui->hcursor = 1; - return ""; + return UI_UPDATE; } if (ui->hshow && (button == CURSOR_SELECT)) { ui->hpencil = 1 - ui->hpencil; ui->hcursor = 1; - return ""; + return UI_UPDATE; } if (ui->hshow && @@ -2383,7 +2379,8 @@ int main(int argc, char **argv) { game_params *p; game_state *s; - char *id = NULL, *desc, *err; + char *id = NULL, *desc; + const char *err; int grade = FALSE; int ret, diff, really_show_working = FALSE; -- cgit v1.2.3