#define IDM_SEED 0x00A0
#define IDM_HELPC 0x00B0
#define IDM_GAMEHELP 0x00C0
+#define IDM_ABOUT 0x00D0
#define IDM_PRESETS 0x0100
-#define IDM_ABOUT 0x0110
#define HELP_FILE_NAME "puzzles.hlp"
#define HELP_CNT_NAME "puzzles.cnt"
dputs(buf);
va_end(ap);
}
-
-#define debug(x) (debug_printf x)
-
-#else
-
-#define debug(x)
-
#endif
struct font {
HFONT cfgfont;
char *help_path;
int help_has_contents;
+ char *laststatus;
};
void fatal(char *fmt, ...)
void status_bar(frontend *fe, char *text)
{
- SetWindowText(fe->statusbar, text);
+ char *rewritten = midend_rewrite_statusbar(fe->me, text);
+ if (!fe->laststatus || strcmp(rewritten, fe->laststatus)) {
+ SetWindowText(fe->statusbar, rewritten);
+ sfree(fe->laststatus);
+ fe->laststatus = rewritten;
+ } else {
+ sfree(rewritten);
+ }
}
void frontend_default_colour(frontend *fe, float *output)
fe->fonts = NULL;
fe->nfonts = fe->fontsize = 0;
+ fe->laststatus = NULL;
+
{
int i, ncolours;
float *colours;
midend_redraw(fe->me);
}
+static int is_alt_pressed(void)
+{
+ BYTE keystate[256];
+ int r = GetKeyboardState(keystate);
+ if (!r)
+ return FALSE;
+ if (keystate[VK_MENU] & 0x80)
+ return TRUE;
+ if (keystate[VK_RMENU] & 0x80)
+ return TRUE;
+ return FALSE;
+}
+
static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
WPARAM wParam, LPARAM lParam)
{
PostQuitMessage(0);
break;
case IDM_RESTART:
- if (!midend_process_key(fe->me, 0, 0, 'r'))
- PostQuitMessage(0);
+ midend_restart_game(fe->me);
break;
case IDM_UNDO:
if (!midend_process_key(fe->me, 0, 0, 'u'))
case WM_KEYDOWN:
{
int key = -1;
+ BYTE keystate[256];
+ int r = GetKeyboardState(keystate);
+ int shift = (r && (keystate[VK_SHIFT] & 0x80)) ? MOD_SHFT : 0;
+ int ctrl = (r && (keystate[VK_CONTROL] & 0x80)) ? MOD_CTRL : 0;
switch (wParam) {
case VK_LEFT:
if (!(lParam & 0x01000000))
key = MOD_NUM_KEYPAD | '4';
- else
- key = CURSOR_LEFT;
+ else
+ key = shift | ctrl | CURSOR_LEFT;
break;
case VK_RIGHT:
if (!(lParam & 0x01000000))
key = MOD_NUM_KEYPAD | '6';
- else
- key = CURSOR_RIGHT;
+ else
+ key = shift | ctrl | CURSOR_RIGHT;
break;
case VK_UP:
if (!(lParam & 0x01000000))
key = MOD_NUM_KEYPAD | '8';
- else
- key = CURSOR_UP;
+ else
+ key = shift | ctrl | CURSOR_UP;
break;
case VK_DOWN:
if (!(lParam & 0x01000000))
key = MOD_NUM_KEYPAD | '2';
- else
- key = CURSOR_DOWN;
+ else
+ key = shift | ctrl | CURSOR_DOWN;
break;
/*
* Diagonal keys on the numeric keypad.
*/
if (message == WM_MBUTTONDOWN || (wParam & MK_SHIFT))
button = MIDDLE_BUTTON;
- else if (message == WM_LBUTTONDOWN)
- button = LEFT_BUTTON;
- else
+ else if (message == WM_RBUTTONDOWN || is_alt_pressed())
button = RIGHT_BUTTON;
+ else
+ button = LEFT_BUTTON;
if (!midend_process_key(fe->me, (signed short)LOWORD(lParam),
(signed short)HIWORD(lParam), button))
*/
if (message == WM_MBUTTONUP || (wParam & MK_SHIFT))
button = MIDDLE_RELEASE;
- else if (message == WM_LBUTTONUP)
- button = LEFT_RELEASE;
- else
+ else if (message == WM_RBUTTONUP || is_alt_pressed())
button = RIGHT_RELEASE;
+ else
+ button = LEFT_RELEASE;
if (!midend_process_key(fe->me, (signed short)LOWORD(lParam),
(signed short)HIWORD(lParam), button))
if (wParam & (MK_MBUTTON | MK_SHIFT))
button = MIDDLE_DRAG;
- else if (wParam & MK_LBUTTON)
- button = LEFT_DRAG;
- else
+ else if (wParam & MK_RBUTTON || is_alt_pressed())
button = RIGHT_DRAG;
+ else
+ button = LEFT_DRAG;
if (!midend_process_key(fe->me, (signed short)LOWORD(lParam),
(signed short)HIWORD(lParam), button))