![Razz :P](./images/smilies/icon_razz.gif)
And naturally it is harmless. Especially since we have to pick apart the stuff ourselves...
Moderator: GZDoom Developers
Code: Select all
override void Draw (int state, double TicFrac)
1) MAPINFO's gameinfo section - check the repo.ZZYZX wrote:How do I point the statusbar to a ZScript class?
Will it completely replace all statusbars or like SBARINFO did it (separate for fullscreen, separate for regular, and althud disables any custom statusbars)?
How do I make something draw over statusbar hudmessage-style that'd work with any statusbar even the internal ones? I made RenderOverlay for that, but then Graf said it's going to be in the statusbar.
If it's of any comfort, I'm holding off until it's actually done this time. I learned my lesson previously.Graf Zahl wrote:I'm not even done with the status bar and some people still use it... Be careful that stuff doesn't break, right now I do not care about breaking changes and if something isn't good it gets changed.
DTA_Clip...something.Nash wrote:
First!!!Compass written in ZScript as a custom status bar.
Just gotta wait for the clipping rectangle and I can dump my ACS for good. >8D
Code: Select all
class SpecialSbar : Element
{
override void OnCreate()
{
mRect = Rect.FromXYWH(0, 0, Screen.GetWidth(), Screen.GetHeight()); // these are coordinates in parent element's coordinates. for root element = screen coordinates
mScale = 1; // this is a float, change if you need to scale to some resolution, e.g. if you want to have virtual 1024x768, do mScale = double(Screen.GetHeight())/768.0;
// you can add other init stuff here
}
override void Draw()
{
Drawer d = GetDrawer();
// use Drawer methods here
}
}
Code: Select all
SpecialSbar sbd = new('SpecialSbar').Init();
Code: Select all
Can't call play function DrawFullScreenStuffCustom from ui context
Code: Select all
class CustomDoomStatusBar : DoomStatusBar
{
override void Draw (int state, double TicFrac)
{
BaseStatusBar.Draw (state, TicFrac);
//Super.Draw (state, TicFrac);
if (state == HUD_StatusBar)
{
BeginStatusBar(320, 200, 32);
DrawMainBar (TicFrac);
}
else if (state == HUD_Fullscreen)
{
BeginHUD(320, 200, 1., false);
DrawFullScreenStuffCustom ();
}
}
protected void DrawFullScreenStuffCustom ()
{
Vector2 iconbox = (40, 20);
// Draw health
let berserk = CPlayer.mo.FindInventory("PowerStrength");
DrawImage(berserk? "PSTRA0" : "MEDIA0", (20, -2));
DrawString(mHUDFont, FormatNumber(CPlayer.health, 3), (44, -20));
let armor = CPlayer.mo.FindInventory("BasicArmor");
if (armor != null)
{
DrawInventoryIcon(armor, (20, -22));
DrawString(mHUDFont, FormatNumber(armor.Amount, 3), (44, -40));
}
Inventory ammotype1, ammotype2;
[ammotype1, ammotype2] = GetCurrentAmmo();
int invY = -20;
if (ammotype1 != null)
{
DrawInventoryIcon(ammotype1, (-14, -4));
DrawString(mHUDFont, FormatNumber(ammotype1.Amount, 3), (-30, -20), DI_TEXT_ALIGN_RIGHT);
invY -= 20;
}
if (ammotype2 != null && ammotype2 != ammotype1)
{
DrawInventoryIcon(ammotype2, (-14, invY + 17));
DrawString(mHUDFont, FormatNumber(ammotype2.Amount, 3), (-30, invY), DI_TEXT_ALIGN_RIGHT);
invY -= 20;
}
if (CPlayer.inventorytics == 0 && CPlayer.mo.InvSel != null && !level.NoInventoryBar)
{
DrawInventoryIcon(CPlayer.mo.InvSel, (-14, invY + 17));
DrawString(mHUDFont, FormatNumber(CPlayer.mo.InvSel.Amount, 3), (-30, invY), DI_TEXT_ALIGN_RIGHT);
}
if (deathmatch)
{
DrawString(mHUDFont, FormatNumber(CPlayer.FragCount, 3), (-3, 1), DI_TEXT_ALIGN_RIGHT, Font.CR_GOLD);
}
// Draw the keys. This does not use a special draw function like SBARINFO because the specifics will be different for each mod
// so it's easier to copy or reimplement the following piece of code instead of trying to write a complicated all-encompassing solution.
Vector2 keypos = (-10, 2);
int rowc = 0;
double roww = 0;
for(let i = CPlayer.mo.Inv; i != null; i = i.Inv)
{
if (i is "Key" && i.Icon.IsValid())
{
DrawTexture(i.Icon, keypos, DI_SCREEN_RIGHT_TOP|DI_ITEM_LEFT_TOP);
Vector2 size = TexMan.GetScaledSize(i.Icon);
keypos.Y += size.Y + 2;
roww = max(roww, size.X);
if (++rowc == 3)
{
keypos.Y = 2;
keypos.X -= roww + 2;
roww = 0;
rowc = 0;
}
}
}
if (CPlayer.inventorytics != 0 && !level.NoInventoryBar)
{
DrawInventoryBar(diparms, (0, 0), 7, DI_SCREEN_CENTER_BOTTOM, HX_SHADOW);
}
}
}
With that done, I get this:ZZYZX wrote:Anyway, this particular issue can be fixed by explicitly marking your draw function as ui (e.g. protected ui void DrawFullScreenStuffCustom).
Code: Select all
Script error, "sbar_testing.pk3:zscript.txt" line 20:
Unexpected identifier
Expecting ';' or ','