expand mouse_support to three values rather than boolean
On Windows only:
0 = turn off mouse_support
1 = turn on mouse_support and turn off QuickEdit mode
2 = turn on mouse_support and leave QuickEdit mode untouched
More generally, but not implemented anywhere:
0 = turn off mouse_support
1 = turn on mouse_support and make supporting O/S adjustments
(O/S adjustments not implented beyond Windows as yet)
2 = turn on mouse_support and do not make OS adjustments
(unimplemented as yet so behaves as 1)
This commit is contained in:
@@ -416,13 +416,13 @@ struct instance_flags {
|
||||
boolean wc_popup_dialog; /* put queries in pop up dialogs instead of
|
||||
* in the message window */
|
||||
boolean wc_eight_bit_input; /* allow eight bit input */
|
||||
boolean wc_mouse_support; /* allow mouse support */
|
||||
boolean wc2_fullscreen; /* run fullscreen */
|
||||
boolean wc2_softkeyboard; /* use software keyboard */
|
||||
boolean wc2_wraptext; /* wrap text */
|
||||
boolean wc2_selectsaved; /* display a menu of user's saved games */
|
||||
boolean wc2_darkgray; /* try to use dark-gray color for black glyphs */
|
||||
boolean wc2_hitpointbar; /* show graphical bar representing hit points */
|
||||
int wc_mouse_support; /* allow mouse support */
|
||||
int wc2_term_cols; /* terminal width, in characters */
|
||||
int wc2_term_rows; /* terminal height, in characters */
|
||||
int wc2_windowborders; /* display borders on NetHack windows */
|
||||
|
||||
@@ -166,11 +166,6 @@ static struct Bool_Opt {
|
||||
{ "menu_overlay", (boolean *) 0, FALSE, SET_IN_FILE },
|
||||
#endif
|
||||
{ "monpolycontrol", &iflags.mon_polycontrol, FALSE, SET_IN_WIZGAME },
|
||||
#ifdef CURSES_GRAPHICS
|
||||
{ "mouse_support", &iflags.wc_mouse_support, FALSE, DISP_IN_GAME }, /*WC*/
|
||||
#else
|
||||
{ "mouse_support", &iflags.wc_mouse_support, TRUE, DISP_IN_GAME }, /*WC*/
|
||||
#endif
|
||||
#ifdef NEWS
|
||||
{ "news", &iflags.news, TRUE, DISP_IN_GAME },
|
||||
#else
|
||||
@@ -342,6 +337,7 @@ static struct Comp_Opt {
|
||||
#endif
|
||||
{ "name", "your character's name (e.g., name:Merlin-W)", PL_NSIZ,
|
||||
DISP_IN_GAME },
|
||||
{ "mouse_support", "game receives click info from mouse", 0, SET_IN_GAME },
|
||||
{ "number_pad", "use the number pad for movement", 1, SET_IN_GAME },
|
||||
{ "objects", "the symbols to use for objects", MAXOCLASSES, SET_IN_FILE },
|
||||
{ "packorder", "the inventory order of the items in your pack",
|
||||
@@ -2209,6 +2205,35 @@ boolean tinitial, tfrom_file;
|
||||
return retval;
|
||||
}
|
||||
|
||||
fullname = "mouse_support";
|
||||
if (match_optname(opts, fullname, 13, TRUE)) {
|
||||
boolean compat = (strlen(opts) <= 13);
|
||||
|
||||
if (duplicate)
|
||||
complain_about_duplicate(opts, 1);
|
||||
op = string_for_opt(opts, (compat || !initial));
|
||||
if (!op) {
|
||||
if (compat || negated || initial) {
|
||||
/* for backwards compatibility, "mouse_support" without a
|
||||
value is a synonym for mouse_support:1 */
|
||||
iflags.wc_mouse_support = !negated;
|
||||
}
|
||||
} else if (negated) {
|
||||
bad_negation(fullname, TRUE);
|
||||
return FALSE;
|
||||
} else {
|
||||
int mode = atoi(op);
|
||||
|
||||
if (mode < 0 || mode > 2 || (mode == 0 && *op != '0')) {
|
||||
config_error_add("Illegal %s parameter '%s'", fullname, op);
|
||||
return FALSE;
|
||||
} else { /* mode > 0 */
|
||||
iflags.wc_mouse_support = mode;
|
||||
}
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
fullname = "number_pad";
|
||||
if (match_optname(opts, fullname, 10, TRUE)) {
|
||||
boolean compat = (strlen(opts) <= 10);
|
||||
@@ -5496,6 +5521,25 @@ char *buf;
|
||||
#endif
|
||||
} else if (!strcmp(optname, "name")) {
|
||||
Sprintf(buf, "%s", plname);
|
||||
} else if (!strcmp(optname, "mouse_support")) {
|
||||
#ifdef WIN32
|
||||
#define MOUSEFIX1 ", QuickEdit off"
|
||||
#define MOUSEFIX2 ", QuickEdit unchanged"
|
||||
#else
|
||||
#define MOUSEFIX1 ", O/S adjusted"
|
||||
#define MOUSEFIX2 ", O/S unchanged"
|
||||
#endif
|
||||
int ms = iflags.wc_mouse_support;
|
||||
static const char *mousemodes[] = {
|
||||
"0=off",
|
||||
"1=on" MOUSEFIX1,
|
||||
"2=on" MOUSEFIX2,
|
||||
};
|
||||
|
||||
if (ms >= 0 && ms < SIZE(mousemodes));
|
||||
Strcpy(buf, mousemodes[ms]);
|
||||
#undef MOUSEFIX1
|
||||
#undef MOUSEFIX2
|
||||
} else if (!strcmp(optname, "number_pad")) {
|
||||
static const char *numpadmodes[] = {
|
||||
"0=off", "1=on", "2=on, MSDOS compatible",
|
||||
|
||||
@@ -87,6 +87,7 @@ static void NDECL(restore_original_console_font);
|
||||
/* Win32 Screen buffer,coordinate,console I/O information */
|
||||
COORD ntcoord;
|
||||
INPUT_RECORD ir;
|
||||
static boolean orig_QuickEdit;
|
||||
|
||||
/* Support for changing console font if existing glyph widths are too wide */
|
||||
|
||||
@@ -311,8 +312,14 @@ const char *s;
|
||||
end_screen();
|
||||
if (s)
|
||||
raw_print(s);
|
||||
|
||||
restore_original_console_font();
|
||||
if (orig_QuickEdit) {
|
||||
DWORD cmode;
|
||||
|
||||
GetConsoleMode(console.hConIn, &cmode);
|
||||
cmode |= (ENABLE_QUICK_EDIT_MODE | ENABLE_EXTENDED_FLAGS);
|
||||
SetConsoleMode(console.hConIn, cmode);
|
||||
}
|
||||
}
|
||||
|
||||
/* called by init_nhwindows() and resume_nhwindows() */
|
||||
@@ -864,12 +871,30 @@ standoutend()
|
||||
void
|
||||
toggle_mouse_support()
|
||||
{
|
||||
static int qeinit = 0;
|
||||
DWORD cmode;
|
||||
|
||||
GetConsoleMode(console.hConIn, &cmode);
|
||||
if (iflags.wc_mouse_support)
|
||||
cmode |= ENABLE_MOUSE_INPUT;
|
||||
else
|
||||
cmode &= ~ENABLE_MOUSE_INPUT;
|
||||
if (!qeinit) {
|
||||
qeinit = 1;
|
||||
orig_QuickEdit = ((cmode & ENABLE_QUICK_EDIT_MODE) != 0);
|
||||
}
|
||||
switch(iflags.wc_mouse_support) {
|
||||
case 2:
|
||||
cmode |= ENABLE_MOUSE_INPUT;
|
||||
break;
|
||||
case 1:
|
||||
cmode |= ENABLE_MOUSE_INPUT;
|
||||
cmode &= ~ENABLE_QUICK_EDIT_MODE;
|
||||
cmode |= ENABLE_EXTENDED_FLAGS;
|
||||
break;
|
||||
case 0:
|
||||
/*FALLTHRU*/
|
||||
default:
|
||||
cmode &= ~ENABLE_MOUSE_INPUT;
|
||||
if (orig_QuickEdit)
|
||||
cmode |= (ENABLE_QUICK_EDIT_MODE | ENABLE_EXTENDED_FLAGS);
|
||||
}
|
||||
SetConsoleMode(console.hConIn, cmode);
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user