1 /*
2 cl_screen.c
3
4 master for refresh, status bar, console, chat, notify, etc
5
6 Copyright (C) 1996-1997 Id Software, Inc.
7
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License
10 as published by the Free Software Foundation; either version 2
11 of the License, or (at your option) any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16
17 See the GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to:
21
22 Free Software Foundation, Inc.
23 59 Temple Place - Suite 330
24 Boston, MA 02111-1307, USA
25
26 */
27 #ifdef HAVE_CONFIG_H
28 # include "config.h"
29 #endif
30
31 #ifdef HAVE_STRING_H
32 # include <string.h>
33 #endif
34 #ifdef HAVE_STRINGS_H
35 # include <strings.h>
36 #endif
37
38 #include <time.h>
39
40 #include "QF/console.h"
41 #include "QF/cvar.h"
42 #include "QF/draw.h"
43 #include "QF/image.h"
44 #include "QF/pcx.h"
45 #include "QF/screen.h"
46
47 #include "client.h"
48 #include "clview.h"
49 #include "sbar.h"
50
51 static qpic_t *scr_net;
52
53 static void
SCR_DrawNet(void)54 SCR_DrawNet (void)
55 {
56 if (cls.netchan.outgoing_sequence - cls.netchan.incoming_acknowledged <
57 UPDATE_BACKUP - 1)
58 return;
59 if (cls.demoplayback)
60 return;
61
62 if (!scr_net)
63 scr_net = r_funcs->Draw_PicFromWad ("net");
64
65 r_funcs->Draw_Pic (r_data->scr_vrect->x + 64, r_data->scr_vrect->y,
66 scr_net);
67 }
68
69 static void
SCR_DrawLoading(void)70 SCR_DrawLoading (void)
71 {
72 qpic_t *pic;
73
74 if (!cl.loading)
75 return;
76 pic = r_funcs->Draw_CachePic ("gfx/loading.lmp", 1);
77 r_funcs->Draw_Pic ((r_data->vid->conwidth - pic->width) / 2,
78 (r_data->vid->conheight - 48 - pic->height) / 2, pic);
79 }
80
81 static void
SCR_CShift(void)82 SCR_CShift (void)
83 {
84 mleaf_t *leaf;
85 int contents = CONTENTS_EMPTY;
86
87 if (cls.state == ca_active && cl.worldmodel) {
88 leaf = Mod_PointInLeaf (r_data->refdef->vieworg, cl.worldmodel);
89 contents = leaf->contents;
90 }
91 V_SetContentsColor (contents);
92 r_funcs->Draw_BlendScreen (r_data->vid->cshift_color);
93 }
94
95 static SCR_Func scr_funcs_normal[] = {
96 0, //Draw_Crosshair,
97 0, //SCR_DrawRam,
98 0, //SCR_DrawTurtle,
99 0, //SCR_DrawPause,
100 SCR_DrawNet,
101 CL_NetGraph,
102 Sbar_Draw,
103 SCR_CShift,
104 Sbar_DrawCenterPrint,
105 Con_DrawConsole,
106 SCR_DrawLoading,
107 0
108 };
109
110 static SCR_Func scr_funcs_intermission[] = {
111 Sbar_IntermissionOverlay,
112 Con_DrawConsole,
113 0
114 };
115
116 static SCR_Func scr_funcs_finale[] = {
117 Sbar_FinaleOverlay,
118 Con_DrawConsole,
119 0,
120 };
121
122 static SCR_Func *scr_funcs[] = {
123 scr_funcs_normal,
124 scr_funcs_intermission,
125 scr_funcs_finale,
126 };
127
128 void
CL_UpdateScreen(double realtime)129 CL_UpdateScreen (double realtime)
130 {
131 unsigned index = cl.intermission;
132
133 if (index >= sizeof (scr_funcs) / sizeof (scr_funcs[0]))
134 index = 0;
135
136 //FIXME not every time
137 if (cls.state == ca_active) {
138 if (cl.watervis)
139 r_data->min_wateralpha = 0.0;
140 else
141 r_data->min_wateralpha = 1.0;
142 }
143 scr_funcs_normal[0] = r_funcs->Draw_Crosshair;
144 scr_funcs_normal[1] = r_funcs->SCR_DrawRam;
145 scr_funcs_normal[2] = r_funcs->SCR_DrawTurtle;
146 scr_funcs_normal[3] = r_funcs->SCR_DrawPause;
147
148 V_PrepBlend ();
149 r_funcs->SCR_UpdateScreen (realtime, V_RenderView, scr_funcs[index]);
150 }
151