]> granicus.if.org Git - nethack/commitdiff
win32_gui: mimic tty interface when "Nethack mode" is selected (remove window features)
authorAlex Kompel <barbos+nethack@gmail.com>
Mon, 4 Jan 2016 03:52:05 +0000 (19:52 -0800)
committerAlex Kompel <barbos+nethack@gmail.com>
Mon, 4 Jan 2016 03:52:05 +0000 (19:52 -0800)
sys/winnt/defaults.nh
win/win32/mhmain.c
win/win32/mhmap.c
win/win32/mhmenu.c
win/win32/mhmsgwnd.c
win/win32/mhstatus.c
win/win32/mhtext.c
win/win32/mswproc.c
win/win32/winMS.h
win/win32/winhack.rc

index 562f2267d88d65df1f864b41ff39d1f07bde4a78..50e801f0317fd8c2376ac5309c1640c6e0f16974 100644 (file)
@@ -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.
index 2bf5029df7e8a5fdce51583d84b1f33e290913a0..2b52f71cf1cd9fb4556c366f6233a59442d859fd 100644 (file)
@@ -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;
+    /* update menu */
+    GetNHApp()->bWindowsLocked = lock;
+    CheckMenuItem(GetMenu(GetNHApp()->hMainWnd), IDM_SETTING_LOCKWINDOWS,
+                  MF_BYCOMMAND | (lock ? MF_CHECKED : MF_UNCHECKED));
 
-    /* go through the windows list and adjust sizes */
+    /* 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) {
-            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);
+            mswin_apply_window_style(GetNHApp()->windowlist[i].win);
         }
     }
-
-    /* update menu */
-    GetNHApp()->bWindowsLocked = lock;
-    CheckMenuItem(GetMenu(GetNHApp()->hMainWnd), IDM_SETTING_LOCKWINDOWS,
-                  MF_BYCOMMAND | (lock ? MF_CHECKED : MF_UNCHECKED));
+    mswin_layout_main_window(NULL);
 }
 
 // returns strdup() created pointer - callee assumes the ownership
index 23501575e8d73087c662dff7c1b77520d65387a5..5e9ac26308e9c7032678ba78cbd515d6026b549f 100644 (file)
@@ -89,6 +89,8 @@ mswin_init_map_window()
     /* Set window caption */
     SetWindowText(ret, "Map");
 
+    mswin_apply_window_style(ret);
+
     return ret;
 }
 
index 258eed46de403b8892337e8edb59ce51d4e88821..2a65afc8586fd4296c53a45c338d428ef3c0a76f 100644 (file)
@@ -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;
index 44ec7810377ba13f94b551c3e8e5a0b8ba14699f..e30a099b31e71756e607103581ac0cd51de945cd 100644 (file)
@@ -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;
 }
 
index 21d3b7bf2dd475f0c63c380edd3ca36c865f695e..fce51f2685c7e8ce27ff8e3de598c7ebe95d1dc0 100644 (file)
@@ -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;
 }
 
index 4dd7a105929bbdaf96e596ea26fd13692ea20b83..626e46e2beaa1ebb1c116d0c8ebd96d4a6f34717 100644 (file)
@@ -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;
+
+        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;
 
-    pt_elem.x = clrt.left;
-    pt_elem.y = clrt.top;
-    sz_elem.cx = clrt.right - clrt.left;
-    sz_elem.cy = pt_ok.y;
+        sz_elem.cx = clrt.right - clrt.left;
+        sz_elem.cy = clrt.bottom - clrt.top;
 
-    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);
+        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 */
index 073cd1501c9c683b70db41f04fd0c9329a3d1502..e386ee50ee5c16c3a893d7e1b3e36c1f4e7f7b00 100644 (file)
@@ -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)
index e2720fccc9067e8bcc2d5850b39ada82bbf210b3..7938d83d12598bbb24ba727e3a5fc48bcc860867 100644 (file)
@@ -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);
 
index 44a5de42e16dde64bad9dc4db3c926a36ac6d083..fbe856b425fe348bef1c0604f953910e96c1ce9b 100644 (file)
@@ -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