Move and reorder ap exc, menucolor and msgtype entries in options

Move autopickup exception, menucolor, and message type entries
in the options menu under "Other settings" -header, and reorders
them into alphabetical order.

Also use enums instead of hardcoded values.
This commit is contained in:
Pasi Kallinen
2016-01-02 13:40:53 +02:00
parent 8da7375c21
commit 0106901078
+52 -29
View File
@@ -3487,6 +3487,7 @@ char ch;
static char fmtstr_doset_add_menu[] = "%s%-15s [%s] "; static char fmtstr_doset_add_menu[] = "%s%-15s [%s] ";
static char fmtstr_doset_add_menu_tab[] = "%s\t[%s]"; static char fmtstr_doset_add_menu_tab[] = "%s\t[%s]";
static char n_currently_set[] = "(%d currently set)";
STATIC_OVL void STATIC_OVL void
doset_add_menu(win, option, indexoffset) doset_add_menu(win, option, indexoffset)
@@ -3528,6 +3529,38 @@ int indexoffset; /* value to add to index in compopt[], or zero
add_menu(win, NO_GLYPH, &any, 0, 0, ATR_NONE, buf, MENU_UNSELECTED); add_menu(win, NO_GLYPH, &any, 0, 0, ATR_NONE, buf, MENU_UNSELECTED);
} }
STATIC_OVL void
opts_add_others(win, name, id, bufx, nset)
winid win;
char *name;
int id;
char *bufx;
int nset;
{
char buf[BUFSZ], buf2[BUFSZ];
anything any = zeroany;
any.a_int = id;
if (!bufx)
Sprintf(buf2, n_currently_set, nset);
else
Sprintf(buf2, "%s", bufx);
if (!iflags.menu_tab_sep)
Sprintf(buf, fmtstr_doset_add_menu, any.a_int ? "" : " ",
name, buf2);
else
Sprintf(buf, fmtstr_doset_add_menu_tab, name, buf2);
add_menu(win, NO_GLYPH, &any, 0, 0, ATR_NONE, buf, MENU_UNSELECTED);
}
enum opt_other_enums {
OPT_OTHER_MSGTYPE = -4,
OPT_OTHER_MENUCOLOR = -3,
OPT_OTHER_STATHILITE = -2,
OPT_OTHER_APEXC = -1
/* these must be < 0 */
};
/* Changing options via menu by Per Liboriussen */ /* Changing options via menu by Per Liboriussen */
int int
doset() doset()
@@ -3541,7 +3574,6 @@ doset()
int indexoffset, startpass, endpass; int indexoffset, startpass, endpass;
boolean setinitial = FALSE, fromfile = FALSE; boolean setinitial = FALSE, fromfile = FALSE;
int biggest_name = 0; int biggest_name = 0;
const char *n_currently_set = "(%d currently set)";
tmpwin = create_nhwindow(NHW_MENU); tmpwin = create_nhwindow(NHW_MENU);
start_menu(tmpwin); start_menu(tmpwin);
@@ -3636,35 +3668,27 @@ doset()
doset_add_menu(tmpwin, compopt[i].name, doset_add_menu(tmpwin, compopt[i].name,
(pass == DISP_IN_GAME) ? 0 : indexoffset); (pass == DISP_IN_GAME) ? 0 : indexoffset);
} }
any.a_int = -4;
Sprintf(buf2, n_currently_set, msgtype_count()); any = zeroany;
Sprintf(buf, fmtstr_doset_add_menu, any.a_int ? "" : " ", add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE, "", MENU_UNSELECTED);
"message types", buf2); add_menu(tmpwin, NO_GLYPH, &any, 0, 0, iflags.menu_headings,
add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE, buf, MENU_UNSELECTED); "Other settings:",
any.a_int = -3; MENU_UNSELECTED);
Sprintf(buf2, n_currently_set, count_menucolors());
Sprintf(buf, fmtstr_doset_add_menu, any.a_int ? "" : " ", opts_add_others(tmpwin, "autopickup exceptions", OPT_OTHER_APEXC,
"menucolors", buf2); NULL, count_ape_maps((int *) 0, (int *) 0));
add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE, buf, MENU_UNSELECTED); opts_add_others(tmpwin, "menucolors", OPT_OTHER_MENUCOLOR,
NULL, count_menucolors());
opts_add_others(tmpwin, "message types", OPT_OTHER_MSGTYPE,
NULL, msgtype_count());
#ifdef STATUS_VIA_WINDOWPORT #ifdef STATUS_VIA_WINDOWPORT
#ifdef STATUS_HILITES #ifdef STATUS_HILITES
any.a_int = -2;
get_status_hilites(buf2, 60); get_status_hilites(buf2, 60);
if (!*buf2) if (!*buf2)
Sprintf(buf2, "%s", "(none)"); Sprintf(buf2, "%s", "(none)");
if (!iflags.menu_tab_sep) opts_add_others(tmpwin, "status_hilites", OPT_OTHER_STATHILITE, buf2, 0);
Sprintf(buf, fmtstr_doset_add_menu, any.a_int ? "" : " ",
"status_hilites", buf2);
else
Sprintf(buf, fmtstr_doset_add_menu_tab, "status_hilites", buf2);
add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE, buf, MENU_UNSELECTED);
#endif #endif
#endif #endif
any.a_int = -1;
Sprintf(buf2, n_currently_set, count_ape_maps((int *) 0, (int *) 0));
Sprintf(buf, fmtstr_doset_add_menu, any.a_int ? "" : " ",
"autopickup exceptions", buf2);
add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE, buf, MENU_UNSELECTED);
#ifdef PREFIXES_IN_USE #ifdef PREFIXES_IN_USE
any = zeroany; any = zeroany;
add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE, "", MENU_UNSELECTED); add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE, "", MENU_UNSELECTED);
@@ -3684,14 +3708,13 @@ doset()
*/ */
for (pick_idx = 0; pick_idx < pick_cnt; ++pick_idx) { for (pick_idx = 0; pick_idx < pick_cnt; ++pick_idx) {
opt_indx = pick_list[pick_idx].item.a_int - 1; opt_indx = pick_list[pick_idx].item.a_int - 1;
if (opt_indx == -2) { if (opt_indx < -1) opt_indx++; /* -1 offset for select_menu() */
/* -2 due to -1 offset for select_menu() */ if (opt_indx == OPT_OTHER_APEXC) {
(void) special_handling("autopickup_exception", setinitial, (void) special_handling("autopickup_exception", setinitial,
fromfile); fromfile);
#ifdef STATUS_VIA_WINDOWPORT #ifdef STATUS_VIA_WINDOWPORT
#ifdef STATUS_HILITES #ifdef STATUS_HILITES
} else if (opt_indx == -3) { } else if (opt_indx == OPT_OTHER_STATHILITE) {
/* -3 due to -1 offset for select_menu() */
if (!status_hilite_menu()) { if (!status_hilite_menu()) {
pline("Bad status hilite(s) specified."); pline("Bad status hilite(s) specified.");
} else { } else {
@@ -3700,10 +3723,10 @@ doset()
} }
#endif #endif
#endif #endif
} else if (opt_indx == -4) { } else if (opt_indx == OPT_OTHER_MENUCOLOR) {
(void) special_handling("menucolors", setinitial, (void) special_handling("menucolors", setinitial,
fromfile); fromfile);
} else if (opt_indx == -5) { } else if (opt_indx == OPT_OTHER_MSGTYPE) {
(void) special_handling("msgtype", setinitial, fromfile); (void) special_handling("msgtype", setinitial, fromfile);
} else if (opt_indx < boolcount) { } else if (opt_indx < boolcount) {
/* boolean option */ /* boolean option */