One of the beta testers asked if the win32 scrolling
offset could be configured. This allows it to be set from the config file using: win32_map_cliparound_margin.
This commit is contained in:
@@ -1787,6 +1787,20 @@ goodfruit:
|
|||||||
badoption(opts);
|
badoption(opts);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
/* win32_map_cliparound_margin:nn */
|
||||||
|
fullname = "win32_map_cliparound_margin";
|
||||||
|
if (match_optname(opts, fullname, sizeof("win32_map_cliparound_margin")-1, TRUE)) {
|
||||||
|
if (negated) {
|
||||||
|
bad_negation(fullname, FALSE);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if (!(opts = string_for_env_opt(fullname, opts, FALSE))) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!set_win32_option(fullname, opts))
|
||||||
|
badoption(opts);
|
||||||
|
return;
|
||||||
|
}
|
||||||
#endif /* MSWIN_GRAPHICS */
|
#endif /* MSWIN_GRAPHICS */
|
||||||
|
|
||||||
fullname = "windowtype";
|
fullname = "windowtype";
|
||||||
|
|||||||
+11
-11
@@ -11,7 +11,6 @@
|
|||||||
|
|
||||||
#define NHMAP_FONT_NAME TEXT("Terminal")
|
#define NHMAP_FONT_NAME TEXT("Terminal")
|
||||||
#define MAXWINDOWTEXT 255
|
#define MAXWINDOWTEXT 255
|
||||||
#define CLIPAROUND_MARGIN 5
|
|
||||||
|
|
||||||
extern short glyph2tile[];
|
extern short glyph2tile[];
|
||||||
|
|
||||||
@@ -384,37 +383,38 @@ void onMSNHCommand(HWND hWnd, WPARAM wParam, LPARAM lParam)
|
|||||||
PMSNHMsgClipAround msg_data = (PMSNHMsgClipAround)lParam;
|
PMSNHMsgClipAround msg_data = (PMSNHMsgClipAround)lParam;
|
||||||
int x, y;
|
int x, y;
|
||||||
BOOL scroll_x, scroll_y;
|
BOOL scroll_x, scroll_y;
|
||||||
|
int mcam = GetNHApp()->mapCliparoundMargin;
|
||||||
|
|
||||||
/* calculate if you should clip around */
|
/* calculate if you should clip around */
|
||||||
scroll_x =
|
scroll_x =
|
||||||
!GetNHApp()->bNoHScroll &&
|
!GetNHApp()->bNoHScroll &&
|
||||||
( msg_data->x<(data->xPos+CLIPAROUND_MARGIN) ||
|
( msg_data->x<(data->xPos+mcam) ||
|
||||||
msg_data->x>(data->xPos+data->xPageSize-CLIPAROUND_MARGIN) );
|
msg_data->x>(data->xPos+data->xPageSize-mcam) );
|
||||||
scroll_y =
|
scroll_y =
|
||||||
!GetNHApp()->bNoVScroll &&
|
!GetNHApp()->bNoVScroll &&
|
||||||
( msg_data->y<(data->yPos+CLIPAROUND_MARGIN) ||
|
( msg_data->y<(data->yPos+mcam) ||
|
||||||
msg_data->y>(data->yPos+data->yPageSize-CLIPAROUND_MARGIN) );
|
msg_data->y>(data->yPos+data->yPageSize-mcam) );
|
||||||
|
|
||||||
/* get page size and center horizontally on x-position */
|
/* get page size and center horizontally on x-position */
|
||||||
if( scroll_x ) {
|
if( scroll_x ) {
|
||||||
if( data->xPageSize<=2*CLIPAROUND_MARGIN ) {
|
if( data->xPageSize<=2*mcam ) {
|
||||||
x = max(0, min(COLNO, msg_data->x - data->xPageSize/2));
|
x = max(0, min(COLNO, msg_data->x - data->xPageSize/2));
|
||||||
} else if( msg_data->x < data->xPos+data->xPageSize/2 ) {
|
} else if( msg_data->x < data->xPos+data->xPageSize/2 ) {
|
||||||
x = max(0, min(COLNO, msg_data->x - CLIPAROUND_MARGIN));
|
x = max(0, min(COLNO, msg_data->x - mcam));
|
||||||
} else {
|
} else {
|
||||||
x = max(0, min(COLNO, msg_data->x - data->xPageSize + CLIPAROUND_MARGIN));
|
x = max(0, min(COLNO, msg_data->x - data->xPageSize + mcam));
|
||||||
}
|
}
|
||||||
SendMessage( hWnd, WM_HSCROLL, (WPARAM)MAKELONG(SB_THUMBTRACK, x), (LPARAM)NULL );
|
SendMessage( hWnd, WM_HSCROLL, (WPARAM)MAKELONG(SB_THUMBTRACK, x), (LPARAM)NULL );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* get page size and center vertically on y-position */
|
/* get page size and center vertically on y-position */
|
||||||
if( scroll_y ) {
|
if( scroll_y ) {
|
||||||
if( data->yPageSize<=2*CLIPAROUND_MARGIN ) {
|
if( data->yPageSize<=2*mcam ) {
|
||||||
y = max(0, min(ROWNO, msg_data->y - data->yPageSize/2));
|
y = max(0, min(ROWNO, msg_data->y - data->yPageSize/2));
|
||||||
} else if( msg_data->y < data->yPos+data->yPageSize/2 ) {
|
} else if( msg_data->y < data->yPos+data->yPageSize/2 ) {
|
||||||
y = max(0, min(ROWNO, msg_data->y - CLIPAROUND_MARGIN));
|
y = max(0, min(ROWNO, msg_data->y - mcam));
|
||||||
} else {
|
} else {
|
||||||
y = max(0, min(ROWNO, msg_data->y - data->yPageSize + CLIPAROUND_MARGIN));
|
y = max(0, min(ROWNO, msg_data->y - data->yPageSize + mcam));
|
||||||
}
|
}
|
||||||
SendMessage( hWnd, WM_VSCROLL, (WPARAM)MAKELONG(SB_THUMBTRACK, y), (LPARAM)NULL );
|
SendMessage( hWnd, WM_VSCROLL, (WPARAM)MAKELONG(SB_THUMBTRACK, y), (LPARAM)NULL );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,4 +28,6 @@ int mswin_map_mode(HWND hWnd, int mode);
|
|||||||
|
|
||||||
#define ROGUE_LEVEL_MAP_MODE NHMAP_VIEW_ASCII12x16
|
#define ROGUE_LEVEL_MAP_MODE NHMAP_VIEW_ASCII12x16
|
||||||
|
|
||||||
|
#define DEF_CLIPAROUND_MARGIN 5
|
||||||
|
|
||||||
#endif /* MSWINMapWindow_h */
|
#endif /* MSWINMapWindow_h */
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ typedef struct mswin_nhwindow_app {
|
|||||||
|
|
||||||
int mapDisplayMode; /* regular map display mode */
|
int mapDisplayMode; /* regular map display mode */
|
||||||
int mapDisplayModeSave; /* saved map display mode */
|
int mapDisplayModeSave; /* saved map display mode */
|
||||||
|
int mapCliparoundMargin; /* when to scroll display */
|
||||||
|
|
||||||
int winStatusAlign; /* alignment of the status window */
|
int winStatusAlign; /* alignment of the status window */
|
||||||
int winMessageAlign; /* alignment of the status window */
|
int winMessageAlign; /* alignment of the status window */
|
||||||
|
|||||||
@@ -61,6 +61,7 @@ int APIENTRY WinMain(HINSTANCE hInstance,
|
|||||||
_nethack_app.mapDisplayMode = NHMAP_VIEW_TILES;
|
_nethack_app.mapDisplayMode = NHMAP_VIEW_TILES;
|
||||||
_nethack_app.winStatusAlign = NHWND_ALIGN_BOTTOM;
|
_nethack_app.winStatusAlign = NHWND_ALIGN_BOTTOM;
|
||||||
_nethack_app.winMessageAlign = NHWND_ALIGN_TOP;
|
_nethack_app.winMessageAlign = NHWND_ALIGN_TOP;
|
||||||
|
_nethack_app.mapCliparoundMargin = DEF_CLIPAROUND_MARGIN;
|
||||||
|
|
||||||
// init controls
|
// init controls
|
||||||
ZeroMemory(&InitCtrls, sizeof(InitCtrls));
|
ZeroMemory(&InitCtrls, sizeof(InitCtrls));
|
||||||
@@ -190,6 +191,13 @@ int set_win32_option( const char * name, const char * val)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
} else if( _stricmp(name, "win32_map_cliparound_margin")==0 ) {
|
||||||
|
int tmp = atoi(val);
|
||||||
|
/* Alex, this range should be revisited and groundtruthed */
|
||||||
|
if( tmp >= DEF_CLIPAROUND_MARGIN && tmp < COLNO/2) {
|
||||||
|
GetNHApp()->mapCliparoundMargin = tmp;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user