diff --git a/src/Ext/Techno/Body.Visuals.cpp b/src/Ext/Techno/Body.Visuals.cpp index ad07a722a8..a13218550a 100644 --- a/src/Ext/Techno/Body.Visuals.cpp +++ b/src/Ext/Techno/Body.Visuals.cpp @@ -273,9 +273,6 @@ Point2D TechnoExt::GetBuildingSelectBracketPosition(TechnoClass* pThis, Building void TechnoExt::ProcessDigitalDisplays(TechnoClass* pThis) { - if (!Phobos::Config::DigitalDisplay_Enable) - return; - const auto pType = pThis->GetTechnoType(); const auto pTypeExt = TechnoTypeExt::ExtMap.Find(pType); diff --git a/src/Ext/Techno/Hooks.Pips.cpp b/src/Ext/Techno/Hooks.Pips.cpp index 85bc445276..1e9203c591 100644 --- a/src/Ext/Techno/Hooks.Pips.cpp +++ b/src/Ext/Techno/Hooks.Pips.cpp @@ -3,65 +3,77 @@ #include #include "Body.h" -DEFINE_HOOK(0x6F65D1, TechnoClass_DrawHealthBar_Buildings, 0x6) +DEFINE_HOOK(0x6F534E, TechnoClass_DrawExtras_Insignia, 0x5) { - GET(TechnoClass*, pThis, ESI); - GET(int, length, EBX); - GET_STACK(Point2D*, pLocation, STACK_OFFSET(0x4C, 0x4)); - GET_STACK(RectangleStruct*, pBound, STACK_OFFSET(0x4C, 0x8)); + enum { SkipAll = 0x6F5EE3, DrawBubble = 0x6F5E8D }; - const auto pExt = TechnoExt::ExtMap.Find(pThis); + GET(TechnoClass*, pThis, EBP); + GET_STACK(Point2D*, pLocation, STACK_OFFSET(0x98, 0x4)); + GET(RectangleStruct*, pBounds, ESI); - if (const auto pShieldData = pExt->Shield.get()) + bool isSelected = pThis->IsSelected || pThis->IsMouseHovering; + + if (pThis->VisualCharacter(false, nullptr) != VisualType::Hidden) { - if (pShieldData->IsAvailable()) - pShieldData->DrawShieldBar(length, pLocation, pBound); + if (isSelected || !RulesExt::Global()->DrawInsignia_OnlyOnSelected.Get()) + TechnoExt::DrawInsignia(pThis, pLocation, pBounds); } - TechnoExt::ProcessDigitalDisplays(pThis); + const auto pExt = TechnoExt::ExtMap.Find(pThis); - return 0; -} + if (pExt->TypeExtData->HealthBar_Hide) + return SkipAll; -DEFINE_HOOK(0x6F683C, TechnoClass_DrawHealthBar_Units, 0x7) -{ - GET(TechnoClass*, pThis, ESI); - GET_STACK(Point2D*, pLocation, STACK_OFFSET(0x4C, 0x4)); - GET_STACK(RectangleStruct*, pBound, STACK_OFFSET(0x4C, 0x8)); + bool canDrawHealthBar = isSelected || (!pThis->IsSurfaced() && pThis->GetCell()->Sensors_InclHouse(HouseClass::CurrentPlayer->ArrayIndex)); - const auto pExt = TechnoExt::ExtMap.Find(pThis); + // TODO: Rewrite everything from here completely: + // * Health bar (small overhead) + // * Shield bar (massive overhead since digital display merged) + // * Extra progress bars + // * IC, Temporal, ROF, Reload, Factory progress, SW progress, ... + // * Digitals - if (const auto pShieldData = pExt->Shield.get()) + int length; + if (auto pBld = specific_cast(pThis)) { - if (pShieldData->IsAvailable()) + int height = pBld->Type->GetFoundationHeight(false); + length= height * 7 + height / 2; + /* + auto DrawBuildingBar = [pBld, pLocation, pBounds,length](double percent,int pip_frame, int) { - const int length = pThis->WhatAmI() == AbstractType::Infantry ? 8 : 17; - pShieldData->DrawShieldBar(length, pLocation, pBound); - } - } - - TechnoExt::ProcessDigitalDisplays(pThis); - - return 0; -} -DEFINE_HOOK(0x6F534E, TechnoClass_DrawExtras_Insignia, 0x5) -{ - enum { SkipGameCode = 0x6F5388 }; + }; + */ + }else + { + length = pThis->WhatAmI() == AbstractType::Infantry ? 8 : 17; + /* + auto DrawFootBar = [pThis, pLocation, pBounds, length](double percent, int pip_frame, int) + { - GET(TechnoClass*, pThis, EBP); - GET_STACK(Point2D*, pLocation, STACK_OFFSET(0x98, 0x4)); - GET(RectangleStruct*, pBounds, ESI); + }; + */ + } - if (pThis->VisualCharacter(false, nullptr) != VisualType::Hidden) + constexpr bool disguiseCheckUnused = true; + if (canDrawHealthBar) { - if (RulesExt::Global()->DrawInsignia_OnlyOnSelected.Get() && !pThis->IsSelected && !pThis->IsMouseHovering) - return SkipGameCode; - else - TechnoExt::DrawInsignia(pThis, pLocation, pBounds); + pThis->DrawHealthBar(pLocation, pBounds, disguiseCheckUnused); // Rewrite everything in it + // HP, Pips + if (const auto pShieldData = pExt->Shield.get()) + { + if (pShieldData->IsAvailable()) + pShieldData->DrawShieldBar(length, pLocation, pBounds); + } } - return SkipGameCode; + if (isSelected && Phobos::Config::DigitalDisplay_Enable) + TechnoExt::ProcessDigitalDisplays(pThis); + + R->EDI(pLocation); + R->ESI(pBounds); + + return DrawBubble; } DEFINE_HOOK(0x709B2E, TechnoClass_DrawPips_Sizes, 0x5) diff --git a/src/Ext/TechnoType/Hooks.cpp b/src/Ext/TechnoType/Hooks.cpp index ca9784f642..ee62250e68 100644 --- a/src/Ext/TechnoType/Hooks.cpp +++ b/src/Ext/TechnoType/Hooks.cpp @@ -49,16 +49,6 @@ DEFINE_HOOK(0x73D223, UnitClass_DrawIt_OreGath, 0x6) return 0x73D28C; } -DEFINE_HOOK(0x6F64A9, TechnoClass_DrawHealthBar_Hide, 0x5) -{ - GET(TechnoClass*, pThis, ECX); - auto pTypeData = TechnoTypeExt::ExtMap.Find(pThis->GetTechnoType()); - if (pTypeData->HealthBar_Hide) - return 0x6F6AB6; - - return 0; -} - // Issue #503 // Author : Otamaa DEFINE_HOOK(0x4AE670, DisplayClass_GetToolTip_EnemyUIName, 0x8)