Browse Source

Merge pull request #1790 from blackwc/guihealthbarhud-flip

GuitHealthBarHud flip fill
Areloch 8 năm trước cách đây
mục cha
commit
00a4a21e3f
1 tập tin đã thay đổi với 14 bổ sung1 xóa
  1. 14 1
      Engine/source/T3D/fps/guiHealthBarHud.cpp

+ 14 - 1
Engine/source/T3D/fps/guiHealthBarHud.cpp

@@ -43,6 +43,7 @@ class GuiHealthBarHud : public GuiControl
    bool     mShowFrame;
    bool     mShowFill;
    bool     mDisplayEnergy;
+   bool     mFlip;
 
    ColorF   mFillColor;
    ColorF   mFrameColor;
@@ -105,6 +106,8 @@ GuiHealthBarHud::GuiHealthBarHud()
    mPulseRate = 0;
    mPulseThreshold = 0.3f;
    mValue = 0.2f;
+
+   mFlip = false;
 }
 
 void GuiHealthBarHud::initPersistFields()
@@ -124,6 +127,7 @@ void GuiHealthBarHud::initPersistFields()
    addField( "showFill", TypeBool, Offset( mShowFill, GuiHealthBarHud ), "If true, we draw the background color of the control." );
    addField( "showFrame", TypeBool, Offset( mShowFrame, GuiHealthBarHud ), "If true, we draw the frame of the control." );
    addField( "displayEnergy", TypeBool, Offset( mDisplayEnergy, GuiHealthBarHud ), "If true, display the energy value rather than the damage value." );
+   addField(  "flip", TypeBool, Offset( mFlip, GuiHealthBarHud), "If true, will fill bar in opposite direction.");
    endGroup("Misc");
 
    Parent::initPersistFields();
@@ -176,12 +180,21 @@ void GuiHealthBarHud::onRender(Point2I offset, const RectI &updateRect)
    // Render damage fill %
    RectI rect(updateRect);
    if(getWidth() > getHeight())
+   {
       rect.extent.x = (S32)(rect.extent.x * mValue);
+
+      if(mFlip)
+         rect.point.x = (S32)(updateRect.point.x + (updateRect.extent.x - rect.extent.x));
+   }
    else
    {
       S32 bottomY = rect.point.y + rect.extent.y;
       rect.extent.y = (S32)(rect.extent.y * mValue);
-      rect.point.y = bottomY - rect.extent.y;
+
+      if(mFlip)
+         rect.extent.y = (S32)(updateRect.extent.y - (updateRect.extent.y - rect.extent.y));
+      else
+         rect.point.y = bottomY - rect.extent.y;
    }
    GFX->getDrawUtil()->drawRectFill(rect, mDamageFillColor);