summaryrefslogtreecommitdiff
path: root/src/cgame
diff options
context:
space:
mode:
Diffstat (limited to 'src/cgame')
-rw-r--r--src/cgame/cg_draw.c119
-rw-r--r--src/cgame/cg_drawtools.c27
-rw-r--r--src/cgame/cg_local.h10
-rw-r--r--src/cgame/cg_main.c13
-rw-r--r--src/cgame/cg_public.h1
-rw-r--r--src/cgame/cg_syscalls.asm115
-rw-r--r--src/cgame/cg_syscalls.c5
7 files changed, 127 insertions, 163 deletions
diff --git a/src/cgame/cg_draw.c b/src/cgame/cg_draw.c
index 73006beb..2a0a2ba5 100644
--- a/src/cgame/cg_draw.c
+++ b/src/cgame/cg_draw.c
@@ -1269,108 +1269,44 @@ static void CG_DrawKiller( rectDef_t *rect, float scale, vec4_t color,
}
+#define SPECTATORS_PIXELS_PER_SECOND 30.0f
+
+/*
+==================
+CG_DrawTeamSpectators
+==================
+*/
static void CG_DrawTeamSpectators( rectDef_t *rect, float scale, int textvalign, vec4_t color, qhandle_t shader )
{
float y;
- qboolean isEmoticon;
- qboolean emoticonEscaped;
- char secondPart[ MAX_STRING_CHARS ] = "";
- int emoticonLen;
- static char lastColorSeen = COLOR_WHITE;
-
- if( cg.spectatorLen )
- {
- float maxX;
-
- if( cg.spectatorWidth == -1 )
- {
- cg.spectatorWidth = 0;
- cg.spectatorPaintX = rect->x + 1;
- cg.spectatorPaintX2 = -1;
- }
+ char *text = cg.spectatorList;
+ float textWidth = UI_Text_Width( text, scale, 0 );
- if( cg.spectatorOffset > cg.spectatorLen )
- {
- cg.spectatorOffset = 0;
- cg.spectatorPaintX = rect->x + 1;
- cg.spectatorPaintX2 = -1;
- }
-
- if( cg.time > cg.spectatorTime )
- {
- cg.spectatorTime = cg.time + 10;
+ CG_AlignText( rect, text, scale, 0.0f, 0.0f, ALIGN_LEFT, textvalign, NULL, &y );
- if( cg.spectatorPaintX <= rect->x + 2 )
- {
- if( cg.spectatorOffset < cg.spectatorLen )
- {
- // skip colour directives
- if( Q_IsColorString( &cg.spectatorList[ cg.spectatorOffset ] ) )
- {
- lastColorSeen = cg.spectatorList[ cg.spectatorOffset + 1 ];
- cg.spectatorOffset += 2;
- }
- else
- {
- isEmoticon = UI_Text_Emoticon( &cg.spectatorList[ cg.spectatorOffset ],
- &emoticonEscaped, &emoticonLen, NULL, NULL );
- if( isEmoticon )
- {
- cg.spectatorOffset += emoticonLen;
- if( emoticonEscaped ) cg.spectatorOffset++; // skip an extra char to not un-scape by eating the escaping [
- }
-
- cg.spectatorPaintX += UI_Text_Width( &cg.spectatorList[ cg.spectatorOffset ], scale, 1 ) - 1;
- cg.spectatorOffset++;
- }
- }
- else
- {
- cg.spectatorOffset = 0;
+ if( textWidth > rect->w )
+ {
+ // The text is too wide to fit, so scroll it
+ int now = trap_Milliseconds( );
+ int delta = now - cg.spectatorTime;
- if( cg.spectatorPaintX2 >= 0 )
- cg.spectatorPaintX = cg.spectatorPaintX2;
- else
- cg.spectatorPaintX = rect->x + rect->w - 2;
+ CG_SetClipRegion( rect->x, rect->y, rect->w, rect->h );
- cg.spectatorPaintX2 = -1;
- }
- }
- else
- {
- cg.spectatorPaintX--;
+ UI_Text_Paint( rect->x - cg.spectatorOffset, y, scale, color, text, 0, 0, 0 );
+ UI_Text_Paint( rect->x + textWidth - cg.spectatorOffset, y, scale, color, text, 0, 0, 0 );
- if( cg.spectatorPaintX2 >= 0 )
- cg.spectatorPaintX2--;
- }
- }
+ CG_ClearClipRegion( );
- secondPart[ 0 ] = Q_COLOR_ESCAPE;
- secondPart[ 1 ] = lastColorSeen;
- Q_strncpyz( secondPart+2, &cg.spectatorList[ cg.spectatorOffset ], sizeof( secondPart ) - 2 );
+ cg.spectatorOffset += ( delta / 1000.0f ) * SPECTATORS_PIXELS_PER_SECOND;
- maxX = rect->x + rect->w - 2;
- CG_AlignText( rect, NULL, 0.0f, 0.0f, UI_Text_EmHeight( scale ),
- ALIGN_LEFT, textvalign, NULL, &y );
+ while( cg.spectatorOffset > textWidth )
+ cg.spectatorOffset -= textWidth;
- UI_Text_Paint_Limit( &maxX, cg.spectatorPaintX, y, scale, color,
- secondPart, 0, 0 );
-
- if( cg.spectatorPaintX2 >= 0 )
- {
- float maxX2 = rect->x + rect->w - 2;
- UI_Text_Paint_Limit( &maxX2, cg.spectatorPaintX2, y, scale,
- color, cg.spectatorList, 0, cg.spectatorOffset );
- }
-
- if( cg.spectatorOffset && maxX > 0 )
- {
- // if we have an offset ( we are skipping the first part of the string ) and we fit the string
- if( cg.spectatorPaintX2 == -1 )
- cg.spectatorPaintX2 = rect->x + rect->w - 2;
- }
- else
- cg.spectatorPaintX2 = -1;
+ cg.spectatorTime = now;
+ }
+ else
+ {
+ UI_Text_Paint( rect->x, y, scale, color, text, 0, 0, 0 );
}
}
@@ -2864,6 +2800,7 @@ static qboolean CG_DrawScoreboard( void )
{
if( firstTime )
{
+ cg.spectatorTime = trap_Milliseconds();
CG_SetScoreSelection( menuScoreboard );
firstTime = qfalse;
}
diff --git a/src/cgame/cg_drawtools.c b/src/cgame/cg_drawtools.c
index b7b980f9..7d32fa1d 100644
--- a/src/cgame/cg_drawtools.c
+++ b/src/cgame/cg_drawtools.c
@@ -172,7 +172,34 @@ void CG_DrawPic( float x, float y, float width, float height, qhandle_t hShader
trap_R_DrawStretchPic( x, y, width, height, 0, 0, 1, 1, hShader );
}
+/*
+================
+CG_SetClipRegion
+=================
+*/
+void CG_SetClipRegion( float x, float y, float w, float h )
+{
+ vec4_t clip;
+
+ CG_AdjustFrom640( &x, &y, &w, &h );
+
+ clip[ 0 ] = x;
+ clip[ 1 ] = y;
+ clip[ 2 ] = x + w;
+ clip[ 3 ] = y + h;
+ trap_R_SetClipRegion( clip );
+}
+
+/*
+================
+CG_ClearClipRegion
+=================
+*/
+void CG_ClearClipRegion( void )
+{
+ trap_R_SetClipRegion( NULL );
+}
/*
================
diff --git a/src/cgame/cg_local.h b/src/cgame/cg_local.h
index 248f4453..d14454a1 100644
--- a/src/cgame/cg_local.h
+++ b/src/cgame/cg_local.h
@@ -1012,13 +1012,8 @@ typedef struct
int scoreFadeTime;
char killerName[ MAX_NAME_LENGTH ];
char spectatorList[ MAX_STRING_CHARS ]; // list of names
- int spectatorLen; // length of list
- float spectatorWidth; // width in device units
int spectatorTime; // next time to offset
- int spectatorPaintX; // current paint x
- int spectatorPaintX2; // current paint x
- int spectatorOffset; // current offset from start
- int spectatorPaintLen; // current offset from start
+ float spectatorOffset; // current offset from start
// centerprinting
int centerPrintTime;
@@ -1593,6 +1588,8 @@ void CG_FillRect( float x, float y, float width, float height, const floa
void CG_DrawPic( float x, float y, float width, float height, qhandle_t hShader );
void CG_DrawFadePic( float x, float y, float width, float height, vec4_t fcolor,
vec4_t tcolor, float amount, qhandle_t hShader );
+void CG_SetClipRegion( float x, float y, float w, float h );
+void CG_ClearClipRegion( void );
int CG_DrawStrlen( const char *str );
@@ -1992,6 +1989,7 @@ void trap_R_AddAdditiveLightToScene( const vec3_t org, float intensity,
int trap_R_LightForPoint( vec3_t point, vec3_t ambientLight, vec3_t directedLight, vec3_t lightDir );
void trap_R_RenderScene( const refdef_t *fd );
void trap_R_SetColor( const float *rgba ); // NULL = 1,1,1,1
+void trap_R_SetClipRegion( const float *region );
void trap_R_DrawStretchPic( float x, float y, float w, float h,
float s1, float t1, float s2, float t2, qhandle_t hShader );
void trap_R_ModelBounds( clipHandle_t model, vec3_t mins, vec3_t maxs );
diff --git a/src/cgame/cg_main.c b/src/cgame/cg_main.c
index d7076a10..da607deb 100644
--- a/src/cgame/cg_main.c
+++ b/src/cgame/cg_main.c
@@ -882,15 +882,10 @@ void CG_BuildSpectatorString( void )
for( i = 0; i < MAX_CLIENTS; i++ )
{
if( cgs.clientinfo[ i ].infoValid && cgs.clientinfo[ i ].team == TEAM_NONE )
- Q_strcat( cg.spectatorList, sizeof( cg.spectatorList ), va( S_COLOR_WHITE "%s ", cgs.clientinfo[ i ].name ) );
- }
-
- i = strlen( cg.spectatorList );
-
- if( i != cg.spectatorLen )
- {
- cg.spectatorLen = i;
- cg.spectatorWidth = -1;
+ {
+ Q_strcat( cg.spectatorList, sizeof( cg.spectatorList ),
+ va( S_COLOR_WHITE "%s ", cgs.clientinfo[ i ].name ) );
+ }
}
}
diff --git a/src/cgame/cg_public.h b/src/cgame/cg_public.h
index 98ffb00a..012e96a7 100644
--- a/src/cgame/cg_public.h
+++ b/src/cgame/cg_public.h
@@ -120,6 +120,7 @@ typedef enum
CG_R_ADDLIGHTTOSCENE,
CG_R_RENDERSCENE,
CG_R_SETCOLOR,
+ CG_R_SETCLIPREGION,
CG_R_DRAWSTRETCHPIC,
CG_R_MODELBOUNDS,
CG_R_LERPTAG,
diff --git a/src/cgame/cg_syscalls.asm b/src/cgame/cg_syscalls.asm
index a28c5db2..2537c91c 100644
--- a/src/cgame/cg_syscalls.asm
+++ b/src/cgame/cg_syscalls.asm
@@ -46,65 +46,66 @@ equ trap_R_AddPolyToScene -43
equ trap_R_AddLightToScene -44
equ trap_R_RenderScene -45
equ trap_R_SetColor -46
-equ trap_R_DrawStretchPic -47
-equ trap_R_ModelBounds -48
-equ trap_R_LerpTag -49
-equ trap_GetGlconfig -50
-equ trap_GetGameState -51
-equ trap_GetCurrentSnapshotNumber -52
-equ trap_GetSnapshot -53
-equ trap_GetServerCommand -54
-equ trap_GetCurrentCmdNumber -55
-equ trap_GetUserCmd -56
-equ trap_SetUserCmdValue -57
-equ trap_R_RegisterShaderNoMip -58
-equ trap_MemoryRemaining -59
-equ trap_R_RegisterFont -60
-equ trap_Key_IsDown -61
-equ trap_Key_GetCatcher -62
-equ trap_Key_SetCatcher -63
-equ trap_Key_GetKey -64
-equ trap_S_StopBackgroundTrack -65
-equ trap_RealTime -66
-equ trap_SnapVector -67
-equ trap_RemoveCommand -68
-equ trap_R_LightForPoint -69
-equ trap_CIN_PlayCinematic -70
-equ trap_CIN_StopCinematic -71
-equ trap_CIN_RunCinematic -72
-equ trap_CIN_DrawCinematic -73
-equ trap_CIN_SetExtents -74
-equ trap_R_RemapShader -75
-equ trap_S_AddRealLoopingSound -76
-equ trap_S_StopLoopingSound -77
-equ trap_CM_TempCapsuleModel -78
-equ trap_CM_CapsuleTrace -79
-equ trap_CM_TransformedCapsuleTrace -80
-equ trap_R_AddAdditiveLightToScene -81
-equ trap_GetEntityToken -82
-equ trap_R_AddPolysToScene -83
-equ trap_R_inPVS -84
-equ trap_FS_Seek -85
-equ trap_FS_GetFileList -86
-equ trap_LiteralArgs -87
-equ trap_CM_BiSphereTrace -88
-equ trap_CM_TransformedBiSphereTrace -89
-equ trap_GetDemoState -90
-equ trap_GetDemoPos -91
-equ trap_GetDemoName -92
-equ trap_Key_KeynumToStringBuf -93
-equ trap_Key_GetBindingBuf -94
-equ trap_Key_SetBinding -95
+equ trap_R_SetClipRegion -47
+equ trap_R_DrawStretchPic -48
+equ trap_R_ModelBounds -49
+equ trap_R_LerpTag -50
+equ trap_GetGlconfig -51
+equ trap_GetGameState -52
+equ trap_GetCurrentSnapshotNumber -53
+equ trap_GetSnapshot -54
+equ trap_GetServerCommand -55
+equ trap_GetCurrentCmdNumber -56
+equ trap_GetUserCmd -57
+equ trap_SetUserCmdValue -58
+equ trap_R_RegisterShaderNoMip -59
+equ trap_MemoryRemaining -60
+equ trap_R_RegisterFont -61
+equ trap_Key_IsDown -62
+equ trap_Key_GetCatcher -63
+equ trap_Key_SetCatcher -64
+equ trap_Key_GetKey -65
+equ trap_S_StopBackgroundTrack -66
+equ trap_RealTime -67
+equ trap_SnapVector -68
+equ trap_RemoveCommand -69
+equ trap_R_LightForPoint -70
+equ trap_CIN_PlayCinematic -71
+equ trap_CIN_StopCinematic -72
+equ trap_CIN_RunCinematic -73
+equ trap_CIN_DrawCinematic -74
+equ trap_CIN_SetExtents -75
+equ trap_R_RemapShader -76
+equ trap_S_AddRealLoopingSound -77
+equ trap_S_StopLoopingSound -78
+equ trap_CM_TempCapsuleModel -79
+equ trap_CM_CapsuleTrace -80
+equ trap_CM_TransformedCapsuleTrace -81
+equ trap_R_AddAdditiveLightToScene -82
+equ trap_GetEntityToken -83
+equ trap_R_AddPolysToScene -84
+equ trap_R_inPVS -85
+equ trap_FS_Seek -86
+equ trap_FS_GetFileList -87
+equ trap_LiteralArgs -88
+equ trap_CM_BiSphereTrace -89
+equ trap_CM_TransformedBiSphereTrace -90
+equ trap_GetDemoState -91
+equ trap_GetDemoPos -92
+equ trap_GetDemoName -93
+equ trap_Key_KeynumToStringBuf -94
+equ trap_Key_GetBindingBuf -95
+equ trap_Key_SetBinding -96
-equ trap_Parse_AddGlobalDefine -96
-equ trap_Parse_LoadSource -97
-equ trap_Parse_FreeSource -98
-equ trap_Parse_ReadToken -99
-equ trap_Parse_SourceFileAndLine -100
-equ trap_Key_SetOverstrikeMode -101
-equ trap_Key_GetOverstrikeMode -102
+equ trap_Parse_AddGlobalDefine -97
+equ trap_Parse_LoadSource -98
+equ trap_Parse_FreeSource -99
+equ trap_Parse_ReadToken -100
+equ trap_Parse_SourceFileAndLine -101
+equ trap_Key_SetOverstrikeMode -102
+equ trap_Key_GetOverstrikeMode -103
-equ trap_S_SoundDuration -103
+equ trap_S_SoundDuration -104
equ memset -201
equ memcpy -202
diff --git a/src/cgame/cg_syscalls.c b/src/cgame/cg_syscalls.c
index f7258efb..2c09134b 100644
--- a/src/cgame/cg_syscalls.c
+++ b/src/cgame/cg_syscalls.c
@@ -380,6 +380,11 @@ void trap_R_SetColor( const float *rgba )
syscall( CG_R_SETCOLOR, rgba );
}
+void trap_R_SetClipRegion( const float *region )
+{
+ syscall( CG_R_SETCLIPREGION, region );
+}
+
void trap_R_DrawStretchPic( float x, float y, float w, float h,
float s1, float t1, float s2, float t2, qhandle_t hShader )
{