summaryrefslogtreecommitdiff
path: root/apps/plugins/puzzles/src/printing.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/puzzles/src/printing.c')
-rw-r--r--apps/plugins/puzzles/src/printing.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/apps/plugins/puzzles/src/printing.c b/apps/plugins/puzzles/src/printing.c
index d1a3badaaa..0a911949a7 100644
--- a/apps/plugins/puzzles/src/printing.c
+++ b/apps/plugins/puzzles/src/printing.c
@@ -10,6 +10,7 @@
10struct puzzle { 10struct puzzle {
11 const game *game; 11 const game *game;
12 game_params *par; 12 game_params *par;
13 game_ui *ui;
13 game_state *st; 14 game_state *st;
14 game_state *st2; 15 game_state *st2;
15}; 16};
@@ -56,6 +57,7 @@ void document_free(document *doc)
56 57
57 for (i = 0; i < doc->npuzzles; i++) { 58 for (i = 0; i < doc->npuzzles; i++) {
58 doc->puzzles[i].game->free_params(doc->puzzles[i].par); 59 doc->puzzles[i].game->free_params(doc->puzzles[i].par);
60 doc->puzzles[i].game->free_ui(doc->puzzles[i].ui);
59 doc->puzzles[i].game->free_game(doc->puzzles[i].st); 61 doc->puzzles[i].game->free_game(doc->puzzles[i].st);
60 if (doc->puzzles[i].st2) 62 if (doc->puzzles[i].st2)
61 doc->puzzles[i].game->free_game(doc->puzzles[i].st2); 63 doc->puzzles[i].game->free_game(doc->puzzles[i].st2);
@@ -75,7 +77,7 @@ void document_free(document *doc)
75 * another sheet (typically the solution to the first game_state). 77 * another sheet (typically the solution to the first game_state).
76 */ 78 */
77void document_add_puzzle(document *doc, const game *game, game_params *par, 79void document_add_puzzle(document *doc, const game *game, game_params *par,
78 game_state *st, game_state *st2) 80 game_ui *ui, game_state *st, game_state *st2)
79{ 81{
80 if (doc->npuzzles >= doc->puzzlesize) { 82 if (doc->npuzzles >= doc->puzzlesize) {
81 doc->puzzlesize += 32; 83 doc->puzzlesize += 32;
@@ -83,6 +85,7 @@ void document_add_puzzle(document *doc, const game *game, game_params *par,
83 } 85 }
84 doc->puzzles[doc->npuzzles].game = game; 86 doc->puzzles[doc->npuzzles].game = game;
85 doc->puzzles[doc->npuzzles].par = par; 87 doc->puzzles[doc->npuzzles].par = par;
88 doc->puzzles[doc->npuzzles].ui = ui;
86 doc->puzzles[doc->npuzzles].st = st; 89 doc->puzzles[doc->npuzzles].st = st;
87 doc->puzzles[doc->npuzzles].st2 = st2; 90 doc->puzzles[doc->npuzzles].st2 = st2;
88 doc->npuzzles++; 91 doc->npuzzles++;
@@ -96,7 +99,11 @@ static void get_puzzle_size(const document *doc, struct puzzle *pz,
96 float ww, hh, ourscale; 99 float ww, hh, ourscale;
97 100
98 /* Get the preferred size of the game, in mm. */ 101 /* Get the preferred size of the game, in mm. */
99 pz->game->print_size(pz->par, &ww, &hh); 102 {
103 game_ui *ui = pz->game->new_ui(pz->st);
104 pz->game->print_size(pz->par, ui, &ww, &hh);
105 pz->game->free_ui(ui);
106 }
100 107
101 /* Adjust for user-supplied scale factor. */ 108 /* Adjust for user-supplied scale factor. */
102 ourscale = doc->userscale; 109 ourscale = doc->userscale;
@@ -270,9 +277,9 @@ void document_print_page(const document *doc, drawing *dr, int page_nr)
270 * permit each game to choose its own?) 277 * permit each game to choose its own?)
271 */ 278 */
272 tilesize = 512; 279 tilesize = 512;
273 pz->game->compute_size(pz->par, tilesize, &pixw, &pixh); 280 pz->game->compute_size(pz->par, tilesize, pz->ui, &pixw, &pixh);
274 print_begin_puzzle(dr, xm, xc, ym, yc, pixw, pixh, w, scale); 281 print_begin_puzzle(dr, xm, xc, ym, yc, pixw, pixh, w, scale);
275 pz->game->print(dr, pass == 0 ? pz->st : pz->st2, tilesize); 282 pz->game->print(dr, pass == 0 ? pz->st : pz->st2, pz->ui, tilesize);
276 print_end_puzzle(dr); 283 print_end_puzzle(dr);
277 } 284 }
278 285