Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions src/Ext/Techno/Body.Visuals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
94 changes: 53 additions & 41 deletions src/Ext/Techno/Hooks.Pips.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,65 +3,77 @@
#include <TiberiumClass.h>
#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<BuildingClass*>(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)
Expand Down
10 changes: 0 additions & 10 deletions src/Ext/TechnoType/Hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down