Skip to content
This repository was archived by the owner on Jan 5, 2024. It is now read-only.

Commit fe20858

Browse files
committed
Cleaned up unheld item HUD logic so it's separated from blink timer
1 parent 6da3a00 commit fe20858

File tree

1 file changed

+23
-29
lines changed

1 file changed

+23
-29
lines changed

Entities/HeldDevice.cpp

Lines changed: 23 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,7 @@ void HeldDevice::DrawHUD(BITMAP *pTargetBitmap, const Vector &targetPos, int whi
548548
// Only draw if the team viewing this has seen the space where this is located.
549549
int viewingPlayer = g_ActivityMan.GetActivity()->PlayerOfScreen(whichScreen);
550550
int viewingTeam = g_ActivityMan.GetActivity()->GetTeamOfPlayer(viewingPlayer);
551-
if (viewingTeam != Activity::NoTeam && g_SceneMan.IsUnseen(m_Pos.GetFloorIntX(), m_Pos.GetFloorIntY(), viewingTeam)) {
551+
if (viewingTeam == Activity::NoTeam || g_SceneMan.IsUnseen(m_Pos.GetFloorIntX(), m_Pos.GetFloorIntY(), viewingTeam)) {
552552
return;
553553
}
554554

@@ -573,39 +573,33 @@ void HeldDevice::DrawHUD(BITMAP *pTargetBitmap, const Vector &targetPos, int whi
573573
}
574574
}
575575

576-
char str[64];
577-
str[0] = 0;
578576
GUIFont *pSymbolFont = g_FrameMan.GetLargeFont();
579577
GUIFont *pTextFont = g_FrameMan.GetSmallFont();
580578
if (pSymbolFont && pTextFont) {
581-
if (m_BlinkTimer.GetElapsedSimTimeMS() > 750) {
582-
str[0] = -40;
583-
str[1] = 0;
584-
} else if (m_BlinkTimer.GetElapsedSimTimeMS() > 500) {
585-
str[0] = -41;
586-
str[1] = 0;
587-
} else if (m_BlinkTimer.GetElapsedSimTimeMS() > 250) {
588-
str[0] = -42;
589-
str[1] = 0;
590-
} else if (m_BlinkTimer.GetElapsedSimTimeMS() > 0) {
591-
str[0] = 0;
592-
} else {
593-
// Check for nearby cursors that will toggle this pickup HUD.
594-
float range = g_SettingsMan.GetUnheldItemsHUDDisplayRange();
595-
if (g_ActivityMan.GetActivity()->GetActivityState() != Activity::ActivityState::Running) {
596-
range = -1.0F;
597-
} else if (const GameActivity *gameActivity = dynamic_cast<const GameActivity *>(g_ActivityMan.GetActivity())) {
598-
if (gameActivity->GetViewState(viewingPlayer) == GameActivity::ViewState::ActorSelect) {
599-
range = -1.0F;
600-
}
601-
}
602-
m_SeenByPlayer.at(viewingPlayer) = range < 0 || (range > 0 && g_SceneMan.ShortestDistance(m_Pos, g_SceneMan.GetScrollTarget(whichScreen), g_SceneMan.SceneWrapsX()).GetMagnitude() < range);
579+
const Activity *activity = g_ActivityMan.GetActivity();
580+
float unheldItemDisplayRange = activity->GetActivityState() == Activity::ActivityState::Running ? g_SettingsMan.GetUnheldItemsHUDDisplayRange() : -1.0F;
603581
}
582+
m_SeenByPlayer.at(viewingPlayer) = unheldItemDisplayRange < 0 || (unheldItemDisplayRange > 0 && g_SceneMan.ShortestDistance(m_Pos, g_SceneMan.GetScrollTarget(whichScreen), g_SceneMan.SceneWrapsX()).GetMagnitude() < unheldItemDisplayRange);
583+
604584
if (m_SeenByPlayer.at(viewingPlayer)) {
605-
AllegroBitmap pBitmapInt(pTargetBitmap);
606-
pSymbolFont->DrawAligned(&pBitmapInt, drawPos.GetFloorIntX() - 1, drawPos.GetFloorIntY() - 20, str, GUIFont::Centre);
607-
std::snprintf(str, sizeof(str), "%s", m_PresetName.c_str());
608-
pTextFont->DrawAligned(&pBitmapInt, drawPos.GetFloorIntX(), drawPos.GetFloorIntY() - 29, str, GUIFont::Centre);
585+
char pickupArrowString[64];
586+
pickupArrowString[0] = 0;
587+
if (m_BlinkTimer.GetElapsedSimTimeMS() < 250) {
588+
pickupArrowString[0] = 0;
589+
} else if (m_BlinkTimer.GetElapsedSimTimeMS() < 500) {
590+
pickupArrowString[0] = -42;
591+
pickupArrowString[1] = 0;
592+
} else if (m_BlinkTimer.GetElapsedSimTimeMS() < 750) {
593+
pickupArrowString[0] = -41;
594+
pickupArrowString[1] = 0;
595+
} else if (m_BlinkTimer.GetElapsedSimTimeMS() < 1000) {
596+
pickupArrowString[0] = -40;
597+
pickupArrowString[1] = 0;
598+
}
599+
600+
AllegroBitmap targetAllegroBitmap(pTargetBitmap);
601+
pSymbolFont->DrawAligned(&targetAllegroBitmap, drawPos.GetFloorIntX() - 1, drawPos.GetFloorIntY() - 20, pickupArrowString, GUIFont::Centre);
602+
pTextFont->DrawAligned(&targetAllegroBitmap, drawPos.GetFloorIntX(), drawPos.GetFloorIntY() - 29, m_PresetName, GUIFont::Centre);
609603
}
610604
}
611605
}

0 commit comments

Comments
 (0)