Exemplo n.º 1
0
void redraw()
{
	erase();
	draw_borders();
	draw_ball();
	draw_users();
	draw_info();
	refresh();
}
Exemplo n.º 2
0
int game() {
    static int selected_game = 0;

    drawgames(selected_game);
    xt_par0(XT_CH_NORMAL);
    SETPOS(2, COLS - 18);
    draw_users();
    fflush(stdout);
    int key;
    if ((key = getkey()) == KEY_NOTHING)
        return 0;

    xt_par0(XT_CH_NORMAL);
    SETPOS(2, COLS - 18);
    // printf("Who's Online");
    // for (i = 0; i < numusers - onlinelistoffset; i++) {
    //     SETPOS(4 + i, COLS - 18);
    //     if (5 + i > ROWS)
    //         break;
    //     printf("%s", users[i + onlinelistoffset].username);

    // }
    switch(key) {
        // case '<':
        //     xt_par0(XT_CLEAR_SCREEN);
        //     drawgames(selected_game);
        //     dispmultiframe();
        //     if (onlinelistoffset > 0)
        //         onlinelistoffset--;
        //     xt_par0(XT_CH_NORMAL);
        //     SETPOS(2, COLS - 18);
        //     printf("Who's Online");
        //     for (i = 0; i < numusers - onlinelistoffset; i++) {
        //         SETPOS(4 + i, COLS - 18);
        //         if (5 + i > ROWS)
        //             break;
        //         if (users[i + onlinelistoffset].status != CLIENT_FREE)
        //             printf("%s", users[i + onlinelistoffset].username);
        //     }
        //     break;
        // case '>':
        //     xt_par0(XT_CLEAR_SCREEN);
        //     drawgames(selected_game);
        //     dispmultiframe();
        //     if (ROWS - 5 + onlinelistoffset < 64)
        //         onlinelistoffset++;
        //     xt_par0(XT_CH_NORMAL);
        //     SETPOS(2, COLS - 18);
        //     printf("Who's Online");
        //     for (i = 0; i < numusers - onlinelistoffset; i++) {
        //         SETPOS(4 + i, COLS - 18);
        //         if (5 + i > ROWS)
        //             break;
        //         if (users[i + onlinelistoffset].status != CLIENT_FREE)
        //             printf("%s", users[i + onlinelistoffset].username);
        //     }
        //     break;
        case 'q':
        case 'Q':
            xt_par0(XT_CLEAR_SCREEN);
            SETPOS(0,0);
            return MENU_QUIT;
        case 'w':
        case KEY_UP: {
            int i;
            for (i = selected_game - 1; i > 0; i--) {
                if (games[i].status != GAME_FREE) {
                    selected_game = i;
                    drawgames(selected_game);
                    xt_par0(XT_CH_NORMAL);
                    SETPOS(2, COLS - 18);
                    draw_users();
                    fflush(stdout);
                }
            }
            break;
        }
        case 's':
        case KEY_DOWN: {
            int i;
            for (i = selected_game + 1; i < MAX_GAMES; i++) {
                if (games[i].status != GAME_FREE) {
                    selected_game = i;
                    drawgames(selected_game);
                    xt_par0(XT_CH_NORMAL);
                    SETPOS(2, COLS - 18);
                    draw_users();
                    fflush(stdout);
                }
            }
            break;
        }
        case 'j':
        case 'J':
            if (join_popup(&games[selected_game]))
                game_wait(selected_game);
            drawgames(selected_game);
            xt_par0(XT_CH_NORMAL);
            SETPOS(2, COLS - 18);
            draw_users();
            break;
        case 'c':
        case 'C':
            if (create_popup()) // create_popup also includes the error message handling
                game_wait(numgames - 1);
            drawgames(selected_game);
            xt_par0(XT_CH_NORMAL);
            SETPOS(2, COLS - 18);
            draw_users();
            break;
        case 'h':
        case 'H':
            help_popup();
            break;
    }
    return 0;
}