From 34ee29f51a32921e72e3b7efb155126666113459 Mon Sep 17 00:00:00 2001 From: Trsdy <914137150@qq.com> Date: Mon, 11 Nov 2024 20:26:22 +0800 Subject: [PATCH 1/2] Demo --- src/Ext/Techno/Body.Visuals.cpp | 3 --- src/Ext/Techno/Hooks.Pips.cpp | 35 ++++++++++++++++++++++++--------- src/Ext/TechnoType/Hooks.cpp | 10 ---------- 3 files changed, 26 insertions(+), 22 deletions(-) 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..7d8da7270c 100644 --- a/src/Ext/Techno/Hooks.Pips.cpp +++ b/src/Ext/Techno/Hooks.Pips.cpp @@ -18,8 +18,6 @@ DEFINE_HOOK(0x6F65D1, TechnoClass_DrawHealthBar_Buildings, 0x6) pShieldData->DrawShieldBar(length, pLocation, pBound); } - TechnoExt::ProcessDigitalDisplays(pThis); - return 0; } @@ -40,28 +38,47 @@ DEFINE_HOOK(0x6F683C, TechnoClass_DrawHealthBar_Units, 0x7) } } - TechnoExt::ProcessDigitalDisplays(pThis); - return 0; } DEFINE_HOOK(0x6F534E, TechnoClass_DrawExtras_Insignia, 0x5) { - enum { SkipGameCode = 0x6F5388 }; + enum { SkipAll = 0x6F5EE3, DrawBubble = 0x6F5E8D }; GET(TechnoClass*, pThis, EBP); GET_STACK(Point2D*, pLocation, STACK_OFFSET(0x98, 0x4)); GET(RectangleStruct*, pBounds, ESI); + bool isSelected = pThis->IsSelected || pThis->IsMouseHovering; + if (pThis->VisualCharacter(false, nullptr) != VisualType::Hidden) { - if (RulesExt::Global()->DrawInsignia_OnlyOnSelected.Get() && !pThis->IsSelected && !pThis->IsMouseHovering) - return SkipGameCode; - else + if (isSelected || !RulesExt::Global()->DrawInsignia_OnlyOnSelected.Get()) TechnoExt::DrawInsignia(pThis, pLocation, pBounds); } - return SkipGameCode; + const auto pExt = TechnoExt::ExtMap.Find(pThis); + + if (pExt->TypeExtData->HealthBar_Hide) + return SkipAll; + + bool canDrawHealthBar = isSelected || (!pThis->IsSurfaced() && pThis->GetCell()->Sensors_InclHouse(HouseClass::CurrentPlayer->ArrayIndex)); + + // 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 + + constexpr bool disguiseCheckUnused = true; + if (canDrawHealthBar) + pThis->DrawHealthBar(pLocation, pBounds, disguiseCheckUnused); // Especially you + + if (isSelected && Phobos::Config::DigitalDisplay_Enable) + TechnoExt::ProcessDigitalDisplays(pThis); + + 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) From 788981e276f91dec6f1a6e08b0598ede47c95cf8 Mon Sep 17 00:00:00 2001 From: Trsdy <914137150@qq.com> Date: Sat, 16 Nov 2024 02:20:24 +0800 Subject: [PATCH 2/2] Move shield shit --- src/Ext/Techno/Hooks.Pips.cpp | 75 ++++++++++++++++------------------- 1 file changed, 35 insertions(+), 40 deletions(-) diff --git a/src/Ext/Techno/Hooks.Pips.cpp b/src/Ext/Techno/Hooks.Pips.cpp index 7d8da7270c..1e9203c591 100644 --- a/src/Ext/Techno/Hooks.Pips.cpp +++ b/src/Ext/Techno/Hooks.Pips.cpp @@ -3,44 +3,6 @@ #include #include "Body.h" -DEFINE_HOOK(0x6F65D1, TechnoClass_DrawHealthBar_Buildings, 0x6) -{ - GET(TechnoClass*, pThis, ESI); - GET(int, length, EBX); - GET_STACK(Point2D*, pLocation, STACK_OFFSET(0x4C, 0x4)); - GET_STACK(RectangleStruct*, pBound, STACK_OFFSET(0x4C, 0x8)); - - const auto pExt = TechnoExt::ExtMap.Find(pThis); - - if (const auto pShieldData = pExt->Shield.get()) - { - if (pShieldData->IsAvailable()) - pShieldData->DrawShieldBar(length, pLocation, pBound); - } - - return 0; -} - -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)); - - const auto pExt = TechnoExt::ExtMap.Find(pThis); - - if (const auto pShieldData = pExt->Shield.get()) - { - if (pShieldData->IsAvailable()) - { - const int length = pThis->WhatAmI() == AbstractType::Infantry ? 8 : 17; - pShieldData->DrawShieldBar(length, pLocation, pBound); - } - } - - return 0; -} - DEFINE_HOOK(0x6F534E, TechnoClass_DrawExtras_Insignia, 0x5) { enum { SkipAll = 0x6F5EE3, DrawBubble = 0x6F5E8D }; @@ -71,13 +33,46 @@ DEFINE_HOOK(0x6F534E, TechnoClass_DrawExtras_Insignia, 0x5) // * IC, Temporal, ROF, Reload, Factory progress, SW progress, ... // * Digitals + int length; + if (auto pBld = specific_cast(pThis)) + { + int height = pBld->Type->GetFoundationHeight(false); + length= height * 7 + height / 2; + /* + auto DrawBuildingBar = [pBld, pLocation, pBounds,length](double percent,int pip_frame, int) + { + + }; + */ + }else + { + length = pThis->WhatAmI() == AbstractType::Infantry ? 8 : 17; + /* + auto DrawFootBar = [pThis, pLocation, pBounds, length](double percent, int pip_frame, int) + { + + }; + */ + } + constexpr bool disguiseCheckUnused = true; if (canDrawHealthBar) - pThis->DrawHealthBar(pLocation, pBounds, disguiseCheckUnused); // Especially you - + { + 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); + } + } + if (isSelected && Phobos::Config::DigitalDisplay_Enable) TechnoExt::ProcessDigitalDisplays(pThis); + R->EDI(pLocation); + R->ESI(pBounds); + return DrawBubble; }