Change menu_headings to accept color and attribute
Instead of just accepting an attribute, it's now possible to use a color, or both color and attribute, for example: OPTIONS=menu_headings:inverse OPTIONS=menu_headings:red OPTIONS=menu_headings:red&underline Default is still just inverse. This lets the player change the menu heading color without needing to use menu colors for them. Also makes it so the core uses NO_COLOR instead of 0, for all the menu lines which don't have any prefedefined color. Tested for tty, curses, x11, qt, and win32
This commit is contained in:
@@ -32,6 +32,7 @@ typedef struct mswin_menu_item {
|
||||
char accelerator;
|
||||
char group_accel;
|
||||
int attr;
|
||||
int color;
|
||||
char str[NHMENU_STR_SIZE];
|
||||
boolean presel;
|
||||
unsigned int itemflags;
|
||||
@@ -623,6 +624,7 @@ onMSNHCommand(HWND hWnd, WPARAM wParam, LPARAM lParam)
|
||||
data->menui.menu.items[new_item].accelerator = msg_data->accelerator;
|
||||
data->menui.menu.items[new_item].group_accel = msg_data->group_accel;
|
||||
data->menui.menu.items[new_item].attr = msg_data->attr;
|
||||
data->menui.menu.items[new_item].color = msg_data->color;
|
||||
strncpy(data->menui.menu.items[new_item].str, msg_data->str,
|
||||
NHMENU_STR_SIZE);
|
||||
/* prevent & being interpreted as a mnemonic start */
|
||||
@@ -1072,6 +1074,12 @@ onDrawItem(HWND hWnd, WPARAM wParam, LPARAM lParam)
|
||||
}
|
||||
x += tm.tmAveCharWidth + tm.tmOverhang + spacing;
|
||||
} else {
|
||||
/* heading */
|
||||
if (iflags.use_menu_color) {
|
||||
color = item->color;
|
||||
if (color != NO_COLOR)
|
||||
(void) SetTextColor(lpdis->hDC, nhcolor_to_RGB(color));
|
||||
}
|
||||
x += tileXScaled + tm.tmAveCharWidth + tm.tmOverhang + 2 * spacing;
|
||||
}
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ typedef struct mswin_nhmsg_add_menu {
|
||||
char accelerator;
|
||||
char group_accel;
|
||||
int attr;
|
||||
int clr;
|
||||
int color;
|
||||
const char *str;
|
||||
boolean presel;
|
||||
unsigned int itemflags;
|
||||
|
||||
@@ -337,7 +337,7 @@ prompt_for_player_selection(void)
|
||||
anything any;
|
||||
menu_item *selected = 0;
|
||||
DWORD box_result;
|
||||
int clr = 0;
|
||||
int clr = NO_COLOR;
|
||||
|
||||
logDebug("prompt_for_player_selection()\n");
|
||||
|
||||
@@ -1156,6 +1156,7 @@ mswin_add_menu(winid wid, const glyph_info *glyphinfo,
|
||||
data.accelerator = accelerator;
|
||||
data.group_accel = group_accel;
|
||||
data.attr = attr;
|
||||
data.color = clr;
|
||||
data.str = str;
|
||||
data.presel = presel;
|
||||
data.itemflags = itemflags;
|
||||
|
||||
Reference in New Issue
Block a user