aboutsummaryrefslogtreecommitdiff
path: root/nullfe.c (follow)
Commit message (Collapse)AuthorAge
* Keep a set of preferences in the midend.Simon Tatham2023-04-23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Extend fuzzpuzz to test more codeBen Harris2023-02-13
| | | | | | Now if the input save file loads correctly, fuzzpuzz asks the back-end to draw the puzzle. All the drawing operations are no-ops, but this tests the drawing code in the back-end.
* Remove some midend functions from nullfe.cBen Harris2023-01-12
| | | | | | | As far as I can tell, nothing that uses nullfe.c depends on these functions. On the other hand, they do make it impossible to include nullfe.c and midend.c in the same program. If anything does turn out to need them, they can be spun off into nullme.c or something.
* Add more functions to nullfe.cBen Harris2023-01-12
| | | | | | | The null get_random_seed required a little care. It's not OK for it to return NULL and zero because NULL isn't a valid argument to memcpy() even with a length of zero (thank you UBSan). So we return a single zero byte instead.
* Add 'const' to the draw_polygon coords array parameter.Simon Tatham2021-09-13
| | | | Thanks to Mouse for spotting that it was missing.
* Adopt C99 bool in the printing API.Simon Tatham2018-11-13
| | | | | | | | | | | | | | Not many changes here: the 'dotted' flag passed to print_line_dotted is bool, and so is the printing_in_colour flag passed to print_get_colour. Also ps_init() takes a bool. line_dotted is also a method in the drawing API structure, but it's not actually filled in for any non-print-oriented implementation of that API. So only front ends that do platform-specific _printing_ should need to make a corresponding change. In-tree, for example, windows.c needed a fix because it prints via Windows GDI, but gtk.c didn't have to do anything, because its CLI-based printing facility just delegates to ps.c.
* Assorted char * -> const char * API changes.Simon Tatham2017-10-01
| | | | | | I went through all the char * parameters and return values I could see in puzzles.h by eye and spotted ones that surely ought to have been const all along.
* Rework the preset menu system to permit submenus.Simon Tatham2017-04-26
| | | | | | | | | | | | | | | | | | | | To do this, I've completely replaced the API between mid-end and front end, so any downstream front end maintainers will have to do some rewriting of their own (sorry). I've done the necessary work in all five of the front ends I keep in-tree here - Windows, GTK, OS X, Javascript/Emscripten, and Java/NestedVM - and I've done it in various different styles (as each front end found most convenient), so that should provide a variety of sample code to show downstreams how, if they should need it. I've left in the old puzzle back-end API function to return a flat list of presets, so for the moment, all the puzzle backends are unchanged apart from an extra null pointer appearing in their top-level game structure. In a future commit I'll actually use the new feature in a puzzle; perhaps in the further future it might make sense to migrate all the puzzles to the new API and stop providing back ends with two alternative ways of doing things, but this seemed like enough upheaval for one day.
* Patch from Mark Wooding to introduce a draw_thick_line() function inSimon Tatham2010-05-29
| | | | | | | | | | | | the drawing API, for use by Loopy. It's optional: drawing.c will construct an acceptable alternative using a filled polygon if the front end doesn't provide it. Net and Netslide previously had static functions called draw_thick_line(), whose claim to the name is less justified and so they've been renamed. [originally from svn r8962]
* Introduce, and implement as usefully as I can in all front ends, aSimon Tatham2009-12-27
| | | | | | | | | | new function in the drawing API which permits the display of text from outside basic ASCII. A fallback mechanism is provided so that puzzles can give a list of strings they'd like to display in order of preference and the system will return the best one it can manage; puzzles are required to cope with ASCII-only front ends. [originally from svn r8793]
* Introduce some infrastructure to permit games' print functions toSimon Tatham2009-02-22
| | | | | | draw dotted lines. No puzzle yet uses this, but one's about to. [originally from svn r8453]
* Revise the printing colour framework so that we can explicitlySimon Tatham2008-04-07
| | | | | | | request either of hatching or halftoning, and also choose which to supply as a fallback when printing in colour. [originally from svn r7976]
* Add James Harvey's excellent new puzzle, `Galaxies'.Simon Tatham2007-02-22
| | | | [originally from svn r7304]
* James H has implemented a new `Tricky' difficulty level in Light Up:Simon Tatham2005-09-01
a non-recursive level above Easy, which therefore moves the recursive Hard mode further up still. Play-testing suggests that in fact Tricky is often _harder_ than the old Hard mode, since the latter had limited depth of recursion and would therefore spot complex deductions only if it happened to start a recursion on the right square; Tricky may be limited in the sophistication of its complex deductions, but it never misses one, so its puzzles tend to be hard all over. Also in this checkin, a new source file `nullfe.c', containing all the annoying stub functions required to make command-line solvers link successfully. James wrote this for (the new) lightupsolver, and I've used it to simplify the other stand-alone solvers. [originally from svn r6254]