follow-up to curses windowcolors
Make sure the windowcolors option can be specified more than once without a config file warning. Make the struct holding the details a little more extendable.
This commit is contained in:
@@ -195,6 +195,16 @@ struct debug_flags {
|
|||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum windowcolors_windows {
|
||||||
|
wcolor_menu, wcolor_message, wcolor_status, wcolor_text,
|
||||||
|
WC_COUNT
|
||||||
|
};
|
||||||
|
|
||||||
|
struct windowcolors_struct {
|
||||||
|
char *fg;
|
||||||
|
char *bg;
|
||||||
|
};
|
||||||
|
|
||||||
struct accessibility_data {
|
struct accessibility_data {
|
||||||
boolean accessiblemsg; /* use msg_loc for plined messages */
|
boolean accessiblemsg; /* use msg_loc for plined messages */
|
||||||
coord msg_loc; /* accessiblemsg: location */
|
coord msg_loc; /* accessiblemsg: location */
|
||||||
@@ -379,6 +389,7 @@ struct instance_flags {
|
|||||||
int wc_align_status; /* status win at top|bot|right|left */
|
int wc_align_status; /* status win at top|bot|right|left */
|
||||||
int wc_align_message; /* message win at top|bot|right|left */
|
int wc_align_message; /* message win at top|bot|right|left */
|
||||||
int wc_vary_msgcount; /* show more old messages at a time */
|
int wc_vary_msgcount; /* show more old messages at a time */
|
||||||
|
#if 0
|
||||||
char *wc_foregrnd_menu; /* points to foregrnd color name for menu win */
|
char *wc_foregrnd_menu; /* points to foregrnd color name for menu win */
|
||||||
char *wc_backgrnd_menu; /* points to backgrnd color name for menu win */
|
char *wc_backgrnd_menu; /* points to backgrnd color name for menu win */
|
||||||
char *wc_foregrnd_message; /* points to foregrnd color name for msg win */
|
char *wc_foregrnd_message; /* points to foregrnd color name for msg win */
|
||||||
@@ -387,6 +398,9 @@ struct instance_flags {
|
|||||||
char *wc_backgrnd_status; /* points to backgrnd color name for status */
|
char *wc_backgrnd_status; /* points to backgrnd color name for status */
|
||||||
char *wc_foregrnd_text; /* points to foregrnd color name for text win */
|
char *wc_foregrnd_text; /* points to foregrnd color name for text win */
|
||||||
char *wc_backgrnd_text; /* points to backgrnd color name for text win */
|
char *wc_backgrnd_text; /* points to backgrnd color name for text win */
|
||||||
|
#else
|
||||||
|
struct windowcolors_struct wcolors[WC_COUNT];
|
||||||
|
#endif
|
||||||
char *wc_font_map; /* points to font name for the map win */
|
char *wc_font_map; /* points to font name for the map win */
|
||||||
char *wc_font_message; /* points to font name for message win */
|
char *wc_font_message; /* points to font name for message win */
|
||||||
char *wc_font_status; /* points to font name for status win */
|
char *wc_font_status; /* points to font name for status win */
|
||||||
|
|||||||
@@ -96,10 +96,12 @@ static int optfn_##a(int, int, boolean, char *, char *);
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* B:nm, ln, opt_*, setwhere?, on?, negat?, val?, dup?, hndlr? Alias, bool_p, term */
|
/* B:nm, sec, ln, opt_*, setwhere?, on?, negat?, val?, dup?, hndlr? Alias,
|
||||||
/* C:nm, ln, opt_*, setwhere?, negateok?, valok?, dupok?, hndlr? Alias, desc */
|
bool_p, term */
|
||||||
/* P:pfx, ln, opt_*, setwhere?, negateok?, valok?, dupok?, hndlr? Alias, desc*/
|
/* C:nm, sec, ln, opt_*, setwhere?, negateok?, valok?, dupok?, hndlr? Alias,
|
||||||
|
desc */
|
||||||
|
/* P:pfx, sec, ln, opt_*, setwhere?, negateok?, valok?, dupok?, hndlr? Alias,
|
||||||
|
desc*/
|
||||||
/*
|
/*
|
||||||
* Most of the options are in alphabetical order; a few are forced
|
* Most of the options are in alphabetical order; a few are forced
|
||||||
* to the top of list so that doset() will list them first and
|
* to the top of list so that doset() will list them first and
|
||||||
@@ -850,7 +852,7 @@ static int optfn_##a(int, int, boolean, char *, char *);
|
|||||||
No, Yes, No, No, NoAlias, "window processor to use")
|
No, Yes, No, No, NoAlias, "window processor to use")
|
||||||
#endif
|
#endif
|
||||||
NHOPTC(windowcolors, Advanced, 80, opt_in, set_gameview,
|
NHOPTC(windowcolors, Advanced, 80, opt_in, set_gameview,
|
||||||
No, Yes, No, No, NoAlias,
|
No, Yes, Yes, No, NoAlias,
|
||||||
"the foreground/background colors of windows")
|
"the foreground/background colors of windows")
|
||||||
/* NHOPTC(windowtype) -- moved to top */
|
/* NHOPTC(windowtype) -- moved to top */
|
||||||
NHOPTB(wizmgender, Advanced, 0, opt_in, set_wizonly,
|
NHOPTB(wizmgender, Advanced, 0, opt_in, set_wizonly,
|
||||||
|
|||||||
@@ -4698,17 +4698,31 @@ optfn_windowcolors(int optidx, int req, boolean negated UNUSED,
|
|||||||
}
|
}
|
||||||
if (req == get_val || req == get_cnf_val) {
|
if (req == get_val || req == get_cnf_val) {
|
||||||
Sprintf(
|
Sprintf(
|
||||||
opts, "%s/%s %s/%s %s/%s %s/%s",
|
opts, "%s/%s %s/%s %s/%s %s/%s",
|
||||||
iflags.wc_foregrnd_menu ? iflags.wc_foregrnd_menu : defbrief,
|
iflags.wcolors[wcolor_menu].fg
|
||||||
iflags.wc_backgrnd_menu ? iflags.wc_backgrnd_menu : defbrief,
|
? iflags.wcolors[wcolor_menu].fg
|
||||||
iflags.wc_foregrnd_message ? iflags.wc_foregrnd_message
|
: defbrief,
|
||||||
: defbrief,
|
iflags.wcolors[wcolor_menu].bg
|
||||||
iflags.wc_backgrnd_message ? iflags.wc_backgrnd_message
|
? iflags.wcolors[wcolor_menu].bg
|
||||||
: defbrief,
|
: defbrief,
|
||||||
iflags.wc_foregrnd_status ? iflags.wc_foregrnd_status : defbrief,
|
iflags.wcolors[wcolor_message].fg
|
||||||
iflags.wc_backgrnd_status ? iflags.wc_backgrnd_status : defbrief,
|
? iflags.wcolors[wcolor_message].fg
|
||||||
iflags.wc_foregrnd_text ? iflags.wc_foregrnd_text : defbrief,
|
: defbrief,
|
||||||
iflags.wc_backgrnd_text ? iflags.wc_backgrnd_text : defbrief);
|
iflags.wcolors[wcolor_message].bg
|
||||||
|
? iflags.wcolors[wcolor_message].bg
|
||||||
|
: defbrief,
|
||||||
|
iflags.wcolors[wcolor_status].fg
|
||||||
|
? iflags.wcolors[wcolor_status].fg
|
||||||
|
: defbrief,
|
||||||
|
iflags.wcolors[wcolor_status].bg
|
||||||
|
? iflags.wcolors[wcolor_status].bg
|
||||||
|
: defbrief,
|
||||||
|
iflags.wcolors[wcolor_text].fg
|
||||||
|
? iflags.wcolors[wcolor_text].fg
|
||||||
|
: defbrief,
|
||||||
|
iflags.wcolors[wcolor_text].bg
|
||||||
|
? iflags.wcolors[wcolor_text].bg
|
||||||
|
: defbrief);
|
||||||
return optn_ok;
|
return optn_ok;
|
||||||
}
|
}
|
||||||
return optn_ok;
|
return optn_ok;
|
||||||
@@ -9635,14 +9649,14 @@ wc_set_window_colors(char *op)
|
|||||||
"menu", "message", "status", "text"
|
"menu", "message", "status", "text"
|
||||||
};
|
};
|
||||||
static const char *const shortnames[] = { "mnu", "msg", "sts", "txt" };
|
static const char *const shortnames[] = { "mnu", "msg", "sts", "txt" };
|
||||||
static char **fgp[] = { &iflags.wc_foregrnd_menu,
|
static char **fgp[] = { &iflags.wcolors[wcolor_menu].fg,
|
||||||
&iflags.wc_foregrnd_message,
|
&iflags.wcolors[wcolor_message].fg,
|
||||||
&iflags.wc_foregrnd_status,
|
&iflags.wcolors[wcolor_status].fg,
|
||||||
&iflags.wc_foregrnd_text };
|
&iflags.wcolors[wcolor_text].fg };
|
||||||
static char **bgp[] = { &iflags.wc_backgrnd_menu,
|
static char **bgp[] = { &iflags.wcolors[wcolor_menu].bg,
|
||||||
&iflags.wc_backgrnd_message,
|
&iflags.wcolors[wcolor_message].bg,
|
||||||
&iflags.wc_backgrnd_status,
|
&iflags.wcolors[wcolor_status].bg,
|
||||||
&iflags.wc_backgrnd_text };
|
&iflags.wcolors[wcolor_text].bg };
|
||||||
|
|
||||||
Strcpy(buf, op);
|
Strcpy(buf, op);
|
||||||
newop = mungspaces(buf);
|
newop = mungspaces(buf);
|
||||||
|
|||||||
@@ -427,9 +427,11 @@ curses_create_nhwindow(int type)
|
|||||||
winid wid = curses_get_wid(type);
|
winid wid = curses_get_wid(type);
|
||||||
|
|
||||||
if (curses_is_menu(wid))
|
if (curses_is_menu(wid))
|
||||||
curses_parse_wid_colors(MENU_WIN, iflags.wc_foregrnd_menu, iflags.wc_backgrnd_menu);
|
curses_parse_wid_colors(MENU_WIN, iflags.wcolors[wcolor_menu].fg,
|
||||||
|
iflags.wcolors[wcolor_menu].bg);
|
||||||
else if (curses_is_text(wid))
|
else if (curses_is_text(wid))
|
||||||
curses_parse_wid_colors(TEXT_WIN, iflags.wc_foregrnd_text, iflags.wc_backgrnd_text);
|
curses_parse_wid_colors(TEXT_WIN, iflags.wcolors[wcolor_text].fg,
|
||||||
|
iflags.wcolors[wcolor_text].bg);
|
||||||
if (curses_is_menu(wid) || curses_is_text(wid)) {
|
if (curses_is_menu(wid) || curses_is_text(wid)) {
|
||||||
curses_start_menu(wid, MENU_BEHAVE_STANDARD);
|
curses_start_menu(wid, MENU_BEHAVE_STANDARD);
|
||||||
curses_add_wid(wid);
|
curses_add_wid(wid);
|
||||||
|
|||||||
@@ -179,15 +179,18 @@ curses_set_wid_colors(int wid, WINDOW *win)
|
|||||||
if (wid == TEXT_WIN || curses_is_text(wid)) {
|
if (wid == TEXT_WIN || curses_is_text(wid)) {
|
||||||
wid = TEXT_WIN;
|
wid = TEXT_WIN;
|
||||||
if (!nhwins[wid].clr_inited)
|
if (!nhwins[wid].clr_inited)
|
||||||
curses_parse_wid_colors(wid, iflags.wc_foregrnd_text, iflags.wc_backgrnd_text);
|
curses_parse_wid_colors(wid, iflags.wcolors[wcolor_text].fg,
|
||||||
|
iflags.wcolors[wcolor_text].bg);
|
||||||
} else if (wid == MENU_WIN || curses_is_menu(wid)) {
|
} else if (wid == MENU_WIN || curses_is_menu(wid)) {
|
||||||
wid = MENU_WIN;
|
wid = MENU_WIN;
|
||||||
if (!nhwins[wid].clr_inited)
|
if (!nhwins[wid].clr_inited)
|
||||||
curses_parse_wid_colors(wid, iflags.wc_foregrnd_menu, iflags.wc_backgrnd_menu);
|
curses_parse_wid_colors(wid, iflags.wcolors[wcolor_menu].fg,
|
||||||
|
iflags.wcolors[wcolor_menu].bg);
|
||||||
}
|
}
|
||||||
/* FIXME: colors and nhwins[] entry for perm invent window */
|
/* FIXME: colors and nhwins[] entry for perm invent window */
|
||||||
if (nhwins[wid].clr_inited > 0) {
|
if (nhwins[wid].clr_inited > 0) {
|
||||||
wbkgd(win ? win : nhwins[wid].curwin, COLOR_PAIR(nhwins[wid].colorpair));
|
wbkgd(win ? win : nhwins[wid].curwin,
|
||||||
|
COLOR_PAIR(nhwins[wid].colorpair));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -361,12 +364,14 @@ curses_add_nhwin(winid wid, int height, int width, int y, int x,
|
|||||||
switch (wid) {
|
switch (wid) {
|
||||||
case MESSAGE_WIN:
|
case MESSAGE_WIN:
|
||||||
messagewin = win;
|
messagewin = win;
|
||||||
curses_parse_wid_colors(wid, iflags.wc_foregrnd_message, iflags.wc_backgrnd_message);
|
curses_parse_wid_colors(wid, iflags.wcolors[wcolor_message].fg,
|
||||||
|
iflags.wcolors[wcolor_message].bg);
|
||||||
curses_set_wid_colors(wid, NULL);
|
curses_set_wid_colors(wid, NULL);
|
||||||
break;
|
break;
|
||||||
case STATUS_WIN:
|
case STATUS_WIN:
|
||||||
statuswin = win;
|
statuswin = win;
|
||||||
curses_parse_wid_colors(wid, iflags.wc_foregrnd_status, iflags.wc_backgrnd_status);
|
curses_parse_wid_colors(wid, iflags.wcolors[wcolor_status].fg,
|
||||||
|
iflags.wcolors[wcolor_status].bg);
|
||||||
curses_set_wid_colors(wid, NULL);
|
curses_set_wid_colors(wid, NULL);
|
||||||
break;
|
break;
|
||||||
case MAP_WIN:
|
case MAP_WIN:
|
||||||
|
|||||||
@@ -240,22 +240,22 @@ mswin_init_nhwindows(int *argc, char **argv)
|
|||||||
| WC_FONTSIZ_TEXT | WC_VARY_MSGCOUNT,
|
| WC_FONTSIZ_TEXT | WC_VARY_MSGCOUNT,
|
||||||
set_in_game);
|
set_in_game);
|
||||||
|
|
||||||
mswin_color_from_string(iflags.wc_foregrnd_menu, &menu_fg_brush,
|
mswin_color_from_string(iflags.wcolors[wcolor_menu].fg,
|
||||||
&menu_fg_color);
|
&menu_fg_brush, &menu_fg_color);
|
||||||
mswin_color_from_string(iflags.wc_foregrnd_message, &message_fg_brush,
|
mswin_color_from_string(iflags.wcolors[wcolor_message].fg,
|
||||||
&message_fg_color);
|
&message_fg_brush, &message_fg_color);
|
||||||
mswin_color_from_string(iflags.wc_foregrnd_status, &status_fg_brush,
|
mswin_color_from_string(iflags.wcolors[wcolor_status].fg,
|
||||||
&status_fg_color);
|
&status_fg_brush, &status_fg_color);
|
||||||
mswin_color_from_string(iflags.wc_foregrnd_text, &text_fg_brush,
|
mswin_color_from_string(iflags.wcolors[wcolor_text].fg,
|
||||||
&text_fg_color);
|
&text_fg_brush, &text_fg_color);
|
||||||
mswin_color_from_string(iflags.wc_backgrnd_menu, &menu_bg_brush,
|
mswin_color_from_string(iflags.wcolors[wcolor_menu].bg,
|
||||||
&menu_bg_color);
|
&menu_bg_brush, &menu_bg_color);
|
||||||
mswin_color_from_string(iflags.wc_backgrnd_message, &message_bg_brush,
|
mswin_color_from_string(iflags.wcolors[wcolor_message].bg,
|
||||||
&message_bg_color);
|
&message_bg_brush, &message_bg_color);
|
||||||
mswin_color_from_string(iflags.wc_backgrnd_status, &status_bg_brush,
|
mswin_color_from_string(iflags.wcolors[wcolor_status].bg,
|
||||||
&status_bg_color);
|
&status_bg_brush, &status_bg_color);
|
||||||
mswin_color_from_string(iflags.wc_backgrnd_text, &text_bg_brush,
|
mswin_color_from_string(iflags.wcolors[wcolor_text].bg,
|
||||||
&text_bg_color);
|
&text_bg_brush, &text_bg_color);
|
||||||
|
|
||||||
if (iflags.wc_splash_screen)
|
if (iflags.wc_splash_screen)
|
||||||
mswin_display_splash_window(FALSE);
|
mswin_display_splash_window(FALSE);
|
||||||
|
|||||||
Reference in New Issue
Block a user