mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-24 13:01:47 +00:00
- reimplemented the health bar for Strife's status bar.
This commit is contained in:
parent
4417afd548
commit
4c51a4fc59
4 changed files with 38 additions and 11 deletions
|
@ -1212,7 +1212,7 @@ public:
|
|||
{
|
||||
if (forceWidth < 0) dx -= (texture->GetScaledWidthDouble()/2.0)-texture->GetScaledLeftOffsetDouble();
|
||||
else dx -= forceWidth*(0.5-(texture->GetScaledLeftOffsetDouble()/texture->GetScaledWidthDouble()));
|
||||
//Unoptimalized formula is dx -= forceWidth/2.0-(texture->GetScaledLeftOffsetDouble()*forceWidth/texture->GetScaledWidthDouble());
|
||||
//Unoptimalized ^^formula is dx -= forceWidth/2.0-(texture->GetScaledLeftOffsetDouble()*forceWidth/texture->GetScaledWidthDouble());
|
||||
|
||||
if (forceHeight < 0) dy -= (texture->GetScaledHeightDouble()/2.0)-texture->GetScaledTopOffsetDouble();
|
||||
else dy -= forceHeight*(0.5-(texture->GetScaledTopOffsetDouble()/texture->GetScaledHeightDouble()));
|
||||
|
|
|
@ -796,6 +796,23 @@ void DCanvas::VirtualToRealCoords(double &x, double &y, double &w, double &h,
|
|||
}
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION(_Screen, VirtualToRealCoords)
|
||||
{
|
||||
PARAM_PROLOGUE;
|
||||
PARAM_FLOAT(x);
|
||||
PARAM_FLOAT(y);
|
||||
PARAM_FLOAT(w);
|
||||
PARAM_FLOAT(h);
|
||||
PARAM_FLOAT(vw);
|
||||
PARAM_FLOAT(vh);
|
||||
PARAM_BOOL_DEF(vbottom);
|
||||
PARAM_BOOL_DEF(handleaspect);
|
||||
screen->VirtualToRealCoords(x, y, w, h, vw, vh, vbottom, handleaspect);
|
||||
if (numret >= 1) ret[0].SetVector2(DVector2(x, y));
|
||||
if (numret >= 2) ret[1].SetVector2(DVector2(w, h));
|
||||
return MIN(numret, 2);
|
||||
}
|
||||
|
||||
void DCanvas::VirtualToRealCoordsFixed(fixed_t &x, fixed_t &y, fixed_t &w, fixed_t &h,
|
||||
int vwidth, int vheight, bool vbottom, bool handleaspect) const
|
||||
{
|
||||
|
|
|
@ -164,6 +164,7 @@ struct Screen native
|
|||
native static vararg void DrawChar(Font font, int normalcolor, double x, double y, int character, ...);
|
||||
native static vararg void DrawText(Font font, int normalcolor, double x, double y, String text, ...);
|
||||
native static void DrawFrame(int x, int y, int w, int h);
|
||||
native static Vector2, Vector2 VirtualToRealCoords(Vector2 pos, Vector2 size, Vector2 vsize, bool vbottom=false, bool handleaspect=true);
|
||||
}
|
||||
|
||||
struct Font native
|
||||
|
|
|
@ -229,10 +229,19 @@ class StrifeStatusBar : BaseStatusBar
|
|||
ItemFlash = 0.75;
|
||||
}
|
||||
|
||||
private void FillBar(int x, int y, int start, int stopp, Color color1, Color color2)
|
||||
private void FillBar(double x, double y, double start, double stopp, Color color1, Color color2)
|
||||
{
|
||||
// right now there is no function to draw this.
|
||||
// The old code used a crude texture hack to work arounf this omission.
|
||||
Vector2 virt = Scaled? (320., 200.) : (screen.GetWidth(), screen.GetHeight());
|
||||
Vector2 pos, sizev;
|
||||
|
||||
start *=2;
|
||||
stopp *=2;
|
||||
|
||||
[pos, sizev] = screen.VirtualToRealCoords((ST_X + x + start, ST_Y + y), (stopp - start, 1), virt, true, Scaled);
|
||||
screen.Dim(color1, 1.0, pos.X + 0.5, pos.Y + 0.5, sizev.X + 0.5, sizev.Y + 0.5);
|
||||
|
||||
[pos, sizev] = screen.VirtualToRealCoords((ST_X + x + start, ST_Y + y + 1), (stopp - start, 1), virt, true, Scaled);
|
||||
screen.Dim(color2, 1.0, pos.X + 0.5, pos.Y + 0.5, sizev.X + 0.5, sizev.Y + 0.5);
|
||||
}
|
||||
|
||||
protected void DrawHealthBar(int health, int x, int y)
|
||||
|
@ -251,7 +260,7 @@ class StrifeStatusBar : BaseStatusBar
|
|||
|
||||
if (health == 999)
|
||||
{
|
||||
FillBar (x, y, 0, 200, gold1, gold2);
|
||||
FillBar (x, y, 0, 100, gold1, gold2);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -259,23 +268,23 @@ class StrifeStatusBar : BaseStatusBar
|
|||
{
|
||||
if (health <= 10)
|
||||
{
|
||||
FillBar (x, y, 0, health*2, red1, red2);
|
||||
FillBar (x, y, 0, health, red1, red2);
|
||||
}
|
||||
else if (health <= 20)
|
||||
{
|
||||
FillBar (x, y, 0, health*2, gold1, gold2);
|
||||
FillBar (x, y, 0, health, gold1, gold2);
|
||||
}
|
||||
else
|
||||
{
|
||||
FillBar (x, y, 0, health, green1, green2);
|
||||
}
|
||||
FillBar (x, y, health, 200, 0, 0);
|
||||
//FillBar (x, y, health, 100, 0, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
int stopp = 100 - (health - 100);
|
||||
FillBar (x, y, 0, stopp*2, green1, green2);
|
||||
FillBar (x, y, stopp*2, 200, blue1, blue2);
|
||||
int stopp = 200 - health;
|
||||
FillBar (x, y, 0, stopp, green1, green2);
|
||||
FillBar (x, y, stopp, 100, blue1, blue2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue