|
|
|
@ -2,6 +2,7 @@ |
|
|
|
|
#include <ncurses.h> |
|
|
|
|
#include <unistd.h> |
|
|
|
|
#include "gfx.h" |
|
|
|
|
#include "merge.h" |
|
|
|
|
|
|
|
|
|
#define NUMBER_OF_COLORS 7 |
|
|
|
|
|
|
|
|
@ -33,6 +34,15 @@ struct gfx_state* gfx_init(struct gamestate *g) |
|
|
|
|
if (g->opts->enable_color && has_colors()) { |
|
|
|
|
start_color(); |
|
|
|
|
|
|
|
|
|
#ifdef INVERT_COLORS |
|
|
|
|
init_pair(0, 0, 1); |
|
|
|
|
init_pair(1, 0, 2); |
|
|
|
|
init_pair(2, 0, 3); |
|
|
|
|
init_pair(3, 0, 4); |
|
|
|
|
init_pair(4, 0, 5); |
|
|
|
|
init_pair(5, 0, 6); |
|
|
|
|
init_pair(6, 0, 7); |
|
|
|
|
#else |
|
|
|
|
init_pair(0, 1, 0); |
|
|
|
|
init_pair(1, 2, 0); |
|
|
|
|
init_pair(2, 3, 0); |
|
|
|
@ -40,6 +50,7 @@ struct gfx_state* gfx_init(struct gamestate *g) |
|
|
|
|
init_pair(4, 5, 0); |
|
|
|
|
init_pair(5, 6, 0); |
|
|
|
|
init_pair(6, 7, 0); |
|
|
|
|
#endif |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return s; |
|
|
|
@ -65,7 +76,7 @@ void gfx_draw(struct gfx_state *s, struct gamestate *g) |
|
|
|
|
for (x = 0; x < g->opts->grid_width; ++x) { |
|
|
|
|
if (g->grid[x][y]) { |
|
|
|
|
wattron(s->window, COLOR_PAIR(g->grid[x][y] % NUMBER_OF_COLORS)); |
|
|
|
|
mvwprintw(s->window, ypos, xpos, "%*ld", g->print_width, merge_value(g->grid[x][y])); |
|
|
|
|
mvwprintw(s->window, ypos, xpos, "%-*ld", g->print_width, merge_value(g->grid[x][y])); |
|
|
|
|
wattroff(s->window, COLOR_PAIR(g->grid[x][y] % NUMBER_OF_COLORS)); |
|
|
|
|
mvwprintw(s->window, ypos, xpos + g->print_width, " |"); |
|
|
|
|
} |
|
|
|
|