[iortcw] 418/497: SP: Initial commit for fixed aspect HUD (Based on ZTM's flexible HUD mod)

2017-09-08 Thread Simon McVittie
This is an automated email from the git hooks/post-receive script.

smcv pushed a commit to annotated tag 1.42d
in repository iortcw.

commit 2d97b71dc8552043c44676420bb713aa1c50c507
Author: MAN-AT-ARMS 
Date:   Wed Nov 4 16:04:28 2015 -0500

SP: Initial commit for fixed aspect HUD (Based on ZTM's flexible HUD mod)
---
 SP/code/cgame/cg_draw.c   | 223 ++
 SP/code/cgame/cg_drawtools.c  | 142 +++
 SP/code/cgame/cg_local.h  |  24 -
 SP/code/cgame/cg_main.c   |  31 +-
 SP/code/cgame/cg_newdraw.c|   4 +
 SP/code/cgame/cg_scoreboard.c |  24 -
 SP/code/cgame/cg_view.c   |  49 ++
 SP/code/cgame/cg_weapons.c|  31 --
 8 files changed, 431 insertions(+), 97 deletions(-)

diff --git a/SP/code/cgame/cg_draw.c b/SP/code/cgame/cg_draw.c
index e9b0c3b..a39437e 100644
--- a/SP/code/cgame/cg_draw.c
+++ b/SP/code/cgame/cg_draw.c
@@ -603,9 +603,18 @@ void CG_DrawTeamBackground( int x, int y, int w, int h, 
float alpha, int team )
} else {
return;
}
-   trap_R_SetColor( hcolor );
-   CG_DrawPic( x, y, w, h, cgs.media.teamStatusBar );
-   trap_R_SetColor( NULL );
+
+   if ( cg_fixedAspect.integer ) {
+   trap_R_SetColor( hcolor );
+   CG_SetScreenPlacement(PLACE_STRETCH, 
CG_GetScreenVerticalPlacement());
+   CG_DrawPic( x, y, w, h, cgs.media.teamStatusBar );
+   CG_PopScreenPlacement();
+   trap_R_SetColor( NULL );
+   } else {
+   trap_R_SetColor( hcolor );
+   CG_DrawPic( x, y, w, h, cgs.media.teamStatusBar );
+   trap_R_SetColor( NULL );
+   }
 }
 
 //
@@ -1490,10 +1499,15 @@ static void CG_DrawTeamInfo( void ) {
} else {
chatHeight = TEAMCHAT_HEIGHT;
}
+
if ( chatHeight <= 0 ) {
return; // disabled
+   }
 
+   if ( cg_fixedAspect.integer ) {
+   CG_SetScreenPlacement( PLACE_LEFT, PLACE_BOTTOM );
}
+
if ( cgs.teamLastChatPos != cgs.teamChatPos ) {
if ( cg.time - cgs.teamChatMsgTimes[cgs.teamLastChatPos % 
chatHeight] > cg_teamChatTime.integer ) {
cgs.teamLastChatPos++;
@@ -1664,6 +1678,11 @@ static void CG_DrawReward( void ) {
if ( !cg_drawRewards.integer ) {
return;
}
+
+   if ( cg_fixedAspect.integer ) {
+   CG_SetScreenPlacement(PLACE_CENTER, PLACE_CENTER);
+   }
+
color = CG_FadeColor( cg.rewardTime, REWARD_TIME );
if ( !color ) {
return;
@@ -1762,6 +1781,10 @@ static void CG_DrawDisconnect( void ) {
return;
}
 
+   if ( cg_fixedAspect.integer ) {
+   CG_SetScreenPlacement(PLACE_CENTER, PLACE_CENTER);
+   }
+
// also add text in center of screen
s = "Connection Interrupted"; // bk 010215 - FIXME
w = CG_DrawStrlen( s ) * BIGCHAR_WIDTH;
@@ -1772,6 +1795,10 @@ static void CG_DrawDisconnect( void ) {
return;
}
 
+   if ( cg_fixedAspect.integer ) {
+   CG_SetScreenPlacement(PLACE_RIGHT, PLACE_BOTTOM);
+   }
+
x = 640 - 48;
y = 480 - 48;
 
@@ -1800,6 +1827,10 @@ static void CG_DrawLagometer( void ) {
return;
}
 
+   if ( cg_fixedAspect.integer ) {
+   CG_SetScreenPlacement(PLACE_RIGHT, PLACE_BOTTOM);
+   }
+
//
// draw the graph
//
@@ -1955,6 +1986,10 @@ static void CG_DrawCenterString( void ) {
return;
}
 
+   if ( cg_fixedAspect.integer ) {
+   CG_SetScreenPlacement(PLACE_CENTER, PLACE_CENTER);
+   }
+
trap_R_SetColor( color );
 
start = cg.centerPrint;
@@ -2021,6 +2056,7 @@ static void CG_DrawWeapReticle( void ) {
vec4_t snoopercolor = {0.7, .8, 0.7, 0};// greenish
float snooperBrightness;
float x = 80, y, w = 240, h = 240;
+   float width = 80.0;
 
CG_AdjustFrom640( &x, &y, &w, &h );
 
@@ -2033,13 +2069,26 @@ static void CG_DrawWeapReticle( void ) {
 
 
if ( weap == WP_SNIPERRIFLE ) {
-
-
// sides
-   CG_FillRect( 0, 0, 80, 480, color );
-   CG_FillRect( 560, 0, 80, 480, color );
+   if ( cg_fixedAspect.integer ) {
+   if ( cgs.glconfig.vidWidth * 480 > 
cgs.glconfig.vidHeight * 640 ) {
+   width = 0.5 * ( ( cgs.glconfig.vidWidth - ( 
min( cgs.screenXScale, cgs.screenYScale ) * 480 ) ) / min( cgs.screenXScale, 
cgs.screenYScale ) );
+   }
+
+   CG_SetScreenPlacement(PLACE_LEFT, PLACE_BOTTOM);
+   CG_FillRect( 0, 0, width, 480, color );
+   CG_SetScreenPlacement(PLACE_RIGHT, PLACE_BOTTOM);
+   CG_FillRect( 640-width, 0, width, 480, co

[iortcw] 418/497: SP: Initial commit for fixed aspect HUD (Based on ZTM's flexible HUD mod)

2016-09-21 Thread Simon McVittie
This is an automated email from the git hooks/post-receive script.

smcv pushed a commit to annotated tag 1.42d
in repository iortcw.

commit 2d97b71dc8552043c44676420bb713aa1c50c507
Author: MAN-AT-ARMS 
Date:   Wed Nov 4 16:04:28 2015 -0500

SP: Initial commit for fixed aspect HUD (Based on ZTM's flexible HUD mod)
---
 SP/code/cgame/cg_draw.c   | 223 ++
 SP/code/cgame/cg_drawtools.c  | 142 +++
 SP/code/cgame/cg_local.h  |  24 -
 SP/code/cgame/cg_main.c   |  31 +-
 SP/code/cgame/cg_newdraw.c|   4 +
 SP/code/cgame/cg_scoreboard.c |  24 -
 SP/code/cgame/cg_view.c   |  49 ++
 SP/code/cgame/cg_weapons.c|  31 --
 8 files changed, 431 insertions(+), 97 deletions(-)

diff --git a/SP/code/cgame/cg_draw.c b/SP/code/cgame/cg_draw.c
index e9b0c3b..a39437e 100644
--- a/SP/code/cgame/cg_draw.c
+++ b/SP/code/cgame/cg_draw.c
@@ -603,9 +603,18 @@ void CG_DrawTeamBackground( int x, int y, int w, int h, 
float alpha, int team )
} else {
return;
}
-   trap_R_SetColor( hcolor );
-   CG_DrawPic( x, y, w, h, cgs.media.teamStatusBar );
-   trap_R_SetColor( NULL );
+
+   if ( cg_fixedAspect.integer ) {
+   trap_R_SetColor( hcolor );
+   CG_SetScreenPlacement(PLACE_STRETCH, 
CG_GetScreenVerticalPlacement());
+   CG_DrawPic( x, y, w, h, cgs.media.teamStatusBar );
+   CG_PopScreenPlacement();
+   trap_R_SetColor( NULL );
+   } else {
+   trap_R_SetColor( hcolor );
+   CG_DrawPic( x, y, w, h, cgs.media.teamStatusBar );
+   trap_R_SetColor( NULL );
+   }
 }
 
 //
@@ -1490,10 +1499,15 @@ static void CG_DrawTeamInfo( void ) {
} else {
chatHeight = TEAMCHAT_HEIGHT;
}
+
if ( chatHeight <= 0 ) {
return; // disabled
+   }
 
+   if ( cg_fixedAspect.integer ) {
+   CG_SetScreenPlacement( PLACE_LEFT, PLACE_BOTTOM );
}
+
if ( cgs.teamLastChatPos != cgs.teamChatPos ) {
if ( cg.time - cgs.teamChatMsgTimes[cgs.teamLastChatPos % 
chatHeight] > cg_teamChatTime.integer ) {
cgs.teamLastChatPos++;
@@ -1664,6 +1678,11 @@ static void CG_DrawReward( void ) {
if ( !cg_drawRewards.integer ) {
return;
}
+
+   if ( cg_fixedAspect.integer ) {
+   CG_SetScreenPlacement(PLACE_CENTER, PLACE_CENTER);
+   }
+
color = CG_FadeColor( cg.rewardTime, REWARD_TIME );
if ( !color ) {
return;
@@ -1762,6 +1781,10 @@ static void CG_DrawDisconnect( void ) {
return;
}
 
+   if ( cg_fixedAspect.integer ) {
+   CG_SetScreenPlacement(PLACE_CENTER, PLACE_CENTER);
+   }
+
// also add text in center of screen
s = "Connection Interrupted"; // bk 010215 - FIXME
w = CG_DrawStrlen( s ) * BIGCHAR_WIDTH;
@@ -1772,6 +1795,10 @@ static void CG_DrawDisconnect( void ) {
return;
}
 
+   if ( cg_fixedAspect.integer ) {
+   CG_SetScreenPlacement(PLACE_RIGHT, PLACE_BOTTOM);
+   }
+
x = 640 - 48;
y = 480 - 48;
 
@@ -1800,6 +1827,10 @@ static void CG_DrawLagometer( void ) {
return;
}
 
+   if ( cg_fixedAspect.integer ) {
+   CG_SetScreenPlacement(PLACE_RIGHT, PLACE_BOTTOM);
+   }
+
//
// draw the graph
//
@@ -1955,6 +1986,10 @@ static void CG_DrawCenterString( void ) {
return;
}
 
+   if ( cg_fixedAspect.integer ) {
+   CG_SetScreenPlacement(PLACE_CENTER, PLACE_CENTER);
+   }
+
trap_R_SetColor( color );
 
start = cg.centerPrint;
@@ -2021,6 +2056,7 @@ static void CG_DrawWeapReticle( void ) {
vec4_t snoopercolor = {0.7, .8, 0.7, 0};// greenish
float snooperBrightness;
float x = 80, y, w = 240, h = 240;
+   float width = 80.0;
 
CG_AdjustFrom640( &x, &y, &w, &h );
 
@@ -2033,13 +2069,26 @@ static void CG_DrawWeapReticle( void ) {
 
 
if ( weap == WP_SNIPERRIFLE ) {
-
-
// sides
-   CG_FillRect( 0, 0, 80, 480, color );
-   CG_FillRect( 560, 0, 80, 480, color );
+   if ( cg_fixedAspect.integer ) {
+   if ( cgs.glconfig.vidWidth * 480 > 
cgs.glconfig.vidHeight * 640 ) {
+   width = 0.5 * ( ( cgs.glconfig.vidWidth - ( 
min( cgs.screenXScale, cgs.screenYScale ) * 480 ) ) / min( cgs.screenXScale, 
cgs.screenYScale ) );
+   }
+
+   CG_SetScreenPlacement(PLACE_LEFT, PLACE_BOTTOM);
+   CG_FillRect( 0, 0, width, 480, color );
+   CG_SetScreenPlacement(PLACE_RIGHT, PLACE_BOTTOM);
+   CG_FillRect( 640-width, 0, width, 480, co