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

📄 hu_stuff.c

📁 The source code of Doom legacy for windows
💻 C
📖 第 1 页 / 共 3 页
字号:
    to=*(*p)++;    if(to==0 || to==consoleplayer || consoleplayer==playernum       || (to<0 && ST_SameTeam(&players[consoleplayer],&players[-to])) )         CONS_Printf("\3%s: %s\n", player_names[playernum], *p);    *p+=strlen(*p)+1;}//  Handles key input and string input//boolean HU_keyInChatString (char *s, char ch){    int         l;    if (ch >= ' ' && ch <= '_')    {        l = strlen(s);        if (l<HU_MAXMSGLEN-1)        {            s[l++]=ch;            s[l]=0;            return true;        }        return false;    }    else        if (ch == KEY_BACKSPACE)        {            l = strlen(s);            if (l)                s[--l]=0;            else                return false;        }        else            if (ch != KEY_ENTER)                return false; // did not eat key    return true; // ate the key}////void HU_Ticker(void){    player_t    *pl;    hu_tick++;    hu_tick &= 7;        //currently only to blink chat input cursor    // display message if necessary    // (display the viewplayer's messages)    pl = &players[displayplayer];    if (cv_showmessages.value && pl->message)    {        CONS_Printf ("%s\n",pl->message);        pl->message = 0;    }    //deathmatch rankings overlay if press key or while in death view    if (cv_deathmatch.value)    {        if (gamekeydown[gamecontrol[gc_scores][0]] ||            gamekeydown[gamecontrol[gc_scores][1]] )            hu_showscores = !chat_on;        else            hu_showscores = playerdeadview; //hack from P_DeathThink()    }    else        hu_showscores = false;}#define QUEUESIZE               128static char     chatchars[QUEUESIZE];static int      head = 0;static int      tail = 0;////char HU_dequeueChatChar(void){    char c;    if (head != tail)    {        c = chatchars[tail];        tail = (tail + 1) & (QUEUESIZE-1);    }    else    {        c = 0;    }    return c;}////void HU_queueChatChar(char c){    if (((head + 1) & (QUEUESIZE-1)) == tail)    {        plr->message = HUSTR_MSGU;      //message not send    }    else    {        if (c == KEY_BACKSPACE)        {            if(tail!=head)                head = (head - 1) & (QUEUESIZE-1);        }        else        {            chatchars[head] = c;            head = (head + 1) & (QUEUESIZE-1);        }    }    // send automaticly the message (no more chat char)    if(c==KEY_ENTER)    {        char buf[255],c;        int i=0;        do {            c=HU_dequeueChatChar();            buf[i++]=c;        } while(c);        if(i>3)            COM_BufInsertText (va("say %s",buf));    }}extern int     con_keymap;////  Returns true if key eaten//boolean HU_Responder (event_t *ev){static boolean        shiftdown = false;static boolean        altdown   = false;    boolean             eatkey = false;    char*               macromessage;    unsigned char       c;    if (ev->data1 == KEY_SHIFT)    {        shiftdown = (ev->type == ev_keydown);        return false;    }    else if (ev->data1 == KEY_ALT)    {        altdown = (ev->type == ev_keydown);        return false;    }    if (ev->type != ev_keydown)        return false;   // only KeyDown events now...    if (!chat_on)    {       // enter chat mode        if (ev->data1==gamecontrol[gc_talkkey][0]         || ev->data1==gamecontrol[gc_talkkey][1])        {            eatkey = chat_on = true;            w_chat[0] = 0;            HU_queueChatChar(HU_BROADCAST);        }    }    else    {        c = ev->data1;        // use console translations        if (con_keymap==french)            c = ForeignTranslation(c);        if (shiftdown)            c = shiftxform[c];        // send a macro        if (altdown)        {            c = c - '0';            if (c > 9)                return false;            macromessage = chat_macros[c]->string;            // kill last message with a '\n'            HU_queueChatChar(KEY_ENTER); // DEBUG!!!            // send the macro message            while (*macromessage)                HU_queueChatChar(*macromessage++);            HU_queueChatChar(KEY_ENTER);            // leave chat mode and notify that it was sent            chat_on = false;            eatkey = true;        }        else        {            if (language==french)                c = ForeignTranslation(c);            if (shiftdown || (c >= 'a' && c <= 'z'))                c = shiftxform[c];            eatkey = HU_keyInChatString(w_chat,c);            if (eatkey)            {                // static unsigned char buf[20]; // DEBUG                HU_queueChatChar(c);                // sprintf(buf, "KEY: %d => %d", ev->data1, c);                //      plr->message = buf;            }            if (c == KEY_ENTER)            {                chat_on = false;            }            else if (c == KEY_ESCAPE)                chat_on = false;        }    }    return eatkey;}//======================================================================//                         HEADS UP DRAWING//======================================================================//  Draw chat input//static void HU_DrawChat (void){    int  i,c,y;    c=0;    i=0;    y=HU_INPUTY;    while (w_chat[i])    {        //Hurdler: isn't it better like that?        V_DrawCharacter( HU_INPUTX + (c<<3), y, w_chat[i++] | 0x80 |V_NOSCALEPATCH|V_NOSCALESTART);        c++;        if (c>=(vid.width>>3))        {            c = 0;            y+=8;        }    }    if (hu_tick<4)        V_DrawCharacter( HU_INPUTX + (c<<3), y, '_' | 0x80 |V_NOSCALEPATCH|V_NOSCALESTART);}extern consvar_t cv_chasecam;//  Heads up displays drawer, call each frame//void HU_Drawer(void){    // draw chat string plus cursor    if (chat_on)        HU_DrawChat ();    // draw deathmatch rankings    if (hu_showscores)        HU_drawDeathmatchRankings ();    // draw the crosshair, not when viewing demos nor with chasecam    if (viewactive && cv_crosshair.value && !demoplayback && !cv_chasecam.value)        HU_drawCrosshair ();    HU_DrawTip();    HU_DrawFSPics();}//======================================================================//                          PLAYER TIPS//======================================================================#define MAXTIPLINES 20char    *tiplines[MAXTIPLINES];int     numtiplines = 0;int     tiptime = 0;int     largestline = 0;void HU_SetTip(char *tip, int displaytics){  int    i;  char   *rover, *ctipline, *ctipline_p;  for(i = 0; i < numtiplines; i++)    Z_Free(tiplines[i]);  numtiplines = 0;  rover = tip;  ctipline = ctipline_p = Z_Malloc(128, PU_STATIC, NULL);  *ctipline = 0;  largestline = 0;  while(*rover)  {    if(*rover == '\n' || strlen(ctipline) + 2 >= 128 || V_StringWidth(ctipline) + 16 >= BASEVIDWIDTH)    {      if(numtiplines > MAXTIPLINES)        break;      if(V_StringWidth(ctipline) > largestline)        largestline = V_StringWidth(ctipline);      tiplines[numtiplines] = ctipline;      ctipline = ctipline_p = Z_Malloc(128, PU_STATIC, NULL);      *ctipline = 0;      numtiplines ++;    }    else    {      *ctipline_p = *rover;      ctipline_p++;      *ctipline_p = 0;    }    rover++;    if(!*rover)    {      if(V_StringWidth(ctipline) > largestline)        largestline = V_StringWidth(ctipline);      tiplines[numtiplines] = ctipline;      numtiplines ++;    }  }  tiptime = displaytics;}static void HU_DrawTip(){  int    i;  if(!numtiplines) return;  if(!tiptime)  {    for(i = 0; i < numtiplines; i++)      Z_Free(tiplines[i]);    numtiplines = 0;    return;  }  tiptime--;  for(i = 0; i < numtiplines; i++)  {    V_DrawString((BASEVIDWIDTH - largestline) / 2,                 ((BASEVIDHEIGHT - (numtiplines * 8)) / 2) + ((i + 1) * 8),                 tiplines[i]);  }}void HU_ClearTips(){  int    i;  for(i = 0; i < numtiplines; i++)    Z_Free(tiplines[i]);  numtiplines = 0;  tiptime = 0;}//======================================================================//                           FS HUD Grapics!//======================================================================typedef struct{  int       lumpnum;  int       xpos;  int       ypos;  patch_t   *data;  boolean   draw;} fspic_t;fspic_t*   piclist = NULL;int        maxpicsize = 0;//// HU_InitFSPics// This function is called when Doom starts and every time the piclist needs// to be expanded.void HU_InitFSPics(){  int  newstart, newend, i;  if(!maxpicsize)  {    newstart = 0;    newend = maxpicsize = 128;  }  else

⌨️ 快捷键说明

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