@@ -879,19 +879,21 @@ void ShieldClass::DrawShieldBar_Building(const int length, RectangleStruct* pBou
879
879
if (this ->HP <= 0 && this ->Type ->Pips_HideIfNoStrength )
880
880
return ;
881
881
882
- Point2D position = { 0 , 0 };
882
+ Point2D selectBracketPosition = TechnoExt::GetBuildingSelectBracketPosition (this ->Techno , BuildingSelectBracketPosition::Top);
883
+ selectBracketPosition.X -= 6 ;
884
+ selectBracketPosition.Y -= 3 ;
883
885
const int totalLength = DrawShieldBar_PipAmount (length);
884
- int frame = this ->DrawShieldBar_Pip (true );
886
+ const int frame = this ->DrawShieldBar_Pip (true );
885
887
886
888
if (totalLength > 0 )
887
889
{
888
890
for (int frameIdx = totalLength, deltaX = 0 , deltaY = 0 ;
889
891
frameIdx;
890
892
frameIdx--, deltaX += 4 , deltaY -= 2 )
891
893
{
892
- position = TechnoExt::GetBuildingSelectBracketPosition (Techno, BuildingSelectBracketPosition::Top) ;
893
- position.X -= deltaX + 6 ;
894
- position.Y -= deltaY + 3 ;
894
+ Point2D position = selectBracketPosition ;
895
+ position.X -= deltaX;
896
+ position.Y -= deltaY;
895
897
896
898
DSurface::Temp->DrawSHP (FileSystem::PALETTE_PAL, FileSystem::PIPS_SHP,
897
899
frame, &position, pBound, BlitterFlags (0x600 ), 0 , 0 , ZGradient::Ground, 1000 , 0 , 0 , 0 , 0 , 0 );
@@ -900,15 +902,15 @@ void ShieldClass::DrawShieldBar_Building(const int length, RectangleStruct* pBou
900
902
901
903
if (totalLength < length)
902
904
{
905
+ const int emptyFrame = this ->Type ->Pips_Building_Empty .Get (RulesExt::Global ()->Pips_Shield_Building_Empty .Get (0 ));
906
+
903
907
for (int frameIdx = length - totalLength, deltaX = 4 * totalLength, deltaY = -2 * totalLength;
904
908
frameIdx;
905
909
frameIdx--, deltaX += 4 , deltaY -= 2 )
906
910
{
907
- position = TechnoExt::GetBuildingSelectBracketPosition (Techno, BuildingSelectBracketPosition::Top);
908
- position.X -= deltaX + 6 ;
909
- position.Y -= deltaY + 3 ;
910
-
911
- const int emptyFrame = this ->Type ->Pips_Building_Empty .Get (RulesExt::Global ()->Pips_Shield_Building_Empty .Get (0 ));
911
+ Point2D position = selectBracketPosition;
912
+ position.X -= deltaX;
913
+ position.Y -= deltaY;
912
914
913
915
DSurface::Temp->DrawSHP (FileSystem::PALETTE_PAL, FileSystem::PIPS_SHP,
914
916
emptyFrame, &position, pBound, BlitterFlags (0x600 ), 0 , 0 , ZGradient::Ground, 1000 , 0 , 0 , 0 , 0 , 0 );
@@ -921,24 +923,27 @@ void ShieldClass::DrawShieldBar_Other(const int length, RectangleStruct* pBound)
921
923
if (this ->HP <= 0 && this ->Type ->Pips_HideIfNoStrength )
922
924
return ;
923
925
924
- auto position = TechnoExt::GetFootSelectBracketPosition (Techno, Anchor (HorizontalPosition::Left, VerticalPosition::Top));
926
+ auto position = TechnoExt::GetFootSelectBracketPosition (this -> Techno , Anchor (HorizontalPosition::Left, VerticalPosition::Top));
925
927
const auto pipBoard = this ->Type ->Pips_Background .Get (RulesExt::Global ()->Pips_Shield_Background .Get (FileSystem::PIPBRD_SHP));
926
- int frame;
928
+ int frame = pipBoard-> Frames > 2 ? 2 : 0 ;
927
929
928
930
position.X -= 1 ;
929
931
position.Y += this ->Techno ->GetTechnoType ()->PixelSelectionBracketDelta + this ->Type ->BracketDelta - 3 ;
930
932
931
- if (length == 8 )
932
- frame = pipBoard->Frames > 2 ? 3 : 1 ;
933
- else
934
- frame = pipBoard->Frames > 2 ? 2 : 0 ;
935
-
936
933
if (this ->Techno ->IsSelected )
937
934
{
938
- position.X += length + 1 + (length == 8 ? length + 1 : 0 );
935
+ int offset = length + 1 ;
936
+
937
+ if (length == 8 )
938
+ {
939
+ frame += 1 ;
940
+ offset += length + 1 ;
941
+ }
942
+
943
+ position.X += offset;
939
944
DSurface::Temp->DrawSHP (FileSystem::PALETTE_PAL, pipBoard,
940
945
frame, &position, pBound, BlitterFlags (0xE00 ), 0 , 0 , ZGradient::Ground, 1000 , 0 , 0 , 0 , 0 , 0 );
941
- position.X -= length + 1 + (length == 8 ? length + 1 : 0 ) ;
946
+ position.X -= offset ;
942
947
}
943
948
944
949
frame = this ->DrawShieldBar_Pip (false );
@@ -957,14 +962,9 @@ int ShieldClass::DrawShieldBar_Pip(const bool isBuilding) const
957
962
{
958
963
const int strength = this ->Type ->Strength .Get ();
959
964
const auto pipsShield = isBuilding ? this ->Type ->Pips_Building .Get () : this ->Type ->Pips .Get ();
960
- const auto pipsGlobal = isBuilding ? RulesExt::Global ()->Pips_Shield_Building .Get () : RulesExt::Global ()->Pips_Shield .Get ();
961
965
962
- CoordStruct shieldPip;
963
-
964
- if (pipsShield.X != -1 )
965
- shieldPip = pipsShield;
966
- else
967
- shieldPip = pipsGlobal;
966
+ const auto shieldPip = pipsShield.X != -1 ? pipsShield :
967
+ (isBuilding ? RulesExt::Global ()->Pips_Shield_Building .Get () : RulesExt::Global ()->Pips_Shield .Get ());
968
968
969
969
if (this ->HP > this ->Type ->GetConditionYellow () * strength && shieldPip.X != -1 )
970
970
return shieldPip.X ;
0 commit comments