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.
This commit is contained in:
Simon Tatham
2023-04-21 15:30:41 +01:00
parent ec2e2f3770
commit a4fca3286f
49 changed files with 214 additions and 144 deletions

View File

@ -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);
}