Skip to content

Commit 93e52c9

Browse files
committed
Cleaner implementation of scaling, including boxgap handling
1 parent 3eaa1f4 commit 93e52c9

File tree

1 file changed

+21
-16
lines changed

1 file changed

+21
-16
lines changed

src/game/client/tf/tf_hud_weaponselection.cpp

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -460,8 +460,8 @@ void CHudWeaponSelection::ComputeSlotLayout( SlotLayout_t *rSlot, int nActiveSlo
460460
{
461461
// calculate where to start drawing
462462
#ifdef BDSBASE
463-
float flTotalHeight = 0.f;
464463
float xStartPos = GetWide() - m_flBoxGap - m_flRightMargin;
464+
float ypos = 0.f;
465465
#else
466466
int nTotalHeight = (nNumSlots - 1) * (m_flSmallBoxTall + m_flBoxGap) + m_flLargeBoxTall;
467467
int xStartPos = GetWide() - m_flBoxGap - m_flRightMargin;
@@ -470,13 +470,13 @@ void CHudWeaponSelection::ComputeSlotLayout( SlotLayout_t *rSlot, int nActiveSlo
470470
// iterate over all the weapon slots
471471
for ( int i = 0; i < m_iMaxSlots; i++ )
472472
{
473+
#ifdef BDSBASE
474+
float flHeightScale = 1.f;
475+
#endif
473476
if ( i == nActiveSlot )
474477
{
475478
rSlot[i].wide = m_flLargeBoxWide;
476479
rSlot[i].tall = m_flLargeBoxTall;
477-
#ifdef BDSBASE
478-
flTotalHeight += rSlot[i].tall;
479-
#endif
480480
}
481481
else
482482
{
@@ -485,32 +485,37 @@ void CHudWeaponSelection::ComputeSlotLayout( SlotLayout_t *rSlot, int nActiveSlo
485485
// only include slot if visible OR (any slot above visible AND any slot below visible)
486486
if ((iSlotBits >> i) && (iSlotBits & ((1 << (i + 1)) - 1)))
487487
{
488-
rSlot[i].tall = (iSlotBits & (1 << i)) ? m_flSmallBoxTall : (m_flSmallBoxTall * tf_weapon_select_empty_bucket_scale.GetFloat());
489-
flTotalHeight += rSlot[i].tall + (m_flBoxGap * rSlot[i].tall / m_flSmallBoxTall);
488+
if ( !( iSlotBits & (1 << i) ) )
489+
{
490+
flHeightScale = tf_weapon_select_empty_bucket_scale.GetFloat();
491+
}
490492
}
491493
else
492494
{
493-
rSlot[i].tall = 0;
495+
flHeightScale = 0.f;
494496
}
497+
rSlot[i].tall = m_flSmallBoxTall * flHeightScale;
495498
#else
496499
rSlot[i].tall = m_flSmallBoxTall;
497500
#endif
498501
}
499502

500503
rSlot[i].x = xStartPos - ( rSlot[i].wide + m_flBoxGap );
504+
rSlot[i].y = ypos;
501505
#ifdef BDSBASE
502-
// now calculate ypos from total height
503-
float ypos = (GetTall() - flTotalHeight) / 2;
504-
for (int i = 0; i < m_iMaxSlots; i++)
505-
{
506-
rSlot[i].y = ypos;
507-
ypos += rSlot[i].tall + MIN(m_flBoxGap, m_flBoxGap * rSlot[i].tall / m_flSmallBoxTall);
508-
}
506+
ypos += ( rSlot[i].tall + ( m_flBoxGap * flHeightScale ) );
509507
#else
510-
rSlot[i].y = ypos;
511-
ypos += (rSlot[i].tall + m_flBoxGap);
508+
ypos += ( rSlot[i].tall + m_flBoxGap );
512509
#endif
513510
}
511+
#ifdef BDSBASE
512+
// now offset ypos using total height
513+
ypos = ( GetTall() - ypos + m_flBoxGap ) / 2;
514+
for ( int i = 0; i < m_iMaxSlots; i++ )
515+
{
516+
rSlot[i].y += ypos;
517+
}
518+
#endif
514519
}
515520
break;
516521

0 commit comments

Comments
 (0)