]> granicus.if.org Git - nethack/commitdiff
CE patch (from <Someone>)
authornethack.allison <nethack.allison>
Mon, 24 May 2004 14:21:15 +0000 (14:21 +0000)
committernethack.allison <nethack.allison>
Mon, 24 May 2004 14:21:15 +0000 (14:21 +0000)
Disable processing of double-click messages if the first click
causes map to scroll. The problem is that if the first click scrolls
the map the second click is going to scroll it even further
(before it is redrawn) which is very confusing for the user.

doc/fixes34.4
sys/wince/mhmap.c

index cc240d41a9aa86914a45a7bfb71b97a7c4f6d0bb..89c9d13a6b740bb691d168e8a5fd5156db72e1fa 100644 (file)
@@ -32,6 +32,8 @@ Platform- and/or Interface-Specific Fixes
 -----------------------------------------
 unix: remove use of parentheses in nethack man page usage that confused a
        man page conversion tool
+winCE: disable processing of double-click messages if the first click
+       causes map to scroll
 
 
 General New Features
index aad79415cf4e5580af991a6ad7c5cd0ef76b520b..e089ed0e0b0e3deeccfa9642b1f2e4b01aaf8e13 100644 (file)
@@ -26,8 +26,8 @@ typedef struct mswin_nethack_map_window {
        int  xCur, yCur;                        /* position of the cursor */
        int  xScrTile, yScrTile;        /* size of display tile */
        POINT map_orig;                         /* map origin point */
-
        HFONT hMapFont;                         /* font for ASCII mode */
+       int  xLastMouseClick, yLastMouseClick;     /* last mouse click */
 } NHMapWindow, *PNHMapWindow;
 
 static TCHAR szNHMapWindowClass[] = TEXT("MSNethackMapWndClass");
@@ -324,6 +324,7 @@ void register_map_window_class()
 LRESULT CALLBACK MapWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
 {
        PNHMapWindow data;
+       int x, y;
        
        data = (PNHMapWindow)GetWindowLong(hWnd, GWL_USERDATA);
        switch (message) 
@@ -369,20 +370,24 @@ LRESULT CALLBACK MapWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPara
     } 
     break; 
 
-       case WM_LBUTTONDOWN:
-               NHEVENT_MS( 
-                       CLICK_1,
-                       max(0, min(COLNO, data->xPos + (LOWORD(lParam)-data->map_orig.x)/data->xScrTile)),
-                       max(0, min(ROWNO, data->yPos + (HIWORD(lParam)-data->map_orig.y)/data->yScrTile))
-               );
+       case WM_LBUTTONDOWN: 
+               x = max(0, min(COLNO, data->xPos + (LOWORD(lParam)-data->map_orig.x)/data->xScrTile));
+               y = max(0, min(ROWNO, data->yPos + (HIWORD(lParam)-data->map_orig.y)/data->yScrTile));
+
+               NHEVENT_MS( CLICK_1, x, y);
+
+               data->xLastMouseClick = x;
+               data->yLastMouseClick = y;
        return 0;
 
-       case WM_LBUTTONDBLCLK :
-               NHEVENT_MS( 
-                       CLICK_2,
-                       max(0, min(COLNO, data->xPos + (LOWORD(lParam)-data->map_orig.x)/data->xScrTile)),
-                       max(0, min(ROWNO, data->yPos + (HIWORD(lParam)-data->map_orig.y)/data->yScrTile))
-               );
+       case WM_LBUTTONDBLCLK:
+               x = max(0, min(COLNO, data->xPos + (LOWORD(lParam)-data->map_orig.x)/data->xScrTile));
+               y = max(0, min(ROWNO, data->yPos + (HIWORD(lParam)-data->map_orig.y)/data->yScrTile));
+
+               /* if map has scrolled since the last mouse click - ignore double-click message */
+               if( data->xLastMouseClick == x && data->yLastMouseClick == y ) {
+                       NHEVENT_MS( CLICK_1, x, y);
+               }
        return 0;
 
        case WM_DESTROY:
@@ -522,6 +527,8 @@ void onCreate(HWND hWnd, WPARAM wParam, LPARAM lParam)
        data->xScrTile = GetNHApp()->mapTile_X;
        data->yScrTile = GetNHApp()->mapTile_Y;
 
+       data->xLastMouseClick = data->yLastMouseClick = -1;
+
        SetWindowLong(hWnd, GWL_USERDATA, (LONG)data);
 }