Moderator: GZDoom Developers
void BeginStatusBar(int resW, int resH, int relTop, bool forceScaled);
void BeginHUD(int resW, int resH, double Alpha, bool forceScaled = false);
height 0;
CompleteBorder True;
Resolution 1024,768;
InterpolateHealth false, 20;
InterpolateArmor false, 20;
//================================================================================================
//================================================================================================
// This version HAS the weapon bar and ammo counter
//================================================================================================
//================================================================================================
statusbar Normal, forcescaled
{
// Powerups
// Go first because otherwise they obscure HUD elements
inInventory PowerD4QuadDamage { drawimage "Shade2Ma", -171, 0; }
inInventory PowerD4Regen { drawimage "Shade2Cy", -171, 0; }
inInventory PowerD4Haste { drawimage "Shade2Ye", -171, 0; }
inInventory PowerD4Money { drawimage "Shade2Gr", -171, 0; }
// UAC Doomguy collectible uses
InInventory DollUses,1
{ drawimage "Ddoll", 1060,727; }
InInventory DollUses,2
{ drawimage "Ddoll", 1030,727; }
InInventory DollUses,3
{ drawimage "Ddoll", 1000,727; }
InInventory DollUses,4
{ drawimage "Ddoll", 970,727; }
InInventory DollUses,5
{ drawimage "Ddoll", 940,727; }
InInventory DollUses,6
{ drawimage "Ddoll", 910,727; }
InInventory DollUses,7
{ drawimage "Ddoll", 880,727; }
InInventory DollUses,8
{ drawimage "Ddoll", 850,727; }
InInventory DollUses,9
{ drawimage "Ddoll", 820,727; }
// The Usual
drawimage "BODYBAR0", -69,669;
// ...
}
Class Doom4StatusBar : BaseStatusBar
{
DynamicValueInterpolator mHealthInterpolator;
DynamicValueInterpolator mHealthInterpolator2;
HUDFont mHUDFont;
HUDFont mIndexFont;
HUDFont mBigFont;
InventoryBarState diparms;
InventoryBarState diparms_sbar;
override void Init()
{
Super.Init();
SetSize(0, 1024, 768);
CompleteBorder = true;
// Create the font used for the fullscreen HUD
Font fnt = "HUDFONT_DOOM";
mHUDFont = HUDFont.Create(fnt, fnt.GetCharWidth("0") + 1, true, 1, 1);
fnt = "INDEXFONT_DOOM";
mIndexFont = HUDFont.Create(fnt, fnt.GetCharWidth("0"), true);
fnt = "BIGFONT";
mBigFont = HUDFont.Create(fnt, fnt.GetCharWidth("0"), true, 2, 2);
diparms = InventoryBarState.Create(mIndexFont);
//diparms_sbar = InventoryBarState.CreateNoBox(mIndexFont, boxsize:(31, 31), arrowoffs:(0,-10));
mHealthInterpolator = DynamicValueInterpolator.Create(0, 0.25, 1, 8);
mHealthInterpolator2 = DynamicValueInterpolator.Create(0, 0.25, 1, 6); // the chain uses a maximum of 6, not 8.
}
override void NewGame ()
{
Super.NewGame();
mHealthInterpolator.Reset (0);
mHealthInterpolator2.Reset (0);
}
override void Tick()
{
Super.Tick();
mHealthInterpolator.Update(CPlayer.health);
}
override void Draw (int state, double TicFrac)
{
Super.Draw (state, TicFrac);
if (state == HUD_StatusBar)
{
BeginStatusBar(true);
DrawMainBar (TicFrac);
}
else if (state == HUD_Fullscreen)
{
BeginHUD(1.0, true);
DrawFullScreenStuff();
}
}
protected void DrawMainBar (double TicFrac)
{
}
protected void DrawFullScreenStuff ()
{
int imageAlignment = 0;
if (GetAmountOnly("PowerD4QuadDamage")) DrawImage("Shade2Ma", (-171, 0), imageAlignment);
if (GetAmountOnly("PowerD4Regen")) DrawImage("Shade2Cy", (-171, 0), imageAlignment);
if (GetAmountOnly("PowerD4Haste")) DrawImage("Shade2Ye", (-171, 0), imageAlignment);
if (GetAmountOnly("PowerD4Money")) DrawImage("Shade2Gr", (-171, 0), imageAlignment);
/* For comparison's sake.
inInventory PowerD4QuadDamage { drawimage "Shade2Ma", -171, 0; }
inInventory PowerD4Regen { drawimage "Shade2Cy", -171, 0; }
inInventory PowerD4Haste { drawimage "Shade2Ye", -171, 0; }
inInventory PowerD4Money { drawimage "Shade2Gr", -171, 0; }
*/
int DoomDollMax, DoomDollCount;
[DoomDollCount, DoomDollMax] = GetAmount("DollUses");
DoomDollCount = Min(DoomDollCount, DoomDollMax);
if (DoomDollCount > 0)
{
for (int i = 0; i < DoomDollCount; i++)
{
int DollX = 1060 - (30 * i);
DrawImage("Ddoll", (DollX, 727), imageAlignment);
}
}
DrawImage ("BODYBAR0", (-69, 669), imageAlignment);
/* UAC Doomguy collectible uses
InInventory DollUses,1
{ drawimage "Ddoll", 1060,727; }
InInventory DollUses,2
{ drawimage "Ddoll", 1030,727; }
InInventory DollUses,3
{ drawimage "Ddoll", 1000,727; }
InInventory DollUses,4
{ drawimage "Ddoll", 970,727; }
InInventory DollUses,5
{ drawimage "Ddoll", 940,727; }
InInventory DollUses,6
{ drawimage "Ddoll", 910,727; }
InInventory DollUses,7
{ drawimage "Ddoll", 880,727; }
InInventory DollUses,8
{ drawimage "Ddoll", 850,727; }
InInventory DollUses,9
{ drawimage "Ddoll", 820,727; }
*/
}
}
extend class Doom4StatusBar
{
int GetAmountOnly(class<Inventory> item)
{
let it = CPlayer.mo.FindInventory(item);
return (it ? it.Amount : 0);
}
}
if (state == HUD_StatusBar)
{
BeginStatusBar(true);
DrawMainBar (TicFrac);
}
else if (state == HUD_Fullscreen)
{
BeginHUD(1.0, true);
DrawFullScreenStuff();
}
Graf Zahl wrote:removed alpha parameter from BaseStatusBar.DrawBar because this cannot be used with this function.
SetClipRect(0, 1080 - 128, 64, 64);
DrawImage("STARTAN2", (0, 1080), DI_ITEM_LEFT_BOTTOM);
Major Cooke wrote:I take it that's planned? It would be highly appreciated.
//Custom version of DrawBar that allows drawing with alpha - mostly copy/paste from original function, modified to allow alpha and scaling
void DrawBarEx(String ongfx, String offgfx, double curval, double maxval, Vector2 position, int border, int vertical, int flags = 0, double alpha = 1., double scale = 1.)
{
let ontex = TexMan.CheckForTexture(ongfx, TexMan.TYPE_MiscPatch);
if (!ontex.IsValid()) return;
let offtex = TexMan.CheckForTexture(offgfx, TexMan.TYPE_MiscPatch);
Vector2 texsize = TexMan.GetScaledSize(ontex);
texsize.x *= scale;
texsize.y *= scale;
[position, flags] = AdjustPosition(position, flags, texsize.X, texsize.Y);
double value = (maxval != 0) ? clamp(curval / maxval, 0, 1) : 0;
if(border != 0) value = 1. - value; //invert since the new drawing method requires drawing the bg on the fg.
// {cx, cb, cr, cy}
double Clip[4];
Clip[0] = Clip[1] = Clip[2] = Clip[3] = 0;
bool horizontal = !(vertical & SHADER_VERT);
bool reverse = !!(vertical & SHADER_REVERSE);
double sizeOfImage = (horizontal ? texsize.X - border*2 : texsize.Y - border*2);
Clip[(!horizontal) | ((!reverse)<<1)] = sizeOfImage - sizeOfImage * value;
// preserve the active clipping rectangle
int cx, cy, cw, ch;
[cx, cy, cw, ch] = screen.GetClipRect();
if(border != 0)
{
for(int i = 0; i < 4; i++) Clip[i] += border;
//Draw the whole foreground
DrawTexture(ontex, position, flags | DI_ITEM_LEFT_TOP, alpha, scale: (scale, scale));
SetClipRect(position.X + Clip[0], position.Y + Clip[1], texsize.X - Clip[0] - Clip[2], texsize.Y - Clip[1] - Clip[3], flags);
}
if (offtex.IsValid()) { DrawTexture(offtex, position, flags | DI_ITEM_LEFT_TOP, alpha, scale: (scale, scale)); }
if (border == 0)
{
SetClipRect(position.X + Clip[0], position.Y + Clip[1], texsize.X - Clip[0] - Clip[2], texsize.Y - Clip[1] - Clip[3], flags);
DrawTexture(ontex, position, flags | DI_ITEM_LEFT_TOP, alpha, scale: (scale, scale));
}
// restore the previous clipping rectangle
screen.SetClipRect(cx, cy, cw, ch);
}
Nash wrote:A bug maybe?
Nash wrote:A bug maybe?
Users browsing this forum: No registered users and 0 guests