Combine three arguments of curses_putch into one
It will need another parameter for 256-colour support. To avoid having too many arguments, put glyph colour, background colour and attributes into a struct and, since to curses library all of that is attributes that are handled by same function, call the struct "gryph attributes". curses_putch was also declared in two different headers, remove one of those declarations.
This commit is contained in:
@@ -128,14 +128,6 @@ extern void curses_refresh_nethack_windows(void);
|
|||||||
extern void curses_del_nhwin(winid wid);
|
extern void curses_del_nhwin(winid wid);
|
||||||
extern void curses_del_wid(winid wid);
|
extern void curses_del_wid(winid wid);
|
||||||
extern void curs_destroy_all_wins(void);
|
extern void curs_destroy_all_wins(void);
|
||||||
#ifdef ENHANCED_SYMBOLS
|
|
||||||
extern void curses_putch(winid wid, int x, int y, int ch,
|
|
||||||
struct unicode_representation *u, int color,
|
|
||||||
int framecolor, int attrs);
|
|
||||||
#else
|
|
||||||
extern void curses_putch(winid wid, int x, int y, int ch, int color,
|
|
||||||
int framecolor, int attrs);
|
|
||||||
#endif
|
|
||||||
extern void curses_get_window_size(winid wid, int *height, int *width);
|
extern void curses_get_window_size(winid wid, int *height, int *width);
|
||||||
extern boolean curses_window_has_border(winid wid);
|
extern boolean curses_window_has_border(winid wid);
|
||||||
extern boolean curses_window_exists(winid wid);
|
extern boolean curses_window_exists(winid wid);
|
||||||
|
|||||||
+13
-14
@@ -7,6 +7,7 @@
|
|||||||
#include "hack.h"
|
#include "hack.h"
|
||||||
#include "color.h"
|
#include "color.h"
|
||||||
#include "wincurs.h"
|
#include "wincurs.h"
|
||||||
|
#include "curswins.h"
|
||||||
#ifdef CURSES_UNICODE
|
#ifdef CURSES_UNICODE
|
||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
#endif
|
#endif
|
||||||
@@ -939,17 +940,16 @@ curses_print_glyph(
|
|||||||
{
|
{
|
||||||
int glyph;
|
int glyph;
|
||||||
int ch;
|
int ch;
|
||||||
int color;
|
struct glyph_attributes attr;
|
||||||
int framecolor;
|
|
||||||
int nhcolor = 0;
|
int nhcolor = 0;
|
||||||
unsigned int special;
|
unsigned int special;
|
||||||
int attr = -1;
|
|
||||||
|
|
||||||
|
attr.attribute_flags = -1;
|
||||||
glyph = glyphinfo->glyph;
|
glyph = glyphinfo->glyph;
|
||||||
special = glyphinfo->gm.glyphflags;
|
special = glyphinfo->gm.glyphflags;
|
||||||
ch = glyphinfo->ttychar;
|
ch = glyphinfo->ttychar;
|
||||||
color = glyphinfo->gm.sym.color;
|
attr.color = glyphinfo->gm.sym.color;
|
||||||
framecolor = bkglyphinfo->framecolor;
|
attr.framecolor = bkglyphinfo->framecolor;
|
||||||
/* Extra color handling
|
/* Extra color handling
|
||||||
* FIQ: The curses library does not support truecolor, only the more limited 256
|
* FIQ: The curses library does not support truecolor, only the more limited 256
|
||||||
* color mode. On top of this, the windowport only supports 16 color mode.
|
* color mode. On top of this, the windowport only supports 16 color mode.
|
||||||
@@ -958,7 +958,7 @@ curses_print_glyph(
|
|||||||
if (glyphinfo->gm.customcolor != 0
|
if (glyphinfo->gm.customcolor != 0
|
||||||
&& (curses_procs.wincap2 & WC2_EXTRACOLORS) != 0) {
|
&& (curses_procs.wincap2 & WC2_EXTRACOLORS) != 0) {
|
||||||
if ((glyphinfo->gm.customcolor & NH_BASIC_COLOR) != 0) {
|
if ((glyphinfo->gm.customcolor & NH_BASIC_COLOR) != 0) {
|
||||||
color = COLORVAL(glyphinfo->gm.customcolor);
|
attr.color = COLORVAL(glyphinfo->gm.customcolor);
|
||||||
#if 0
|
#if 0
|
||||||
} else {
|
} else {
|
||||||
/* 24-bit color, NH_BASIC_COLOR == 0 */
|
/* 24-bit color, NH_BASIC_COLOR == 0 */
|
||||||
@@ -967,10 +967,10 @@ curses_print_glyph(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((special & MG_PET) && iflags.hilite_pet) {
|
if ((special & MG_PET) && iflags.hilite_pet) {
|
||||||
attr = curses_convert_attr(iflags.wc2_petattr);
|
attr.attribute_flags = curses_convert_attr(iflags.wc2_petattr);
|
||||||
}
|
}
|
||||||
if ((special & MG_DETECT) && iflags.use_inverse) {
|
if ((special & MG_DETECT) && iflags.use_inverse) {
|
||||||
attr = A_REVERSE;
|
attr.attribute_flags = A_REVERSE;
|
||||||
}
|
}
|
||||||
if (SYMHANDLING(H_DEC))
|
if (SYMHANDLING(H_DEC))
|
||||||
ch = curses_convert_glyph(ch, glyph);
|
ch = curses_convert_glyph(ch, glyph);
|
||||||
@@ -983,9 +983,9 @@ curses_print_glyph(
|
|||||||
*/
|
*/
|
||||||
if ((special & MG_OBJPILE) && iflags.hilite_pile) {
|
if ((special & MG_OBJPILE) && iflags.hilite_pile) {
|
||||||
if (iflags.wc_color)
|
if (iflags.wc_color)
|
||||||
framecolor = CLR_BLUE;
|
attr.framecolor = CLR_BLUE;
|
||||||
else /* if (iflags.use_inverse) */
|
else /* if (iflags.use_inverse) */
|
||||||
attr = A_REVERSE;
|
attr.attribute_flags = A_REVERSE;
|
||||||
}
|
}
|
||||||
/* water and lava look the same except for color; when color is off
|
/* water and lava look the same except for color; when color is off
|
||||||
(checked by core), render lava in inverse video so that it looks
|
(checked by core), render lava in inverse video so that it looks
|
||||||
@@ -994,11 +994,11 @@ curses_print_glyph(
|
|||||||
if ((special & (MG_BW_LAVA | MG_BW_ICE | MG_BW_SINK | MG_BW_ENGR))
|
if ((special & (MG_BW_LAVA | MG_BW_ICE | MG_BW_SINK | MG_BW_ENGR))
|
||||||
!= 0 && iflags.use_inverse) {
|
!= 0 && iflags.use_inverse) {
|
||||||
/* reset_glyphmap() only sets MG_BW_foo if color is off */
|
/* reset_glyphmap() only sets MG_BW_foo if color is off */
|
||||||
attr = A_REVERSE;
|
attr.attribute_flags = A_REVERSE;
|
||||||
}
|
}
|
||||||
/* highlight female monsters (wizard mode option) */
|
/* highlight female monsters (wizard mode option) */
|
||||||
if ((special & MG_FEMALE) && wizard && iflags.wizmgender) {
|
if ((special & MG_FEMALE) && wizard && iflags.wizmgender) {
|
||||||
attr = A_REVERSE;
|
attr.attribute_flags = A_REVERSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1008,8 +1008,7 @@ curses_print_glyph(
|
|||||||
&& glyphinfo->gm.u && glyphinfo->gm.u->utf8str)
|
&& glyphinfo->gm.u && glyphinfo->gm.u->utf8str)
|
||||||
? glyphinfo->gm.u : NULL,
|
? glyphinfo->gm.u : NULL,
|
||||||
#endif
|
#endif
|
||||||
(nhcolor != 0) ? nhcolor : color,
|
&attr);
|
||||||
framecolor, attr);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -532,7 +532,7 @@ curses_putch(winid wid, int x, int y, int ch,
|
|||||||
#ifdef ENHANCED_SYMBOLS
|
#ifdef ENHANCED_SYMBOLS
|
||||||
struct unicode_representation *unicode_representation,
|
struct unicode_representation *unicode_representation,
|
||||||
#endif
|
#endif
|
||||||
int color, int framecolor, int attr)
|
const struct glyph_attributes *attr)
|
||||||
{
|
{
|
||||||
static boolean map_initted = FALSE;
|
static boolean map_initted = FALSE;
|
||||||
int sx, sy, ex, ey;
|
int sx, sy, ex, ey;
|
||||||
@@ -554,9 +554,9 @@ curses_putch(winid wid, int x, int y, int ch,
|
|||||||
|
|
||||||
--x; /* map column [0] is not used; draw column [1] in first screen col */
|
--x; /* map column [0] is not used; draw column [1] in first screen col */
|
||||||
map[y][x].ch = ch;
|
map[y][x].ch = ch;
|
||||||
map[y][x].color = color;
|
map[y][x].color = attr->color;
|
||||||
map[y][x].framecolor = framecolor;
|
map[y][x].framecolor = attr->framecolor;
|
||||||
map[y][x].attr = attr;
|
map[y][x].attr = attr->attribute_flags;
|
||||||
#ifdef ENHANCED_SYMBOLS
|
#ifdef ENHANCED_SYMBOLS
|
||||||
map[y][x].unicode_representation = unicode_representation;
|
map[y][x].unicode_representation = unicode_representation;
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -6,6 +6,11 @@
|
|||||||
#ifndef CURSWIN_H
|
#ifndef CURSWIN_H
|
||||||
# define CURSWIN_H
|
# define CURSWIN_H
|
||||||
|
|
||||||
|
struct glyph_attributes {
|
||||||
|
int color;
|
||||||
|
int framecolor;
|
||||||
|
int attribute_flags;
|
||||||
|
};
|
||||||
|
|
||||||
/* Global declarations */
|
/* Global declarations */
|
||||||
|
|
||||||
@@ -27,11 +32,11 @@ void curses_del_wid(winid wid);
|
|||||||
void curs_destroy_all_wins(void);
|
void curs_destroy_all_wins(void);
|
||||||
#ifdef ENHANCED_SYMBOLS
|
#ifdef ENHANCED_SYMBOLS
|
||||||
void curses_putch(winid wid, int x, int y, int ch,
|
void curses_putch(winid wid, int x, int y, int ch,
|
||||||
struct unicode_representation *ur, int color,
|
struct unicode_representation *ur,
|
||||||
int framecolor, int attrs);
|
const struct glyph_attributes *attr);
|
||||||
#else
|
#else
|
||||||
void curses_putch(winid wid, int x, int y, int ch, int color,
|
void curses_putch(winid wid, int x, int y, int ch,
|
||||||
int framecolor, int attrs);
|
const struct glyph_attributes *attr);
|
||||||
#endif
|
#endif
|
||||||
void curses_get_window_xy(winid wid, int *x, int *y);
|
void curses_get_window_xy(winid wid, int *x, int *y);
|
||||||
boolean curses_window_has_border(winid wid);
|
boolean curses_window_has_border(winid wid);
|
||||||
|
|||||||
Reference in New Issue
Block a user