2021-03-22 12:26:13 +03:00
|
|
|
#include <cstdlib>
|
|
|
|
|
#include <curses.h>
|
2021-03-22 19:37:34 +03:00
|
|
|
#include "draw.hpp"
|
2021-03-22 12:26:13 +03:00
|
|
|
|
|
|
|
|
namespace draw {
|
|
|
|
|
void initColorPairs() {
|
2021-04-11 20:14:23 +03:00
|
|
|
init_pair(static_cast<short>(ColorScheme::simple), COLOR_WHITE, COLOR_BLACK);
|
|
|
|
|
init_pair(static_cast<short>(ColorScheme::map_simple), COLOR_WHITE, COLOR_BLACK);
|
|
|
|
|
init_pair(static_cast<short>(ColorScheme::map_active), COLOR_BLACK, COLOR_WHITE);
|
|
|
|
|
init_pair(static_cast<short>(ColorScheme::menu_simple), COLOR_WHITE, COLOR_BLACK);
|
|
|
|
|
init_pair(static_cast<short>(ColorScheme::menu_active), COLOR_BLACK, COLOR_WHITE);
|
|
|
|
|
init_pair(static_cast<short>(ColorScheme::player0), COLOR_RED, COLOR_BLACK);
|
|
|
|
|
init_pair(static_cast<short>(ColorScheme::player1), COLOR_BLUE, COLOR_BLACK);
|
|
|
|
|
init_pair(static_cast<short>(ColorScheme::player2), COLOR_MAGENTA, COLOR_BLACK);
|
|
|
|
|
init_pair(static_cast<short>(ColorScheme::player3), COLOR_YELLOW, COLOR_BLACK);
|
|
|
|
|
init_pair(static_cast<short>(ColorScheme::neutral), COLOR_GREEN, COLOR_WHITE);
|
|
|
|
|
init_pair(static_cast<short>(ColorScheme::enviroment), COLOR_WHITE, COLOR_BLACK);
|
|
|
|
|
init_pair(static_cast<short>(ColorScheme::damaged), COLOR_WHITE, COLOR_RED);
|
2021-03-22 12:26:13 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void begin() {
|
|
|
|
|
start_color();
|
|
|
|
|
initColorPairs();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void step() {
|
|
|
|
|
refresh();
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-22 19:37:34 +03:00
|
|
|
void end() {}
|
2021-03-22 12:26:13 +03:00
|
|
|
|
|
|
|
|
void clearAll() {
|
|
|
|
|
clear();
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-06 19:31:54 +03:00
|
|
|
void drawCh(size_t x, size_t y,
|
2021-03-22 12:26:13 +03:00
|
|
|
Cell cell, ColorScheme colorScheme) {
|
|
|
|
|
attron(COLOR_PAIR(colorScheme));
|
2021-04-11 20:14:23 +03:00
|
|
|
mvaddch(y, x, static_cast<short>(cell));
|
|
|
|
|
attroff(COLOR_PAIR(colorScheme));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void drawKey(size_t x, size_t y,
|
|
|
|
|
char key, ColorScheme colorScheme) {
|
|
|
|
|
attron(COLOR_PAIR(colorScheme));
|
|
|
|
|
mvaddch(y, x, key);
|
2021-03-22 12:26:13 +03:00
|
|
|
attroff(COLOR_PAIR(colorScheme));
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-06 19:31:54 +03:00
|
|
|
void getSize(size_t& x, size_t& y) { // is it work ??
|
2021-03-22 12:26:13 +03:00
|
|
|
getmaxyx(stdscr, y, x);
|
|
|
|
|
}
|
2021-04-06 19:31:54 +03:00
|
|
|
}
|