Aesthetic changes to graphics in ncurses version

This commit is contained in:
Tiehuis 2015-02-23 16:42:45 +13:00
parent 622a4b46ef
commit d1b80fe2fe

View File

@ -35,21 +35,21 @@ struct gfx_state* gfx_init(struct gamestate *g)
start_color(); start_color();
#ifdef INVERT_COLORS #ifdef INVERT_COLORS
init_pair(0, 0, 1); init_pair(1, COLOR_BLACK, COLOR_RED);
init_pair(1, 0, 2); init_pair(2, COLOR_BLACK, COLOR_GREEN);
init_pair(2, 0, 3); init_pair(3, COLOR_BLACK, COLOR_YELLOW);
init_pair(3, 0, 4); init_pair(4, COLOR_BLACK, COLOR_BLUE);
init_pair(4, 0, 5); init_pair(5, COLOR_BLACK, COLOR_MAGENTA);
init_pair(5, 0, 6); init_pair(6, COLOR_BLACK, COLOR_CYAN);
init_pair(6, 0, 7); init_pair(7, COLOR_BLACK, COLOR_WHITE);
#else #else
init_pair(0, 1, 0); init_pair(1, COLOR_RED, COLOR_BLACK);
init_pair(1, 2, 0); init_pair(2, COLOR_GREEN, COLOR_BLACK);
init_pair(2, 3, 0); init_pair(3, COLOR_YELLOW, COLOR_BLACK);
init_pair(3, 4, 0); init_pair(4, COLOR_BLUE, COLOR_BLACK);
init_pair(4, 5, 0); init_pair(5, COLOR_MAGENTA, COLOR_BLACK);
init_pair(5, 6, 0); init_pair(6, COLOR_CYAN, COLOR_BLACK);
init_pair(6, 7, 0); init_pair(7, COLOR_WHITE, COLOR_BLACK);
#endif #endif
} }
@ -64,32 +64,45 @@ void gfx_draw(struct gfx_state *s, struct gamestate *g)
mvwprintw(s->window, 0, 0, "Score: %d\n", g->score); mvwprintw(s->window, 0, 0, "Score: %d\n", g->score);
mvwprintw(s->window, 1, 0, " Hi: %d\n", g->score_high); mvwprintw(s->window, 1, 0, " Hi: %d\n", g->score_high);
wattron(s->window, A_DIM);
iterate(g->opts->grid_width * (g->print_width + 2) + 1, waddch(s->window, '-')); iterate(g->opts->grid_width * (g->print_width + 2) + 1, waddch(s->window, '-'));
wattroff(s->window, A_DIM);
int x, y, int x, y,
xpos = 0, xpos = 0,
ypos = 3; ypos = 3;
for (y = 0; y < g->opts->grid_height; ++y, ++ypos, xpos = 0) { for (y = 0; y < g->opts->grid_height; ++y, ++ypos, xpos = 0) {
wattron(s->window, A_DIM);
mvwprintw(s->window, ypos, xpos++, "|"); mvwprintw(s->window, ypos, xpos++, "|");
wattroff(s->window, A_DIM);
for (x = 0; x < g->opts->grid_width; ++x) { for (x = 0; x < g->opts->grid_width; ++x) {
if (g->grid[x][y]) { if (g->grid[x][y]) {
wattron(s->window, COLOR_PAIR(g->grid[x][y] % NUMBER_OF_COLORS)); wattron(s->window, COLOR_PAIR(g->grid[x][y] % NUMBER_OF_COLORS + 1));
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, " ");
mvwprintw(s->window, ypos, xpos + g->print_width, " |"); wattroff(s->window, COLOR_PAIR(g->grid[x][y] % NUMBER_OF_COLORS + 1));
wattron(s->window, A_DIM);
mvwprintw(s->window, ypos, xpos + g->print_width + 1, "|");
wattroff(s->window, A_DIM);
} }
else { else {
wattron(s->window, A_DIM);
iterate(g->print_width + 1, waddch(s->window, ' ')); iterate(g->print_width + 1, waddch(s->window, ' '));
waddch(s->window, '|'); waddch(s->window, '|');
wattroff(s->window, A_DIM);
} }
xpos += (g->print_width + 2); xpos += (g->print_width + 2);
} }
} }
wattron(s->window, A_DIM);
iterate(g->opts->grid_height * (g->print_width + 2) + 1, waddch(s->window, '-')); iterate(g->opts->grid_height * (g->print_width + 2) + 1, waddch(s->window, '-'));
wattroff(s->window, A_DIM);
wrefresh(s->window); wrefresh(s->window);
} }