⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 screen.c

📁 我搜集到的一个java常用类库的源代码
💻 C
📖 第 1 页 / 共 2 页
字号:
  int x,y;  wmvaddstr(stdscr,4,10,"□");  for(x=13;x<=45;x+=2)  {    waddstr(stdscr,"─");  }  waddstr(stdscr,"□");  for(y=5;y<=12;y++)  {    wmvaddstr(stdscr,y,10,"│");    wmvaddstr(stdscr,y,46,"│");  }  wmvaddstr(stdscr,13,10,"□");  for(x=12;x<=44;x+=2)  {    waddstr(stdscr,"─");  }  waddstr(stdscr,"□");}draw_global_screen(){  clear();  draw_title(); }draw_playing_screen(){  int x,y;  clear();  /* Draw outline */  for(y=0;y<=23;y++)  {    wmvaddstr(stdscr,y,0,"│");    wmvaddstr(stdscr,y,56,"│");    wmvaddstr(stdscr,y,76,"│");  }  wmvaddstr(stdscr,18,0,"├");  for(x=3;x<=77;x+=2)  {    waddstr(stdscr,"─");  }  wmvaddstr(stdscr,18,76,"┤");  wmvaddstr(stdscr,18,56,"┼");  wmvaddstr(stdscr,23,2,"【对话】 ");  /* Draw table outline */  /* Information section */  wmvaddstr(stdscr,1,56,"├");  for(x=58;x<=74;x+=2)    waddstr(stdscr,"─");  waddstr(stdscr,"┤");  wmvaddstr(stdscr,3,56,"├");  for(x=58;x<=74;x+=2)    waddstr(stdscr,"─");  waddstr(stdscr,"┤");  wmvaddstr(stdscr,12,56,"├");  for(x=58;x<=74;x+=2)    waddstr(stdscr,"─");  waddstr(stdscr,"┤");  wmvaddstr(stdscr,0,66,"│");  wmvaddstr(stdscr,1,66,"┼");  wmvaddstr(stdscr,2,66,"│");  wmvaddstr(stdscr,3,66,"┴");  /* Characters */  wmvaddstr(stdscr,0,60,"风  局");  wmvaddstr(stdscr,0,68,"连    庄");  wmvaddstr(stdscr,2,58,"门风:");  wmvaddstr(stdscr,2,68,"剩    张");  wmvaddstr(stdscr,4,58,"东家:");  wmvaddstr(stdscr,6,58,"南家:");  wmvaddstr(stdscr,8,58,"西家:");  wmvaddstr(stdscr,10,58,"北家:");  wmvaddstr(stdscr,5,62,"$");  wmvaddstr(stdscr,7,62,"$");  wmvaddstr(stdscr,9,62,"$");  wmvaddstr(stdscr,11,62,"$");  wmvaddstr(stdscr,13,60,"0  1  2  3  4");  wmvaddstr(stdscr,14,60,"无 吃 碰 杠 胡");  wmvaddstr(stdscr,20,64,"┌  ┐");  wmvaddstr(stdscr,22,64,"└  ┘");  wrefresh(stdscr);  wmove(inputwin,talk_y,talk_x);  wrefresh(inputwin);}find_point(pos)int pos;{  switch(pos)  {    case 0:      wmove(stdscr,22,66);      break;    case 1:      wmove(stdscr,21,68);      break;    case 2:      wmove(stdscr,20,66);      break;    case 3:      wmove(stdscr,21,64);      break;  }}display_point(current_turn)int current_turn;{  static int last_turn=0;  char msg_buf[255];  if(last_turn)  {    find_point((last_turn+4-my_sit)%4);    waddstr(stdscr,"  ");    wrefresh(stdscr);    find_point((last_turn+4-my_sit)%4);    waddstr(stdscr,sit_name[last_turn]);  }  find_point((current_turn+4-my_sit)%4);  waddstr(stdscr,"  ");  wrefresh(stdscr);  find_point((current_turn+4-my_sit)%4);  attron(A_REVERSE);  waddstr(stdscr,sit_name[current_turn]);  attroff(A_REVERSE);  last_turn=current_turn;}display_time(sit)char sit;{  char msg_buf[255];  char pos;  int min,sec;  pos=(sit-my_sit+4)%4;  min=(int) pool[sit].time/60;  min=min%60;    sec=(int) pool[sit].time%60;  sprintf(msg_buf,"%2d:%02d",min,sec);  switch(pos)  {    case 0:      wmvaddstr(stdscr,23,64,"     ");      wmvaddstr(stdscr,23,64,msg_buf);      break;    case 1:      wmvaddstr(stdscr,21,71,"     ");      sprintf(msg_buf,"%d:%02d",min,sec);      wmvaddstr(stdscr,21,71,msg_buf);      break;    case 2:      wmvaddstr(stdscr,19,64,"     ");      wmvaddstr(stdscr,19,64,msg_buf);      break;    case 3:      wmvaddstr(stdscr,21,58,"     ");      wmvaddstr(stdscr,21,58,msg_buf);      break;  }  return_cursor();}display_info(){  int i;  wmvaddstr(stdscr,0,58,"  ");  wmvaddstr(stdscr,0,62,"  ");  wmvaddstr(stdscr,0,70,"    ");  wrefresh(stdscr);  wmvaddstr(stdscr,0,58,sit_name[info.wind]);  wmvaddstr(stdscr,0,62,sit_name[info.dealer]);  if(info.cont_dealer<10)    show_num(0,71,info.cont_dealer,1);  else    show_num(0,70,info.cont_dealer,2);  wmvaddstr(stdscr,22,66,sit_name[my_sit]);  wmvaddstr(stdscr,21,68,sit_name[(my_sit)%4+1]);  wmvaddstr(stdscr,20,66,sit_name[(my_sit+1)%4+1]);  wmvaddstr(stdscr,21,64,sit_name[(my_sit+2)%4+1]);  wmvaddstr(stdscr,4,64,player[table[EAST]].name);  wmvaddstr(stdscr,6,64,player[table[SOUTH]].name);  wmvaddstr(stdscr,8,64,player[table[WEST]].name);  wmvaddstr(stdscr,10,64,player[table[NORTH]].name);  for(i=1;i<=4;i++)  {    display_time(i);  }  mvwprintw(stdscr,5,64,"         ");  mvwprintw(stdscr,5,64,"%ld",player[table[EAST]].money);  mvwprintw(stdscr,7,64,"         ");  mvwprintw(stdscr,7,64,"%ld",player[table[SOUTH]].money);  mvwprintw(stdscr,9,64,"         ");  mvwprintw(stdscr,9,64,"%ld",player[table[WEST]].money);  mvwprintw(stdscr,11,64,"         ");  mvwprintw(stdscr,11,64,"%ld",player[table[NORTH]].money);  mvwprintw(stdscr,4,74,"  ");  mvwprintw(stdscr,6,74,"  ");  mvwprintw(stdscr,8,74,"  ");  mvwprintw(stdscr,10,74,"  ");  attron(A_REVERSE);  mvwprintw(stdscr,2+info.dealer*2,74,"庄");  attroff(A_REVERSE);  wrefresh(stdscr);  wmove(inputwin,talk_y,talk_x);  wrefresh(inputwin);}int more_size=0, more_num=0;char more_buf[4096];int readln(fd,buf,end_flag)int fd ;char *buf ;int *end_flag;{    int len, bytes, in_esc, ch;    len = bytes = in_esc = 0;    *end_flag=0;    while( 1 ) {        if( more_num >= more_size ) {            more_size = read( fd, more_buf, 1);            if( more_size == 0 ) {                break;            }            more_num = 0;        }        ch = more_buf[ more_num++ ];        bytes++;        if( ch == '\n' || len >= 74 ) {            break;        } else if( ch == '\0' ) {            *end_flag=1;            *buf='\0';             return bytes;/*        } else if( ch == '\t' ) {            do {                len++, *buf++ = ' ';            } while( (len % 8) != 0 );        } else if( ch == '\033' ) {            if( showansi )  *buf++ = ch;            in_esc = 1;        } else if( in_esc ) {            if( showansi )  *buf++ = ch;            if( strchr( "[0123456789;,", ch ) == NULL ) {                in_esc = 0;            }*/        } else {            len++, *buf++ = ch;        }    }    *buf++ = ch;    *buf = '\0';    return bytes;}display_news(fd)int fd;{  char buf[256];  int bytes;  int line_count;  int end_flag;  WINDOW *news_win;    line_count=0;  news_win=newwin(22,74,0,2);   wclear(news_win);  wmove(news_win,0,0);  while(readln(fd,buf,&end_flag))  {    if(end_flag==1)      break;    if(line_count==22)    {      wrefresh(news_win);      wait_a_key("请按 <ENTER> 至下一页......");      line_count=0;      wclear(news_win);      wmove(news_win,0,0);    }    printstr(news_win,buf);wrefresh(news_win);    line_count++;  }  wrefresh(news_win);  wait_a_key("请按 <ENTER> 继续.......");  delwin(news_win);  redraw_screen();}display_comment(comment)char *comment;{  waddstr(commentwin,"\n");   printstr(commentwin,comment);  wrefresh(commentwin);  return_cursor();}send_talk_line(talk)char *talk;{  char comment[255];  char msg_buf[255];  int i;  sprintf(comment,"<%s> ",my_name);  strcat(comment,talk);  display_comment(comment);  sprintf(msg_buf,"102%s",comment);  if(in_serv)  {    broadcast_msg(1,msg_buf);  }  if(in_join)  {    write_msg(table_sockfd,msg_buf);  }}send_gps_line(msg)char *msg;{  char comment[255];/*  sprintf(comment,"□ ");  strcat(comment,msg);*/strcpy(comment,msg);  display_comment(comment);}intlog10(num)int num;{  int i;  i=0;  do  {    num/=10;    if(num>=1)      i++;  } while(num>=1);  return(i);}convert_num(str,number,digit)char *str;int number;int digit;{  int i;  int tmp[10];  for(i=digit-1;i>=0;i--)  {    tmp[i]=number%10;    number/=10;  }  for(i=0;i<digit;i++)    strcpy(str+i*2,number_item[tmp[i]]);}    show_num(y,x,number,digit) int y;int x;int number;int digit;{  int i;  char msg_buf[255];  wmove(stdscr,y,x);  for(i=0;i<digit;i++)    waddstr(stdscr,"  ");  wrefresh(stdscr);  convert_num(msg_buf,number,digit);  wmvaddstr(stdscr,y,x,msg_buf);  wrefresh(stdscr);}show_cardmsg(sit,card,type)int sit;char card;int type;{  int pos;  pos=(sit-my_sit+4)%4;  clear_screen_area(15,58,3,18);  if(card)  {     wmvaddstr(stdscr,15,58,"┌───────┐");    wmvaddstr(stdscr,16,58,"│              │");    wmvaddstr(stdscr,17,58,"└───────┘");    switch(pos)    {      case 0:        wmvaddstr(stdscr,16,60,"玩");        break;      case 1:        wmvaddstr(stdscr,16,60,"下");        break;      case 2:        wmvaddstr(stdscr,16,60,"对");        break;      case 3:        wmvaddstr(stdscr,16,60,"上");        break;    }    wmvaddstr(stdscr,16,62,"家打(    )");    wrefresh(stdscr);    show_card(card,68,16,0);  }  return_cursor();}redraw_screen(){  int i,j;  clearok(stdscr,TRUE);  wrefresh(stdscr);  touchwin(commentwin);  wrefresh(commentwin);  touchwin(inputwin);  wrefresh(inputwin);  return_cursor();/*  if(screen_mode==PLAYING_SCREEN_MODE)  {    for(i=1;i<=4;i++)    {      if(table[i] && i!=my_sit)        show_cardback(i);    }    if(turn==card_owner)      show_newcard(turn,2);    for(i=0;i<3;i++)      for(j=0;j<17;j++)      {        if(table_card[i][j]!=0 && table_card[i][j]!=20)        {          show_card(20,THROW_X+j*2,THROW_Y+i*2,1);          show_card(table_card[i][j],THROW_X+j*2,THROW_Y+i*2,1);        }      }    sort_card(0);  }*/}reset_cursor(){  mvwaddstr(stdscr,23,75," ");  wrefresh(stdscr);}return_cursor(){  switch(input_mode)  {    case ASK_MODE:    case TALK_MODE:      reset_cursor();      wmove(inputwin,talk_y,talk_x);      wrefresh(inputwin);      break;    case CHECK_MODE:      wmove(stdscr,org_check_y,check_x);      wrefresh(stdscr);      break;    case PLAY_MODE:      wmove(stdscr,pos_y,pos_x);      wrefresh(stdscr);      break;    case EAT_MODE:      wmove(stdscr,eat_y,eat_x);      wrefresh(stdscr);      break;  }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -