X-Git-Url: https://git.xonotic.org/?a=blobdiff_plain;f=cl_screen.c;h=702635a2a2d68cd7583d58979a57c52f68336bd3;hb=6dab44a4a2dc52692d90438b14aef70a9ed96930;hp=3c4ffd56e8fbb9ab6f78468ef0f9a24ad2cb0f6f;hpb=ac5533c5e5a5ad2e2edfae17c596faf29692aa06;p=xonotic%2Fdarkplaces.git diff --git a/cl_screen.c b/cl_screen.c index 3c4ffd56..702635a2 100644 --- a/cl_screen.c +++ b/cl_screen.c @@ -81,6 +81,8 @@ float scr_centertime_off; int scr_center_lines; int scr_erase_lines; int scr_erase_center; +char scr_infobarstring[MAX_INPUTLINE]; +float scr_infobartime_off; /* ============== @@ -90,7 +92,7 @@ Called for important messages that should stay in the center of the screen for a few moments ============== */ -void SCR_CenterPrint(char *str) +void SCR_CenterPrint(const char *str) { strlcpy (scr_centerstring, str, sizeof (scr_centerstring)); scr_centertime_off = scr_centertime.value; @@ -118,6 +120,9 @@ void SCR_DrawCenterString (void) if(sb_showscores) // make TAB hide the finale message (sb_showscores overrides finale in sbar.c) return; + if(scr_centertime.value <= 0 && !cl.intermission) + return; + // the finale prints the characters one at a time, except if printspeed is an absurdly high value if (cl.intermission && scr_printspeed.value > 0 && scr_printspeed.value < 1000000) remaining = (int)(scr_printspeed.value * (cl.time - scr_centertime_start)); @@ -334,7 +339,7 @@ void SCR_DrawTurtle (void) if (count < 3) return; - DrawQ_Pic (0, 0, Draw_CachePic("gfx/turtle", true), 0, 0, 1, 1, 1, 1, 0); + DrawQ_Pic (0, 0, Draw_CachePic ("gfx/turtle"), 0, 0, 1, 1, 1, 1, 0); } /* @@ -351,7 +356,7 @@ void SCR_DrawNet (void) if (cls.demoplayback) return; - DrawQ_Pic (64, 0, Draw_CachePic("gfx/net", true), 0, 0, 1, 1, 1, 1, 0); + DrawQ_Pic (64, 0, Draw_CachePic ("gfx/net"), 0, 0, 1, 1, 1, 1, 0); } /* @@ -372,7 +377,7 @@ void SCR_DrawPause (void) if (!cl.paused) return; - pic = Draw_CachePic ("gfx/pause", true); + pic = Draw_CachePic ("gfx/pause"); DrawQ_Pic ((vid_conwidth.integer - pic->width)/2, (vid_conheight.integer - pic->height)/2, pic, 0, 0, 1, 1, 1, 1, 0); } @@ -389,7 +394,7 @@ void SCR_DrawBrand (void) if (!scr_showbrand.value) return; - pic = Draw_CachePic ("gfx/brand", true); + pic = Draw_CachePic ("gfx/brand"); switch ((int)scr_showbrand.value) { @@ -439,7 +444,7 @@ SCR_DrawQWDownload */ static int SCR_DrawQWDownload(int offset) { - // sync with SCR_DownloadHeight + // sync with SCR_InfobarHeight int len; float x, y; float size = 8; @@ -463,12 +468,30 @@ static int SCR_DrawQWDownload(int offset) else dpsnprintf(temp, sizeof(temp), "Downloading %s %3i%% (%i/%i) at %i bytes/s\n", cls.qw_downloadname, cls.qw_downloadpercent, cls.qw_downloadmemorycursize, cls.qw_downloadmemorymaxsize, cls.qw_downloadspeedrate); len = (int)strlen(temp); - x = (vid_conwidth.integer - DrawQ_TextWidth_Font(temp, len, 0, FONT_INFOBAR) * size) / 2; + x = (vid_conwidth.integer - DrawQ_TextWidth_Font(temp, len, true, FONT_INFOBAR) * size) / 2; y = vid_conheight.integer - size - offset; DrawQ_Fill(0, y, vid_conwidth.integer, size, 0, 0, 0, cls.signon == SIGNONS ? 0.5 : 1, 0); DrawQ_String_Font(x, y, temp, len, size, size, 1, 1, 1, 1, 0, NULL, true, FONT_INFOBAR); return 8; } +/* +============== +SCR_DrawInfobarString +============== +*/ +static int SCR_DrawInfobarString(int offset) +{ + int len; + float x, y; + float size = 8; + + len = (int)strlen(scr_infobarstring); + x = (vid_conwidth.integer - DrawQ_TextWidth_Font(scr_infobarstring, len, false, FONT_INFOBAR) * size) / 2; + y = vid_conheight.integer - size - offset; + DrawQ_Fill(0, y, vid_conwidth.integer, size, 0, 0, 0, cls.signon == SIGNONS ? 0.5 : 1, 0); + DrawQ_String_Font(x, y, scr_infobarstring, len, size, size, 1, 1, 1, 1, 0, NULL, false, FONT_INFOBAR); + return 8; +} /* ============== @@ -477,7 +500,7 @@ SCR_DrawCurlDownload */ static int SCR_DrawCurlDownload(int offset) { - // sync with SCR_DownloadHeight + // sync with SCR_InfobarHeight int len; int nDownloads; int i; @@ -496,7 +519,7 @@ static int SCR_DrawCurlDownload(int offset) if(addinfo) { len = (int)strlen(addinfo); - x = (vid_conwidth.integer - DrawQ_TextWidth_Font(addinfo, len, false, FONT_INFOBAR) * size) / 2; + x = (vid_conwidth.integer - DrawQ_TextWidth_Font(addinfo, len, true, FONT_INFOBAR) * size) / 2; DrawQ_Fill(0, y - size, vid_conwidth.integer, size, 1, 1, 1, cls.signon == SIGNONS ? 0.8 : 1, 0); DrawQ_String_Font(x, y - size, addinfo, len, size, size, 0, 0, 0, 1, 0, NULL, true, FONT_INFOBAR); } @@ -510,7 +533,7 @@ static int SCR_DrawCurlDownload(int offset) else dpsnprintf(temp, sizeof(temp), "Downloading %s ... %5.1f%% @ %.1f KiB/s\n", downinfo[i].filename, 100.0 * downinfo[i].progress, downinfo[i].speed / 1024.0); len = (int)strlen(temp); - x = (vid_conwidth.integer - DrawQ_TextWidth_Font(temp, len, false, FONT_INFOBAR) * size) / 2; + x = (vid_conwidth.integer - DrawQ_TextWidth_Font(temp, len, true, FONT_INFOBAR) * size) / 2; DrawQ_Fill(0, y + i * size, vid_conwidth.integer, size, 0, 0, 0, cls.signon == SIGNONS ? 0.5 : 1, 0); DrawQ_String_Font(x, y + i * size, temp, len, size, size, 1, 1, 1, 1, 0, NULL, true, FONT_INFOBAR); } @@ -522,27 +545,34 @@ static int SCR_DrawCurlDownload(int offset) /* ============== -SCR_DrawDownload +SCR_DrawInfobar ============== */ -static void SCR_DrawDownload() +static void SCR_DrawInfobar() { int offset = 0; + if(scr_infobartime_off > 0) + offset += SCR_DrawInfobarString(offset); offset += SCR_DrawQWDownload(offset); offset += SCR_DrawCurlDownload(offset); if(offset != scr_con_margin_bottom) Con_DPrintf("broken console margin calculation: %d != %d\n", offset, scr_con_margin_bottom); } -static int SCR_DownloadHeight() +static int SCR_InfobarHeight() { int offset = 0; Curl_downloadinfo_t *downinfo; const char *addinfo; int nDownloads; + if (cl.time > cl.oldtime) + scr_infobartime_off -= cl.time - cl.oldtime; + if(scr_infobartime_off > 0) + offset += 8; + if(cls.qw_downloadname[0]) - offset += 0; + offset += 8; downinfo = Curl_GetDownloadInfo(&nDownloads, &addinfo); if(downinfo) @@ -554,6 +584,23 @@ static int SCR_DownloadHeight() return offset; } +/* +============== +SCR_InfoBar_f +============== +*/ +void SCR_InfoBar_f(void) +{ + if(Cmd_Argc() == 3) + { + scr_infobartime_off = atof(Cmd_Argv(1)); + strlcpy(scr_infobarstring, Cmd_Argv(2), sizeof(scr_infobarstring)); + } + else + { + Con_Printf("usage:\ninfobar expiretime \"string\"\n"); + } +} //============================================================================= /* @@ -600,7 +647,7 @@ SCR_DrawConsole */ void SCR_DrawConsole (void) { - scr_con_margin_bottom = SCR_DownloadHeight(); + scr_con_margin_bottom = SCR_InfobarHeight(); if (key_consoleactive & KEY_CONSOLEACTIVE_FORCED) { // full screen @@ -694,18 +741,23 @@ void R_TimeReport_EndFrame(void) // put the location name in the r_speeds display as it greatly helps // when creating loc files loc = CL_Locs_FindNearest(cl.movement_origin); - if (loc) - sprintf(string + strlen(string), "Location: %s\n", loc->name); - sprintf(string + strlen(string), "%3i renders org:'%+8.2f %+8.2f %+8.2f' dir:'%+2.3f %+2.3f %+2.3f'\n", r_refdef.stats.renders, r_refdef.view.origin[0], r_refdef.view.origin[1], r_refdef.view.origin[2], r_refdef.view.forward[0], r_refdef.view.forward[1], r_refdef.view.forward[2]); - sprintf(string + strlen(string), "%7i surfaces%7i triangles %5i entities (%7i surfaces%7i triangles)\n", r_refdef.stats.world_surfaces, r_refdef.stats.world_triangles, r_refdef.stats.entities, r_refdef.stats.entities_surfaces, r_refdef.stats.entities_triangles); - sprintf(string + strlen(string), "%5i leafs%5i portals%6i/%6i particles%6i/%6i decals %3i%% quality\n", r_refdef.stats.world_leafs, r_refdef.stats.world_portals, r_refdef.stats.particles, cl.num_particles, r_refdef.stats.decals, cl.num_decals, (int)(100 * r_refdef.view.quality)); - sprintf(string + strlen(string), "%7i lightmap updates (%7i pixels)\n", r_refdef.stats.lightmapupdates, r_refdef.stats.lightmapupdatepixels); - sprintf(string + strlen(string), "%4i lights%4i clears%4i scissored%7i light%7i shadow%7i dynamic\n", r_refdef.stats.lights, r_refdef.stats.lights_clears, r_refdef.stats.lights_scissored, r_refdef.stats.lights_lighttriangles, r_refdef.stats.lights_shadowtriangles, r_refdef.stats.lights_dynamicshadowtriangles); - if (r_refdef.stats.bloom) - sprintf(string + strlen(string), "rendered%6i meshes%8i triangles bloompixels%8i copied%8i drawn\n", r_refdef.stats.meshes, r_refdef.stats.meshes_elements / 3, r_refdef.stats.bloom_copypixels, r_refdef.stats.bloom_drawpixels); - else - sprintf(string + strlen(string), "rendered%6i meshes%8i triangles\n", r_refdef.stats.meshes, r_refdef.stats.meshes_elements / 3); - strlcat(string, r_speeds_timestring, sizeof(string)); + dpsnprintf(string, sizeof(string), +"%s%s\n" +"%3i renders org:'%+8.2f %+8.2f %+8.2f' dir:'%+2.3f %+2.3f %+2.3f'\n" +"%7i surfaces%7i triangles %5i entities (%7i surfaces%7i triangles)\n" +"%5i leafs%5i portals%6i/%6i particles%6i/%6i decals %3i%% quality\n" +"%7i lightmap updates (%7i pixels)\n" +"%4i lights%4i clears%4i scissored%7i light%7i shadow%7i dynamic\n" +"rendered%6i meshes%8i triangles bloompixels%8i copied%8i drawn\n" +"%s" +, loc ? "Location: " : "", loc ? loc->name : "" +, r_refdef.stats.renders, r_refdef.view.origin[0], r_refdef.view.origin[1], r_refdef.view.origin[2], r_refdef.view.forward[0], r_refdef.view.forward[1], r_refdef.view.forward[2] +, r_refdef.stats.world_surfaces, r_refdef.stats.world_triangles, r_refdef.stats.entities, r_refdef.stats.entities_surfaces, r_refdef.stats.entities_triangles +, r_refdef.stats.world_leafs, r_refdef.stats.world_portals, r_refdef.stats.particles, cl.num_particles, r_refdef.stats.decals, cl.num_decals, (int)(100 * r_refdef.view.quality) +, r_refdef.stats.lightmapupdates, r_refdef.stats.lightmapupdatepixels +, r_refdef.stats.lights, r_refdef.stats.lights_clears, r_refdef.stats.lights_scissored, r_refdef.stats.lights_lighttriangles, r_refdef.stats.lights_shadowtriangles, r_refdef.stats.lights_dynamicshadowtriangles +, r_refdef.stats.meshes, r_refdef.stats.meshes_elements / 3, r_refdef.stats.bloom_copypixels, r_refdef.stats.bloom_drawpixels +, r_speeds_timestring); memset(&r_refdef.stats, 0, sizeof(r_refdef.stats)); @@ -821,6 +873,7 @@ void CL_Screen_Init(void) Cmd_AddCommand ("sizedown",SCR_SizeDown_f, "decrease view size (decreases viewsize cvar)"); Cmd_AddCommand ("screenshot",SCR_ScreenShot_f, "takes a screenshot of the next rendered frame"); Cmd_AddCommand ("envmap", R_Envmap_f, "render a cubemap (skybox) of the current scene"); + Cmd_AddCommand ("infobar", SCR_InfoBar_f, "display a text in the infobar (usage: infobar expiretime string)"); scr_initialized = true; } @@ -841,11 +894,11 @@ void SCR_ScreenShot_f (void) unsigned char *buffer3; qboolean jpeg = (scr_screenshot_jpeg.integer != 0); - sprintf (base, "screenshots/%s", scr_screenshot_name.string); + dpsnprintf (base, sizeof(base), "screenshots/%s", scr_screenshot_name.string); if (strcmp (oldname, scr_screenshot_name.string)) { - sprintf(oldname, "%s", scr_screenshot_name.string); + dpsnprintf(oldname, sizeof(oldname), "%s", scr_screenshot_name.string); shotnumber = 0; } @@ -859,7 +912,7 @@ void SCR_ScreenShot_f (void) return; } - sprintf(filename, "%s%06d.%s", base, shotnumber, jpeg ? "jpg" : "tga"); + dpsnprintf(filename, sizeof(filename), "%s%06d.%s", base, shotnumber, jpeg ? "jpg" : "tga"); buffer1 = (unsigned char *)Mem_Alloc(tempmempool, vid.width * vid.height * 3); buffer2 = (unsigned char *)Mem_Alloc(tempmempool, vid.width * vid.height * 3); @@ -1217,7 +1270,7 @@ Cr = R * .500 + G * -.419 + B * -.0813 + 128.; //else { cls.capturevideo.format = CAPTUREVIDEOFORMAT_AVI_I420; - cls.capturevideo.videofile = FS_Open (va("%s.avi", cls.capturevideo.basename), "wb", false, true); + cls.capturevideo.videofile = FS_OpenRealFile(va("%s.avi", cls.capturevideo.basename), "wb", false); SCR_CaptureVideo_RIFF_Start(); // enclosing RIFF chunk (there can be multiple of these in >1GB files, the later ones are "AVIX" instead of "AVI " and have no header/stream info) SCR_CaptureVideo_RIFF_Push("RIFF", "AVI "); @@ -1719,6 +1772,7 @@ static void R_Envmap_f (void) r_refdef.view.height = size; r_refdef.view.depth = 1; r_refdef.view.useperspective = true; + r_refdef.view.isoverlay = false; r_refdef.view.frustum_x = tan(90 * M_PI / 360.0); r_refdef.view.frustum_y = tan(90 * M_PI / 360.0); @@ -1729,7 +1783,7 @@ static void R_Envmap_f (void) for (j = 0;j < 12;j++) { - sprintf(filename, "env/%s%s.tga", basename, envmapinfo[j].name); + dpsnprintf(filename, sizeof(filename), "env/%s%s.tga", basename, envmapinfo[j].name); Matrix4x4_CreateFromQuakeEntity(&r_refdef.view.matrix, r_refdef.view.origin[0], r_refdef.view.origin[1], r_refdef.view.origin[2], envmapinfo[j].angles[0], envmapinfo[j].angles[1], envmapinfo[j].angles[2], 1); r_refdef.view.quality = 1; r_refdef.view.clear = true; @@ -1808,7 +1862,7 @@ void SHOWLMP_drawall(void) int i; for (i = 0;i < cl.num_showlmps;i++) if (cl.showlmps[i].isactive) - DrawQ_Pic(cl.showlmps[i].x, cl.showlmps[i].y, Draw_CachePic(cl.showlmps[i].pic, true), 0, 0, 1, 1, 1, 1, 0); + DrawQ_Pic(cl.showlmps[i].x, cl.showlmps[i].y, Draw_CachePic (cl.showlmps[i].pic), 0, 0, 1, 1, 1, 1, 0); } /* @@ -2009,7 +2063,7 @@ void SCR_DrawScreen (void) SCR_DrawBrand(); - SCR_DrawDownload(); + SCR_DrawInfobar(); if (r_timereport_active) R_TimeReport("2d"); @@ -2033,6 +2087,9 @@ void SCR_UpdateLoadingScreen (qboolean clear) // don't do anything if not initialized yet if (vid_hidden || !scr_refresh.integer) return; + // release mouse grab while loading + if (!vid.fullscreen) + VID_SetMouse(false, false, false); CHECKGLERROR qglViewport(0, 0, vid.width, vid.height);CHECKGLERROR //qglDisable(GL_SCISSOR_TEST);CHECKGLERROR @@ -2051,7 +2108,7 @@ void SCR_UpdateLoadingScreen (qboolean clear) R_Mesh_Start(); R_Mesh_Matrix(&identitymatrix); // draw the loading plaque - pic = Draw_CachePic("gfx/loading", true); + pic = Draw_CachePic ("gfx/loading"); x = (vid_conwidth.integer - pic->width)/2; y = (vid_conheight.integer - pic->height)/2; GL_Color(1,1,1,1); @@ -2064,6 +2121,7 @@ void SCR_UpdateLoadingScreen (qboolean clear) R_Mesh_ResetTextureState(); R_Mesh_TexBind(0, R_GetTexture(pic->tex)); R_Mesh_TexCoordPointer(0, 2, texcoord2f, 0, 0); + R_SetupGenericShader(true); vertex3f[2] = vertex3f[5] = vertex3f[8] = vertex3f[11] = 0; vertex3f[0] = vertex3f[9] = x; vertex3f[1] = vertex3f[4] = y; @@ -2076,19 +2134,19 @@ void SCR_UpdateLoadingScreen (qboolean clear) if (vid.stereobuffer) { qglDrawBuffer(GL_FRONT_LEFT); - R_Mesh_Draw(0, 4, 2, polygonelements, 0, 0); + R_Mesh_Draw(0, 4, 0, 2, NULL, polygonelements, 0, 0); qglDrawBuffer(GL_FRONT_RIGHT); - R_Mesh_Draw(0, 4, 2, polygonelements, 0, 0); + R_Mesh_Draw(0, 4, 0, 2, NULL, polygonelements, 0, 0); } else { qglDrawBuffer(GL_FRONT); - R_Mesh_Draw(0, 4, 2, polygonelements, 0, 0); + R_Mesh_Draw(0, 4, 0, 2, NULL, polygonelements, 0, 0); } R_Mesh_Finish(); // refresh // not necessary when rendering to GL_FRONT buffers - //VID_Finish(false); + //VID_Finish(); // however this IS necessary on Windows Vista qglFinish(); } @@ -2097,6 +2155,7 @@ extern cvar_t cl_minfps; extern cvar_t cl_minfps_fade; extern cvar_t cl_minfps_qualitymax; extern cvar_t cl_minfps_qualitymin; +extern cvar_t cl_minfps_qualitypower; extern cvar_t cl_minfps_qualityscale; static double cl_updatescreen_rendertime = 0; static double cl_updatescreen_quality = 1; @@ -2105,12 +2164,25 @@ void CL_UpdateScreen(void) double rendertime1; float conwidth, conheight; - if (vid_hidden || !scr_refresh.integer) - return; - if (!scr_initialized || !con_initialized) return; // not initialized yet + if(gamemode == GAME_NEXUIZ) + { + // play a bit with the palette (experimental) + palette_rgb_pantscolormap[15][0] = 128 + 127 * sin(cl.time / exp(1) + 0*M_PI/3); + palette_rgb_pantscolormap[15][1] = 128 + 127 * sin(cl.time / exp(1) + 2*M_PI/3); + palette_rgb_pantscolormap[15][2] = 128 + 127 * sin(cl.time / exp(1) + 4*M_PI/3); + palette_rgb_shirtcolormap[15][0] = 128 + 127 * sin(cl.time / M_PI + 5*M_PI/3); + palette_rgb_shirtcolormap[15][1] = 128 + 127 * sin(cl.time / M_PI + 3*M_PI/3); + palette_rgb_shirtcolormap[15][2] = 128 + 127 * sin(cl.time / M_PI + 1*M_PI/3); + memcpy(palette_rgb_pantsscoreboard[15], palette_rgb_pantscolormap[15], sizeof(*palette_rgb_pantscolormap)); + memcpy(palette_rgb_shirtscoreboard[15], palette_rgb_shirtcolormap[15], sizeof(*palette_rgb_shirtcolormap)); + } + + if (vid_hidden || !scr_refresh.integer) + return; + rendertime1 = Sys_DoubleTime(); conwidth = bound(320, vid_conwidth.value, 2048); @@ -2170,7 +2242,8 @@ void CL_UpdateScreen(void) qglClearColor(0,0,0,0);CHECKGLERROR R_ClearScreen(false); r_refdef.view.clear = false; - r_refdef.view.quality = bound(cl_minfps_qualitymin.value, cl_updatescreen_quality * cl_minfps_qualityscale.value, cl_minfps_qualitymax.value); + r_refdef.view.isoverlay = false; + r_refdef.view.quality = bound(cl_minfps_qualitymin.value, pow(cl_updatescreen_quality, cl_minfps_qualitypower.value) * cl_minfps_qualityscale.value, cl_minfps_qualitymax.value); if(scr_stipple.integer) { @@ -2249,7 +2322,18 @@ void CL_UpdateScreen(void) else cl_updatescreen_quality = 1; - VID_Finish(true); + if (!vid_activewindow) + VID_SetMouse(false, false, false); + else if (key_consoleactive) + VID_SetMouse(vid.fullscreen, false, false); + else if (key_dest == key_menu_grabbed) + VID_SetMouse(true, vid_mouse.integer && !in_client_mouse, true); + else if (key_dest == key_menu) + VID_SetMouse(vid.fullscreen, vid_mouse.integer && !in_client_mouse, true); + else + VID_SetMouse(vid.fullscreen, vid_mouse.integer && !cls.demoplayback && !cl.csqc_wantsmousemove, true); + + VID_Finish(); } void CL_Screen_NewMap(void)