aboutsummaryrefslogtreecommitdiff
path: root/printing.c
diff options
context:
space:
mode:
Diffstat (limited to 'printing.c')
-rw-r--r--printing.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/printing.c b/printing.c
index 7301ba0..0a91194 100644
--- a/printing.c
+++ b/printing.c
@@ -10,6 +10,7 @@
struct puzzle {
const game *game;
game_params *par;
+ game_ui *ui;
game_state *st;
game_state *st2;
};
@@ -56,6 +57,7 @@ void document_free(document *doc)
for (i = 0; i < doc->npuzzles; i++) {
doc->puzzles[i].game->free_params(doc->puzzles[i].par);
+ doc->puzzles[i].game->free_ui(doc->puzzles[i].ui);
doc->puzzles[i].game->free_game(doc->puzzles[i].st);
if (doc->puzzles[i].st2)
doc->puzzles[i].game->free_game(doc->puzzles[i].st2);
@@ -75,7 +77,7 @@ void document_free(document *doc)
* another sheet (typically the solution to the first game_state).
*/
void document_add_puzzle(document *doc, const game *game, game_params *par,
- game_state *st, game_state *st2)
+ game_ui *ui, game_state *st, game_state *st2)
{
if (doc->npuzzles >= doc->puzzlesize) {
doc->puzzlesize += 32;
@@ -83,6 +85,7 @@ void document_add_puzzle(document *doc, const game *game, game_params *par,
}
doc->puzzles[doc->npuzzles].game = game;
doc->puzzles[doc->npuzzles].par = par;
+ doc->puzzles[doc->npuzzles].ui = ui;
doc->puzzles[doc->npuzzles].st = st;
doc->puzzles[doc->npuzzles].st2 = st2;
doc->npuzzles++;
@@ -274,14 +277,9 @@ void document_print_page(const document *doc, drawing *dr, int page_nr)
* permit each game to choose its own?)
*/
tilesize = 512;
- {
- 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);
- }
+ pz->game->compute_size(pz->par, tilesize, pz->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, pz->ui, tilesize);
print_end_puzzle(dr);
}