mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-01-29 20:20:43 +00:00
final (?) cleanup of center printing. turns out there's no reason to keep
it in the renderer and every reason to pull it out (ok, some might disagree:)
This commit is contained in:
parent
39fc0fe721
commit
37024a4419
12 changed files with 181 additions and 117 deletions
|
@ -43,7 +43,6 @@ void SCR_UpdateWholeScreen (void);
|
|||
void SCR_SizeUp (void);
|
||||
void SCR_SizeDown (void);
|
||||
void SCR_BringDownConsole (void);
|
||||
void SCR_CenterPrint (const char *str);
|
||||
void SCR_CalcRefdef (void);
|
||||
|
||||
void SCR_BeginLoadingPlaque (void);
|
||||
|
@ -55,7 +54,6 @@ void SCR_DrawFPS (void);
|
|||
void SCR_DrawTime (void);
|
||||
void SCR_DrawTurtle (void);
|
||||
void SCR_DrawPause (void);
|
||||
void SCR_DrawCenterString (struct view_s *view, int remaining);
|
||||
|
||||
struct tex_s *SCR_ScreenShot (int width, int height);
|
||||
void SCR_DrawStringToSnap (const char *s, struct tex_s *tex, int x, int y);
|
||||
|
@ -63,11 +61,6 @@ int MipColor (int r, int g, int b);
|
|||
int SCR_ModalMessage (const char *text);
|
||||
|
||||
extern float scr_con_current;
|
||||
extern float scr_centertime_off;
|
||||
extern float scr_conlines; // lines of console to display
|
||||
extern float scr_centertime_start; // for slow victory printing
|
||||
extern int scr_center_lines;
|
||||
extern int scr_erase_lines;
|
||||
|
||||
extern int scr_fullupdate; // set to 0 to force full redraw
|
||||
extern int sb_lines;
|
||||
|
|
|
@ -62,15 +62,6 @@ extern vrect_t scr_vrect;
|
|||
|
||||
extern qboolean scr_skipupdate;
|
||||
|
||||
/* CENTER PRINTING */
|
||||
|
||||
extern char scr_centerstring[1024];
|
||||
extern float scr_centertime_start; // for slow victory printing
|
||||
extern float scr_centertime_off;
|
||||
extern int scr_center_lines;
|
||||
extern int scr_erase_lines;
|
||||
extern int scr_erase_center;
|
||||
|
||||
float CalcFov (float fov_x, float width, float height);
|
||||
void SCR_SetUpToDrawConsole (void);
|
||||
void SCR_ScreenShot_f (void);
|
||||
|
|
|
@ -52,6 +52,7 @@ void Sbar_IntermissionOverlay (void);
|
|||
|
||||
void Sbar_FinaleOverlay (void);
|
||||
void Sbar_DrawCenterPrint (void);
|
||||
void Sbar_CenterPrint (const char *str);
|
||||
|
||||
void Sbar_LogFrags (void);
|
||||
|
||||
|
|
|
@ -354,16 +354,6 @@ C_SayTeam (const char *line)
|
|||
game_target = IMT_0;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
C_GIB_Print_Center_f (void)
|
||||
{
|
||||
if (GIB_Argc () != 2) {
|
||||
GIB_USAGE ("text");
|
||||
} else
|
||||
SCR_CenterPrint (GIB_Argv(1));
|
||||
}
|
||||
|
||||
static void
|
||||
Linefeed (void)
|
||||
{
|
||||
|
@ -924,7 +914,6 @@ C_Init (void)
|
|||
"file");
|
||||
|
||||
// register GIB builtins
|
||||
GIB_Builtin_Add ("print::center", C_GIB_Print_Center_f);
|
||||
GIB_Builtin_Add ("HUD::enable", C_GIB_HUD_Enable_f);
|
||||
GIB_Builtin_Add ("HUD::disable", C_GIB_HUD_Disable_f);
|
||||
|
||||
|
|
|
@ -121,14 +121,6 @@ vrect_t scr_vrect;
|
|||
|
||||
qboolean scr_skipupdate;
|
||||
|
||||
/* CENTER PRINTING */
|
||||
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;
|
||||
|
||||
void
|
||||
R_SetVrect (vrect_t *pvrectin, vrect_t *pvrect, int lineadj)
|
||||
{
|
||||
|
@ -193,65 +185,6 @@ SCR_CalcRefdef (void)
|
|||
R_ViewChanged (vid.aspect);
|
||||
}
|
||||
|
||||
/*
|
||||
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)
|
||||
{
|
||||
strncpy (scr_centerstring, str, sizeof (scr_centerstring) - 1);
|
||||
scr_centertime_off = scr_centertime->value;
|
||||
scr_centertime_start = r_realtime;
|
||||
|
||||
// count the number of lines for centering
|
||||
scr_center_lines = 1;
|
||||
while (*str) {
|
||||
if (*str == '\n')
|
||||
scr_center_lines++;
|
||||
str++;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SCR_DrawCenterString (view_t *view, int remaining)
|
||||
{
|
||||
char *start;
|
||||
int j, l, x, y;
|
||||
|
||||
scr_erase_center = 0;
|
||||
start = scr_centerstring;
|
||||
|
||||
if (scr_center_lines <= 4)
|
||||
y = view->yabs + view->ylen * 0.35;
|
||||
else
|
||||
y = view->yabs + 48;
|
||||
|
||||
do {
|
||||
// scan the width of the line
|
||||
for (l = 0; l < 40; l++)
|
||||
if (start[l] == '\n' || !start[l])
|
||||
break;
|
||||
x = view->xabs + (view->xlen - l * 8) / 2;
|
||||
for (j = 0; j < l; 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);
|
||||
}
|
||||
|
||||
float
|
||||
CalcFov (float fov_x, float width, float height)
|
||||
{
|
||||
|
|
|
@ -221,7 +221,6 @@ extern client_t *host_client;
|
|||
extern jmp_buf host_abortserver;
|
||||
|
||||
extern double host_time;
|
||||
extern float scr_centertime_off;
|
||||
|
||||
extern edict_t *sv_player;
|
||||
|
||||
|
|
|
@ -252,6 +252,7 @@ CL_NewMap (const char *mapname)
|
|||
{
|
||||
R_NewMap (cl.worldmodel, cl.model_precache, MAX_MODELS);
|
||||
Con_NewMap ();
|
||||
Sbar_CenterPrint (0);
|
||||
|
||||
map_cfg (mapname, 1);
|
||||
}
|
||||
|
@ -812,7 +813,7 @@ CL_ParseServerMessage (void)
|
|||
break;
|
||||
|
||||
case svc_centerprint:
|
||||
SCR_CenterPrint (MSG_ReadString (net_message));
|
||||
Sbar_CenterPrint (MSG_ReadString (net_message));
|
||||
break;
|
||||
|
||||
case svc_stufftext:
|
||||
|
@ -964,14 +965,14 @@ CL_ParseServerMessage (void)
|
|||
cl.intermission = 2;
|
||||
cl.completed_time = cl.time;
|
||||
vid.recalc_refdef = true; // go to full screen
|
||||
SCR_CenterPrint (MSG_ReadString (net_message));
|
||||
Sbar_CenterPrint (MSG_ReadString (net_message));
|
||||
break;
|
||||
|
||||
case svc_cutscene:
|
||||
cl.intermission = 3;
|
||||
cl.completed_time = cl.time;
|
||||
vid.recalc_refdef = true; // go to full screen
|
||||
SCR_CenterPrint (MSG_ReadString (net_message));
|
||||
Sbar_CenterPrint (MSG_ReadString (net_message));
|
||||
break;
|
||||
|
||||
case svc_sellscreen:
|
||||
|
|
|
@ -37,6 +37,8 @@ static __attribute__ ((unused)) const char rcsid[] =
|
|||
#include "QF/cmd.h"
|
||||
#include "QF/cvar.h"
|
||||
#include "QF/draw.h"
|
||||
#include "QF/dstring.h"
|
||||
#include "QF/gib.h"
|
||||
#include "QF/plugin.h"
|
||||
#include "QF/screen.h"
|
||||
#include "QF/sys.h"
|
||||
|
@ -1182,6 +1184,73 @@ Sbar_IntermissionOverlay (void)
|
|||
draw_intermission (overlay_view);
|
||||
}
|
||||
|
||||
/* CENTER PRINTING */
|
||||
static dstring_t center_string = {&dstring_default_mem};
|
||||
static float centertime_start; // for slow victory printing
|
||||
static float centertime_off;
|
||||
static int center_lines;
|
||||
|
||||
/*
|
||||
Called for important messages that should stay in the center of the screen
|
||||
for a few moments
|
||||
*/
|
||||
void
|
||||
Sbar_CenterPrint (const char *str)
|
||||
{
|
||||
if (!str) {
|
||||
centertime_off = 0;
|
||||
dstring_clearstr (¢er_string);
|
||||
return;
|
||||
}
|
||||
|
||||
dstring_copystr (¢er_string, str);
|
||||
|
||||
centertime_off = scr_centertime->value;
|
||||
centertime_start = realtime;
|
||||
|
||||
// count the number of lines for centering
|
||||
center_lines = 1;
|
||||
while (*str) {
|
||||
if (*str == '\n')
|
||||
center_lines++;
|
||||
str++;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
Sbar_DrawCenterString (view_t *view, int remaining)
|
||||
{
|
||||
const char *start;
|
||||
int j, l, x, y;
|
||||
|
||||
start = center_string.str;
|
||||
|
||||
if (center_lines <= 4)
|
||||
y = view->yabs + view->ylen * 0.35;
|
||||
else
|
||||
y = view->yabs + 48;
|
||||
|
||||
do {
|
||||
// scan the width of the line
|
||||
for (l = 0; l < 40; l++)
|
||||
if (start[l] == '\n' || !start[l])
|
||||
break;
|
||||
x = view->xabs + (view->xlen - l * 8) / 2;
|
||||
for (j = 0; j < l; 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);
|
||||
}
|
||||
|
||||
void
|
||||
Sbar_FinaleOverlay (void)
|
||||
|
@ -1195,25 +1264,23 @@ Sbar_FinaleOverlay (void)
|
|||
|
||||
draw_cachepic (overlay_view, 0, 16, "gfx/finale.lmp", 1);
|
||||
// the finale prints the characters one at a time
|
||||
remaining = scr_printspeed->value * (realtime - scr_centertime_start);
|
||||
SCR_DrawCenterString (overlay_view, remaining);
|
||||
remaining = scr_printspeed->value * (realtime - centertime_start);
|
||||
Sbar_DrawCenterString (overlay_view, remaining);
|
||||
}
|
||||
|
||||
void
|
||||
Sbar_DrawCenterPrint (void)
|
||||
{
|
||||
scr_copytop = 1;
|
||||
if (scr_center_lines > scr_erase_lines)
|
||||
scr_erase_lines = scr_center_lines;
|
||||
|
||||
scr_centertime_off -= r_frametime;
|
||||
if (scr_centertime_off <= 0)
|
||||
centertime_off -= r_frametime;
|
||||
if (centertime_off <= 0)
|
||||
return;
|
||||
|
||||
if (key_dest != key_game)
|
||||
return;
|
||||
|
||||
SCR_DrawCenterString (overlay_view, -1);
|
||||
Sbar_DrawCenterString (overlay_view, -1);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1561,6 +1628,15 @@ init_views (void)
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
Sbar_GIB_Print_Center_f (void)
|
||||
{
|
||||
if (GIB_Argc () != 2) {
|
||||
GIB_USAGE ("text");
|
||||
} else
|
||||
Sbar_CenterPrint (GIB_Argv(1));
|
||||
}
|
||||
|
||||
/*
|
||||
Sbar_Init
|
||||
|
||||
|
@ -1718,4 +1794,7 @@ Sbar_Init (void)
|
|||
"overlay: center, northwest, north, "
|
||||
"northeast, west, east, southwest, "
|
||||
"south, southeast");
|
||||
|
||||
// register GIB builtins
|
||||
GIB_Builtin_Add ("print::center", Sbar_GIB_Print_Center_f);
|
||||
}
|
||||
|
|
|
@ -55,8 +55,6 @@ client_static_t cls;
|
|||
|
||||
keydest_t key_dest = key_game;
|
||||
|
||||
float scr_centertime_off;
|
||||
|
||||
cvar_t *cl_name;
|
||||
cvar_t *cl_writecfg;
|
||||
cvar_t *demo_speed;
|
||||
|
|
|
@ -906,7 +906,6 @@ SV_SpawnServer (const char *server)
|
|||
// let's not have any servers with no name
|
||||
if (hostname->string[0] == 0)
|
||||
Cvar_Set (hostname, "UNNAMED");
|
||||
scr_centertime_off = 0;
|
||||
|
||||
Con_DPrintf ("SpawnServer: %s\n", server);
|
||||
svs.changelevel_issued = false; // now safe to issue another
|
||||
|
|
|
@ -287,6 +287,7 @@ CL_NewMap (const char *mapname)
|
|||
Team_NewMap ();
|
||||
Con_NewMap ();
|
||||
Hunk_Check (); // make sure nothing is hurt
|
||||
Sbar_CenterPrint (0);
|
||||
|
||||
map_cfg (mapname, 1);
|
||||
}
|
||||
|
@ -1264,7 +1265,7 @@ CL_ParseServerMessage (void)
|
|||
break;
|
||||
}
|
||||
case svc_centerprint:
|
||||
SCR_CenterPrint (MSG_ReadString (net_message));
|
||||
Sbar_CenterPrint (MSG_ReadString (net_message));
|
||||
break;
|
||||
|
||||
case svc_stufftext:
|
||||
|
@ -1436,7 +1437,7 @@ CL_ParseServerMessage (void)
|
|||
cl.intermission = 2;
|
||||
cl.completed_time = realtime;
|
||||
vid.recalc_refdef = true; // go to full screen
|
||||
SCR_CenterPrint (MSG_ReadString (net_message));
|
||||
Sbar_CenterPrint (MSG_ReadString (net_message));
|
||||
break;
|
||||
|
||||
case svc_sellscreen:
|
||||
|
|
|
@ -46,6 +46,8 @@ static __attribute__ ((unused)) const char rcsid[] =
|
|||
#include "QF/console.h"
|
||||
#include "QF/cvar.h"
|
||||
#include "QF/draw.h"
|
||||
#include "QF/dstring.h"
|
||||
#include "QF/gib.h"
|
||||
#include "QF/msg.h"
|
||||
#include "QF/plugin.h"
|
||||
#include "QF/quakefs.h"
|
||||
|
@ -1675,6 +1677,74 @@ Sbar_IntermissionOverlay (void)
|
|||
Sbar_DeathmatchOverlay (overlay_view, 0);
|
||||
}
|
||||
|
||||
/* CENTER PRINTING */
|
||||
static dstring_t center_string = {&dstring_default_mem};
|
||||
static float centertime_start; // for slow victory printing
|
||||
static float centertime_off;
|
||||
static int center_lines;
|
||||
|
||||
/*
|
||||
Called for important messages that should stay in the center of the screen
|
||||
for a few moments
|
||||
*/
|
||||
void
|
||||
Sbar_CenterPrint (const char *str)
|
||||
{
|
||||
if (!str) {
|
||||
centertime_off = 0;
|
||||
dstring_clearstr (¢er_string);
|
||||
return;
|
||||
}
|
||||
|
||||
dstring_copystr (¢er_string, str);
|
||||
|
||||
centertime_off = scr_centertime->value;
|
||||
centertime_start = realtime;
|
||||
|
||||
// count the number of lines for centering
|
||||
center_lines = 1;
|
||||
while (*str) {
|
||||
if (*str == '\n')
|
||||
center_lines++;
|
||||
str++;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
Sbar_DrawCenterString (view_t *view, int remaining)
|
||||
{
|
||||
const char *start;
|
||||
int j, l, x, y;
|
||||
|
||||
start = center_string.str;
|
||||
|
||||
if (center_lines <= 4)
|
||||
y = view->yabs + view->ylen * 0.35;
|
||||
else
|
||||
y = view->yabs + 48;
|
||||
|
||||
do {
|
||||
// scan the width of the line
|
||||
for (l = 0; l < 40; l++)
|
||||
if (start[l] == '\n' || !start[l])
|
||||
break;
|
||||
x = view->xabs + (view->xlen - l * 8) / 2;
|
||||
for (j = 0; j < l; 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);
|
||||
}
|
||||
|
||||
void
|
||||
Sbar_FinaleOverlay (void)
|
||||
{
|
||||
|
@ -1687,25 +1757,23 @@ Sbar_FinaleOverlay (void)
|
|||
|
||||
draw_cachepic (overlay_view, 0, 16, "gfx/finale.lmp");
|
||||
// the finale prints the characters one at a time
|
||||
remaining = scr_printspeed->value * (realtime - scr_centertime_start);
|
||||
SCR_DrawCenterString (overlay_view, remaining);
|
||||
remaining = scr_printspeed->value * (realtime - centertime_start);
|
||||
Sbar_DrawCenterString (overlay_view, remaining);
|
||||
}
|
||||
|
||||
void
|
||||
Sbar_DrawCenterPrint (void)
|
||||
{
|
||||
scr_copytop = 1;
|
||||
if (scr_center_lines > scr_erase_lines)
|
||||
scr_erase_lines = scr_center_lines;
|
||||
|
||||
scr_centertime_off -= r_frametime;
|
||||
if (scr_centertime_off <= 0)
|
||||
centertime_off -= r_frametime;
|
||||
if (centertime_off <= 0)
|
||||
return;
|
||||
|
||||
if (key_dest != key_game)
|
||||
return;
|
||||
|
||||
SCR_DrawCenterString (overlay_view, -1);
|
||||
Sbar_DrawCenterString (overlay_view, -1);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1896,6 +1964,15 @@ init_views (void)
|
|||
init_hud_views ();
|
||||
}
|
||||
|
||||
static void
|
||||
Sbar_GIB_Print_Center_f (void)
|
||||
{
|
||||
if (GIB_Argc () != 2) {
|
||||
GIB_USAGE ("text");
|
||||
} else
|
||||
Sbar_CenterPrint (GIB_Argv(1));
|
||||
}
|
||||
|
||||
void
|
||||
Sbar_Init (void)
|
||||
{
|
||||
|
@ -2012,4 +2089,7 @@ Sbar_Init (void)
|
|||
"overlay: center, northwest, north, "
|
||||
"northeast, west, east, southwest, "
|
||||
"south, southeast");
|
||||
|
||||
// register GIB builtins
|
||||
GIB_Builtin_Add ("print::center", Sbar_GIB_Print_Center_f);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue