From 09aa8de52cb962f1ceebfb1fd44f2c54a924fc5c Mon Sep 17 00:00:00 2001 From: Franklin Wei Date: Mon, 22 Jul 2024 21:43:25 -0400 Subject: puzzles: resync with upstream This brings the puzzles source in sync with Simon's branch, commit fd304c5 (from March 2024), with some added Rockbox-specific compatibility changes: https://www.franklinwei.com/git/puzzles/commit/?h=rockbox-devel&id=516830d9d76bdfe64fe5ccf2a9b59c33f5c7c078 There are quite a lot of backend changes, including a new "Mosaic" puzzle. In addition, some new frontend changes were necessary: - New "Preferences" menu to access the user preferences system. - Enabled spacebar input for several games. Change-Id: I94c7df674089c92f32d5f07025f6a1059068af1e --- apps/plugins/puzzles/src/printing.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'apps/plugins/puzzles/src/printing.c') 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 @@ 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++; @@ -96,7 +99,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 +277,9 @@ 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); + 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, tilesize); + pz->game->print(dr, pass == 0 ? pz->st : pz->st2, pz->ui, tilesize); print_end_puzzle(dr); } -- cgit v1.2.3