forked from SpiritQuaddicted/reQuiem
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gl_screen.c
2359 lines (1930 loc) · 50 KB
/
gl_screen.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
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 the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// gl_screen.c -- master for refresh, status bar, console, chat, notify, etc
#include "quakedef.h"
#ifndef RQM_SV_ONLY
#include <time.h> // cl_clock
#include "movie.h"
#ifndef _WIN32
#include <ctype.h>
#endif
/*
background clear
rendering
turtle/net/ram icons
sbar
centerprint / slow centerprint
notify lines
intermission / finale overlay
loading plaque
console
menu
required background clears
required update regions
syncronous draw mode or async
One off screen buffer, with updates either copied or xblited
Need to double buffer?
async draw will require the refresh area to be cleared, because it will be
xblited, but sync draw can just ignore it.
sync
draw
CenterPrint ()
SlowPrint ()
Screen_Update ();
Con_Printf ();
net
turn off messages option
the refresh is always rendered, unless the console is full screen
console is:
notify lines
half
full
*/
int glx, gly, glwidth, glheight;
// only the refresh window will be updated unless these variables are flagged
// JDH: remnants from SW renderer?
//int scr_copytop;
//int scr_copyeverything;
//int scr_fullupdate;
float scr_con_current;
float scr_conlines; // lines of console to display
const char *scr_notifystring;
qboolean scr_drawdialog;
//float oldscreensize, oldfov;
qboolean OnChange_screenvar (cvar_t *var, const char *value);
cvar_t scr_viewsize = {"viewsize", "100", CVAR_FLAG_ARCHIVE, OnChange_screenvar};
cvar_t scr_fov = {"fov", "90", CVAR_FLAG_ARCHIVE, OnChange_screenvar}; // 10 - 170
cvar_t scr_fov_adapt = {"fov_adapt", "1", CVAR_FLAG_ARCHIVE, OnChange_screenvar};
cvar_t scr_consize = {"scr_consize", "0.8", CVAR_FLAG_ARCHIVE}; // by joe (JDH: changed default from 0.5)
cvar_t scr_conspeed = {"scr_conspeed", "600", CVAR_FLAG_ARCHIVE}; // JDH: changed default from 1000
cvar_t scr_centertime = {"scr_centertime", "2", CVAR_FLAG_ARCHIVE};
cvar_t scr_showram = {"showram", "1", CVAR_FLAG_ARCHIVE};
cvar_t scr_showturtle = {"showturtle", "0", CVAR_FLAG_ARCHIVE};
cvar_t scr_showpause = {"showpause", "1", CVAR_FLAG_ARCHIVE};
cvar_t scr_printspeed = {"scr_printspeed", "8", CVAR_FLAG_ARCHIVE};
cvar_t gl_triplebuffer = {"gl_triplebuffer", "1"};
cvar_t scr_sshot_format = {"scr_sshot_format", "jpg", CVAR_FLAG_ARCHIVE};
cvar_t scr_clock = {"cl_clock", "0", CVAR_FLAG_ARCHIVE};
cvar_t scr_clock_x = {"cl_clock_x", "0", CVAR_FLAG_ARCHIVE};
cvar_t scr_clock_y = {"cl_clock_y", "-1", CVAR_FLAG_ARCHIVE};
cvar_t scr_showdemoctrl = {"scr_showdemoctrl", "1", CVAR_FLAG_ARCHIVE};
cvar_t scr_showspeed = {"scr_showspeed", "0", CVAR_FLAG_ARCHIVE};
cvar_t scr_showfps = {"scr_showfps", "0", CVAR_FLAG_ARCHIVE};
cvar_t scr_showorigin = {"scr_showorigin", "0", CVAR_FLAG_ARCHIVE}; // JDH
cvar_t scr_printstats = {"scr_printstats", "0", CVAR_FLAG_ARCHIVE}; // JT022405 - default off for timer
cvar_t scr_printstats_style = {"scr_printstats_style", "0"};
cvar_t scr_printstats_length = {"scr_printstats_length", "0.5"};
cvar_t cl_sbar = {"cl_sbar", "0", CVAR_FLAG_ARCHIVE, OnChange_screenvar};
cvar_t scr_sbarsize = {"scr_sbarsize", "0", CVAR_FLAG_ARCHIVE, OnChange_screenvar}; // JDH
cvar_t scr_hudscale = {"scr_hudscale", "1", CVAR_FLAG_ARCHIVE}; // JDH
cvar_t scr_menusize = {"scr_menusize", "0", CVAR_FLAG_ARCHIVE}; // JDH
cvar_t scr_centermenu = {"scr_centermenu", "1", CVAR_FLAG_ARCHIVE};
qboolean scr_initialized; // ready to draw
mpic_t *scr_ram;
mpic_t *scr_net;
mpic_t *scr_turtle;
int clearconsole;
int clearnotify;
viddef_t vid; // global video state
vrect_t scr_vrect;
qboolean scr_disabled_for_loading;
qboolean scr_drawloading;
float scr_disabled_time;
double scr_demo_overlay_time = 0; // JDH: at what time demo overlay should disappear
const char *scr_loadcaption = NULL; // JDH: displayed below LOADING plaque
double scr_sshot_time = 0; // JDH: at what time screenshot should be taken
char scr_sshot_filename[MAX_OSPATH]; // JDH: for time-delayed screenshots
qboolean block_drawing;
void SCR_ScreenShot_f (cmd_source_t src);
void SCR_SizeUp_f (cmd_source_t src);
void SCR_SizeDown_f (cmd_source_t src);
#ifdef HEXEN2_SUPPORT
#define PLAQUE_WIDTH 26
#define MAXLINES 27
#define MAX_INFO 1024
extern double introTime;
extern int *pr_string_index;
extern char *pr_global_strings;
extern int pr_string_count;
extern int *pr_info_string_index;
extern char *pr_global_info_strings;
extern int pr_info_string_count;
extern char *plaquemessage;
extern cvar_t scr_hudspeed;
char infomessage[MAX_INFO];
static int StartC[MAXLINES], EndC[MAXLINES];
static int lines;
int total_loading_size, current_loading_size, loading_stage;
qboolean info_up = false;
qboolean intro_playing = false;
void SCR_Bottom_Plaque_Draw (const char *message);
#endif // #ifdef HEXEN2_SUPPORT
/*
==================
SCR_Init
==================
*/
void SCR_Init (void)
{
Cvar_RegisterInt (&scr_fov, 10, 170);
Cvar_RegisterInt (&scr_fov_adapt, 0, 1);
Cvar_RegisterInt (&scr_viewsize, 30, 120);
Cvar_RegisterFloat (&scr_consize, 0, 1); // by joe
Cvar_RegisterInt (&scr_conspeed, 100, CVAR_UNKNOWN_MAX);
Cvar_RegisterBool (&scr_showram);
Cvar_RegisterBool (&scr_showturtle);
Cvar_RegisterBool (&scr_showpause);
Cvar_RegisterFloat (&scr_centertime, 0, 5); // 5 as max is arbitrary
Cvar_Register (&scr_printspeed);
Cvar_RegisterBool (&gl_triplebuffer);
Cvar_RegisterString (&scr_sshot_format);
Cvar_RegisterInt (&scr_clock, 0, 4);
Cvar_RegisterInt (&scr_clock_x, 0, vid.width/8 - 8);
Cvar_RegisterInt (&scr_clock_y, -(int)vid.height/8, vid.height/8); // neg val gives offset from bottom
Cvar_RegisterBool (&scr_showdemoctrl);
Cvar_RegisterBool (&scr_showspeed);
Cvar_RegisterBool (&scr_showfps);
Cvar_RegisterBool (&scr_showorigin); // JDH
Cvar_RegisterInt (&scr_printstats, 0, 4);
Cvar_RegisterBool (&scr_printstats_style);
Cvar_Register (&scr_printstats_length);
Cvar_RegisterBool (&cl_sbar); // by joe
Cvar_RegisterFloat (&scr_sbarsize, 0, 100);
Cvar_RegisterFloat (&scr_hudscale, 1, 8);
Cvar_RegisterBool (&scr_centermenu);
Cvar_RegisterFloat (&scr_menusize, 0, 100);
// register our commands
Cmd_AddCommand ("screenshot", SCR_ScreenShot_f, 0);
Cmd_AddCommand ("sizeup", SCR_SizeUp_f, 0);
Cmd_AddCommand ("sizedown", SCR_SizeDown_f, 0);
// SCR_LoadWadPics (); // JDH: now done in Draw_Init
Movie_Init ();
vid.recalc_refdef = true;
scr_initialized = true;
}
/*
=====================
OnChange_screenvar
(viewsize, fov, fov_adapt, cl_sbar)
=====================
*/
qboolean OnChange_screenvar (cvar_t *var, const char *value)
{
#ifdef HEXEN2_SUPPORT
if (hexen2 && (var == &scr_viewsize))
{
float oldsize = scr_viewsize.value;
scr_viewsize.value = Q_atof (value);
Sbar_ViewSizeChanged ();
scr_viewsize.value = oldsize;
}
#endif
vid.recalc_refdef = true;
return false; // allow change
}
/*
===============================================================================
CENTER PRINTING
===============================================================================
*/
#ifdef HEXEN2_SUPPORT
/*
=====================
SCR_DrawTextBox2
=====================
*/
void SCR_DrawTextBox2 (int x, int y, int width, int lines, qboolean bottom)
{
mpic_t *p,*tm,*bm;
int cx, cy;
int n;
// draw left side
cx = x;
cy = y;
p = Draw_GetCachePic ("gfx/box_tl.lmp", false);
if (bottom)
M_DrawTransPic (cx, cy, p);
else
M_DrawTransPic2 (cx, cy, p);
p = Draw_GetCachePic ("gfx/box_ml.lmp", false);
for (n = 0; n < lines; n++)
{
cy += 8;
if(bottom)
M_DrawTransPic (cx, cy, p);
else
M_DrawTransPic2 (cx, cy, p);
}
p = Draw_GetCachePic ("gfx/box_bl.lmp", false);
if (bottom)
M_DrawTransPic (cx, cy+8, p);
else
M_DrawTransPic2 (cx, cy+8, p);
// draw middle
cx += 8;
tm = Draw_GetCachePic ("gfx/box_tm.lmp", false);
bm = Draw_GetCachePic ("gfx/box_bm.lmp", false);
while (width > 0)
{
cy = y;
if (bottom)
M_DrawTransPic (cx, cy, tm);
else
M_DrawTransPic2 (cx, cy, tm);
p = Draw_GetCachePic ("gfx/box_mm.lmp", false);
for (n = 0; n < lines; n++)
{
cy += 8;
if (n == 1)
p = Draw_GetCachePic ("gfx/box_mm2.lmp", false);
if(bottom)
M_DrawTransPic (cx, cy, p);
else
M_DrawTransPic2 (cx, cy, p);
}
if (bottom)
M_DrawTransPic (cx, cy+8, bm);
else
M_DrawTransPic2 (cx, cy+8, bm);
width -= 2;
cx += 16;
}
// draw right side
cy = y;
p = Draw_GetCachePic ("gfx/box_tr.lmp", false);
if (bottom)
M_DrawTransPic (cx, cy, p);
else
M_DrawTransPic2 (cx, cy, p);
p = Draw_GetCachePic ("gfx/box_mr.lmp", false);
for (n = 0; n < lines; n++)
{
cy += 8;
if (bottom)
M_DrawTransPic (cx, cy, p);
else
M_DrawTransPic2 (cx, cy, p);
}
p = Draw_GetCachePic ("gfx/box_br.lmp", false);
if (bottom)
M_DrawTransPic (cx, cy+8, p);
else
M_DrawTransPic2 (cx, cy+8, p);
}
/*
=====================
FindTextBreaks
=====================
*/
void FindTextBreaks (const char *message, int width)
{
int length, pos, start, lastspace, oldlast;
length = strlen (message);
lines = pos = start = 0;
lastspace = -1;
while(1)
{
if (pos-start >= width || message[pos] == '@' || message[pos] == 0)
{
oldlast = lastspace;
if (message[pos] == '@' || lastspace == -1 || message[pos] == 0)
lastspace = pos;
StartC[lines] = start;
EndC[lines] = lastspace;
lines++;
if (lines == MAXLINES)
return;
if (message[pos] == '@')
start = pos + 1;
else if (oldlast == -1)
start = lastspace;
else
start = lastspace + 1;
lastspace = -1;
}
if (message[pos] == 32) lastspace = pos;
else if (message[pos] == 0)
{
break;
}
pos++;
}
}
/*
============
ReformatText
- replaces '@' with '\n' and inserts '\n' when word-wrap occurs
============
*/
void ReformatText (char *text, int width)
{
int len, i;
char buf[MAXPRINTMSG];
FindTextBreaks (text, width);
len = 0;
for (i=0; i < lines; i++)
{
//strncpy(buf + len, text + StartC[i], EndC[i] - StartC[i]);
//len += EndC[i] - StartC[i];
len += Q_strncpy (buf + len, sizeof(buf)-len, text + StartC[i], EndC[i] - StartC[i]);
buf[len++] = '\n';
}
//strncpy(text, buf, len);
//text[len-1] = 0; // skip last '\n'
Q_strncpy (text, MAXPRINTMSG, buf, len-1); // skip last '\n'
}
/*
=====================
SCR_Print2
=====================
*/
void SCR_Print2 (int cx, int cy, const char *str)
{
while (*str)
{
Draw_Character (cx + ((vid.width - 320)>>1), cy + ((vid.height - 200)>>1), ((unsigned char)(*str))+256);
str++;
cx += 8;
}
}
#endif // #ifdef HEXEN2_SUPPORT
char scr_centerstring[1024];
float scr_centertime_start; // for slow victory printing
float scr_centertime_off;
int scr_center_lines;
int scr_erase_lines;
int scr_erase_center;
/*
==============
SCR_CenterPrint
Called for important messages that should stay in the center of the screen
for a few moments
==============
*/
void SCR_CenterPrint (const char *str)
{
Q_strcpy (scr_centerstring, str, sizeof(scr_centerstring));
scr_centertime_off = scr_centertime.value;
scr_centertime_start = cl.time;
#ifdef HEXEN2_SUPPORT
if (hexen2)
{
FindTextBreaks(scr_centerstring, 38);
scr_center_lines = lines;
return;
}
#endif
// count the number of lines for centering
scr_center_lines = 1;
while (*str)
{
if (*str == '\n')
scr_center_lines++;
str++;
}
}
/*
=====================
SCR_DrawCenterString
=====================
*/
void SCR_DrawCenterString (void)
{
char *start;
int len, j, x, y, remaining;
// the finale prints the characters one at a time
if (cl.intermission)
remaining = scr_printspeed.value * (cl.time - scr_centertime_start);
else
remaining = 9999;
scr_erase_center = 0;
#ifdef HEXEN2_SUPPORT
if (hexen2)
{
char temp[80];
FindTextBreaks (scr_centerstring, 38);
y = ((25-lines) * 8) / 2;
for (j=0; j<lines; j++, y+=8)
{
len = Q_strncpy (temp, sizeof(temp), &scr_centerstring[StartC[j]], EndC[j]-StartC[j]);
//temp[EndC[j]-StartC[j]] = 0;
//x = ((40-strlen(temp)) * 8) / 2;
x = ((40-len)*8)/2;
SCR_Print2 (x, y, temp);
}
return;
}
#endif
start = scr_centerstring;
if (scr_center_lines <= 4)
y = vid.height*0.35;
else
y = 48;
do
{
// scan the width of the line
for (len=0 ; len<40 ; len++)
if (start[len] == '\n' || !start[len])
break;
x = (vid.width - len*8) / 2;
for (j=0 ; j<len ; j++, x+=8)
{
Draw_Character (x, y, start[j]);
if (!remaining--)
return;
}
y += 8;
while (*start && *start != '\n')
start++;
if (!*start)
break;
start++; // skip the \n
} while (1);
}
/*
=====================
SCR_CheckDrawCenterString
=====================
*/
void SCR_CheckDrawCenterString (void)
{
// scr_copytop = 1;
if (scr_center_lines > scr_erase_lines)
scr_erase_lines = scr_center_lines;
scr_centertime_off -= host_frametime;
if (scr_centertime_off <= 0 && !cl.intermission)
return;
if (key_dest != key_game)
return;
#ifdef HEXEN2_SUPPORT
if (intro_playing)
SCR_Bottom_Plaque_Draw (scr_centerstring);
else
#endif
SCR_DrawCenterString ();
}
#ifdef HEXEN2_SUPPORT
/*
=====================
SCR_Plaque_Draw
=====================
*/
void SCR_Plaque_Draw (const char *message, qboolean AlwaysDraw)
{
int i, len;
char temp[80];
int bx, by;
if (scr_con_current == vid.height && !AlwaysDraw)
return; // console is full screen
if (!*message)
return;
M_SetScale (true); // set up menu vars, since DrawTextBox2 uses menu funcs
FindTextBreaks (message, PLAQUE_WIDTH);
by = (200 - lines*DRAW_CHARHEIGHT) / 2;
SCR_DrawTextBox2 (32, by-2*DRAW_CHARHEIGHT, 30, lines+2, false);
for (i=0; i<lines; i++, by+=DRAW_CHARHEIGHT)
{
//strncpy (temp,&message[StartC[i]],EndC[i]-StartC[i]);
//temp[EndC[i]-StartC[i]] = 0;
//bx = ((40-strlen(temp)) * 8) / 2;
len = Q_strncpy (temp, sizeof(temp), &message[StartC[i]], EndC[i]-StartC[i]);
bx = (320 - len*DRAW_CHARWIDTH) / 2;
SCR_Print2 (bx, by, temp);
}
M_SetScale (false);
}
/*
=====================
SCR_Bottom_Plaque_Draw
=====================
*/
void SCR_Bottom_Plaque_Draw (const char *message)
{
int i, len;
char temp[80];
int bx, by;
if (!*message)
return;
// scr_needfull = true;
M_SetScale (true); // set up menu vars, since DrawTextBox2 uses menu funcs
FindTextBreaks (message, PLAQUE_WIDTH);
by = vid.height - (lines+2)*DRAW_CHARHEIGHT;
SCR_DrawTextBox2 (32, by-2*DRAW_CHARHEIGHT, 30, lines+2, true);
for (i=0; i<lines; i++, by+=DRAW_CHARHEIGHT)
{
//strncpy (temp,&message[StartC[i]],EndC[i]-StartC[i]);
//temp[EndC[i]-StartC[i]] = 0;
//bx = ((40-strlen(temp)) * 8) / 2;
len = Q_strncpy (temp, sizeof(temp), &message[StartC[i]], EndC[i]-StartC[i]);
bx = (320 - len*DRAW_CHARWIDTH) / 2;
M_Print (bx, by, temp);
}
M_SetScale (false);
}
/*
=====================
SCR_Info_Plaque_Draw
=====================
*/
void SCR_Info_Plaque_Draw (const char *message)
{
int i, len;
char temp[80];
int bx, by;
if (scr_con_current == vid.height)
return; // console is full screen
if (!*message)
return;
// scr_needfull = true;
M_SetScale (true); // set up menu vars, since DrawTextBox2 uses menu funcs
FindTextBreaks (message, PLAQUE_WIDTH+4);
if (lines == MAXLINES)
{
Con_DPrintf ("Info_Plaque_Draw: line overflow error\n");
lines = MAXLINES-1;
}
by = (200 - lines*DRAW_CHARHEIGHT) / 2;
SCR_DrawTextBox2 (15, by-2*DRAW_CHARHEIGHT, PLAQUE_WIDTH+4+4, lines+2,false);
for (i=0; i<lines; i++, by+=DRAW_CHARHEIGHT)
{
//strncpy(temp,&message[StartC[i]],EndC[i]-StartC[i]);
//temp[EndC[i]-StartC[i]] = 0;
//bx = ((40-strlen(temp)) * 8) / 2;
len = Q_strncpy (temp, sizeof(temp), &message[StartC[i]], EndC[i]-StartC[i]);
bx = (320 - len*DRAW_CHARWIDTH) / 2;
SCR_Print2 (bx, by, temp);
}
M_SetScale (false);
}
/*
=====================
UpdateInfoMessage
=====================
*/
void UpdateInfoMessage (void)
{
unsigned int len, i, check;
char *newmessage;
len = Q_strcpy (infomessage, "Objectives:", sizeof(infomessage));
if (!pr_global_info_strings)
return;
for (i = 0; i < 32; i++)
{
check = (1 << i);
if (cl.info_mask & check)
{
newmessage = &pr_global_info_strings[pr_info_string_index[i]];
len += Q_strcpy (infomessage+len, "@@", sizeof(infomessage)-len);
len += Q_strcpy (infomessage+len, newmessage, sizeof(infomessage)-len);
}
}
for (i = 0; i < 32; i++)
{
check = (1 << i);
if (cl.info_mask2 & check)
{
newmessage = &pr_global_info_strings[pr_info_string_index[i+32]];
len += Q_strcpy (infomessage+len, "@@", sizeof(infomessage)-len);
len += Q_strcpy (infomessage+len, newmessage, sizeof(infomessage)-len);
}
}
}
#endif // #ifdef HEXEN2_SUPPORT
//=============================================================================
/*
====================
CalcFov
Given an FOV value for a reference dimension, calculate the FOV value for
another dimension that would preserve the subtended angles of objects.
====================
*/
float CalcFov (float fov_ref, float dim_ref, float dim_other)
{
float a;
if (fov_ref < 1 || fov_ref > 179)
Sys_Error ("Bad fov: %f", fov_ref);
a = atan(dim_other / dim_ref * tan(fov_ref / 360 * M_PI));
a = a * 360 / M_PI;
return a;
}
/*
=================
SCR_CalcRefdef
Must be called whenever vid changes
Internal use only
=================
*/
static void SCR_CalcRefdef (void)
{
float size;
int sbar_height;
qboolean full = false;
// scr_fullupdate = 0; // force a background redraw
vid.recalc_refdef = 0;
// force the status bar to redraw
Sbar_Changed ();
//========================================
// bound viewsize
if (scr_viewsize.value < scr_viewsize.minvalue)
Cvar_SetValueDirect (&scr_viewsize, scr_viewsize.minvalue);
else if (scr_viewsize.value > scr_viewsize.maxvalue)
Cvar_SetValueDirect (&scr_viewsize, scr_viewsize.maxvalue);
// bound field of view
if (scr_fov.value < scr_fov.minvalue)
Cvar_SetValueDirect (&scr_fov, scr_fov.minvalue);
else if (scr_fov.value > scr_fov.maxvalue)
Cvar_SetValueDirect (&scr_fov, scr_fov.maxvalue);
// intermission is always full screen
if (cl.intermission)
{
full = true;
size = 100.0;
// sb_lines = 0;
}
else
{
size = scr_viewsize.value;
/*
if (size >= scr_viewsize.maxvalue)
sb_lines = 0; // no status bar at all
else if (size >= scr_viewsize.maxvalue-10)
sb_lines = 1; // no inventory
else
sb_lines = 2;
*/
if (size >= 100.0)
{
full = true;
size = 100.0;
}
}
size /= 100.0;
r_refdef.vrect.width = vid.width * size;
if (r_refdef.vrect.width < 96)
{
size = 96.0 / r_refdef.vrect.width;
r_refdef.vrect.width = 96; // min for icons
}
/*r_refdef.vrect.height = (vid.height * size) - Sbar_Height();
if (cl_sbar.value || !full)
{
if (r_refdef.vrect.height > vid.height - sb_lines)
r_refdef.vrect.height = vid.height - sb_lines;
}
else if (r_refdef.vrect.height > vid.height)
{
r_refdef.vrect.height = vid.height;
}*/
sbar_height = ((cl_sbar.value || scr_viewsize.value < 100) ? Sbar_Height() : 0);
r_refdef.vrect.height = (vid.height - sbar_height) * size;
r_refdef.vrect.x = (vid.width - r_refdef.vrect.width) / 2;
if (full)
r_refdef.vrect.y = 0;
else
// r_refdef.vrect.y = (vid.height - sb_lines - r_refdef.vrect.height) / 2;
r_refdef.vrect.y = (vid.height - sbar_height - r_refdef.vrect.height) / 2;
if (scr_fov_adapt.value)
{
// "auto" FOV: treat fov value as horizontal FOV for 4:3 aspect ratio
// Find what the screen width dimension would be for the current screen
// height, if the screen aspect ratio were 4:3. Assuming scr_fov.value is
// the FOV at that width, then find the appropriate FOV for the current
// screen width. Use that for the viewport's horizontal FOV.
r_refdef.fov_x = CalcFov (scr_fov.value, vid.height * 4.0 / 3.0, vid.width);
}
else
{
// "manual" FOV: treat fov value as the viewport's horizontal FOV.
r_refdef.fov_x = scr_fov.value;
}
// Always derive the viewport's vertical FOV from its horizontal FOV.
r_refdef.fov_y = CalcFov (r_refdef.fov_x, r_refdef.vrect.width, r_refdef.vrect.height);
scr_vrect = r_refdef.vrect;
}
/*
=================
SCR_SizeUp_f
Keybinding command
=================
*/
void SCR_SizeUp_f (cmd_source_t src)
{
Cvar_SetValueDirect (&scr_viewsize, scr_viewsize.value + 10);
vid.recalc_refdef = 1;
}
/*
=================
SCR_SizeDown_f
Keybinding command
=================
*/
void SCR_SizeDown_f (cmd_source_t src)
{
Cvar_SetValueDirect (&scr_viewsize, scr_viewsize.value - 10);
vid.recalc_refdef = 1;
}
//============================================================================
/*
==================
SCR_ClearWadPics
==================
*/
void SCR_ClearWadPics (void)
{
scr_ram = scr_net = scr_turtle = NULL;
}
/*
==================
SCR_LoadWadPics
==================
*/
void SCR_LoadWadPics (void)
{
scr_ram = Draw_PicFromWad ("ram");
scr_net = Draw_PicFromWad ("net");
scr_turtle = Draw_PicFromWad ("turtle");
}
/*
==============
SCR_DrawRam
==============
*/
void SCR_DrawRam (void)
{
if (!scr_showram.value)
return;
if (!r_cache_thrash)
return;
if (scr_ram)
Draw_Pic (scr_vrect.x+32, scr_vrect.y, scr_ram);
}
/*
==============
SCR_DrawTurtle
==============
*/
void SCR_DrawTurtle (void)
{
static int count;
if (!scr_showturtle.value)
return;
if (host_frametime < 0.1)
{
count = 0;
return;
}
count++;
if (count < 3)
return;
if (scr_turtle)
Draw_Pic (scr_vrect.x, scr_vrect.y, scr_turtle);
}
/*
==============
SCR_DrawNet
==============
*/
void SCR_DrawNet (void)
{
if (realtime - cl.last_received_message < 0.3)
return;
if (cls.demoplayback)
return;
if (scr_net)
Draw_Pic (scr_vrect.x+64, scr_vrect.y, scr_net);
}
/*
==============