X-Git-Url: https://git.distorted.org.uk/~mdw/sgt/puzzles/blobdiff_plain/28b5987d5dbdcb396c07b937a638590e5361361e..a8c8847b94f2f07c350a331dfcbedbebef5b5c82:/netslide.c diff --git a/netslide.c b/netslide.c index fe77794..b16cb0b 100644 --- a/netslide.c +++ b/netslide.c @@ -1194,29 +1194,23 @@ static void game_free_drawstate(game_drawstate *ds) sfree(ds); } -static void game_size(game_params *params, game_drawstate *ds, int *x, int *y, - int expand) +static void game_compute_size(game_params *params, int tilesize, + int *x, int *y) { - int tsx, tsy, ts; - /* - * Each window dimension equals the tile size times two more - * than the grid dimension (the border containing the arrows is - * the same width as the tiles), plus TILE_BORDER, plus twice - * WINDOW_OFFSET. - */ - tsx = (*x - 2*WINDOW_OFFSET - TILE_BORDER) / (params->width + 2); - tsy = (*y - 2*WINDOW_OFFSET - TILE_BORDER) / (params->height + 2); - ts = min(tsx, tsy); - - if (expand) - ds->tilesize = ts; - else - ds->tilesize = min(ts, PREFERRED_TILE_SIZE); + /* Ick: fake up `ds->tilesize' for macro expansion purposes */ + struct { int tilesize; } ads, *ds = &ads; + ads.tilesize = tilesize; *x = BORDER * 2 + WINDOW_OFFSET * 2 + TILE_SIZE * params->width + TILE_BORDER; *y = BORDER * 2 + WINDOW_OFFSET * 2 + TILE_SIZE * params->height + TILE_BORDER; } +static void game_set_size(game_drawstate *ds, game_params *params, + int tilesize) +{ + ds->tilesize = tilesize; +} + static float *game_colours(frontend *fe, game_state *state, int *ncolours) { float *ret; @@ -1815,7 +1809,7 @@ const struct game thegame = { game_changed_state, interpret_move, execute_move, - game_size, + PREFERRED_TILE_SIZE, game_compute_size, game_set_size, game_colours, game_new_drawstate, game_free_drawstate,