[iortcw] 450/497: MP: Initial fixed aspect stuff for UI / Placement fixes SP: Move ui_fixedAspect cvar declaration

Simon McVittie smcv at debian.org
Fri Sep 8 10:37:49 UTC 2017


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 cd010c9440a5919049ba2fa3e4563fb9360f5df0
Author: MAN-AT-ARMS <M4N4T4RMS at gmail.com>
Date:   Wed Dec 2 11:37:02 2015 -0500

    MP: Initial fixed aspect stuff for UI / Placement fixes
    SP: Move ui_fixedAspect cvar declaration
---
 MP/code/cgame/cg_draw.c       | 130 +++++++++++++++--------------
 MP/code/cgame/cg_info.c       |   6 +-
 MP/code/cgame/cg_local.h      |  13 ---
 MP/code/cgame/cg_newdraw.c    |  10 ---
 MP/code/cgame/cg_scoreboard.c |  10 +--
 MP/code/cgame/cg_weapons.c    |   3 -
 MP/code/qcommon/q_shared.h    |  13 +++
 MP/code/ui/ui_atoms.c         |  23 -----
 MP/code/ui/ui_local.h         |   2 +
 MP/code/ui/ui_main.c          |  45 ++++++++--
 MP/code/ui/ui_shared.c        | 189 +++++++++++++++++++++++++++++++++++++++---
 MP/code/ui/ui_shared.h        |   9 ++
 SP/code/ui/ui_main.c          |   2 -
 SP/code/ui/ui_shared.c        |   1 -
 14 files changed, 313 insertions(+), 143 deletions(-)

diff --git a/MP/code/cgame/cg_draw.c b/MP/code/cgame/cg_draw.c
index c59645e..32c0ddd 100644
--- a/MP/code/cgame/cg_draw.c
+++ b/MP/code/cgame/cg_draw.c
@@ -511,18 +511,9 @@ void CG_DrawTeamBackground( int x, int y, int w, int h, float alpha, int team )
 	} else {
 		return;
 	}
-
-	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 );
-	}
+	trap_R_SetColor( hcolor );
+	CG_DrawPic( x, y, w, h, cgs.media.teamStatusBar );
+	trap_R_SetColor( NULL );
 }
 
 /*
@@ -876,8 +867,6 @@ static void CG_DrawUpperRight(stereoFrame_t stereoFrame) {
 
 	if ( cg_fixedAspect.integer == 2 ) {
 		CG_SetScreenPlacement(PLACE_RIGHT, PLACE_TOP);
-	} else if ( cg_fixedAspect.integer == 1 ) {
-		CG_SetScreenPlacement(PLACE_CENTER, PLACE_TOP);
 	}
 
 	if ( cgs.gametype >= GT_TEAM ) {
@@ -932,9 +921,7 @@ static void CG_DrawTeamInfo( void ) {
 
 	if ( cg_fixedAspect.integer == 2 ) {
 		CG_SetScreenPlacement( PLACE_LEFT, PLACE_BOTTOM );
-	} else if ( cg_fixedAspect.integer == 1 ) {
-		CG_SetScreenPlacement( PLACE_CENTER, PLACE_BOTTOM );
- 	}
+	}
 
 	if ( cgs.teamLastChatPos != cgs.teamChatPos ) {
 		if ( cg.time - cgs.teamChatMsgTimes[cgs.teamLastChatPos % chatHeight] > cg_teamChatTime.integer ) {
@@ -967,8 +954,11 @@ static void CG_DrawTeamInfo( void ) {
 			hcolor[3] = 0.33f * alphapercent;
 
 			trap_R_SetColor( hcolor );
-			CG_DrawPic( CHATLOC_X, CHATLOC_Y - ( cgs.teamChatPos - i ) * TINYCHAR_HEIGHT, 640, TINYCHAR_HEIGHT, cgs.media.teamStatusBar );
-
+			if ( cg_fixedAspect.integer == 2 ) {
+				CG_DrawPic( CHATLOC_X, CHATLOC_Y - ( cgs.teamChatPos - i ) * TINYCHAR_HEIGHT, cgs.glconfig.vidWidth, TINYCHAR_HEIGHT, cgs.media.teamStatusBar );
+			} else {
+				CG_DrawPic( CHATLOC_X, CHATLOC_Y - ( cgs.teamChatPos - i ) * TINYCHAR_HEIGHT, 640, TINYCHAR_HEIGHT, cgs.media.teamStatusBar );
+			}
 			hcolor[0] = hcolor[1] = hcolor[2] = 1.0;
 			hcolor[3] = alphapercent;
 			trap_R_SetColor( hcolor );
@@ -997,8 +987,6 @@ static void CG_DrawPickupItem( void ) {
 
 	if ( cg_fixedAspect.integer == 2 ) {
 		CG_SetScreenPlacement(PLACE_LEFT, PLACE_BOTTOM);
-	} else if ( cg_fixedAspect.integer == 1 ) {
-		CG_SetScreenPlacement(PLACE_CENTER, PLACE_CENTER);
 	}
 
 	value = cg.itemPickup;
@@ -1053,8 +1041,6 @@ static void CG_DrawNotify( void ) {
 
 	if ( cg_fixedAspect.integer == 2 ) {
 		CG_SetScreenPlacement(PLACE_LEFT, PLACE_TOP);
-	} else if ( cg_fixedAspect.integer == 1 ) {
-		CG_SetScreenPlacement(PLACE_CENTER, PLACE_TOP);
 	}
 
 	trap_Cvar_VariableStringBuffer( "con_notifytime", var, sizeof( var ) );
@@ -1195,12 +1181,12 @@ static void CG_DrawDisconnect( void ) {
 		return;
 	}
 
-	if ( cg_fixedAspect.integer ) {
+	if ( cg_fixedAspect.integer == 2 ) {
 		CG_SetScreenPlacement(PLACE_RIGHT, PLACE_BOTTOM);
 	}
 
-	x = 640 - 72;
-	y = 480 - 52;
+	x = 640 - 52;
+	y = 480 - 140;
 
 	CG_DrawPic( x, y, 48, 48, trap_R_RegisterShader( "gfx/2d/net.tga" ) );
 }
@@ -1229,14 +1215,12 @@ static void CG_DrawLagometer( void ) {
 
 	if ( cg_fixedAspect.integer == 2 ) {
 		CG_SetScreenPlacement(PLACE_RIGHT, PLACE_BOTTOM);
-	} else if ( cg_fixedAspect.integer == 1 ) {
-		CG_SetScreenPlacement(PLACE_CENTER, PLACE_BOTTOM);
 	}
 
 	//
 	// draw the graph
 	//
-	x = 640 - 55;
+	x = 640 - 52;
 	y = 480 - 140;
 
 	trap_R_SetColor( NULL );
@@ -1522,7 +1506,6 @@ CG_DrawWeapReticle
 static void CG_DrawWeapReticle( void ) {
 	qboolean snooper, sniper;
 	vec4_t color = {0, 0, 0, 1};
-	float width = 80.0;
 
 	// DHM - Nerve :: So that we will draw reticle
 	if ( cgs.gametype >= GT_WOLF && ( ( cg.snap->ps.pm_flags & PMF_FOLLOW ) || cg.demoPlayback ) ) {
@@ -1538,14 +1521,29 @@ static void CG_DrawWeapReticle( void ) {
 
 			// sides
 			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 ) );
+				if ( cgs.glconfig.vidWidth * 480.0 > cgs.glconfig.vidHeight * 640.0 ) {
+					float mask = 0.5 * ( ( cgs.glconfig.vidWidth - ( cgs.screenXScale * 480.0 ) ) / cgs.screenXScale );
+
+					CG_SetScreenPlacement(PLACE_LEFT, PLACE_CENTER);
+					CG_FillRect( 0, 0, mask, 480, color );
+					CG_SetScreenPlacement(PLACE_RIGHT, PLACE_CENTER);
+					CG_FillRect( 640 - mask, 0, mask, 480, color );
 				}
 
-				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, color );
+				// sides with letterbox
+				if ( cgs.glconfig.vidWidth * 480.0 < cgs.glconfig.vidHeight * 640.0 ) {
+					float lb = 0.5 * ( ( cgs.glconfig.vidHeight - ( cgs.screenYScale * 480.0 ) ) / cgs.screenYScale );
+
+					CG_SetScreenPlacement(PLACE_LEFT, PLACE_CENTER);
+					CG_FillRect( 0, 0, 80, 480, color );
+					CG_SetScreenPlacement(PLACE_RIGHT, PLACE_CENTER);
+					CG_FillRect( 560, 0, 80, 480, color );
+
+					CG_SetScreenPlacement(PLACE_LEFT, PLACE_BOTTOM);
+					CG_FillRect( 0, 480 - lb, 640, lb, color );
+					CG_SetScreenPlacement(PLACE_LEFT, PLACE_TOP);
+					CG_FillRect( 0, 0, 640, lb, color );
+				}
 			} else {
 				CG_FillRect( 0, 0, 80, 480, color );
 				CG_FillRect( 560, 0, 80, 480, color );
@@ -1571,14 +1569,29 @@ static void CG_DrawWeapReticle( void ) {
 
 			// sides
 			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 ) );
+				if ( cgs.glconfig.vidWidth * 480.0 > cgs.glconfig.vidHeight * 640.0 ) {
+					float mask = 0.5 * ( ( cgs.glconfig.vidWidth - ( cgs.screenXScale * 480.0 ) ) / cgs.screenXScale );
+
+					CG_SetScreenPlacement(PLACE_LEFT, PLACE_CENTER);
+					CG_FillRect( 0, 0, mask, 480, color );
+					CG_SetScreenPlacement(PLACE_RIGHT, PLACE_CENTER);
+					CG_FillRect( 640 - mask, 0, mask, 480, color );
 				}
 
-				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, color );
+				// sides with letterbox
+				if ( cgs.glconfig.vidWidth * 480.0 < cgs.glconfig.vidHeight * 640.0 ) {
+					float lb = 0.5 * ( ( cgs.glconfig.vidHeight - ( cgs.screenYScale * 480.0 ) ) / cgs.screenYScale );
+
+					CG_SetScreenPlacement(PLACE_LEFT, PLACE_CENTER);
+					CG_FillRect( 0, 0, 80, 480, color );
+					CG_SetScreenPlacement(PLACE_RIGHT, PLACE_CENTER);
+					CG_FillRect( 560, 0, 80, 480, color );
+
+					CG_SetScreenPlacement(PLACE_LEFT, PLACE_BOTTOM);
+					CG_FillRect( 0, 480 - lb, 640, lb, color );
+					CG_SetScreenPlacement(PLACE_LEFT, PLACE_TOP);
+					CG_FillRect( 0, 0, 640, lb, color );
+				}
 			} else {
 				CG_FillRect( 0, 0, 80, 480, color );
 				CG_FillRect( 560, 0, 80, 480, color );
@@ -2292,9 +2305,10 @@ CG_DrawSpectator
 =================
 */
 static void CG_DrawSpectator( void ) {
-	if ( cg_fixedAspect.integer ) {
+	if ( cg_fixedAspect.integer == 2 ) {
 		CG_SetScreenPlacement(PLACE_CENTER, PLACE_BOTTOM);
 	}
+
 	CG_DrawBigString( 320 - 9 * 8, 440, CG_TranslateString( "SPECTATOR" ), 1.0F );
 	if ( cgs.gametype == GT_TOURNAMENT ) {
 		CG_DrawBigString( 320 - 15 * 8, 460, "waiting to play", 1.0F );
@@ -2315,6 +2329,10 @@ static void CG_DrawVote( void ) {
 	float color[4] = { 1, 1, 0, 1 };
 	int sec;
 
+	if ( cg_fixedAspect.integer == 2 ) {
+		CG_SetScreenPlacement(PLACE_LEFT, PLACE_CENTER);
+	}
+
 	if ( cgs.complaintEndTime > cg.time ) {
 
 		if ( cgs.complaintClient == -1 ) {
@@ -2368,10 +2386,6 @@ static void CG_DrawVote( void ) {
 		Q_strncpyz( str2, "vote no", 32 );
 	}
 
-	if ( cg_fixedAspect.integer ) {
-		CG_SetScreenPlacement(PLACE_LEFT, PLACE_TOP);
-	}
-
 	// play a talk beep whenever it is modified
 	if ( cgs.voteModified ) {
 		cgs.voteModified = qfalse;
@@ -2596,8 +2610,6 @@ static qboolean CG_DrawFollow( void ) {
 
 	if ( cg_fixedAspect.integer == 2 ) {
 		CG_SetScreenPlacement(PLACE_LEFT, PLACE_TOP);
-	} else if ( cg_fixedAspect.integer == 1 ) {
-		CG_SetScreenPlacement(PLACE_CENTER, PLACE_TOP);
 	}
 
 	color[0] = 1;
@@ -2653,7 +2665,7 @@ static void CG_DrawWarmup( void ) {
 		return;     // (SA) don't bother with this stuff in sp
 	}
 
-	if ( cg_fixedAspect.integer ) {
+	if ( cg_fixedAspect.integer == 2 ) {
 		CG_SetScreenPlacement(PLACE_CENTER, PLACE_TOP);
 	}
 
@@ -2953,7 +2965,8 @@ static void CG_DrawFlashFire( void ) {
 		col[3] = alpha;
 		trap_R_SetColor( col );
 		if ( cg_fixedAspect.integer ) {
-			trap_R_DrawStretchPic( -10, -10, 650, 490, 0, 0, 1, 1, cgs.media.viewFlashFire[( cg.time / 50 ) % 16] );
+			CG_SetScreenPlacement(PLACE_STRETCH, PLACE_STRETCH);
+			CG_DrawPic( -10, -10, 650, 490, cgs.media.viewFlashFire[( cg.time / 50 ) % 16] );
 		} else {
 			CG_DrawPic( -10, -10, 650, 490, cgs.media.viewFlashFire[( cg.time / 50 ) % 16] );
 		}
@@ -2996,14 +3009,13 @@ static void CG_DrawFlashLightning( void ) {
 	}
 
 	if ( cg_fixedAspect.integer ) {
-		trap_R_DrawStretchPic( -10, -10, 650, 490, 0, 0, 1, 1, shader );
+		CG_SetScreenPlacement(PLACE_STRETCH, PLACE_STRETCH);
+		CG_DrawPic( -10, -10, 650, 490, shader );
 	} else {
 		CG_DrawPic( -10, -10, 650, 490, shader );
 	}
 }
 
-
-
 /*
 ==============
 CG_DrawFlashBlendBehindHUD
@@ -3213,8 +3225,6 @@ void CG_DrawObjectiveIcons( void ) {
 
 	if ( cg_fixedAspect.integer == 2 ) {
 		CG_SetScreenPlacement(PLACE_LEFT, PLACE_TOP);
-	} else if ( cg_fixedAspect.integer == 1 ) {
-		CG_SetScreenPlacement(PLACE_CENTER, PLACE_TOP);
 	}
 
 // JPW NERVE added round timer
@@ -3461,7 +3471,7 @@ void CG_Draw2D2( void ) {
 	hcolor[3] = cg_hudAlpha.value;
 	trap_R_SetColor( hcolor );
 
-	if ( cg_fixedAspect.integer ) {
+	if ( cg_fixedAspect.integer == 2 ) {
 		CG_SetScreenPlacement(PLACE_CENTER, PLACE_BOTTOM);
 	}
 
@@ -3552,7 +3562,7 @@ static void CG_DrawCompass( void ) {
 		return;
 	}
 
-	if ( cg_fixedAspect.integer ) {
+	if ( cg_fixedAspect.integer == 2 ) {
 		CG_SetScreenPlacement(PLACE_CENTER, PLACE_BOTTOM);
 	}
 
@@ -3709,8 +3719,6 @@ static void CG_Draw2D(stereoFrame_t stereoFrame) {
 		if ( cg_drawStatus.integer ) {
 			if ( cg_fixedAspect.integer == 2 ) {
 				CG_SetScreenPlacement(PLACE_LEFT, PLACE_BOTTOM);
-			} else if ( cg_fixedAspect.integer == 1 ) {
-				CG_SetScreenPlacement(PLACE_CENTER, PLACE_BOTTOM);
 			}
 
 			Menu_PaintAll();
@@ -3836,7 +3844,7 @@ void CG_DrawActive( stereoFrame_t stereoView ) {
 		h = LIMBO_3D_H;
 
 		cg.refdef.width = 0;
-		if ( cg_fixedAspect.integer ) {
+		if ( cg_fixedAspect.integer == 2 ) { //FIXME:MAN-AT-ARMS...Use correct view
 			cg.refdef.x = LIMBO_3D_X * cgs.screenXScaleStretch;
 			cg.refdef.y = LIMBO_3D_Y * cgs.screenYScaleStretch;
 			cg.refdef.width = LIMBO_3D_W * cgs.screenXScaleStretch;
diff --git a/MP/code/cgame/cg_info.c b/MP/code/cgame/cg_info.c
index b552182..e92ba51 100644
--- a/MP/code/cgame/cg_info.c
+++ b/MP/code/cgame/cg_info.c
@@ -260,11 +260,7 @@ void CG_DrawInformation( void ) {
 		levelshot = trap_R_RegisterShaderNoMip( "levelshots/unknownmap.jpg" );
 	}
 	trap_R_SetColor( NULL );
-	if ( cg_fixedAspect.integer ) {
-		trap_R_DrawStretchPic( 0, 0, cgs.glconfig.vidWidth, cgs.glconfig.vidHeight, 0, 0, 1, 1, levelshot );
-	} else {
-		CG_DrawPic( 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, levelshot );
-	}
+	CG_DrawPic( 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, levelshot );
 
 	// show the server motd
 	CG_DrawMotd();
diff --git a/MP/code/cgame/cg_local.h b/MP/code/cgame/cg_local.h
index 5176640..da54c9b 100644
--- a/MP/code/cgame/cg_local.h
+++ b/MP/code/cgame/cg_local.h
@@ -1823,19 +1823,6 @@ void CG_Concussive( centity_t *cent );
 //
 // cg_drawtools.c
 //
-typedef enum {
-	PLACE_STRETCH,
-	PLACE_CENTER,
-
-	// horizontal only
-	PLACE_LEFT,
-	PLACE_RIGHT,
-
-	// vertical only
-	PLACE_TOP,
-	PLACE_BOTTOM
-} screenPlacement_e;
-
 void CG_SetScreenPlacement(screenPlacement_e hpos, screenPlacement_e vpos);
 void CG_PopScreenPlacement(void);
 screenPlacement_e CG_GetScreenHorizontalPlacement(void);
diff --git a/MP/code/cgame/cg_newdraw.c b/MP/code/cgame/cg_newdraw.c
index 600d465..adf15f5 100644
--- a/MP/code/cgame/cg_newdraw.c
+++ b/MP/code/cgame/cg_newdraw.c
@@ -290,8 +290,6 @@ static void CG_DrawPlayerWeaponIcon( rectDef_t *rect, qboolean drawHighlighted,
 
 	if ( cg_fixedAspect.integer == 2 ) {
 		CG_SetScreenPlacement(PLACE_RIGHT, PLACE_BOTTOM);
-	} else if ( cg_fixedAspect.integer == 1 ) {
-		CG_SetScreenPlacement(PLACE_CENTER, PLACE_CENTER);
 	}
 
 	realweap = cg.predictedPlayerState.weapon;
@@ -659,8 +657,6 @@ static void CG_DrawPlayerAmmoValue( rectDef_t *rect, float scale, vec4_t color,
 
 	if ( cg_fixedAspect.integer == 2 ) {
 		CG_SetScreenPlacement(PLACE_RIGHT, PLACE_BOTTOM);
-	} else if ( cg_fixedAspect.integer == 1 ) {
-		CG_SetScreenPlacement(PLACE_CENTER, PLACE_CENTER);
 	}
 
 	switch ( weap ) {      // some weapons don't draw ammo count text
@@ -1109,8 +1105,6 @@ static void CG_DrawPlayerHealth( rectDef_t *rect, float scale, vec4_t color, qha
 
 	if ( cg_fixedAspect.integer == 2 ) {
 		CG_SetScreenPlacement(PLACE_LEFT, PLACE_BOTTOM);
-	} else if ( cg_fixedAspect.integer == 1 ) {
-		CG_SetScreenPlacement(PLACE_CENTER, PLACE_CENTER);
 	}
 
 	if ( shader ) {
@@ -2223,8 +2217,6 @@ void CG_DrawWeapHeat( rectDef_t *rect, int align ) {
 
 	if ( cg_fixedAspect.integer == 2 ) {
 		CG_SetScreenPlacement(PLACE_RIGHT, PLACE_BOTTOM);
-	} else if ( cg_fixedAspect.integer == 1 ) {
-		CG_SetScreenPlacement(PLACE_CENTER, PLACE_CENTER);
 	}
 
 	if ( align != HUD_HORIZONTAL ) {
@@ -2252,8 +2244,6 @@ static void CG_DrawFatigue( rectDef_t *rect, vec4_t color, int align ) {
 
 	if ( cg_fixedAspect.integer == 2 ) {
 		CG_SetScreenPlacement(PLACE_LEFT, PLACE_BOTTOM);
-	} else if ( cg_fixedAspect.integer == 1 ) {
-		CG_SetScreenPlacement(PLACE_CENTER, PLACE_CENTER);
 	}
 
 	if ( align != HUD_HORIZONTAL ) {
diff --git a/MP/code/cgame/cg_scoreboard.c b/MP/code/cgame/cg_scoreboard.c
index fd737f3..14a35cb 100644
--- a/MP/code/cgame/cg_scoreboard.c
+++ b/MP/code/cgame/cg_scoreboard.c
@@ -650,10 +650,6 @@ qboolean CG_DrawScoreboard( void ) {
 	float   *fadeColor;
 	char    *s;
 
-	if ( cg_fixedAspect.integer ) {
-		CG_SetScreenPlacement(PLACE_CENTER, PLACE_CENTER);
-	}
-
 	// don't draw anything if the menu or console is up
 	if ( cg_paused.integer ) {
 		cg.deferredPlayerLoading = 0;
@@ -670,6 +666,10 @@ qboolean CG_DrawScoreboard( void ) {
 		return qfalse;
 	}
 
+	if ( cg_fixedAspect.integer ) {
+		CG_SetScreenPlacement(PLACE_CENTER, PLACE_CENTER);
+	}
+
 	// NERVE - SMF - added mp wolf check
 	if ( cg.showScores || ( cg.predictedPlayerState.pm_type == PM_DEAD && cgs.gametype < GT_WOLF ) ||
 		 cg.predictedPlayerState.pm_type == PM_INTERMISSION ) {
@@ -864,7 +864,7 @@ void CG_DrawTourneyScoreboard( void ) {
 	 	color[3] = 1;
 		CG_SetScreenPlacement(PLACE_STRETCH, PLACE_STRETCH);
 		CG_FillRect( 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, color );
-		CG_PopScreenPlacement();
+		CG_SetScreenPlacement(PLACE_CENTER, PLACE_CENTER);
 	} else {
 		color[0] = color[1] = color[2] = 0;
 		color[3] = 1;
diff --git a/MP/code/cgame/cg_weapons.c b/MP/code/cgame/cg_weapons.c
index 30680b7..7908a63 100644
--- a/MP/code/cgame/cg_weapons.c
+++ b/MP/code/cgame/cg_weapons.c
@@ -2927,11 +2927,8 @@ void CG_DrawWeaponSelect( void ) {
 
 	if ( cg_fixedAspect.integer == 2 ) {
 		CG_SetScreenPlacement(PLACE_RIGHT, PLACE_BOTTOM);
-	} else if ( cg_fixedAspect.integer == 1 ) {
-		CG_SetScreenPlacement(PLACE_CENTER, PLACE_BOTTOM);
 	}
 
-
 //----(SA)	neither of these overlap the weapon selection area anymore, so let them stay
 	// showing weapon select clears pickup item display, but not the blend blob
 	cg.itemPickupTime = 0;
diff --git a/MP/code/qcommon/q_shared.h b/MP/code/qcommon/q_shared.h
index 583450d..1c01108 100644
--- a/MP/code/qcommon/q_shared.h
+++ b/MP/code/qcommon/q_shared.h
@@ -471,6 +471,19 @@ extern vec4_t g_color_table[8];
 #define DEG2RAD( a ) ( ( ( a ) * M_PI ) / 180.0F )
 #define RAD2DEG( a ) ( ( ( a ) * 180.0f ) / M_PI )
 
+typedef enum {
+	PLACE_STRETCH,
+	PLACE_CENTER,
+
+	// horizontal only
+	PLACE_LEFT,
+	PLACE_RIGHT,
+
+	// vertical only
+	PLACE_TOP,
+	PLACE_BOTTOM
+} screenPlacement_e;
+
 struct cplane_s;
 
 extern vec3_t vec3_origin;
diff --git a/MP/code/ui/ui_atoms.c b/MP/code/ui/ui_atoms.c
index 05b2d15..bbbd87d 100644
--- a/MP/code/ui/ui_atoms.c
+++ b/MP/code/ui/ui_atoms.c
@@ -450,29 +450,6 @@ UI_Shutdown
 void UI_Shutdown( void ) {
 }
 
-/*
-================
-UI_AdjustFrom640
-
-Adjusted for resolution and screen aspect ratio
-================
-*/
-void UI_AdjustFrom640( float *x, float *y, float *w, float *h ) {
-	// expect valid pointers
-#if 0
-	*x = *x * uiInfo.uiDC.scale + uiInfo.uiDC.bias;
-	*y *= uiInfo.uiDC.scale;
-	*w *= uiInfo.uiDC.scale;
-	*h *= uiInfo.uiDC.scale;
-#endif
-
-	*x *= uiInfo.uiDC.xscale;
-	*y *= uiInfo.uiDC.yscale;
-	*w *= uiInfo.uiDC.xscale;
-	*h *= uiInfo.uiDC.yscale;
-
-}
-
 void UI_DrawNamedPic( float x, float y, float width, float height, const char *picname ) {
 	qhandle_t hShader;
 
diff --git a/MP/code/ui/ui_local.h b/MP/code/ui/ui_local.h
index c6f32bc..bbd4dcf 100644
--- a/MP/code/ui/ui_local.h
+++ b/MP/code/ui/ui_local.h
@@ -74,6 +74,8 @@ extern vmCvar_t ui_autoactivate;
 extern vmCvar_t ui_emptyswitch;
 // END JOSEPH
 
+extern vmCvar_t ui_fixedAspect;
+
 extern vmCvar_t ui_server1;
 extern vmCvar_t ui_server2;
 extern vmCvar_t ui_server3;
diff --git a/MP/code/ui/ui_main.c b/MP/code/ui/ui_main.c
index cb7b5d3..00c002c 100644
--- a/MP/code/ui/ui_main.c
+++ b/MP/code/ui/ui_main.c
@@ -1600,6 +1600,7 @@ static void UI_DrawClanCinematic( rectDef_t *rect, float scale, vec4_t color ) {
 			}
 			if ( uiInfo.teamList[i].cinematic >= 0 ) {
 				trap_CIN_RunCinematic( uiInfo.teamList[i].cinematic );
+				//FIXME:MAN-AT-ARMS Scale this
 				trap_CIN_SetExtents( uiInfo.teamList[i].cinematic, rect->x, rect->y, rect->w, rect->h );
 				trap_CIN_DrawCinematic( uiInfo.teamList[i].cinematic );
 			} else {
@@ -1619,6 +1620,7 @@ static void UI_DrawPreviewCinematic( rectDef_t *rect, float scale, vec4_t color
 		uiInfo.previewMovie = trap_CIN_PlayCinematic( va( "%s.roq", uiInfo.movieList[uiInfo.movieIndex] ), 0, 0, 0, 0, ( CIN_loop | CIN_silent ) );
 		if ( uiInfo.previewMovie >= 0 ) {
 			trap_CIN_RunCinematic( uiInfo.previewMovie );
+			//FIXME:MAN-AT-ARMS Scale this
 			trap_CIN_SetExtents( uiInfo.previewMovie, rect->x, rect->y, rect->w, rect->h );
 			trap_CIN_DrawCinematic( uiInfo.previewMovie );
 		} else {
@@ -1743,8 +1745,9 @@ static void UI_DrawMapCinematic( rectDef_t *rect, float scale, vec4_t color, qbo
 		if ( uiInfo.mapList[map].cinematic == -1 ) {
 			uiInfo.mapList[map].cinematic = trap_CIN_PlayCinematic( va( "%s.roq", uiInfo.mapList[map].mapLoadName ), 0, 0, 0, 0, ( CIN_loop | CIN_silent ) );
 		}
-		if ( uiInfo.mapList[map].cinematic >= 0 ) {
+		if ( uiInfo.mapList[map].cinematic >= 0 ) { 
 			trap_CIN_RunCinematic( uiInfo.mapList[map].cinematic );
+			// FIXME:MAN-AT-ARMS Scale this
 			trap_CIN_SetExtents( uiInfo.mapList[map].cinematic, rect->x, rect->y, rect->w, rect->h );
 			trap_CIN_DrawCinematic( uiInfo.mapList[map].cinematic );
 		} else {
@@ -1872,6 +1875,7 @@ static void UI_DrawNetMapCinematic( rectDef_t *rect, float scale, vec4_t color )
 
 	if ( uiInfo.serverStatus.currentServerCinematic >= 0 ) {
 		trap_CIN_RunCinematic( uiInfo.serverStatus.currentServerCinematic );
+		// FIXME:MAN-AT-ARMS Scale this
 		trap_CIN_SetExtents( uiInfo.serverStatus.currentServerCinematic, rect->x, rect->y, rect->w, rect->h );
 		trap_CIN_DrawCinematic( uiInfo.serverStatus.currentServerCinematic );
 	} else {
@@ -6734,6 +6738,7 @@ static void UI_StopCinematic( int handle ) {
 }
 
 static void UI_DrawCinematic( int handle, float x, float y, float w, float h ) {
+	//FIXME:MAN-AT-ARMS Scale this
 	trap_CIN_SetExtents( handle, x, y, w, h );
 	trap_CIN_DrawCinematic( handle );
 }
@@ -6823,14 +6828,36 @@ void _UI_Init( qboolean inGameLoad ) {
 	trap_GetGlconfig( &uiInfo.uiDC.glconfig );
 
 	// for 640x480 virtualized screen
-	uiInfo.uiDC.yscale = uiInfo.uiDC.glconfig.vidHeight * ( 1.0 / 480.0 );
-	uiInfo.uiDC.xscale = uiInfo.uiDC.glconfig.vidWidth * ( 1.0 / 640.0 );
-	if ( uiInfo.uiDC.glconfig.vidWidth * 480 > uiInfo.uiDC.glconfig.vidHeight * 640 ) {
-		// wide screen
-		uiInfo.uiDC.bias = 0.5 * ( uiInfo.uiDC.glconfig.vidWidth - ( uiInfo.uiDC.glconfig.vidHeight * ( 640.0 / 480.0 ) ) );
+	if ( ui_fixedAspect.integer ) {
+		uiInfo.uiDC.xscaleStretch = uiInfo.uiDC.glconfig.vidWidth * (1.0/640.0);
+		uiInfo.uiDC.yscaleStretch = uiInfo.uiDC.glconfig.vidHeight * (1.0/480.0);
+		if ( uiInfo.uiDC.glconfig.vidWidth * 480 > uiInfo.uiDC.glconfig.vidHeight * 640 ) {
+			uiInfo.uiDC.xscale = uiInfo.uiDC.glconfig.vidWidth * (1.0/640.0);
+			uiInfo.uiDC.yscale = uiInfo.uiDC.glconfig.vidHeight * (1.0/480.0);
+			// wide screen
+			uiInfo.uiDC.xBias = 0.5 * ( uiInfo.uiDC.glconfig.vidWidth - ( uiInfo.uiDC.glconfig.vidHeight * (640.0/480.0) ) );
+			uiInfo.uiDC.xscale = uiInfo.uiDC.yscale;
+			// no narrow screen
+			uiInfo.uiDC.yBias = 0;
+		} else {
+			uiInfo.uiDC.xscale = uiInfo.uiDC.glconfig.vidWidth * (1.0/640.0);
+			uiInfo.uiDC.yscale = uiInfo.uiDC.glconfig.vidHeight * (1.0/480.0);
+			// narrow screen
+			uiInfo.uiDC.yBias = 0.5 * ( uiInfo.uiDC.glconfig.vidHeight - ( uiInfo.uiDC.glconfig.vidWidth * (480.0/640.0) ) );
+			uiInfo.uiDC.yscale = uiInfo.uiDC.xscale;
+			// no wide screen
+			uiInfo.uiDC.xBias = 0;
+		}
 	} else {
-		// no wide screen
-		uiInfo.uiDC.bias = 0;
+		uiInfo.uiDC.yscale = uiInfo.uiDC.glconfig.vidHeight * ( 1.0 / 480.0 );
+		uiInfo.uiDC.xscale = uiInfo.uiDC.glconfig.vidWidth * ( 1.0 / 640.0 );
+		if ( uiInfo.uiDC.glconfig.vidWidth * 480 > uiInfo.uiDC.glconfig.vidHeight * 640 ) {
+			// wide screen
+			uiInfo.uiDC.bias = 0.5 * ( uiInfo.uiDC.glconfig.vidWidth - ( uiInfo.uiDC.glconfig.vidHeight * ( 640.0 / 480.0 ) ) );
+		} else {
+			// no wide screen
+			uiInfo.uiDC.bias = 0;
+		}
 	}
 
 
@@ -7583,6 +7610,8 @@ cvarTable_t cvarTable[] = {
 	{ &ui_autoactivate, "cg_autoactivate", "1", CVAR_ARCHIVE },
 	// END JOSEPH
 
+	{ &ui_fixedAspect, "cg_fixedAspect", "0", CVAR_ARCHIVE | CVAR_LATCH },
+
 	{ &ui_server1, "server1", "", CVAR_ARCHIVE },
 	{ &ui_server2, "server2", "", CVAR_ARCHIVE },
 	{ &ui_server3, "server3", "", CVAR_ARCHIVE },
diff --git a/MP/code/ui/ui_shared.c b/MP/code/ui/ui_shared.c
index 4ac7285..8464b8d 100644
--- a/MP/code/ui/ui_shared.c
+++ b/MP/code/ui/ui_shared.c
@@ -94,6 +94,111 @@ static char memoryPool[MEM_POOL_SIZE];
 static int allocPoint, outOfMemory;
 
 
+static screenPlacement_e ui_horizontalPlacement = PLACE_CENTER;
+static screenPlacement_e ui_verticalPlacement = PLACE_CENTER;
+static screenPlacement_e ui_lastHorizontalPlacement = PLACE_CENTER;
+static screenPlacement_e ui_lastVerticalPlacement = PLACE_CENTER;
+
+/*
+================
+UI_SetScreenPlacement
+================
+*/
+void UI_SetScreenPlacement(screenPlacement_e hpos, screenPlacement_e vpos)
+{
+	ui_lastHorizontalPlacement = ui_horizontalPlacement;
+	ui_lastVerticalPlacement = ui_verticalPlacement;
+
+	ui_horizontalPlacement = hpos;
+	ui_verticalPlacement = vpos;
+}
+
+/*
+================
+UI_PopScreenPlacement
+================
+*/
+void UI_PopScreenPlacement(void)
+{
+	ui_horizontalPlacement = ui_lastHorizontalPlacement;
+	ui_verticalPlacement = ui_lastVerticalPlacement;
+}
+
+/*
+================
+UI_GetScreenHorizontalPlacement
+================
+*/
+screenPlacement_e UI_GetScreenHorizontalPlacement(void)
+{
+	return ui_horizontalPlacement;
+}
+
+/*
+================
+UI_GetScreenVerticalPlacement
+================
+*/
+screenPlacement_e UI_GetScreenVerticalPlacement(void)
+{
+	return ui_verticalPlacement;
+}
+
+vmCvar_t ui_fixedAspect;
+
+/*
+================
+UI_AdjustFrom640
+
+Adjusted for resolution and screen aspect ratio
+================
+*/
+void UI_AdjustFrom640( float *x, float *y, float *w, float *h ) {
+	// expect valid pointers
+#if 0
+	*x = *x * DC->scale + DC->bias;
+	*y *= DC->scale;
+	*w *= DC->scale;
+	*h *= DC->scale;
+#endif
+	if ( ui_fixedAspect.integer ) {
+		if (ui_horizontalPlacement == PLACE_STRETCH) {
+			// scale for screen sizes (not aspect correct in wide screen)
+			*w *= DC->xscaleStretch;
+			*x *= DC->xscaleStretch;
+		} else {
+			// scale for screen sizes
+			*w *= DC->xscale;
+			*x *= DC->xscale;
+	
+			if (ui_horizontalPlacement == PLACE_CENTER) {
+				*x += DC->xBias;
+			} else if (ui_horizontalPlacement == PLACE_RIGHT) {
+				*x += DC->xBias*2;
+			}
+		}
+
+		if (ui_verticalPlacement == PLACE_STRETCH) {
+			*h *= DC->yscaleStretch;
+			*y *= DC->yscaleStretch;
+		} else {
+			*h *= DC->yscale;
+			*y *= DC->yscale;
+	
+			if (ui_verticalPlacement == PLACE_CENTER) {
+				*y += DC->yBias;
+			} else if (ui_verticalPlacement == PLACE_BOTTOM) {
+				*y += DC->yBias*2;
+			}
+		}
+	} else {
+		*x *= DC->xscale;
+		*y *= DC->yscale;
+		*w *= DC->xscale;
+		*h *= DC->yscale;
+	}
+}
+
 /*
 ===============
 UI_Alloc
@@ -687,13 +792,44 @@ void Window_Paint( Window *w, float fadeAmount, float fadeClamp, float fadeCycle
 		fillRect.h -= w->borderSize + 1;
 	}
 
+	// Make pillarbox/letterbox for 4:3 UI
+	if ( ui_fixedAspect.integer == 1 || !Q_stricmpn( w->name, "wm_limbo", 8 ) ) {
+		vec4_t col = {0, 0, 0, 1};	
+		if ( DC->glconfig.vidWidth * 480.0 > DC->glconfig.vidHeight * 640.0 ) {
+			float pillar = 0.5 * ( ( DC->glconfig.vidWidth - ( DC->xscale * 640.0 ) ) / DC->xscale );
+
+			UI_SetScreenPlacement(PLACE_LEFT, PLACE_CENTER);
+			DC->fillRect( 0, 0, pillar + 1, 480, col );
+			UI_SetScreenPlacement(PLACE_RIGHT, PLACE_CENTER);
+			DC->fillRect( 640 - pillar, 0, pillar + 1, 480, col );
+			UI_SetScreenPlacement(PLACE_CENTER, PLACE_CENTER);
+		} else if ( DC->glconfig.vidWidth * 480.0 < DC->glconfig.vidHeight * 640.0 ) {
+			float lb = 0.5 * ( ( DC->glconfig.vidHeight - ( DC->yscale * 480.0 ) ) / DC->yscale );
+
+			UI_SetScreenPlacement(PLACE_LEFT, PLACE_BOTTOM);
+			DC->fillRect( 0, 480 - lb, 640, lb + 1, col );
+			UI_SetScreenPlacement(PLACE_LEFT, PLACE_TOP);
+			DC->fillRect( 0, 0, 640, lb + 1, col );
+			UI_SetScreenPlacement(PLACE_CENTER, PLACE_CENTER);
+		}
+	}
+
 	if ( w->style == WINDOW_STYLE_FILLED ) {
 		// box, but possible a shader that needs filled
 		if ( w->background ) {
-			Fade( &w->flags, &w->backColor[3], fadeClamp, &w->nextTime, fadeCycle, qtrue, fadeAmount );
-			DC->setColor( w->backColor );
-			DC->drawHandlePic( fillRect.x, fillRect.y, fillRect.w, fillRect.h, w->background );
-			DC->setColor( NULL );
+			if ( ui_fixedAspect.integer == 2 ) {
+				UI_SetScreenPlacement(PLACE_CENTER, PLACE_STRETCH);
+				Fade( &w->flags, &w->backColor[3], fadeClamp, &w->nextTime, fadeCycle, qtrue, fadeAmount );
+				DC->setColor( w->backColor );
+				DC->drawHandlePic( fillRect.x, fillRect.y, fillRect.w, fillRect.h, w->background );
+				DC->setColor( NULL );
+				UI_SetScreenPlacement(PLACE_CENTER, PLACE_CENTER);
+			} else {
+				Fade( &w->flags, &w->backColor[3], fadeClamp, &w->nextTime, fadeCycle, qtrue, fadeAmount );
+				DC->setColor( w->backColor );
+				DC->drawHandlePic( fillRect.x, fillRect.y, fillRect.w, fillRect.h, w->background );
+				DC->setColor( NULL );
+			}
 		} else {
 			DC->fillRect( fillRect.x, fillRect.y, fillRect.w, fillRect.h, w->backColor );
 		}
@@ -704,8 +840,32 @@ void Window_Paint( Window *w, float fadeAmount, float fadeClamp, float fadeCycle
 		if ( w->flags & WINDOW_FORECOLORSET ) {
 			DC->setColor( w->foreColor );
 		}
-		DC->drawHandlePic( fillRect.x, fillRect.y, fillRect.w, fillRect.h, w->background );
-		DC->setColor( NULL );
+		if ( ui_fixedAspect.integer == 2 ) {
+			if ( DC->glconfig.vidWidth * 480 > DC->glconfig.vidHeight * 640 ) {
+				// HACK ... widen menu without stretching items and models
+				if ( !Q_stricmpn( w->name, "BLACKGRAD", 9 ) ) {
+					UI_SetScreenPlacement(PLACE_STRETCH, PLACE_STRETCH);
+					DC->drawHandlePic( fillRect.x, fillRect.y, fillRect.w, fillRect.h, w->background );
+					DC->setColor( NULL );
+				} else if ( !Q_stricmpn( w->name, "gold_line", 9 ) ) {
+					UI_SetScreenPlacement(PLACE_STRETCH, PLACE_STRETCH);
+					DC->drawHandlePic( fillRect.x, fillRect.y, fillRect.w, fillRect.h, w->background );
+					DC->setColor( NULL );
+				} else {
+					UI_SetScreenPlacement(PLACE_CENTER, PLACE_STRETCH);
+					DC->drawHandlePic( fillRect.x, fillRect.y, fillRect.w, fillRect.h, w->background );
+					DC->setColor( NULL );
+				}
+			} else {
+				UI_SetScreenPlacement(PLACE_CENTER, PLACE_CENTER);
+				DC->drawHandlePic( fillRect.x, fillRect.y, fillRect.w, fillRect.h, w->background );
+				DC->setColor( NULL );
+			}
+			UI_SetScreenPlacement(PLACE_CENTER, PLACE_CENTER);
+		} else {
+			DC->drawHandlePic( fillRect.x, fillRect.y, fillRect.w, fillRect.h, w->background );
+			DC->setColor( NULL );
+		}
 	} else if ( w->style == WINDOW_STYLE_TEAMCOLOR ) {
 		if ( DC->getTeamColor ) {
 			DC->getTeamColor( &color );
@@ -3900,14 +4060,19 @@ qboolean Item_Bind_HandleKey( itemDef_t *item, int key, qboolean down ) {
 	return qtrue;
 }
 
-
-
 void AdjustFrom640( float *x, float *y, float *w, float *h ) {
 	//*x = *x * DC->scale + DC->bias;
-	*x *= DC->xscale;
-	*y *= DC->yscale;
-	*w *= DC->xscale;
-	*h *= DC->yscale;
+	if ( ui_fixedAspect.integer ) {
+		*w *= DC->xscale;
+		*x = *x * DC->xscale + DC->xBias;
+		*h *= DC->yscale;
+		*y = *y * DC->yscale + DC->yBias;
+	} else {
+		*x *= DC->xscale;
+		*y *= DC->yscale;
+		*w *= DC->xscale;
+		*h *= DC->yscale;
+	}
 }
 
 void Item_Model_Paint( itemDef_t *item ) {
diff --git a/MP/code/ui/ui_shared.h b/MP/code/ui/ui_shared.h
index 5b4ac43..09478ed 100644
--- a/MP/code/ui/ui_shared.h
+++ b/MP/code/ui/ui_shared.h
@@ -408,6 +408,10 @@ typedef struct {
 
 	float yscale;
 	float xscale;
+	float yscaleStretch;
+	float xscaleStretch;
+	float yBias;
+	float xBias;
 	float bias;
 	int realTime;
 	int frameTime;
@@ -491,4 +495,9 @@ int         trap_PC_FreeSource( int handle );
 int         trap_PC_ReadToken( int handle, pc_token_t *pc_token );
 int         trap_PC_SourceFileAndLine( int handle, char *filename, int *line );
 
+void UI_SetScreenPlacement(screenPlacement_e hpos, screenPlacement_e vpos);
+void UI_PopScreenPlacement(void);
+screenPlacement_e UI_GetScreenHorizontalPlacement(void);
+screenPlacement_e UI_GetScreenVerticalPlacement(void);
+
 #endif
diff --git a/SP/code/ui/ui_main.c b/SP/code/ui/ui_main.c
index 252385f..11f8b0f 100644
--- a/SP/code/ui/ui_main.c
+++ b/SP/code/ui/ui_main.c
@@ -7269,8 +7269,6 @@ vmCvar_t ui_autoactivate;
 vmCvar_t ui_emptyswitch;        //----(SA)	added
 // END JOSEPH
 
-vmCvar_t ui_fixedAspect;
-
 vmCvar_t ui_server1;
 vmCvar_t ui_server2;
 vmCvar_t ui_server3;
diff --git a/SP/code/ui/ui_shared.c b/SP/code/ui/ui_shared.c
index ee7466e..55fb9ec 100644
--- a/SP/code/ui/ui_shared.c
+++ b/SP/code/ui/ui_shared.c
@@ -214,7 +214,6 @@ void UI_AdjustFrom640( float *x, float *y, float *w, float *h ) {
 	*w *= DC->scale;
 	*h *= DC->scale;
 #endif
-
 	if ( ui_fixedAspect.integer ) {
 		if (ui_horizontalPlacement == PLACE_STRETCH) {
 			// scale for screen sizes (not aspect correct in wide screen)

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/iortcw.git



More information about the Pkg-games-commits mailing list