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

Commit e1f1031

Browse files
committed
Added inventory menu handling to allow 1-handed bg equipped items to be put into empty fg arm and vice-versa
Added better gui text for bg equipped items so they'll show up even if there's no fg equipped item. Also cleaned up code in that area a little bit.
1 parent e03cec2 commit e1f1031

File tree

2 files changed

+27
-31
lines changed

2 files changed

+27
-31
lines changed

Entities/AHuman.cpp

Lines changed: 23 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -4309,44 +4309,39 @@ void AHuman::DrawHUD(BITMAP *pTargetBitmap, const Vector &targetPos, int whichSc
43094309

43104310
m_HUDStack -= 10;
43114311
if (m_pFGArm && !m_EquipHUDTimer.IsPastRealMS(500)) {
4312-
if (m_pFGArm->HoldsSomething()) {
4313-
pSmallFont->DrawAligned(&allegroBitmap, drawPos.GetFloorIntX() + 1, drawPos.GetFloorIntY() + m_HUDStack + 3, m_pFGArm->GetHeldMO()->GetPresetName().c_str(), GUIFont::Centre);
4314-
} else {
4315-
pSmallFont->DrawAligned(&allegroBitmap, drawPos.GetFloorIntX() + 1, drawPos.GetFloorIntY() + m_HUDStack + 3, "EMPTY", GUIFont::Centre);
4316-
}
4312+
std::string equippedItemsString = (m_pFGArm->HoldsSomething() ? m_pFGArm->GetHeldMO()->GetPresetName() : "EMPTY") + (m_pBGArm->HoldsSomething() ? " | " + m_pBGArm->GetHeldMO()->GetPresetName() : "");
4313+
pSmallFont->DrawAligned(&allegroBitmap, drawPos.GetFloorIntX() + 1, drawPos.GetFloorIntY() + m_HUDStack + 3, equippedItemsString, GUIFont::Centre);
43174314
m_HUDStack -= 9;
43184315
}
43194316
}
43204317
// Held-related GUI stuff
4321-
else if (m_pFGArm) {
4322-
HDFirearm *pHeldFirearm = dynamic_cast<HDFirearm *>(m_pFGArm->GetHeldDevice());
4323-
4324-
// Ammo
4325-
if (pHeldFirearm)
4326-
{
4327-
MovableObject *bgHeldItem = GetEquippedBGItem();
4328-
HDFirearm const *bgHeldFirearm = bgHeldItem == NULL ? NULL : dynamic_cast<HDFirearm *>(bgHeldItem);
4318+
else if (m_pFGArm || m_pBGArm) {
4319+
HDFirearm *fgHeldFirearm = dynamic_cast<HDFirearm *>(m_pFGArm->GetHeldDevice());
4320+
MovableObject *bgHeldItem = GetEquippedBGItem();
4321+
const HDFirearm *bgHeldFirearm = dynamic_cast<HDFirearm *>(bgHeldItem);
43294322

4323+
if (fgHeldFirearm || bgHeldFirearm) {
43304324
str[0] = -56; str[1] = 0;
4331-
pSymbolFont->DrawAligned(&allegroBitmap, drawPos.m_X - 10, drawPos.m_Y + m_HUDStack, str, GUIFont::Left);
4332-
std::string fgWeaponString;
4333-
4334-
if (pHeldFirearm->IsReloading()) {
4335-
fgWeaponString = "Reloading";
4336-
rectfill(pTargetBitmap, drawPos.GetFloorIntX() + 1, drawPos.GetFloorIntY() + m_HUDStack + 13, drawPos.GetFloorIntX() + 29, drawPos.GetFloorIntY() + m_HUDStack + 14, 245);
4337-
rectfill(pTargetBitmap, drawPos.GetFloorIntX(), drawPos.GetFloorIntY() + m_HUDStack + 12, drawPos.GetFloorIntX() + static_cast<int>(28.0F * pHeldFirearm->GetReloadProgress() + 0.5F), drawPos.GetFloorIntY() + m_HUDStack + 13, 77);
4338-
} else {
4339-
fgWeaponString = pHeldFirearm->GetRoundInMagCount() < 0 ? "Infinite" : std::to_string(pHeldFirearm->GetRoundInMagCount());
4325+
pSymbolFont->DrawAligned(&allegroBitmap, drawPos.GetFloorIntX() - 10, drawPos.GetFloorIntY() + m_HUDStack, str, GUIFont::Left);
4326+
4327+
std::string fgWeaponString = "EMPTY";
4328+
if (fgHeldFirearm) {
4329+
if (fgHeldFirearm->IsReloading()) {
4330+
fgWeaponString = "Reloading";
4331+
rectfill(pTargetBitmap, drawPos.GetFloorIntX() + 1, drawPos.GetFloorIntY() + m_HUDStack + 13, drawPos.GetFloorIntX() + 29, drawPos.GetFloorIntY() + m_HUDStack + 14, 245);
4332+
rectfill(pTargetBitmap, drawPos.GetFloorIntX(), drawPos.GetFloorIntY() + m_HUDStack + 12, drawPos.GetFloorIntX() + static_cast<int>(28.0F * fgHeldFirearm->GetReloadProgress() + 0.5F), drawPos.GetFloorIntY() + m_HUDStack + 13, 77);
4333+
} else {
4334+
fgWeaponString = fgHeldFirearm->GetRoundInMagCount() < 0 ? "Infinite" : std::to_string(fgHeldFirearm->GetRoundInMagCount());
4335+
}
43404336
}
43414337

43424338
if (bgHeldItem && bgHeldFirearm) {
43434339
std::string bgWeaponString;
4344-
43454340
if (bgHeldFirearm->IsReloading()) {
43464341
bgWeaponString = "Reloading";
4347-
int textWidth = pSmallFont->CalculateWidth(fgWeaponString) + 6;
4348-
rectfill(pTargetBitmap, drawPos.GetFloorIntX() + 1 + textWidth, drawPos.GetFloorIntY() + m_HUDStack + 13, drawPos.GetFloorIntX() + 29 + textWidth, drawPos.GetFloorIntY() + m_HUDStack + 14, 245);
4349-
rectfill(pTargetBitmap, drawPos.GetFloorIntX() + textWidth, drawPos.GetFloorIntY() + m_HUDStack + 12, drawPos.GetFloorIntX() + static_cast<int>(28.0F * bgHeldFirearm->GetReloadProgress() + 0.5F) + textWidth, drawPos.GetFloorIntY() + m_HUDStack + 13, 77);
4342+
int totalTextWidth = pSmallFont->CalculateWidth(fgWeaponString) + 6;
4343+
rectfill(pTargetBitmap, drawPos.GetFloorIntX() + 1 + totalTextWidth, drawPos.GetFloorIntY() + m_HUDStack + 13, drawPos.GetFloorIntX() + 29 + totalTextWidth, drawPos.GetFloorIntY() + m_HUDStack + 14, 245);
4344+
rectfill(pTargetBitmap, drawPos.GetFloorIntX() + totalTextWidth, drawPos.GetFloorIntY() + m_HUDStack + 12, drawPos.GetFloorIntX() + static_cast<int>(28.0F * bgHeldFirearm->GetReloadProgress() + 0.5F) + totalTextWidth, drawPos.GetFloorIntY() + m_HUDStack + 13, 77);
43504345
} else {
43514346
bgWeaponString = bgHeldFirearm->GetRoundInMagCount() < 0 ? "Infinite" : std::to_string(bgHeldFirearm->GetRoundInMagCount());
43524347
}
@@ -4372,11 +4367,8 @@ void AHuman::DrawHUD(BITMAP *pTargetBitmap, const Vector &targetPos, int whichSc
43724367
m_HUDStack -= 11;
43734368
}
43744369
*/
4375-
if (m_pFGArm->HoldsSomething()) {
4376-
pSmallFont->DrawAligned(&allegroBitmap, drawPos.GetFloorIntX() + 1, drawPos.GetFloorIntY() + m_HUDStack + 3, m_pFGArm->GetHeldMO()->GetPresetName().c_str(), GUIFont::Centre);
4377-
} else {
4378-
pSmallFont->DrawAligned(&allegroBitmap, drawPos.GetFloorIntX() + 1, drawPos.GetFloorIntY() + m_HUDStack + 3, "EMPTY", GUIFont::Centre);
4379-
}
4370+
std::string equippedItemsString = (m_pFGArm->HoldsSomething() ? m_pFGArm->GetHeldMO()->GetPresetName() : "EMPTY") + (m_pBGArm->HoldsSomething() ? " | " + m_pBGArm->GetHeldMO()->GetPresetName() : "");
4371+
pSmallFont->DrawAligned(&allegroBitmap, drawPos.GetFloorIntX() + 1, drawPos.GetFloorIntY() + m_HUDStack + 3, equippedItemsString, GUIFont::Centre);
43804372
m_HUDStack -= 9;
43814373
/*
43824374
// Reload GUI, only show when there's nothing to pick up

Menus/InventoryMenuGUI.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1163,6 +1163,10 @@ namespace RTE {
11631163
if (buttonEquippedItemIndex > -1) {
11641164
Arm *selectedItemArm = dynamic_cast<Arm *>(m_GUISelectedItem->Object->GetParent());
11651165
Arm *buttonObjectArm = selectedItemArm && buttonObject ? dynamic_cast<Arm *>(buttonObject->GetParent()) : nullptr;
1166+
if (!buttonObject) {
1167+
const AHuman *inventoryActorAsAHuman = dynamic_cast<const AHuman *>(m_InventoryActor);
1168+
buttonObjectArm = buttonEquippedItemIndex == 0 ? inventoryActorAsAHuman->GetFGArm() : inventoryActorAsAHuman->GetBGArm();
1169+
}
11661170
if (selectedItemArm && buttonObjectArm) {
11671171
selectedItemArm->ReleaseHeldMO();
11681172
buttonObjectArm->ReleaseHeldMO();

0 commit comments

Comments
 (0)