Skip to content

Commit 74c078b

Browse files
authored
Merge pull request #1 from FlaminSarge/patch-2
Update implementation of ValveSoftware#901
2 parents a0a57ec + 93e52c9 commit 74c078b

File tree

1 file changed

+21
-26
lines changed

1 file changed

+21
-26
lines changed

src/game/client/tf/tf_hud_weaponselection.cpp

Lines changed: 21 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,7 @@
4646
ConVar tf_weapon_select_demo_start_delay( "tf_weapon_select_demo_start_delay", "1.0", FCVAR_CLIENTDLL | FCVAR_ARCHIVE, "Delay after spawning to start the weapon bucket demo." );
4747
ConVar tf_weapon_select_demo_time( "tf_weapon_select_demo_time", "0.5", FCVAR_CLIENTDLL | FCVAR_ARCHIVE, "Time to pulse each weapon bucket upon spawning as a new class. 0 to turn off." );
4848
#ifdef BDSBASE
49-
ConVar tf_weapon_select_space_reduction("tf_weapon_select_space_reduction", "0", FCVAR_CLIENTDLL | FCVAR_ARCHIVE);
50-
ConVar tf_weapon_select_space_reduction_factor("tf_weapon_select_space_reduction_factor", "2", FCVAR_CLIENTDLL | FCVAR_ARCHIVE);
49+
ConVar tf_weapon_select_empty_bucket_scale("tf_weapon_select_empty_bucket_scale", "1.0", FCVAR_CLIENTDLL | FCVAR_ARCHIVE, "Scale empty weapon bucket spaces by this amount.", true, 0.0f, true, 1.0f);
5150
#endif
5251

5352
//-----------------------------------------------------------------------------
@@ -461,24 +460,23 @@ void CHudWeaponSelection::ComputeSlotLayout( SlotLayout_t *rSlot, int nActiveSlo
461460
{
462461
// calculate where to start drawing
463462
#ifdef BDSBASE
464-
int nTotalHeight = 0;
463+
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;
467-
#endif
468467
int xStartPos = GetWide() - m_flBoxGap - m_flRightMargin;
469-
#ifndef BDSBASE
470468
int ypos = (GetTall() - nTotalHeight) / 2;
471469
#endif
472470
// iterate over all the weapon slots
473471
for ( int i = 0; i < m_iMaxSlots; i++ )
474472
{
473+
#ifdef BDSBASE
474+
float flHeightScale = 1.f;
475+
#endif
475476
if ( i == nActiveSlot )
476477
{
477478
rSlot[i].wide = m_flLargeBoxWide;
478479
rSlot[i].tall = m_flLargeBoxTall;
479-
#ifdef BDSBASE
480-
nTotalHeight += rSlot[i].tall;
481-
#endif
482480
}
483481
else
484482
{
@@ -487,40 +485,37 @@ void CHudWeaponSelection::ComputeSlotLayout( SlotLayout_t *rSlot, int nActiveSlo
487485
// only include slot if visible OR (any slot above visible AND any slot below visible)
488486
if ((iSlotBits >> i) && (iSlotBits & ((1 << (i + 1)) - 1)))
489487
{
490-
if (tf_weapon_select_space_reduction.GetBool())
491-
{
492-
rSlot[i].tall = (iSlotBits & (1 << i)) ? m_flSmallBoxTall : m_flSmallBoxTall / tf_weapon_select_space_reduction_factor.GetInt();
493-
}
494-
else
488+
if ( !( iSlotBits & (1 << i) ) )
495489
{
496-
rSlot[i].tall = m_flSmallBoxTall;
490+
flHeightScale = tf_weapon_select_empty_bucket_scale.GetFloat();
497491
}
498-
nTotalHeight += rSlot[i].tall + m_flBoxGap;
499492
}
500493
else
501494
{
502-
rSlot[i].tall = 0;
495+
flHeightScale = 0.f;
503496
}
497+
rSlot[i].tall = m_flSmallBoxTall * flHeightScale;
504498
#else
505499
rSlot[i].tall = m_flSmallBoxTall;
506500
#endif
507501
}
508502

509503
rSlot[i].x = xStartPos - ( rSlot[i].wide + m_flBoxGap );
504+
rSlot[i].y = ypos;
510505
#ifdef BDSBASE
511-
// now calculate ypos from total height
512-
int ypos = (GetTall() - nTotalHeight) / 2;
513-
for (int i = 0; i < m_iMaxSlots; i++)
514-
{
515-
rSlot[i].y = ypos;
516-
// only include boxgap if slot was visible
517-
ypos += (rSlot[i].tall + (rSlot[i].tall > 0 ? m_flBoxGap : 0));
518-
}
506+
ypos += ( rSlot[i].tall + ( m_flBoxGap * flHeightScale ) );
519507
#else
520-
rSlot[i].y = ypos;
521-
ypos += (rSlot[i].tall + m_flBoxGap);
508+
ypos += ( rSlot[i].tall + m_flBoxGap );
522509
#endif
523510
}
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
524519
}
525520
break;
526521

0 commit comments

Comments
 (0)