win32_gui: mimic tty interface when "Nethack mode" is selected (remove window features)
This commit is contained in:
@@ -100,6 +100,10 @@ OPTIONS=hilite_pet,!toptenwin
|
||||
# window, windowframe, windowtext.
|
||||
#OPTIONS=windowcolors:status windowtext/window message windowtext/window
|
||||
|
||||
# "Nethack mode" colors
|
||||
OPTIONS=windowcolors:status white/#000000 message white/#000000 text white/#000000 menu white/#000000 menutext white/#000000
|
||||
OPTIONS=vary_msgcount:1
|
||||
|
||||
# *** LOCATIONS ***
|
||||
# IMPORTANT: If you change any of these locations, the directories they
|
||||
# point at must exist. NetHack will not create them for you.
|
||||
|
||||
@@ -34,6 +34,7 @@ static int menuid2mapmode(int menuid);
|
||||
static int mapmode2menuid(int map_mode);
|
||||
static void nhlock_windows(BOOL lock);
|
||||
static char *nh_compose_ascii_screenshot();
|
||||
static void mswin_apply_window_style_all();
|
||||
// returns strdup() created pointer - callee assumes the ownership
|
||||
|
||||
HWND
|
||||
@@ -711,11 +712,12 @@ mswin_layout_main_window(HWND changed_child)
|
||||
/* kludge - inventory window should have its own type (same as
|
||||
menu-text
|
||||
as a matter of fact) */
|
||||
if (flags.perm_invent && i == WIN_INVEN)
|
||||
if (flags.perm_invent && i == WIN_INVEN) {
|
||||
mswin_get_window_placement(NHW_INVEN, &rt);
|
||||
else
|
||||
} else {
|
||||
mswin_get_window_placement(GetNHApp()->windowlist[i].type,
|
||||
&rt);
|
||||
}
|
||||
|
||||
MoveWindow(GetNHApp()->windowlist[i].win, rt.left, rt.top,
|
||||
rt.right - rt.left, rt.bottom - rt.top, TRUE);
|
||||
@@ -879,6 +881,7 @@ onWMCommand(HWND hWnd, WPARAM wParam, LPARAM lParam)
|
||||
case IDM_NHMODE: {
|
||||
GetNHApp()->regNetHackMode = GetNHApp()->regNetHackMode ? 0 : 1;
|
||||
mswin_menu_check_intf_mode();
|
||||
mswin_apply_window_style_all();
|
||||
break;
|
||||
}
|
||||
case IDM_CLEARSETTINGS: {
|
||||
@@ -1099,29 +1102,50 @@ mapmode2menuid(int map_mode)
|
||||
void
|
||||
nhlock_windows(BOOL lock)
|
||||
{
|
||||
int i;
|
||||
|
||||
/* go through the windows list and adjust sizes */
|
||||
for (i = 0; i < MAXWINDOWS; i++) {
|
||||
if (IsWindow(GetNHApp()->windowlist[i].win)
|
||||
&& !GetNHApp()->windowlist[i].dead) {
|
||||
DWORD style;
|
||||
style = GetWindowLong(GetNHApp()->windowlist[i].win, GWL_STYLE);
|
||||
if (lock)
|
||||
style &= ~WS_CAPTION;
|
||||
else
|
||||
style |= WS_CAPTION;
|
||||
SetWindowLong(GetNHApp()->windowlist[i].win, GWL_STYLE, style);
|
||||
SetWindowPos(GetNHApp()->windowlist[i].win, NULL, 0, 0, 0, 0,
|
||||
SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER
|
||||
| SWP_FRAMECHANGED);
|
||||
}
|
||||
}
|
||||
|
||||
/* update menu */
|
||||
GetNHApp()->bWindowsLocked = lock;
|
||||
CheckMenuItem(GetMenu(GetNHApp()->hMainWnd), IDM_SETTING_LOCKWINDOWS,
|
||||
MF_BYCOMMAND | (lock ? MF_CHECKED : MF_UNCHECKED));
|
||||
|
||||
/* restyle windows */
|
||||
mswin_apply_window_style_all();
|
||||
}
|
||||
|
||||
void
|
||||
mswin_apply_window_style(HWND hwnd) {
|
||||
DWORD style = 0, exstyle = 0;
|
||||
|
||||
style = GetWindowLong(hwnd, GWL_STYLE);
|
||||
exstyle = GetWindowLong(hwnd, GWL_EXSTYLE);
|
||||
|
||||
if( !GetNHApp()->bWindowsLocked ) {
|
||||
style = WS_CHILD|WS_CLIPSIBLINGS|WS_CAPTION|WS_SIZEBOX|(style & (WS_VISIBLE|WS_VSCROLL|WS_HSCROLL));
|
||||
exstyle = WS_EX_WINDOWEDGE;
|
||||
} else if (GetNHApp()->regNetHackMode) {
|
||||
/* do away borders */
|
||||
style = WS_CHILD|WS_CLIPSIBLINGS|(style & (WS_VISIBLE|WS_VSCROLL|WS_HSCROLL));
|
||||
exstyle = 0;
|
||||
} else {
|
||||
style = WS_CHILD|WS_CLIPSIBLINGS|WS_THICKFRAME|(style & (WS_VISIBLE|WS_VSCROLL|WS_HSCROLL));
|
||||
exstyle = WS_EX_WINDOWEDGE;
|
||||
}
|
||||
|
||||
SetWindowLong(hwnd, GWL_STYLE, style);
|
||||
SetWindowLong(hwnd, GWL_EXSTYLE, exstyle);
|
||||
SetWindowPos(hwnd, NULL, 0, 0, 0, 0,
|
||||
SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED | SWP_NOCOPYBITS);
|
||||
}
|
||||
|
||||
void
|
||||
mswin_apply_window_style_all() {
|
||||
int i;
|
||||
for (i = 0; i < MAXWINDOWS; i++) {
|
||||
if (IsWindow(GetNHApp()->windowlist[i].win)
|
||||
&& !GetNHApp()->windowlist[i].dead) {
|
||||
mswin_apply_window_style(GetNHApp()->windowlist[i].win);
|
||||
}
|
||||
}
|
||||
mswin_layout_main_window(NULL);
|
||||
}
|
||||
|
||||
// returns strdup() created pointer - callee assumes the ownership
|
||||
|
||||
@@ -89,6 +89,8 @@ mswin_init_map_window()
|
||||
/* Set window caption */
|
||||
SetWindowText(ret, "Map");
|
||||
|
||||
mswin_apply_window_style(ret);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -119,15 +119,7 @@ mswin_init_menu_window(int type)
|
||||
/* Set window caption */
|
||||
SetWindowText(ret, "Menu/Text");
|
||||
|
||||
if (!GetNHApp()->bWindowsLocked) {
|
||||
DWORD style;
|
||||
style = GetWindowLong(ret, GWL_STYLE);
|
||||
style |= WS_CAPTION;
|
||||
SetWindowLong(ret, GWL_STYLE, style);
|
||||
SetWindowPos(ret, NULL, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE
|
||||
| SWP_NOZORDER
|
||||
| SWP_FRAMECHANGED);
|
||||
}
|
||||
mswin_apply_window_style(ret);
|
||||
|
||||
SetMenuType(ret, type);
|
||||
return ret;
|
||||
@@ -155,7 +147,7 @@ mswin_menu_window_select_menu(HWND hWnd, int how, MENU_ITEM_P **_selected,
|
||||
activate = TRUE;
|
||||
}
|
||||
|
||||
data->is_active = activate;
|
||||
data->is_active = activate && !GetNHApp()->regNetHackMode;
|
||||
|
||||
/* set menu type */
|
||||
SetMenuListType(hWnd, how);
|
||||
@@ -485,7 +477,12 @@ MenuWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
: SYSCLR_TO_BRUSH(DEFAULT_COLOR_BG_TEXT));
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
return FALSE;
|
||||
|
||||
case WM_CTLCOLORDLG:
|
||||
return (INT_PTR)(text_bg_brush
|
||||
? text_bg_brush
|
||||
: SYSCLR_TO_BRUSH(DEFAULT_COLOR_BG_TEXT));
|
||||
|
||||
case WM_DESTROY:
|
||||
if (data) {
|
||||
@@ -801,17 +798,17 @@ SetMenuListType(HWND hWnd, int how)
|
||||
|
||||
switch (how) {
|
||||
case PICK_NONE:
|
||||
dwStyles = WS_VISIBLE | WS_TABSTOP | WS_BORDER | WS_CHILD | WS_VSCROLL
|
||||
dwStyles = WS_VISIBLE | WS_TABSTOP | WS_CHILD | WS_VSCROLL
|
||||
| WS_HSCROLL | LVS_REPORT | LVS_OWNERDRAWFIXED
|
||||
| LVS_SINGLESEL;
|
||||
break;
|
||||
case PICK_ONE:
|
||||
dwStyles = WS_VISIBLE | WS_TABSTOP | WS_BORDER | WS_CHILD | WS_VSCROLL
|
||||
dwStyles = WS_VISIBLE | WS_TABSTOP | WS_CHILD | WS_VSCROLL
|
||||
| WS_HSCROLL | LVS_REPORT | LVS_OWNERDRAWFIXED
|
||||
| LVS_SINGLESEL;
|
||||
break;
|
||||
case PICK_ANY:
|
||||
dwStyles = WS_VISIBLE | WS_TABSTOP | WS_BORDER | WS_CHILD | WS_VSCROLL
|
||||
dwStyles = WS_VISIBLE | WS_TABSTOP | WS_CHILD | WS_VSCROLL
|
||||
| WS_HSCROLL | LVS_REPORT | LVS_OWNERDRAWFIXED
|
||||
| LVS_SINGLESEL;
|
||||
break;
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
#define MSG_WRAP_TEXT
|
||||
|
||||
#define MSG_VISIBLE_LINES max(iflags.wc_vary_msgcount, 2)
|
||||
#define MSG_VISIBLE_LINES max(iflags.wc_vary_msgcount, 1)
|
||||
#define MAX_MSG_LINES 128
|
||||
#define MSG_LINES (int) min(iflags.msg_history, MAX_MSG_LINES)
|
||||
#define MAXWINDOWTEXT TBUFSZ
|
||||
@@ -108,6 +108,8 @@ mswin_init_message_window()
|
||||
/* Set window caption */
|
||||
SetWindowText(ret, "Messages");
|
||||
|
||||
mswin_apply_window_style(ret);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -80,6 +80,9 @@ mswin_init_status_window()
|
||||
|
||||
ZeroMemory(data, sizeof(NHStatusWindow));
|
||||
SetWindowLongPtr(ret, GWLP_USERDATA, (LONG_PTR) data);
|
||||
|
||||
mswin_apply_window_style(ret);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -51,15 +51,6 @@ mswin_init_text_window()
|
||||
|
||||
/* Set window caption */
|
||||
SetWindowText(ret, "Text");
|
||||
if (!GetNHApp()->bWindowsLocked) {
|
||||
DWORD style;
|
||||
style = GetWindowLong(ret, GWL_STYLE);
|
||||
style |= WS_CAPTION;
|
||||
SetWindowLong(ret, GWL_STYLE, style);
|
||||
SetWindowPos(ret, NULL, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE
|
||||
| SWP_NOZORDER
|
||||
| SWP_FRAMECHANGED);
|
||||
}
|
||||
|
||||
/* create and set window data */
|
||||
data = (PNHTextWindow) malloc(sizeof(NHTextWindow));
|
||||
@@ -67,6 +58,9 @@ mswin_init_text_window()
|
||||
panic("out of memory");
|
||||
ZeroMemory(data, sizeof(NHTextWindow));
|
||||
SetWindowLongPtr(ret, GWLP_USERDATA, (LONG_PTR) data);
|
||||
|
||||
mswin_apply_window_style(ret);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -239,20 +233,35 @@ LayoutText(HWND hWnd)
|
||||
/* get window coordinates */
|
||||
GetClientRect(hWnd, &clrt);
|
||||
|
||||
/* set window placements */
|
||||
GetWindowRect(btn_ok, &rt);
|
||||
sz_ok.cx = clrt.right - clrt.left;
|
||||
sz_ok.cy = rt.bottom - rt.top;
|
||||
pt_ok.x = clrt.left;
|
||||
pt_ok.y = clrt.bottom - sz_ok.cy;
|
||||
if( !GetNHApp()->regNetHackMode ) {
|
||||
/* set window placements */
|
||||
GetWindowRect(btn_ok, &rt);
|
||||
sz_ok.cx = clrt.right - clrt.left;
|
||||
sz_ok.cy = rt.bottom - rt.top;
|
||||
pt_ok.x = clrt.left;
|
||||
pt_ok.y = clrt.bottom - sz_ok.cy;
|
||||
|
||||
pt_elem.x = clrt.left;
|
||||
pt_elem.y = clrt.top;
|
||||
sz_elem.cx = clrt.right - clrt.left;
|
||||
sz_elem.cy = pt_ok.y;
|
||||
pt_elem.x = clrt.left;
|
||||
pt_elem.y = clrt.top;
|
||||
sz_elem.cx = clrt.right - clrt.left;
|
||||
sz_elem.cy = pt_ok.y;
|
||||
|
||||
MoveWindow(text, pt_elem.x, pt_elem.y, sz_elem.cx, sz_elem.cy, TRUE);
|
||||
MoveWindow(btn_ok, pt_ok.x, pt_ok.y, sz_ok.cx, sz_ok.cy, TRUE);
|
||||
MoveWindow(text, pt_elem.x, pt_elem.y, sz_elem.cx, sz_elem.cy, TRUE);
|
||||
MoveWindow(btn_ok, pt_ok.x, pt_ok.y, sz_ok.cx, sz_ok.cy, TRUE);
|
||||
} else {
|
||||
sz_ok.cx = sz_ok.cy = 0;
|
||||
|
||||
pt_ok.x = pt_ok.y = 0;
|
||||
pt_elem.x = clrt.left;
|
||||
pt_elem.y = clrt.top;
|
||||
|
||||
sz_elem.cx = clrt.right - clrt.left;
|
||||
sz_elem.cy = clrt.bottom - clrt.top;
|
||||
|
||||
ShowWindow(btn_ok, SW_HIDE);
|
||||
MoveWindow(text, pt_elem.x, pt_elem.y, sz_elem.cx, sz_elem.cy, TRUE );
|
||||
}
|
||||
mswin_apply_window_style(text);
|
||||
}
|
||||
|
||||
/* Edit box hook */
|
||||
|
||||
@@ -210,7 +210,7 @@ mswin_init_nhwindows(int *argc, char **argv)
|
||||
*/
|
||||
iflags.toptenwin = 1;
|
||||
set_option_mod_status("toptenwin", SET_IN_FILE);
|
||||
set_option_mod_status("perm_invent", SET_IN_FILE);
|
||||
//set_option_mod_status("perm_invent", SET_IN_FILE);
|
||||
|
||||
/* initialize map tiles bitmap */
|
||||
initMapTiles();
|
||||
@@ -2279,7 +2279,7 @@ mswin_read_reg()
|
||||
is
|
||||
read from the registry, so these defaults apply. */
|
||||
GetNHApp()->saveRegistrySettings = 1; /* Normally, we always save */
|
||||
GetNHApp()->regNetHackMode = 0;
|
||||
GetNHApp()->regNetHackMode = TRUE;
|
||||
|
||||
if (RegOpenKeyEx(HKEY_CURRENT_USER, keystring, 0, KEY_READ, &key)
|
||||
!= ERROR_SUCCESS)
|
||||
|
||||
@@ -201,6 +201,7 @@ void mswin_write_reg(void);
|
||||
|
||||
void mswin_get_window_placement(int type, LPRECT rt);
|
||||
void mswin_update_window_placement(int type, LPRECT rt);
|
||||
void mswin_apply_window_style(HWND hwnd);
|
||||
|
||||
int NHMessageBox(HWND hWnd, LPCTSTR text, UINT type);
|
||||
|
||||
|
||||
@@ -135,9 +135,9 @@ STYLE WS_CHILD | WS_CLIPSIBLINGS | WS_THICKFRAME
|
||||
EXSTYLE WS_EX_CLIENTEDGE | WS_EX_CONTROLPARENT
|
||||
FONT 8, "MS Sans Serif", 0, 0
|
||||
BEGIN
|
||||
LISTBOX IDC_MENU_LIST,10,10,170,55,LBS_SORT
|
||||
LISTBOX IDC_MENU_LIST,10,10,170,55,LBS_SORT | NOT WS_BORDER
|
||||
EDITTEXT IDC_MENU_TEXT,10,70,170,60,ES_MULTILINE | ES_OEMCONVERT |
|
||||
ES_READONLY | WS_VSCROLL | WS_HSCROLL | NOT WS_TABSTOP
|
||||
ES_READONLY | WS_VSCROLL | WS_HSCROLL | NOT WS_TABSTOP | NOT WS_BORDER
|
||||
DEFPUSHBUTTON "OK",IDOK,7,132,50,14,BS_FLAT | NOT WS_TABSTOP
|
||||
PUSHBUTTON "Cancel",IDCANCEL,130,132,50,14,BS_FLAT | NOT WS_TABSTOP
|
||||
END
|
||||
|
||||
Reference in New Issue
Block a user