From a4fca3286f3aa630a3641e50a8e1f44ab1504a29 Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Fri, 21 Apr 2023 15:30:41 +0100 Subject: [PATCH] Pass a game_ui to compute_size, print_size and print. I'm about to move some of the bodgy getenv-based options so that they become fields in game_ui. So these functions, which could previously access those options directly via getenv, will now need to be given a game_ui where they can look them up. --- blackbox.c | 2 +- bridges.c | 10 ++++++---- cube.c | 2 +- devel.but | 8 +++++--- dominosa.c | 10 ++++++---- fifteen.c | 2 +- filling.c | 10 ++++++---- flip.c | 2 +- flood.c | 2 +- galaxies.c | 10 ++++++---- guess.c | 5 +++-- inertia.c | 2 +- keen.c | 10 ++++++---- lightup.c | 10 ++++++---- loopy.c | 10 ++++++---- magnets.c | 10 ++++++---- map.c | 10 ++++++---- midend.c | 12 ++++++------ mines.c | 2 +- mosaic.c | 2 +- net.c | 10 ++++++---- netslide.c | 2 +- nullgame.c | 2 +- palisade.c | 10 ++++++---- pattern.c | 10 ++++++---- pearl.c | 10 ++++++---- pegs.c | 2 +- printing.c | 17 +++++++++++++---- puzzles.h | 8 +++++--- range.c | 10 ++++++---- rect.c | 10 ++++++---- samegame.c | 2 +- signpost.c | 10 ++++++---- singles.c | 10 ++++++---- sixteen.c | 2 +- slant.c | 10 ++++++---- solo.c | 10 ++++++---- tents.c | 10 ++++++---- towers.c | 10 ++++++---- tracks.c | 10 ++++++---- twiddle.c | 2 +- undead.c | 2 +- unequal.c | 10 ++++++---- unfinished/group.c | 10 ++++++---- unfinished/separate.c | 8 +++++--- unfinished/slide.c | 8 +++++--- unfinished/sokoban.c | 8 +++++--- unruly.c | 10 ++++++---- untangle.c | 4 ++-- 49 files changed, 214 insertions(+), 144 deletions(-) diff --git a/blackbox.c b/blackbox.c index 2ec8693..114a2ac 100644 --- a/blackbox.c +++ b/blackbox.c @@ -1149,7 +1149,7 @@ static void game_get_cursor_location(const game_ui *ui, */ static void game_compute_size(const game_params *params, int tilesize, - int *x, int *y) + const game_ui *ui, int *x, int *y) { /* Border is ts/2, to make things easier. * Thus we have (width) + 2 (firing range*2) + 1 (border*2) tiles diff --git a/bridges.c b/bridges.c index e562fbc..ce79640 100644 --- a/bridges.c +++ b/bridges.c @@ -2665,7 +2665,7 @@ static char *solve_game(const game_state *state, const game_state *currstate, */ static void game_compute_size(const game_params *params, int tilesize, - int *x, int *y) + const game_ui *ui, int *x, int *y) { /* Ick: fake up `ds->tilesize' for macro expansion purposes */ struct { int tilesize; } ads, *ds = &ads; @@ -3203,17 +3203,19 @@ static int game_status(const game_state *state) return state->completed ? +1 : 0; } -static void game_print_size(const game_params *params, float *x, float *y) +static void game_print_size(const game_params *params, const game_ui *ui, + float *x, float *y) { int pw, ph; /* 10mm squares by default. */ - game_compute_size(params, 1000, &pw, &ph); + game_compute_size(params, 1000, ui, &pw, &ph); *x = pw / 100.0F; *y = ph / 100.0F; } -static void game_print(drawing *dr, const game_state *state, int ts) +static void game_print(drawing *dr, const game_state *state, const game_ui *ui, + int ts) { int ink = print_mono_colour(dr, 0); int paper = print_mono_colour(dr, 1); diff --git a/cube.c b/cube.c index 0512746..41057fc 100644 --- a/cube.c +++ b/cube.c @@ -1489,7 +1489,7 @@ static struct bbox find_bbox(const game_params *params) ((int)(((bb).d - (bb).u + 2*(solid)->border) * gs)) static void game_compute_size(const game_params *params, int tilesize, - int *x, int *y) + const game_ui *ui, int *x, int *y) { struct bbox bb = find_bbox(params); diff --git a/devel.but b/devel.but index 48a4b1e..0fb1a14 100644 --- a/devel.but +++ b/devel.but @@ -1181,7 +1181,7 @@ explicitly requesting a resize). \S{backend-compute-size} \cw{compute_size()} \c void (*compute_size)(const game_params *params, int tilesize, -\c int *x, int *y); +\c const game_ui *ui, int *x, int *y); This function is passed a \c{game_params} structure and a tile size. It returns, in \c{*x} and \c{*y}, the size in pixels of the drawing @@ -1497,7 +1497,8 @@ ignored. \S{backend-print-size} \cw{print_size()} -\c void (*print_size)(const game_params *params, float *x, float *y); +\c void (*print_size)(const game_params *params, const game_ui *ui, +\c float *x, float *y); This function is passed a \c{game_params} structure and a tile size. It returns, in \c{*x} and \c{*y}, the preferred size in @@ -1508,7 +1509,8 @@ called. \S{backend-print} \cw{print()} -\c void (*print)(drawing *dr, const game_state *state, int tilesize); +\c void (*print)(drawing *dr, const game_state *state, +\c const game_ui *ui, int tilesize); This function is called when a puzzle is to be printed out on paper. It should use the drawing API functions (see \k{drawing}) to print diff --git a/dominosa.c b/dominosa.c index f24ed03..8589018 100644 --- a/dominosa.c +++ b/dominosa.c @@ -3031,7 +3031,7 @@ static game_state *execute_move(const game_state *state, const char *move) */ static void game_compute_size(const game_params *params, int tilesize, - int *x, int *y) + const game_ui *ui, int *x, int *y) { int n = params->n, w = n+2, h = n+1; @@ -3371,19 +3371,21 @@ static int game_status(const game_state *state) return state->completed ? +1 : 0; } -static void game_print_size(const game_params *params, float *x, float *y) +static void game_print_size(const game_params *params, const game_ui *ui, + float *x, float *y) { int pw, ph; /* * I'll use 6mm squares by default. */ - game_compute_size(params, 600, &pw, &ph); + game_compute_size(params, 600, ui, &pw, &ph); *x = pw / 100.0F; *y = ph / 100.0F; } -static void game_print(drawing *dr, const game_state *state, int tilesize) +static void game_print(drawing *dr, const game_state *state, const game_ui *ui, + int tilesize) { int w = state->w, h = state->h; int c, x, y; diff --git a/fifteen.c b/fifteen.c index 5d01aa2..224a712 100644 --- a/fifteen.c +++ b/fifteen.c @@ -804,7 +804,7 @@ static game_state *execute_move(const game_state *from, const char *move) */ static void game_compute_size(const game_params *params, int tilesize, - int *x, int *y) + const game_ui *ui, int *x, int *y) { /* Ick: fake up `ds->tilesize' for macro expansion purposes */ struct { int tilesize; } ads, *ds = &ads; diff --git a/filling.c b/filling.c index 61060b4..970301c 100644 --- a/filling.c +++ b/filling.c @@ -1652,7 +1652,7 @@ enum { }; static void game_compute_size(const game_params *params, int tilesize, - int *x, int *y) + const game_ui *ui, int *x, int *y) { *x = (params->w + 1) * tilesize; *y = (params->h + 1) * tilesize; @@ -2092,19 +2092,21 @@ static int game_status(const game_state *state) return state->completed ? +1 : 0; } -static void game_print_size(const game_params *params, float *x, float *y) +static void game_print_size(const game_params *params, const game_ui *ui, + float *x, float *y) { int pw, ph; /* * I'll use 6mm squares by default. */ - game_compute_size(params, 600, &pw, &ph); + game_compute_size(params, 600, ui, &pw, &ph); *x = pw / 100.0F; *y = ph / 100.0F; } -static void game_print(drawing *dr, const game_state *state, int tilesize) +static void game_print(drawing *dr, const game_state *state, const game_ui *ui, + int tilesize) { const int w = state->shared->params.w; const int h = state->shared->params.h; diff --git a/flip.c b/flip.c index d989a28..10a71b0 100644 --- a/flip.c +++ b/flip.c @@ -1055,7 +1055,7 @@ static game_state *execute_move(const game_state *from, const char *move) */ static void game_compute_size(const game_params *params, int tilesize, - int *x, int *y) + const game_ui *ui, int *x, int *y) { /* Ick: fake up `ds->tilesize' for macro expansion purposes */ struct { int tilesize; } ads, *ds = &ads; diff --git a/flood.c b/flood.c index f1c40f1..6274252 100644 --- a/flood.c +++ b/flood.c @@ -974,7 +974,7 @@ static game_state *execute_move(const game_state *state, const char *move) */ static void game_compute_size(const game_params *params, int tilesize, - int *x, int *y) + const game_ui *ui, int *x, int *y) { /* Ick: fake up `ds->tilesize' for macro expansion purposes */ struct { int tilesize; } ads, *ds = &ads; diff --git a/galaxies.c b/galaxies.c index 37a530d..dfa1274 100644 --- a/galaxies.c +++ b/galaxies.c @@ -3405,7 +3405,7 @@ badmove: */ static void game_compute_size(const game_params *params, int sz, - int *x, int *y) + const game_ui *ui, int *x, int *y) { struct { int tilesize, w, h; } ads, *ds = &ads; @@ -3926,7 +3926,8 @@ static int game_status(const game_state *state) } #ifndef EDITOR -static void game_print_size(const game_params *params, float *x, float *y) +static void game_print_size(const game_params *params, const game_ui *ui, + float *x, float *y) { int pw, ph; @@ -3934,12 +3935,13 @@ static void game_print_size(const game_params *params, float *x, float *y) * 8mm squares by default. (There isn't all that much detail * that needs to go in each square.) */ - game_compute_size(params, 800, &pw, &ph); + game_compute_size(params, 800, ui, &pw, &ph); *x = pw / 100.0F; *y = ph / 100.0F; } -static void game_print(drawing *dr, const game_state *state, int sz) +static void game_print(drawing *dr, const game_state *state, const game_ui *ui, + int sz) { int w = state->w, h = state->h; int white, black, blackish; diff --git a/guess.c b/guess.c index dc02d57..27aeabd 100644 --- a/guess.c +++ b/guess.c @@ -999,7 +999,7 @@ static game_state *execute_move(const game_state *from, const char *move) #define BORDER 0.5 static void game_compute_size(const game_params *params, int tilesize, - int *x, int *y) + const game_ui *ui, int *x, int *y) { double hmul, vmul_c, vmul_g, vmul; int hintw = (params->npegs+1)/2; @@ -1043,7 +1043,8 @@ static void game_set_size(drawing *dr, game_drawstate *ds, guessh = ((ds->pegsz + ds->gapsz) * params->nguesses); /* guesses */ guessh += ds->gapsz + ds->pegsz; /* solution */ - game_compute_size(params, tilesize, &ds->w, &ds->h); + /* We know we don't need anything from the game_ui we haven't got */ + game_compute_size(params, tilesize, NULL, &ds->w, &ds->h); ds->colx = ds->border; ds->coly = (ds->h - colh) / 2; diff --git a/inertia.c b/inertia.c index a352514..4ac3eae 100644 --- a/inertia.c +++ b/inertia.c @@ -1768,7 +1768,7 @@ static game_state *execute_move(const game_state *state, const char *move) */ static void game_compute_size(const game_params *params, int tilesize, - int *x, int *y) + const game_ui *ui, int *x, int *y) { /* Ick: fake up `ds->tilesize' for macro expansion purposes */ struct { int tilesize; } ads, *ds = &ads; diff --git a/keen.c b/keen.c index 80ebd7a..0b28a90 100644 --- a/keen.c +++ b/keen.c @@ -1866,7 +1866,7 @@ static game_state *execute_move(const game_state *from, const char *move) #define SIZE(w) ((w) * TILESIZE + 2*BORDER) static void game_compute_size(const game_params *params, int tilesize, - int *x, int *y) + const game_ui *ui, int *x, int *y) { /* Ick: fake up `ds->tilesize' for macro expansion purposes */ struct { int tilesize; } ads, *ds = &ads; @@ -2222,14 +2222,15 @@ static int game_status(const game_state *state) return state->completed ? +1 : 0; } -static void game_print_size(const game_params *params, float *x, float *y) +static void game_print_size(const game_params *params, const game_ui *ui, + float *x, float *y) { int pw, ph; /* * We use 9mm squares by default, like Solo. */ - game_compute_size(params, 900, &pw, &ph); + game_compute_size(params, 900, ui, &pw, &ph); *x = pw / 100.0F; *y = ph / 100.0F; } @@ -2365,7 +2366,8 @@ static void outline_block_structure(drawing *dr, game_drawstate *ds, sfree(coords); } -static void game_print(drawing *dr, const game_state *state, int tilesize) +static void game_print(drawing *dr, const game_state *state, const game_ui *ui, + int tilesize) { int w = state->par.w; int ink = print_mono_colour(dr, 0); diff --git a/lightup.c b/lightup.c index f60017f..ca0d962 100644 --- a/lightup.c +++ b/lightup.c @@ -2021,7 +2021,7 @@ badmove: /* XXX entirely cloned from fifteen.c; separate out? */ static void game_compute_size(const game_params *params, int tilesize, - int *x, int *y) + const game_ui *ui, int *x, int *y) { /* Ick: fake up `ds->tilesize' for macro expansion purposes */ struct { int tilesize; } ads, *ds = &ads; @@ -2247,19 +2247,21 @@ static int game_status(const game_state *state) return state->completed ? +1 : 0; } -static void game_print_size(const game_params *params, float *x, float *y) +static void game_print_size(const game_params *params, const game_ui *ui, + float *x, float *y) { int pw, ph; /* * I'll use 6mm squares by default. */ - game_compute_size(params, 600, &pw, &ph); + game_compute_size(params, 600, ui, &pw, &ph); *x = pw / 100.0F; *y = ph / 100.0F; } -static void game_print(drawing *dr, const game_state *state, int tilesize) +static void game_print(drawing *dr, const game_state *state, const game_ui *ui, + int tilesize) { int w = state->w, h = state->h; int ink = print_mono_colour(dr, 0); diff --git a/loopy.c b/loopy.c index b0f4280..e7bf9c0 100644 --- a/loopy.c +++ b/loopy.c @@ -883,7 +883,7 @@ static void game_changed_state(game_ui *ui, const game_state *oldstate, } static void game_compute_size(const game_params *params, int tilesize, - int *x, int *y) + const game_ui *ui, int *x, int *y) { int grid_width, grid_height, rendered_width, rendered_height; int g_tilesize; @@ -3554,19 +3554,21 @@ static int game_status(const game_state *state) return state->solved ? +1 : 0; } -static void game_print_size(const game_params *params, float *x, float *y) +static void game_print_size(const game_params *params, const game_ui *ui, + float *x, float *y) { int pw, ph; /* * I'll use 7mm "squares" by default. */ - game_compute_size(params, 700, &pw, &ph); + game_compute_size(params, 700, ui, &pw, &ph); *x = pw / 100.0F; *y = ph / 100.0F; } -static void game_print(drawing *dr, const game_state *state, int tilesize) +static void game_print(drawing *dr, const game_state *state, const game_ui *ui, + int tilesize) { int ink = print_mono_colour(dr, 0); int i; diff --git a/magnets.c b/magnets.c index 45ebc83..6f216df 100644 --- a/magnets.c +++ b/magnets.c @@ -1965,7 +1965,7 @@ badmove: */ static void game_compute_size(const game_params *params, int tilesize, - int *x, int *y) + const game_ui *ui, int *x, int *y) { /* Ick: fake up `ds->tilesize' for macro expansion purposes */ struct { int tilesize; } ads, *ds = &ads; @@ -2341,19 +2341,21 @@ static int game_status(const game_state *state) return state->completed ? +1 : 0; } -static void game_print_size(const game_params *params, float *x, float *y) +static void game_print_size(const game_params *params, const game_ui *ui, + float *x, float *y) { int pw, ph; /* * I'll use 6mm squares by default. */ - game_compute_size(params, 600, &pw, &ph); + game_compute_size(params, 600, ui, &pw, &ph); *x = pw / 100.0F; *y = ph / 100.0F; } -static void game_print(drawing *dr, const game_state *state, int tilesize) +static void game_print(drawing *dr, const game_state *state, const game_ui *ui, + int tilesize) { int w = state->w, h = state->h; int ink = print_mono_colour(dr, 0); diff --git a/map.c b/map.c index 9a2a58a..b8f5970 100644 --- a/map.c +++ b/map.c @@ -2630,7 +2630,7 @@ static game_state *execute_move(const game_state *state, const char *move) */ static void game_compute_size(const game_params *params, int tilesize, - int *x, int *y) + const game_ui *ui, int *x, int *y) { /* Ick: fake up `ds->tilesize' for macro expansion purposes */ struct { int tilesize; } ads, *ds = &ads; @@ -3093,7 +3093,8 @@ static int game_status(const game_state *state) return state->completed ? +1 : 0; } -static void game_print_size(const game_params *params, float *x, float *y) +static void game_print_size(const game_params *params, const game_ui *ui, + float *x, float *y) { int pw, ph; @@ -3102,12 +3103,13 @@ static void game_print_size(const game_params *params, float *x, float *y) * compute this size is to compute the pixel puzzle size at a * given tile size and then scale. */ - game_compute_size(params, 400, &pw, &ph); + game_compute_size(params, 400, ui, &pw, &ph); *x = pw / 100.0F; *y = ph / 100.0F; } -static void game_print(drawing *dr, const game_state *state, int tilesize) +static void game_print(drawing *dr, const game_state *state, const game_ui *ui, + int tilesize) { int w = state->p.w, h = state->p.h, wh = w*h, n = state->p.n; int ink, c[FOUR], i; diff --git a/midend.c b/midend.c index c9ef415..4339366 100644 --- a/midend.c +++ b/midend.c @@ -303,7 +303,7 @@ static void midend_size_new_drawstate(midend *me) * anyway yet. */ if (me->tilesize > 0) { - me->ourgame->compute_size(me->params, me->tilesize, + me->ourgame->compute_size(me->params, me->tilesize, me->ui, &me->winwidth, &me->winheight); me->ourgame->set_size(me->drawing, me->drawstate, me->params, me->tilesize); @@ -328,19 +328,19 @@ static int convert_tilesize(midend *me, int old_tilesize, defaults = me->ourgame->default_params(); - me->ourgame->compute_size(defaults, old_tilesize, &x, &y); + me->ourgame->compute_size(defaults, old_tilesize, me->ui, &x, &y); x *= new_dpr / old_dpr; y *= new_dpr / old_dpr; min = max = 1; do { max *= 2; - me->ourgame->compute_size(defaults, max, &rx, &ry); + me->ourgame->compute_size(defaults, max, me->ui, &rx, &ry); } while (rx <= x && ry <= y); while (max - min > 1) { int mid = (max + min) / 2; - me->ourgame->compute_size(defaults, mid, &rx, &ry); + me->ourgame->compute_size(defaults, mid, me->ui, &rx, &ry); if (rx <= x && ry <= y) min = mid; else @@ -382,7 +382,7 @@ void midend_size(midend *me, int *x, int *y, bool user_size, max = 1; do { max *= 2; - me->ourgame->compute_size(me->params, max, &rx, &ry); + me->ourgame->compute_size(me->params, max, me->ui, &rx, &ry); } while (rx <= *x && ry <= *y); } else max = convert_tilesize(me, me->preferred_tilesize, @@ -398,7 +398,7 @@ void midend_size(midend *me, int *x, int *y, bool user_size, */ while (max - min > 1) { int mid = (max + min) / 2; - me->ourgame->compute_size(me->params, mid, &rx, &ry); + me->ourgame->compute_size(me->params, mid, me->ui, &rx, &ry); if (rx <= *x && ry <= *y) min = mid; else diff --git a/mines.c b/mines.c index a945dc4..5781c4c 100644 --- a/mines.c +++ b/mines.c @@ -2694,7 +2694,7 @@ static game_state *execute_move(const game_state *from, const char *move) */ static void game_compute_size(const game_params *params, int tilesize, - int *x, int *y) + const game_ui *ui, int *x, int *y) { /* Ick: fake up `ds->tilesize' for macro expansion purposes */ struct { int tilesize; } ads, *ds = &ads; diff --git a/mosaic.c b/mosaic.c index 98e7077..51d379e 100644 --- a/mosaic.c +++ b/mosaic.c @@ -1398,7 +1398,7 @@ static game_state *execute_move(const game_state *state, const char *move) */ static void game_compute_size(const game_params *params, int tilesize, - int *x, int *y) + const game_ui *ui, int *x, int *y) { *x = (params->width + 1) * tilesize; *y = (params->height + 1) * tilesize; diff --git a/net.c b/net.c index e4cc979..2c8909d 100644 --- a/net.c +++ b/net.c @@ -2488,7 +2488,7 @@ static void game_free_drawstate(drawing *dr, game_drawstate *ds) } static void game_compute_size(const game_params *params, int tilesize, - int *x, int *y) + const game_ui *ui, int *x, int *y) { /* Ick: fake up `ds->tilesize' for macro expansion purposes */ struct { int tilesize; } ads, *ds = &ads; @@ -3112,14 +3112,15 @@ static int game_status(const game_state *state) return state->completed ? +1 : 0; } -static void game_print_size(const game_params *params, float *x, float *y) +static void game_print_size(const game_params *params, const game_ui *ui, + float *x, float *y) { int pw, ph; /* * I'll use 8mm squares by default. */ - game_compute_size(params, 800, &pw, &ph); + game_compute_size(params, 800, ui, &pw, &ph); *x = pw / 100.0F; *y = ph / 100.0F; } @@ -3170,7 +3171,8 @@ static void draw_diagram(drawing *dr, game_drawstate *ds, int x, int y, } } -static void game_print(drawing *dr, const game_state *state, int tilesize) +static void game_print(drawing *dr, const game_state *state, const game_ui *ui, + int tilesize) { int w = state->width, h = state->height; int ink = print_mono_colour(dr, 0); diff --git a/netslide.c b/netslide.c index 164bf9c..6472e23 100644 --- a/netslide.c +++ b/netslide.c @@ -1223,7 +1223,7 @@ static void game_free_drawstate(drawing *dr, game_drawstate *ds) } static void game_compute_size(const game_params *params, int tilesize, - int *x, int *y) + const game_ui *ui, int *x, int *y) { /* Ick: fake up `ds->tilesize' for macro expansion purposes */ struct { int tilesize; } ads, *ds = &ads; diff --git a/nullgame.c b/nullgame.c index aa5ca99..a779bc6 100644 --- a/nullgame.c +++ b/nullgame.c @@ -148,7 +148,7 @@ static game_state *execute_move(const game_state *state, const char *move) */ static void game_compute_size(const game_params *params, int tilesize, - int *x, int *y) + const game_ui *ui, int *x, int *y) { *x = *y = 10 * tilesize; /* FIXME */ } diff --git a/palisade.c b/palisade.c index 09ef3af..0af19e5 100644 --- a/palisade.c +++ b/palisade.c @@ -1043,7 +1043,7 @@ static game_state *execute_move(const game_state *state, const char *move) /* --- Drawing routines --------------------------------------------- */ static void game_compute_size(const game_params *params, int tilesize, - int *x, int *y) + const game_ui *ui, int *x, int *y) { *x = (params->w + 1) * tilesize; *y = (params->h + 1) * tilesize; @@ -1291,11 +1291,12 @@ static int game_status(const game_state *state) return state->completed ? +1 : 0; } -static void game_print_size(const game_params *params, float *x, float *y) +static void game_print_size(const game_params *params, const game_ui *ui, + float *x, float *y) { int pw, ph; - game_compute_size(params, 700, &pw, &ph); /* 7mm, like loopy */ + game_compute_size(params, 700, ui, &pw, &ph); /* 7mm, like loopy */ *x = pw / 100.0F; *y = ph / 100.0F; @@ -1314,7 +1315,8 @@ static void print_line(drawing *dr, int x1, int y1, int x2, int y2, } else draw_line(dr, x1, y1, x2, y2, colour); } -static void game_print(drawing *dr, const game_state *state, int tilesize) +static void game_print(drawing *dr, const game_state *state, const game_ui *ui, + int tilesize) { int w = state->shared->params.w, h = state->shared->params.h; int ink = print_mono_colour(dr, 0); diff --git a/pattern.c b/pattern.c index 4602585..fc01d1f 100644 --- a/pattern.c +++ b/pattern.c @@ -1669,7 +1669,7 @@ static bool check_errors(const game_state *state, int i) */ static void game_compute_size(const game_params *params, int tilesize, - int *x, int *y) + const game_ui *ui, int *x, int *y) { /* Ick: fake up `ds->tilesize' for macro expansion purposes */ struct { int tilesize; } ads, *ds = &ads; @@ -1990,19 +1990,21 @@ static int game_status(const game_state *state) return state->completed ? +1 : 0; } -static void game_print_size(const game_params *params, float *x, float *y) +static void game_print_size(const game_params *params, const game_ui *ui, + float *x, float *y) { int pw, ph; /* * I'll use 5mm squares by default. */ - game_compute_size(params, 500, &pw, &ph); + game_compute_size(params, 500, ui, &pw, &ph); *x = pw / 100.0F; *y = ph / 100.0F; } -static void game_print(drawing *dr, const game_state *state, int tilesize) +static void game_print(drawing *dr, const game_state *state, const game_ui *ui, + int tilesize) { int w = state->common->w, h = state->common->h; int ink = print_mono_colour(dr, 0); diff --git a/pearl.c b/pearl.c index 13e90aa..745985a 100644 --- a/pearl.c +++ b/pearl.c @@ -2344,7 +2344,7 @@ badmove: #define FLASH_TIME 0.5F static void game_compute_size(const game_params *params, int tilesize, - int *x, int *y) + const game_ui *ui, int *x, int *y) { /* Ick: fake up `ds->tilesize' for macro expansion purposes */ struct { int halfsz; } ads, *ds = &ads; @@ -2633,19 +2633,21 @@ static int game_status(const game_state *state) return state->completed ? +1 : 0; } -static void game_print_size(const game_params *params, float *x, float *y) +static void game_print_size(const game_params *params, const game_ui *ui, + float *x, float *y) { int pw, ph; /* * I'll use 6mm squares by default. */ - game_compute_size(params, 600, &pw, &ph); + game_compute_size(params, 600, ui, &pw, &ph); *x = pw / 100.0F; *y = ph / 100.0F; } -static void game_print(drawing *dr, const game_state *state, int tilesize) +static void game_print(drawing *dr, const game_state *state, const game_ui *ui, + int tilesize) { int w = state->shared->w, h = state->shared->h, x, y; int black = print_mono_colour(dr, 0); diff --git a/pegs.c b/pegs.c index 7cd33e8..054d198 100644 --- a/pegs.c +++ b/pegs.c @@ -1048,7 +1048,7 @@ static game_state *execute_move(const game_state *state, const char *move) */ static void game_compute_size(const game_params *params, int tilesize, - int *x, int *y) + const game_ui *ui, int *x, int *y) { /* Ick: fake up `ds->tilesize' for macro expansion purposes */ struct { int tilesize; } ads, *ds = &ads; diff --git a/printing.c b/printing.c index d1a3bad..7301ba0 100644 --- a/printing.c +++ b/printing.c @@ -96,7 +96,11 @@ static void get_puzzle_size(const document *doc, struct puzzle *pz, float ww, hh, ourscale; /* Get the preferred size of the game, in mm. */ - pz->game->print_size(pz->par, &ww, &hh); + { + game_ui *ui = pz->game->new_ui(pz->st); + pz->game->print_size(pz->par, ui, &ww, &hh); + pz->game->free_ui(ui); + } /* Adjust for user-supplied scale factor. */ ourscale = doc->userscale; @@ -270,9 +274,14 @@ void document_print_page(const document *doc, drawing *dr, int page_nr) * permit each game to choose its own?) */ tilesize = 512; - pz->game->compute_size(pz->par, tilesize, &pixw, &pixh); - print_begin_puzzle(dr, xm, xc, ym, yc, pixw, pixh, w, scale); - pz->game->print(dr, pass == 0 ? pz->st : pz->st2, tilesize); + { + game_ui *ui = pz->game->new_ui(pz->st); + pz->game->compute_size(pz->par, tilesize, ui, + &pixw, &pixh); + print_begin_puzzle(dr, xm, xc, ym, yc, pixw, pixh, w, scale); + pz->game->print(dr, pass == 0 ? pz->st : pz->st2, ui, tilesize); + pz->game->free_ui(ui); + } print_end_puzzle(dr); } diff --git a/puzzles.h b/puzzles.h index 73e4478..cb7fbca 100644 --- a/puzzles.h +++ b/puzzles.h @@ -689,7 +689,7 @@ struct game { game_state *(*execute_move)(const game_state *state, const char *move); int preferred_tilesize; void (*compute_size)(const game_params *params, int tilesize, - int *x, int *y); + const game_ui *ui, int *x, int *y); void (*set_size)(drawing *dr, game_drawstate *ds, const game_params *params, int tilesize); float *(*colours)(frontend *fe, int *ncolours); @@ -709,8 +709,10 @@ struct game { int *x, int *y, int *w, int *h); int (*status)(const game_state *state); bool can_print, can_print_in_colour; - void (*print_size)(const game_params *params, float *x, float *y); - void (*print)(drawing *dr, const game_state *state, int tilesize); + void (*print_size)(const game_params *params, const game_ui *ui, + float *x, float *y); + void (*print)(drawing *dr, const game_state *state, const game_ui *ui, + int tilesize); bool wants_statusbar; bool is_timed; bool (*timing_state)(const game_state *state, game_ui *ui); diff --git a/range.c b/range.c index 54272e6..1fbb87c 100644 --- a/range.c +++ b/range.c @@ -1623,7 +1623,7 @@ enum { }; static void game_compute_size(const game_params *params, int tilesize, - int *x, int *y) + const game_ui *ui, int *x, int *y) { *x = (1 + params->w) * tilesize; *y = (1 + params->h) * tilesize; @@ -1766,15 +1766,17 @@ static void draw_cell(drawing *draw, game_drawstate *ds, int r, int c, * User interface: print */ -static void game_print_size(const game_params *params, float *x, float *y) +static void game_print_size(const game_params *params, const game_ui *ui, + float *x, float *y) { int print_width, print_height; - game_compute_size(params, 800, &print_width, &print_height); + game_compute_size(params, 800, ui, &print_width, &print_height); *x = print_width / 100.0F; *y = print_height / 100.0F; } -static void game_print(drawing *dr, const game_state *state, int tilesize) +static void game_print(drawing *dr, const game_state *state, const game_ui *ui, + int tilesize) { int const w = state->params.w, h = state->params.h; game_drawstate ds_obj, *ds = &ds_obj; diff --git a/rect.c b/rect.c index 00e84c4..a4ff8d2 100644 --- a/rect.c +++ b/rect.c @@ -2630,7 +2630,7 @@ static game_state *execute_move(const game_state *from, const char *move) #define MAX4(x,y,z,w) ( max(max(x,y),max(z,w)) ) static void game_compute_size(const game_params *params, int tilesize, - int *x, int *y) + const game_ui *ui, int *x, int *y) { /* Ick: fake up `ds->tilesize' for macro expansion purposes */ struct { int tilesize; } ads, *ds = &ads; @@ -2907,19 +2907,21 @@ static int game_status(const game_state *state) return state->completed ? +1 : 0; } -static void game_print_size(const game_params *params, float *x, float *y) +static void game_print_size(const game_params *params, const game_ui *ui, + float *x, float *y) { int pw, ph; /* * I'll use 5mm squares by default. */ - game_compute_size(params, 500, &pw, &ph); + game_compute_size(params, 500, ui, &pw, &ph); *x = pw / 100.0F; *y = ph / 100.0F; } -static void game_print(drawing *dr, const game_state *state, int tilesize) +static void game_print(drawing *dr, const game_state *state, const game_ui *ui, + int tilesize) { int w = state->w, h = state->h; int ink = print_mono_colour(dr, 0); diff --git a/samegame.c b/samegame.c index d1f1f2e..5c57a55 100644 --- a/samegame.c +++ b/samegame.c @@ -1373,7 +1373,7 @@ static void game_set_size(drawing *dr, game_drawstate *ds, } static void game_compute_size(const game_params *params, int tilesize, - int *x, int *y) + const game_ui *ui, int *x, int *y) { /* Ick: fake up tile size variables for macro expansion purposes */ game_drawstate ads, *ds = &ads; diff --git a/signpost.c b/signpost.c index 3f87744..d166b0c 100644 --- a/signpost.c +++ b/signpost.c @@ -1659,7 +1659,7 @@ static game_state *execute_move(const game_state *state, const char *move) */ static void game_compute_size(const game_params *params, int tilesize, - int *x, int *y) + const game_ui *ui, int *x, int *y) { /* Ick: fake up `ds->tilesize' for macro expansion purposes */ struct { int tilesize, order; } ads, *ds = &ads; @@ -2220,16 +2220,18 @@ static int game_status(const game_state *state) return state->completed ? +1 : 0; } -static void game_print_size(const game_params *params, float *x, float *y) +static void game_print_size(const game_params *params, const game_ui *ui, + float *x, float *y) { int pw, ph; - game_compute_size(params, 1300, &pw, &ph); + game_compute_size(params, 1300, ui, &pw, &ph); *x = pw / 100.0F; *y = ph / 100.0F; } -static void game_print(drawing *dr, const game_state *state, int tilesize) +static void game_print(drawing *dr, const game_state *state, const game_ui *ui, + int tilesize) { int ink = print_mono_colour(dr, 0); int x, y; diff --git a/singles.c b/singles.c index 222a322..6eb5a2c 100644 --- a/singles.c +++ b/singles.c @@ -1594,7 +1594,7 @@ badmove: */ static void game_compute_size(const game_params *params, int tilesize, - int *x, int *y) + const game_ui *ui, int *x, int *y) { /* Ick: fake up `ds->tilesize' for macro expansion purposes */ struct { int tilesize; } ads, *ds = &ads; @@ -1783,17 +1783,19 @@ static int game_status(const game_state *state) return state->completed ? +1 : 0; } -static void game_print_size(const game_params *params, float *x, float *y) +static void game_print_size(const game_params *params, const game_ui *ui, + float *x, float *y) { int pw, ph; /* 8mm squares by default. */ - game_compute_size(params, 800, &pw, &ph); + game_compute_size(params, 800, ui, &pw, &ph); *x = pw / 100.0F; *y = ph / 100.0F; } -static void game_print(drawing *dr, const game_state *state, int tilesize) +static void game_print(drawing *dr, const game_state *state, const game_ui *ui, + int tilesize) { int ink = print_mono_colour(dr, 0); int paper = print_mono_colour(dr, 1); diff --git a/sixteen.c b/sixteen.c index 01fd6df..3f5ed5b 100644 --- a/sixteen.c +++ b/sixteen.c @@ -802,7 +802,7 @@ static game_state *execute_move(const game_state *from, const char *move) */ static void game_compute_size(const game_params *params, int tilesize, - int *x, int *y) + const game_ui *ui, int *x, int *y) { /* Ick: fake up `ds->tilesize' for macro expansion purposes */ struct { int tilesize; } ads, *ds = &ads; diff --git a/slant.c b/slant.c index da3045b..5230f25 100644 --- a/slant.c +++ b/slant.c @@ -1785,7 +1785,7 @@ static game_state *execute_move(const game_state *state, const char *move) */ static void game_compute_size(const game_params *params, int tilesize, - int *x, int *y) + const game_ui *ui, int *x, int *y) { /* fool the macros */ struct dummy { int tilesize; } dummy, *ds = &dummy; @@ -2084,19 +2084,21 @@ static int game_status(const game_state *state) return state->completed ? +1 : 0; } -static void game_print_size(const game_params *params, float *x, float *y) +static void game_print_size(const game_params *params, const game_ui *ui, + float *x, float *y) { int pw, ph; /* * I'll use 6mm squares by default. */ - game_compute_size(params, 600, &pw, &ph); + game_compute_size(params, 600, ui, &pw, &ph); *x = pw / 100.0F; *y = ph / 100.0F; } -static void game_print(drawing *dr, const game_state *state, int tilesize) +static void game_print(drawing *dr, const game_state *state, const game_ui *ui, + int tilesize) { int w = state->p.w, h = state->p.h, W = w+1; int ink = print_mono_colour(dr, 0); diff --git a/solo.c b/solo.c index 1dad766..4005f2d 100644 --- a/solo.c +++ b/solo.c @@ -4810,7 +4810,7 @@ static game_state *execute_move(const game_state *from, const char *move) #define GETTILESIZE(cr, w) ( (double)(w-1) / (double)(cr+1) ) static void game_compute_size(const game_params *params, int tilesize, - int *x, int *y) + const game_ui *ui, int *x, int *y) { /* Ick: fake up `ds->tilesize' for macro expansion purposes */ struct { int tilesize; } ads, *ds = &ads; @@ -5330,7 +5330,8 @@ static int game_status(const game_state *state) return state->completed ? +1 : 0; } -static void game_print_size(const game_params *params, float *x, float *y) +static void game_print_size(const game_params *params, const game_ui *ui, + float *x, float *y) { int pw, ph; @@ -5339,7 +5340,7 @@ static void game_print_size(const game_params *params, float *x, float *y) * for this game, because players will want to jot down no end * of pencil marks in the squares. */ - game_compute_size(params, 900, &pw, &ph); + game_compute_size(params, 900, ui, &pw, &ph); *x = pw / 100.0F; *y = ph / 100.0F; } @@ -5513,7 +5514,8 @@ static void outline_block_structure(drawing *dr, game_drawstate *ds, sfree(coords); } -static void game_print(drawing *dr, const game_state *state, int tilesize) +static void game_print(drawing *dr, const game_state *state, const game_ui *ui, + int tilesize) { int cr = state->cr; int ink = print_mono_colour(dr, 0); diff --git a/tents.c b/tents.c index 194055b..c6a3514 100644 --- a/tents.c +++ b/tents.c @@ -1905,7 +1905,7 @@ static game_state *execute_move(const game_state *state, const char *move) */ static void game_compute_size(const game_params *params, int tilesize, - int *x, int *y) + const game_ui *ui, int *x, int *y) { /* fool the macros */ struct dummy { int tilesize; } dummy, *ds = &dummy; @@ -2596,19 +2596,21 @@ static int game_status(const game_state *state) return state->completed ? +1 : 0; } -static void game_print_size(const game_params *params, float *x, float *y) +static void game_print_size(const game_params *params, const game_ui *ui, + float *x, float *y) { int pw, ph; /* * I'll use 6mm squares by default. */ - game_compute_size(params, 600, &pw, &ph); + game_compute_size(params, 600, ui, &pw, &ph); *x = pw / 100.0F; *y = ph / 100.0F; } -static void game_print(drawing *dr, const game_state *state, int tilesize) +static void game_print(drawing *dr, const game_state *state, const game_ui *ui, + int tilesize) { int c; diff --git a/towers.c b/towers.c index 43d5f03..012c8b3 100644 --- a/towers.c +++ b/towers.c @@ -1574,7 +1574,7 @@ static game_state *execute_move(const game_state *from, const char *move) #define SIZE(w) ((w) * TILESIZE + 2*BORDER) static void game_compute_size(const game_params *params, int tilesize, - int *x, int *y) + const game_ui *ui, int *x, int *y) { /* Ick: fake up `ds->tilesize' for macro expansion purposes */ struct { int tilesize; } ads, *ds = &ads; @@ -1954,19 +1954,21 @@ static int game_status(const game_state *state) return state->completed ? +1 : 0; } -static void game_print_size(const game_params *params, float *x, float *y) +static void game_print_size(const game_params *params, const game_ui *ui, + float *x, float *y) { int pw, ph; /* * We use 9mm squares by default, like Solo. */ - game_compute_size(params, 900, &pw, &ph); + game_compute_size(params, 900, ui, &pw, &ph); *x = pw / 100.0F; *y = ph / 100.0F; } -static void game_print(drawing *dr, const game_state *state, int tilesize) +static void game_print(drawing *dr, const game_state *state, const game_ui *ui, + int tilesize) { int w = state->par.w; int ink = print_mono_colour(dr, 0); diff --git a/tracks.c b/tracks.c index 1e46c9d..294ae04 100644 --- a/tracks.c +++ b/tracks.c @@ -2479,7 +2479,7 @@ static game_state *execute_move(const game_state *state, const char *move) #define FLASH_TIME 0.5F static void game_compute_size(const game_params *params, int tilesize, - int *x, int *y) + const game_ui *ui, int *x, int *y) { /* Ick: fake up `ds->sz6' and `ds->border` for macro expansion purposes */ struct { @@ -2976,17 +2976,19 @@ static int game_status(const game_state *state) return state->completed ? +1 : 0; } -static void game_print_size(const game_params *params, float *x, float *y) +static void game_print_size(const game_params *params, const game_ui *ui, + float *x, float *y) { int pw, ph; /* The Times uses 7mm squares */ - game_compute_size(params, 700, &pw, &ph); + game_compute_size(params, 700, ui, &pw, &ph); *x = pw / 100.0F; *y = ph / 100.0F; } -static void game_print(drawing *dr, const game_state *state, int tilesize) +static void game_print(drawing *dr, const game_state *state, const game_ui *ui, + int tilesize) { int w = state->p.w, h = state->p.h; int black = print_mono_colour(dr, 0), grey = print_grey_colour(dr, 0.5F); diff --git a/twiddle.c b/twiddle.c index 626b621..3095c99 100644 --- a/twiddle.c +++ b/twiddle.c @@ -800,7 +800,7 @@ static game_state *execute_move(const game_state *from, const char *move) */ static void game_compute_size(const game_params *params, int tilesize, - int *x, int *y) + const game_ui *ui, int *x, int *y) { /* Ick: fake up `ds->tilesize' for macro expansion purposes */ struct { int tilesize; } ads, *ds = &ads; diff --git a/undead.c b/undead.c index d4f0ee1..2e18e11 100644 --- a/undead.c +++ b/undead.c @@ -2138,7 +2138,7 @@ static game_state *execute_move(const game_state *state, const char *move) #define PREFERRED_TILE_SIZE 64 static void game_compute_size(const game_params *params, int tilesize, - int *x, int *y) + const game_ui *ui, int *x, int *y) { /* Ick: fake up `ds->tilesize' for macro expansion purposes */ struct { int tilesize; } ads, *ds = &ads; diff --git a/unequal.c b/unequal.c index f6ce50f..dff5885 100644 --- a/unequal.c +++ b/unequal.c @@ -1720,7 +1720,7 @@ badmove: #define DRAW_SIZE (TILE_SIZE*ds->order + GAP_SIZE*(ds->order-1) + BORDER*2) static void game_compute_size(const game_params *params, int tilesize, - int *x, int *y) + const game_ui *ui, int *x, int *y) { /* Ick: fake up `ds->tilesize' for macro expansion purposes */ struct { int tilesize, order; } ads, *ds = &ads; @@ -2083,17 +2083,19 @@ static int game_status(const game_state *state) return state->completed ? +1 : 0; } -static void game_print_size(const game_params *params, float *x, float *y) +static void game_print_size(const game_params *params, const game_ui *ui, + float *x, float *y) { int pw, ph; /* 10mm squares by default, roughly the same as Grauniad. */ - game_compute_size(params, 1000, &pw, &ph); + game_compute_size(params, 1000, ui, &pw, &ph); *x = pw / 100.0F; *y = ph / 100.0F; } -static void game_print(drawing *dr, const game_state *state, int tilesize) +static void game_print(drawing *dr, const game_state *state, const game_ui *ui, + int tilesize) { int ink = print_mono_colour(dr, 0); int x, y, o = state->order, ox, oy, n; diff --git a/unfinished/group.c b/unfinished/group.c index 7a2ffe6..dfa466d 100644 --- a/unfinished/group.c +++ b/unfinished/group.c @@ -1807,7 +1807,7 @@ static game_state *execute_move(const game_state *from, const char *move) #define SIZE(w) ((w) * TILESIZE + 2*BORDER + LEGEND) static void game_compute_size(const game_params *params, int tilesize, - int *x, int *y) + const game_ui *ui, int *x, int *y) { /* Ick: fake up `ds->tilesize' for macro expansion purposes */ struct { int tilesize; } ads, *ds = &ads; @@ -2224,19 +2224,21 @@ static bool game_timing_state(const game_state *state, game_ui *ui) return true; } -static void game_print_size(const game_params *params, float *x, float *y) +static void game_print_size(const game_params *params, const game_ui *ui, + float *x, float *y) { int pw, ph; /* * We use 9mm squares by default, like Solo. */ - game_compute_size(params, 900, &pw, &ph); + game_compute_size(params, 900, ui, &pw, &ph); *x = pw / 100.0F; *y = ph / 100.0F; } -static void game_print(drawing *dr, const game_state *state, int tilesize) +static void game_print(drawing *dr, const game_state *state, const game_ui *ui, + int tilesize) { int w = state->par.w; int ink = print_mono_colour(dr, 0); diff --git a/unfinished/separate.c b/unfinished/separate.c index cc2a6c1..635d7c6 100644 --- a/unfinished/separate.c +++ b/unfinished/separate.c @@ -731,7 +731,7 @@ static game_state *execute_move(const game_state *state, const char *move) */ static void game_compute_size(const game_params *params, int tilesize, - int *x, int *y) + const game_ui *ui, int *x, int *y) { *x = *y = 10 * tilesize; /* FIXME */ } @@ -804,11 +804,13 @@ static bool game_timing_state(const game_state *state, game_ui *ui) return true; } -static void game_print_size(const game_params *params, float *x, float *y) +static void game_print_size(const game_params *params, const game_ui *ui, + float *x, float *y) { } -static void game_print(drawing *dr, const game_state *state, int tilesize) +static void game_print(drawing *dr, const game_state *state, const game_ui *ui, + int tilesize) { } diff --git a/unfinished/slide.c b/unfinished/slide.c index e091def..6368eba 100644 --- a/unfinished/slide.c +++ b/unfinished/slide.c @@ -1594,7 +1594,7 @@ static game_state *execute_move(const game_state *state, const char *move) */ static void game_compute_size(const game_params *params, int tilesize, - int *x, int *y) + const game_ui *ui, int *x, int *y) { /* fool the macros */ struct dummy { int tilesize; } dummy, *ds = &dummy; @@ -2297,11 +2297,13 @@ static bool game_timing_state(const game_state *state, game_ui *ui) return true; } -static void game_print_size(const game_params *params, float *x, float *y) +static void game_print_size(const game_params *params, const game_ui *ui, + float *x, float *y) { } -static void game_print(drawing *dr, const game_state *state, int tilesize) +static void game_print(drawing *dr, const game_state *state, const game_ui *ui, + int tilesize) { } diff --git a/unfinished/sokoban.c b/unfinished/sokoban.c index 65d1fa6..3b847af 100644 --- a/unfinished/sokoban.c +++ b/unfinished/sokoban.c @@ -1178,7 +1178,7 @@ static game_state *execute_move(const game_state *state, const char *move) */ static void game_compute_size(const game_params *params, int tilesize, - int *x, int *y) + const game_ui *ui, int *x, int *y) { /* Ick: fake up `ds->tilesize' for macro expansion purposes */ struct { int tilesize; } ads, *ds = &ads; @@ -1419,11 +1419,13 @@ static bool game_timing_state(const game_state *state, game_ui *ui) return true; } -static void game_print_size(const game_params *params, float *x, float *y) +static void game_print_size(const game_params *params, const game_ui *ui, + float *x, float *y) { } -static void game_print(drawing *dr, const game_state *state, int tilesize) +static void game_print(drawing *dr, const game_state *state, const game_ui *ui, + int tilesize) { } diff --git a/unruly.c b/unruly.c index a8df09a..3ee1767 100644 --- a/unruly.c +++ b/unruly.c @@ -1727,7 +1727,7 @@ static game_state *execute_move(const game_state *state, const char *move) */ static void game_compute_size(const game_params *params, int tilesize, - int *x, int *y) + const game_ui *ui, int *x, int *y) { *x = tilesize * (params->w2 + 1); *y = tilesize * (params->h2 + 1); @@ -1965,17 +1965,19 @@ static int game_status(const game_state *state) return state->completed ? +1 : 0; } -static void game_print_size(const game_params *params, float *x, float *y) +static void game_print_size(const game_params *params, const game_ui *ui, + float *x, float *y) { int pw, ph; /* Using 7mm squares */ - game_compute_size(params, 700, &pw, &ph); + game_compute_size(params, 700, ui, &pw, &ph); *x = pw / 100.0F; *y = ph / 100.0F; } -static void game_print(drawing *dr, const game_state *state, int tilesize) +static void game_print(drawing *dr, const game_state *state, const game_ui *ui, + int tilesize) { int w2 = state->w2, h2 = state->h2; int x, y; diff --git a/untangle.c b/untangle.c index 85d8fc9..8ae1a7f 100644 --- a/untangle.c +++ b/untangle.c @@ -1183,7 +1183,7 @@ static game_state *execute_move(const game_state *state, const char *move) */ static void game_compute_size(const game_params *params, int tilesize, - int *x, int *y) + const game_ui *ui, int *x, int *y) { *x = *y = COORDLIMIT(params->n) * tilesize; } @@ -1341,7 +1341,7 @@ static void game_redraw(drawing *dr, game_drawstate *ds, ds->dragpoint = ui->dragpoint; ds->bg = bg; - game_compute_size(&state->params, ds->tilesize, &w, &h); + game_compute_size(&state->params, ds->tilesize, ui, &w, &h); draw_rect(dr, 0, 0, w, h, bg); /*