/* =============== SCR_DrawStats =============== */ void SCR_DrawStats (void) { int mins, secs, tens; int y; char str[100]; if (!scr_showstats.value) return; y = scr_showfps.value ? 8 : 0; mins = cl.time / 60; secs = cl.time - 60 * mins; tens = (int)(cl.time * 10) % 10; sprintf (str,"%i:%i%i:%i", mins, secs/10, secs%10, tens); Draw_String (vid.width - (strlen(str)<<3), y, str); if (scr_showstats.value > 1) { sprintf (str,"s: %3i/%3i", cl.stats[STAT_SECRETS], cl.stats[STAT_TOTALSECRETS]); Draw_String (vid.width - (strlen(str)<<3), y + 8, str); sprintf (str,"m: %3i/%3i", cl.stats[STAT_MONSTERS], cl.stats[STAT_TOTALMONSTERS]); Draw_String (vid.width - (strlen(str)<<3), y + 16, str); } }
void SCR_DrawFPS(void) { extern CVar show_fps; static double lastframetime; double t; extern int fps_count; static int lastfps; static int totalfps; static int lastsecond; int x, y; char st[80]; if (!show_fps.getBool()) return; t = Sys_FloatTime(); lastfps = 1 / (t - lastframetime); if (((int) (t) % 100) > ((int) (lastframetime) % 100)) { lastsecond = totalfps; totalfps = 0; } lastframetime = t; totalfps += 1; sprintf(st, "%3d FPS", lastfps); x = vid.conwidth - strlen(st) * 8 - 16; y = 0; Draw_String(x, y, st); sprintf(st, "%3d Last second", lastsecond); x = vid.conwidth - strlen(st) * 8 - 16; y = 8; Draw_String(x, y, st); }
/* ============== SCR_DrawBAT Crow_bar ============== */ void SCR_DrawBAT (void) { extern cvar_t show_bat; int x, y, i; char stA[80],stB[80]; if (!show_bat.value) return; if (!scePowerIsBatteryExist()) { // Don't report anything. return; } const int level = scePowerGetBatteryLifePercent(); const bool charging = scePowerGetBatteryChargingStatus(); // Is the level not sensible? if ((level < 0) || (level > 100)) { // Hopefully it will be sensible soon. return; } sprintf(stA, "Battery %d%%\n",level); sprintf(stB, "Battery %d%% (charging)\n",level); if(!charging) x = vid.width - strlen(stA) * 16 - 70; else x = vid.width - strlen(stB) * 16 - 70; y = 2 ; //vid.height - (sb_lines * (vid.height/240) )- 16; if(show_bat.value == 2) { if(!charging) Draw_String(x, y, stA); else Draw_String(x, y, stB); } else { if(charging) { Draw_Fill (240, y, level, 5, 12+((int)(realtime*8)&120)); } else Draw_Fill (240, y, level, 5, level); } }
/* ================== SCR_DrawDemoStatus draws demo name, status and progress ================== */ int SCR_DrawDemoStatus(void) { extern cvar_t demo_statustime; char st[128]; int x, y; int w, i; int mins, secs; if (cls.timedemo || !cls.demoplayback) return 0; if (!cls.demopaused && (realtime - cls.demobartime > demo_statustime.value || cls.demobartime < 0)) return 0; w = min(((vid.width / 2) / 16) * 2, 40); //w = 20; x = vid.width / 2 - (w*8/2); y = vid.height - sb_lines - 8; // status if (cls.demopaused) Draw_String(vid.width/2-4*6, y-16, "paused"); // speed snprintf (st, sizeof (st), "%d%%", cls.demospeed); Draw_String(x+8, y-16, st); // status - time mins = ((int)(hosttime-cls.demostarttime)) / 60; secs = ((int)(hosttime-cls.demostarttime)) % 60; snprintf (st, sizeof (st), "%d:%02d", mins, secs); Draw_String(x+8*(w-strlen(st)-1), y-16, st); // progress bar memset(st, '\x81', w); st[0] = '\x80'; st[w-1] = '\x82'; st[w] = 0; Draw_String(x, y-24, st); Draw_Character((int)(x + 8*((cls.demopos / cls.demolength)*(w-3)+1)), y-24, '\x83'); // demo name strlcpy (st, cls.demoname, sizeof (st)); st[vid.width/8] = 0; Draw_Alt_String(vid.width/2 - 4*strlen(st), y-4, st); return 1; }
//muff - hacked out of SourceForge implementation + modified void SCR_DrawFPS (void) { static double lastframetime; double t; static int lastfps; int x, y; char st[80]; if (!cl_showfps->value) return; t = Sys_FloatTime (); if ((t - lastframetime) >= 1.0) { lastfps = fps_count; fps_count = 0; lastframetime = t; } sprintf(st, "%3d FPS", lastfps); x = vid.width - strlen(st) * 16 - 16; y = 0 ; //vid.height - (sb_lines * (vid.height/240) )- 16; // Draw_TileClear(x, y, strlen(st)*16, 16); Draw_String(x, y, st); }
/* ============== SCR_DrawFPS ============== */ void SCR_DrawFPS (void) { static double oldtime = 0, fps = 0; static int oldframecount = 0; double time; int frames; char str[12]; if (!scr_showfps.value) return; time = realtime - oldtime; frames = r_framecount - oldframecount; if (time < 0 || frames < 0) { oldtime = realtime; oldframecount = r_framecount; return; } if (time > 0.75) //update value every 3/4 second { fps = frames / time; oldtime = realtime; oldframecount = r_framecount; } sprintf (str, "%4.0f fps", fps); Draw_String (vid.width - (strlen(str)<<3), 0, str); }
void SCR_DrawFPS (void) { extern cvar_t show_fps; static double lastframetime; double t; extern int fps_count; #if defined(__APPLE__) || defined(MACOSX) static int lastfps; #else static lastfps; #endif /* APPLE || MACOSX */ int x, y; char st[80]; if (!show_fps.value) return; t = Sys_DoubleTime(); if ((t - lastframetime) >= 1.0) { lastfps = fps_count; fps_count = 0; lastframetime = t; } #if defined (__APPLE__) || defined (MACOSX) snprintf(st, 80, "%3d FPS", lastfps); #else sprintf(st, "%3d FPS", lastfps); #endif /* __APPLE__ || MACOSX */ x = vid.width - ((int) strlen(st)) * 8 - 8; y = vid.height - sb_lines - 8; // Draw_TileClear(x, y, strlen(st) * 8, 8); Draw_String(x, y, st); }
void SCR_DrawFPS (void) { extern cvar_t show_fps; static double lastframetime; double t; extern int fps_count; static lastfps; int x, y; char st[80]; if (!show_fps.value) return; t = Sys_DoubleTime(); if ((t - lastframetime) >= 1.0) { lastfps = fps_count; fps_count = 0; lastframetime = t; } sprintf(st, "%3d FPS", lastfps); x = vid.width - strlen(st) * 8 - 8; y = vid.height - sb_lines - 8; // Draw_TileClear(x, y, strlen(st) * 8, 8); Draw_String(x, y, st); }
void MS_Draw_Content_Editbox (struct menu_ct *content){ int py = 8; int i; char buf[512]; i = (content->rx - content->lx) / 8; // if we are the selected editbox draw a black background if (selected_editbox == content) Draw_AlphaRectangleRealRGB(content->lx, content->ly, content->width * 8, 8, 1, 1, 0.2, 0.2, 0.2, 1); if (content->subtype == 1) strcpy(buf,content->variable->string); if (content->subtype == 2) { if (content->iptr != NULL) strcpy(buf,va("%i",**content->iptr)); if (content->fptr != NULL) strcpy(buf,va("%f",**content->fptr)); if (content->dptr != NULL) strcpy(buf,va("%f",**content->dptr)); } if (ssc){ if (selected_editbox == content) { Draw_String(content->lx,content->ly,tmpstring); } else { Draw_String(content->lx,content->ly,buf); } }else{ Draw_String(content->lx,content->ly,buf); } content->ry = content->ly + py; content->rx = content->lx + 8 * content->width; }
/* =============== SCR_DrawStats =============== */ void SCR_DrawStats (void) { int mins, secs, tens; if (!show_stats.value || (show_stats.value == 3 || show_stats.value == 4)) return; mins = cl.time / 60; secs = cl.time - 60 * mins; tens = (int)(cl.time * 10) % 10; Draw_String (vid.width - 72, 32, va("%2i:%02i:%i", mins, secs, tens)); if (show_stats.value == 2 || show_stats.value == 4) { Draw_String (vid.width - 32, 40, va("%2i", cl.stats[STAT_SECRETS])); Draw_String (vid.width - 40, 48, va("%3i", cl.stats[STAT_MONSTERS])); } }
void SCR_DrawClock (void) { char str[9]; if (scr_clock.value == 1) { int minutes, seconds; minutes = cl.time / 60; seconds = ((int)cl.time)%60; sprintf (str,"%i:%i%i", minutes, seconds/10, seconds%10); } #ifdef _WIN32 else if (scr_clock.value == 2) { int hours, minutes, seconds; SYSTEMTIME systime; char m[3] = "AM"; GetLocalTime(&systime); hours = systime.wHour; minutes = systime.wMinute; seconds = systime.wSecond; if (hours > 12) strcpy(m, "PM"); hours = hours%12; if (hours == 0) hours = 12; sprintf (str,"%i:%i%i:%i%i %s", hours, minutes/10, minutes%10, seconds/10, seconds%10, m); } else if (scr_clock.value == 3) { int hours, minutes, seconds; SYSTEMTIME systime; GetLocalTime(&systime); hours = systime.wHour; minutes = systime.wMinute; seconds = systime.wSecond; sprintf (str,"%i:%i%i:%i%i", hours%12, minutes/10, minutes%10, seconds/10, seconds%10); } #endif else return; //draw it GL_SetCanvas (CANVAS_BOTTOMRIGHT); Draw_String(320 - (strlen(str) << 3), 200 - 8, str); scr_tileclear_updates = 0; }
/* QMB //muff - hacked out of SourceForge implementation + modified ============== SCR_DrawFPS ============== */ void SCR_DrawFPS (void) { extern cvar_t show_fps; static double lastframetime; double t; extern int fps_count; static float lastfps; static int totalfps; static int lastsecond; int x, y; char st[60]; if (!show_fps.value) return; t = Sys_FloatTime (); lastfps= 1/(t - lastframetime); if (((int)(t)%100) > ((int)(lastframetime)%100)) { lastsecond = totalfps; totalfps = 0; } lastframetime = t; totalfps += 1; if (lastfps < 1 && lastfps > 0) sprintf(st, "%4.2f SPF", 1/(float)lastfps); else sprintf(st, "%4.2f FPS", lastfps); x = vid.width - strlen(st) * 8 - 16; y = 0; if (r_speeds.value) y += 360; Draw_String(x, y, st); sprintf(st, "%i Last second", lastsecond); x = vid.width - strlen(st) * 8 - 16; y = 8; if (r_speeds.value) y += 360; Draw_String(x, y, st); }
void Screen_DrawFPS(void) { static double oldtime = 0,fps = 0; static int oldframecount = 0; double time; char str[128]; int x,y,frames; time = realtime-oldtime; frames = Video.iFrameCount - oldframecount; if(time < 0 || frames < 0) { oldtime = realtime; oldframecount = Video.iFrameCount; return; } // Allow us to set our own update rate. if(time > scr_fps_rate.value) { fps = frames / time; oldtime = realtime; oldframecount = Video.iFrameCount; } if(scr_showfps.value) //draw it { // Set the highest and lowest counts we get. if(fps > dHighestFPS) dHighestFPS = fps; if((fps < dLowestFPS) && fps >= 1) dLowestFPS = fps; sprintf(str,"%4.0f FPS (%1.0f/%1.0f)", fps,dHighestFPS,dLowestFPS); x = 320-(strlen(str)<<3); if (scr_con_current && (cls.state != ca_connected)) y = 200 - 16; else y = 200 - 8; if (scr_clock.value) y -= 8; //make room for clock GL_SetCanvas(CANVAS_BOTTOMRIGHT); Draw_String(x, y, str); scr_tileclear_updates = 0; } }
void MS_Draw_Content_Text(struct menu_ct *content){ if (content->subtype == 1) { Draw_String(content->lx,content->ly,content->text); //Test_Draw(content->lx, content->ly, content->text); content->rx = content->lx + strlen(content->text)*8; } else if (content->subtype == 2) { if (content->text_function) { Draw_String(content->lx, content->ly, content->text_function()); //Test_Draw(content->lx, content->ly, content->text_function()); content->rx = content->lx + strlen(content->text_function()); } } content->ry = content->ly + content->pixel_height; }
inline void Clear_Screen(void) { // this function clears the screen // set color to white on black Set_Color(15,0); // clear the screen for (int index=0; index<=25; index++) Draw_String(0, SCROLL_POS,"\n"); } // end Clear_Screen
void SCR_DrawAutoID (void) { int i, x, y; if (!scr_autoid.value || cls.state != ca_connected || !cls.demoplayback) return; for (i = 0 ; i < autoid_count ; i++) { x = autoids[i].x * vid.width / glwidth; y = (glheight - autoids[i].y) * vid.height / glheight; Draw_String (x - strlen(autoids[i].player->name) * 4, y - 8, autoids[i].player->name); } }
void SCR_DrawDevStats (void) { Colour_t colour_dark = { 0, 0, 0, 0.5f }; char str[40]; int y = 25-9; //9=number of lines to print int x = 0; //margin if (!devstats.value) return; GL_SetCanvas (CANVAS_BOTTOMLEFT); Draw_Rectangle(x,y*8,152,72, colour_dark); //dark rectangle sprintf (str, "devstats |Curr Peak"); Draw_String(x, (y++) * 8 - x, str); sprintf (str, "---------+---------"); Draw_String(x, (y++) * 8 - x, str); sprintf (str, "Edicts |%4i %4i", dev_stats.edicts, dev_peakstats.edicts); Draw_String(x, (y++) * 8 - x, str); sprintf (str, "Packet |%4i %4i", dev_stats.packetsize, dev_peakstats.packetsize); Draw_String(x, (y++) * 8 - x, str); sprintf (str, "Visedicts|%4i %4i", dev_stats.visedicts, dev_peakstats.visedicts); Draw_String(x, (y++) * 8 - x, str); sprintf (str, "Efrags |%4i %4i", dev_stats.efrags, dev_peakstats.efrags); Draw_String(x, (y++) * 8 - x, str); sprintf (str, "Dlights |%4i %4i", dev_stats.dlights, dev_peakstats.dlights); Draw_String(x, (y++) * 8 - x, str); sprintf (str, "Beams |%4i %4i", dev_stats.beams, dev_peakstats.beams); Draw_String(x, (y++) * 8 - x, str); sprintf (str, "Tempents |%4i %4i", dev_stats.tempents, dev_peakstats.tempents); Draw_String(x, (y++) * 8 - x, str); }
void MS_Draw_Content_Button(struct menu_ct *content){ int py = 8; content->rx = content->lx + strlen(content->text) * 8; if ((content->color)) { Draw_ColoredString(content->lx,content->ly,va("&c%s%s",content->color,content->text),0); } else { Draw_String(content->lx,content->ly,content->text); } content->rx = content->lx + strlen(content->text)*8; content->ry = content->ly + py; }
void Scr_ShowNumP(void) { extern CVar show_fps; int x, y; char st[80]; extern int numParticles; if (!show_fps.getBool()) return; sprintf(st, "%i Particles in world", numParticles); x = vid.conwidth - strlen(st) * 8 - 16; y = 16; //vid.conheight - (sb_lines * (vid.conheight/240) )- 16; //Draw_TileClear(x, y, strlen(st)*16, 16); Draw_String(x, y, st); }
void CEditBox_Draw(CEditBox *e, int x, int y, qbool active) { while (e->pos > e->disp + e->width - 1) e->disp ++; if (e->disp > e->pos) e->disp = e->pos; if (e->disp > strlen(e->text) - e->width + 1) e->disp = strlen(e->text) - e->width + 1; // if (e->disp < 0) // e->disp = 0; snprintf(buf, sizeof (buf), "%-*.*s", e->width, e->width, active ? e->text+e->disp : e->text); Draw_String(x, y, buf); if (active) Draw_Character(x+8*(e->pos-e->disp), y, 10+((int)(cls.realtime*4)&1)); }
static void MS_Draw_Tooltip(int x, int y, char *string, float r, float g, float b,float alpha) { int len = strlen(string) * 8; // Make sure we're drawing within the screen. if (x + len > vid.width) { x -= len; } if (y + 9 > vid.height) { y -= 9; } Draw_AlphaRectangleRealRGB(x, y, len, 8, 1, 1, r, g, b,alpha); Draw_String(x, y, string); }
void Scr_ShowNumP (void) { extern cvar_t show_fps; int x, y; char st[80]; extern int numParticles; if (!show_fps.value) return; sprintf(st, "%i Particles in world", numParticles); x = vid.width - strlen(st) * 8 - 16; y = 16 ; //vid.height - (sb_lines * (vid.height/240) )- 16; //Draw_TileClear(x, y, strlen(st)*16, 16); if (r_speeds.value) y += 360; Draw_String(x, y, st); }
/* ============== SCR_DrawFPS -- johnfitz ============== */ void SCR_DrawFPS (void) { static double oldtime = 0; static double lastfps = 0; static int oldframecount = 0; double elapsed_time; int frames; elapsed_time = realtime - oldtime; frames = r_framecount - oldframecount; if (elapsed_time < 0 || frames < 0) { oldtime = realtime; oldframecount = r_framecount; return; } // update value every 3/4 second if (elapsed_time > 0.75) { lastfps = frames / elapsed_time; oldtime = realtime; oldframecount = r_framecount; } if (scr_showfps.value) { char st[16]; int x, y; sprintf (st, "%4.0f fps", lastfps); x = 320 - (strlen(st)<<3); y = 200 - 8; if (scr_clock.value) y -= 8; //make room for clock GL_SetCanvas (CANVAS_BOTTOMRIGHT); Draw_String (x, y, st); scr_tileclear_updates = 0; } }
/* ============== SCR_DrawClock -- johnfitz ============== */ void SCR_DrawClock (void) { char str[12]; if (scr_clock.value == 1) { int minutes, seconds; minutes = cl.time / 60; seconds = ((int)cl.time)%60; sprintf (str,"%i:%i%i", minutes, seconds/10, seconds%10); } else return; //draw it GL_SetCanvas (CANVAS_BOTTOMRIGHT); Draw_String (320 - (strlen(str)<<3), 200 - 8, str); scr_tileclear_updates = 0; }
/* ================== Sbar_MiniDeathmatchOverlay frags name frags team name displayed to right of status bar if there's room ================== */ void Sbar_MiniDeathmatchOverlay(void) { int i, k; int top, bottom; int x, y, f; char num[12]; player_info_t *s; int teamplay; char team[5]; int numlines; char name[16 + 1]; team_t *tm; if (vid.width < 512 || !sb_lines) return; // not enuff room teamplay = atoi(Info_ValueForKey(cl.serverinfo, "teamplay")); scr_copyeverything = 1; scr_fullupdate = 0; // scores Sbar_SortFrags(false); if (vid.width >= 640) Sbar_SortTeams(); if (!scoreboardlines) return; // no one there? // draw the text y = vid.height - sb_lines - 1; numlines = sb_lines / 8; if (numlines < 3) return; // not enough room // find us for (i = 0; i < scoreboardlines; i++) if (fragsort[i] == cl.playernum) break; if (i == scoreboardlines) // we're not there, we are probably a spectator, just display top i = 0; else // figure out start i = i - numlines / 2; if (i > scoreboardlines - numlines) i = scoreboardlines - numlines; if (i < 0) i = 0; x = 324; for ( /* */ ; i < scoreboardlines && y < vid.height - 8 + 1; i++) { k = fragsort[i]; s = &cl.players[k]; if (!s->name[0]) continue; // draw ping top = Sbar_ColorForMap(s->topcolor); bottom = Sbar_ColorForMap(s->bottomcolor); Draw_Fill(x, y + 1, 40, 3, top); Draw_Fill(x, y + 4, 40, 4, bottom); // draw number f = s->frags; sprintf(num, "%3i", f); Draw_Character(x + 8, y, num[0]); Draw_Character(x + 16, y, num[1]); Draw_Character(x + 24, y, num[2]); if (k == cl.playernum) { Draw_Character(x, y, 16); Draw_Character(x + 32, y, 17); } // team if (teamplay) { team[4] = 0; strncpy(team, Info_ValueForKey(s->userinfo, "team"), 4); Draw_String(x + 48, y, team); } // draw name name[16] = 0; strncpy(name, s->name, 16); if (teamplay) Draw_String(x + 48 + 40, y, name); else Draw_String(x + 48, y, name); y += 8; } // draw teams if room if (vid.width < 640 || !teamplay) return; // draw seperator x += 208; for (y = vid.height - sb_lines; y < vid.height - 6; y += 2) Draw_Character(x, y, 14); x += 16; y = vid.height - sb_lines; for (i = 0; i < scoreboardteams && y <= vid.height; i++) { k = teamsort[i]; tm = teams + k; // draw pings team[4] = 0; strncpy(team, tm->team, 4); Draw_String(x, y, team); // draw total sprintf(num, "%5i", tm->frags); Draw_String(x + 40, y, num); if (!strncmp(Info_ValueForKey(cl.players[cl.playernum].userinfo, "team"), tm->team, 16)) { Draw_Character(x - 8, y, 16); Draw_Character(x + 32, y, 17); } y += 8; } }
void MS_Mouse(void) { struct menu_s *mm = NULL; static double remaining_x; static double remaining_y; int type = 0; int lx,ly,rx,ry; int x,y; menu_mouse_x *= new_menu_sensitivity.value; menu_mouse_y *= new_menu_sensitivity.value; menu_mouse_x += remaining_x; menu_mouse_y += remaining_y; remaining_x = menu_mouse_x - floor(menu_mouse_x); remaining_y = menu_mouse_y - floor(menu_mouse_y); menu_mouse_x = floor(menu_mouse_x); menu_mouse_y = floor(menu_mouse_y); /* 1- moving 2- resize 3- minimize 4- close */ if (!menu_active) { lx = -1; ly = -1; rx = -1; ry = -1; type = -1; } else { type = 0; mm = menu_active; lx = mm->lx; ly = mm->ly; rx = mm->rx; ry = mm->ry; if (mm->minimized) { rx = strlen(mm->name)*8+22 +lx; ry = ly + 22; } } // we always draw the cursor Draw_String(mscx-4, mscy-4, "x"); if (popup_active) { if (mscx + menu_mouse_x > 0 && mscx + menu_mouse_x < vid.width) mscx += menu_mouse_x; if (mscy + menu_mouse_y > 0 && mscy + menu_mouse_y < vid.height) mscy += menu_mouse_y; return; } // check if we are in the activemenu if ( mscx >= lx && mscx <= rx && mscy >= ly && mscy <= ry) { } else { } if (mm == NULL) return; // check if we are in the moving area if (mscx >= lx && mscx <= rx - 18 && mscy >= ly && mscy <= ly + 10) { MS_Draw_Tooltip(mscx,mscy,va("%s moving",mm->name,lx,ly,rx,ry),0.5,0.5,0.5,0.9); type = 1; } // check if we are in the resize area if (mscx >= rx - 10 && mscx <= rx && mscy >= ry - 10 && mscy <= ry) { MS_Draw_Tooltip(mscx,mscy,va("%s resizing",mm->name),.5,0.5,0.5,0.9); type = 2; } // minimize if (mscx >= rx - 17 && mscx <= rx - 8 && mscy >= ly + 1 && mscy <= ly + 10) { MS_Draw_Tooltip(mscx,mscy,va("%s minimizing",mm->name),.5,0.5,0.5,0.9); type = 3; } // close if (mscx >= rx - 9 && mscx <= rx && mscy >= ly + 1 && mscy <= ly + 9) { MS_Draw_Tooltip(mscx,mscy,va("close %s",mm->name),.5,0.5,0.5,0.9); type = 4; } // scroll x if (mm->content_width > rx - lx - 10) if (mscx >= lx && mscx <= rx - 9 && mscy >= ry - 8 && mscy <= ry ) { MS_Draw_Tooltip(mscx,mscy,va("scroll %s", mm->name),.5,0.5,0.5,0.9); type = 5; } // scroll y if (mm->content_height > ry - ly - 22) if (mscx >= rx -9 && mscx <= rx && mscy >= ly - 8 && mscy <= ry - 9 ) { MS_Draw_Tooltip(mscx,mscy,va("scroll %s", mm->name),.5,0.5,0.5,0.9); type = 6; } if (keydown[K_MOUSE1] && type == 4) { menu_active = NULL; } if(!slider_active) { if (mscx + menu_mouse_x > 0 && mscx + menu_mouse_x < vid.width) mscx += menu_mouse_x; if (mscy + menu_mouse_y > 0 && mscy + menu_mouse_y < vid.height) mscy += menu_mouse_y; } if (keydown[K_MOUSE1] && !kdmb1) kdmb1 = 1; if (!keydown[K_MOUSE1] && kdmb1) { slider_active = 0; kdmb1 = 0; } if (!keydown[K_MOUSE1]) { resizing = 0; moving = 0; scrolling = 0; } if (keydown[K_MOUSE1]) { if (type == 1) moving = 1; if (type == 2) resizing = 1; if (type == 5 || type == 6) scrolling = 1; } if (type != -1) { if (mm->rx < strlen(mm->name)*8) mm->rx = strlen(mm->name)*8 + 40; if (mm->ry < mm->ly + 20) mm->ry = mm->ly + 20; } if (keydown[K_MOUSE1] && type != -1){ if (type == 1){ if (mm->rx + menu_mouse_x > vid.width || mm->ry + menu_mouse_y > vid.height || mm->lx + menu_mouse_x < 0 || mm->ly + menu_mouse_y < 0) return; moving = 1; mm->lx += menu_mouse_x; mm->rx += menu_mouse_x; mm->ly += menu_mouse_y; mm->ry += menu_mouse_y; mscx = mm->lx + 2; mscy = mm->ly + 2; } if (type == 2){ if (mm->rx + menu_mouse_x > vid.width || mm->ry + menu_mouse_y > vid.height || mm->ry +menu_mouse_y< mm->ly + 20 || mm->rx +menu_mouse_x <= mm->lx + strlen(mm->name)*8 + 22) return; mm->rx += menu_mouse_x; mm->ry += menu_mouse_y; resizing = 1; mscx = mm->rx - 5; mscy = mm->ry - 5; } if (type == 3) mm->minimized = !mm->minimized; if (type == 5) { mm->slider_offset_x += menu_mouse_x; if (mm->slider_offset_x < 0) mm->slider_offset_x = 0; if (mm->slider_offset_x > 100) mm->slider_offset_x = 100; x = mm->rx - mm->lx - 11; //100 x = x * (float)(x/(float)(mm->content_width)); y = mm->rx - mm->lx - 11; y = y - x; y = y * (float)(mm->slider_offset_x/100.0f); y = y + x/2; mscx = mm->lx + y; mscy = mm->ry - 5; } if (type == 6) { mm->slider_offset_y += menu_mouse_y; if (mm->slider_offset_y < 0) mm->slider_offset_y = 0; if (mm->slider_offset_y > 100) mm->slider_offset_y = 100; y = mm->ry - mm->ly - 22; y = y * (float)(y/(float)(mm->content_height)); x = mm->ry - mm->ly - 22; x = x -y; x = x * (float)(mm->slider_offset_y/100.0f); x = x + y/2; mscy = mm->ly + 11 + x; mscx = mm->rx - 5; } } }
/* ================== Sbar_DeathmatchOverlay ping time frags name ================== */ void Sbar_DeathmatchOverlay(int start) { const qpic_t *pic; int i, k, l; int top, bottom; int x, y, f; char num[12]; player_info_t *s; int total; int minutes; int p; int teamplay; char team[5]; int skip = 10; if (largegame) skip = 8; // request new ping times every two second if (realtime - cl.last_ping_request > 2) { cl.last_ping_request = realtime; MSG_WriteByte(&cls.netchan.message, clc_stringcmd); MSG_WriteString(&cls.netchan.message, "pings"); } teamplay = atoi(Info_ValueForKey(cl.serverinfo, "teamplay")); scr_copyeverything = 1; scr_fullupdate = 0; if (!start) { pic = Draw_CachePic("gfx/ranking.lmp"); Draw_Pic(160 - pic->width / 2, 0, pic); } // scores Sbar_SortFrags(true); // draw the text l = scoreboardlines; if (start) y = start; else y = 24; if (teamplay) { x = 4; // 0 40 64 104 152 192 Draw_String(x, y, "ping pl time frags team name"); y += 8; // Draw_String ( x , y, "---- -- ---- ----- ---- ----------------"); Draw_String(x, y, "\x1d\x1e\x1e\x1f \x1d\x1f \x1d\x1e\x1e\x1f \x1d\x1e\x1e\x1e\x1f \x1d\x1e\x1e\x1f \x1d\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1f"); y += 8; } else { x = 16; // 0 40 64 104 152 Draw_String(x, y, "ping pl time frags name"); y += 8; // Draw_String ( x , y, "---- -- ---- ----- ----------------"); Draw_String(x, y, "\x1d\x1e\x1e\x1f \x1d\x1f \x1d\x1e\x1e\x1f \x1d\x1e\x1e\x1e\x1f \x1d\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1f"); y += 8; } for (i = 0; i < l && y <= vid.height - 10; i++) { k = fragsort[i]; s = &cl.players[k]; if (!s->name[0]) continue; // draw ping p = s->ping; if (p < 0 || p > 999) p = 999; sprintf(num, "%4i", p); Draw_String(x, y, num); // draw pl p = s->pl; sprintf(num, "%3i", p); if (p > 25) Draw_Alt_String(x + 32, y, num); else Draw_String(x + 32, y, num); if (s->spectator) { Draw_String(x + 40, y, "(spectator)"); // draw name if (teamplay) Draw_String(x + 152 + 40, y, s->name); else Draw_String(x + 152, y, s->name); y += skip; continue; } // draw time if (cl.intermission) total = cl.completed_time - s->entertime; else total = realtime - s->entertime; minutes = (int)total / 60; sprintf(num, "%4i", minutes); Draw_String(x + 64, y, num); // draw background top = Sbar_ColorForMap(s->topcolor); bottom = Sbar_ColorForMap(s->bottomcolor); if (largegame) Draw_Fill(x + 104, y + 1, 40, 3, top); else Draw_Fill(x + 104, y, 40, 4, top); Draw_Fill(x + 104, y + 4, 40, 4, bottom); // draw number f = s->frags; sprintf(num, "%3i", f); Draw_Character(x + 112, y, num[0]); Draw_Character(x + 120, y, num[1]); Draw_Character(x + 128, y, num[2]); if (k == cl.playernum) { Draw_Character(x + 104, y, 16); Draw_Character(x + 136, y, 17); } // team if (teamplay) { team[4] = 0; strncpy(team, Info_ValueForKey(s->userinfo, "team"), 4); Draw_String(x + 152, y, team); } // draw name if (teamplay) Draw_String(x + 152 + 40, y, s->name); else Draw_String(x + 152, y, s->name); y += skip; } if (y >= vid.height - 10) // we ran over the screen size, squish largegame = true; }
/* ================== Sbar_TeamOverlay team frags added by Zoid ================== */ void Sbar_TeamOverlay(void) { const qpic_t *pic; int i, k; int x, y; char num[12]; int teamplay; char team[5]; team_t *tm; int plow, phigh, pavg; // request new ping times every two second teamplay = atoi(Info_ValueForKey(cl.serverinfo, "teamplay")); if (!teamplay) { Sbar_DeathmatchOverlay(0); return; } scr_copyeverything = 1; scr_fullupdate = 0; pic = Draw_CachePic("gfx/ranking.lmp"); Draw_Pic(160 - pic->width / 2, 0, pic); y = 24; x = 36; Draw_String(x, y, "low/avg/high team total players"); y += 8; // Draw_String(x, y, "------------ ---- ----- -------"); Draw_String(x, y, "\x1d\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1f \x1d\x1e\x1e\x1f \x1d\x1e\x1e\x1e\x1f \x1d\x1e\x1e\x1e\x1e\x1e\x1f"); y += 8; // sort the teams Sbar_SortTeams(); // draw the text for (i = 0; i < scoreboardteams && y <= vid.height - 10; i++) { k = teamsort[i]; tm = teams + k; // draw pings plow = tm->plow; if (plow < 0 || plow > 999) plow = 999; phigh = tm->phigh; if (phigh < 0 || phigh > 999) phigh = 999; if (!tm->players) pavg = 999; else pavg = tm->ptotal / tm->players; if (pavg < 0 || pavg > 999) pavg = 999; sprintf(num, "%3i/%3i/%3i", plow, pavg, phigh); Draw_String(x, y, num); // draw team team[4] = 0; strncpy(team, tm->team, 4); Draw_String(x + 104, y, team); // draw total sprintf(num, "%5i", tm->frags); Draw_String(x + 104 + 40, y, num); // draw players sprintf(num, "%5i", tm->players); Draw_String(x + 104 + 88, y, num); if (!strncmp(Info_ValueForKey(cl.players[cl.playernum].userinfo, "team"), tm->team, 16)) { Draw_Character(x + 104 - 8, y, 16); Draw_Character(x + 104 + 32, y, 17); } y += 8; } y += 8; Sbar_DeathmatchOverlay(y); }
static void Con_DrawTextLines(unsigned int y, unsigned int maxlinestodraw, unsigned int lastlinetodraw) { unsigned int i; unsigned int j; unsigned int nextline; unsigned int linelength; if (firstline == ((lastline + 1) % maxlines)) return; if (maxlinestodraw == 0) return; if (!con_parsecolors.value) Draw_BeginTextRendering(); y += maxlinestodraw * 8; j = lastlinetodraw; if (firstline > lastlinetodraw) j += maxlines; if (firstline + maxlinestodraw - 1 <= j) { i = j - maxlinestodraw + 1; } else { i = firstline; maxlinestodraw = j - firstline + 1; } i %= maxlines; y -= maxlinestodraw * 8; while(i != ((lastline + 1) % maxlines) && maxlinestodraw) { if (maxlinestodraw == 1 && i != lastline) { Draw_String(8, y, scrollupmarker); break; } nextline = (i + 1) % maxlines; linelength = Con_BufferStringLength(lines[i]); if (nextline != ((lastline + 1) % maxlines)) { if (lines[nextline] < lines[i]) j = consize - lines[i] + lines[nextline]; else j = lines[nextline] - lines[i]; if (j < linelength) linelength = j; } if (lines[i] + linelength > consize) { if (stitchbuffer) { if (con_parsecolors.value) Draw_ColoredString_Length(8, y, stitchbuffer, 0, linelength, linestartcolours[i]); else Draw_String_Length(8, y, stitchbuffer, linelength); } } else { if (con_parsecolors.value) Draw_ColoredString_Length(8, y, conbuf + lines[i], 0, linelength, linestartcolours[i]); else Draw_String_Length(8, y, conbuf + lines[i], linelength); } y += 8; i = nextline; maxlinestodraw--; } if (!con_parsecolors.value) Draw_EndTextRendering(); }
/* ================ Sbar_DrawString ================ */ static void Sbar_DrawString(int x, int y, const char *str) { Draw_String(x /*+ ((vid.width - 320)>>1) */ , y + vid.height - SBAR_HEIGHT, str); }