Skip to content

Commit

Permalink
show reload progress on ammo hud
Browse files Browse the repository at this point in the history
  • Loading branch information
siecvi committed Jul 28, 2024
1 parent e77a629 commit 29705ba
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion Sources/Client/Client_Draw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -684,6 +684,10 @@ namespace spades {
Vector2 iconSize = MakeVector2(ammoIcon->GetWidth(), ammoIcon->GetHeight());
Vector2 iconPos = MakeVector2(x - (iconSize.x + spacing), y - iconSize.y);

bool isReloading = weapon.IsAwaitingReloadCompletion() && !weapon.IsReloadSlow();
int clip = isReloading
? (int)(clipSize * weapon.GetReloadProgress()) : clipSize;

for (int i = 0; i < clipSize; i++) {
iconPos.x = x - ((float)(i + 1) * (iconSize.x + spacing));

Expand All @@ -693,7 +697,8 @@ namespace spades {

// draw icon
renderer->SetColorAlphaPremultiplied(
(clipNum >= i + 1) ? ammoCol : bgColor);
isReloading ? ((i < clip) ? color : bgColor)
: ((clipNum >= i + 1) ? ammoCol : bgColor));
renderer->DrawImage(ammoIcon, iconPos);
}

Expand Down

0 comments on commit 29705ba

Please sign in to comment.