void printtextbox(const char *text, int pos) { int underscore; if (_WHITE_BG) underscore = textgfx_flags & (ASCII | GNOME_TERM) || !_XTERM; else underscore = textgfx_flags & (MONOCHROME | TT_BLOCKS); while (*text) { setattr_normal(); if (!pos) setattr_standout(); else { if (_WHITE_BG) { if (!underscore || textgfx_flags & GNOME_TERM) setattr_underline(); } else setcolorpair(WHITE_ON_BLUE); } if (*text == ' ' && underscore) putch('_'); else putch(*text); text++; pos--; } setattr_normal(); }
void drawpanel_bordercolor(int clr) { if (_MONOCHROME) setattr_normal(); else setcolorpair(clr | 16); }
void printmenuitem(const char *name, int sel) { #if !NO_MENU if (*name == '-') { putch(' '); if (!name[1]) putnchars('-', 16); else printstr(name); return; } #endif if (!sel) setcolorpair(MAGENTA_FG); else if (!_MONOCHROME) setcolorpair(WHITE_ON_BLUE); else setattr_standout(); if (sel && (textgfx_flags & TT_MONO)==TT_BLOCKS) { while (*name==' ') { putch(' '); name++; } putch('*'); } else putch(' '); printstr(name); putch(' '); setattr_normal(); movefwd(1); }
void print_vitetris_ver(int x, int y) { setcurs(x, y); setattr_bold(); printstr(VITETRIS_VER); setattr_normal(); }
void textgfx_init() { #ifdef UNIX strcpy(_xwin.application_name, "vitetris"); strcpy(_xwin.application_class, "Vitetris"); #endif if (install_allegro(SYSTEM_AUTODETECT, &errno, NULL) != 0) exit(1); #ifdef UNIX sigaction(SIGINT, NULL, &allegro_sigint_handler); signal(SIGINT, sigint_handler); #endif load_pc8x16_font(); set_window_title(VITETRIS_VER); set_close_button_callback(close_btn); #ifndef UNIX /* Seems to cause seg fault later quite randomly on Linux */ int depth = desktop_color_depth(); if (depth != 0) set_color_depth(depth); #endif virt_screen = set_screen(getopt_int("", "fullscreen")); lang |= LATIN1; if (!font8x16) { font8x16 = font; textgfx_flags |= ASCII; } setattr_normal(); #if WIN32 && !ALLEGRO_USE_CONSOLE if (exists("stdout.tmp")) { FILE *fp; freopen("stdout2.tmp", "w", stdout); fp = fopen("stdout.tmp", "r"); if (fp) { char line[80]; int i; for (i=0; i < 25 && fgets(line, 80, fp); i++) { setcurs(0, i); i += printline(line); } fclose(fp); if (i) { refreshscreen(); if (!strncmp(line, "Press ", 6)) { install_keyboard(); clear_keybuf(); readkey(); remove_keyboard(); } } } freopen("stdout.tmp", "w", stdout); delete_file("stdout2.tmp"); } #endif }
static void printstat_1p() { setattr_normal(); if (!_WHITE_BG) setattr_bold(); setcurs(1, 2); printlong(" %06ld ", player1.score % 1000000); setcurs(3, 6); printint(" %02d ", player1.level); setcurs(3, 10); printint(" %03d ", player1.lines); }
void draw_tetris_logo(int x, int y) { int bl; drawbl(0x227, 1, x, y); drawbl(0x313, 4, x+7, y); drawbl(1, 4, x+8, y+1); drawbl(0x227, 6, x+12, y); drawbl(0x113, 7, x+19, y); drawbl(0x111, 2, x+24, y); bl = 0x326; if (is_outside_screen(x+33, 0)) bl = 0x322; drawbl(bl, 3, x+27, y); setattr_normal(); }
static void printdropdownitem(const char *name, int sel, int w) { if (sel) { while (name[0]==' ' && name[1]==' ') { putch(' '); name++; w--; } setattr_normal(); } printstr(name); if (strlen(name) < w) putch(' '); if (sel) setattr_standout(); }
void print_game_message(int pl, const char *str, int bold) { int x = board_x(pl, 4); int n = strlen(str); if (!(game->player[pl-1].rotationsys & ROT_LEFTHAND)) x--; while (n >= 6) { x--; n -= 2; } setwcurs(0, x, _HEIGHT_24L ? 7 : 3); setattr_normal(); if (bold) setcolorpair(MAGENTA_FG); printstr(str); refreshwin(0); }
static int op_tcolor(int k, int *pos) { char *c = tetrom_colors + *pos; if (k >= '1' && k <= '7') *c = k-'0'; else if (k == A_BTN) { *c += 1; if (*c == 8) *c = 1; } else if (k) return 0; setcolorpair(*c); putch(' '); putch(*c+'0'); putch(' '); setattr_normal(); return 1; }
static void printsavebutton(int sel) { if (_MONOCHROME) { if (sel) setattr_standout(); else setattr_bold(); } else if (sel) { setcolorpair(YELLOW_ON_GREEN); } else { setcolorpair(4); putch('['); setcolorpair(YELLOW_ON_BLUE); printstr(" Save "); setcolorpair(4); putch(']'); goto out; } printstr("[ Save ]"); out: setattr_normal(); }
static void print_tetr_stats() { const char letters[8] = "IJLOSTZ"; int sum = 0; int i; if (term_width < 45) return; setwcurs(WIN_TETROM_STATS, 1, 0); for (i = 0; i < 7; i++) { setblockcolor(tetrom_colors[i]); putch(block_chars[0]); putch(letters[i]); putch(block_chars[1]); setattr_normal(); printint(" %03d", tetr_stats[i]); newln(1); sum += tetr_stats[i]; } printstr(" -----"); newln(0); printint("Sum %04d", sum); refreshwin(WIN_TETROM_STATS); }
static void print_top_scores() { char s[8]; const struct hiscore *hs = hiscores; int pos = 0; int i = 1; if (term_width < 47 || !hs[0].score) return; setwcurs(WIN_TOP_SCORES, 0, 0); setcolorpair(MAGENTA_FG); printstr("Top Scores"); setattr_normal(); while (hs->score && i <= 5) { newln(0); if (!pos && player1.score > hs->score) { hiscoreline(); pos = 1; continue; } putch(i+'0'); putch('.'); if (hs->score < 1000000) putch(' '); sprintf(s, "%06ld", (long) hs->score); printstr(s); hs++; i++; } if (!pos) { newln(0); if (ishiscore()) hiscoreline(); else cleartoeol(); } refreshwin(WIN_TOP_SCORES); }
void printmenuitem_options(const char *str, int sel) { char buf[16]; const char *p = str; int ret; while (1) { if (p = strchr(str, ' ')) { memcpy(buf, str, p-str); buf[p-str] = '\0'; } else strcpy(buf, str); if (!sel) { setattr_standout(); ret = printstr(buf); setattr_normal(); } else ret = printstr(buf); if (!ret || !p) break; putch(' '); str = p+1; sel--; } }
static void hiscoreline() { setcolorpair(RED_FG); putnchars('-', 9); setattr_normal(); }