mirror of
git://git.tartarus.org/simon/puzzles.git
synced 2025-04-20 23:51:29 -07:00
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:
15
windows.c
15
windows.c
@ -195,7 +195,7 @@ struct frontend {
|
||||
HBRUSH *brushes;
|
||||
HPEN *pens;
|
||||
HRGN clip;
|
||||
HMENU typemenu;
|
||||
HMENU gamemenu, typemenu;
|
||||
UINT timer;
|
||||
DWORD timer_last_tickcount;
|
||||
int npresets;
|
||||
@ -222,6 +222,7 @@ struct frontend {
|
||||
};
|
||||
|
||||
static void update_type_menu_tick(frontend *fe);
|
||||
static void update_copy_menu_greying(frontend *fe);
|
||||
|
||||
void fatal(char *fmt, ...)
|
||||
{
|
||||
@ -1573,6 +1574,7 @@ static frontend *new_window(HINSTANCE inst, char *game_id, char **error)
|
||||
HMENU menu = SHGetSubMenu(SHFindMenuBar(fe->hwnd), ID_GAME);
|
||||
DeleteMenu(menu, 0, MF_BYPOSITION);
|
||||
#endif
|
||||
fe->gamemenu = menu;
|
||||
AppendMenu(menu, MF_ENABLED, IDM_NEW, TEXT("&New"));
|
||||
AppendMenu(menu, MF_ENABLED, IDM_RESTART, TEXT("&Restart"));
|
||||
#ifndef _WIN32_WCE
|
||||
@ -1635,7 +1637,7 @@ static frontend *new_window(HINSTANCE inst, char *game_id, char **error)
|
||||
AppendMenu(menu, MF_ENABLED, IDM_UNDO, TEXT("Undo"));
|
||||
AppendMenu(menu, MF_ENABLED, IDM_REDO, TEXT("Redo"));
|
||||
#ifndef _WIN32_WCE
|
||||
if (thegame.can_format_as_text) {
|
||||
if (thegame.can_format_as_text_ever) {
|
||||
AppendMenu(menu, MF_SEPARATOR, 0, 0);
|
||||
AppendMenu(menu, MF_ENABLED, IDM_COPY, TEXT("&Copy"));
|
||||
}
|
||||
@ -1680,6 +1682,7 @@ static frontend *new_window(HINSTANCE inst, char *game_id, char **error)
|
||||
SetForegroundWindow(fe->hwnd);
|
||||
|
||||
update_type_menu_tick(fe);
|
||||
update_copy_menu_greying(fe);
|
||||
|
||||
midend_redraw(fe->me);
|
||||
|
||||
@ -2657,11 +2660,19 @@ static void update_type_menu_tick(frontend *fe)
|
||||
DrawMenuBar(fe->hwnd);
|
||||
}
|
||||
|
||||
static void update_copy_menu_greying(frontend *fe)
|
||||
{
|
||||
UINT enable = (midend_can_format_as_text_now(fe->me) ?
|
||||
MF_ENABLED : MF_GRAYED);
|
||||
EnableMenuItem(fe->gamemenu, IDM_COPY, MF_BYCOMMAND | enable);
|
||||
}
|
||||
|
||||
static void new_game_type(frontend *fe)
|
||||
{
|
||||
midend_new_game(fe->me);
|
||||
new_game_size(fe);
|
||||
update_type_menu_tick(fe);
|
||||
update_copy_menu_greying(fe);
|
||||
}
|
||||
|
||||
static int is_alt_pressed(void)
|
||||
|
Reference in New Issue
Block a user