2001-05-23 06:33:23 +00:00
|
|
|
/*
|
|
|
|
cl_screen.c
|
|
|
|
|
|
|
|
master for refresh, status bar, console, chat, notify, etc
|
|
|
|
|
|
|
|
Copyright (C) 1996-1997 Id Software, Inc.
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
|
|
|
See the GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to:
|
|
|
|
|
|
|
|
Free Software Foundation, Inc.
|
|
|
|
59 Temple Place - Suite 330
|
|
|
|
Boston, MA 02111-1307, USA
|
|
|
|
|
|
|
|
*/
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
2003-01-15 15:31:36 +00:00
|
|
|
|
2001-05-23 06:33:23 +00:00
|
|
|
#ifdef HAVE_STRING_H
|
|
|
|
# include <string.h>
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_STRINGS_H
|
|
|
|
# include <strings.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <time.h>
|
|
|
|
|
|
|
|
#include "QF/console.h"
|
2001-05-31 03:41:35 +00:00
|
|
|
#include "QF/cvar.h"
|
2001-05-23 06:33:23 +00:00
|
|
|
#include "QF/draw.h"
|
2003-09-04 18:59:39 +00:00
|
|
|
#include "QF/image.h"
|
2001-05-23 06:33:23 +00:00
|
|
|
#include "QF/pcx.h"
|
|
|
|
#include "QF/screen.h"
|
|
|
|
|
2022-09-21 08:31:18 +00:00
|
|
|
#include "QF/plugin/console.h"
|
2022-11-01 12:00:40 +00:00
|
|
|
#include "QF/plugin/vid_render.h"
|
2022-09-21 08:31:18 +00:00
|
|
|
|
2022-05-05 05:41:46 +00:00
|
|
|
#include "QF/scene/scene.h"
|
2022-02-28 07:59:38 +00:00
|
|
|
#include "QF/scene/transform.h"
|
2021-07-10 09:04:34 +00:00
|
|
|
#include "QF/ui/view.h"
|
|
|
|
|
2001-05-23 06:33:23 +00:00
|
|
|
#include "sbar.h"
|
|
|
|
|
2022-09-21 08:31:18 +00:00
|
|
|
#include "r_local.h" //FIXME for r_cache_thrash
|
|
|
|
|
2022-02-28 03:12:51 +00:00
|
|
|
#include "client/hud.h"
|
2022-03-04 16:48:10 +00:00
|
|
|
#include "client/world.h"
|
2021-03-12 02:48:53 +00:00
|
|
|
|
2020-06-21 14:15:17 +00:00
|
|
|
#include "qw/include/client.h"
|
2021-07-10 09:04:34 +00:00
|
|
|
#include "qw/include/cl_parse.h"
|
2020-06-21 14:15:17 +00:00
|
|
|
|
2022-09-21 08:31:18 +00:00
|
|
|
int scr_showpause;
|
|
|
|
static cvar_t scr_showpause_cvar = {
|
|
|
|
.name = "showpause",
|
|
|
|
.description =
|
|
|
|
"Toggles display of pause graphic",
|
|
|
|
.default_value = "1",
|
|
|
|
.flags = CVAR_NONE,
|
|
|
|
.value = { .type = &cexpr_int, .value = &scr_showpause },
|
|
|
|
};
|
|
|
|
int scr_showram;
|
|
|
|
static cvar_t scr_showram_cvar = {
|
|
|
|
.name = "showram",
|
|
|
|
.description =
|
|
|
|
"Show RAM icon if game is running low on memory",
|
|
|
|
.default_value = "1",
|
|
|
|
.flags = CVAR_NONE,
|
|
|
|
.value = { .type = &cexpr_int, .value = &scr_showram },
|
|
|
|
};
|
|
|
|
int scr_showturtle;
|
|
|
|
static cvar_t scr_showturtle_cvar = {
|
|
|
|
.name = "showturtle",
|
|
|
|
.description =
|
|
|
|
"Show a turtle icon if your fps is below 10",
|
|
|
|
.default_value = "0",
|
|
|
|
.flags = CVAR_NONE,
|
|
|
|
.value = { .type = &cexpr_int, .value = &scr_showturtle },
|
|
|
|
};
|
|
|
|
|
2022-10-31 15:40:52 +00:00
|
|
|
view_t cl_screen_view;
|
|
|
|
static view_t net_view;
|
|
|
|
static view_t timegraph_view;
|
|
|
|
static view_t zgraph_view;
|
|
|
|
static view_t loading_view;
|
|
|
|
static view_t ram_view;
|
|
|
|
static view_t turtle_view;
|
|
|
|
static view_t pause_view;
|
2001-05-23 06:33:23 +00:00
|
|
|
|
2012-01-28 11:45:14 +00:00
|
|
|
static void
|
|
|
|
SCR_CShift (void)
|
|
|
|
{
|
|
|
|
mleaf_t *leaf;
|
|
|
|
int contents = CONTENTS_EMPTY;
|
|
|
|
|
2022-05-05 05:41:46 +00:00
|
|
|
if (cls.state == ca_active && cl_world.scene->worldmodel) {
|
2022-02-28 07:59:38 +00:00
|
|
|
vec4f_t origin;
|
|
|
|
origin = Transform_GetWorldPosition (cl.viewstate.camera_transform);
|
2022-05-22 02:18:32 +00:00
|
|
|
leaf = Mod_PointInLeaf (origin, cl_world.scene->worldmodel);
|
2012-01-28 11:45:14 +00:00
|
|
|
contents = leaf->contents;
|
|
|
|
}
|
2022-02-25 06:48:57 +00:00
|
|
|
V_SetContentsColor (&cl.viewstate, contents);
|
2022-02-28 07:55:12 +00:00
|
|
|
r_funcs->Draw_BlendScreen (cl.viewstate.cshift_color);
|
2012-01-28 11:45:14 +00:00
|
|
|
}
|
|
|
|
|
2022-09-21 08:31:18 +00:00
|
|
|
static void
|
2022-10-31 15:40:52 +00:00
|
|
|
scr_draw_views (void)
|
2022-09-21 08:31:18 +00:00
|
|
|
{
|
2022-10-31 15:40:52 +00:00
|
|
|
if (scr_showturtle) {
|
|
|
|
static int count;
|
|
|
|
if (r_data->frametime < 0.1) {
|
|
|
|
count = 0;
|
|
|
|
} else {
|
|
|
|
count++;
|
|
|
|
}
|
|
|
|
View_SetVisible (turtle_view, count > 2);
|
2022-09-21 08:31:18 +00:00
|
|
|
}
|
|
|
|
|
2022-10-31 15:40:52 +00:00
|
|
|
// turn off for screenshots
|
|
|
|
View_SetVisible (pause_view, scr_showpause && r_data->paused);
|
2022-09-21 08:31:18 +00:00
|
|
|
|
2022-10-31 15:40:52 +00:00
|
|
|
View_SetVisible (ram_view, scr_showram && r_cache_thrash);
|
2022-11-01 12:00:40 +00:00
|
|
|
View_SetVisible (net_view, (!cls.demoplayback
|
|
|
|
&& realtime - cl.last_servermessage >= 0.3));
|
2022-10-31 15:40:52 +00:00
|
|
|
View_SetVisible (loading_view, cl.loading);
|
2022-11-01 12:00:40 +00:00
|
|
|
// FIXME cvar callbacks
|
|
|
|
View_SetVisible (timegraph_view, r_timegraph);
|
|
|
|
View_SetVisible (zgraph_view, r_zgraph);
|
2021-07-10 09:04:34 +00:00
|
|
|
}
|
|
|
|
|
2004-03-01 23:47:39 +00:00
|
|
|
static SCR_Func scr_funcs_normal[] = {
|
2012-02-14 10:47:02 +00:00
|
|
|
0, //Draw_Crosshair,
|
2001-05-23 06:33:23 +00:00
|
|
|
Sbar_Draw,
|
2022-10-31 15:40:52 +00:00
|
|
|
HUD_Draw_Views,
|
2013-01-08 11:37:36 +00:00
|
|
|
SCR_CShift,
|
|
|
|
Sbar_DrawCenterPrint,
|
2022-10-31 15:40:52 +00:00
|
|
|
scr_draw_views,
|
2003-07-25 22:21:47 +00:00
|
|
|
Con_DrawConsole,
|
2001-05-23 06:33:23 +00:00
|
|
|
0
|
|
|
|
};
|
|
|
|
|
2004-03-01 23:47:39 +00:00
|
|
|
static SCR_Func scr_funcs_intermission[] = {
|
|
|
|
Sbar_IntermissionOverlay,
|
2004-03-02 00:02:09 +00:00
|
|
|
Con_DrawConsole,
|
2021-07-10 09:04:34 +00:00
|
|
|
scr_draw_views,
|
2004-03-01 23:47:39 +00:00
|
|
|
0
|
|
|
|
};
|
|
|
|
|
|
|
|
static SCR_Func scr_funcs_finale[] = {
|
|
|
|
Sbar_FinaleOverlay,
|
2004-03-02 00:02:09 +00:00
|
|
|
Con_DrawConsole,
|
2021-07-10 09:04:34 +00:00
|
|
|
scr_draw_views,
|
2004-03-01 23:47:39 +00:00
|
|
|
0,
|
|
|
|
};
|
|
|
|
|
2004-03-02 00:02:09 +00:00
|
|
|
static SCR_Func *scr_funcs[] = {
|
|
|
|
scr_funcs_normal,
|
|
|
|
scr_funcs_intermission,
|
|
|
|
scr_funcs_finale,
|
|
|
|
};
|
|
|
|
|
2022-10-31 15:40:52 +00:00
|
|
|
static void
|
|
|
|
cl_vidsize_listener (void *data, const viddef_t *vdef)
|
|
|
|
{
|
|
|
|
View_SetLen (cl_screen_view, vdef->width, vdef->height);
|
|
|
|
View_UpdateHierarchy (cl_screen_view);
|
|
|
|
}
|
|
|
|
|
2022-09-21 08:31:18 +00:00
|
|
|
void
|
|
|
|
CL_Init_Screen (void)
|
|
|
|
{
|
|
|
|
qpic_t *pic;
|
|
|
|
|
2022-10-31 15:40:52 +00:00
|
|
|
VID_OnVidResize_AddListener (cl_vidsize_listener, 0);
|
2022-09-21 08:31:18 +00:00
|
|
|
|
2022-10-31 15:40:52 +00:00
|
|
|
HUD_Init ();
|
|
|
|
|
|
|
|
cl_screen_view = View_New (hud_registry, nullview);
|
|
|
|
con_module->data->console->screen_view = &cl_screen_view;
|
|
|
|
|
|
|
|
View_SetPos (cl_screen_view, 0, 0);
|
|
|
|
View_SetLen (cl_screen_view, viddef.width, viddef.height);
|
|
|
|
View_SetGravity (cl_screen_view, grav_northwest);
|
|
|
|
View_SetVisible (cl_screen_view, 1);
|
|
|
|
|
|
|
|
pic = r_funcs->Draw_PicFromWad ("ram");
|
|
|
|
ram_view = View_New (hud_registry, cl_screen_view);
|
|
|
|
View_SetPos (ram_view, 32, 0);
|
|
|
|
View_SetLen (ram_view, pic->width, pic->height);
|
|
|
|
View_SetGravity (ram_view, grav_northwest);
|
|
|
|
Ent_SetComponent (ram_view.id, hud_pic, ram_view.reg, &pic);
|
|
|
|
View_SetVisible (ram_view, 0);
|
|
|
|
|
|
|
|
pic = r_funcs->Draw_PicFromWad ("turtle");
|
|
|
|
turtle_view = View_New (hud_registry, cl_screen_view);
|
|
|
|
View_SetPos (turtle_view, 32, 0);
|
|
|
|
View_SetLen (turtle_view, pic->width, pic->height);
|
|
|
|
View_SetGravity (turtle_view, grav_northwest);
|
|
|
|
Ent_SetComponent (turtle_view.id, hud_pic, turtle_view.reg, &pic);
|
|
|
|
View_SetVisible (turtle_view, 0);
|
2022-09-21 08:31:18 +00:00
|
|
|
|
|
|
|
Cvar_Register (&scr_showpause_cvar, 0, 0);
|
|
|
|
Cvar_Register (&scr_showram_cvar, 0, 0);
|
|
|
|
Cvar_Register (&scr_showturtle_cvar, 0, 0);
|
|
|
|
|
|
|
|
pic = r_funcs->Draw_PicFromWad ("net");
|
2022-10-31 15:40:52 +00:00
|
|
|
net_view = View_New (hud_registry, cl_screen_view);
|
|
|
|
View_SetPos (net_view, 64, 0);
|
|
|
|
View_SetLen (net_view, pic->width, pic->height);
|
|
|
|
View_SetGravity (net_view, grav_northwest);
|
|
|
|
Ent_SetComponent (net_view.id, hud_pic, net_view.reg, &pic);
|
|
|
|
View_SetVisible (net_view, 0);
|
|
|
|
|
|
|
|
timegraph_view = View_New (hud_registry, cl_screen_view);
|
|
|
|
View_SetPos (timegraph_view, 0, 0);
|
|
|
|
View_SetLen (timegraph_view, r_data->vid->width, 100);
|
|
|
|
View_SetGravity (timegraph_view, grav_southwest);
|
|
|
|
Ent_SetComponent (timegraph_view.id, hud_func, timegraph_view.reg,
|
|
|
|
R_TimeGraph);
|
|
|
|
View_SetVisible (timegraph_view, r_timegraph);
|
|
|
|
|
|
|
|
zgraph_view = View_New (hud_registry, cl_screen_view);
|
|
|
|
View_SetPos (zgraph_view, 0, 0);
|
|
|
|
View_SetLen (zgraph_view, r_data->vid->width, 100);
|
|
|
|
View_SetGravity (zgraph_view, grav_southwest);
|
|
|
|
Ent_SetComponent (zgraph_view.id, hud_func, zgraph_view.reg, R_ZGraph);
|
|
|
|
View_SetVisible (zgraph_view, r_zgraph);
|
2022-09-21 08:31:18 +00:00
|
|
|
|
|
|
|
const char *name = "gfx/loading.lmp";
|
|
|
|
pic = r_funcs->Draw_CachePic (name, 1);
|
2022-10-31 15:40:52 +00:00
|
|
|
loading_view = View_New (hud_registry, cl_screen_view);
|
|
|
|
View_SetPos (loading_view, 0, -24);
|
|
|
|
View_SetLen (loading_view, pic->width, pic->height);
|
|
|
|
View_SetGravity (loading_view, grav_center);
|
|
|
|
Ent_SetComponent (loading_view.id, hud_cachepic, loading_view.reg, &name);
|
|
|
|
View_SetVisible (loading_view, 0);
|
|
|
|
|
|
|
|
name = "gfx/pause.lmp";
|
|
|
|
pic = r_funcs->Draw_CachePic (name, 1);
|
|
|
|
pause_view = View_New (hud_registry, cl_screen_view);
|
|
|
|
View_SetPos (pause_view, 0, -24);
|
|
|
|
View_SetLen (pause_view, pic->width, pic->height);
|
|
|
|
View_SetGravity (pause_view, grav_center);
|
|
|
|
Ent_SetComponent (pause_view.id, hud_cachepic, pause_view.reg, &name);
|
|
|
|
View_SetVisible (pause_view, 0);
|
2022-09-21 08:31:18 +00:00
|
|
|
}
|
|
|
|
|
2001-05-23 06:33:23 +00:00
|
|
|
void
|
|
|
|
CL_UpdateScreen (double realtime)
|
|
|
|
{
|
2004-03-02 00:02:09 +00:00
|
|
|
unsigned index = cl.intermission;
|
|
|
|
|
2004-05-08 23:27:05 +00:00
|
|
|
if (index >= sizeof (scr_funcs) / sizeof (scr_funcs[0]))
|
2004-03-02 00:02:09 +00:00
|
|
|
index = 0;
|
2004-03-01 23:47:39 +00:00
|
|
|
|
2012-06-03 00:30:31 +00:00
|
|
|
//FIXME not every time
|
2012-02-23 12:17:32 +00:00
|
|
|
if (cls.state == ca_active) {
|
2002-04-25 14:34:15 +00:00
|
|
|
if (cl.watervis)
|
2012-02-14 08:28:09 +00:00
|
|
|
r_data->min_wateralpha = 0.0;
|
2002-04-25 14:34:15 +00:00
|
|
|
else
|
2012-02-14 08:28:09 +00:00
|
|
|
r_data->min_wateralpha = 1.0;
|
2002-04-25 14:34:15 +00:00
|
|
|
}
|
2012-02-14 10:47:02 +00:00
|
|
|
scr_funcs_normal[0] = r_funcs->Draw_Crosshair;
|
2002-04-25 14:34:15 +00:00
|
|
|
|
2022-02-25 06:48:57 +00:00
|
|
|
cl.viewstate.intermission = cl.intermission != 0;
|
|
|
|
V_PrepBlend (&cl.viewstate);
|
|
|
|
V_RenderView (&cl.viewstate);
|
2022-02-28 07:59:38 +00:00
|
|
|
SCR_UpdateScreen (cl.viewstate.camera_transform,
|
|
|
|
realtime, scr_funcs[index]);
|
2001-05-23 06:33:23 +00:00
|
|
|
}
|