diff --git a/cl_dll/MOTD.cpp b/cl_dll/MOTD.cpp index 3dd1371..5ba5fa5 100644 --- a/cl_dll/MOTD.cpp +++ b/cl_dll/MOTD.cpp @@ -28,9 +28,6 @@ DECLARE_MESSAGE( m_MOTD, MOTD ); -float fStartTime; -int iMaxLength; -extern float scale; int CHudMOTD :: Init( void ) { gHUD.AddHudElem( this ); @@ -48,8 +45,6 @@ int CHudMOTD :: Init( void ) int CHudMOTD :: VidInit( void ) { // Load sprites here - scale = gEngfuncs.pfnGetCvarFloat("hud_scale"); - if(scale <= 0.01) scale = 1; return 1; } @@ -60,36 +55,35 @@ void CHudMOTD :: Reset( void ) m_iLines = 0; m_bShow = 0; } -void DarkSquare( int x, int y, int wide, int tall ) -{ - gEngfuncs.pTriAPI->RenderMode( kRenderTransTexture ); - gEngfuncs.pTriAPI->Begin(TRI_QUADS); - gEngfuncs.pTriAPI->Color4f(0.0, 0.0, 0.0, 0.6); - gEngfuncs.pTriAPI->Vertex3f(x * scale, (y+tall)*scale, 0); - gEngfuncs.pTriAPI->Vertex3f(x * scale, y*scale, 0); - gEngfuncs.pTriAPI->Vertex3f((x + wide)*scale, y*scale, 0); - gEngfuncs.pTriAPI->Vertex3f((x + wide)*scale, (y+tall)*scale, 0); - gEngfuncs.pTriAPI->End(); - FillRGBA( x+1, y, wide-1, 1, 255, 140, 0, 255 ); - FillRGBA( x, y, 1, tall-1, 255, 140, 0, 255 ); - FillRGBA( x+wide-1, y+1, 1, tall-1, 255, 140, 0, 255 ); - FillRGBA( x, y+tall-1, wide-1, 1, 255, 140, 0, 255 ); -} #define LINE_HEIGHT 13 #define ROW_GAP 13 -#define ROW_RANGE_MIN 15 -#define ROW_RANGE_MAX ( ScreenHeight - 50 ) +#define ROW_RANGE_MIN 30 +#define ROW_RANGE_MAX ( ScreenHeight - 100 ) int CHudMOTD :: Draw( float fTime ) { + bool bScroll; // find the top of where the MOTD should be drawn, so the whole thing is centered in the screen - int ypos = ROW_RANGE_MIN + 3 + scroll; // shift it up slightly + int ypos = (ScreenHeight - LINE_HEIGHT * m_iLines)/2; // shift it up slightly char *ch = m_szMOTD; - int xpos = (ScreenWidth - gHUD.m_scrinfo.charWidths[ 'M' ] * iMaxLength) / 2; + int xpos = (ScreenWidth - gHUD.m_scrinfo.charWidths[ 'M' ] * m_iMaxLength) / 2; if( xpos < 30 ) xpos = 30; - int xmax = xpos + gHUD.m_scrinfo.charWidths[ 'M' ] * iMaxLength; + int xmax = xpos + gHUD.m_scrinfo.charWidths[ 'M' ] * m_iMaxLength; + int height = LINE_HEIGHT * m_iLines; + int ypos_r=ypos; + if( height > ROW_RANGE_MAX ) + { + ypos = ROW_RANGE_MIN + 3 + scroll; + if( ypos > ROW_RANGE_MIN ) + scroll-=7; + if( ypos + height < ROW_RANGE_MAX ) + scroll+=7; + ypos_r = ROW_RANGE_MIN; + height = ROW_RANGE_MAX; + } + int ymax = ypos + height; if( xmax > ScreenWidth - 30 ) xmax = ScreenWidth - 30; - DarkSquare(xpos-5, ROW_RANGE_MIN-5, xmax - xpos+10, ROW_RANGE_MAX + 23); + gHUD.DrawDarkRectangle(xpos-5, ypos_r - 5, xmax - xpos+10, height + 10); while ( *ch ) { int line_length = 0; // count the length of the current line @@ -102,7 +96,7 @@ int CHudMOTD :: Draw( float fTime ) top = NULL; // find where to start drawing the line - if( ypos > ROW_RANGE_MIN && ypos < ROW_RANGE_MAX ) + if( (ypos > ROW_RANGE_MIN) && (ypos + LINE_HEIGHT <= ypos_r + height) ) gHUD.DrawHudString( xpos, ypos, xmax, ch, 255, 180, 0 ); ypos += LINE_HEIGHT; @@ -136,7 +130,7 @@ int CHudMOTD :: MsgFunc_MOTD( const char *pszName, int iSize, void *pbuf ) { int length = 0; - iMaxLength = 0; + m_iMaxLength = 0; m_iFlags |= HUD_ACTIVE; @@ -145,14 +139,21 @@ int CHudMOTD :: MsgFunc_MOTD( const char *pszName, int iSize, void *pbuf ) if ( *sz == '\n' ) { m_iLines++; - if( length > iMaxLength ) + if( length > m_iMaxLength ) { - iMaxLength = length; + m_iMaxLength = length; length = 0; } } length++; } + + m_iLines++; + if( length > m_iMaxLength ) + { + m_iMaxLength = length; + length = 0; + } m_bShow = true; } diff --git a/cl_dll/death.cpp b/cl_dll/death.cpp index 839ffd1..7bb589b 100644 --- a/cl_dll/death.cpp +++ b/cl_dll/death.cpp @@ -112,7 +112,7 @@ int CHudDeathNotice :: Draw( float flTime ) // Hide when scoreboard drawing. It will break triapi //if ( gViewPort && gViewPort->AllowedToPrintText() ) - if ( !gHUD.m_Scoreboard.m_iShowscoresHeld && gHUD.m_Health.m_iHealth > 0 && !gHUD.m_iIntermission ) + if ( !gHUD.m_Scoreboard.m_iShowscoresHeld && gHUD.m_Health.m_iHealth > 0 && !gHUD.m_iIntermission && !gHUD.m_MOTD.m_bShow ) { // Draw the death notice y = YRES(DEATHNOTICE_TOP) + 2 + (20 * i); //!!! diff --git a/cl_dll/hud.cpp b/cl_dll/hud.cpp index d762a5d..e9be621 100644 --- a/cl_dll/hud.cpp +++ b/cl_dll/hud.cpp @@ -400,6 +400,10 @@ void CHud :: VidInit( void ) // assumption: number_1, number_2, etc, are all listed and loaded sequentially m_HUD_number_0 = GetSpriteIndex( "number_0" ); + m_flScale = gEngfuncs.pfnGetCvarFloat("hud_scale"); + if(m_flScale < 0.01) + m_flScale = 1; + m_iFontHeight = m_rgrcRects[m_HUD_number_0].bottom - m_rgrcRects[m_HUD_number_0].top; m_Ammo.VidInit(); diff --git a/cl_dll/hud.h b/cl_dll/hud.h index 45ce6ef..8599f3b 100644 --- a/cl_dll/hud.h +++ b/cl_dll/hud.h @@ -228,6 +228,7 @@ protected: char m_szMOTD[ MAX_MOTD_LENGTH ]; int m_iLines; + int m_iMaxLength; }; @@ -601,6 +602,7 @@ public: int m_iFOV; int m_Teamplay; int m_iRes; + float m_flScale; cvar_t *m_pCvarStealMouse; cvar_t *m_pCvarDraw; @@ -610,6 +612,7 @@ public: int DrawHudStringReverse( int xpos, int ypos, int iMinX, char *szString, int r, int g, int b ); int DrawHudNumberString( int xpos, int ypos, int iMinX, int iNumber, int r, int g, int b ); int GetNumWidth(int iNumber, int iFlags); + void DrawDarkRectangle( int x, int y, int wide, int tall); private: // the memory for these arrays are allocated in the first call to CHud::VidInit(), when the hud.txt and associated sprites are loaded. diff --git a/cl_dll/hud_redraw.cpp b/cl_dll/hud_redraw.cpp index a6e4be6..a74e164 100644 --- a/cl_dll/hud_redraw.cpp +++ b/cl_dll/hud_redraw.cpp @@ -18,6 +18,7 @@ #include #include "hud.h" #include "cl_util.h" +#include "triangleapi.h" #define MAX_LOGO_FRAMES 56 @@ -346,4 +347,19 @@ int CHud::GetNumWidth( int iNumber, int iFlags ) } +void CHud::DrawDarkRectangle( int x, int y, int wide, int tall ) +{ + gEngfuncs.pTriAPI->RenderMode( kRenderTransTexture ); + gEngfuncs.pTriAPI->Begin(TRI_QUADS); + gEngfuncs.pTriAPI->Color4f(0.0, 0.0, 0.0, 0.6); + gEngfuncs.pTriAPI->Vertex3f(x * m_flScale, (y+tall)*m_flScale, 0); + gEngfuncs.pTriAPI->Vertex3f(x * m_flScale, y*m_flScale, 0); + gEngfuncs.pTriAPI->Vertex3f((x + wide)*m_flScale, y*m_flScale, 0); + gEngfuncs.pTriAPI->Vertex3f((x + wide)*m_flScale, (y+tall)*m_flScale, 0); + gEngfuncs.pTriAPI->End(); + FillRGBA( x+1, y, wide-1, 1, 255, 140, 0, 255 ); + FillRGBA( x, y, 1, tall-1, 255, 140, 0, 255 ); + FillRGBA( x+wide-1, y+1, 1, tall-1, 255, 140, 0, 255 ); + FillRGBA( x, y+tall-1, wide-1, 1, 255, 140, 0, 255 ); +} diff --git a/cl_dll/input_xash3d.cpp b/cl_dll/input_xash3d.cpp index 60a415f..c3737c8 100644 --- a/cl_dll/input_xash3d.cpp +++ b/cl_dll/input_xash3d.cpp @@ -184,9 +184,10 @@ void IN_Move( float frametime, usercmd_t *cmd ) viewangles[YAW] -= ac_sidemove * 5; ac_sidemove = 0; } - + if(gHUD.m_MOTD.m_bShow) + gHUD.m_MOTD.scroll += rel_pitch; + else viewangles[PITCH] += rel_pitch; - //viewangles[PITCH] = bound( -cl_pitchup->value, viewangles[PITCH], cl_pitchdown->value ); if (viewangles[PITCH] > cl_pitchdown->value) viewangles[PITCH] = cl_pitchdown->value; if (viewangles[PITCH] < -cl_pitchup->value) diff --git a/cl_dll/scoreboard.cpp b/cl_dll/scoreboard.cpp index d19d3a5..e0cf2f0 100644 --- a/cl_dll/scoreboard.cpp +++ b/cl_dll/scoreboard.cpp @@ -36,8 +36,6 @@ int g_iUser3; int g_iTeamNumber; int g_iPlayerClass; -float scale; - //#include "vgui_TeamFortressViewport.h" DECLARE_COMMAND( m_Scoreboard, ShowScores ); @@ -70,8 +68,6 @@ int CHudScoreboard :: Init( void ) int CHudScoreboard :: VidInit( void ) { // Load sprites here - scale = gEngfuncs.pfnGetCvarFloat("hud_scale"); - if(scale <= 0.01) scale = 1; return 1; } @@ -147,19 +143,7 @@ int CHudScoreboard :: Draw( float fTime ) FAR_RIGHT = can_show_packetloss ? PL_RANGE_MAX : PING_RANGE_MAX; FAR_RIGHT += 5; - - gEngfuncs.pTriAPI->RenderMode( kRenderTransTexture ); - gEngfuncs.pTriAPI->Begin(TRI_QUADS); - gEngfuncs.pTriAPI->Color4f(0.0, 0.0, 0.0, 0.6); - gEngfuncs.pTriAPI->Vertex3f((xpos - 5)*scale, (ROW_RANGE_MAX - ypos)*scale, 0); - gEngfuncs.pTriAPI->Vertex3f((xpos - 5)*scale, (ypos - 5)*scale, 0); - gEngfuncs.pTriAPI->Vertex3f((FAR_RIGHT + xpos - 5)*scale, (ypos - 5)*scale, 0); - gEngfuncs.pTriAPI->Vertex3f((FAR_RIGHT + xpos - 5)*scale, (ROW_RANGE_MAX - ypos)*scale, 0); - gEngfuncs.pTriAPI->End(); - FillRGBA( xpos - 5, ypos - 5, FAR_RIGHT, 1, 255, 140, 0, 255 ); - FillRGBA( xpos - 5, ypos - 4, 1, ROW_RANGE_MAX - ypos * 2 + 3, 255, 140, 0, 255 ); - FillRGBA( FAR_RIGHT + xpos - 6, ypos - 4, 1, ROW_RANGE_MAX - ypos * 2 + 3, 255, 140, 0, 255 ); - FillRGBA( xpos - 5, ROW_RANGE_MAX - ypos - 1, FAR_RIGHT, 1, 255, 140, 0, 255 ); + gHUD.DrawDarkRectangle(xpos - 5, ypos - 5, FAR_RIGHT, ROW_RANGE_MAX); if ( !gHUD.m_Teamplay ) gHUD.DrawHudString( xpos, ypos, NAME_RANGE_MAX + xpos_rel, "Player", 255, 140, 0 ); else @@ -201,8 +185,8 @@ int CHudScoreboard :: Draw( float fTime ) // recalc the team scores, then draw them for ( i = 1; i < MAX_PLAYERS; i++ ) { - if ( g_PlayerInfoList[i].name == NULL ) - continue; // empty player slot, skip + //if ( g_PlayerInfoList[i].name == NULL ) + // continue; // empty player slot, skip if ( g_PlayerExtraInfo[i].teamname[0] == 0 ) continue; // skip over players who are not in a team @@ -517,8 +501,8 @@ int CHudScoreboard :: MsgFunc_TeamInfo( const char *pszName, int iSize, void *pb m_iNumTeams = 0; for ( i = 1; i < MAX_PLAYERS; i++ ) { - if ( g_PlayerInfoList[i].name == NULL ) - continue; + //if ( g_PlayerInfoList[i].name == NULL ) + // continue; if ( g_PlayerExtraInfo[i].teamname[0] == 0 ) continue; // skip over players who are not in a team