mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-01-26 07:34:45 +00:00
Merge pull request #1790 from blackwc/guihealthbarhud-flip
GuitHealthBarHud flip fill
This commit is contained in:
commit
00a4a21e3f
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue