case WM_CLOSE:
{
/* exit gracefully */
- switch(MessageBox(hWnd, TEXT("Save?"), TEXT("NetHack for Windows"), MB_YESNOCANCEL | MB_ICONQUESTION)) {
- case IDYES: NHEVENT_KBD('y'); dosave(); break;
- case IDNO: NHEVENT_KBD('q'); done(QUIT); break;
- case IDCANCEL: break;
+ if (program_state.gameover)
+ {
+ /* assume the user really meant this, as the game is already over... */
+ /* to make sure we still save bones, just set stop printing flag */
+ program_state.stopprint++;
+ NHEVENT_KBD('\033'); /* and send keyboard input as if user pressed ESC */
+ /* additional code for this is done in menu and rip windows */
+ }
+ else
+ {
+ switch(MessageBox(hWnd, TEXT("Save?"), TEXT("NetHack for Windows"), MB_YESNOCANCEL | MB_ICONQUESTION)) {
+ case IDYES: NHEVENT_KBD('y'); dosave(); break;
+ case IDNO: NHEVENT_KBD('q'); done(QUIT); break;
+ case IDCANCEL: break;
+ }
}
} return 0;
#define RIP_WIDTH 400
#define RIP_HEIGHT 200
+#define RIP_GRAVE_HEIGHT 120
+#define RIP_GRAVE_WIDTH 115
+#define RIP_GRAVE_X 90
+#define RIP_GRAVE_Y 60
+
+#define RIP_OFFSET_X 10
+#define RIP_OFFSET_Y 10
+
PNHWinApp GetNHApp(void);
typedef struct mswin_nethack_text_window {
GetWindowRect(hWnd, &riprt);
GetClientRect (hWnd, &clientrect);
textrect = clientrect;
- textrect.top += 10;
- textrect.left += 10;
- textrect.right -= 10;
+ textrect.top += RIP_OFFSET_Y;
+ textrect.left += RIP_OFFSET_X;
+ textrect.right -= RIP_OFFSET_X;
if (data->window_text)
{
hdc = GetDC (hWnd);
ReleaseDC(hWnd, hdc);
}
if (textrect.right - textrect.left > RIP_WIDTH)
- clientrect.right = textrect.right + 10 - clientrect.right;
+ clientrect.right = textrect.right + RIP_OFFSET_X - clientrect.right;
else
- clientrect.right = textrect.left + 20 + RIP_WIDTH - clientrect.right;
- clientrect.bottom = textrect.bottom + RIP_HEIGHT + 10 - clientrect.bottom;
+ clientrect.right = textrect.left + 2 * RIP_OFFSET_X + RIP_WIDTH - clientrect.right;
+ clientrect.bottom = textrect.bottom + RIP_HEIGHT + RIP_OFFSET_Y - clientrect.bottom;
GetWindowRect (GetDlgItem(hWnd, IDOK), &textrect);
textrect.right -= textrect.left;
textrect.bottom -= textrect.top;
- clientrect.bottom += textrect.bottom + 10;
+ clientrect.bottom += textrect.bottom + RIP_OFFSET_Y;
riprt.right -= riprt.left;
riprt.bottom -= riprt.top;
riprt.right += clientrect.right;
GetClientRect (hWnd, &clientrect);
MoveWindow (GetDlgItem(hWnd, IDOK),
(clientrect.right - clientrect.left - textrect.right) / 2,
- clientrect.bottom - textrect.bottom - 10, textrect.right, textrect.bottom, TRUE);
+ clientrect.bottom - textrect.bottom - RIP_OFFSET_Y, textrect.right, textrect.bottom, TRUE);
ShowWindow(hWnd, SW_SHOW);
while( IsWindow(hWnd) &&
SetBkMode (hdc, TRANSPARENT);
GetClientRect (hWnd, &clientrect);
textrect = clientrect;
- textrect.top += 10;
- textrect.left += 10;
- textrect.right -= 10;
+ textrect.top += RIP_OFFSET_Y;
+ textrect.left += RIP_OFFSET_X;
+ textrect.right -= RIP_OFFSET_X;
if (data->window_text)
{
DrawText (hdc, data->window_text, strlen(data->window_text), &textrect,
SetBkMode (hdc, TRANSPARENT);
if (data->rip_text)
{
- textrect.left += 90 + bitmap_offset;
- textrect.top = textrect.bottom + 60;
- textrect.right = textrect.left + 115;
- textrect.bottom = textrect.top + 120;
+ textrect.left += RIP_GRAVE_X + bitmap_offset;
+ textrect.top = textrect.bottom + RIP_GRAVE_Y;
+ textrect.right = textrect.left + RIP_GRAVE_WIDTH;
+ textrect.bottom = textrect.top + RIP_GRAVE_HEIGHT;
DrawText (hdc, data->rip_text, strlen(data->rip_text), &textrect,
DT_CENTER | DT_VCENTER | DT_NOPREFIX | DT_WORDBREAK);
}
switch (LOWORD(wParam))
{
case IDOK:
- case IDCANCEL:
mswin_window_mark_dead(mswin_winid_from_handle(hWnd));
if( GetNHApp()->hMainWnd==hWnd )
GetNHApp()->hMainWnd=NULL;
}
break;
+ case WM_CLOSE:
+ /* if we get this here, we saved the bones so we can just force a quit */
+
+ mswin_window_mark_dead(mswin_winid_from_handle(hWnd));
+ if( GetNHApp()->hMainWnd==hWnd )
+ GetNHApp()->hMainWnd=NULL;
+ DestroyWindow(hWnd);
+ SetFocus(GetNHApp()->hMainWnd);
+ program_state.stopprint++;
+ return TRUE;
+
case WM_DESTROY:
if( data ) {
if( data->window_text ) free(data->window_text);