From 0f829312a45d2c4bf58ad972fcfd6e322eb5e5ec Mon Sep 17 00:00:00 2001 From: Gene Date: Sun, 23 Jun 2024 10:06:30 -0700 Subject: [PATCH] widescreen hud selection --- code/cgame/cg_main.cpp | 56 +++++++++++++++++++-------------------- code/cgame/cg_weapons.cpp | 34 +++++++++++++----------- codemp/cgame/cg_draw.c | 48 +++++++++++++++++---------------- codemp/cgame/cg_weapons.c | 34 +++++++++++++----------- 4 files changed, 91 insertions(+), 81 deletions(-) diff --git a/code/cgame/cg_main.cpp b/code/cgame/cg_main.cpp index e95ca338fe..80a9c360a7 100644 --- a/code/cgame/cg_main.cpp +++ b/code/cgame/cg_main.cpp @@ -3296,7 +3296,7 @@ void CG_DrawInventorySelect( void ) int holdCount,iconCnt; int sideLeftIconCnt,sideRightIconCnt; int count; - int holdX; + float holdX; //int height; // int tag; float addX; @@ -3370,18 +3370,18 @@ void CG_DrawInventorySelect( void ) i = INV_MAX-1; } - const int smallIconSize = 40; - const int bigIconSize = 80; - const int pad = 16; + const float smallIconSize_x = 40 * cgs.widthRatioCoef, smallIconSize_y = 40; + const float bigIconSize_x = 80 * cgs.widthRatioCoef, bigIconSize_y = 80; + const float pad = 16 * cgs.widthRatioCoef; const int x = 320; const int y = 410; // Left side ICONS // Work backwards from current icon - holdX = x - ((bigIconSize/2) + pad + smallIconSize); + holdX = x - ((bigIconSize_x/2) + pad + smallIconSize_x); //height = smallIconSize * cg.iconHUDPercent; - addX = (float) smallIconSize * .75; + addX = smallIconSize_x * .75; for (iconCnt=0;iconCntps.inventory[i], 6, 12, + CG_DrawNumField (holdX + addX, y + smallIconSize_y, 2, cg.snap->ps.inventory[i], 6*cgs.widthRatioCoef, 12, NUM_FONT_SMALL,qfalse); - holdX -= (smallIconSize+pad); + holdX -= (smallIconSize_x+pad); } } @@ -3415,10 +3415,10 @@ void CG_DrawInventorySelect( void ) if (inv_icons[cg.inventorySelect]) { cgi_R_SetColor(NULL); - CG_DrawPic( x-(bigIconSize/2), (y-((bigIconSize-smallIconSize)/2))+10, bigIconSize, bigIconSize, inv_icons[cg.inventorySelect] ); - addX = (float) bigIconSize * .75; + CG_DrawPic( x-(bigIconSize_x/2), (y-((bigIconSize_y-smallIconSize_y)/2))+10, bigIconSize_x, bigIconSize_y, inv_icons[cg.inventorySelect] ); + addX = bigIconSize_x * .75; cgi_R_SetColor(colorTable[CT_ICON_BLUE]); - CG_DrawNumField ((x-(bigIconSize/2)) + addX, y, 2, cg.snap->ps.inventory[cg.inventorySelect], 6, 12, + CG_DrawNumField ((x-(bigIconSize_x/2)) + addX, y, 2, cg.snap->ps.inventory[cg.inventorySelect], 6*cgs.widthRatioCoef, 12, NUM_FONT_SMALL,qfalse); if (inv_names[cg.inventorySelect]) @@ -3451,9 +3451,9 @@ void CG_DrawInventorySelect( void ) // Right side ICONS // Work forwards from current icon - holdX = x + (bigIconSize/2) + pad; + holdX = x + (bigIconSize_x/2) + pad; //height = smallIconSize * cg.iconHUDPercent; - addX = (float) smallIconSize * .75; + addX = smallIconSize_x * .75; for (iconCnt=0;iconCnt INV_MAX-1) @@ -3471,13 +3471,13 @@ void CG_DrawInventorySelect( void ) if (inv_icons[i]) { cgi_R_SetColor(NULL); - CG_DrawPic( holdX, y+10, smallIconSize, smallIconSize, inv_icons[i] ); + CG_DrawPic( holdX, y+10, smallIconSize_x, smallIconSize_y, inv_icons[i] ); cgi_R_SetColor(colorTable[CT_ICON_BLUE]); - CG_DrawNumField (holdX + addX, y + smallIconSize, 2, cg.snap->ps.inventory[i], 6, 12, + CG_DrawNumField (holdX + addX, y + smallIconSize_y, 2, cg.snap->ps.inventory[i], 6*cgs.widthRatioCoef, 12, NUM_FONT_SMALL,qfalse); - holdX += (smallIconSize+pad); + holdX += (smallIconSize_x+pad); } } } @@ -3866,7 +3866,7 @@ void CG_DrawForceSelect( void ) { int i; int count; - int holdX; + float holdX; int sideLeftIconCnt,sideRightIconCnt; int holdCount,iconCnt; char text[1024]={0}; @@ -3932,9 +3932,9 @@ void CG_DrawForceSelect( void ) sideRightIconCnt = holdCount - sideLeftIconCnt; } - const int smallIconSize = 30; - const int bigIconSize = 60; - const int pad = 12; + const float smallIconSize_x = 30 * cgs.widthRatioCoef, smallIconSize_y = 30; + const float bigIconSize_x = 60 * cgs.widthRatioCoef, bigIconSize_y = 60; + const float pad = 12; const int x = 320; const int y = 425; @@ -3947,7 +3947,7 @@ void CG_DrawForceSelect( void ) cgi_R_SetColor(NULL); // Work backwards from current icon - holdX = x - ((bigIconSize/2) + pad + smallIconSize); + holdX = x - ((bigIconSize_x/2) + pad + smallIconSize_x); for (iconCnt=1;iconCnt<(sideLeftIconCnt+1);i--) { if (i < 0) @@ -3964,15 +3964,15 @@ void CG_DrawForceSelect( void ) if (force_icons[showPowers[i]]) { - CG_DrawPic( holdX, y + yOffset, smallIconSize, smallIconSize, force_icons[showPowers[i]] ); - holdX -= (smallIconSize+pad); + CG_DrawPic( holdX, y + yOffset, smallIconSize_x, smallIconSize_y, force_icons[showPowers[i]] ); + holdX -= (smallIconSize_x+pad); } } // Current Center Icon if (force_icons[showPowers[cg.forcepowerSelect]]) { - CG_DrawPic( x-(bigIconSize/2), (y-((bigIconSize-smallIconSize)/2)) + yOffset, bigIconSize, bigIconSize, force_icons[showPowers[cg.forcepowerSelect]] ); + CG_DrawPic( x-(bigIconSize_x/2), (y-((bigIconSize_y-smallIconSize_y)/2)) + yOffset, bigIconSize_x, bigIconSize_y, force_icons[showPowers[cg.forcepowerSelect]] ); } @@ -3983,7 +3983,7 @@ void CG_DrawForceSelect( void ) } // Work forwards from current icon - holdX = x + (bigIconSize/2) + pad; + holdX = x + (bigIconSize_x/2) + pad; for (iconCnt=1;iconCnt<(sideRightIconCnt+1);i++) { if (i>=MAX_SHOWPOWERS) @@ -4000,8 +4000,8 @@ void CG_DrawForceSelect( void ) if (force_icons[showPowers[i]]) { - CG_DrawPic( holdX, y + yOffset, smallIconSize, smallIconSize, force_icons[showPowers[i]] ); - holdX += (smallIconSize+pad); + CG_DrawPic( holdX, y + yOffset, smallIconSize_x, smallIconSize_y, force_icons[showPowers[i]] ); + holdX += (smallIconSize_x+pad); } } diff --git a/code/cgame/cg_weapons.cpp b/code/cgame/cg_weapons.cpp index ee4b22297b..38d0bcfc5f 100644 --- a/code/cgame/cg_weapons.cpp +++ b/code/cgame/cg_weapons.cpp @@ -1774,8 +1774,10 @@ void CG_DrawWeaponSelect( void ) int i; int bits; int count; - int smallIconSize,bigIconSize; - int holdX,x,y,x2,y2,w2,h2,pad; + float smallIconSize_x,bigIconSize_x; + float smallIconSize_y,bigIconSize_y; + float holdX,pad; + int x,y,x2,y2,w2,h2; int sideLeftIconCnt,sideRightIconCnt; int sideMax,holdCount,iconCnt; //int height; @@ -1853,9 +1855,11 @@ void CG_DrawWeaponSelect( void ) i = MAX_PLAYER_WEAPONS; } - smallIconSize = 40; - bigIconSize = 80; - pad = 12; + smallIconSize_x = 40 * cgs.widthRatioCoef; + smallIconSize_y = 40; + bigIconSize_x = 80 * cgs.widthRatioCoef; + bigIconSize_y = 80; + pad = 12 * cgs.widthRatioCoef; if (!cgi_UI_GetMenuInfo("weaponselecthud",&x2,&y2,&w2,&h2)) { @@ -1872,7 +1876,7 @@ void CG_DrawWeaponSelect( void ) // Left side ICONS cgi_R_SetColor( calcColor); // Work backwards from current icon - holdX = x - ((bigIconSize/2) + pad + smallIconSize); + holdX = x - ((bigIconSize_x/2) + pad + smallIconSize_x); //height = smallIconSize * cg.iconHUDPercent; drewConc = qfalse; @@ -1923,14 +1927,14 @@ void CG_DrawWeaponSelect( void ) if (!CG_WeaponCheck(i)) { - CG_DrawPic( holdX, y+10+yOffset, smallIconSize, smallIconSize, weaponInfo->weaponIconNoAmmo ); + CG_DrawPic( holdX, y+10+yOffset, smallIconSize_x, smallIconSize_y, weaponInfo->weaponIconNoAmmo ); } else { - CG_DrawPic( holdX, y+10+yOffset, smallIconSize, smallIconSize, weaponInfo->weaponIcon ); + CG_DrawPic( holdX, y+10+yOffset, smallIconSize_x, smallIconSize_y, weaponInfo->weaponIcon ); } - holdX -= (smallIconSize+pad); + holdX -= (smallIconSize_x+pad); } if ( i == WP_CONCUSSION ) { @@ -1950,11 +1954,11 @@ void CG_DrawWeaponSelect( void ) if (!CG_WeaponCheck(cg.weaponSelect)) { - CG_DrawPic( x-(bigIconSize/2), (y-((bigIconSize-smallIconSize)/2))+10+yOffset, bigIconSize, bigIconSize, weaponInfo->weaponIconNoAmmo ); + CG_DrawPic( x-(bigIconSize_x/2), (y-((bigIconSize_y-smallIconSize_y)/2))+10+yOffset, bigIconSize_x, bigIconSize_y, weaponInfo->weaponIconNoAmmo ); } else { - CG_DrawPic( x-(bigIconSize/2), (y-((bigIconSize-smallIconSize)/2))+10+yOffset, bigIconSize, bigIconSize, weaponInfo->weaponIcon ); + CG_DrawPic( x-(bigIconSize_x/2), (y-((bigIconSize_y-smallIconSize_y)/2))+10+yOffset, bigIconSize_x, bigIconSize_y, weaponInfo->weaponIcon ); } } @@ -1974,7 +1978,7 @@ void CG_DrawWeaponSelect( void ) // Right side ICONS // Work forwards from current icon cgi_R_SetColor( calcColor); - holdX = x + (bigIconSize/2) + pad; + holdX = x + (bigIconSize_x/2) + pad; //height = smallIconSize * cg.iconHUDPercent; drewConc = qfalse; for (iconCnt=1;iconCnt<(sideRightIconCnt+1);i++) @@ -2024,15 +2028,15 @@ void CG_DrawWeaponSelect( void ) // No ammo for this weapon? if (!CG_WeaponCheck(i)) { - CG_DrawPic( holdX, y+10+yOffset, smallIconSize, smallIconSize, weaponInfo->weaponIconNoAmmo ); + CG_DrawPic( holdX, y+10+yOffset, smallIconSize_x, smallIconSize_y, weaponInfo->weaponIconNoAmmo ); } else { - CG_DrawPic( holdX, y+10+yOffset, smallIconSize, smallIconSize, weaponInfo->weaponIcon ); + CG_DrawPic( holdX, y+10+yOffset, smallIconSize_x, smallIconSize_y, weaponInfo->weaponIcon ); } - holdX += (smallIconSize+pad); + holdX += (smallIconSize_x+pad); } if ( i == WP_CONCUSSION ) { diff --git a/codemp/cgame/cg_draw.c b/codemp/cgame/cg_draw.c index 08cdde50e9..6814d81e38 100644 --- a/codemp/cgame/cg_draw.c +++ b/codemp/cgame/cg_draw.c @@ -1536,8 +1536,9 @@ void CG_DrawForceSelect( void ) { int i; int count; - int smallIconSize,bigIconSize; - int holdX, x, y, pad; + float smallIconSize_x,smallIconSize_y,bigIconSize_x,bigIconSize_y; + float holdX,pad; + int x,y; int sideLeftIconCnt,sideRightIconCnt; int sideMax,holdCount,iconCnt; int yOffset = 0; @@ -1595,8 +1596,8 @@ void CG_DrawForceSelect( void ) sideRightIconCnt = holdCount - sideLeftIconCnt; } - smallIconSize = 30; - bigIconSize = 60; + smallIconSize_x = 30 * cgs.widthRatioCoef, smallIconSize_y = 30; + bigIconSize_x = 60 * cgs.widthRatioCoef, bigIconSize_y = 60; pad = 12; x = 320; @@ -1610,7 +1611,7 @@ void CG_DrawForceSelect( void ) trap->R_SetColor(NULL); // Work backwards from current icon - holdX = x - ((bigIconSize/2) + pad + smallIconSize); + holdX = x - ((bigIconSize_x/2) + pad + smallIconSize_x); for (iconCnt=1;iconCnt<(sideLeftIconCnt+1);i--) { if (i < 0) @@ -1627,8 +1628,8 @@ void CG_DrawForceSelect( void ) if (cgs.media.forcePowerIcons[forcePowerSorted[i]]) { - CG_DrawPic( holdX, y + yOffset, smallIconSize, smallIconSize, cgs.media.forcePowerIcons[forcePowerSorted[i]] ); - holdX -= (smallIconSize+pad); + CG_DrawPic( holdX, y + yOffset, smallIconSize_x, smallIconSize_y, cgs.media.forcePowerIcons[forcePowerSorted[i]] ); + holdX -= (smallIconSize_x+pad); } } @@ -1637,7 +1638,7 @@ void CG_DrawForceSelect( void ) // Current Center Icon if (cgs.media.forcePowerIcons[cg.forceSelect]) { - CG_DrawPic( x-(bigIconSize/2), (y-((bigIconSize-smallIconSize)/2)) + yOffset, bigIconSize, bigIconSize, cgs.media.forcePowerIcons[cg.forceSelect] ); //only cache the icon for display + CG_DrawPic( x-(bigIconSize_x/2), (y-((bigIconSize_y-smallIconSize_y)/2)) + yOffset, bigIconSize_x, bigIconSize_y, cgs.media.forcePowerIcons[cg.forceSelect] ); //only cache the icon for display } } @@ -1648,7 +1649,7 @@ void CG_DrawForceSelect( void ) } // Work forwards from current icon - holdX = x + (bigIconSize/2) + pad; + holdX = x + (bigIconSize_x/2) + pad; for (iconCnt=1;iconCnt<(sideRightIconCnt+1);i++) { if (i>=MAX_SHOWPOWERS) @@ -1665,8 +1666,8 @@ void CG_DrawForceSelect( void ) if (cgs.media.forcePowerIcons[forcePowerSorted[i]]) { - CG_DrawPic( holdX, y + yOffset, smallIconSize, smallIconSize, cgs.media.forcePowerIcons[forcePowerSorted[i]] ); //only cache the icon for display - holdX += (smallIconSize+pad); + CG_DrawPic( holdX, y + yOffset, smallIconSize_x, smallIconSize_y, cgs.media.forcePowerIcons[forcePowerSorted[i]] ); //only cache the icon for display + holdX += (smallIconSize_x+pad); } } @@ -1685,10 +1686,11 @@ void CG_DrawInvenSelect( void ) { int i; int sideMax,holdCount,iconCnt; - int smallIconSize,bigIconSize; + float smallIconSize_x,smallIconSize_y,bigIconSize_x,bigIconSize_y; int sideLeftIconCnt,sideRightIconCnt; int count; - int holdX, x, y, y2, pad; + int x, y, y2; + float holdX, pad; // float addX; // don't display if dead @@ -1758,16 +1760,16 @@ void CG_DrawInvenSelect( void ) i = HI_NUM_HOLDABLE-1; } - smallIconSize = 40; - bigIconSize = 80; - pad = 16; + smallIconSize_x = 40 * cgs.widthRatioCoef, smallIconSize_y = 40; + bigIconSize_x = 80 * cgs.widthRatioCoef, bigIconSize_y = 80; + pad = 16 * cgs.widthRatioCoef; x = 320; y = 410; // Left side ICONS // Work backwards from current icon - holdX = x - ((bigIconSize/2) + pad + smallIconSize); + holdX = x - ((bigIconSize_x/2) + pad + smallIconSize_x); // addX = (float) smallIconSize * .75; for (iconCnt=0;iconCntR_SetColor(NULL); - CG_DrawPic( holdX, y+10, smallIconSize, smallIconSize, cgs.media.invenIcons[i] ); + CG_DrawPic( holdX, y+10, smallIconSize_x, smallIconSize_y, cgs.media.invenIcons[i] ); trap->R_SetColor(colorTable[CT_ICON_BLUE]); /*CG_DrawNumField (holdX + addX, y + smallIconSize, 2, cg.snap->ps.inventory[i], 6, 12, NUM_FONT_SMALL,qfalse); */ - holdX -= (smallIconSize+pad); + holdX -= (smallIconSize_x+pad); } } @@ -1808,7 +1810,7 @@ void CG_DrawInvenSelect( void ) { int itemNdex; trap->R_SetColor(NULL); - CG_DrawPic( x-(bigIconSize/2), (y-((bigIconSize-smallIconSize)/2))+10, bigIconSize, bigIconSize, cgs.media.invenIcons[cg.itemSelect] ); + CG_DrawPic( x-(bigIconSize_x/2), (y-((bigIconSize_y-smallIconSize_y)/2))+10, bigIconSize_x, bigIconSize_y, cgs.media.invenIcons[cg.itemSelect] ); // addX = (float) bigIconSize * .75; trap->R_SetColor(colorTable[CT_ICON_BLUE]); /*CG_DrawNumField ((x-(bigIconSize/2)) + addX, y, 2, cg.snap->ps.inventory[cg.inventorySelect], 6, 12, @@ -1842,7 +1844,7 @@ void CG_DrawInvenSelect( void ) // Right side ICONS // Work forwards from current icon - holdX = x + (bigIconSize/2) + pad; + holdX = x + (bigIconSize_x/2) + pad; // addX = (float) smallIconSize * .75; for (iconCnt=0;iconCntR_SetColor(NULL); - CG_DrawPic( holdX, y+10, smallIconSize, smallIconSize, cgs.media.invenIcons[i] ); + CG_DrawPic( holdX, y+10, smallIconSize_x, smallIconSize_y, cgs.media.invenIcons[i] ); trap->R_SetColor(colorTable[CT_ICON_BLUE]); /*CG_DrawNumField (holdX + addX, y + smallIconSize, 2, cg.snap->ps.inventory[i], 6, 12, NUM_FONT_SMALL,qfalse);*/ - holdX += (smallIconSize+pad); + holdX += (smallIconSize_x+pad); } } } diff --git a/codemp/cgame/cg_weapons.c b/codemp/cgame/cg_weapons.c index 99b659e6c3..43a31b1b56 100644 --- a/codemp/cgame/cg_weapons.c +++ b/codemp/cgame/cg_weapons.c @@ -1091,8 +1091,10 @@ void CG_DrawWeaponSelect( void ) { int i; int bits; int count; - int smallIconSize,bigIconSize; - int holdX,x,y,pad; + float smallIconSize_x,bigIconSize_x; + float smallIconSize_y,bigIconSize_y; + float holdX,pad; + int x,y; int sideLeftIconCnt,sideRightIconCnt; int sideMax,holdCount,iconCnt; // int height; @@ -1180,9 +1182,11 @@ void CG_DrawWeaponSelect( void ) { i = LAST_USEABLE_WEAPON; } - smallIconSize = 40; - bigIconSize = 80; - pad = 12; + smallIconSize_x = 40 * cgs.widthRatioCoef; + smallIconSize_y = 40; + bigIconSize_x = 80 * cgs.widthRatioCoef; + bigIconSize_y = 80; + pad = 12 * cgs.widthRatioCoef; x = 320; y = 410; @@ -1195,7 +1199,7 @@ void CG_DrawWeaponSelect( void ) { // Left side ICONS trap->R_SetColor(colorTable[CT_WHITE]); // Work backwards from current icon - holdX = x - ((bigIconSize/2) + pad + smallIconSize); + holdX = x - ((bigIconSize_x/2) + pad + smallIconSize_x); // height = smallIconSize * 1;//cg.iconHUDPercent; drewConc = qfalse; @@ -1243,14 +1247,14 @@ void CG_DrawWeaponSelect( void ) { trap->R_SetColor(colorTable[CT_WHITE]); if (!CG_WeaponCheck(i)) { - CG_DrawPic( holdX, y+10+yOffset, smallIconSize, smallIconSize, /*weaponInfo->weaponIconNoAmmo*/cgs.media.weaponIcons_NA[i] ); + CG_DrawPic( holdX, y+10+yOffset, smallIconSize_x, smallIconSize_y, /*weaponInfo->weaponIconNoAmmo*/cgs.media.weaponIcons_NA[i] ); } else { - CG_DrawPic( holdX, y+10+yOffset, smallIconSize, smallIconSize, /*weaponInfo->weaponIcon*/cgs.media.weaponIcons[i] ); + CG_DrawPic( holdX, y+10+yOffset, smallIconSize_x, smallIconSize_y, /*weaponInfo->weaponIcon*/cgs.media.weaponIcons[i] ); } - holdX -= (smallIconSize+pad); + holdX -= (smallIconSize_x+pad); } if ( i == WP_CONCUSSION ) { @@ -1270,11 +1274,11 @@ void CG_DrawWeaponSelect( void ) { trap->R_SetColor( colorTable[CT_WHITE]); if (!CG_WeaponCheck(cg.weaponSelect)) { - CG_DrawPic( x-(bigIconSize/2), (y-((bigIconSize-smallIconSize)/2))+10+yOffset, bigIconSize, bigIconSize, cgs.media.weaponIcons_NA[cg.weaponSelect] ); + CG_DrawPic( x-(bigIconSize_x/2), (y-((bigIconSize_y-smallIconSize_y)/2))+10+yOffset, bigIconSize_x, bigIconSize_y, cgs.media.weaponIcons_NA[cg.weaponSelect] ); } else { - CG_DrawPic( x-(bigIconSize/2), (y-((bigIconSize-smallIconSize)/2))+10+yOffset, bigIconSize, bigIconSize, cgs.media.weaponIcons[cg.weaponSelect] ); + CG_DrawPic( x-(bigIconSize_x/2), (y-((bigIconSize_y-smallIconSize_y)/2))+10+yOffset, bigIconSize_x, bigIconSize_y, cgs.media.weaponIcons[cg.weaponSelect] ); } } @@ -1293,7 +1297,7 @@ void CG_DrawWeaponSelect( void ) { // Right side ICONS // Work forwards from current icon - holdX = x + (bigIconSize/2) + pad; + holdX = x + (bigIconSize_x/2) + pad; // height = smallIconSize * cg.iconHUDPercent; for (iconCnt=1;iconCnt<(sideRightIconCnt+1);i++) { @@ -1337,15 +1341,15 @@ void CG_DrawWeaponSelect( void ) { trap->R_SetColor( colorTable[CT_WHITE]); if (!CG_WeaponCheck(i)) { - CG_DrawPic( holdX, y+10+yOffset, smallIconSize, smallIconSize, cgs.media.weaponIcons_NA[i] ); + CG_DrawPic( holdX, y+10+yOffset, smallIconSize_x, smallIconSize_y, cgs.media.weaponIcons_NA[i] ); } else { - CG_DrawPic( holdX, y+10+yOffset, smallIconSize, smallIconSize, cgs.media.weaponIcons[i] ); + CG_DrawPic( holdX, y+10+yOffset, smallIconSize_x, smallIconSize_y, cgs.media.weaponIcons[i] ); } - holdX += (smallIconSize+pad); + holdX += (smallIconSize_x+pad); } if ( i == WP_CONCUSSION ) {