From 5bd29d05f6a33ecbf5ee02483ba5defef545b1cf Mon Sep 17 00:00:00 2001 From: "nethack.allison" Date: Tue, 5 Feb 2002 19:04:35 +0000 Subject: [PATCH] Fixes (from ) - visual feedback after a prompt: append an empty line to the message window when clear_nhwindow(WIN_MESSAGE) is called. Filter out empty lines in the buffer except for the active slot. - append ellipses to the status line text if the text is truncated - get rid of message boxes at the end of the game (ignore empty lines in raw_print as Yitzhak suggested) --- win/win32/mhmsgwnd.c | 23 +++++++++++++++++++---- win/win32/mhstatus.c | 6 +++--- win/win32/mswproc.c | 6 ++++-- 3 files changed, 26 insertions(+), 9 deletions(-) diff --git a/win/win32/mhmsgwnd.c b/win/win32/mhmsgwnd.c index 67a585ddf..5906f33a7 100644 --- a/win/win32/mhmsgwnd.c +++ b/win/win32/mhmsgwnd.c @@ -196,11 +196,19 @@ void onMSNHCommand(HWND hWnd, WPARAM wParam, LPARAM lParam) { PMSNHMsgPutstr msg_data = (PMSNHMsgPutstr)lParam; SCROLLINFO si; + char* p; - /* append text to the end of the array */ - memmove(&data->window_text[0], - &data->window_text[1], - (MSG_LINES-1)*sizeof(data->window_text[0])); + /* check if the string is empty */ + for(p = data->window_text[MSG_LINES-1].text; *p && isspace(*p); p++); + + if( *p ) { + /* last string is not empty - scroll up */ + memmove(&data->window_text[0], + &data->window_text[1], + (MSG_LINES-1)*sizeof(data->window_text[0])); + } + + /* append new text to the end of the array */ data->window_text[MSG_LINES-1].attr = msg_data->attr; strncpy(data->window_text[MSG_LINES-1].text, msg_data->text, MAXWINDOWTEXT); @@ -220,6 +228,13 @@ void onMSNHCommand(HWND hWnd, WPARAM wParam, LPARAM lParam) case MSNH_MSG_CLEAR_WINDOW: { + MSNHMsgPutstr data; + + /* append an empty line to the message window (send message to itself) */ + data.attr = ATR_NONE; + data.text = " "; + onMSNHCommand(hWnd, (WPARAM)MSNH_MSG_PUTSTR, (LPARAM)&data); + InvalidateRect(hWnd, NULL, TRUE); break; } diff --git a/win/win32/mhstatus.c b/win/win32/mhstatus.c index b29fe1305..4b521c28e 100644 --- a/win/win32/mhstatus.c +++ b/win/win32/mhstatus.c @@ -106,7 +106,7 @@ LRESULT CALLBACK StatusWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lP int i; SIZE sz; HGDIOBJ oldFont; - TCHAR wbuf[255]; + TCHAR wbuf[BUFSZ]; hdc = BeginPaint(hWnd, &ps); GetClientRect(hWnd, &rt); @@ -115,8 +115,8 @@ LRESULT CALLBACK StatusWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lP for(i=0; iwindow_text[i], wbuf, sizeof(wbuf)), strlen(data->window_text[i]), &sz); - OemToChar(data->window_text[i], wbuf); - DrawText(hdc, wbuf, strlen(data->window_text[i]), &rt, DT_LEFT); + NH_A2W(data->window_text[i], wbuf, BUFSZ); + DrawText(hdc, wbuf, strlen(data->window_text[i]), &rt, DT_LEFT | DT_END_ELLIPSIS); rt.top += sz.cy; } diff --git a/win/win32/mswproc.c b/win/win32/mswproc.c index fe3a1398f..fbb93945e 100644 --- a/win/win32/mswproc.c +++ b/win/win32/mswproc.c @@ -734,7 +734,8 @@ void mswin_raw_print(const char *str) { TCHAR wbuf[255]; logDebug("mswin_raw_print(%s)\n", str); - MessageBox(GetNHApp()->hMainWnd, NH_A2W(str, wbuf, sizeof(wbuf)), TEXT("NetHack"), MB_OK ); + if( str && *str ) + MessageBox(GetNHApp()->hMainWnd, NH_A2W(str, wbuf, sizeof(wbuf)), TEXT("NetHack"), MB_OK ); } /* @@ -746,7 +747,8 @@ void mswin_raw_print_bold(const char *str) { TCHAR wbuf[255]; logDebug("mswin_raw_print_bold(%s)\n", str); - MessageBox(GetNHApp()->hMainWnd, NH_A2W(str, wbuf, sizeof(wbuf)), TEXT("NetHack"), MB_OK ); + if( str && *str ) + MessageBox(GetNHApp()->hMainWnd, NH_A2W(str, wbuf, sizeof(wbuf)), TEXT("NetHack"), MB_OK ); } /*