1
0
mirror of https://git.zap.org.au/git/trader.git synced 2024-12-04 14:46:45 -05:00

Replace individual colour/window attributes with ATTR_ macros

This commit is contained in:
John Zaitseff 2011-07-11 11:40:52 +10:00
parent dd281f795b
commit 42e05ee20b
2 changed files with 19 additions and 5 deletions

View File

@ -52,6 +52,7 @@ typedef struct txwin {
************************************************************************/ ************************************************************************/
WINDOW *curwin = NULL; // Top-most (current) window WINDOW *curwin = NULL; // Top-most (current) window
bool use_color = false; // True to use colour in Star Traders
/************************************************************************ /************************************************************************
@ -84,6 +85,8 @@ void init_screen (void)
MIN_COLS, MIN_LINES); MIN_COLS, MIN_LINES);
} }
use_color = has_colors();
curwin = stdscr; curwin = stdscr;
topwin = NULL; topwin = NULL;
firstwin = NULL; firstwin = NULL;
@ -92,7 +95,7 @@ void init_screen (void)
curs_set(CURS_OFF); curs_set(CURS_OFF);
raw(); raw();
if (has_colors()) { if (use_color) {
start_color(); start_color();
init_pair(WHITE_ON_BLACK, COLOR_WHITE, COLOR_BLACK); init_pair(WHITE_ON_BLACK, COLOR_WHITE, COLOR_BLACK);
@ -103,14 +106,14 @@ void init_screen (void)
init_pair(YELLOW_ON_CYAN, COLOR_YELLOW, COLOR_CYAN); init_pair(YELLOW_ON_CYAN, COLOR_YELLOW, COLOR_CYAN);
init_pair(BLACK_ON_WHITE, COLOR_BLACK, COLOR_WHITE); init_pair(BLACK_ON_WHITE, COLOR_BLACK, COLOR_WHITE);
bkgd(COLOR_PAIR(WHITE_ON_BLACK)); bkgd(ATTR_ROOT_WINDOW);
} }
clear(); clear();
attrset(ATTR(COLOR_PAIR(YELLOW_ON_CYAN) | A_BOLD, A_REVERSE | A_BOLD)); attrset(ATTR_GAME_TITLE);
center(stdscr, 0, true, PACKAGE_NAME); center(stdscr, 0, true, PACKAGE_NAME);
attrset(A_NORMAL); attrset(ATTR_ROOT_WINDOW);
refresh(); refresh();
} }

View File

@ -98,7 +98,7 @@ typedef enum curs_type {
// Colour and non-colour attribute selection // Colour and non-colour attribute selection
#define ATTR(color, nocolor) (has_colors() ? (color) : (nocolor)) #define ATTR(color, nocolor) (use_color ? (color) : (nocolor))
// Colour pairs used in Star Traders // Colour pairs used in Star Traders
@ -114,11 +114,22 @@ enum color_pairs {
}; };
// Window attributes used in Star Traders
#define ATTR_GAME_TITLE ATTR(COLOR_PAIR(YELLOW_ON_CYAN) | A_BOLD, A_REVERSE | A_BOLD)
#define ATTR_ROOT_WINDOW ATTR(COLOR_PAIR(WHITE_ON_BLACK), A_NORMAL)
#define ATTR_NORMAL_WINDOW ATTR(COLOR_PAIR(WHITE_ON_BLUE), A_NORMAL)
#define ATTR_STATUS_WINDOW ATTR(COLOR_PAIR(BLACK_ON_WHITE), A_REVERSE)
#define ATTR_WINDOW_TITLE ATTR(COLOR_PAIR(YELLOW_ON_BLACK) | A_BOLD, A_REVERSE)
#define ATTR_KEYCODE_STR ATTR(COLOR_PAIR(YELLOW_ON_BLACK) | A_BOLD, A_REVERSE)
#define ATTR_INPUT_FIELD ATTR(COLOR_PAIR(WHITE_ON_BLACK), A_BOLD | '_')
/************************************************************************ /************************************************************************
* Global variable declarations * * Global variable declarations *
************************************************************************/ ************************************************************************/
extern WINDOW *curwin; // Top-most (current) window extern WINDOW *curwin; // Top-most (current) window
extern bool use_color; // True to use colour in Star Traders
/************************************************************************ /************************************************************************