New infrastructure feature. Games are now permitted to be

_conditionally_ able to format the current puzzle as text to be sent
to the clipboard. For instance, if a game were to support playing on
a square grid and on other kinds of grid such as hexagonal, then it
might reasonably feel that only the former could be sensibly
rendered in ASCII art; so it can now arrange for the "Copy" menu
item to be greyed out depending on the game_params.

To do this I've introduced a new backend function
(can_format_as_text_now()), and renamed the existing static backend
field "can_format_as_text" to "can_format_as_text_ever". The latter
will cause compile errors for anyone maintaining a third-party front
end; if any such person is reading this, I apologise to them for the
inconvenience, but I did do it deliberately so that they'd know to
update their front end.

As yet, no checked-in game actually uses this feature; all current
games can still either copy always or copy never.

[originally from svn r8161]
This commit is contained in:
Simon Tatham
2008-09-06 09:27:56 +00:00
parent c6b1d4472b
commit a7431c0b7c
38 changed files with 303 additions and 55 deletions

View File

@ -242,6 +242,7 @@ config_item *midend_get_config(midend *me, int which, char **wintitle);
char *midend_set_config(midend *me, int which, config_item *cfg);
char *midend_game_id(midend *me, char *id);
char *midend_get_game_id(midend *me);
int midend_can_format_as_text_now(midend *me);
char *midend_text_format(midend *me);
char *midend_solve(midend *me);
void midend_supersede_game_desc(midend *me, char *desc, char *privdesc);
@ -419,7 +420,8 @@ struct game {
int can_solve;
char *(*solve)(game_state *orig, game_state *curr,
char *aux, char **error);
int can_format_as_text;
int can_format_as_text_ever;
int (*can_format_as_text_now)(game_params *params);
char *(*text_format)(game_state *state);
game_ui *(*new_ui)(game_state *state);
void (*free_ui)(game_ui *ui);