diff --git a/src/constants.h b/src/constants.h index e2a9fe8..d649c07 100644 --- a/src/constants.h +++ b/src/constants.h @@ -30,9 +30,6 @@ enum game_command {game_command_terminate = 0, game_command_pass, game_command_panic }; -// TODO: added a few colors for cursor -enum curse_color {}; - enum stat_name {HP, ATK, DEF, hostile}; const int LAYER_CNT = 4; // TODO: update as you go diff --git a/src/cursor.cc b/src/cursor.cc index f35d571..4362293 100644 --- a/src/cursor.cc +++ b/src/cursor.cc @@ -17,8 +17,14 @@ void cursor::show() const { refresh(); } -void cursor::print_char(const position &pos, const char ch) const { +void cursor::print_char(const position &pos, const char ch, const int attrs) const { + attrset(attrs); + mvaddch(pos.y,pos.x,ch); +} +void cursor::print_str(const position &pos, const std::string str, const int attrs) const { + attrset(attrs); + mvaddstr(pos.y, pos.x, str.c_str()); } bool check_terminal_size() { diff --git a/src/cursor.h b/src/cursor.h index 188d0ae..f90bd0f 100644 --- a/src/cursor.h +++ b/src/cursor.h @@ -4,6 +4,31 @@ #include #include "position.h" +/* Attributes + A_NORMAL Normal display (no highlight) + A_STANDOUT Best highlighting mode of the terminal. + A_UNDERLINE Underlining + A_REVERSE Reverse video + A_BLINK Blinking + A_DIM Half bright + A_BOLD Extra bright or bold + A_PROTECT Protected mode + A_INVIS Invisible or blank mode + A_ALTCHARSET Alternate character set + A_CHARTEXT Bit-mask to extract a character + COLOR_PAIR(n) Color-pair number n + + Color pair numbers + COLOR_BLACK 0 + COLOR_RED 1 + COLOR_GREEN 2 + COLOR_YELLOW 3 + COLOR_BLUE 4 + COLOR_MAGENTA 5 + COLOR_CYAN 6 + COLOR_WHITE 7 + */ + // IMPORTANT: use unique_ptr for cursor because: // 1. Every instance of cursor will initialize a new ncurses screen // Hence you should only have one instance of cursor at a time @@ -20,9 +45,9 @@ public: void show() const; - void print_char(const position &pos, const char ch) const; + void print_char(const position &pos, const char ch, const int attrs) const; - void print_str(const position &head, const std::string str) const; + void print_str(const position &head, const std::string str, const int attrs) const; }; // IMPORTANT: this will fail when terminal size changes