-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
3 changed files
with
70 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#ifndef COLOR_HANDLER_H_ | ||
#define COLOR_HANDLER_H_ | ||
|
||
#include <string_view> | ||
|
||
#include "curses.h" | ||
|
||
namespace roadrun { | ||
const int kColorRed = COLOR_RED; | ||
const int kColorGreen = COLOR_GREEN; | ||
const int kColorYellow = COLOR_YELLOW; | ||
const int kColorBlue = COLOR_BLUE; | ||
const int kColorMagenta = COLOR_MAGENTA; | ||
const int kColorCyan = COLOR_CYAN; | ||
const int kColorWhite = COLOR_WHITE; | ||
class ColorHandler { | ||
public: | ||
static void InitializeColorPairs(); | ||
static void PrintColor(int y, int x, const char* str, int color_pair); | ||
static void PrintRed(int y, int x, const char* str); | ||
static void PrintGreen(int y, int x, const char* str); | ||
static void PrintYellow(int y, int x, const char* str); | ||
static void PrintBlue(int y, int x, const char* str); | ||
static void PrintMagenta(int y, int x, const char* str); | ||
static void PrintCyan(int y, int x, const char* str); | ||
static void PrintWhite(int y, int x, const char* str); | ||
}; | ||
} // namespace roadrun | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#include "color_handler.h" | ||
|
||
namespace roadrun { | ||
void ColorHandler::InitializeColorPairs() { | ||
init_pair(kColorRed, COLOR_RED, COLOR_BLACK); | ||
init_pair(kColorGreen, COLOR_GREEN, COLOR_BLACK); | ||
init_pair(kColorYellow, COLOR_YELLOW, COLOR_BLACK); | ||
init_pair(kColorBlue, COLOR_BLUE, COLOR_BLACK); | ||
init_pair(kColorMagenta, COLOR_MAGENTA, COLOR_BLACK); | ||
init_pair(kColorCyan, COLOR_CYAN, COLOR_BLACK); | ||
init_pair(kColorWhite, COLOR_WHITE, COLOR_BLACK); | ||
} | ||
void ColorHandler::PrintColor(int y, int x, const char* str, int color_pair) { | ||
attron(COLOR_PAIR(color_pair)); | ||
mvprintw(y, x, str); | ||
attroff(COLOR_PAIR(color_pair)); | ||
} | ||
void ColorHandler::PrintRed(int y, int x, const char* str) { | ||
PrintColor(y, x, str, kColorRed); | ||
} | ||
void ColorHandler::PrintGreen(int y, int x, const char* str) { | ||
PrintColor(y, x, str, kColorGreen); | ||
} | ||
void ColorHandler::PrintYellow(int y, int x, const char* str) { | ||
PrintColor(y, x, str, kColorYellow); | ||
} | ||
void ColorHandler::PrintBlue(int y, int x, const char* str) { | ||
PrintColor(y, x, str, kColorBlue); | ||
} | ||
void ColorHandler::PrintMagenta(int y, int x, const char* str) { | ||
PrintColor(y, x, str, kColorMagenta); | ||
} | ||
void ColorHandler::PrintCyan(int y, int x, const char* str) { | ||
PrintColor(y, x, str, kColorCyan); | ||
} | ||
void ColorHandler::PrintWhite(int y, int x, const char* str) { | ||
PrintColor(y, x, str, kColorWhite); | ||
} | ||
} // namespace roadrun |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
#include "game_environment.h" | ||
#include "color_handler.h" | ||
|
||
namespace roadrun | ||
{ | ||
|