diff --git a/Phobos.vcxproj b/Phobos.vcxproj index 2def0db9a8..316b4c1a5b 100644 --- a/Phobos.vcxproj +++ b/Phobos.vcxproj @@ -107,6 +107,7 @@ + @@ -269,6 +270,7 @@ + diff --git a/YRpp b/YRpp index 5af96790ce..ff414079f5 160000 --- a/YRpp +++ b/YRpp @@ -1 +1 @@ -Subproject commit 5af96790ce73e4ea068a390c60c124dccbc220e1 +Subproject commit ff414079f5ac770d666547f67ad7709b990b5ab3 diff --git a/src/Ext/Rules/Body.cpp b/src/Ext/Rules/Body.cpp index 60b9ec37b0..ccf63f940a 100644 --- a/src/Ext/Rules/Body.cpp +++ b/src/Ext/Rules/Body.cpp @@ -15,6 +15,7 @@ #include #include #include +#include #include std::unique_ptr RulesExt::Data = nullptr; @@ -44,6 +45,7 @@ void RulesExt::LoadBeforeTypeData(RulesClass* pThis, CCINIClass* pINI) AttachEffectTypeClass::LoadFromINIList(pINI); BannerTypeClass::LoadFromINIList(pINI); InsigniaTypeClass::LoadFromINIList(pINI); + BarTypeClass::LoadFromINIList(pINI); Data->LoadBeforeTypeData(pThis, pINI); } @@ -232,6 +234,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->JumpjetClimbPredictHeight.Read(exINI, GameStrings::General, "JumpjetClimbPredictHeight"); this->JumpjetClimbWithoutCutOut.Read(exINI, GameStrings::General, "JumpjetClimbWithoutCutOut"); @@ -527,6 +533,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 1a0e4bb8e9..f377aa3340 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 { @@ -156,6 +157,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; @@ -284,7 +289,7 @@ class RulesExt Valueable AIAirTargetingFix; Valueable SortCameoByName; - + ExtData(RulesClass* OwnerObject) : Extension(OwnerObject) , Storage_TiberiumIndex { -1 } , HarvesterDumpAmount { 0.0f } @@ -410,6 +415,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 9547710f04..7df8553611 100644 --- a/src/Ext/Techno/Body.Visuals.cpp +++ b/src/Ext/Techno/Body.Visuals.cpp @@ -866,6 +866,181 @@ 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 = pBarType->Bar_ConditionYellow; + double pConditionRed = pBarType->Bar_ConditionRed; + + switch (pBarType->InfoType) + { + case DisplayInfoType::Health: + { + pConditionYellow = pConditionYellow > 0 ? pConditionYellow : RulesClass::Instance->ConditionYellow; + pConditionRed = pConditionRed > 0 ? 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 = 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: + { + break; + } + } + + int value = -1; + int maxValue = 0; + + GetValuesForDisplay(pThis, pType, pBarType->InfoType, value, maxValue, 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); + 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 bySection = barType->Pips_ChangePerSection; + const bool drawBackwards = barType->Pips_DrawBackwards; + int sectionsToDraw = (int)round(sectionAmount * barPercentage); + int sign = drawBackwards ? 1 : -1; + + if(barType->InfoType == DisplayInfoType::Health) + sectionsToDraw = sectionsToDraw == 0 ? 1 : sectionsToDraw; + + + pLocation += barType->Bar_Offset; + Point2D boardPosition = pLocation + barType->PipBrd_Offset; + + 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; + 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 -= {sign * sectionOffset.X, sign * sectionOffset.Y}; + 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); + } + + position = pLocation; + position += {sign * (int)round(sectionAmount * sectionOffset.X / 2), sign * (int)round(sectionAmount * sectionOffset.Y / 2)}; + } + + if (drawBackwards) + { + for (int i = 0; i < (sectionAmount - sectionsToDraw); ++i) + position -= sectionOffset; + } + + 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); + } + + 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); +} + void TechnoExt::ShowPromoteAnim(TechnoClass* pThis) { auto const pTypeExt = TechnoExt::ExtMap.Find(pThis)->TypeExtData; diff --git a/src/Ext/Techno/Body.h b/src/Ext/Techno/Body.h index d63aae16bc..bb0dbbe9d7 100644 --- a/src/Ext/Techno/Body.h +++ b/src/Ext/Techno/Body.h @@ -294,6 +294,8 @@ 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 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 b15f9f64bd..7a9bea5541 100644 --- a/src/Ext/Techno/Hooks.Pips.cpp +++ b/src/Ext/Techno/Hooks.Pips.cpp @@ -38,7 +38,7 @@ DEFINE_HOOK(0x6F5E37, TechnoClass_DrawExtras_DrawHealthBar, 0x6) return 0; } -DEFINE_HOOK(0x6F64A9, TechnoClass_DrawHealthBar_Hide, 0x5) +/*DEFINE_HOOK(0x6F64A9, TechnoClass_DrawHealthBar_Hide, 0x5) //replaced with new bars { enum { SkipDraw = 0x6F6AB6 }; @@ -50,7 +50,7 @@ DEFINE_HOOK(0x6F64A9, TechnoClass_DrawHealthBar_Hide, 0x5) return SkipDraw; return 0; -} +}*/ DEFINE_HOOK(0x6F6637, TechnoClass_DrawHealthBar_HideBuildingsPips, 0x5) { @@ -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); } @@ -93,9 +93,12 @@ DEFINE_HOOK(0x6F65D1, TechnoClass_DrawHealthBar_Buildings, 0x6) if (const auto pShieldData = pExt->Shield.get()) { if (pShieldData->IsAvailable() && !pShieldData->IsBrokenAndNonRespawning()) + { pShieldData->DrawShieldBar_Building(length, pBound); + } } + TechnoExt::ProcessBars(pThis, *pLocation, pBound); TechnoExt::ProcessDigitalDisplays(pThis); return 0; @@ -121,11 +124,12 @@ DEFINE_HOOK(0x6F683C, TechnoClass_DrawHealthBar_Units, 0x7) { if (pShieldData->IsAvailable() && !pShieldData->IsBrokenAndNonRespawning()) { - const int length = pThis->WhatAmI() == AbstractType::Infantry ? 8 : 17; + const int length = pThis->WhatAmI() == AbstractType::Infantry ? Unsorted::HealthBarSectionsInfantry : Unsorted::HealthBarSectionsOther; pShieldData->DrawShieldBar_Other(length, pBound); } } + TechnoExt::ProcessBars(pThis, *pLocation, pBound); TechnoExt::ProcessDigitalDisplays(pThis); if (pExt->TypeExtData->HealthBar_HidePips) diff --git a/src/Ext/TechnoType/Body.cpp b/src/Ext/TechnoType/Body.cpp index e64525096e..cf121230dc 100644 --- a/src/Ext/TechnoType/Body.cpp +++ b/src/Ext/TechnoType/Body.cpp @@ -1010,7 +1010,8 @@ void TechnoTypeExt::ExtData::LoadFromINIFile(CCINIClass* const pINI) this->AttackMove_PursuitTarget.Read(exINI, pSection, "AttackMove.PursuitTarget"); this->InfantryAutoDeploy.Read(exINI, pSection, "InfantryAutoDeploy"); - + this->BarTypes.Read(exINI, pSection, "BarTypes"); + // Ares 0.2 this->RadarJamRadius.Read(exINI, pSection, "RadarJamRadius"); @@ -1668,6 +1669,8 @@ void TechnoTypeExt::ExtData::Serialize(T& Stm) .Process(this->InfantryAutoDeploy) .Process(this->TurretResponse) + + .Process(this->BarTypes) ; } void TechnoTypeExt::ExtData::LoadFromStream(PhobosStreamReader& Stm) diff --git a/src/Ext/TechnoType/Body.h b/src/Ext/TechnoType/Body.h index 54db8f831a..4749c3f9d4 100644 --- a/src/Ext/TechnoType/Body.h +++ b/src/Ext/TechnoType/Body.h @@ -15,6 +15,7 @@ #include #include #include +#include class Matrix3D; class ParticleSystemTypeClass; @@ -360,6 +361,7 @@ class TechnoTypeExt ValueableVector Promote_VeteranAnimation; ValueableVector Promote_EliteAnimation; + ValueableVector BarTypes; Nullable RadarInvisibleToHouse; @@ -826,6 +828,8 @@ class TechnoTypeExt , InfantryAutoDeploy {} , TurretResponse {} + + , BarTypes { } { } virtual ~ExtData() = default; diff --git a/src/New/Entity/ShieldClass.cpp b/src/New/Entity/ShieldClass.cpp index 48ceb6a369..fd0000ca90 100644 --- a/src/New/Entity/ShieldClass.cpp +++ b/src/New/Entity/ShieldClass.cpp @@ -994,7 +994,7 @@ void ShieldClass::DrawShieldBar_Building(const int length, RectangleStruct* pBou position.Y -= deltaY; 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); } } @@ -1011,7 +1011,7 @@ void ShieldClass::DrawShieldBar_Building(const int length, RectangleStruct* pBou position.Y -= deltaY; 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); } } } @@ -1040,7 +1040,7 @@ void ShieldClass::DrawShieldBar_Other(const int length, RectangleStruct* pBound) position.X += offset; 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 -= offset; } @@ -1052,7 +1052,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); } } diff --git a/src/New/Type/BarTypeClass.cpp b/src/New/Type/BarTypeClass.cpp new file mode 100644 index 0000000000..59955ae569 --- /dev/null +++ b/src/New/Type/BarTypeClass.cpp @@ -0,0 +1,76 @@ +#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->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"); + 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->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"); + this->Pips_ChangePerSection.Read(exINI, section, "Pips.ChangePerSection"); + +} + +template +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) + .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->Pips_File) + .Process(this->Pips_Frames) + .Process(this->Pips_EmptyFrame) + .Process(this->Pips_Amount) + .Process(this->Pips_PositionDelta) + .Process(this->Pips_DrawBackwards) + .Process(this->Pips_ChangePerSection) + ; +} + +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..9c43b29df8 --- /dev/null +++ b/src/New/Type/BarTypeClass.h @@ -0,0 +1,60 @@ +#pragma once +#include +#include +#include +#include +#include + +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; + Nullable PipBrd_Foreground_File; + Valueable PipBrd_Foreground_ShowWhenNotSelected; + Nullable PipBrd_Foreground_Translucency; + Valueable> PipBrd_Offset; + Valueable> Bar_Offset; + Valueable Pips_File; + Valueable> Pips_Frames; + Valueable Pips_EmptyFrame; + Valueable Pips_Amount; + Valueable> Pips_PositionDelta; + Valueable Pips_DrawBackwards; + Valueable Pips_ChangePerSection; + + BarTypeClass(const char* pTitle = NONE_STR) : Enumerable(pTitle) + , InfoType { DisplayInfoType::Health } + , InfoIndex { 0 } + , Bar_ConditionYellow { 0.66 } + , Bar_ConditionRed { 0.33 } + , 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 } } + , Pips_File { FileSystem::PIPS_SHP } + , Pips_Frames { { 16, 17, 18 } } + , Pips_EmptyFrame { -1 } + , Pips_Amount { 17 } + , Pips_PositionDelta { { 2, 0 } } + , Pips_DrawBackwards { false } + , Pips_ChangePerSection { false } + { } + + 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 ac02d779bf..0d6f6ca1f5 100644 --- a/src/Phobos.Ext.cpp +++ b/src/Phobos.Ext.cpp @@ -39,6 +39,7 @@ #include #include +#include #include @@ -242,7 +243,8 @@ using PhobosTypeRegistry = TypeRegistry < AttachEffectTypeClass, AttachEffectClass, NewSWType, - SelectBoxTypeClass + SelectBoxTypeClass, + BarTypeClass // other classes > ;