static void printmenuhelp(int y) { setcurs(0, y); printstr("Use the arrow keys or TAB to navigate,"); newln(0); printstr("ENTER to proceed, BACKSPACE or ESC to"); newln(0); printstr("go back. Exit at once with Q."); }
int startupmenu(int i) { while (1) { print_vitetris_ver(19, 4); newln(0); newln(19); printstr("Written by"); newln(19); printstr("Victor Nilsson"); newln(19); printstr("2007-2009"); i = startup_menu(i-1, 1, 4); # ifndef TTY_SOCKET if (!i) break; # else if (i==2 && !select_2p_tty(17, 5)) continue; if (!i && (i = menu_checkinvit(1, 4)) == -1) { i = 1; continue; } if (!i) break; setcurs_end(); printf("\033[K"); # endif clearbox(0, 4, 0, menuheight-4); break; } return i; }
static int hiscore_congrats(const char **menu) { char name[8] = " "; int x = 9; int y = _HEIGHT_24L ? 7 : 3; setwcurs(0, 9, y); while (is_outside_screen(x+26, 0)) x--; drawbox(x, y, 26, 9, "CONGRATULATIONS!"); setcurs(x+2, y+2); printstr("You have a highscore!"); newln(x+2); printstr("Please enter your name"); entername: switch (hiscore_entername_menu(name, menu, x+4, y+4)) { case 0: return 0; case 1: if (savehiscore(name)) { if (x > 7) clearbox(33, y, 2, 9); return hiscorebox(menu, 9, y); } setcurs(x+2, y+2); printstr("ERROR! Could not save"); newln(x+2); printstr("score to file. "); goto entername; case 2: clearbox(32, y, 0, 9); return 1; } }
static void printmenuhelp(int y) { if (term_height < y+5 || term_width < 48) return; setcurs(0, y); printstr("Use the arrow keys or TAB to navigate,"); newln(0); printstr("ENTER to proceed, BACKSPACE or ESC to"); newln(0); printstr("go back. Exit at once with Q."); }
void drawboard(int pl) { int x = board_x(pl, 0); int i; char tmp[30]; if (_HEIGHT_24L) { //i = x+5; //setwcurs(0, i, 0); if (!_MONOCHROME) { setcolorpair(BOARD_FRAME_COLOR); setattr_bold(); } //i = x-5; //setwcurs(0, i, 0); //sprintf(tmp, "lqNk\\x Nx\\| N|"); //drawstr(tmp, 8, i, 0); i = x+5; setwcurs(0, i, 0); drawstr("lqNk\\x Nx\\2|_N|", 8, i, 0); setcolorpair(BOARD_FRAME_COLOR); setcurs(x, 3); printstr("_____"); movefwd(10); printstr("_____"); i = 4; } else i = 0; x--; setwcurs(0, x, i); setcolorpair(BOARD_FRAME_COLOR); for (i = 0; i < 20; i++) { putch(VLINE); movefwd(20); putch(VLINE); if (i < 19) newln(x); } if (term_height > 20 && term_height != 24) { newln(x); printstr_acs("m*Nj", 20); } else { setcurs(0, term_height-2); newln(0); } #ifdef TWOPLAYER board_bottom_color[pl-1] = BOARD_FRAME_COLOR; #endif }
void show_hiscorelist5(int x, int y, int i) { char s[20]; const struct hiscore *hs, *end; int n; if (!hiscores[0].score && !readhiscores(NULL)) return; setcurs(x, y); hs = hiscores; i -= 5; if (i < 0) i = 0; else hs += i; end = hs+5; while (hs->score && hs != end) { n = sprintf(s, "%2d. %s", i+1, gethiscorename(i, s+12)); memset(s+n, ' ', 12-n); sprintf(s+12, "%7ld", (long) hs->score); printstr(s); newln(x); hs++; i++; } }
void textgfx_entermenu() { while (curs_y < 4) newln(0); menuheight = 4; margin_x = getmargin_x(); draw_tetris_logo(0, 0); }
int dropdownlist(const char **items, int n, int i, int x, int y) { int w = getdropdownwidth(items, n); int j; while (is_outside_screen(0, y+n+1)) y--; setattr_standout(); drawbox(x, y, w+2, n+2, NULL); x++; y++; setcurs(x, y); for (j = 0; j < n; j++) { printdropdownitem(items[j], i==j, w); newln(x); } while (1) { setcurs(x-1, y+i); refreshwin(-1); switch (getkeypress_block(SINGLE_PL) & 0xFF) { case STARTBTN: case A_BTN: goto out; case 'q': exit(0); case MVUP: if (!i) continue; j = -1; break; case '\t': if (i == n-1) { j = -i; break; } case MVDOWN: if (i < n-1) { j = 1; break; } case MVRIGHT: continue; default: i = -1; goto out; } setcurs(x, y+i); printdropdownitem(items[i], 0, w); i += j; setcurs(x, y+i); printdropdownitem(items[i], 1, w); } out: clearbox(x-1, y-1, w+2, n+2); return i+1; }
int draw_vline(int x, int y, int h) { if (is_outside_screen(x+1, 0)) return 0; movefwd(x); while (--h) { putch(VLINE); newln(x); } putch(VLINE); return 1; }
void drawmenu(const char **menu, int n, int pos, int x, int y, menuhandler *handlers) { int i; setcurs(x, y); for (i = 0; i < n; i++) { printmenuitem(menu[i], (i==pos)); if (handlers && handlers[i]) handlers[i](0, &i); newln(x); } }
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 inp_printkeys(int dev, int x, int y) { const char *k; int i; x += 6; setcurs(x, y); for (i = 0; i < 11; i++) { k = getkeyfor_str(dev, inp_keypr(i)); printstr(k); putnchars(' ', 6-strlen(k)); if (i == 5) { x += 17; setcurs(x, y); } else newln(x); } }
int gamemenu() { int i = 1; #ifdef TWOPLAYER int h; if (!TWOPLAYER_MODE || game->mode & MODE_NETWORK) h = GAMEMENU_LENGTH+4; else { h = 17; while (menuheight < h) newln(2); } while (1) { i = game_menu(0, 1, 4); if (i==4) inputsetup_box(0, 1, 4); else break; } if (!i) clearbox(0, 4, 0, h-4); #else while (1) { i = game_menu(i-1, 1, 4); if (i==4) { setcurs(0, 13); printf("\033[K"); inputsetup_box(0, 1, 4); i = 1; } else if (i < GAMEMENU_LENGTH-1) break; else { clearbox(0, 4, 0, GAMEMENU_LENGTH); if (i == GAMEMENU_LENGTH-1) optionsmenu(); else hiscorelist(); } } #endif return i; }
void inputsetup_menu(int pl, int x, int y) { const char *menu[11] = { " Up", "Dwn", "Lft", "Rgt", " A", " B", " Rotate ", " Rot cw ", NULL, "Harddrop", "Softdrop" }; char rot_acw[9] = " Rot acw"; int dev = 0; int i = 0; int xx, k; #ifdef JOYSTICK int devlist = num_joyst; if (devlist) { i = -1; setcurs(x, y); newln(x); y++; } #endif spellword(rot_acw+5); menu[8] = rot_acw; drawmenu(menu, 6, i, x, y, NULL); drawmenu(menu+6, 5, -1, x+12, y, NULL); #ifdef TWOPLAYER player_ = pl; #endif while (1) { #ifdef JOYSTICK if (devlist && i==-1) { if (!inp_devlist(&dev, x, y-1)) return; printmenuitem(menu[0], 1); i = 0; } #endif inp_printkeys(dev, x, y); xx = inp_setcurs(x, y, i); refreshwin(-1); k = setkeymapping(dev, inp_keypr(i)); #ifdef JOYSTICK if (devlist && (k==MVUP && !i || k=='\t' && i==10)) { printmenuitem(menu[i], 0); i = -1; continue; } #endif if (k==MVUP && !i) k = MVDOWN; else if (k==MVDOWN && i==10) { printmenuitem(menu[10], 0); inp_setcurs(x, y, i=0); printmenuitem(menu[0], 1); continue; } switch (handle_menuitem_2cols(menu, 11, &i, 6, xx, y+i%6, NULL, k)) { case 0: case 2: return; case 3: inp_setcurs(x, y, i); printmenuitem(menu[i], 1); } } }
static void printhelp(int x, int y) { setcurs(x, y); printstr("ESC to clear, TAB to skip,"); newln(x); printstr("ENTER to return"); }