From 514420d072eb31558eb9f009e347a8d8e9433b74 Mon Sep 17 00:00:00 2001 From: Fryone Date: Wed, 25 Sep 2024 19:36:59 +0300 Subject: [PATCH 01/20] custom health bar types Initial commit --- Phobos.vcxproj | 2 + src/Ext/Rules/Body.cpp | 2 + src/Ext/Techno/Hooks.Pips.cpp | 92 +++++++++++++++++++++++++++++ src/Ext/TechnoType/Body.cpp | 4 ++ src/Ext/TechnoType/Body.h | 5 ++ src/New/Type/HealthBarTypeClass.cpp | 56 ++++++++++++++++++ src/New/Type/HealthBarTypeClass.h | 40 +++++++++++++ src/Phobos.Ext.cpp | 4 +- 8 files changed, 204 insertions(+), 1 deletion(-) create mode 100644 src/New/Type/HealthBarTypeClass.cpp create mode 100644 src/New/Type/HealthBarTypeClass.h diff --git a/Phobos.vcxproj b/Phobos.vcxproj index da0fa52603..8585d70341 100644 --- a/Phobos.vcxproj +++ b/Phobos.vcxproj @@ -74,6 +74,7 @@ + @@ -215,6 +216,7 @@ + diff --git a/src/Ext/Rules/Body.cpp b/src/Ext/Rules/Body.cpp index 336cae4272..cd0cda2db8 100644 --- a/src/Ext/Rules/Body.cpp +++ b/src/Ext/Rules/Body.cpp @@ -9,6 +9,7 @@ #include #include #include +#include std::unique_ptr RulesExt::Data = nullptr; @@ -34,6 +35,7 @@ void RulesExt::LoadBeforeTypeData(RulesClass* pThis, CCINIClass* pINI) ShieldTypeClass::LoadFromINIList(pINI); LaserTrailTypeClass::LoadFromINIList(&CCINIClass::INI_Art.get()); AttachEffectTypeClass::LoadFromINIList(pINI); + HealthBarTypeClass::LoadFromINIList(pINI); Data->LoadBeforeTypeData(pThis, pINI); } diff --git a/src/Ext/Techno/Hooks.Pips.cpp b/src/Ext/Techno/Hooks.Pips.cpp index 064274c7d7..4d97e89491 100644 --- a/src/Ext/Techno/Hooks.Pips.cpp +++ b/src/Ext/Techno/Hooks.Pips.cpp @@ -275,3 +275,95 @@ DEFINE_HOOK(0x70A4FB, TechnoClass_DrawPips_SelfHealGain, 0x5) return SkipGameDrawing; } + +DEFINE_HOOK(0x6F64C1, TechnoClass_DrawHealthBar_BuildingHealthBar, 0xA) +{ + enum { Continue = 0x6F64CB, Skip = 0x6F683C }; + GET(TechnoClass*, pThis, ESI); + + R->EAX(pThis->GetTechnoType()); + + const auto pTypeExt = TechnoTypeExt::ExtMap.Find(pThis->GetTechnoType()); + + if(pThis->WhatAmI() == AbstractType::Building && pTypeExt->CustomHealthBarType) + return Skip; + + return Continue; +} + +DEFINE_HOOK(0x6F6846, TechnoClass_DrawHealthBar_CustomHealthBar, 0x6) +{ + enum { Continue = 0x6F68E8, ContinueInf = 0x6F6852, Skip = 0x6F6A58 }; + GET(TechnoClass*, pThis, ESI); + GET_STACK(Point2D*, pLocation, STACK_OFFSET(0x4C, 0x4)); + GET_STACK(RectangleStruct*, pBound, STACK_OFFSET(0x4C, 0x8)); + const auto pTypeExt = TechnoTypeExt::ExtMap.Find(pThis->GetTechnoType()); + + bool pThisIsInf = pThis->WhatAmI() == AbstractType::Infantry; + + if(!pTypeExt->CustomHealthBarType) + { + R->AL(pThis->IsSelected); + if(pThisIsInf) + return ContinueInf; + return Continue; + } + + const auto thisHBType = pTypeExt->CustomHealthBarType.Get(); + const auto pipBoardBG = thisHBType->Frame_Background.Get(FileSystem::PIPBRD_SHP()); + const bool pipBoardBGVisibility = thisHBType->Frame_Background_ShowWhenNotSelected.Get(); + const BlitterFlags blitFlags = thisHBType->Frame_Background_Translucency.Get(0); + const auto pipBoardFG = thisHBType->Frame_Foreground.Get(); + const bool pipBoardFGVisibility = thisHBType->Frame_Foreground_ShowWhenNotSelected.Get(); + const int pipsOffset = thisHBType->HealthBar_XOffset.Get(); + const Vector3D pipsFrames = thisHBType->Sections_Pips.Get(); + const int pipsAmount = thisHBType->Sections_Amount.Get(); + const int pipsSize = thisHBType->Sections_Size.Get(); + + int top_adjust = pThisIsInf ? -25 : -26; + int left_adjust = pipsAmount * pipsSize / 2 - pipsSize; + left_adjust = (pipsAmount % 2 == 0) ? left_adjust - 1 : left_adjust; + int border_adjust = (pipsAmount % 2 == 0) ? 1 : 0; + Point2D position; + + if(pThis->WhatAmI() == AbstractType::Building) + top_adjust -= static_cast(pThis)->Type->Height * Unsorted::CellHeightInPixels / 2; + + if(pThis->IsSelected || pipBoardBGVisibility) + { + position.X = pLocation->X + 1 + border_adjust + pipsOffset; + position.Y = pThis->GetTechnoType()->PixelSelectionBracketDelta + pLocation->Y + top_adjust; + DSurface::Temp->DrawSHP(FileSystem::PALETTE_PAL, pipBoardBG, + 0, &position, pBound, BlitterFlags(0xE00) | blitFlags, 0, 0, ZGradient::Ground, 1000, 0, 0, 0, 0, 0); + } + + double health = pThis->GetHealthPercentage(); + int frameIdxa = pipsFrames.Z; + + if (health > RulesClass::Instance->ConditionYellow) + frameIdxa = pipsFrames.X; + else if (health > RulesClass::Instance->ConditionRed) + frameIdxa = pipsFrames.Y; + + int pipsNeeded = (int)round(health * pipsAmount); + pipsNeeded = pipsNeeded <= 0 ? 1 : pipsNeeded; + + for(int i = 0; i < pipsNeeded; ++i) + { + position.X = pLocation->X - left_adjust + pipsOffset + pipsSize * i; + position.Y = pThis->GetTechnoType()->PixelSelectionBracketDelta + pLocation->Y + top_adjust + 1; + DSurface::Temp->DrawSHP(FileSystem::PALETTE_PAL, FileSystem::PIPS_SHP(), + frameIdxa, &position, pBound, BlitterFlags(0x600), 0, 0, ZGradient::Ground, 1000, 0, 0, 0, 0, 0); + } + + if(pipBoardFG && (pThis->IsSelected || pipBoardFGVisibility)) + { + position.X = pLocation->X + 1 + border_adjust + pipsOffset; + position.Y = pThis->GetTechnoType()->PixelSelectionBracketDelta + pLocation->Y + top_adjust; + DSurface::Temp->DrawSHP(FileSystem::PALETTE_PAL, pipBoardFG, + 0, &position, pBound, BlitterFlags(0xE00), 0, 0, ZGradient::Ground, 1000, 0, 0, 0, 0, 0); + } + + R->EDI(pLocation); + return Skip; +} diff --git a/src/Ext/TechnoType/Body.cpp b/src/Ext/TechnoType/Body.cpp index aef8425b07..13d7ed94dc 100644 --- a/src/Ext/TechnoType/Body.cpp +++ b/src/Ext/TechnoType/Body.cpp @@ -319,6 +319,8 @@ void TechnoTypeExt::ExtData::LoadFromINIFile(CCINIClass* const pINI) this->Wake_Grapple.Read(exINI, pSection, "Wake.Grapple"); this->Wake_Sinking.Read(exINI, pSection, "Wake.Sinking"); + this->CustomHealthBarType.Read(exINI, pSection, "CustomHealthBarType"); + // Ares 0.2 this->RadarJamRadius.Read(exINI, pSection, "RadarJamRadius"); @@ -688,6 +690,8 @@ void TechnoTypeExt::ExtData::Serialize(T& Stm) .Process(this->Wake) .Process(this->Wake_Grapple) .Process(this->Wake_Sinking) + + .Process(this->CustomHealthBarType) ; } void TechnoTypeExt::ExtData::LoadFromStream(PhobosStreamReader& Stm) diff --git a/src/Ext/TechnoType/Body.h b/src/Ext/TechnoType/Body.h index b390188549..7b40c39037 100644 --- a/src/Ext/TechnoType/Body.h +++ b/src/Ext/TechnoType/Body.h @@ -12,6 +12,7 @@ #include #include #include +#include class Matrix3D; @@ -233,6 +234,8 @@ class TechnoTypeExt Nullable Wake_Grapple; Nullable Wake_Sinking; + Valueable CustomHealthBarType; + struct LaserTrailDataEntry { ValueableIdx idxType; @@ -461,6 +464,8 @@ class TechnoTypeExt , Wake { } , Wake_Grapple { } , Wake_Sinking { } + + , CustomHealthBarType {} { } virtual ~ExtData() = default; diff --git a/src/New/Type/HealthBarTypeClass.cpp b/src/New/Type/HealthBarTypeClass.cpp new file mode 100644 index 0000000000..1c9e8cecbe --- /dev/null +++ b/src/New/Type/HealthBarTypeClass.cpp @@ -0,0 +1,56 @@ +#include "HealthBarTypeClass.h" + +#include +#include + +#include + +template<> +const char* Enumerable::GetMainSection() +{ + return "HealthBarTypes"; +} + +void HealthBarTypeClass::LoadFromINI(CCINIClass* pINI) +{ + const char* section = this->Name; + + INI_EX exINI(pINI); + + this->Frame_Background.Read(exINI, section, "Frame.Background"); + this->Frame_Background_ShowWhenNotSelected.Read(exINI, section, "Frame.Background.ShowWhenNotSelected"); + this->Frame_Background_Translucency.Read(exINI, section, "Frame.Background.Translucency"); + this->Frame_Foreground.Read(exINI, section, "Frame.Foreground"); + this->Frame_Foreground_ShowWhenNotSelected.Read(exINI, section, "Frame.Foreground.ShowWhenNotSelected"); + this->HealthBar_XOffset.Read(exINI, section, "HealthBar.OffsetX"); + this->Sections_Pips.Read(exINI, section, "Sections.Pips"); + this->Sections_Amount.Read(exINI, section, "Sections.Amount"); + this->Sections_Size.Read(exINI, section, "Sections.Size"); + +} + +template +void HealthBarTypeClass::Serialize(T& Stm) +{ + Stm + .Process(this->Frame_Background) + .Process(this->Frame_Background_ShowWhenNotSelected) + .Process(this->Frame_Background_Translucency) + .Process(this->Frame_Foreground) + .Process(this->Frame_Foreground_ShowWhenNotSelected) + .Process(this->HealthBar_XOffset) + .Process(this->Sections_Pips) + .Process(this->Sections_Amount) + .Process(this->Sections_Size) + ; +} + +void HealthBarTypeClass::LoadFromStream(PhobosStreamReader& Stm) +{ + this->Serialize(Stm); +} + +void HealthBarTypeClass::SaveToStream(PhobosStreamWriter& Stm) +{ + this->Serialize(Stm); +} diff --git a/src/New/Type/HealthBarTypeClass.h b/src/New/Type/HealthBarTypeClass.h new file mode 100644 index 0000000000..d6af051b43 --- /dev/null +++ b/src/New/Type/HealthBarTypeClass.h @@ -0,0 +1,40 @@ +#pragma once +#include +#include +#include +#include +#include + +class HealthBarTypeClass final : public Enumerable +{ +public: + Nullable Frame_Background; + Valueable Frame_Background_ShowWhenNotSelected; + Nullable Frame_Background_Translucency; + Nullable Frame_Foreground; + Valueable Frame_Foreground_ShowWhenNotSelected; + Valueable HealthBar_XOffset; + Valueable> Sections_Pips; + Valueable Sections_Amount; + Valueable Sections_Size; + + HealthBarTypeClass(const char* pTitle = NONE_STR) : Enumerable(pTitle) + , Frame_Background { } + , Frame_Background_ShowWhenNotSelected { false } + , Frame_Background_Translucency { } + , Frame_Foreground { } + , Frame_Foreground_ShowWhenNotSelected { false } + , HealthBar_XOffset { 0 } + , Sections_Pips { { 16,17,18 } } + , Sections_Amount { 17 } + , Sections_Size { 2 } + { } + + void LoadFromINI(CCINIClass* pINI); + void LoadFromStream(PhobosStreamReader& Stm); + void SaveToStream(PhobosStreamWriter& Stm); + +private: + template + void Serialize(T& Stm); +}; diff --git a/src/Phobos.Ext.cpp b/src/Phobos.Ext.cpp index 9d743dd835..6621d98ff7 100644 --- a/src/Phobos.Ext.cpp +++ b/src/Phobos.Ext.cpp @@ -32,6 +32,7 @@ #include #include #include +#include #include @@ -229,7 +230,8 @@ using PhobosTypeRegistry = TypeRegistry< ShieldClass, DigitalDisplayTypeClass, AttachEffectTypeClass, - AttachEffectClass + AttachEffectClass, + HealthBarTypeClass // other classes >; From 35350e4f3fbbc48fb98f8ef8e377e690530edf38 Mon Sep 17 00:00:00 2001 From: Fryone Date: Sat, 28 Sep 2024 14:35:31 +0300 Subject: [PATCH 02/20] changed to BarTypes - added emptypip - added draw direction - added border offset - changed overall logic --- Phobos.vcxproj | 4 +- src/Ext/Rules/Body.cpp | 4 +- src/Ext/Techno/Body.Visuals.cpp | 59 ++++++++++++++++++++++++++ src/Ext/Techno/Body.h | 1 + src/Ext/Techno/Hooks.Pips.cpp | 63 +++++----------------------- src/Ext/TechnoType/Body.cpp | 4 +- src/Ext/TechnoType/Body.h | 6 +-- src/New/Type/BarTypeClass.cpp | 64 +++++++++++++++++++++++++++++ src/New/Type/BarTypeClass.h | 48 ++++++++++++++++++++++ src/New/Type/HealthBarTypeClass.cpp | 56 ------------------------- src/New/Type/HealthBarTypeClass.h | 40 ------------------ src/Phobos.Ext.cpp | 4 +- 12 files changed, 193 insertions(+), 160 deletions(-) create mode 100644 src/New/Type/BarTypeClass.cpp create mode 100644 src/New/Type/BarTypeClass.h delete mode 100644 src/New/Type/HealthBarTypeClass.cpp delete mode 100644 src/New/Type/HealthBarTypeClass.h diff --git a/Phobos.vcxproj b/Phobos.vcxproj index 8585d70341..cd71d5691d 100644 --- a/Phobos.vcxproj +++ b/Phobos.vcxproj @@ -74,7 +74,7 @@ - + @@ -216,7 +216,7 @@ - + diff --git a/src/Ext/Rules/Body.cpp b/src/Ext/Rules/Body.cpp index cd0cda2db8..b78731bb52 100644 --- a/src/Ext/Rules/Body.cpp +++ b/src/Ext/Rules/Body.cpp @@ -9,7 +9,7 @@ #include #include #include -#include +#include std::unique_ptr RulesExt::Data = nullptr; @@ -35,7 +35,7 @@ void RulesExt::LoadBeforeTypeData(RulesClass* pThis, CCINIClass* pINI) ShieldTypeClass::LoadFromINIList(pINI); LaserTrailTypeClass::LoadFromINIList(&CCINIClass::INI_Art.get()); AttachEffectTypeClass::LoadFromINIList(pINI); - HealthBarTypeClass::LoadFromINIList(pINI); + BarTypeClass::LoadFromINIList(pINI); Data->LoadBeforeTypeData(pThis, pINI); } diff --git a/src/Ext/Techno/Body.Visuals.cpp b/src/Ext/Techno/Body.Visuals.cpp index 4b959b1f37..a017906be0 100644 --- a/src/Ext/Techno/Body.Visuals.cpp +++ b/src/Ext/Techno/Body.Visuals.cpp @@ -469,3 +469,62 @@ void TechnoExt::GetValuesForDisplay(TechnoClass* pThis, DisplayInfoType infoType } } } + +void TechnoExt::DrawBar(TechnoClass* pThis, BarTypeClass* barType, Point2D pLocation, RectangleStruct* pBounds, double barPercentage, double yellowCond, double redCond) +{ + const BlitterFlags blitFlagsBG = barType->BoardBG_Translucency.Get(0); + const BlitterFlags blitFlagsFG = barType->BoardFG_Translucency.Get(0); + const Point2D sectionOffset = barType->Sections_PositionDelta; + const Vector3D sectionFrames = barType->Sections_Pips; + const int sectionAmount = barType->Sections_Amount; + const int sectionEmptyFrame = barType->Sections_EmptyPip; + const bool drawBackwards = barType->Sections_DrawBackwards; + int sectionsToDraw = (int)round(sectionAmount * barPercentage); + sectionsToDraw = sectionsToDraw == 0 ? 1 : sectionsToDraw; + int frameIdxa = sectionFrames.Z; + + if (barPercentage > yellowCond) + frameIdxa = sectionFrames.X; + else if (barPercentage > redCond) + frameIdxa = sectionFrames.Y; + + pLocation += barType->Bar_Offset; + Point2D boardPosition = pLocation + barType->Board_Offset; + + if(barType->BoardBG_File && (pThis->IsSelected || barType->BoardBG_ShowWhenNotSelected)) + DSurface::Temp->DrawSHP(FileSystem::PALETTE_PAL, barType->BoardBG_File.Get(), + 0, &boardPosition, pBounds, BlitterFlags(0xE00) | blitFlagsBG, 0, 0, ZGradient::Ground, 1000, 0, 0, 0, 0, 0); + + Point2D position = pLocation; + position.X += drawBackwards ? (int)round(sectionAmount * sectionOffset.X / 2) : -(int)round(sectionAmount * sectionOffset.X / 2); + position.Y += drawBackwards ? (int)round(sectionAmount * sectionOffset.Y / 2) : -(int)round(sectionAmount * sectionOffset.Y / 2); + + if(sectionEmptyFrame != -1) + { + for(int i = 0; i < sectionAmount; ++i) + { + position += drawBackwards ? -sectionOffset : sectionOffset; + DSurface::Temp->DrawSHP(FileSystem::PALETTE_PAL, FileSystem::PIPS_SHP(), + sectionEmptyFrame, &position, pBounds, BlitterFlags(0x600), 0, 0, ZGradient::Ground, 1000, 0, 0, 0, 0, 0); + } + + position = pLocation; + position.X += drawBackwards ? (int)round(sectionAmount * sectionOffset.X / 2) : -(int)round(sectionAmount * sectionOffset.X / 2); + position.Y += drawBackwards ? (int)round(sectionAmount * sectionOffset.Y / 2) : -(int)round(sectionAmount * sectionOffset.Y / 2); + } + + if(drawBackwards) + for(int i = 0; i < (sectionAmount - sectionsToDraw); ++i) + position -= sectionOffset; + + for(int i = 0; i < sectionsToDraw; ++i) + { + position += drawBackwards ? -sectionOffset : sectionOffset; + DSurface::Temp->DrawSHP(FileSystem::PALETTE_PAL, FileSystem::PIPS_SHP(), + frameIdxa, &position, pBounds, BlitterFlags(0x600), 0, 0, ZGradient::Ground, 1000, 0, 0, 0, 0, 0); + } + + if(barType->BoardFG_File && (pThis->IsSelected || barType->BoardFG_ShowWhenNotSelected)) + DSurface::Temp->DrawSHP(FileSystem::PALETTE_PAL, barType->BoardFG_File.Get(), + 0, &boardPosition, pBounds, BlitterFlags(0xE00) | blitFlagsFG, 0, 0, ZGradient::Ground, 1000, 0, 0, 0, 0, 0); +} diff --git a/src/Ext/Techno/Body.h b/src/Ext/Techno/Body.h index 0a90b4f688..f2c6f75ca5 100644 --- a/src/Ext/Techno/Body.h +++ b/src/Ext/Techno/Body.h @@ -168,6 +168,7 @@ class TechnoExt static Point2D GetBuildingSelectBracketPosition(TechnoClass* pThis, BuildingSelectBracketPosition bracketPosition); static void ProcessDigitalDisplays(TechnoClass* pThis); static void GetValuesForDisplay(TechnoClass* pThis, DisplayInfoType infoType, int& value, int& maxValue); + static void DrawBar(TechnoClass* pThis, BarTypeClass* barType, Point2D pLocation, RectangleStruct* pBounds, double barPercentage, double yellowCond, double redCond); // WeaponHelpers.cpp static int PickWeaponIndex(TechnoClass* pThis, TechnoClass* pTargetTechno, AbstractClass* pTarget, int weaponIndexOne, int weaponIndexTwo, bool allowFallback = true, bool allowAAFallback = true); diff --git a/src/Ext/Techno/Hooks.Pips.cpp b/src/Ext/Techno/Hooks.Pips.cpp index 4d97e89491..ee4d453d04 100644 --- a/src/Ext/Techno/Hooks.Pips.cpp +++ b/src/Ext/Techno/Hooks.Pips.cpp @@ -285,7 +285,7 @@ DEFINE_HOOK(0x6F64C1, TechnoClass_DrawHealthBar_BuildingHealthBar, 0xA) const auto pTypeExt = TechnoTypeExt::ExtMap.Find(pThis->GetTechnoType()); - if(pThis->WhatAmI() == AbstractType::Building && pTypeExt->CustomHealthBarType) + if(pThis->WhatAmI() == AbstractType::Building && pTypeExt->HealthBar_BarType) return Skip; return Continue; @@ -301,7 +301,7 @@ DEFINE_HOOK(0x6F6846, TechnoClass_DrawHealthBar_CustomHealthBar, 0x6) bool pThisIsInf = pThis->WhatAmI() == AbstractType::Infantry; - if(!pTypeExt->CustomHealthBarType) + if(!pTypeExt->HealthBar_BarType) { R->AL(pThis->IsSelected); if(pThisIsInf) @@ -309,60 +309,17 @@ DEFINE_HOOK(0x6F6846, TechnoClass_DrawHealthBar_CustomHealthBar, 0x6) return Continue; } - const auto thisHBType = pTypeExt->CustomHealthBarType.Get(); - const auto pipBoardBG = thisHBType->Frame_Background.Get(FileSystem::PIPBRD_SHP()); - const bool pipBoardBGVisibility = thisHBType->Frame_Background_ShowWhenNotSelected.Get(); - const BlitterFlags blitFlags = thisHBType->Frame_Background_Translucency.Get(0); - const auto pipBoardFG = thisHBType->Frame_Foreground.Get(); - const bool pipBoardFGVisibility = thisHBType->Frame_Foreground_ShowWhenNotSelected.Get(); - const int pipsOffset = thisHBType->HealthBar_XOffset.Get(); - const Vector3D pipsFrames = thisHBType->Sections_Pips.Get(); - const int pipsAmount = thisHBType->Sections_Amount.Get(); - const int pipsSize = thisHBType->Sections_Size.Get(); - - int top_adjust = pThisIsInf ? -25 : -26; - int left_adjust = pipsAmount * pipsSize / 2 - pipsSize; - left_adjust = (pipsAmount % 2 == 0) ? left_adjust - 1 : left_adjust; - int border_adjust = (pipsAmount % 2 == 0) ? 1 : 0; - Point2D position; + const auto thisHBType = pTypeExt->HealthBar_BarType.Get(); - if(pThis->WhatAmI() == AbstractType::Building) - top_adjust -= static_cast(pThis)->Type->Height * Unsorted::CellHeightInPixels / 2; - - if(pThis->IsSelected || pipBoardBGVisibility) - { - position.X = pLocation->X + 1 + border_adjust + pipsOffset; - position.Y = pThis->GetTechnoType()->PixelSelectionBracketDelta + pLocation->Y + top_adjust; - DSurface::Temp->DrawSHP(FileSystem::PALETTE_PAL, pipBoardBG, - 0, &position, pBound, BlitterFlags(0xE00) | blitFlags, 0, 0, ZGradient::Ground, 1000, 0, 0, 0, 0, 0); - } - - double health = pThis->GetHealthPercentage(); - int frameIdxa = pipsFrames.Z; - - if (health > RulesClass::Instance->ConditionYellow) - frameIdxa = pipsFrames.X; - else if (health > RulesClass::Instance->ConditionRed) - frameIdxa = pipsFrames.Y; - - int pipsNeeded = (int)round(health * pipsAmount); - pipsNeeded = pipsNeeded <= 0 ? 1 : pipsNeeded; + Point2D position = *pLocation; - for(int i = 0; i < pipsNeeded; ++i) - { - position.X = pLocation->X - left_adjust + pipsOffset + pipsSize * i; - position.Y = pThis->GetTechnoType()->PixelSelectionBracketDelta + pLocation->Y + top_adjust + 1; - DSurface::Temp->DrawSHP(FileSystem::PALETTE_PAL, FileSystem::PIPS_SHP(), - frameIdxa, &position, pBound, BlitterFlags(0x600), 0, 0, ZGradient::Ground, 1000, 0, 0, 0, 0, 0); - } + if(pThis->WhatAmI() == AbstractType::Building) + position.Y -= (static_cast(pThis)->Type->Height + 1) * Unsorted::CellHeightInPixels / 2; + else + position.Y -= pThisIsInf ? 25 : 26; - if(pipBoardFG && (pThis->IsSelected || pipBoardFGVisibility)) - { - position.X = pLocation->X + 1 + border_adjust + pipsOffset; - position.Y = pThis->GetTechnoType()->PixelSelectionBracketDelta + pLocation->Y + top_adjust; - DSurface::Temp->DrawSHP(FileSystem::PALETTE_PAL, pipBoardFG, - 0, &position, pBound, BlitterFlags(0xE00), 0, 0, ZGradient::Ground, 1000, 0, 0, 0, 0, 0); - } + position.Y += pThis->GetTechnoType()->PixelSelectionBracketDelta; + TechnoExt::DrawBar(pThis, thisHBType, position, pBound, pThis->GetHealthPercentage(), RulesClass::Instance->ConditionYellow, RulesClass::Instance->ConditionRed); R->EDI(pLocation); return Skip; diff --git a/src/Ext/TechnoType/Body.cpp b/src/Ext/TechnoType/Body.cpp index 13d7ed94dc..fd51a1f946 100644 --- a/src/Ext/TechnoType/Body.cpp +++ b/src/Ext/TechnoType/Body.cpp @@ -319,7 +319,7 @@ void TechnoTypeExt::ExtData::LoadFromINIFile(CCINIClass* const pINI) this->Wake_Grapple.Read(exINI, pSection, "Wake.Grapple"); this->Wake_Sinking.Read(exINI, pSection, "Wake.Sinking"); - this->CustomHealthBarType.Read(exINI, pSection, "CustomHealthBarType"); + this->HealthBar_BarType.Read(exINI, pSection, "HealthBar.BarType"); // Ares 0.2 this->RadarJamRadius.Read(exINI, pSection, "RadarJamRadius"); @@ -691,7 +691,7 @@ void TechnoTypeExt::ExtData::Serialize(T& Stm) .Process(this->Wake_Grapple) .Process(this->Wake_Sinking) - .Process(this->CustomHealthBarType) + .Process(this->HealthBar_BarType) ; } void TechnoTypeExt::ExtData::LoadFromStream(PhobosStreamReader& Stm) diff --git a/src/Ext/TechnoType/Body.h b/src/Ext/TechnoType/Body.h index 7b40c39037..35d97e1624 100644 --- a/src/Ext/TechnoType/Body.h +++ b/src/Ext/TechnoType/Body.h @@ -12,7 +12,7 @@ #include #include #include -#include +#include class Matrix3D; @@ -234,7 +234,7 @@ class TechnoTypeExt Nullable Wake_Grapple; Nullable Wake_Sinking; - Valueable CustomHealthBarType; + Valueable HealthBar_BarType; struct LaserTrailDataEntry { @@ -465,7 +465,7 @@ class TechnoTypeExt , Wake_Grapple { } , Wake_Sinking { } - , CustomHealthBarType {} + , HealthBar_BarType {} { } virtual ~ExtData() = default; diff --git a/src/New/Type/BarTypeClass.cpp b/src/New/Type/BarTypeClass.cpp new file mode 100644 index 0000000000..5e4f35da9a --- /dev/null +++ b/src/New/Type/BarTypeClass.cpp @@ -0,0 +1,64 @@ +#include "BarTypeClass.h" + +#include +#include + +#include + +template<> +const char* Enumerable::GetMainSection() +{ + return "BarTypes"; +} + +void BarTypeClass::LoadFromINI(CCINIClass* pINI) +{ + const char* section = this->Name; + + INI_EX exINI(pINI); + + this->BoardBG_File.Read(exINI, section, "BoardBG.File"); + this->BoardBG_ShowWhenNotSelected.Read(exINI, section, "BoardBG.ShowWhenNotSelected"); + this->BoardBG_Translucency.Read(exINI, section, "BoardBG.Translucency"); + this->BoardFG_File.Read(exINI, section, "BoardFG.File"); + this->BoardFG_ShowWhenNotSelected.Read(exINI, section, "BoardFG.ShowWhenNotSelected"); + this->BoardFG_Translucency.Read(exINI, section, "BoardFG.Translucency"); + this->Board_Offset.Read(exINI, section, "Board.Offset"); + this->Bar_Offset.Read(exINI, section, "Bar.Offset"); + this->Sections_DrawBackwards.Read(exINI, section, "Sections.DrawBackwards"); + this->Sections_Pips.Read(exINI, section, "Sections.Pips"); + this->Sections_EmptyPip.Read(exINI, section, "Sections.EmptyPip"); + this->Sections_Amount.Read(exINI, section, "Sections.Amount"); + this->Sections_PositionDelta.Read(exINI, section, "Sections.PositionDelta"); + +} + +template +void BarTypeClass::Serialize(T& Stm) +{ + Stm + .Process(this->BoardBG_File) + .Process(this->BoardBG_ShowWhenNotSelected) + .Process(this->BoardBG_Translucency) + .Process(this->BoardFG_File) + .Process(this->BoardFG_ShowWhenNotSelected) + .Process(this->BoardFG_Translucency) + .Process(this->Board_Offset) + .Process(this->Bar_Offset) + .Process(this->Sections_DrawBackwards) + .Process(this->Sections_Pips) + .Process(this->Sections_EmptyPip) + .Process(this->Sections_Amount) + .Process(this->Sections_PositionDelta) + ; +} + +void BarTypeClass::LoadFromStream(PhobosStreamReader& Stm) +{ + this->Serialize(Stm); +} + +void BarTypeClass::SaveToStream(PhobosStreamWriter& Stm) +{ + this->Serialize(Stm); +} diff --git a/src/New/Type/BarTypeClass.h b/src/New/Type/BarTypeClass.h new file mode 100644 index 0000000000..e830efdd99 --- /dev/null +++ b/src/New/Type/BarTypeClass.h @@ -0,0 +1,48 @@ +#pragma once +#include +#include +#include +#include +#include + +class BarTypeClass final : public Enumerable +{ +public: + Nullable BoardBG_File; + Valueable BoardBG_ShowWhenNotSelected; + Nullable BoardBG_Translucency; + Nullable BoardFG_File; + Valueable BoardFG_ShowWhenNotSelected; + Nullable BoardFG_Translucency; + Valueable> Board_Offset; + Valueable> Bar_Offset; + Valueable Sections_DrawBackwards; + Valueable> Sections_Pips; + Valueable Sections_EmptyPip; + Valueable Sections_Amount; + Valueable> Sections_PositionDelta; + + BarTypeClass(const char* pTitle = NONE_STR) : Enumerable(pTitle) + , BoardBG_File { } + , BoardBG_ShowWhenNotSelected { false } + , BoardBG_Translucency { } + , BoardFG_File { } + , BoardFG_ShowWhenNotSelected { false } + , BoardFG_Translucency { } + , Board_Offset { { 0,0 } } + , Bar_Offset { { 0,0 } } + , Sections_DrawBackwards { false } + , Sections_Pips { { 16,17,18 } } + , Sections_EmptyPip { -1 } + , Sections_Amount { 17 } + , Sections_PositionDelta { { 2,0 } } + { } + + void LoadFromINI(CCINIClass* pINI); + void LoadFromStream(PhobosStreamReader& Stm); + void SaveToStream(PhobosStreamWriter& Stm); + +private: + template + void Serialize(T& Stm); +}; diff --git a/src/New/Type/HealthBarTypeClass.cpp b/src/New/Type/HealthBarTypeClass.cpp deleted file mode 100644 index 1c9e8cecbe..0000000000 --- a/src/New/Type/HealthBarTypeClass.cpp +++ /dev/null @@ -1,56 +0,0 @@ -#include "HealthBarTypeClass.h" - -#include -#include - -#include - -template<> -const char* Enumerable::GetMainSection() -{ - return "HealthBarTypes"; -} - -void HealthBarTypeClass::LoadFromINI(CCINIClass* pINI) -{ - const char* section = this->Name; - - INI_EX exINI(pINI); - - this->Frame_Background.Read(exINI, section, "Frame.Background"); - this->Frame_Background_ShowWhenNotSelected.Read(exINI, section, "Frame.Background.ShowWhenNotSelected"); - this->Frame_Background_Translucency.Read(exINI, section, "Frame.Background.Translucency"); - this->Frame_Foreground.Read(exINI, section, "Frame.Foreground"); - this->Frame_Foreground_ShowWhenNotSelected.Read(exINI, section, "Frame.Foreground.ShowWhenNotSelected"); - this->HealthBar_XOffset.Read(exINI, section, "HealthBar.OffsetX"); - this->Sections_Pips.Read(exINI, section, "Sections.Pips"); - this->Sections_Amount.Read(exINI, section, "Sections.Amount"); - this->Sections_Size.Read(exINI, section, "Sections.Size"); - -} - -template -void HealthBarTypeClass::Serialize(T& Stm) -{ - Stm - .Process(this->Frame_Background) - .Process(this->Frame_Background_ShowWhenNotSelected) - .Process(this->Frame_Background_Translucency) - .Process(this->Frame_Foreground) - .Process(this->Frame_Foreground_ShowWhenNotSelected) - .Process(this->HealthBar_XOffset) - .Process(this->Sections_Pips) - .Process(this->Sections_Amount) - .Process(this->Sections_Size) - ; -} - -void HealthBarTypeClass::LoadFromStream(PhobosStreamReader& Stm) -{ - this->Serialize(Stm); -} - -void HealthBarTypeClass::SaveToStream(PhobosStreamWriter& Stm) -{ - this->Serialize(Stm); -} diff --git a/src/New/Type/HealthBarTypeClass.h b/src/New/Type/HealthBarTypeClass.h deleted file mode 100644 index d6af051b43..0000000000 --- a/src/New/Type/HealthBarTypeClass.h +++ /dev/null @@ -1,40 +0,0 @@ -#pragma once -#include -#include -#include -#include -#include - -class HealthBarTypeClass final : public Enumerable -{ -public: - Nullable Frame_Background; - Valueable Frame_Background_ShowWhenNotSelected; - Nullable Frame_Background_Translucency; - Nullable Frame_Foreground; - Valueable Frame_Foreground_ShowWhenNotSelected; - Valueable HealthBar_XOffset; - Valueable> Sections_Pips; - Valueable Sections_Amount; - Valueable Sections_Size; - - HealthBarTypeClass(const char* pTitle = NONE_STR) : Enumerable(pTitle) - , Frame_Background { } - , Frame_Background_ShowWhenNotSelected { false } - , Frame_Background_Translucency { } - , Frame_Foreground { } - , Frame_Foreground_ShowWhenNotSelected { false } - , HealthBar_XOffset { 0 } - , Sections_Pips { { 16,17,18 } } - , Sections_Amount { 17 } - , Sections_Size { 2 } - { } - - void LoadFromINI(CCINIClass* pINI); - void LoadFromStream(PhobosStreamReader& Stm); - void SaveToStream(PhobosStreamWriter& Stm); - -private: - template - void Serialize(T& Stm); -}; diff --git a/src/Phobos.Ext.cpp b/src/Phobos.Ext.cpp index 6621d98ff7..0ebdb3e3a2 100644 --- a/src/Phobos.Ext.cpp +++ b/src/Phobos.Ext.cpp @@ -32,7 +32,7 @@ #include #include #include -#include +#include #include @@ -231,7 +231,7 @@ using PhobosTypeRegistry = TypeRegistry< DigitalDisplayTypeClass, AttachEffectTypeClass, AttachEffectClass, - HealthBarTypeClass + BarTypeClass // other classes >; From 89c0cfbf0755550e029fe97ef092dede455a757d Mon Sep 17 00:00:00 2001 From: Fryone Date: Sat, 16 Nov 2024 18:13:48 +0300 Subject: [PATCH 03/20] Update src/Ext/Techno/Body.Visuals.cpp Co-authored-by: Kerbiter --- src/Ext/Techno/Body.Visuals.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Ext/Techno/Body.Visuals.cpp b/src/Ext/Techno/Body.Visuals.cpp index a017906be0..d5e7e5661f 100644 --- a/src/Ext/Techno/Body.Visuals.cpp +++ b/src/Ext/Techno/Body.Visuals.cpp @@ -499,9 +499,9 @@ void TechnoExt::DrawBar(TechnoClass* pThis, BarTypeClass* barType, Point2D pLoca position.X += drawBackwards ? (int)round(sectionAmount * sectionOffset.X / 2) : -(int)round(sectionAmount * sectionOffset.X / 2); position.Y += drawBackwards ? (int)round(sectionAmount * sectionOffset.Y / 2) : -(int)round(sectionAmount * sectionOffset.Y / 2); - if(sectionEmptyFrame != -1) + if (sectionEmptyFrame != -1) { - for(int i = 0; i < sectionAmount; ++i) + for (int i = 0; i < sectionAmount; ++i) { position += drawBackwards ? -sectionOffset : sectionOffset; DSurface::Temp->DrawSHP(FileSystem::PALETTE_PAL, FileSystem::PIPS_SHP(), From da0e53d4edee2047fc261a4f1e7220161fa25928 Mon Sep 17 00:00:00 2001 From: Fryone Date: Sat, 16 Nov 2024 18:14:05 +0300 Subject: [PATCH 04/20] Update src/Ext/Techno/Body.Visuals.cpp Co-authored-by: Kerbiter --- src/Ext/Techno/Body.Visuals.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Ext/Techno/Body.Visuals.cpp b/src/Ext/Techno/Body.Visuals.cpp index d5e7e5661f..44478438b9 100644 --- a/src/Ext/Techno/Body.Visuals.cpp +++ b/src/Ext/Techno/Body.Visuals.cpp @@ -513,9 +513,11 @@ void TechnoExt::DrawBar(TechnoClass* pThis, BarTypeClass* barType, Point2D pLoca position.Y += drawBackwards ? (int)round(sectionAmount * sectionOffset.Y / 2) : -(int)round(sectionAmount * sectionOffset.Y / 2); } - if(drawBackwards) - for(int i = 0; i < (sectionAmount - sectionsToDraw); ++i) + if (drawBackwards) + { + for (int i = 0; i < (sectionAmount - sectionsToDraw); ++i) position -= sectionOffset; + } for(int i = 0; i < sectionsToDraw; ++i) { From df0c9a0867c511a2b3ecd563d0be28baa41349dc Mon Sep 17 00:00:00 2001 From: Fryone Date: Sat, 16 Nov 2024 18:14:24 +0300 Subject: [PATCH 05/20] Update src/Ext/Techno/Hooks.Pips.cpp Co-authored-by: Kerbiter --- src/Ext/Techno/Hooks.Pips.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Ext/Techno/Hooks.Pips.cpp b/src/Ext/Techno/Hooks.Pips.cpp index ee4d453d04..b5b4efbb0c 100644 --- a/src/Ext/Techno/Hooks.Pips.cpp +++ b/src/Ext/Techno/Hooks.Pips.cpp @@ -304,7 +304,7 @@ DEFINE_HOOK(0x6F6846, TechnoClass_DrawHealthBar_CustomHealthBar, 0x6) if(!pTypeExt->HealthBar_BarType) { R->AL(pThis->IsSelected); - if(pThisIsInf) + if (pThisIsInf) return ContinueInf; return Continue; } From 4dd8b3480529f663c5b8fb444d5c9b0e6a755b13 Mon Sep 17 00:00:00 2001 From: Fryone Date: Sat, 16 Nov 2024 18:14:44 +0300 Subject: [PATCH 06/20] Update src/Ext/Techno/Hooks.Pips.cpp Co-authored-by: Kerbiter --- src/Ext/Techno/Hooks.Pips.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Ext/Techno/Hooks.Pips.cpp b/src/Ext/Techno/Hooks.Pips.cpp index b5b4efbb0c..991916d578 100644 --- a/src/Ext/Techno/Hooks.Pips.cpp +++ b/src/Ext/Techno/Hooks.Pips.cpp @@ -301,7 +301,7 @@ DEFINE_HOOK(0x6F6846, TechnoClass_DrawHealthBar_CustomHealthBar, 0x6) bool pThisIsInf = pThis->WhatAmI() == AbstractType::Infantry; - if(!pTypeExt->HealthBar_BarType) + if (!pTypeExt->HealthBar_BarType) { R->AL(pThis->IsSelected); if (pThisIsInf) From 39b2679538b619bfc9776ff7af1da94de5a5a427 Mon Sep 17 00:00:00 2001 From: Fryone Date: Sat, 16 Nov 2024 18:15:06 +0300 Subject: [PATCH 07/20] Update src/Ext/Techno/Body.Visuals.cpp Co-authored-by: Kerbiter --- src/Ext/Techno/Body.Visuals.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Ext/Techno/Body.Visuals.cpp b/src/Ext/Techno/Body.Visuals.cpp index 44478438b9..16a9e3cee3 100644 --- a/src/Ext/Techno/Body.Visuals.cpp +++ b/src/Ext/Techno/Body.Visuals.cpp @@ -526,7 +526,7 @@ void TechnoExt::DrawBar(TechnoClass* pThis, BarTypeClass* barType, Point2D pLoca frameIdxa, &position, pBounds, BlitterFlags(0x600), 0, 0, ZGradient::Ground, 1000, 0, 0, 0, 0, 0); } - if(barType->BoardFG_File && (pThis->IsSelected || barType->BoardFG_ShowWhenNotSelected)) + if (barType->BoardFG_File && (pThis->IsSelected || barType->BoardFG_ShowWhenNotSelected)) DSurface::Temp->DrawSHP(FileSystem::PALETTE_PAL, barType->BoardFG_File.Get(), 0, &boardPosition, pBounds, BlitterFlags(0xE00) | blitFlagsFG, 0, 0, ZGradient::Ground, 1000, 0, 0, 0, 0, 0); } From 6e75804bcdd1650af7c650ffd50877ded236471c Mon Sep 17 00:00:00 2001 From: Fryone Date: Sat, 16 Nov 2024 18:15:31 +0300 Subject: [PATCH 08/20] Update src/New/Type/BarTypeClass.h Co-authored-by: Kerbiter --- src/New/Type/BarTypeClass.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/New/Type/BarTypeClass.h b/src/New/Type/BarTypeClass.h index e830efdd99..731ab17f0b 100644 --- a/src/New/Type/BarTypeClass.h +++ b/src/New/Type/BarTypeClass.h @@ -29,13 +29,13 @@ class BarTypeClass final : public Enumerable , BoardFG_File { } , BoardFG_ShowWhenNotSelected { false } , BoardFG_Translucency { } - , Board_Offset { { 0,0 } } - , Bar_Offset { { 0,0 } } + , Board_Offset { { 0, 0 } } + , Bar_Offset { { 0, 0 } } , Sections_DrawBackwards { false } - , Sections_Pips { { 16,17,18 } } + , Sections_Pips { { 16, 17, 18 } } , Sections_EmptyPip { -1 } , Sections_Amount { 17 } - , Sections_PositionDelta { { 2,0 } } + , Sections_PositionDelta { { 2, 0 } } { } void LoadFromINI(CCINIClass* pINI); From 496f884276e56c9b619c8ab4efc79d261bcf7137 Mon Sep 17 00:00:00 2001 From: Fryone Date: Sat, 16 Nov 2024 18:15:53 +0300 Subject: [PATCH 09/20] Update src/Ext/Techno/Body.Visuals.cpp Co-authored-by: Kerbiter --- src/Ext/Techno/Body.Visuals.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Ext/Techno/Body.Visuals.cpp b/src/Ext/Techno/Body.Visuals.cpp index 16a9e3cee3..6447964683 100644 --- a/src/Ext/Techno/Body.Visuals.cpp +++ b/src/Ext/Techno/Body.Visuals.cpp @@ -519,7 +519,7 @@ void TechnoExt::DrawBar(TechnoClass* pThis, BarTypeClass* barType, Point2D pLoca position -= sectionOffset; } - for(int i = 0; i < sectionsToDraw; ++i) + for (int i = 0; i < sectionsToDraw; ++i) { position += drawBackwards ? -sectionOffset : sectionOffset; DSurface::Temp->DrawSHP(FileSystem::PALETTE_PAL, FileSystem::PIPS_SHP(), From d41b3c109023667834f029d182c5dc4f5695eb5b Mon Sep 17 00:00:00 2001 From: Fryone Date: Sat, 16 Nov 2024 18:16:27 +0300 Subject: [PATCH 10/20] Update src/Ext/Techno/Hooks.Pips.cpp Co-authored-by: Kerbiter --- src/Ext/Techno/Hooks.Pips.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Ext/Techno/Hooks.Pips.cpp b/src/Ext/Techno/Hooks.Pips.cpp index 991916d578..1a0b008dca 100644 --- a/src/Ext/Techno/Hooks.Pips.cpp +++ b/src/Ext/Techno/Hooks.Pips.cpp @@ -294,6 +294,7 @@ DEFINE_HOOK(0x6F64C1, TechnoClass_DrawHealthBar_BuildingHealthBar, 0xA) DEFINE_HOOK(0x6F6846, TechnoClass_DrawHealthBar_CustomHealthBar, 0x6) { enum { Continue = 0x6F68E8, ContinueInf = 0x6F6852, Skip = 0x6F6A58 }; + GET(TechnoClass*, pThis, ESI); GET_STACK(Point2D*, pLocation, STACK_OFFSET(0x4C, 0x4)); GET_STACK(RectangleStruct*, pBound, STACK_OFFSET(0x4C, 0x8)); From 1519333fe8f56b764bdb0a49ae1dd799e52139b8 Mon Sep 17 00:00:00 2001 From: Fryone Date: Sat, 16 Nov 2024 18:16:50 +0300 Subject: [PATCH 11/20] Update src/Ext/Techno/Hooks.Pips.cpp Co-authored-by: Kerbiter --- src/Ext/Techno/Hooks.Pips.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Ext/Techno/Hooks.Pips.cpp b/src/Ext/Techno/Hooks.Pips.cpp index 1a0b008dca..03ed63207b 100644 --- a/src/Ext/Techno/Hooks.Pips.cpp +++ b/src/Ext/Techno/Hooks.Pips.cpp @@ -279,6 +279,7 @@ DEFINE_HOOK(0x70A4FB, TechnoClass_DrawPips_SelfHealGain, 0x5) DEFINE_HOOK(0x6F64C1, TechnoClass_DrawHealthBar_BuildingHealthBar, 0xA) { enum { Continue = 0x6F64CB, Skip = 0x6F683C }; + GET(TechnoClass*, pThis, ESI); R->EAX(pThis->GetTechnoType()); From 7cd1aae9430bfc3b7a0b782609de70ceadc5fe09 Mon Sep 17 00:00:00 2001 From: Fryone Date: Sat, 16 Nov 2024 18:17:04 +0300 Subject: [PATCH 12/20] Update src/Ext/Techno/Hooks.Pips.cpp Co-authored-by: Kerbiter --- src/Ext/Techno/Hooks.Pips.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Ext/Techno/Hooks.Pips.cpp b/src/Ext/Techno/Hooks.Pips.cpp index 03ed63207b..6c20d396b7 100644 --- a/src/Ext/Techno/Hooks.Pips.cpp +++ b/src/Ext/Techno/Hooks.Pips.cpp @@ -286,7 +286,7 @@ DEFINE_HOOK(0x6F64C1, TechnoClass_DrawHealthBar_BuildingHealthBar, 0xA) const auto pTypeExt = TechnoTypeExt::ExtMap.Find(pThis->GetTechnoType()); - if(pThis->WhatAmI() == AbstractType::Building && pTypeExt->HealthBar_BarType) + if (pThis->WhatAmI() == AbstractType::Building && pTypeExt->HealthBar_BarType) return Skip; return Continue; From 35111afa1387422c06f3f21e90b899b8ff9906bf Mon Sep 17 00:00:00 2001 From: Fryone Date: Sun, 17 Nov 2024 20:59:35 +0300 Subject: [PATCH 13/20] Rework 1 - hook refactor - Healthbar.Hide moved to healthbar hook - applied some suggested changes - added ability to choose file for bar pips - added ShieldBar.BarType TO DO: - for now, ShieldBar.BarType dont work without HealthBar.BarType --- src/Ext/Techno/Body.Visuals.cpp | 35 +++++++++--------- src/Ext/Techno/Body.h | 2 +- src/Ext/Techno/Hooks.Pips.cpp | 63 +++++++++++++++++---------------- src/Ext/TechnoType/Body.cpp | 2 ++ src/Ext/TechnoType/Body.h | 6 ++-- src/Ext/TechnoType/Hooks.cpp | 10 ------ src/New/Type/BarTypeClass.cpp | 26 +++++++------- src/New/Type/BarTypeClass.h | 26 +++++++------- 8 files changed, 85 insertions(+), 85 deletions(-) diff --git a/src/Ext/Techno/Body.Visuals.cpp b/src/Ext/Techno/Body.Visuals.cpp index 6447964683..6764135f99 100644 --- a/src/Ext/Techno/Body.Visuals.cpp +++ b/src/Ext/Techno/Body.Visuals.cpp @@ -470,10 +470,10 @@ void TechnoExt::GetValuesForDisplay(TechnoClass* pThis, DisplayInfoType infoType } } -void TechnoExt::DrawBar(TechnoClass* pThis, BarTypeClass* barType, Point2D pLocation, RectangleStruct* pBounds, double barPercentage, double yellowCond, double redCond) +void TechnoExt::DrawBar(TechnoClass* pThis, BarTypeClass* barType, Point2D pLocation, RectangleStruct* pBounds, double barPercentage, double conditionYellow, double conditionRed) { - const BlitterFlags blitFlagsBG = barType->BoardBG_Translucency.Get(0); - const BlitterFlags blitFlagsFG = barType->BoardFG_Translucency.Get(0); + const BlitterFlags blitFlagsBG = barType->Board_Background_Translucency.Get(0); + const BlitterFlags blitFlagsFG = barType->Board_Foreground_Translucency.Get(0); const Point2D sectionOffset = barType->Sections_PositionDelta; const Vector3D sectionFrames = barType->Sections_Pips; const int sectionAmount = barType->Sections_Amount; @@ -482,35 +482,34 @@ void TechnoExt::DrawBar(TechnoClass* pThis, BarTypeClass* barType, Point2D pLoca int sectionsToDraw = (int)round(sectionAmount * barPercentage); sectionsToDraw = sectionsToDraw == 0 ? 1 : sectionsToDraw; int frameIdxa = sectionFrames.Z; + int sign = drawBackwards ? 1 : -1; - if (barPercentage > yellowCond) + if (barPercentage > conditionYellow) frameIdxa = sectionFrames.X; - else if (barPercentage > redCond) + else if (barPercentage > conditionRed) frameIdxa = sectionFrames.Y; pLocation += barType->Bar_Offset; Point2D boardPosition = pLocation + barType->Board_Offset; - if(barType->BoardBG_File && (pThis->IsSelected || barType->BoardBG_ShowWhenNotSelected)) - DSurface::Temp->DrawSHP(FileSystem::PALETTE_PAL, barType->BoardBG_File.Get(), + if (barType->Board_Background_File && (pThis->IsSelected || barType->Board_Background_ShowWhenNotSelected)) + DSurface::Temp->DrawSHP(FileSystem::PALETTE_PAL, barType->Board_Background_File.Get(), 0, &boardPosition, pBounds, BlitterFlags(0xE00) | blitFlagsBG, 0, 0, ZGradient::Ground, 1000, 0, 0, 0, 0, 0); Point2D position = pLocation; - position.X += drawBackwards ? (int)round(sectionAmount * sectionOffset.X / 2) : -(int)round(sectionAmount * sectionOffset.X / 2); - position.Y += drawBackwards ? (int)round(sectionAmount * sectionOffset.Y / 2) : -(int)round(sectionAmount * sectionOffset.Y / 2); + position += {sign * (int)round(sectionAmount * sectionOffset.X / 2), sign * (int)round(sectionAmount * sectionOffset.Y / 2)}; if (sectionEmptyFrame != -1) { for (int i = 0; i < sectionAmount; ++i) { - position += drawBackwards ? -sectionOffset : sectionOffset; - DSurface::Temp->DrawSHP(FileSystem::PALETTE_PAL, FileSystem::PIPS_SHP(), + position -= {sign * sectionOffset.X, sign * sectionOffset.Y}; + DSurface::Temp->DrawSHP(FileSystem::PALETTE_PAL, barType->Sections_Pips_File.Get(), sectionEmptyFrame, &position, pBounds, BlitterFlags(0x600), 0, 0, ZGradient::Ground, 1000, 0, 0, 0, 0, 0); } position = pLocation; - position.X += drawBackwards ? (int)round(sectionAmount * sectionOffset.X / 2) : -(int)round(sectionAmount * sectionOffset.X / 2); - position.Y += drawBackwards ? (int)round(sectionAmount * sectionOffset.Y / 2) : -(int)round(sectionAmount * sectionOffset.Y / 2); + position += {sign * (int)round(sectionAmount * sectionOffset.X / 2), sign * (int)round(sectionAmount * sectionOffset.Y / 2)}; } if (drawBackwards) @@ -521,12 +520,12 @@ void TechnoExt::DrawBar(TechnoClass* pThis, BarTypeClass* barType, Point2D pLoca for (int i = 0; i < sectionsToDraw; ++i) { - position += drawBackwards ? -sectionOffset : sectionOffset; - DSurface::Temp->DrawSHP(FileSystem::PALETTE_PAL, FileSystem::PIPS_SHP(), + position -= {sign * sectionOffset.X, sign * sectionOffset.Y}; + DSurface::Temp->DrawSHP(FileSystem::PALETTE_PAL, barType->Sections_Pips_File.Get(), frameIdxa, &position, pBounds, BlitterFlags(0x600), 0, 0, ZGradient::Ground, 1000, 0, 0, 0, 0, 0); } - if (barType->BoardFG_File && (pThis->IsSelected || barType->BoardFG_ShowWhenNotSelected)) - DSurface::Temp->DrawSHP(FileSystem::PALETTE_PAL, barType->BoardFG_File.Get(), - 0, &boardPosition, pBounds, BlitterFlags(0xE00) | blitFlagsFG, 0, 0, ZGradient::Ground, 1000, 0, 0, 0, 0, 0); + if (barType->Board_Foreground_File && (pThis->IsSelected || barType->Board_Foreground_ShowWhenNotSelected)) + DSurface::Temp->DrawSHP(FileSystem::PALETTE_PAL, barType->Board_Foreground_File.Get(), + 0, &boardPosition, pBounds, BlitterFlags(0xE00), 0, 0, ZGradient::Ground, 1000, 0, 0, 0, 0, 0); } diff --git a/src/Ext/Techno/Body.h b/src/Ext/Techno/Body.h index f2c6f75ca5..0f1ed4985b 100644 --- a/src/Ext/Techno/Body.h +++ b/src/Ext/Techno/Body.h @@ -168,7 +168,7 @@ class TechnoExt static Point2D GetBuildingSelectBracketPosition(TechnoClass* pThis, BuildingSelectBracketPosition bracketPosition); static void ProcessDigitalDisplays(TechnoClass* pThis); static void GetValuesForDisplay(TechnoClass* pThis, DisplayInfoType infoType, int& value, int& maxValue); - static void DrawBar(TechnoClass* pThis, BarTypeClass* barType, Point2D pLocation, RectangleStruct* pBounds, double barPercentage, double yellowCond, double redCond); + static void DrawBar(TechnoClass* pThis, BarTypeClass* barType, Point2D pLocation, RectangleStruct* pBounds, double barPercentage, double conditionYellow, double conditionRed); // WeaponHelpers.cpp static int PickWeaponIndex(TechnoClass* pThis, TechnoClass* pTargetTechno, AbstractClass* pTarget, int weaponIndexOne, int weaponIndexTwo, bool allowFallback = true, bool allowAAFallback = true); diff --git a/src/Ext/Techno/Hooks.Pips.cpp b/src/Ext/Techno/Hooks.Pips.cpp index 6c20d396b7..1fee426744 100644 --- a/src/Ext/Techno/Hooks.Pips.cpp +++ b/src/Ext/Techno/Hooks.Pips.cpp @@ -276,53 +276,56 @@ DEFINE_HOOK(0x70A4FB, TechnoClass_DrawPips_SelfHealGain, 0x5) return SkipGameDrawing; } -DEFINE_HOOK(0x6F64C1, TechnoClass_DrawHealthBar_BuildingHealthBar, 0xA) +DEFINE_HOOK(0x6F64A9, TechnoClass_DrawHealthBar_HealthAndShieldBar, 0x5) { - enum { Continue = 0x6F64CB, Skip = 0x6F683C }; + enum { Skip = 0x6F6AB6 }; - GET(TechnoClass*, pThis, ESI); - - R->EAX(pThis->GetTechnoType()); - - const auto pTypeExt = TechnoTypeExt::ExtMap.Find(pThis->GetTechnoType()); - - if (pThis->WhatAmI() == AbstractType::Building && pTypeExt->HealthBar_BarType) - return Skip; - - return Continue; -} - -DEFINE_HOOK(0x6F6846, TechnoClass_DrawHealthBar_CustomHealthBar, 0x6) -{ - enum { Continue = 0x6F68E8, ContinueInf = 0x6F6852, Skip = 0x6F6A58 }; - - GET(TechnoClass*, pThis, ESI); + GET(TechnoClass*, pThis, ECX); GET_STACK(Point2D*, pLocation, STACK_OFFSET(0x4C, 0x4)); GET_STACK(RectangleStruct*, pBound, STACK_OFFSET(0x4C, 0x8)); + const auto pTypeExt = TechnoTypeExt::ExtMap.Find(pThis->GetTechnoType()); - bool pThisIsInf = pThis->WhatAmI() == AbstractType::Infantry; + if (pTypeExt && pTypeExt->HealthBar_Hide) + return Skip; if (!pTypeExt->HealthBar_BarType) - { - R->AL(pThis->IsSelected); - if (pThisIsInf) - return ContinueInf; - return Continue; - } + return 0; + const bool pThisIsInf = pThis->WhatAmI() == AbstractType::Infantry; + const bool pThisIsBld = pThis->WhatAmI() == AbstractType::Building; const auto thisHBType = pTypeExt->HealthBar_BarType.Get(); - + const auto thisSBType = pTypeExt->ShieldBar_BarType.Get(); Point2D position = *pLocation; + int length = pThisIsInf ? 8 : 17; - if(pThis->WhatAmI() == AbstractType::Building) + if (pThisIsBld) + { position.Y -= (static_cast(pThis)->Type->Height + 1) * Unsorted::CellHeightInPixels / 2; + const int pThisBldTypeWidth = static_cast(pThis)->Type->GetFoundationWidth(); + length = pThisBldTypeWidth * 7 + (pThisBldTypeWidth / 2); + } else + { position.Y -= pThisIsInf ? 25 : 26; + position.Y += pThis->GetTechnoType()->PixelSelectionBracketDelta; + } - position.Y += pThis->GetTechnoType()->PixelSelectionBracketDelta; TechnoExt::DrawBar(pThis, thisHBType, position, pBound, pThis->GetHealthPercentage(), RulesClass::Instance->ConditionYellow, RulesClass::Instance->ConditionRed); + const auto pExt = TechnoExt::ExtMap.Find(pThis); + + if (const auto pShieldData = pExt->Shield.get()) + { + if (pShieldData->IsAvailable() && (pShieldData->GetHP() > 0)) + { + if(thisSBType) + TechnoExt::DrawBar(pThis, thisSBType, position, pBound, pShieldData->GetHealthRatio(), pShieldData->GetType()->GetConditionYellow(), pShieldData->GetType()->GetConditionRed()); + else + pShieldData->DrawShieldBar(length, pLocation, pBound); + } + } + + TechnoExt::ProcessDigitalDisplays(pThis); - R->EDI(pLocation); return Skip; } diff --git a/src/Ext/TechnoType/Body.cpp b/src/Ext/TechnoType/Body.cpp index fd51a1f946..7d3872eba7 100644 --- a/src/Ext/TechnoType/Body.cpp +++ b/src/Ext/TechnoType/Body.cpp @@ -320,6 +320,7 @@ void TechnoTypeExt::ExtData::LoadFromINIFile(CCINIClass* const pINI) this->Wake_Sinking.Read(exINI, pSection, "Wake.Sinking"); this->HealthBar_BarType.Read(exINI, pSection, "HealthBar.BarType"); + this->ShieldBar_BarType.Read(exINI, pSection, "ShieldBar.BarType"); // Ares 0.2 this->RadarJamRadius.Read(exINI, pSection, "RadarJamRadius"); @@ -692,6 +693,7 @@ void TechnoTypeExt::ExtData::Serialize(T& Stm) .Process(this->Wake_Sinking) .Process(this->HealthBar_BarType) + .Process(this->ShieldBar_BarType) ; } void TechnoTypeExt::ExtData::LoadFromStream(PhobosStreamReader& Stm) diff --git a/src/Ext/TechnoType/Body.h b/src/Ext/TechnoType/Body.h index 35d97e1624..8c9a7d936a 100644 --- a/src/Ext/TechnoType/Body.h +++ b/src/Ext/TechnoType/Body.h @@ -234,7 +234,8 @@ class TechnoTypeExt Nullable Wake_Grapple; Nullable Wake_Sinking; - Valueable HealthBar_BarType; + Nullable HealthBar_BarType; + Nullable ShieldBar_BarType; struct LaserTrailDataEntry { @@ -465,7 +466,8 @@ class TechnoTypeExt , Wake_Grapple { } , Wake_Sinking { } - , HealthBar_BarType {} + , HealthBar_BarType { } + , ShieldBar_BarType { } { } virtual ~ExtData() = default; diff --git a/src/Ext/TechnoType/Hooks.cpp b/src/Ext/TechnoType/Hooks.cpp index 9b5f52a0b4..324ae521ea 100644 --- a/src/Ext/TechnoType/Hooks.cpp +++ b/src/Ext/TechnoType/Hooks.cpp @@ -23,16 +23,6 @@ #include #include -DEFINE_HOOK(0x6F64A9, TechnoClass_DrawHealthBar_Hide, 0x5) -{ - GET(TechnoClass*, pThis, ECX); - auto pTypeData = TechnoTypeExt::ExtMap.Find(pThis->GetTechnoType()); - if (pTypeData && pTypeData->HealthBar_Hide) - return 0x6F6AB6; - - return 0; -} - DEFINE_HOOK(0x6F3C56, TechnoClass_GetFLH_TurretMultiOffset, 0x0) { LEA_STACK(Matrix3D*, mtx, STACK_OFFSET(0xD8, -0x90)); diff --git a/src/New/Type/BarTypeClass.cpp b/src/New/Type/BarTypeClass.cpp index 5e4f35da9a..e0d27a595e 100644 --- a/src/New/Type/BarTypeClass.cpp +++ b/src/New/Type/BarTypeClass.cpp @@ -17,15 +17,16 @@ void BarTypeClass::LoadFromINI(CCINIClass* pINI) INI_EX exINI(pINI); - this->BoardBG_File.Read(exINI, section, "BoardBG.File"); - this->BoardBG_ShowWhenNotSelected.Read(exINI, section, "BoardBG.ShowWhenNotSelected"); - this->BoardBG_Translucency.Read(exINI, section, "BoardBG.Translucency"); - this->BoardFG_File.Read(exINI, section, "BoardFG.File"); - this->BoardFG_ShowWhenNotSelected.Read(exINI, section, "BoardFG.ShowWhenNotSelected"); - this->BoardFG_Translucency.Read(exINI, section, "BoardFG.Translucency"); + this->Board_Background_File.Read(exINI, section, "Board.Background.File"); + this->Board_Background_ShowWhenNotSelected.Read(exINI, section, "Board.Background.ShowWhenNotSelected"); + this->Board_Background_Translucency.Read(exINI, section, "Board.Background.Translucency"); + this->Board_Foreground_File.Read(exINI, section, "Board.Foreground.File"); + this->Board_Foreground_ShowWhenNotSelected.Read(exINI, section, "Board.Foreground.ShowWhenNotSelected"); + this->Board_Foreground_Translucency.Read(exINI, section, "Board.Foreground.Translucency"); this->Board_Offset.Read(exINI, section, "Board.Offset"); this->Bar_Offset.Read(exINI, section, "Bar.Offset"); this->Sections_DrawBackwards.Read(exINI, section, "Sections.DrawBackwards"); + this->Sections_Pips_File.Read(exINI, section, "Sections.Pips.File"); this->Sections_Pips.Read(exINI, section, "Sections.Pips"); this->Sections_EmptyPip.Read(exINI, section, "Sections.EmptyPip"); this->Sections_Amount.Read(exINI, section, "Sections.Amount"); @@ -37,15 +38,16 @@ template void BarTypeClass::Serialize(T& Stm) { Stm - .Process(this->BoardBG_File) - .Process(this->BoardBG_ShowWhenNotSelected) - .Process(this->BoardBG_Translucency) - .Process(this->BoardFG_File) - .Process(this->BoardFG_ShowWhenNotSelected) - .Process(this->BoardFG_Translucency) + .Process(this->Board_Background_File) + .Process(this->Board_Background_ShowWhenNotSelected) + .Process(this->Board_Background_Translucency) + .Process(this->Board_Foreground_File) + .Process(this->Board_Foreground_ShowWhenNotSelected) + .Process(this->Board_Foreground_Translucency) .Process(this->Board_Offset) .Process(this->Bar_Offset) .Process(this->Sections_DrawBackwards) + .Process(this->Sections_Pips_File) .Process(this->Sections_Pips) .Process(this->Sections_EmptyPip) .Process(this->Sections_Amount) diff --git a/src/New/Type/BarTypeClass.h b/src/New/Type/BarTypeClass.h index 731ab17f0b..3705305420 100644 --- a/src/New/Type/BarTypeClass.h +++ b/src/New/Type/BarTypeClass.h @@ -8,30 +8,32 @@ class BarTypeClass final : public Enumerable { public: - Nullable BoardBG_File; - Valueable BoardBG_ShowWhenNotSelected; - Nullable BoardBG_Translucency; - Nullable BoardFG_File; - Valueable BoardFG_ShowWhenNotSelected; - Nullable BoardFG_Translucency; + Nullable Board_Background_File; + Valueable Board_Background_ShowWhenNotSelected; + Nullable Board_Background_Translucency; + Nullable Board_Foreground_File; + Valueable Board_Foreground_ShowWhenNotSelected; + Nullable Board_Foreground_Translucency; Valueable> Board_Offset; Valueable> Bar_Offset; Valueable Sections_DrawBackwards; + Valueable Sections_Pips_File; Valueable> Sections_Pips; Valueable Sections_EmptyPip; Valueable Sections_Amount; Valueable> Sections_PositionDelta; BarTypeClass(const char* pTitle = NONE_STR) : Enumerable(pTitle) - , BoardBG_File { } - , BoardBG_ShowWhenNotSelected { false } - , BoardBG_Translucency { } - , BoardFG_File { } - , BoardFG_ShowWhenNotSelected { false } - , BoardFG_Translucency { } + , Board_Background_File { } + , Board_Background_ShowWhenNotSelected { false } + , Board_Background_Translucency { } + , Board_Foreground_File { } + , Board_Foreground_ShowWhenNotSelected { false } + , Board_Foreground_Translucency { } , Board_Offset { { 0, 0 } } , Bar_Offset { { 0, 0 } } , Sections_DrawBackwards { false } + , Sections_Pips_File { FileSystem::PIPS_SHP() } , Sections_Pips { { 16, 17, 18 } } , Sections_EmptyPip { -1 } , Sections_Amount { 17 } From f169caa74238950dd35a325416617938e7d21bd6 Mon Sep 17 00:00:00 2001 From: Fryone Date: Sat, 7 Dec 2024 19:56:58 +0300 Subject: [PATCH 14/20] rework update - changed blitterflags - updated logic with latest hook movements - shield and health bars can be used separately --- src/Ext/Techno/Body.Visuals.cpp | 8 ++-- src/Ext/Techno/Hooks.Pips.cpp | 66 ++++++++++++++++++++++++--------- src/New/Entity/ShieldClass.cpp | 8 ++-- 3 files changed, 57 insertions(+), 25 deletions(-) diff --git a/src/Ext/Techno/Body.Visuals.cpp b/src/Ext/Techno/Body.Visuals.cpp index ba0d40463b..78e5d0f4ad 100644 --- a/src/Ext/Techno/Body.Visuals.cpp +++ b/src/Ext/Techno/Body.Visuals.cpp @@ -490,7 +490,7 @@ void TechnoExt::DrawBar(TechnoClass* pThis, BarTypeClass* barType, Point2D pLoca if (barType->Board_Background_File && (pThis->IsSelected || barType->Board_Background_ShowWhenNotSelected)) DSurface::Temp->DrawSHP(FileSystem::PALETTE_PAL, barType->Board_Background_File.Get(), - 0, &boardPosition, pBounds, BlitterFlags(0xE00) | blitFlagsBG, 0, 0, ZGradient::Ground, 1000, 0, 0, 0, 0, 0); + 0, &boardPosition, pBounds, BlitterFlags::Centered | BlitterFlags::bf_400 | BlitterFlags::Alpha | blitFlagsBG, 0, 0, ZGradient::Ground, 1000, 0, 0, 0, 0, 0); Point2D position = pLocation; position += {sign * (int)round(sectionAmount * sectionOffset.X / 2), sign * (int)round(sectionAmount * sectionOffset.Y / 2)}; @@ -501,7 +501,7 @@ void TechnoExt::DrawBar(TechnoClass* pThis, BarTypeClass* barType, Point2D pLoca { position -= {sign * sectionOffset.X, sign * sectionOffset.Y}; DSurface::Temp->DrawSHP(FileSystem::PALETTE_PAL, barType->Sections_Pips_File.Get(), - sectionEmptyFrame, &position, pBounds, BlitterFlags(0x600), 0, 0, ZGradient::Ground, 1000, 0, 0, 0, 0, 0); + sectionEmptyFrame, &position, pBounds, BlitterFlags::Centered | BlitterFlags::bf_400, 0, 0, ZGradient::Ground, 1000, 0, 0, 0, 0, 0); } position = pLocation; @@ -518,10 +518,10 @@ void TechnoExt::DrawBar(TechnoClass* pThis, BarTypeClass* barType, Point2D pLoca { position -= {sign * sectionOffset.X, sign * sectionOffset.Y}; DSurface::Temp->DrawSHP(FileSystem::PALETTE_PAL, barType->Sections_Pips_File.Get(), - frameIdxa, &position, pBounds, BlitterFlags(0x600), 0, 0, ZGradient::Ground, 1000, 0, 0, 0, 0, 0); + frameIdxa, &position, pBounds, BlitterFlags::Centered | BlitterFlags::bf_400, 0, 0, ZGradient::Ground, 1000, 0, 0, 0, 0, 0); } if (barType->Board_Foreground_File && (pThis->IsSelected || barType->Board_Foreground_ShowWhenNotSelected)) DSurface::Temp->DrawSHP(FileSystem::PALETTE_PAL, barType->Board_Foreground_File.Get(), - 0, &boardPosition, pBounds, BlitterFlags(0xE00), 0, 0, ZGradient::Ground, 1000, 0, 0, 0, 0, 0); + 0, &boardPosition, pBounds, BlitterFlags::Centered | BlitterFlags::bf_400 | BlitterFlags::Alpha | blitFlagsFG, 0, 0, ZGradient::Ground, 1000, 0, 0, 0, 0, 0); } diff --git a/src/Ext/Techno/Hooks.Pips.cpp b/src/Ext/Techno/Hooks.Pips.cpp index b31d2baafa..6dab0028fe 100644 --- a/src/Ext/Techno/Hooks.Pips.cpp +++ b/src/Ext/Techno/Hooks.Pips.cpp @@ -3,7 +3,7 @@ #include #include "Body.h" -DEFINE_HOOK(0x6F64A9, TechnoClass_DrawHealthBar_Hide, 0x5) +/*DEFINE_HOOK(0x6F64A9, TechnoClass_DrawHealthBar_Hide, 0x5) { GET(TechnoClass*, pThis, ECX); auto pTypeData = TechnoTypeExt::ExtMap.Find(pThis->GetTechnoType()); @@ -11,7 +11,7 @@ DEFINE_HOOK(0x6F64A9, TechnoClass_DrawHealthBar_Hide, 0x5) return 0x6F6AB6; return 0; -} +}*/ DEFINE_HOOK(0x6F65D1, TechnoClass_DrawHealthBar_Buildings, 0x6) { @@ -26,7 +26,20 @@ DEFINE_HOOK(0x6F65D1, TechnoClass_DrawHealthBar_Buildings, 0x6) if (const auto pShieldData = pExt->Shield.get()) { if (pShieldData->IsAvailable() && !pShieldData->IsBrokenAndNonRespawning()) - pShieldData->DrawShieldBar_Building(length, pBound); + { + const auto thisSBType = TechnoTypeExt::ExtMap.Find(pThis->GetTechnoType())->ShieldBar_BarType.Get(); + + if (thisSBType) + { + Point2D position = *pLocation; + position.Y -= (pThis->Type->Height + 1) * Unsorted::CellHeightInPixels / 2; + TechnoExt::DrawBar(pThis, thisSBType, position, pBound, pShieldData->GetHealthRatio(), pShieldData->GetType()->GetConditionYellow(), pShieldData->GetType()->GetConditionRed()); + } + else + { + pShieldData->DrawShieldBar_Building(length, pBound); + } + } } TechnoExt::ProcessDigitalDisplays(pThis); @@ -47,8 +60,20 @@ DEFINE_HOOK(0x6F683C, TechnoClass_DrawHealthBar_Units, 0x7) { if (pShieldData->IsAvailable() && !pShieldData->IsBrokenAndNonRespawning()) { - const int length = pThis->WhatAmI() == AbstractType::Infantry ? 8 : 17; - pShieldData->DrawShieldBar_Other(length, pBound); + const auto thisSBType = TechnoTypeExt::ExtMap.Find(pThis->GetTechnoType())->ShieldBar_BarType.Get(); + + if (thisSBType) + { + Point2D position = *pLocation; + position.Y -= pThis->WhatAmI() == AbstractType::Infantry ? 25 : 26; + position.Y += pThis->GetTechnoType()->PixelSelectionBracketDelta + pShieldData->GetType()->BracketDelta; + TechnoExt::DrawBar(pThis, thisSBType, position, pBound, pShieldData->GetHealthRatio(), pShieldData->GetType()->GetConditionYellow(), pShieldData->GetType()->GetConditionRed()); + } + else + { + const int length = pThis->WhatAmI() == AbstractType::Infantry ? 8 : 17; + pShieldData->DrawShieldBar_Other(length, pBound); + } } } @@ -370,31 +395,38 @@ DEFINE_HOOK(0x6F64A9, TechnoClass_DrawHealthBar_HealthAndShieldBar, 0x5) const auto thisHBType = pTypeExt->HealthBar_BarType.Get(); const auto thisSBType = pTypeExt->ShieldBar_BarType.Get(); Point2D position = *pLocation; - int length = pThisIsInf ? 8 : 17; if (pThisIsBld) - { position.Y -= (static_cast(pThis)->Type->Height + 1) * Unsorted::CellHeightInPixels / 2; - const int pThisBldTypeWidth = static_cast(pThis)->Type->GetFoundationWidth(); - length = pThisBldTypeWidth * 7 + (pThisBldTypeWidth / 2); - } else - { - position.Y -= pThisIsInf ? 25 : 26; - position.Y += pThis->GetTechnoType()->PixelSelectionBracketDelta; - } + position.Y -= (pThisIsInf ? 25 : 26) - pThis->GetTechnoType()->PixelSelectionBracketDelta; TechnoExt::DrawBar(pThis, thisHBType, position, pBound, pThis->GetHealthPercentage(), RulesClass::Instance->ConditionYellow, RulesClass::Instance->ConditionRed); const auto pExt = TechnoExt::ExtMap.Find(pThis); if (const auto pShieldData = pExt->Shield.get()) { - if (pShieldData->IsAvailable() && (pShieldData->GetHP() > 0)) + if (pShieldData->IsAvailable() && !pShieldData->IsBrokenAndNonRespawning()) { - if(thisSBType) + if (thisSBType) + { + position.Y += pShieldData->GetType()->BracketDelta; TechnoExt::DrawBar(pThis, thisSBType, position, pBound, pShieldData->GetHealthRatio(), pShieldData->GetType()->GetConditionYellow(), pShieldData->GetType()->GetConditionRed()); + } else - pShieldData->DrawShieldBar(length, pLocation, pBound); + { + if (pThisIsBld) + { + const short pThisBldTypeWidth = static_cast(pThis)->Type->GetFoundationWidth(); + const int length = pThisBldTypeWidth * 7 + (pThisBldTypeWidth / 2); + pShieldData->DrawShieldBar_Building(length, pBound); + } + else + { + const int length = pThisIsInf ? 8 : 17; + pShieldData->DrawShieldBar_Other(length, pBound); + } + } } } diff --git a/src/New/Entity/ShieldClass.cpp b/src/New/Entity/ShieldClass.cpp index e440f624b4..5d3de73e49 100644 --- a/src/New/Entity/ShieldClass.cpp +++ b/src/New/Entity/ShieldClass.cpp @@ -851,7 +851,7 @@ void ShieldClass::DrawShieldBar_Building(const int length, RectangleStruct* pBou position.Y -= deltaY + 3; DSurface::Temp->DrawSHP(FileSystem::PALETTE_PAL, FileSystem::PIPS_SHP, - frame, &position, pBound, BlitterFlags(0x600), 0, 0, ZGradient::Ground, 1000, 0, 0, 0, 0, 0); + frame, &position, pBound, BlitterFlags::Centered | BlitterFlags::bf_400, 0, 0, ZGradient::Ground, 1000, 0, 0, 0, 0, 0); } } @@ -868,7 +868,7 @@ void ShieldClass::DrawShieldBar_Building(const int length, RectangleStruct* pBou const int emptyFrame = this->Type->Pips_Building_Empty.Get(RulesExt::Global()->Pips_Shield_Building_Empty.Get(0)); DSurface::Temp->DrawSHP(FileSystem::PALETTE_PAL, FileSystem::PIPS_SHP, - emptyFrame, &position, pBound, BlitterFlags(0x600), 0, 0, ZGradient::Ground, 1000, 0, 0, 0, 0, 0); + emptyFrame, &position, pBound, BlitterFlags::Centered | BlitterFlags::bf_400, 0, 0, ZGradient::Ground, 1000, 0, 0, 0, 0, 0); } } } @@ -891,7 +891,7 @@ void ShieldClass::DrawShieldBar_Other(const int length, RectangleStruct* pBound) { position.X += length + 1 + (length == 8 ? length + 1 : 0); DSurface::Temp->DrawSHP(FileSystem::PALETTE_PAL, pipBoard, - frame, &position, pBound, BlitterFlags(0xE00), 0, 0, ZGradient::Ground, 1000, 0, 0, 0, 0, 0); + frame, &position, pBound, BlitterFlags::Centered | BlitterFlags::bf_400 | BlitterFlags::Alpha, 0, 0, ZGradient::Ground, 1000, 0, 0, 0, 0, 0); position.X -= length + 1 + (length == 8 ? length + 1 : 0); } @@ -903,7 +903,7 @@ void ShieldClass::DrawShieldBar_Other(const int length, RectangleStruct* pBound) { position.X += 2; DSurface::Temp->DrawSHP(FileSystem::PALETTE_PAL, FileSystem::PIPS_SHP, - frame, &position, pBound, BlitterFlags(0x600), 0, 0, ZGradient::Ground, 1000, 0, 0, 0, 0, 0); + frame, &position, pBound, BlitterFlags::Centered | BlitterFlags::bf_400, 0, 0, ZGradient::Ground, 1000, 0, 0, 0, 0, 0); } } From aa17db5f5442d21cc77d272ed37452356f241a9f Mon Sep 17 00:00:00 2001 From: Fryone Date: Mon, 23 Jun 2025 22:22:23 +0300 Subject: [PATCH 15/20] latest state - changed logic and namings - shields does not work - some problems with value calculations --- YRpp | 2 +- src/Ext/Rules/Body.cpp | 8 ++ src/Ext/Rules/Body.h | 11 +- src/Ext/Techno/Body.Visuals.cpp | 28 ++-- src/Ext/Techno/Hooks.Pips.cpp | 220 ++++++++++++++++++++++++-------- src/Ext/TechnoType/Body.cpp | 6 +- src/Ext/TechnoType/Body.h | 7 +- src/New/Type/BarTypeClass.cpp | 54 ++++---- src/New/Type/BarTypeClass.h | 54 ++++---- 9 files changed, 262 insertions(+), 128 deletions(-) diff --git a/YRpp b/YRpp index 76e2005551..5d92d7d756 160000 --- a/YRpp +++ b/YRpp @@ -1 +1 @@ -Subproject commit 76e2005551ab38a95902d8a48ab35e24137a10ac +Subproject commit 5d92d7d756db36b1819719027e8992928e75e0b4 diff --git a/src/Ext/Rules/Body.cpp b/src/Ext/Rules/Body.cpp index 8fe2f128f3..5f4a46eec5 100644 --- a/src/Ext/Rules/Body.cpp +++ b/src/Ext/Rules/Body.cpp @@ -224,6 +224,10 @@ void RulesExt::ExtData::LoadBeforeTypeData(RulesClass* pThis, CCINIClass* pINI) this->DefaultInfantrySelectBox.Read(exINI, GameStrings::AudioVisual, "DefaultInfantrySelectBox"); this->DefaultUnitSelectBox.Read(exINI, GameStrings::AudioVisual, "DefaultUnitSelectBox"); + this->Buildings_DefaultBarTypes.Read(exINI, GameStrings::AudioVisual, "Buildings.DefaultBarTypes"); + this->Infantry_DefaultBarTypes.Read(exINI, GameStrings::AudioVisual, "Infantry.DefaultBarTypes"); + this->Vehicles_DefaultBarTypes.Read(exINI, GameStrings::AudioVisual, "Vehicles.DefaultBarTypes"); + this->Aircraft_DefaultBarTypes.Read(exINI, GameStrings::AudioVisual, "Aircraft.DefaultBarTypes"); this->DamageOwnerMultiplier.Read(exINI, GameStrings::CombatDamage, "DamageOwnerMultiplier"); this->DamageAlliesMultiplier.Read(exINI, GameStrings::CombatDamage, "DamageAlliesMultiplier"); @@ -473,6 +477,10 @@ void RulesExt::ExtData::Serialize(T& Stm) .Process(this->Aircraft_DefaultDigitalDisplayTypes) .Process(this->DefaultInfantrySelectBox) .Process(this->DefaultUnitSelectBox) + .Process(this->Buildings_DefaultBarTypes) + .Process(this->Infantry_DefaultBarTypes) + .Process(this->Vehicles_DefaultBarTypes) + .Process(this->Aircraft_DefaultBarTypes) .Process(this->VisualScatter_Min) .Process(this->VisualScatter_Max) .Process(this->ShowDesignatorRange) diff --git a/src/Ext/Rules/Body.h b/src/Ext/Rules/Body.h index d52b70a3a8..5b755ec4d2 100644 --- a/src/Ext/Rules/Body.h +++ b/src/Ext/Rules/Body.h @@ -18,6 +18,7 @@ class VocClass; class WarheadTypeClass; class DigitalDisplayTypeClass; class SelectBoxTypeClass; +class BarTypeClass; class RulesExt { @@ -150,6 +151,10 @@ class RulesExt ValueableVector Infantry_DefaultDigitalDisplayTypes; ValueableVector Vehicles_DefaultDigitalDisplayTypes; ValueableVector Aircraft_DefaultDigitalDisplayTypes; + ValueableVector Buildings_DefaultBarTypes; + ValueableVector Infantry_DefaultBarTypes; + ValueableVector Vehicles_DefaultBarTypes; + ValueableVector Aircraft_DefaultBarTypes; Valueable DefaultInfantrySelectBox; Valueable DefaultUnitSelectBox; @@ -232,7 +237,7 @@ class RulesExt Valueable AttackMove_IgnoreWeaponCheck; Nullable AttackMove_StopWhenTargetAcquired; - + // cache tint color int TintColorIronCurtain; int TintColorForceShield; @@ -357,6 +362,10 @@ class RulesExt , Infantry_DefaultDigitalDisplayTypes {} , Vehicles_DefaultDigitalDisplayTypes {} , Aircraft_DefaultDigitalDisplayTypes {} + , Buildings_DefaultBarTypes {} + , Infantry_DefaultBarTypes {} + , Vehicles_DefaultBarTypes {} + , Aircraft_DefaultBarTypes {} , DefaultInfantrySelectBox {} , DefaultUnitSelectBox {} , VisualScatter_Min { Leptons(8) } diff --git a/src/Ext/Techno/Body.Visuals.cpp b/src/Ext/Techno/Body.Visuals.cpp index a3d378d660..d05f009ac8 100644 --- a/src/Ext/Techno/Body.Visuals.cpp +++ b/src/Ext/Techno/Body.Visuals.cpp @@ -858,13 +858,13 @@ void TechnoExt::GetDigitalDisplayFakeHealth(TechnoClass* pThis, int& value, int& void TechnoExt::DrawBar(TechnoClass* pThis, BarTypeClass* barType, Point2D pLocation, RectangleStruct* pBounds, double barPercentage, double conditionYellow, double conditionRed) { - const BlitterFlags blitFlagsBG = barType->Board_Background_Translucency.Get(0); - const BlitterFlags blitFlagsFG = barType->Board_Foreground_Translucency.Get(0); - const Point2D sectionOffset = barType->Sections_PositionDelta; - const Vector3D sectionFrames = barType->Sections_Pips; - const int sectionAmount = barType->Sections_Amount; - const int sectionEmptyFrame = barType->Sections_EmptyPip; - const bool drawBackwards = barType->Sections_DrawBackwards; + const BlitterFlags blitFlagsBG = barType->PipBrd_Background_Translucency.Get(0); + const BlitterFlags blitFlagsFG = barType->PipBrd_Foreground_Translucency.Get(0); + const Point2D sectionOffset = barType->Pips_PositionDelta; + const Vector3D sectionFrames = barType->Pips_Frames; + const int sectionAmount = barType->Pips_Amount; + const int sectionEmptyFrame = barType->Pips_EmptyFrame; + const bool drawBackwards = barType->Pips_DrawBackwards; int sectionsToDraw = (int)round(sectionAmount * barPercentage); sectionsToDraw = sectionsToDraw == 0 ? 1 : sectionsToDraw; int frameIdxa = sectionFrames.Z; @@ -876,10 +876,10 @@ void TechnoExt::DrawBar(TechnoClass* pThis, BarTypeClass* barType, Point2D pLoca frameIdxa = sectionFrames.Y; pLocation += barType->Bar_Offset; - Point2D boardPosition = pLocation + barType->Board_Offset; + Point2D boardPosition = pLocation + barType->PipBrd_Offset; - if (barType->Board_Background_File && (pThis->IsSelected || barType->Board_Background_ShowWhenNotSelected)) - DSurface::Temp->DrawSHP(FileSystem::PALETTE_PAL, barType->Board_Background_File.Get(), + if (barType->PipBrd_Background_File && (pThis->IsSelected || barType->PipBrd_Background_ShowWhenNotSelected)) + DSurface::Temp->DrawSHP(FileSystem::PALETTE_PAL, barType->PipBrd_Background_File.Get(), 0, &boardPosition, pBounds, BlitterFlags::Centered | BlitterFlags::bf_400 | BlitterFlags::Alpha | blitFlagsBG, 0, 0, ZGradient::Ground, 1000, 0, 0, 0, 0, 0); Point2D position = pLocation; @@ -890,7 +890,7 @@ void TechnoExt::DrawBar(TechnoClass* pThis, BarTypeClass* barType, Point2D pLoca for (int i = 0; i < sectionAmount; ++i) { position -= {sign * sectionOffset.X, sign * sectionOffset.Y}; - DSurface::Temp->DrawSHP(FileSystem::PALETTE_PAL, barType->Sections_Pips_File.Get(), + DSurface::Temp->DrawSHP(FileSystem::PALETTE_PAL, barType->Pips_File.Get(), sectionEmptyFrame, &position, pBounds, BlitterFlags::Centered | BlitterFlags::bf_400, 0, 0, ZGradient::Ground, 1000, 0, 0, 0, 0, 0); } @@ -907,11 +907,11 @@ void TechnoExt::DrawBar(TechnoClass* pThis, BarTypeClass* barType, Point2D pLoca for (int i = 0; i < sectionsToDraw; ++i) { position -= {sign * sectionOffset.X, sign * sectionOffset.Y}; - DSurface::Temp->DrawSHP(FileSystem::PALETTE_PAL, barType->Sections_Pips_File.Get(), + DSurface::Temp->DrawSHP(FileSystem::PALETTE_PAL, barType->Pips_File.Get(), frameIdxa, &position, pBounds, BlitterFlags::Centered | BlitterFlags::bf_400, 0, 0, ZGradient::Ground, 1000, 0, 0, 0, 0, 0); } - if (barType->Board_Foreground_File && (pThis->IsSelected || barType->Board_Foreground_ShowWhenNotSelected)) - DSurface::Temp->DrawSHP(FileSystem::PALETTE_PAL, barType->Board_Foreground_File.Get(), + if (barType->PipBrd_Foreground_File && (pThis->IsSelected || barType->PipBrd_Foreground_ShowWhenNotSelected)) + DSurface::Temp->DrawSHP(FileSystem::PALETTE_PAL, barType->PipBrd_Foreground_File.Get(), 0, &boardPosition, pBounds, BlitterFlags::Centered | BlitterFlags::bf_400 | BlitterFlags::Alpha | blitFlagsFG, 0, 0, ZGradient::Ground, 1000, 0, 0, 0, 0, 0); } \ No newline at end of file diff --git a/src/Ext/Techno/Hooks.Pips.cpp b/src/Ext/Techno/Hooks.Pips.cpp index 7acc3ce788..43fd01f0ff 100644 --- a/src/Ext/Techno/Hooks.Pips.cpp +++ b/src/Ext/Techno/Hooks.Pips.cpp @@ -52,18 +52,7 @@ DEFINE_HOOK(0x6F65D1, TechnoClass_DrawHealthBar_Buildings, 0x6) { if (pShieldData->IsAvailable() && !pShieldData->IsBrokenAndNonRespawning()) { - const auto thisSBType = TechnoTypeExt::ExtMap.Find(pThis->GetTechnoType())->ShieldBar_BarType.Get(); - - if (thisSBType) - { - Point2D position = *pLocation; - position.Y -= (pThis->Type->Height + 1) * Unsorted::CellHeightInPixels / 2; - TechnoExt::DrawBar(pThis, thisSBType, position, pBound, pShieldData->GetHealthRatio(), pShieldData->GetType()->GetConditionYellow(), pShieldData->GetType()->GetConditionRed()); - } - else - { - pShieldData->DrawShieldBar_Building(length, pBound); - } + pShieldData->DrawShieldBar_Building(length, pBound); } } @@ -90,20 +79,8 @@ DEFINE_HOOK(0x6F683C, TechnoClass_DrawHealthBar_Units, 0x7) { if (pShieldData->IsAvailable() && !pShieldData->IsBrokenAndNonRespawning()) { - const auto thisSBType = TechnoTypeExt::ExtMap.Find(pThis->GetTechnoType())->ShieldBar_BarType.Get(); - - if (thisSBType) - { - Point2D position = *pLocation; - position.Y -= pThis->WhatAmI() == AbstractType::Infantry ? 25 : 26; - position.Y += pThis->GetTechnoType()->PixelSelectionBracketDelta + pShieldData->GetType()->BracketDelta; - TechnoExt::DrawBar(pThis, thisSBType, position, pBound, pShieldData->GetHealthRatio(), pShieldData->GetType()->GetConditionYellow(), pShieldData->GetType()->GetConditionRed()); - } - else - { - const int length = pThis->WhatAmI() == AbstractType::Infantry ? 8 : 17; - pShieldData->DrawShieldBar_Other(length, pBound); - } + const int length = pThis->WhatAmI() == AbstractType::Infantry ? Unsorted::HealthBarSectionsInfantry : Unsorted::HealthBarSectionsOther; + pShieldData->DrawShieldBar_Other(length, pBound); } } @@ -417,52 +394,191 @@ DEFINE_HOOK(0x6F64A9, TechnoClass_DrawHealthBar_HealthAndShieldBar, 0x5) GET_STACK(Point2D*, pLocation, STACK_OFFSET(0x4C, 0x4)); GET_STACK(RectangleStruct*, pBound, STACK_OFFSET(0x4C, 0x8)); + const auto pType = pThis->GetTechnoType(); const auto pTypeExt = TechnoTypeExt::ExtMap.Find(pThis->GetTechnoType()); if (pTypeExt && pTypeExt->HealthBar_Hide) return Skip; - if (!pTypeExt->HealthBar_BarType) - return 0; + //if (!pTypeExt->HealthBar_BarType) + // return 0; + const auto pExt = TechnoExt::ExtMap.Find(pThis); const bool pThisIsInf = pThis->WhatAmI() == AbstractType::Infantry; const bool pThisIsBld = pThis->WhatAmI() == AbstractType::Building; - const auto thisHBType = pTypeExt->HealthBar_BarType.Get(); - const auto thisSBType = pTypeExt->ShieldBar_BarType.Get(); + ValueableVector* pBarTypes = nullptr; + Point2D position = *pLocation; - if (pThisIsBld) - position.Y -= (static_cast(pThis)->Type->Height + 1) * Unsorted::CellHeightInPixels / 2; + //if (pThisIsBld) + // position.Y -= (static_cast(pThis)->Type->Height + 1) * Unsorted::CellHeightInPixels / 2; + //else + // position.Y -= (pThisIsInf ? Unsorted::HealthBarYOffsetInfantry : Unsorted::HealthBarYOffsetOther) - pThis->GetTechnoType()->PixelSelectionBracketDelta; + + if (!pTypeExt->BarTypes.empty()) + { + pBarTypes = &pTypeExt->BarTypes; + } else - position.Y -= (pThisIsInf ? 25 : 26) - pThis->GetTechnoType()->PixelSelectionBracketDelta; + { + switch (pThis->WhatAmI()) + { + case AbstractType::Building: + { + pBarTypes = &RulesExt::Global()->Buildings_DefaultBarTypes; + const auto pBuildingType = static_cast(pType); + position.Y -= (pBuildingType->Height + 1) * Unsorted::CellHeightInPixels / 2; + break; + } + case AbstractType::Infantry: + { + pBarTypes = &RulesExt::Global()->Infantry_DefaultBarTypes; + position.Y -= Unsorted::HealthBarYOffsetInfantry - pType->PixelSelectionBracketDelta; + break; + } + case AbstractType::Unit: + { + pBarTypes = &RulesExt::Global()->Vehicles_DefaultBarTypes; + position.Y -= Unsorted::HealthBarYOffsetOther - pType->PixelSelectionBracketDelta; + break; + } + case AbstractType::Aircraft: + { + pBarTypes = &RulesExt::Global()->Aircraft_DefaultBarTypes; + position.Y -= Unsorted::HealthBarYOffsetOther - pType->PixelSelectionBracketDelta; + break; + } + default: + break; + } + } - TechnoExt::DrawBar(pThis, thisHBType, position, pBound, pThis->GetHealthPercentage(), RulesClass::Instance->ConditionYellow, RulesClass::Instance->ConditionRed); - const auto pExt = TechnoExt::ExtMap.Find(pThis); + if (pBarTypes->empty()) + { + TechnoExt::ProcessDigitalDisplays(pThis); + return 0; + } - if (const auto pShieldData = pExt->Shield.get()) + for (BarTypeClass*& pBarType : *pBarTypes) { - if (pShieldData->IsAvailable() && !pShieldData->IsBrokenAndNonRespawning()) + //if (HouseClass::IsCurrentPlayerObserver() && !pBarType->VisibleToHouses_Observer) + // continue; + + //if (!HouseClass::IsCurrentPlayerObserver() && !EnumFunctions::CanTargetHouse(pBarType->VisibleToHouses, pThis->Owner, HouseClass::CurrentPlayer)) + // continue; + + //int value = -1; + //int maxValue = -1; + + //GetValuesForDisplay(pThis, pBarType->InfoType, value, maxValue); + + //if (value == -1 || maxValue == -1) + // continue; + + //if (pBarType->ValueScaleDivisor > 1) + //{ + // value = Math::max(value / pBarType->ValueScaleDivisor, value != 0 ? 1 : 0); + // maxValue = Math::max(maxValue / pBarType->ValueScaleDivisor, maxValue != 0 ? 1 : 0); + //} + + //const bool isBuilding = pThis->WhatAmI() == AbstractType::Building; + //const bool isInfantry = pThis->WhatAmI() == AbstractType::Infantry; + //const bool hasShield = pExt->Shield != nullptr && !pExt->Shield->IsBrokenAndNonRespawning(); + //Point2D position = pThis->WhatAmI() == AbstractType::Building ? + // GetBuildingSelectBracketPosition(pThis, pDisplayType->AnchorType_Building) + // : GetFootSelectBracketPosition(pThis, pDisplayType->AnchorType); + //position.Y += pType->PixelSelectionBracketDelta; + double pValuePercentage = 1.0; + double pConditionYellow = 0.66; + double pConditionRed = 0.33; + + switch (pBarType->InfoType) { - if (thisSBType) + case DisplayInfoType::Health: { - position.Y += pShieldData->GetType()->BracketDelta; - TechnoExt::DrawBar(pThis, thisSBType, position, pBound, pShieldData->GetHealthRatio(), pShieldData->GetType()->GetConditionYellow(), pShieldData->GetType()->GetConditionRed()); + pValuePercentage = pThis->GetHealthPercentage(); + pConditionYellow = RulesClass::Instance->ConditionYellow; + pConditionRed = RulesClass::Instance->ConditionRed; + break; } - else + case DisplayInfoType::Shield: { - if (pThisIsBld) - { - const short pThisBldTypeWidth = static_cast(pThis)->Type->GetFoundationWidth(); - const int length = pThisBldTypeWidth * 7 + (pThisBldTypeWidth / 2); - pShieldData->DrawShieldBar_Building(length, pBound); - } - else - { - const int length = pThisIsInf ? 8 : 17; - pShieldData->DrawShieldBar_Other(length, pBound); - } + position.Y += pExt->Shield->GetType()->BracketDelta; + pValuePercentage = double(pExt->Shield->GetHP()) / pExt->Shield->GetType()->Strength.Get(); + pConditionYellow = pExt->Shield->GetType()->ConditionYellow; + pConditionRed = pExt->Shield->GetType()->ConditionRed; + break; + } + case DisplayInfoType::Ammo: + { + if (pType->Ammo > 0) + pValuePercentage = double(pThis->Ammo) / pType->Ammo; + + break; + } + case DisplayInfoType::MindControl: + { + if (pThis->CaptureManager != nullptr) + pValuePercentage = double(pThis->CaptureManager->ControlNodes.Count) / pThis->CaptureManager->MaxControlNodes; + + break; + } + case DisplayInfoType::Spawns: + { + if (pThis->SpawnManager == nullptr || pType->Spawns == nullptr || pType->SpawnsNumber <= 0) + break; + + pValuePercentage = double(pThis->SpawnManager->CountAliveSpawns()) / pType->SpawnsNumber; + break; + } + case DisplayInfoType::Passengers: + { + if (pType->Passengers > 0) + pValuePercentage = double(pThis->Passengers.NumPassengers) / pType->Passengers; + + break; + } + case DisplayInfoType::Tiberium: + { + if (pType->Storage > 0) + pValuePercentage = double(pThis->Tiberium.GetTotalAmount()) / pType->Storage; + + break; + } + case DisplayInfoType::Experience: + { + pValuePercentage = double(pThis->Veterancy.Veterancy * RulesClass::Instance->VeteranRatio * pType->GetCost()) / (2.0 * RulesClass::Instance->VeteranRatio * pType->GetCost()); + break; + } + case DisplayInfoType::Occupants: + { + if (pThis->WhatAmI() != AbstractType::Building) + break; + + const auto pBuildingType = abstract_cast(pType); + const auto pBuilding = abstract_cast(pThis); + + if (!pBuildingType->CanBeOccupied) + break; + + pValuePercentage = double(pBuilding->Occupants.Count) / pBuildingType->MaxNumberOccupants; + break; + } + case DisplayInfoType::GattlingStage: + { + if (!pType->IsGattling) + break; + + pValuePercentage = double(pThis->CurrentGattlingStage) / pType->WeaponStages; + break; + } + default: + { + break; } } + + TechnoExt::DrawBar(pThis, pBarType, position, pBound, pValuePercentage, pConditionYellow, pConditionRed); } TechnoExt::ProcessDigitalDisplays(pThis); diff --git a/src/Ext/TechnoType/Body.cpp b/src/Ext/TechnoType/Body.cpp index 0ee1c65b49..aede904be7 100644 --- a/src/Ext/TechnoType/Body.cpp +++ b/src/Ext/TechnoType/Body.cpp @@ -701,8 +701,7 @@ void TechnoTypeExt::ExtData::LoadFromINIFile(CCINIClass* const pINI) this->AttackMove_StopWhenTargetAcquired.Read(exINI, pSection, "AttackMove.StopWhenTargetAcquired"); this->AttackMove_PursuitTarget.Read(exINI, pSection, "AttackMove.PursuitTarget"); - this->HealthBar_BarType.Read(exINI, pSection, "HealthBar.BarType"); - this->ShieldBar_BarType.Read(exINI, pSection, "ShieldBar.BarType"); + this->BarTypes.Read(exINI, pSection, "BarTypes"); // Ares 0.2 this->RadarJamRadius.Read(exINI, pSection, "RadarJamRadius"); @@ -1304,8 +1303,7 @@ void TechnoTypeExt::ExtData::Serialize(T& Stm) .Process(this->AttackMove_StopWhenTargetAcquired) .Process(this->AttackMove_PursuitTarget) - .Process(this->HealthBar_BarType) - .Process(this->ShieldBar_BarType) + .Process(this->BarTypes) ; } void TechnoTypeExt::ExtData::LoadFromStream(PhobosStreamReader& Stm) diff --git a/src/Ext/TechnoType/Body.h b/src/Ext/TechnoType/Body.h index 1a6d6a0d44..c6113ff63f 100644 --- a/src/Ext/TechnoType/Body.h +++ b/src/Ext/TechnoType/Body.h @@ -329,8 +329,8 @@ class TechnoTypeExt Nullable Promote_VeteranAnimation; Nullable Promote_EliteAnimation; - Nullable HealthBar_BarType; - Nullable ShieldBar_BarType; + //Nullable BarTypes; + ValueableVector BarTypes; Nullable RadarInvisibleToHouse; @@ -729,8 +729,7 @@ class TechnoTypeExt , AttackMove_StopWhenTargetAcquired { } , AttackMove_PursuitTarget { false } - , HealthBar_BarType { } - , ShieldBar_BarType { } + , BarTypes { } { } virtual ~ExtData() = default; diff --git a/src/New/Type/BarTypeClass.cpp b/src/New/Type/BarTypeClass.cpp index e0d27a595e..0ab4ce6c61 100644 --- a/src/New/Type/BarTypeClass.cpp +++ b/src/New/Type/BarTypeClass.cpp @@ -17,20 +17,21 @@ void BarTypeClass::LoadFromINI(CCINIClass* pINI) INI_EX exINI(pINI); - this->Board_Background_File.Read(exINI, section, "Board.Background.File"); - this->Board_Background_ShowWhenNotSelected.Read(exINI, section, "Board.Background.ShowWhenNotSelected"); - this->Board_Background_Translucency.Read(exINI, section, "Board.Background.Translucency"); - this->Board_Foreground_File.Read(exINI, section, "Board.Foreground.File"); - this->Board_Foreground_ShowWhenNotSelected.Read(exINI, section, "Board.Foreground.ShowWhenNotSelected"); - this->Board_Foreground_Translucency.Read(exINI, section, "Board.Foreground.Translucency"); - this->Board_Offset.Read(exINI, section, "Board.Offset"); + this->InfoType.Read(exINI, section, "InfoType"); + this->PipBrd_Background_File.Read(exINI, section, "PipBrd.Background.File"); + this->PipBrd_Background_ShowWhenNotSelected.Read(exINI, section, "PipBrd.Background.ShowWhenNotSelected"); + this->PipBrd_Background_Translucency.Read(exINI, section, "PipBrd.Background.Translucency"); + this->PipBrd_Foreground_File.Read(exINI, section, "PipBrd.Foreground.File"); + this->PipBrd_Foreground_ShowWhenNotSelected.Read(exINI, section, "PipBrd.Foreground.ShowWhenNotSelected"); + this->PipBrd_Foreground_Translucency.Read(exINI, section, "PipBrd.Foreground.Translucency"); + this->PipBrd_Offset.Read(exINI, section, "PipBrd.Offset"); this->Bar_Offset.Read(exINI, section, "Bar.Offset"); - this->Sections_DrawBackwards.Read(exINI, section, "Sections.DrawBackwards"); - this->Sections_Pips_File.Read(exINI, section, "Sections.Pips.File"); - this->Sections_Pips.Read(exINI, section, "Sections.Pips"); - this->Sections_EmptyPip.Read(exINI, section, "Sections.EmptyPip"); - this->Sections_Amount.Read(exINI, section, "Sections.Amount"); - this->Sections_PositionDelta.Read(exINI, section, "Sections.PositionDelta"); + this->Pips_File.Read(exINI, section, "Pips.File"); + this->Pips_Frames.Read(exINI, section, "Pips.Frames"); + this->Pips_EmptyFrame.Read(exINI, section, "Pips.EmptyFrame"); + this->Pips_Amount.Read(exINI, section, "Pips.Amount"); + this->Pips_PositionDelta.Read(exINI, section, "Pips.PositionDelta"); + this->Pips_DrawBackwards.Read(exINI, section, "Pips.DrawBackwards"); } @@ -38,20 +39,21 @@ template void BarTypeClass::Serialize(T& Stm) { Stm - .Process(this->Board_Background_File) - .Process(this->Board_Background_ShowWhenNotSelected) - .Process(this->Board_Background_Translucency) - .Process(this->Board_Foreground_File) - .Process(this->Board_Foreground_ShowWhenNotSelected) - .Process(this->Board_Foreground_Translucency) - .Process(this->Board_Offset) + .Process(this->InfoType) + .Process(this->PipBrd_Background_File) + .Process(this->PipBrd_Background_ShowWhenNotSelected) + .Process(this->PipBrd_Background_Translucency) + .Process(this->PipBrd_Foreground_File) + .Process(this->PipBrd_Foreground_ShowWhenNotSelected) + .Process(this->PipBrd_Foreground_Translucency) + .Process(this->PipBrd_Offset) .Process(this->Bar_Offset) - .Process(this->Sections_DrawBackwards) - .Process(this->Sections_Pips_File) - .Process(this->Sections_Pips) - .Process(this->Sections_EmptyPip) - .Process(this->Sections_Amount) - .Process(this->Sections_PositionDelta) + .Process(this->Pips_File) + .Process(this->Pips_Frames) + .Process(this->Pips_EmptyFrame) + .Process(this->Pips_Amount) + .Process(this->Pips_PositionDelta) + .Process(this->Pips_DrawBackwards) ; } diff --git a/src/New/Type/BarTypeClass.h b/src/New/Type/BarTypeClass.h index 3705305420..0929129680 100644 --- a/src/New/Type/BarTypeClass.h +++ b/src/New/Type/BarTypeClass.h @@ -8,36 +8,38 @@ class BarTypeClass final : public Enumerable { public: - Nullable Board_Background_File; - Valueable Board_Background_ShowWhenNotSelected; - Nullable Board_Background_Translucency; - Nullable Board_Foreground_File; - Valueable Board_Foreground_ShowWhenNotSelected; - Nullable Board_Foreground_Translucency; - Valueable> Board_Offset; + Valueable InfoType; + Nullable PipBrd_Background_File; + Valueable PipBrd_Background_ShowWhenNotSelected; + Nullable PipBrd_Background_Translucency; + Nullable PipBrd_Foreground_File; + Valueable PipBrd_Foreground_ShowWhenNotSelected; + Nullable PipBrd_Foreground_Translucency; + Valueable> PipBrd_Offset; Valueable> Bar_Offset; - Valueable Sections_DrawBackwards; - Valueable Sections_Pips_File; - Valueable> Sections_Pips; - Valueable Sections_EmptyPip; - Valueable Sections_Amount; - Valueable> Sections_PositionDelta; + Valueable Pips_File; + Valueable> Pips_Frames; + Valueable Pips_EmptyFrame; + Valueable Pips_Amount; + Valueable> Pips_PositionDelta; + Valueable Pips_DrawBackwards; BarTypeClass(const char* pTitle = NONE_STR) : Enumerable(pTitle) - , Board_Background_File { } - , Board_Background_ShowWhenNotSelected { false } - , Board_Background_Translucency { } - , Board_Foreground_File { } - , Board_Foreground_ShowWhenNotSelected { false } - , Board_Foreground_Translucency { } - , Board_Offset { { 0, 0 } } + , InfoType { } + , PipBrd_Background_File { } + , PipBrd_Background_ShowWhenNotSelected { false } + , PipBrd_Background_Translucency { } + , PipBrd_Foreground_File { } + , PipBrd_Foreground_ShowWhenNotSelected { false } + , PipBrd_Foreground_Translucency { } + , PipBrd_Offset { { 0, 0 } } , Bar_Offset { { 0, 0 } } - , Sections_DrawBackwards { false } - , Sections_Pips_File { FileSystem::PIPS_SHP() } - , Sections_Pips { { 16, 17, 18 } } - , Sections_EmptyPip { -1 } - , Sections_Amount { 17 } - , Sections_PositionDelta { { 2, 0 } } + , Pips_File { FileSystem::PIPS_SHP } + , Pips_Frames { { 16, 17, 18 } } + , Pips_EmptyFrame { -1 } + , Pips_Amount { 17 } + , Pips_PositionDelta { { 2, 0 } } + , Pips_DrawBackwards { false } { } void LoadFromINI(CCINIClass* pINI); From 1c1b8229ebdd14cc50440a64696c53a3ddd1b6e6 Mon Sep 17 00:00:00 2001 From: Fryone Date: Mon, 24 Nov 2025 21:14:58 +0300 Subject: [PATCH 16/20] update renewed 1 shield check fix yrpp update --- YRpp | 2 +- src/Ext/Techno/Hooks.Pips.cpp | 17 +++++++++++------ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/YRpp b/YRpp index 5d92d7d756..3cb1c3f244 160000 --- a/YRpp +++ b/YRpp @@ -1 +1 @@ -Subproject commit 5d92d7d756db36b1819719027e8992928e75e0b4 +Subproject commit 3cb1c3f244d15c0bc52e2d5a4c0f36b729b13f5c diff --git a/src/Ext/Techno/Hooks.Pips.cpp b/src/Ext/Techno/Hooks.Pips.cpp index cdd68f1e97..fe2e8e9c13 100644 --- a/src/Ext/Techno/Hooks.Pips.cpp +++ b/src/Ext/Techno/Hooks.Pips.cpp @@ -459,9 +459,9 @@ DEFINE_HOOK(0x6F64A9, TechnoClass_DrawHealthBar_HealthAndShieldBar, 0x5) // return 0; const auto pExt = TechnoExt::ExtMap.Find(pThis); - const bool pThisIsInf = pThis->WhatAmI() == AbstractType::Infantry; - const bool pThisIsBld = pThis->WhatAmI() == AbstractType::Building; ValueableVector* pBarTypes = nullptr; + //const bool pThisIsInf = pThis->WhatAmI() == AbstractType::Infantry; + //const bool pThisIsBld = pThis->WhatAmI() == AbstractType::Building; Point2D position = *pLocation; @@ -558,10 +558,15 @@ DEFINE_HOOK(0x6F64A9, TechnoClass_DrawHealthBar_HealthAndShieldBar, 0x5) } case DisplayInfoType::Shield: { - position.Y += pExt->Shield->GetType()->BracketDelta; - pValuePercentage = double(pExt->Shield->GetHP()) / pExt->Shield->GetType()->Strength.Get(); - pConditionYellow = pExt->Shield->GetType()->ConditionYellow; - pConditionRed = pExt->Shield->GetType()->ConditionRed; + if (const auto pShield = pExt->Shield.get()) + { + if (pShield->IsBrokenAndNonRespawning()) + break; + position.Y += pShield->GetType()->BracketDelta; + pValuePercentage = double(pShield->GetHP()) / pShield->GetType()->Strength.Get(); + pConditionYellow = pShield->GetType()->ConditionYellow; + pConditionRed = pShield->GetType()->ConditionRed; + } break; } case DisplayInfoType::Ammo: From d7c6acba38183216e193268c95fe7ff869bc8f81 Mon Sep 17 00:00:00 2001 From: Fryone Date: Tue, 25 Nov 2025 00:21:41 +0300 Subject: [PATCH 17/20] update renewed 1.1 --- src/Ext/Techno/Body.Visuals.cpp | 4 ++- src/Ext/Techno/Hooks.Pips.cpp | 62 +++++++++++++++++++++------------ 2 files changed, 43 insertions(+), 23 deletions(-) diff --git a/src/Ext/Techno/Body.Visuals.cpp b/src/Ext/Techno/Body.Visuals.cpp index 0318cd85fb..1ccb80768f 100644 --- a/src/Ext/Techno/Body.Visuals.cpp +++ b/src/Ext/Techno/Body.Visuals.cpp @@ -876,10 +876,12 @@ void TechnoExt::DrawBar(TechnoClass* pThis, BarTypeClass* barType, Point2D pLoca const int sectionEmptyFrame = barType->Pips_EmptyFrame; const bool drawBackwards = barType->Pips_DrawBackwards; int sectionsToDraw = (int)round(sectionAmount * barPercentage); - sectionsToDraw = sectionsToDraw == 0 ? 1 : sectionsToDraw; int frameIdxa = sectionFrames.Z; int sign = drawBackwards ? 1 : -1; + if(barType->InfoType == DisplayInfoType::Health) + sectionsToDraw = sectionsToDraw == 0 ? 1 : sectionsToDraw; + if (barPercentage > conditionYellow) frameIdxa = sectionFrames.X; else if (barPercentage > conditionRed) diff --git a/src/Ext/Techno/Hooks.Pips.cpp b/src/Ext/Techno/Hooks.Pips.cpp index fe2e8e9c13..dbc94f0ab7 100644 --- a/src/Ext/Techno/Hooks.Pips.cpp +++ b/src/Ext/Techno/Hooks.Pips.cpp @@ -441,7 +441,7 @@ DEFINE_HOOK(0x70A4FB, TechnoClass_DrawPips_SelfHealGain, 0x5) return SkipGameDrawing; } -DEFINE_HOOK(0x6F64A9, TechnoClass_DrawHealthBar_HealthAndShieldBar, 0x5) +DEFINE_HOOK(0x6F64A9, TechnoClass_DrawHealthBar_PrepareBarsToDraw, 0x5) { enum { Skip = 0x6F6AB6 }; @@ -452,8 +452,6 @@ DEFINE_HOOK(0x6F64A9, TechnoClass_DrawHealthBar_HealthAndShieldBar, 0x5) const auto pType = pThis->GetTechnoType(); const auto pTypeExt = TechnoTypeExt::ExtMap.Find(pThis->GetTechnoType()); - if (pTypeExt && pTypeExt->HealthBar_Hide) - return Skip; //if (!pTypeExt->HealthBar_BarType) // return 0; @@ -511,6 +509,10 @@ DEFINE_HOOK(0x6F64A9, TechnoClass_DrawHealthBar_HealthAndShieldBar, 0x5) if (pBarTypes->empty()) { TechnoExt::ProcessDigitalDisplays(pThis); + + if (pTypeExt && pTypeExt->HealthBar_Hide) + return Skip; + return 0; } @@ -551,36 +553,46 @@ DEFINE_HOOK(0x6F64A9, TechnoClass_DrawHealthBar_HealthAndShieldBar, 0x5) { case DisplayInfoType::Health: { + if (pTypeExt && pTypeExt->HealthBar_Hide) + return Skip; + pValuePercentage = pThis->GetHealthPercentage(); pConditionYellow = RulesClass::Instance->ConditionYellow; pConditionRed = RulesClass::Instance->ConditionRed; + TechnoExt::DrawBar(pThis, pBarType, position, pBound, pValuePercentage, pConditionYellow, pConditionRed); break; } case DisplayInfoType::Shield: { - if (const auto pShield = pExt->Shield.get()) - { - if (pShield->IsBrokenAndNonRespawning()) - break; - position.Y += pShield->GetType()->BracketDelta; - pValuePercentage = double(pShield->GetHP()) / pShield->GetType()->Strength.Get(); - pConditionYellow = pShield->GetType()->ConditionYellow; - pConditionRed = pShield->GetType()->ConditionRed; - } + const auto pShield = TechnoExt::ExtMap.Find(pThis)->Shield.get(); + const bool hasShield = pShield && !pShield->IsBrokenAndNonRespawning(); + + if (!hasShield) + break; + + position.Y += pShield->GetType()->BracketDelta; + pValuePercentage = double(pShield->GetHP()) / pShield->GetType()->Strength.Get(); + pConditionYellow = pShield->GetType()->ConditionYellow; + pConditionRed = pShield->GetType()->ConditionRed; + TechnoExt::DrawBar(pThis, pBarType, position, pBound, pValuePercentage, pConditionYellow, pConditionRed); break; } case DisplayInfoType::Ammo: { - if (pType->Ammo > 0) - pValuePercentage = double(pThis->Ammo) / pType->Ammo; + if (pType->Ammo == 0) + break; + pValuePercentage = double(pThis->Ammo) / pType->Ammo; + TechnoExt::DrawBar(pThis, pBarType, position, pBound, pValuePercentage, pConditionYellow, pConditionRed); break; } case DisplayInfoType::MindControl: { - if (pThis->CaptureManager != nullptr) - pValuePercentage = double(pThis->CaptureManager->ControlNodes.Count) / pThis->CaptureManager->MaxControlNodes; + if (pThis->CaptureManager == nullptr) + break; + pValuePercentage = double(pThis->CaptureManager->ControlNodes.Count) / pThis->CaptureManager->MaxControlNodes; + TechnoExt::DrawBar(pThis, pBarType, position, pBound, pValuePercentage, pConditionYellow, pConditionRed); break; } case DisplayInfoType::Spawns: @@ -589,25 +601,31 @@ DEFINE_HOOK(0x6F64A9, TechnoClass_DrawHealthBar_HealthAndShieldBar, 0x5) break; pValuePercentage = double(pThis->SpawnManager->CountAliveSpawns()) / pType->SpawnsNumber; + TechnoExt::DrawBar(pThis, pBarType, position, pBound, pValuePercentage, pConditionYellow, pConditionRed); break; } case DisplayInfoType::Passengers: { - if (pType->Passengers > 0) - pValuePercentage = double(pThis->Passengers.NumPassengers) / pType->Passengers; + if (pType->Passengers == 0) + break; + pValuePercentage = double(pThis->Passengers.NumPassengers) / pType->Passengers; + TechnoExt::DrawBar(pThis, pBarType, position, pBound, pValuePercentage, pConditionYellow, pConditionRed); break; } case DisplayInfoType::Tiberium: { - if (pType->Storage > 0) - pValuePercentage = double(pThis->Tiberium.GetTotalAmount()) / pType->Storage; + if (pType->Storage == 0) + break; + pValuePercentage = double(pThis->Tiberium.GetTotalAmount()) / pType->Storage; + TechnoExt::DrawBar(pThis, pBarType, position, pBound, pValuePercentage, pConditionYellow, pConditionRed); break; } case DisplayInfoType::Experience: { pValuePercentage = double(pThis->Veterancy.Veterancy * RulesClass::Instance->VeteranRatio * pType->GetCost()) / (2.0 * RulesClass::Instance->VeteranRatio * pType->GetCost()); + TechnoExt::DrawBar(pThis, pBarType, position, pBound, pValuePercentage, pConditionYellow, pConditionRed); break; } case DisplayInfoType::Occupants: @@ -622,6 +640,7 @@ DEFINE_HOOK(0x6F64A9, TechnoClass_DrawHealthBar_HealthAndShieldBar, 0x5) break; pValuePercentage = double(pBuilding->Occupants.Count) / pBuildingType->MaxNumberOccupants; + TechnoExt::DrawBar(pThis, pBarType, position, pBound, pValuePercentage, pConditionYellow, pConditionRed); break; } case DisplayInfoType::GattlingStage: @@ -630,6 +649,7 @@ DEFINE_HOOK(0x6F64A9, TechnoClass_DrawHealthBar_HealthAndShieldBar, 0x5) break; pValuePercentage = double(pThis->CurrentGattlingStage) / pType->WeaponStages; + TechnoExt::DrawBar(pThis, pBarType, position, pBound, pValuePercentage, pConditionYellow, pConditionRed); break; } default: @@ -637,8 +657,6 @@ DEFINE_HOOK(0x6F64A9, TechnoClass_DrawHealthBar_HealthAndShieldBar, 0x5) break; } } - - TechnoExt::DrawBar(pThis, pBarType, position, pBound, pValuePercentage, pConditionYellow, pConditionRed); } TechnoExt::ProcessDigitalDisplays(pThis); From dc7ee7a89887f7198f02f79c3c525ece9d4aca39 Mon Sep 17 00:00:00 2001 From: Fryone Date: Wed, 26 Nov 2025 20:50:32 +0300 Subject: [PATCH 18/20] update renewed 2 - removed hook and used similar to DigitalDisplay procedure - values check used from DigitalDisplay * vanilla and new health bars behave a bit different - no info index atm --- YRpp | 2 +- src/Ext/Techno/Body.Visuals.cpp | 91 +++++++++++++ src/Ext/Techno/Body.h | 1 + src/Ext/Techno/Hooks.Pips.cpp | 227 +------------------------------- 4 files changed, 96 insertions(+), 225 deletions(-) diff --git a/YRpp b/YRpp index 3cb1c3f244..ff414079f5 160000 --- a/YRpp +++ b/YRpp @@ -1 +1 @@ -Subproject commit 3cb1c3f244d15c0bc52e2d5a4c0f36b729b13f5c +Subproject commit ff414079f5ac770d666547f67ad7709b990b5ab3 diff --git a/src/Ext/Techno/Body.Visuals.cpp b/src/Ext/Techno/Body.Visuals.cpp index 1ccb80768f..788a6f3fe6 100644 --- a/src/Ext/Techno/Body.Visuals.cpp +++ b/src/Ext/Techno/Body.Visuals.cpp @@ -866,6 +866,97 @@ void TechnoExt::GetDigitalDisplayFakeHealth(TechnoClass* pThis, int& value, int& } } +void TechnoExt::ProcessBars(TechnoClass* pThis, Point2D pLocation, RectangleStruct* pBounds) +{ + const auto pType = pThis->GetTechnoType(); + const auto pTypeExt = TechnoTypeExt::ExtMap.Find(pThis->GetTechnoType()); + ValueableVector* pBarTypes = nullptr; + + if (!pTypeExt->BarTypes.empty()) + { + pBarTypes = &pTypeExt->BarTypes; + } + else + { + switch (pThis->WhatAmI()) + { + case AbstractType::Building: + { + pBarTypes = &RulesExt::Global()->Buildings_DefaultBarTypes; + const auto pBuildingType = static_cast(pType); + pLocation.Y -= (pBuildingType->Height + 1) * Unsorted::CellHeightInPixels / 2; + break; + } + case AbstractType::Infantry: + { + pBarTypes = &RulesExt::Global()->Infantry_DefaultBarTypes; + pLocation.Y -= Unsorted::HealthBarYOffsetInfantry - pType->PixelSelectionBracketDelta; + break; + } + case AbstractType::Unit: + { + pBarTypes = &RulesExt::Global()->Vehicles_DefaultBarTypes; + pLocation.Y -= Unsorted::HealthBarYOffsetOther - pType->PixelSelectionBracketDelta; + break; + } + case AbstractType::Aircraft: + { + pBarTypes = &RulesExt::Global()->Aircraft_DefaultBarTypes; + pLocation.Y -= Unsorted::HealthBarYOffsetOther - pType->PixelSelectionBracketDelta; + break; + } + default: + break; + } + } + + if (pBarTypes->empty()) + return; + + for (BarTypeClass*& pBarType : *pBarTypes) + { + double pConditionYellow = 0.66; + double pConditionRed = 0.33; + + switch (pBarType->InfoType) + { + case DisplayInfoType::Health: + { + pConditionYellow = RulesClass::Instance->ConditionYellow; + pConditionRed = RulesClass::Instance->ConditionRed; + break; + } + case DisplayInfoType::Shield: + { + const auto pShield = TechnoExt::ExtMap.Find(pThis)->Shield.get(); + const bool hasShield = pShield != nullptr && !pShield->IsBrokenAndNonRespawning(); + + if (!hasShield) + continue; + + pConditionYellow = pShield->GetType()->ConditionYellow ? pShield->GetType()->ConditionYellow : RulesClass::Instance->ConditionYellow; + pConditionRed = pShield->GetType()->ConditionRed ? pShield->GetType()->ConditionRed : RulesClass::Instance->ConditionRed; + break; + } + default: + { + break; + } + } + + int value = -1; + int maxValue = 0; + + GetValuesForDisplay(pThis, pType, pBarType->InfoType, value, maxValue, 0 /*pBarType->InfoIndex*/); + + if (value <= -1 || maxValue <= 0) + continue; + + double pValuePercentage = static_cast(value) / maxValue; + TechnoExt::DrawBar(pThis, pBarType, pLocation, pBounds, pValuePercentage, pConditionYellow, pConditionRed); + } +} + void TechnoExt::DrawBar(TechnoClass* pThis, BarTypeClass* barType, Point2D pLocation, RectangleStruct* pBounds, double barPercentage, double conditionYellow, double conditionRed) { const BlitterFlags blitFlagsBG = barType->PipBrd_Background_Translucency.Get(0); diff --git a/src/Ext/Techno/Body.h b/src/Ext/Techno/Body.h index b3dbc8c8f4..bb0dbbe9d7 100644 --- a/src/Ext/Techno/Body.h +++ b/src/Ext/Techno/Body.h @@ -294,6 +294,7 @@ class TechnoExt static void HandleOnDeployAmmoChange(TechnoClass* pThis, int maxAmmoOverride = -1); static bool SimpleDeployerAllowedToDeploy(UnitClass* pThis, bool defaultValue, bool alwaysCheckLandTypes); static void ShowPromoteAnim(TechnoClass* pThis); + static void ProcessBars(TechnoClass* pThis, Point2D pLocation, RectangleStruct* pBounds); static void DrawBar(TechnoClass* pThis, BarTypeClass* barType, Point2D pLocation, RectangleStruct* pBounds, double barPercentage, double conditionYellow, double conditionRed); // WeaponHelpers.cpp diff --git a/src/Ext/Techno/Hooks.Pips.cpp b/src/Ext/Techno/Hooks.Pips.cpp index dbc94f0ab7..7a9bea5541 100644 --- a/src/Ext/Techno/Hooks.Pips.cpp +++ b/src/Ext/Techno/Hooks.Pips.cpp @@ -80,12 +80,12 @@ DEFINE_HOOK(0x6F65D1, TechnoClass_DrawHealthBar_Buildings, 0x6) GET(BuildingClass*, pThis, ESI); GET(const int, length, EBX); GET_STACK(RectangleStruct*, pBound, STACK_OFFSET(0x4C, 0x8)); + GET_STACK(Point2D*, pLocation, STACK_OFFSET(0x4C, 0x4)); const auto pExt = TechnoExt::ExtMap.Find(pThis); if (pThis->IsSelected && Phobos::Config::EnableSelectBox && !pExt->TypeExtData->HideSelectBox) { - GET_STACK(Point2D*, pLocation, STACK_OFFSET(0x4C, 0x4)); UNREFERENCED_PARAMETER(pLocation); // choom thought he was clever and recomputed the same shit again and again TechnoExt::DrawSelectBox(pThis, pLocation, pBound); } @@ -98,6 +98,7 @@ DEFINE_HOOK(0x6F65D1, TechnoClass_DrawHealthBar_Buildings, 0x6) } } + TechnoExt::ProcessBars(pThis, *pLocation, pBound); TechnoExt::ProcessDigitalDisplays(pThis); return 0; @@ -128,6 +129,7 @@ DEFINE_HOOK(0x6F683C, TechnoClass_DrawHealthBar_Units, 0x7) } } + TechnoExt::ProcessBars(pThis, *pLocation, pBound); TechnoExt::ProcessDigitalDisplays(pThis); if (pExt->TypeExtData->HealthBar_HidePips) @@ -440,226 +442,3 @@ DEFINE_HOOK(0x70A4FB, TechnoClass_DrawPips_SelfHealGain, 0x5) return SkipGameDrawing; } - -DEFINE_HOOK(0x6F64A9, TechnoClass_DrawHealthBar_PrepareBarsToDraw, 0x5) -{ - enum { Skip = 0x6F6AB6 }; - - GET(TechnoClass*, pThis, ECX); - GET_STACK(Point2D*, pLocation, STACK_OFFSET(0x4C, 0x4)); - GET_STACK(RectangleStruct*, pBound, STACK_OFFSET(0x4C, 0x8)); - - const auto pType = pThis->GetTechnoType(); - const auto pTypeExt = TechnoTypeExt::ExtMap.Find(pThis->GetTechnoType()); - - - //if (!pTypeExt->HealthBar_BarType) - // return 0; - - const auto pExt = TechnoExt::ExtMap.Find(pThis); - ValueableVector* pBarTypes = nullptr; - //const bool pThisIsInf = pThis->WhatAmI() == AbstractType::Infantry; - //const bool pThisIsBld = pThis->WhatAmI() == AbstractType::Building; - - Point2D position = *pLocation; - - //if (pThisIsBld) - // position.Y -= (static_cast(pThis)->Type->Height + 1) * Unsorted::CellHeightInPixels / 2; - //else - // position.Y -= (pThisIsInf ? Unsorted::HealthBarYOffsetInfantry : Unsorted::HealthBarYOffsetOther) - pThis->GetTechnoType()->PixelSelectionBracketDelta; - - if (!pTypeExt->BarTypes.empty()) - { - pBarTypes = &pTypeExt->BarTypes; - } - else - { - switch (pThis->WhatAmI()) - { - case AbstractType::Building: - { - pBarTypes = &RulesExt::Global()->Buildings_DefaultBarTypes; - const auto pBuildingType = static_cast(pType); - position.Y -= (pBuildingType->Height + 1) * Unsorted::CellHeightInPixels / 2; - break; - } - case AbstractType::Infantry: - { - pBarTypes = &RulesExt::Global()->Infantry_DefaultBarTypes; - position.Y -= Unsorted::HealthBarYOffsetInfantry - pType->PixelSelectionBracketDelta; - break; - } - case AbstractType::Unit: - { - pBarTypes = &RulesExt::Global()->Vehicles_DefaultBarTypes; - position.Y -= Unsorted::HealthBarYOffsetOther - pType->PixelSelectionBracketDelta; - break; - } - case AbstractType::Aircraft: - { - pBarTypes = &RulesExt::Global()->Aircraft_DefaultBarTypes; - position.Y -= Unsorted::HealthBarYOffsetOther - pType->PixelSelectionBracketDelta; - break; - } - default: - break; - } - } - - if (pBarTypes->empty()) - { - TechnoExt::ProcessDigitalDisplays(pThis); - - if (pTypeExt && pTypeExt->HealthBar_Hide) - return Skip; - - return 0; - } - - for (BarTypeClass*& pBarType : *pBarTypes) - { - //if (HouseClass::IsCurrentPlayerObserver() && !pBarType->VisibleToHouses_Observer) - // continue; - - //if (!HouseClass::IsCurrentPlayerObserver() && !EnumFunctions::CanTargetHouse(pBarType->VisibleToHouses, pThis->Owner, HouseClass::CurrentPlayer)) - // continue; - - //int value = -1; - //int maxValue = -1; - - //GetValuesForDisplay(pThis, pBarType->InfoType, value, maxValue); - - //if (value == -1 || maxValue == -1) - // continue; - - //if (pBarType->ValueScaleDivisor > 1) - //{ - // value = Math::max(value / pBarType->ValueScaleDivisor, value != 0 ? 1 : 0); - // maxValue = Math::max(maxValue / pBarType->ValueScaleDivisor, maxValue != 0 ? 1 : 0); - //} - - //const bool isBuilding = pThis->WhatAmI() == AbstractType::Building; - //const bool isInfantry = pThis->WhatAmI() == AbstractType::Infantry; - //const bool hasShield = pExt->Shield != nullptr && !pExt->Shield->IsBrokenAndNonRespawning(); - //Point2D position = pThis->WhatAmI() == AbstractType::Building ? - // GetBuildingSelectBracketPosition(pThis, pDisplayType->AnchorType_Building) - // : GetFootSelectBracketPosition(pThis, pDisplayType->AnchorType); - //position.Y += pType->PixelSelectionBracketDelta; - double pValuePercentage = 1.0; - double pConditionYellow = 0.66; - double pConditionRed = 0.33; - - switch (pBarType->InfoType) - { - case DisplayInfoType::Health: - { - if (pTypeExt && pTypeExt->HealthBar_Hide) - return Skip; - - pValuePercentage = pThis->GetHealthPercentage(); - pConditionYellow = RulesClass::Instance->ConditionYellow; - pConditionRed = RulesClass::Instance->ConditionRed; - TechnoExt::DrawBar(pThis, pBarType, position, pBound, pValuePercentage, pConditionYellow, pConditionRed); - break; - } - case DisplayInfoType::Shield: - { - const auto pShield = TechnoExt::ExtMap.Find(pThis)->Shield.get(); - const bool hasShield = pShield && !pShield->IsBrokenAndNonRespawning(); - - if (!hasShield) - break; - - position.Y += pShield->GetType()->BracketDelta; - pValuePercentage = double(pShield->GetHP()) / pShield->GetType()->Strength.Get(); - pConditionYellow = pShield->GetType()->ConditionYellow; - pConditionRed = pShield->GetType()->ConditionRed; - TechnoExt::DrawBar(pThis, pBarType, position, pBound, pValuePercentage, pConditionYellow, pConditionRed); - break; - } - case DisplayInfoType::Ammo: - { - if (pType->Ammo == 0) - break; - - pValuePercentage = double(pThis->Ammo) / pType->Ammo; - TechnoExt::DrawBar(pThis, pBarType, position, pBound, pValuePercentage, pConditionYellow, pConditionRed); - break; - } - case DisplayInfoType::MindControl: - { - if (pThis->CaptureManager == nullptr) - break; - - pValuePercentage = double(pThis->CaptureManager->ControlNodes.Count) / pThis->CaptureManager->MaxControlNodes; - TechnoExt::DrawBar(pThis, pBarType, position, pBound, pValuePercentage, pConditionYellow, pConditionRed); - break; - } - case DisplayInfoType::Spawns: - { - if (pThis->SpawnManager == nullptr || pType->Spawns == nullptr || pType->SpawnsNumber <= 0) - break; - - pValuePercentage = double(pThis->SpawnManager->CountAliveSpawns()) / pType->SpawnsNumber; - TechnoExt::DrawBar(pThis, pBarType, position, pBound, pValuePercentage, pConditionYellow, pConditionRed); - break; - } - case DisplayInfoType::Passengers: - { - if (pType->Passengers == 0) - break; - - pValuePercentage = double(pThis->Passengers.NumPassengers) / pType->Passengers; - TechnoExt::DrawBar(pThis, pBarType, position, pBound, pValuePercentage, pConditionYellow, pConditionRed); - break; - } - case DisplayInfoType::Tiberium: - { - if (pType->Storage == 0) - break; - - pValuePercentage = double(pThis->Tiberium.GetTotalAmount()) / pType->Storage; - TechnoExt::DrawBar(pThis, pBarType, position, pBound, pValuePercentage, pConditionYellow, pConditionRed); - break; - } - case DisplayInfoType::Experience: - { - pValuePercentage = double(pThis->Veterancy.Veterancy * RulesClass::Instance->VeteranRatio * pType->GetCost()) / (2.0 * RulesClass::Instance->VeteranRatio * pType->GetCost()); - TechnoExt::DrawBar(pThis, pBarType, position, pBound, pValuePercentage, pConditionYellow, pConditionRed); - break; - } - case DisplayInfoType::Occupants: - { - if (pThis->WhatAmI() != AbstractType::Building) - break; - - const auto pBuildingType = abstract_cast(pType); - const auto pBuilding = abstract_cast(pThis); - - if (!pBuildingType->CanBeOccupied) - break; - - pValuePercentage = double(pBuilding->Occupants.Count) / pBuildingType->MaxNumberOccupants; - TechnoExt::DrawBar(pThis, pBarType, position, pBound, pValuePercentage, pConditionYellow, pConditionRed); - break; - } - case DisplayInfoType::GattlingStage: - { - if (!pType->IsGattling) - break; - - pValuePercentage = double(pThis->CurrentGattlingStage) / pType->WeaponStages; - TechnoExt::DrawBar(pThis, pBarType, position, pBound, pValuePercentage, pConditionYellow, pConditionRed); - break; - } - default: - { - break; - } - } - } - - TechnoExt::ProcessDigitalDisplays(pThis); - - return Skip; -} From 7a66283c20f11f88ec5aa2fedba4774d1000a1a9 Mon Sep 17 00:00:00 2001 From: Fryone Date: Fri, 28 Nov 2025 19:15:23 +0300 Subject: [PATCH 19/20] update renewed 3 - added InfoIndex - added Bar.ConditionYellow and Bar.ConditionRed --- src/Ext/Techno/Body.Visuals.cpp | 14 +++++++------- src/New/Type/BarTypeClass.cpp | 6 ++++++ src/New/Type/BarTypeClass.h | 8 +++++++- 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/src/Ext/Techno/Body.Visuals.cpp b/src/Ext/Techno/Body.Visuals.cpp index 788a6f3fe6..17febfbe86 100644 --- a/src/Ext/Techno/Body.Visuals.cpp +++ b/src/Ext/Techno/Body.Visuals.cpp @@ -915,15 +915,15 @@ void TechnoExt::ProcessBars(TechnoClass* pThis, Point2D pLocation, RectangleStru for (BarTypeClass*& pBarType : *pBarTypes) { - double pConditionYellow = 0.66; - double pConditionRed = 0.33; + double pConditionYellow = pBarType->Bar_ConditionYellow; + double pConditionRed = pBarType->Bar_ConditionRed; switch (pBarType->InfoType) { case DisplayInfoType::Health: { - pConditionYellow = RulesClass::Instance->ConditionYellow; - pConditionRed = RulesClass::Instance->ConditionRed; + pConditionYellow = pConditionYellow > 0 ? pConditionYellow : RulesClass::Instance->ConditionYellow; + pConditionRed = pConditionRed > 0 ? pConditionRed : RulesClass::Instance->ConditionRed; break; } case DisplayInfoType::Shield: @@ -934,8 +934,8 @@ void TechnoExt::ProcessBars(TechnoClass* pThis, Point2D pLocation, RectangleStru if (!hasShield) continue; - pConditionYellow = pShield->GetType()->ConditionYellow ? pShield->GetType()->ConditionYellow : RulesClass::Instance->ConditionYellow; - pConditionRed = pShield->GetType()->ConditionRed ? pShield->GetType()->ConditionRed : RulesClass::Instance->ConditionRed; + pConditionYellow = pConditionYellow > 0 ? pConditionYellow : (pShield->GetType()->ConditionYellow ? pShield->GetType()->ConditionYellow : RulesClass::Instance->ConditionYellow); + pConditionRed = pConditionYellow > 0 ? pConditionYellow : (pShield->GetType()->ConditionRed ? pShield->GetType()->ConditionRed : RulesClass::Instance->ConditionRed); break; } default: @@ -947,7 +947,7 @@ void TechnoExt::ProcessBars(TechnoClass* pThis, Point2D pLocation, RectangleStru int value = -1; int maxValue = 0; - GetValuesForDisplay(pThis, pType, pBarType->InfoType, value, maxValue, 0 /*pBarType->InfoIndex*/); + GetValuesForDisplay(pThis, pType, pBarType->InfoType, value, maxValue, pBarType->InfoIndex); if (value <= -1 || maxValue <= 0) continue; diff --git a/src/New/Type/BarTypeClass.cpp b/src/New/Type/BarTypeClass.cpp index 0ab4ce6c61..deb0394e0b 100644 --- a/src/New/Type/BarTypeClass.cpp +++ b/src/New/Type/BarTypeClass.cpp @@ -18,6 +18,9 @@ void BarTypeClass::LoadFromINI(CCINIClass* pINI) INI_EX exINI(pINI); this->InfoType.Read(exINI, section, "InfoType"); + this->InfoIndex.Read(exINI, section, "InfoIndex"); + this->Bar_ConditionYellow.Read(exINI, section, "Bar.ConditionYellow"); + this->Bar_ConditionRed.Read(exINI, section, "Bar.ConditionRed"); this->PipBrd_Background_File.Read(exINI, section, "PipBrd.Background.File"); this->PipBrd_Background_ShowWhenNotSelected.Read(exINI, section, "PipBrd.Background.ShowWhenNotSelected"); this->PipBrd_Background_Translucency.Read(exINI, section, "PipBrd.Background.Translucency"); @@ -40,6 +43,9 @@ void BarTypeClass::Serialize(T& Stm) { Stm .Process(this->InfoType) + .Process(this->InfoIndex) + .Process(this->Bar_ConditionYellow) + .Process(this->Bar_ConditionRed) .Process(this->PipBrd_Background_File) .Process(this->PipBrd_Background_ShowWhenNotSelected) .Process(this->PipBrd_Background_Translucency) diff --git a/src/New/Type/BarTypeClass.h b/src/New/Type/BarTypeClass.h index 0929129680..68c5ed5c0c 100644 --- a/src/New/Type/BarTypeClass.h +++ b/src/New/Type/BarTypeClass.h @@ -9,6 +9,9 @@ class BarTypeClass final : public Enumerable { public: Valueable InfoType; + Valueable InfoIndex; + Valueable Bar_ConditionYellow; + Valueable Bar_ConditionRed; Nullable PipBrd_Background_File; Valueable PipBrd_Background_ShowWhenNotSelected; Nullable PipBrd_Background_Translucency; @@ -25,7 +28,10 @@ class BarTypeClass final : public Enumerable Valueable Pips_DrawBackwards; BarTypeClass(const char* pTitle = NONE_STR) : Enumerable(pTitle) - , InfoType { } + , InfoType { DisplayInfoType::Health } + , InfoIndex { 0 } + , Bar_ConditionYellow { 0.66 } + , Bar_ConditionRed { 0.33 } , PipBrd_Background_File { } , PipBrd_Background_ShowWhenNotSelected { false } , PipBrd_Background_Translucency { } From f8ba66281247af54a79363f2b7cce8f37f15506d Mon Sep 17 00:00:00 2001 From: Fryone Date: Thu, 4 Dec 2025 20:52:26 +0300 Subject: [PATCH 20/20] update renewed 4 - added Pips.ChangePerSection * changes pip frame only for the last section --- src/Ext/Techno/Body.Visuals.cpp | 34 +++++++++++++++++++++++++++------ src/New/Type/BarTypeClass.cpp | 2 ++ src/New/Type/BarTypeClass.h | 2 ++ 3 files changed, 32 insertions(+), 6 deletions(-) diff --git a/src/Ext/Techno/Body.Visuals.cpp b/src/Ext/Techno/Body.Visuals.cpp index 17febfbe86..7df8553611 100644 --- a/src/Ext/Techno/Body.Visuals.cpp +++ b/src/Ext/Techno/Body.Visuals.cpp @@ -965,18 +965,14 @@ void TechnoExt::DrawBar(TechnoClass* pThis, BarTypeClass* barType, Point2D pLoca const Vector3D sectionFrames = barType->Pips_Frames; const int sectionAmount = barType->Pips_Amount; const int sectionEmptyFrame = barType->Pips_EmptyFrame; + const bool bySection = barType->Pips_ChangePerSection; const bool drawBackwards = barType->Pips_DrawBackwards; int sectionsToDraw = (int)round(sectionAmount * barPercentage); - int frameIdxa = sectionFrames.Z; int sign = drawBackwards ? 1 : -1; if(barType->InfoType == DisplayInfoType::Health) sectionsToDraw = sectionsToDraw == 0 ? 1 : sectionsToDraw; - if (barPercentage > conditionYellow) - frameIdxa = sectionFrames.X; - else if (barPercentage > conditionRed) - frameIdxa = sectionFrames.Y; pLocation += barType->Bar_Offset; Point2D boardPosition = pLocation + barType->PipBrd_Offset; @@ -1007,8 +1003,34 @@ void TechnoExt::DrawBar(TechnoClass* pThis, BarTypeClass* barType, Point2D pLoca position -= sectionOffset; } - for (int i = 0; i < sectionsToDraw; ++i) + if(bySection) + barPercentage = 1 - ((int)ceil(sectionAmount * barPercentage) - barPercentage * sectionAmount); + + int frameIdxa = sectionFrames.Z; + + if (barPercentage > conditionYellow) + frameIdxa = sectionFrames.X; + else if (barPercentage > conditionRed) + frameIdxa = sectionFrames.Y; + + if(!bySection) { + for (int i = 0; i < sectionsToDraw; ++i) + { + position -= {sign * sectionOffset.X, sign * sectionOffset.Y}; + DSurface::Temp->DrawSHP(FileSystem::PALETTE_PAL, barType->Pips_File.Get(), + frameIdxa, &position, pBounds, BlitterFlags::Centered | BlitterFlags::bf_400, 0, 0, ZGradient::Ground, 1000, 0, 0, 0, 0, 0); + } + } + else + { + for (int i = 0; i < (sectionsToDraw - 1); ++i) + { + position -= {sign * sectionOffset.X, sign * sectionOffset.Y}; + DSurface::Temp->DrawSHP(FileSystem::PALETTE_PAL, barType->Pips_File.Get(), + sectionFrames.X, &position, pBounds, BlitterFlags::Centered | BlitterFlags::bf_400, 0, 0, ZGradient::Ground, 1000, 0, 0, 0, 0, 0); + } + position -= {sign * sectionOffset.X, sign * sectionOffset.Y}; DSurface::Temp->DrawSHP(FileSystem::PALETTE_PAL, barType->Pips_File.Get(), frameIdxa, &position, pBounds, BlitterFlags::Centered | BlitterFlags::bf_400, 0, 0, ZGradient::Ground, 1000, 0, 0, 0, 0, 0); diff --git a/src/New/Type/BarTypeClass.cpp b/src/New/Type/BarTypeClass.cpp index deb0394e0b..59955ae569 100644 --- a/src/New/Type/BarTypeClass.cpp +++ b/src/New/Type/BarTypeClass.cpp @@ -35,6 +35,7 @@ void BarTypeClass::LoadFromINI(CCINIClass* pINI) this->Pips_Amount.Read(exINI, section, "Pips.Amount"); this->Pips_PositionDelta.Read(exINI, section, "Pips.PositionDelta"); this->Pips_DrawBackwards.Read(exINI, section, "Pips.DrawBackwards"); + this->Pips_ChangePerSection.Read(exINI, section, "Pips.ChangePerSection"); } @@ -60,6 +61,7 @@ void BarTypeClass::Serialize(T& Stm) .Process(this->Pips_Amount) .Process(this->Pips_PositionDelta) .Process(this->Pips_DrawBackwards) + .Process(this->Pips_ChangePerSection) ; } diff --git a/src/New/Type/BarTypeClass.h b/src/New/Type/BarTypeClass.h index 68c5ed5c0c..9c43b29df8 100644 --- a/src/New/Type/BarTypeClass.h +++ b/src/New/Type/BarTypeClass.h @@ -26,6 +26,7 @@ class BarTypeClass final : public Enumerable Valueable Pips_Amount; Valueable> Pips_PositionDelta; Valueable Pips_DrawBackwards; + Valueable Pips_ChangePerSection; BarTypeClass(const char* pTitle = NONE_STR) : Enumerable(pTitle) , InfoType { DisplayInfoType::Health } @@ -46,6 +47,7 @@ class BarTypeClass final : public Enumerable , Pips_Amount { 17 } , Pips_PositionDelta { { 2, 0 } } , Pips_DrawBackwards { false } + , Pips_ChangePerSection { false } { } void LoadFromINI(CCINIClass* pINI);