aboutsummaryrefslogtreecommitdiff
path: root/nullfe.c
diff options
context:
space:
mode:
authorSimon Tatham <anakin@pobox.com>2023-04-22 12:54:11 +0100
committerSimon Tatham <anakin@pobox.com>2023-04-23 13:25:57 +0100
commitbb1ab36108942ed9b0c84bf68e22869994467a2a (patch)
tree85d446d041629683a8536ef8fc046e482cfde15c /nullfe.c
parentea6be8f0af766ed15b19260ae17fa793d3d6d4d8 (diff)
downloadpuzzles-bb1ab36108942ed9b0c84bf68e22869994467a2a.zip
puzzles-bb1ab36108942ed9b0c84bf68e22869994467a2a.tar.gz
puzzles-bb1ab36108942ed9b0c84bf68e22869994467a2a.tar.bz2
puzzles-bb1ab36108942ed9b0c84bf68e22869994467a2a.tar.xz
Keep a set of preferences in the midend.
This commit introduces a serialisation format for the user preferences stored in game_ui, using the keyword identifiers that get_prefs is required to write into its list of config_item. As a result, the serialisation format looks enough like an ordinary config file that a user could write one by hand. The preferences for the game backend are kept in serialised form in me->be_prefs. The typical use of this is to apply it to a just-created game_ui by calling midend_apply_prefs(), which deserialises the prefs buffer into a list of config_item and passes it to the backend's set_prefs function, overwriting the preference fields (but no others) of the game_ui. This is duly done when creating a new game, when loading a game from a save file, and also when printing a puzzle. To make the latter work, document_add_puzzle now takes a game_ui (and keeps ownership of it afterwards), and passes that to the backend's compute_size and print functions. The backend's own get_prefs and set_prefs functions are wrapped by midend_get_prefs and midend_set_prefs. This is partly as a convenience (it deals with optionally constructing a game_ui specially to call the backend with), but mostly so that there will be a convenient place in the midend to add standard preferences applying across all puzzles. No cross-puzzle preferences are provided yet. There are two external interfaces to all this, and in this commit, neither one is yet called by any frontend: A new pair of midend functions is exposed to the front end, called midend_load_prefs and midend_save_prefs. These have a similar API to midend_serialise and midend_deserialise, taking a read/write function pointer and a context. So front ends that can already load/save a game to a file on disk should find it easy to add a similar set of functions loading/saving user preferences. Secondly, a new value CFG_PREFS is added to the enumeration of configuration dialog types, alongside the ones for the Custom game type, entering a game description and entering a random seed. This should make it easy for frontends to offer a Preferences dialog, because it will operate almost exactly like three dialogs they already handle.
Diffstat (limited to 'nullfe.c')
-rw-r--r--nullfe.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/nullfe.c b/nullfe.c
index 971250e..9a57832 100644
--- a/nullfe.c
+++ b/nullfe.c
@@ -52,7 +52,7 @@ void print_line_width(drawing *dr, int width) {}
void print_line_dotted(drawing *dr, bool dotted) {}
void status_bar(drawing *dr, const char *text) {}
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) {}
void fatal(const char *fmt, ...)
{