📄 hu_stuff.c
字号:
{ newstart = maxpicsize; newend = maxpicsize = (maxpicsize * 2); } piclist = realloc(piclist, sizeof(fspic_t) * maxpicsize); for(i = newstart; i < newend; i++) { piclist[i].lumpnum = -1; piclist[i].data = NULL; }}int HU_GetFSPic(int lumpnum, int xpos, int ypos){ int i; if(!maxpicsize) HU_InitFSPics(); getpic: for(i = 0; i < maxpicsize; i++) { if(piclist[i].lumpnum != -1) continue; piclist[i].lumpnum = lumpnum; piclist[i].xpos = xpos; piclist[i].ypos = ypos; piclist[i].draw = false; return i; } HU_InitFSPics(); goto getpic;}int HU_DeleteFSPic(int handle){ if(handle < 0 || handle > maxpicsize) return -1; piclist[handle].lumpnum = -1; piclist[handle].data = NULL; return 0;}int HU_ModifyFSPic(int handle, int lumpnum, int xpos, int ypos){ if(handle < 0 || handle > maxpicsize) return -1; if(piclist[handle].lumpnum == -1) return -1; piclist[handle].lumpnum = lumpnum; piclist[handle].xpos = xpos; piclist[handle].ypos = ypos; piclist[handle].data = NULL; return 0;}int HU_FSDisplay(int handle, boolean newval){ if(handle < 0 || handle > maxpicsize) return -1; if(piclist[handle].lumpnum == -1) return -1; piclist[handle].draw = newval; return 0;}void HU_DrawFSPics(){ int i; for(i = 0; i < maxpicsize; i++) { if(piclist[i].lumpnum == -1 || piclist[i].draw == false) continue; if(piclist[i].xpos >= vid.width || piclist[i].ypos >= vid.height) continue; if(!piclist[i].data) piclist[i].data = (patch_t *) W_CachePatchNum(piclist[i].lumpnum, PU_STATIC); if((piclist[i].xpos + piclist[i].data->width) < 0 || (piclist[i].ypos + piclist[i].data->height) < 0) continue; V_DrawScaledPatch(piclist[i].xpos, piclist[i].ypos, 0, piclist[i].data); }}//======================================================================// HUD MESSAGES CLEARING FROM SCREEN//======================================================================// Clear old messages from the borders around the view window// (only for reduced view, refresh the borders when needed)//// startline : y coord to start clear,// clearlines : how many lines to clear.//static int oldclearlines;void HU_Erase (void){ int topline; int bottomline; int y,yoffset; //faB: clear hud msgs on double buffer (Glide mode) boolean secondframe; static int secondframelines; if (con_clearlines==oldclearlines && !con_hudupdate && !chat_on) return; // clear the other frame in double-buffer modes secondframe = (con_clearlines!=oldclearlines); if (secondframe) secondframelines = oldclearlines; // clear the message lines that go away, so use _oldclearlines_ bottomline = oldclearlines; oldclearlines = con_clearlines; if( chat_on ) if( bottomline < 8 ) bottomline=8; if (automapactive || viewwindowx==0) // hud msgs don't need to be cleared return; // software mode copies view border pattern & beveled edges from the backbuffer if (rendermode==render_soft) { topline = 0; for (y=topline,yoffset=y*vid.width; y<bottomline ; y++,yoffset+=vid.width) { if (y < viewwindowy || y >= viewwindowy + viewheight) R_VideoErase(yoffset, vid.width); // erase entire line else { R_VideoErase(yoffset, viewwindowx); // erase left border // erase right border R_VideoErase(yoffset + viewwindowx + viewwidth, viewwindowx); } } con_hudupdate = false; // if it was set.. }#ifdef HWRENDER else { // refresh just what is needed from the view borders HWR_DrawViewBorder (secondframelines); con_hudupdate = secondframe; }#endif}//======================================================================// IN-LEVEL DEATHMATCH RANKINGS//======================================================================// count frags for each teamint HU_CreateTeamFragTbl(fragsort_t *fragtab,int dmtotals[],int fragtbl[MAXPLAYERS][MAXPLAYERS]){ int i,j,k,scorelines,team; scorelines = 0; for (i=0; i<MAXPLAYERS; i++) { if (playeringame[i]) { if(cv_teamplay.value==1) team=players[i].skincolor; else team=players[i].skin; for(j=0;j<scorelines;j++) if (fragtab[j].num == team) { // found there team if(fragtbl) { for(k=0;k<MAXPLAYERS;k++) if(playeringame[k]) { if(cv_teamplay.value==1) fragtbl[team][players[k].skincolor] += players[i].frags[k]; else fragtbl[team][players[k].skin] += players[i].frags[k]; } } fragtab[j].count += ST_PlayerFrags(i); if(dmtotals) dmtotals[team]=fragtab[j].count; break; } if (j==scorelines) { // team not found add it if(fragtbl) for(k=0;k<MAXPLAYERS;k++) fragtbl[team][k] = 0; fragtab[scorelines].count = ST_PlayerFrags(i); fragtab[scorelines].num = team; fragtab[scorelines].color = players[i].skincolor; fragtab[scorelines].name = team_names[team]; if(fragtbl) { for(k=0;k<MAXPLAYERS;k++) if(playeringame[k]) { if(cv_teamplay.value==1) fragtbl[team][players[k].skincolor] += players[i].frags[k]; else fragtbl[team][players[k].skin] += players[i].frags[k]; } } if(dmtotals) dmtotals[team]=fragtab[scorelines].count; scorelines++; } } } return scorelines;}//// draw Deathmatch Rankings//void HU_drawDeathmatchRankings (void){ patch_t* p; fragsort_t fragtab[MAXPLAYERS]; int i; int scorelines; int whiteplayer; // draw the ranking title panel p = W_CachePatchName("RANKINGS",PU_CACHE); V_DrawScaledPatch ((BASEVIDWIDTH-p->width)/2,5,0,p); // count frags for each present player scorelines = 0; for (i=0; i<MAXPLAYERS; i++) { if (playeringame[i]) { fragtab[scorelines].count = ST_PlayerFrags(i); fragtab[scorelines].num = i; fragtab[scorelines].color = players[i].skincolor; fragtab[scorelines].name = player_names[i]; scorelines++; } } //Fab:25-04-98: when you play, you quickly see your frags because your // name is displayed white, when playback demo, you quicly see who's the // view. whiteplayer = demoplayback ? displayplayer : consoleplayer; if (scorelines>9) scorelines = 9; //dont draw past bottom of screen, show the best only if(cv_teamplay.value==0) WI_drawRancking(NULL,80,70,fragtab,scorelines,true,whiteplayer); else { // draw the frag to the right// WI_drawRancking("Individual",170,70,fragtab,scorelines,true,whiteplayer); scorelines = HU_CreateTeamFragTbl(fragtab,NULL,NULL); // and the team frag to the left WI_drawRancking("Teams",80,70,fragtab,scorelines,true,players[whiteplayer].skincolor); }}// draw the Crosshair, at the exact center of the view.//// Crosshairs are pre-cached at HU_Init#ifdef HWRENDER // not win32 only 19990829 by Kin extern float gr_basewindowcentery; extern float gr_viewheight;#endifvoid HU_drawCrosshair (void){ int i; int y; i = cv_crosshair.value & 3; if (!i) return;#ifdef HWRENDER if ( rendermode != render_soft ) { HWR_ScalePatch ( FALSE ); y = gr_basewindowcentery; } else#endif y = viewwindowy+(viewheight>>1); V_DrawTranslucentPatch (vid.width>>1, y, 0, crosshair[i-1]); if( cv_splitscreen.value ) {#ifdef HWRENDER if ( rendermode != render_soft ) y += gr_viewheight; else#endif y += viewheight; V_DrawTranslucentPatch (vid.width>>1, y, 0, crosshair[i-1]); }#ifdef HWRENDER if ( rendermode != render_soft ) HWR_ScalePatch ( TRUE );#endif}//======================================================================// CHAT MACROS COMMAND & VARS//======================================================================// better do HackChatmacros() because the strings are NULL !!consvar_t cv_chatmacro1 = {"_chatmacro1", NULL, CV_SAVE,NULL};consvar_t cv_chatmacro2 = {"_chatmacro2", NULL, CV_SAVE,NULL};consvar_t cv_chatmacro3 = {"_chatmacro3", NULL, CV_SAVE,NULL};consvar_t cv_chatmacro4 = {"_chatmacro4", NULL, CV_SAVE,NULL};consvar_t cv_chatmacro5 = {"_chatmacro5", NULL, CV_SAVE,NULL};consvar_t cv_chatmacro6 = {"_chatmacro6", NULL, CV_SAVE,NULL};consvar_t cv_chatmacro7 = {"_chatmacro7", NULL, CV_SAVE,NULL};consvar_t cv_chatmacro8 = {"_chatmacro8", NULL, CV_SAVE,NULL};consvar_t cv_chatmacro9 = {"_chatmacro9", NULL, CV_SAVE,NULL};consvar_t cv_chatmacro0 = {"_chatmacro0", NULL, CV_SAVE,NULL};// set the chatmacros original text, before config is executed// if a dehacked patch was loaded, it will set the hacked texts,// but the config.cfg will override it.//void HU_HackChatmacros (void){ int i; // this is either the original text, or dehacked ones cv_chatmacro0.defaultvalue = HUSTR_CHATMACRO0; cv_chatmacro1.defaultvalue = HUSTR_CHATMACRO1; cv_chatmacro2.defaultvalue = HUSTR_CHATMACRO2; cv_chatmacro3.defaultvalue = HUSTR_CHATMACRO3; cv_chatmacro4.defaultvalue = HUSTR_CHATMACRO4; cv_chatmacro5.defaultvalue = HUSTR_CHATMACRO5; cv_chatmacro6.defaultvalue = HUSTR_CHATMACRO6; cv_chatmacro7.defaultvalue = HUSTR_CHATMACRO7; cv_chatmacro8.defaultvalue = HUSTR_CHATMACRO8; cv_chatmacro9.defaultvalue = HUSTR_CHATMACRO9; // link chatmacros to cvars chat_macros[0] = &cv_chatmacro0; chat_macros[1] = &cv_chatmacro1; chat_macros[2] = &cv_chatmacro2; chat_macros[3] = &cv_chatmacro3; chat_macros[4] = &cv_chatmacro4; chat_macros[5] = &cv_chatmacro5; chat_macros[6] = &cv_chatmacro6; chat_macros[7] = &cv_chatmacro7; chat_macros[8] = &cv_chatmacro8; chat_macros[9] = &cv_chatmacro9; // register chatmacro vars ready for config.cfg for (i=0;i<10;i++) CV_RegisterVar (chat_macros[i]);}// chatmacro <0-9> "chat message"//void Command_Chatmacro_f (void){ int i; if (COM_Argc()<2) { CONS_Printf ("chatmacro <0-9> : view chatmacro\n" "chatmacro <0-9> \"chat message\" : change chatmacro\n"); return; } i = atoi(COM_Argv(1)) % 10; if (COM_Argc()==2) { CONS_Printf("chatmacro %d is \"%s\"\n",i,chat_macros[i]->string); return; } // change a chatmacro CV_Set (chat_macros[i], COM_Argv(2));}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -