/** Pops a window showing the top highscores */ void engine_draw_hscores() { window_s* w = NULL; w = &(engine.screen.hscores_container); if (global.screen_fancy_borders) window_fancy_borders(w->win); else window_normal_borders(w->win); wattrset(w->win, engine_get_color(COLOR_BLUE, COLOR_BLACK, false)); mvwaddstr(w->win, 0, 1, "High Scores"); wnoutrefresh(w->win); w = &(engine.screen.hscores); werase(w->win); /* This is all well-alligned, think twice before changing a single char */ wattrset(w->win, engine_get_color(COLOR_BLUE, COLOR_BLACK, false)); mvwaddstr(w->win, 0, 1, " Score Lines Level Timer Name Date Time"); wattrset(w->win, engine_get_color(COLOR_BLUE, COLOR_BLACK, true)); int i; for (i = 0; i < MAX_HSCORES; i++) { if (hscores[i].points == 0) /* empty score record */ mvwaddstr(w->win, 1 + i, 1, "---------- ---------- -- -------- ---------- ---------- --------"); else mvwprintw(w->win, 1 + i, 1, "%10d %10d %2d %8s %10s %10s %8s", hscores[i].points, hscores[i].lines, hscores[i].level, hscores[i].timer, hscores[i].name, hscores[i].date, hscores[i].time); } wnoutrefresh(w->win); }
globals_s new_globals() { globals_s g; g.screen_center_vertically = false; g.screen_center_horizontally = false; g.screen_use_colors = true; g.screen_fancy_borders = true; g.screen_show_outer_border = true; g.game_has_ghost = true; g.game_can_hold = true; g.game_next_no = NEXT_PIECES_NO; g.game_has_statistics = true; g.game_has_line_statistics= false; g.game_random_algorithm = 1; g.game_line_clear_timeout = 200000; /* the hard-coded default appearances */ g.theme_piece[0] = ' '; g.theme_piece[1] = ' '; g.theme_ghost[0] = '['; g.theme_ghost[1] = ']'; g.theme_clear_line[0] = ':'; g.theme_clear_line[1] = ':'; g.theme_piece_has_colors = true; g.theme_ghost_has_colors = false; g.theme_show_pivot_block = false; g.theme_lock_piece_color = false; g.theme_clear_line_color = engine_get_color(COLOR_WHITE, COLOR_BLACK, true); g.theme_piece_no_color = engine_get_color(COLOR_BLACK, COLOR_WHITE, false); g.theme_ghost_color = engine_get_color(COLOR_WHITE, COLOR_BLACK, true); g.theme_piece_S_color = engine_get_color(COLOR_WHITE, COLOR_GREEN, false); g.theme_piece_Z_color = engine_get_color(COLOR_WHITE, COLOR_RED, false); g.theme_piece_O_color = engine_get_color(COLOR_WHITE, COLOR_YELLOW, false); g.theme_piece_I_color = engine_get_color(COLOR_WHITE, COLOR_CYAN, true); g.theme_piece_L_color = engine_get_color(COLOR_WHITE, COLOR_YELLOW, false); g.theme_piece_J_color = engine_get_color(COLOR_WHITE, COLOR_BLUE, false); g.theme_piece_T_color = engine_get_color(COLOR_WHITE, COLOR_MAGENTA, false); int i; for (i = 0; i < 2; i++) { g.theme_piece_S[i] = ' '; g.theme_piece_Z[i] = ' '; g.theme_piece_O[i] = ' '; g.theme_piece_I[i] = ' '; g.theme_piece_L[i] = ' '; g.theme_piece_J[i] = ' '; g.theme_piece_T[i] = ' '; } g.fps = 0; g.config_filename = NULL; return g; }
/** Draws everything that's on the info window (the rightmost one) */ void engine_draw_info(game_s* g) { window_s w = engine.screen.info; werase(w.win); /* Can only draw one at a time D: */ if (global.game_has_statistics) engine_draw_statistics(g); else if (global.game_has_line_statistics) engine_draw_line_statistics(g); wattrset(w.win, engine_get_color(COLOR_BLUE, COLOR_BLACK, false)); mvwaddstr(w.win, 0, 0, "yetris v"VERSION); mvwaddstr(w.win, 1, 1, "(press 'h' for info)"); mvwaddstr(w.win, w.height - 1, 0, "Timer:"); wattrset(w.win, engine_get_color(COLOR_WHITE, COLOR_BLACK, false)); if (g->gameplay_h) /* Wow.. will someone really play this game for hours? */ mvwprintw(w.win, w.height - 1, 7, "%02d:%02d:%02d", g->gameplay_h, g->gameplay_m % 60, g->gameplay_s % 60); else mvwprintw(w.win, w.height - 1, 7, "%02d:%02d", g->gameplay_m % 60, g->gameplay_s % 60); wattrset(w.win, engine_get_color(COLOR_BLUE, COLOR_BLACK, false)); mvwaddstr(w.win, w.height - 2, 0, "Speed:"); wattrset(w.win, engine_get_color(COLOR_WHITE, COLOR_BLACK, false)); mvwprintw(w.win, w.height - 2, 7, "%dms", g->speed); /* This is a little hack to display the time onscreen. * It's ugly as hell, but I had to make it * Format: Wed Jun 30 21:49:08 1993\n */ time_t cur_time; time(&cur_time); wattrset(w.win, engine_get_color(COLOR_BLACK, COLOR_BLACK, true)); mvwprintw(w.win, w.height - 1, 15, "%.8s", (ctime(&cur_time) + 11)); /* Showing FPS */ // mvwprintw(w.win, w.height - 2, 15, "FPS: %d", global.fps); /* DRAW BORDERS AGGHWW */ w = engine.screen.rightmost; if (global.screen_fancy_borders) window_fancy_borders(w.win); else window_normal_borders(w.win); wnoutrefresh(w.win); }
/** Prints 'pause' on the board */ void engine_draw_pause() { window_s* w = &(engine.screen.board); wattrset(w->win, engine_get_color(COLOR_BLUE, COLOR_BLACK, false)); mvwaddstr(w->win, w->height/2 - 1, w->width/2 - 4, "[paused]"); wnoutrefresh(w->win); }
void engine_draw_line_statistics(game_s* g) { window_s* w = &(engine.screen.info); wattrset(w->win, engine_get_color(COLOR_BLUE, COLOR_BLACK, true)); mvwaddstr(w->win, 3, 1, "Single:"); mvwaddstr(w->win, 4, 1, "Double:"); mvwaddstr(w->win, 5, 1, "Triple:"); mvwaddstr(w->win, 6, 1, "Tetris:"); mvwaddstr(w->win, 7, 1, "Total:"); wattrset(w->win, engine_get_color(COLOR_WHITE, COLOR_BLACK, false)); mvwprintw(w->win, 3, 9, "%10d", g->single_count); mvwprintw(w->win, 4, 9, "%10d", g->double_count); mvwprintw(w->win, 5, 9, "%10d", g->triple_count); mvwprintw(w->win, 6, 9, "%10d", g->tetris_count); mvwprintw(w->win, 7, 9, "%10d", g->lines_count); }
/** Prints a message telling the player that he has lost the game */ void engine_draw_gameover() { window_s* w = &(engine.screen.board); wattrset(w->win, engine_get_color(COLOR_BLUE, COLOR_BLACK, true)); mvwaddstr(w->win, w->height/2 - 1, w->width/2 - 4, "Game Over"); mvwaddstr(w->win, w->height/2 + 1, 4, "Press <Enter>"); mvwaddstr(w->win, w->height/2 + 2, 5, "to restart"); wnoutrefresh(w->win); }
/** Draws the window where we keep the hold piece */ void engine_draw_hold(game_s* g) { window_s* w = NULL; piece_s* p = &(g->piece_hold); w = &(engine.screen.leftmost); wattrset(w->win, engine_get_color(COLOR_BLUE, COLOR_BLACK, false)); mvwaddstr(w->win, 0, 1, "Hold"); wnoutrefresh(w->win); w = &(engine.screen.hold); werase(w->win); engine_draw_piece(p, w->win); wnoutrefresh(w->win); w = &(engine.screen.leftmost); /* DRAWING BORDERS, AGGGHW */ if (global.screen_fancy_borders) { window_fancy_borders(w->win); /* If the player has no hold, doesnt make sense printing these parts */ if (global.game_can_hold) { /* making the top line between hold and score windows */ mvwaddch(w->win, 5, 0, ACS_LLCORNER|COLOR_PAIR(WHITE_BLACK)); my_mvwhline(w->win, 5, 1, ACS_HLINE|COLOR_PAIR(BLACK_BLACK)|A_BOLD, w->width - 2); mvwaddch(w->win, 5, w->width - 1, ACS_LRCORNER|COLOR_PAIR(BLACK_BLACK)|A_BOLD); /* making the bottom line between hold and score windows */ mvwaddch(w->win, 6, 0, ACS_ULCORNER|COLOR_PAIR(WHITE_BLACK)|A_BOLD); my_mvwhline(w->win, 6, 1, ACS_HLINE|COLOR_PAIR(WHITE_BLACK), w->width - 2); mvwaddch(w->win, 6, w->width - 1, ACS_URCORNER|COLOR_PAIR(WHITE_BLACK)); } } else { window_normal_borders(w->win); wattrset(w->win, engine_get_color(COLOR_BLACK, COLOR_BLACK, true)); mvwhline(w->win, 5, 1, '-', w->width - 2); } }
/** Draws a single block. * It prints on the screen the two chars that represents * the block. They're stored on #b under 'theme'. */ void engine_draw_block(block_s* b, WINDOW* w) { if (global.screen_use_colors) wattrset(w, b->color); else wattrset(w, engine_get_color(COLOR_BLACK, COLOR_WHITE, false)); mvwaddch(w, b->y, (b->x * 2), b->theme[0]); mvwaddch(w, b->y, (b->x * 2) + 1, b->theme[1]); }
/** Draws the score, high score and warn the player if he has any * combo or back-to-back sequences. */ void engine_draw_score(game_s* g) { window_s w = engine.screen.score; werase(w.win); /* If user has combo, let's show it to him */ if ((g->is_combo) && (g->combo_count > 0)) { if (g->combo_count > 3) wattrset(w.win, engine_get_color(COLOR_RED, COLOR_BLACK, false)); else wattrset(w.win, engine_get_color(COLOR_YELLOW, COLOR_BLACK, false)); mvwaddstr(w.win, 0, 2, "Combo!"); mvwprintw(w.win, 0, 8, "x%d", g->combo_count); } /* If user has back-to-back lines, let's show it to him */ if (g->back_to_back_count > 0) { if (g->back_to_back_lines < 4) wattrset(w.win, engine_get_color(COLOR_RED, COLOR_BLACK, true)); else wattrset(w.win, engine_get_color(COLOR_YELLOW, COLOR_BLACK, true)); mvwaddstr(w.win, 1, 0, "Back-to-back"); switch (g->back_to_back_lines) { case 2: mvwaddstr(w.win, 2, 2, "Double"); break; case 3: mvwaddstr(w.win, 2, 2, "Triple"); break; case 4: mvwaddstr(w.win, 2, 2, "Tetris"); break; } if (g->back_to_back_count > 1) mvwprintw(w.win, 2, 8, "x%d", g->back_to_back_count); } wattrset(w.win, engine_get_color(COLOR_BLUE, COLOR_BLACK, false)); mvwaddstr(w.win, 3, 1, "High Score"); mvwaddstr(w.win, 6, 1, "Score"); mvwaddstr(w.win, 9, 1, "Lines"); mvwaddstr(w.win, 12, 1, "Level"); wattrset(w.win, engine_get_color(COLOR_WHITE, COLOR_BLACK, false)); mvwprintw(w.win, 4, 1, "%10d", hscores[0].points); mvwprintw(w.win, 7, 1, "%10d", g->score); mvwprintw(w.win, 10, 1, "%10d", g->lines); mvwprintw(w.win, 13, 9, "%02d", g->level); if (g->show_score_delta) { wattrset(w.win, engine_get_color(COLOR_GREEN, COLOR_BLACK, true)); mvwprintw(w.win, 8, 1, "%10d", g->score_delta); } wnoutrefresh(w.win); }
/** Locks all the blocks from piece #p on the board #b */ void board_lock_piece(board_s* b, piece_s* p) { int k; for (k = 0; k < 4; k++) { int block_x = p->block[k].x; int block_y = p->block[k].y; b->block[block_x][block_y] = p->block[k]; if (global.theme_lock_piece_color) b->block[block_x][block_y].color = engine_get_color(WHITE_WHITE, false); } }
/* patio brasil, 504 sul, locus * vi x emacs * * */ void engine_get_hscore_name(char* name, int size) { window_s* w = &(engine.screen.input); WINDOW* sub = derwin(w->win, 1, 11, 1, 18); werase(sub); wattrset(sub, engine_get_color(COLOR_BLACK, COLOR_BLUE, false)); mvwhline(sub, 0, 0, ' ', 11); char buffer[256]; memset(buffer, '\0', 256); wattrset(w->win, engine_get_color(COLOR_WHITE, COLOR_BLACK, false)); nodelay(stdscr, FALSE); echo(); mvwscanw(sub, 0, 0, "%[^\n]s", buffer); if (strlen(buffer) != 0) strncpy(name, buffer, size); noecho(); nodelay(stdscr, TRUE); }
/** Deletes all the lines specified by the array #lines. * * @note I know this function's ugly... I'll fix that later */ void board_delete_lines(board_s* b, bool lines[]) { int i, j, k; char clear1, clear2; /* The appearance of the line just before it's deleted */ if (global.theme_clear_line[0] != '\0') { clear1 = global.theme_clear_line[0]; clear2 = global.theme_clear_line[1]; } else { clear1 = ':'; clear2 = ':'; } /* loop through all lines, doing something only on those marked 'true' */ for (k = 0; k < BOARD_HEIGHT; k++) { if (!lines[k]) continue; /* A nice little animation for destroyed lines */ for (i = 0; i < BOARD_WIDTH; i++) { b->block[i][k].theme[0] = clear1; b->block[i][k].theme[1] = clear2; b->block[i][k].color = engine_get_color(WHITE_BLACK, true); } } engine_draw_board(b); wrefresh(engine.screen.board.win); usleep(200 * 1000); for (k = 0; k < BOARD_HEIGHT; k++) { if (!lines[k]) continue; /* Moves all upper lines one row down */ for (j = k; j > 0; j--) { for (i = 0; i < BOARD_WIDTH; i++) { b->block[i][j] = b->block[i][j - 1]; b->block[i][j].y += 1; } } } }
/** Pops a window explaining some stuff */ void engine_draw_help() { window_s* w = NULL; w = &(engine.screen.help_container); if (global.screen_fancy_borders) window_fancy_borders(w->win); else window_normal_borders(w->win); wattrset(w->win, engine_get_color(COLOR_BLUE, COLOR_BLACK, false)); mvwaddstr(w->win, 0, 1, "Help"); wnoutrefresh(w->win); w = &(engine.screen.help); werase(w->win); wattrset(w->win, engine_get_color(COLOR_BLUE, COLOR_BLACK, true)); mvwaddstr(w->win, 0, 2, "Controls:\n"); wattrset(w->win, engine_get_color(COLOR_WHITE, COLOR_BLACK, false)); mvwaddstr(w->win, 1, 0, " Enter Return to the game\n" " q Quits game at any time\n" " Left, Right Controls the piece\n" " Down Soft-drop\n" " Space Hard-drop\n" " c Holds the piece\n" " z, x Rotates piece counter-clockwise and clockwise\n" " p Pauses/unpauses the game\n" " r Restart game\n" " F2 Switch statistics\n" " F3 Show high scores\n" " F5 Refresh game based on config file\n"); mvwaddstr(w->win,w->height - 1, 0, "For fun, check config file '~/.yetrisrc.ini'"); wnoutrefresh(w->win); }
void engine_draw_input() { window_s* w = NULL; w = &(engine.screen.input_container); if (global.screen_fancy_borders) window_fancy_borders(w->win); else window_normal_borders(w->win); wattrset(w->win, engine_get_color(COLOR_BLUE, COLOR_BLACK, false)); // mvwaddstr(w->win, 0, 1, "Enter your name"); wrefresh(w->win); w = &(engine.screen.input); werase(w->win); wattrset(w->win, engine_get_color(COLOR_BLUE, COLOR_BLACK, false)); mvwaddstr(w->win, 0, 1, "Contrats, you made into the high score list!"); mvwaddstr(w->win, 1, 1, "Enter your name:"); // mvwprintf(w->win, 1, 1, "(position: %d", 192998); char name[11]; memset(name, '\0', 11); if (getenv("USER") == NULL) strncpy(name, "player", 10); else strncpy(name, getenv("USER"), 10); wattrset(w->win, engine_get_color(COLOR_BLUE, COLOR_BLACK, true)); mvwprintw(w->win, 2, 18, "(default: %s)", name); /* ncurses' refresh all windows */ wrefresh(w->win); }
/** Draws a nice animation when the player loses the game */ void engine_draw_gameover_animation(game_s* g) { board_s* b = &(g->board); window_s* w = &(engine.screen.board); int i, j; for (j = 0; j < BOARD_HEIGHT; j++) { for (i = 0; i < BOARD_WIDTH; i++) { if (b->block[i][j].type != EMPTY) { b->block[i][j].color = engine_get_color(COLOR_WHITE, COLOR_WHITE, false); engine_draw_block(&(b->block[i][j]), w->win); } } /* Stop a little (50ms) before painting next line */ usleep(50000); wrefresh(w->win); } wrefresh(w->win); /* Now wait a second, to let the feeling of defeat sink in */ // usleep(1000000); }
/** This is a very ugly function that draws blocks on the * info window for statistical purposes. * It uses several position hacks that i need to fix later. * The problem is that pieces always start relative to the * middle of the board, independent of the screen. * So im repositioning them according to it, on the info screen. */ void engine_draw_statistics(game_s* g) { window_s w = engine.screen.info; int k; int x_offset = 3; wattrset(w.win, engine_get_color(COLOR_WHITE, COLOR_BLACK, false)); mvwprintw(w.win, 3, 1, "%10d x", g->I_count); piece_s p = new_piece(PIECE_I); p.x = x_offset; p.y = 4; for (k = 0; k < 4; k++) { p.block[k].x += p.x; p.block[k].y += p.y; } engine_draw_piece(&p, w.win); wattrset(w.win, engine_get_color(COLOR_WHITE, COLOR_BLACK, false)); mvwprintw(w.win, 5, 1, "%10d x", g->T_count); p = new_piece(PIECE_T); p.x = x_offset; p.y = 6; for (k = 0; k < 4; k++) { p.block[k].x += p.x; p.block[k].y += p.y; } engine_draw_piece(&p, w.win); wattrset(w.win, engine_get_color(COLOR_WHITE, COLOR_BLACK, false)); mvwprintw(w.win, 7, 1, "%10d x", g->L_count); p = new_piece(PIECE_L); p.x = x_offset; p.y = 8; for (k = 0; k < 4; k++) { p.block[k].x += p.x; p.block[k].y += p.y; } engine_draw_piece(&p, w.win); wattrset(w.win, engine_get_color(COLOR_WHITE, COLOR_BLACK, false)); mvwprintw(w.win, 9, 1, "%10d x", g->J_count); p = new_piece(PIECE_J); p.x = x_offset; p.y = 10; for (k = 0; k < 4; k++) { p.block[k].x += p.x; p.block[k].y += p.y; } engine_draw_piece(&p, w.win); wattrset(w.win, engine_get_color(COLOR_WHITE, COLOR_BLACK, false)); mvwprintw(w.win, 11, 1, "%10d x", g->S_count); p = new_piece(PIECE_S); p.x = x_offset; p.y = 12; for (k = 0; k < 4; k++) { p.block[k].x += p.x; p.block[k].y += p.y; } engine_draw_piece(&p, w.win); wattrset(w.win, engine_get_color(COLOR_WHITE, COLOR_BLACK, false)); mvwprintw(w.win, 13, 1, "%10d x", g->Z_count); p = new_piece(PIECE_Z); p.x = x_offset; p.y = 14; for (k = 0; k < 4; k++) { p.block[k].x += p.x; p.block[k].y += p.y; } engine_draw_piece(&p, w.win); wattrset(w.win, engine_get_color(COLOR_WHITE, COLOR_BLACK, false)); mvwprintw(w.win, 15, 1, "%10d x", g->O_count); p = new_piece(PIECE_O); p.x = x_offset - 1; p.y = 16; for (k = 0; k < 4; k++) { p.block[k].x += p.x; p.block[k].y += p.y; } engine_draw_piece(&p, w.win); wattrset(w.win, engine_get_color(COLOR_WHITE, COLOR_BLACK, false)); mvwprintw(w.win, 16, 1, "%10d Total", g->piece_count); }
void engine_draw_next_pieces(game_s* g) { WINDOW* w = NULL; int i, k; for (i = 0; i < global.game_next_no; i++) { piece_s p = g->piece_next[i]; w = engine.screen.next[i].win; werase(w); /* This is a little hack to pretty-print pieces * TODO somehow manage to fix this */ for (k = 0; k < 4; k++) { /* shifting them to the left */ p.block[k].x -= p.x + 1; p.block[k].y -= p.y; p.block[k].y--; if (p.type == PIECE_O) p.block[k].y -= 1; } engine_draw_piece(&p, w); wnoutrefresh(w); } w = engine.screen.middle_right.win; if (global.screen_fancy_borders) { mvwaddch(w, 3, 0, ACS_LLCORNER|COLOR_PAIR(WHITE_BLACK)); mvwhline(w, 3, 1, ACS_HLINE|COLOR_PAIR(BLACK_BLACK)|A_BOLD, 8); mvwaddch(w, 3, 9, ACS_LRCORNER|COLOR_PAIR(BLACK_BLACK)|A_BOLD); } else { wattrset(w, engine_get_color(COLOR_BLACK, COLOR_BLACK, true)); mvwhline(w, 3, 1, '-', 8); } wattrset(w, engine_get_color(COLOR_BLUE, COLOR_BLACK, false)); mvwaddstr(w, 0, 1, "Next"); wnoutrefresh(w); window_s* win = &(engine.screen.middle_right); /* RE-DRAWING BORDERS (damn this sucks) */ if (global.screen_fancy_borders) { window_fancy_borders(win->win); /* making the top line between 1st next and the rest */ mvwaddch(win->win, 3, 0, ACS_LLCORNER|COLOR_PAIR(WHITE_BLACK)); mvwhline(win->win, 3, 1, ACS_HLINE|COLOR_PAIR(BLACK_BLACK)|A_BOLD, win->width - 2); mvwaddch(win->win, 3, win->width - 1, ACS_LRCORNER|COLOR_PAIR(BLACK_BLACK)|A_BOLD); /* making the bottom line between 1st next and the rest */ mvwaddch(win->win, 4, 0, ACS_ULCORNER|COLOR_PAIR(WHITE_BLACK)|A_BOLD); mvwhline(win->win, 4, 1, ACS_HLINE|COLOR_PAIR(WHITE_BLACK), win->width - 2); mvwaddch(win->win, 4, win->width - 1, ACS_URCORNER|COLOR_PAIR(WHITE_BLACK)); } else { window_normal_borders(win->win); wattrset(win->win, engine_get_color(COLOR_BLACK, COLOR_BLACK, true)); mvwhline(win->win, 3, 1, '-', win->width - 2); } }
/** Starts all the subscreens of the game */ int engine_windows_init() { window_s w; screen_s* s = &(engine.screen); int main_x = 0; int main_y = 0; if (global.screen_center_horizontally) main_x = engine.screen.width/2 - 80/2; if (global.screen_center_vertically) main_y = engine.screen.height/2 - 24/2; /* main window, wrapper of all others */ w.width = 80; w.height = 24; w.x = main_x; w.y = main_y; w.win = newwin(w.height, w.width, w.y, w.x); if (global.screen_show_outer_border) { if (global.screen_fancy_borders) window_fancy_borders(w.win); else window_normal_borders(w.win); } wnoutrefresh(w.win); s->main = w; /* leftmost */ w.width = 6 * 2 + 2; w.height = s->main.height - 2; /* borders */ w.x = 2; w.y = 1; w.win = derwin(s->main.win, w.height, w.width, w.y, w.x); if (global.screen_fancy_borders) { window_fancy_borders(w.win); /* If the player has no hold, doesnt make sense printing these parts */ if (global.game_can_hold) { /* making the top line between hold and score windows */ mvwaddch(w.win, 5, 0, ACS_LLCORNER|COLOR_PAIR(WHITE_BLACK)); my_mvwhline(w.win, 5, 1, ACS_HLINE|COLOR_PAIR(BLACK_BLACK)|A_BOLD, w.width - 2); mvwaddch(w.win, 5, w.width - 1, ACS_LRCORNER|COLOR_PAIR(BLACK_BLACK)|A_BOLD); /* making the bottom line between hold and score windows */ mvwaddch(w.win, 6, 0, ACS_ULCORNER|COLOR_PAIR(WHITE_BLACK)|A_BOLD); my_mvwhline(w.win, 6, 1, ACS_HLINE|COLOR_PAIR(WHITE_BLACK), w.width - 2); mvwaddch(w.win, 6, w.width - 1, ACS_URCORNER|COLOR_PAIR(WHITE_BLACK)); } } else { window_normal_borders(w.win); wattrset(w.win, engine_get_color(COLOR_BLACK, COLOR_BLACK, true)); mvwhline(w.win, 5, 1, '-', w.width - 2); } wnoutrefresh(w.win); s->leftmost = w; /* middle-left */ w.width = 10 * 2 + 2; w.height = s->main.height - 2; /* borders */ w.x = s->leftmost.x + s->leftmost.width + 1; w.y = 1; w.win = derwin(s->main.win, w.height, w.width, w.y, w.x); if (global.screen_fancy_borders) window_fancy_borders(w.win); else window_normal_borders(w.win); wnoutrefresh(w.win); s->middle_left = w; /* middle-right */ w.width = 4 * 2 + 2; w.height = s->main.height - 2; /* borders */ w.x = s->middle_left.x + s->middle_left.width + 1; w.y = 1; w.win = derwin(s->main.win, w.height, w.width, w.y, w.x); if (global.screen_fancy_borders) { window_fancy_borders(w.win); /* making the top line between 1st next and the rest */ mvwaddch(w.win, 3, 0, ACS_LLCORNER|COLOR_PAIR(WHITE_BLACK)); mvwhline(w.win, 3, 1, ACS_HLINE|COLOR_PAIR(BLACK_BLACK)|A_BOLD, w.width - 2); mvwaddch(w.win, 3, w.width - 1, ACS_LRCORNER|COLOR_PAIR(BLACK_BLACK)|A_BOLD); /* making the bottom line between 1st next and the rest */ mvwaddch(w.win, 4, 0, ACS_ULCORNER|COLOR_PAIR(WHITE_BLACK)|A_BOLD); mvwhline(w.win, 4, 1, ACS_HLINE|COLOR_PAIR(WHITE_BLACK), w.width - 2); mvwaddch(w.win, 4, w.width - 1, ACS_URCORNER|COLOR_PAIR(WHITE_BLACK)); } else { window_normal_borders(w.win); wattrset(w.win, engine_get_color(COLOR_BLACK, COLOR_BLACK, true)); mvwhline(w.win, 3, 1, '-', w.width - 2); } wnoutrefresh(w.win); s->middle_right = w; /* right-most */ w.width = s->main.width - (s->middle_right.x + s->middle_right.width) - 3; w.height = s->main.height - 2; /* borders */ w.x = s->middle_right.x + s->middle_right.width + 1; w.y = 1; w.win = derwin(s->main.win, w.height, w.width, w.y, w.x); if (global.screen_fancy_borders) window_fancy_borders(w.win); else window_normal_borders(w.win); wnoutrefresh(w.win); s->rightmost = w; /* next pieces */ w.width = s->middle_right.width - 2; w.height = s->middle_right.height - 2; w.x = 1; w.y = 1; w.win = derwin(s->middle_right.win, w.height, w.width, w.y, w.x); wnoutrefresh(w.win); s->next_container = w; /* first next piece */ w.width = s->next_container.width; w.height = 2; w.x = 0; w.y = 0; w.win = derwin(s->next_container.win, w.height, w.width, w.y, w.x); wnoutrefresh(w.win); s->next[0] = w; /* the rest */ int i; int y_offset = 2; for (i = 1; i <= global.game_next_no; i++) { /* making all the next pieces 1 line lower */ if (i != 1) y_offset = 0; w.width = s->next_container.width; w.height = 2; w.x = 0; w.y = s->next[i - 1].y + s->next[i - 1].height + 1 + y_offset; w.win = derwin(s->next_container.win, w.height, w.width, w.y, w.x); wnoutrefresh(w.win); s->next[i] = w; } s->board = new_sub_win_from(s->middle_left.win, (s->middle_left.width - 2), (s->middle_left.height - 2), 1, 1); s->info = new_sub_win_from(s->rightmost.win, (s->rightmost.width - 4), (s->rightmost.height - 2), 2, 1); s->leftmost_container = new_sub_win_from(s->leftmost.win, (s->leftmost.width - 2), (s->leftmost.height - 2), 1, 1); s->hold = new_sub_win_from(s->leftmost_container.win, s->leftmost_container.width, 4, 0, 0); s->score = new_sub_win_from(s->leftmost_container.win, s->leftmost_container.width, s->leftmost_container.height - (s->hold.height) - 2, 0, s->hold.y + s->hold.height + 2); /* w.width = s->leftmost_container.width; */ /* w.height = s->leftmost_container.height - (s->hold.height) - 2; */ /* w.x = 0; */ /* w.y = s->hold.y + s->hold.height + 2; */ /* w.win = derwin(s->leftmost_container.win, w.height, w.width, w.y, w.x); */ /* wnoutrefresh(w.win); */ /* s->score = w; */ w = s->info; wattrset(w.win, engine_get_color(COLOR_WHITE, COLOR_BLACK, true)); mvwaddstr(w.win, w.height - 1, 16 , "Loading"); wnoutrefresh(w.win); return 1; }
/** Draws normal borders on window #win */ void window_normal_borders(WINDOW* win) { wattrset(win, engine_get_color(COLOR_BLACK, COLOR_BLACK, true)); wborder(win, '|', '|', '-', '-', '+', '+', '+', '+'); }