-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcolormanager.cpp
More file actions
42 lines (32 loc) · 860 Bytes
/
Copy pathcolormanager.cpp
File metadata and controls
42 lines (32 loc) · 860 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <ncurses.h>
#include "color.hpp"
#include "colormanager.hpp"
namespace roadagain
{
const Color ColorManager::BOARD = { BOARD_NUMBER, COLOR_BLACK, COLOR_GREEN };
const Color ColorManager::BLACK = { BLACK_NUMBER, COLOR_BLACK, COLOR_BLACK };
const Color ColorManager::WHITE = { WHITE_NUMBER, COLOR_WHITE, COLOR_WHITE };
ColorManager& ColorManager::instance()
{
static ColorManager instance_;
return (instance_);
}
void ColorManager::init()
{
if (not has_colors()){
return;
}
start_color();
register_color(BOARD);
register_color(BLACK);
register_color(WHITE);
}
void ColorManager::register_color(const Color& color)
{
init_pair(color.number, color.foreground, color.background);
}
void ColorManager::change_color(const Color& color)
{
attrset(COLOR_PAIR(color.number));
}
} // namespace roadagain