Classes:BaseStatusBar

From ZDoom Wiki
Jump to navigation Jump to search
Note: This feature is for ZScript only.


BaseStatusBar is the base class that all standard HUDs inherit from. Despite the name, it handles drawing both of statusbar HUDs and fullscreen HUDs. It does not handle GZDoom's Alternate HUD, however (see AltHUD for creating altHUD replacements). This class can be used to create your own custom HUDs from entirely within ZScript.

The statusbar global variable contains a pointer to the current HUD. As such, it's possible to interact with the HUD from play scope by using an event handler with an InterfaceProcess override.

Constants

  • double XHAIRSHRINKSIZE = 1. / 18
  • double XHAIRPICKUPSIZE = 2 + XHAIRSHRINKSIZE
  • int POWERUPICONSIZE = 32

Fields

  • int RelTop - The height of the status bar in pixels. This is based off the resolution defined by HorizontalResolution and VerticalResolution and does not take GZDoom's status bar scaling into account.
  • int HorizontalResolution - Width of the virtual resolution in pixels. If 0 this is 320.
  • int VerticalResolution - Height of the virtual resolution in pixels. If 0 this is 200.
  • bool Centering - Unused
  • bool FixedOrigin - Unused
  • bool CompleteBorder - Controls how the background image is drawn when the view port is smaller than the window resolution. If set to true the image is drawn behind the status bar and not just around the edges.
  • double CrosshairSize - Scalar for the size of the player's crosshair. The CVar crosshairgrow must be true for this to scale.
  • double Displacement - The size difference (in pixels) between the scaled status bar and the unscaled status bar as a fraction of RelTop. The size difference is based off of HorizontalResolution and VerticalResolution. This value is scaled down by GZDoom's status bar scale.
  • Note: If hud_aspectscale is set to true GZDoom's status bar scale is multiplied by 1.2 for this calculation
  • PlayerInfo CPlayer - The PlayerInfo for the player currently being viewed through. Note that this can change if swapping player views in multiplayer.
  • bool ShowLog - Handles showing subtitles and log text (mainly used in Strife).
  • Vector2 defaultScale - The x and y scale for scaling a HorizontalResolution x VerticalResolution area to best fit the window resolution without any fractional steps.
  • int artiflashTick - Keeps track of drawing the flash sprite when using an item from the inventory bar (mainly used in Heretic and Hexen).
  • double itemFlashFade - Keeps track of the alpha of the flash when using an item (mainly used in Strife).
  • double Alpha - Controls the overall alpha of the HUD.
  • Vector2 drawOffset - X and y offsets for drawing HUD graphics. This is based off of HorizontalResolution and VerticalResolution and not the real window resolution. This is scaled by GZDoom's status bar scaling.
  • double drawClip[4] - Unused
  • bool fullscreenOffsets - If set to true, draws graphics based off the real window resolution instead of the virtual resolution defined by HorizontalResolution and VerticalResolution.

Methods

Virtual

See also this article for a description of what each virtual function does.

  • void Init()
  • void Tick()
  • void Draw(int state, double TicFrac)
  • void ScreenSizeChanged()
  • clearscope void ReceivedWeapon(Weapon weapn)
  • clearscope void SetMugShotState(String state_name, wait_till_done = false, reset = false)
  • clearscope void FlashItem(class<Inventory> itemtype)
  • void AttachToPlayer(PlayerInfo player)
  • void FlashCrosshair()
  • void NewGame()
  • void ShowPop(int popnum)
  • bool MustDrawLog(int state)
  • bool ProcessNotify(EPrintLevel printlevel, String outline)
  • void FlushNotify()
  • bool ProcessMidPrint(Font fnt, String msg, bool bold)
  • bool DrawChat(String txt)
  • int GetProtrusion(double scaleratio) const
  • void DrawMyPos()
  • void DrawAutomapHUD(double ticFrac)
  • void DrawPowerups()

Static

  • TextureID, bool GetInventoryIcon(Inventory item, int flags)
  • String FormatNumber(int number, int minsize = 0, int maxsize = 0, int format = 0, String prefix = "")
  • String GetGlobalACSString(int index)
  • String GetGlobalACSArrayString(int arrayno, int index)
  • int GetGlobalACSValue(int index)
  • int GetGlobalACSArrayValue(int arrayno, int index)

Non-static

  • void AttachMessage(HUDMessageBase msg, uint msgid = 0, int layer = HUDMSGLayer_Default)
  • HUDMessageBase DetachMessage(HUDMessageBase msg)
  • HUDMessageBase DetachMessageID(uint msgid)
  • void DetachAllMessages()
  • void SetSize(int height, int vwidth, int vheight, int hwidth = -1, int hheight = -1)
  • Vector2 GetHUDScale()
  • void BeginStatusBar(bool forceScaled = false, int resW = -1, int resH = -1, int rel = -1)
  • void BeginHUD(double Alpha = 1., bool forcescaled = false, int resW = -1, int resH = -1)
  • void UpdateScreenGeometry()
  • TextureID GetMugShot(int accuracy, int stateflags = MugShot.STANDARD, String default_face = "STF")
  • void DrawTexture(TextureID texture, Vector2 pos, int flags = 0, double Alpha = 1., Vector2 box = (-1, -1), Vector2 scale = (1, 1), ERenderStyle style = STYLE_Translucent, Color col = 0xffffffff, int translation = 0, double clipwidth = -1)
  • void DrawImage(String texture, Vector2 pos, int flags = 0, double Alpha = 1., Vector2 box = (-1, -1), Vector2 scale = (1, 1), ERenderStyle style = STYLE_Translucent, Color col = 0xffffffff, int translation = 0, double clipwidth = -1)
  • void DrawImageRotated(String texid, Vector2 pos, int flags, double angle, double alpha = 1, Vector2 scale = (1, 1), ERenderStyle style = STYLE_Translucent, Color col = 0xffffffff, int translation = 0)
  • void DrawInventoryIcon(Inventory item, Vector2 pos, int flags = 0, double alpha = 1.0, Vector2 boxsize = (-1, -1), Vector2 scale = (1.,1.))
  • void DrawString(HUDFont font, String string, Vector2 pos, int flags = 0, int translation = Font.CR_UNTRANSLATED, double Alpha = 1., int wrapwidth = -1, int linespacing = 4, Vector2 scale = (1, 1))
  • void DrawHexenArmor(int armortype, String image, Vector2 pos, int flags = 0, double alpha = 1.0, Vector2 boxsize = (-1, -1), Vector2 scale = (1.,1.))
  • void DrawShader(int which, Vector2 pos, Vector2 size, int flags = 0, double alpha = 1.)
  • Vector2, int AdjustPosition(Vector2 position, int flags, double width, double height)
  • void DrawGem(String chain, String gem, int displayvalue, int maxrange, Vector2 pos, int leftpadding, int rightpadding, int chainmod, int flags = 0)
  • void DrawBar(String ongfx, String offgfx, double curval, double maxval, Vector2 position, int border, int vertical, int flags = 0, double alpha 1.0)
  • void DrawInventoryBar(InventoryBarState parms, Vector2 position, int numfields, int flags = 0, double bgalpha = 1.)
  • double, double, double, double TransformRect(double x, double y, double w, double h, int flags = 0)
  • void Fill(Color col, double x, double y, double w, double h, int flags = 0)
  • double, double, double, double StatusbarToRealCoords(double x, double y = 0, double w = 0, double h = 0)
  • int GetTopOfStatusBar()
  • void SetClipRect(double x, double y, double w, double h, int flags = 0)
  • void ClearClipRect()
  • Inventory ValidateInvFirst(int numVisible) const
  • Ammo, Ammo, int, int GetCurrentAmmo() const
  • TextureID, Vector2 GetIcon(Inventory item, int flags, bool showdepleted = true)
  • String GetAmmoTag(bool secondary = false)
  • String GetWeaponTag()
  • String GetSelectedInventoryTag()
  • int GetArmorAmount()
  • int, int GetAmount(class<Inventory> item)
  • int GetMaxAmount(class<Inventory> item)
  • int GetArmorSavePercent()
  • int GetAirTime()
  • int GetSelectedInventoryAmount()
  • int GetKeyCount()
  • bool WeaponUsesAmmo(int ValidModes)
  • bool isInventoryBarVisible()
  • bool CheckAspectRatio(double min, double max)
  • bool CheckWeaponSelected(class<Weapon> weap, bool checksister = true)
  • bool CheckDisplayName(String displayname)
  • int CheckWeaponPiece(class<Weapon> weap, int piecenum)
  • int GetWeaponPieceMask(class<Weapon> weap)
  • bool WeaponUsesAmmoType(class<Ammo> ammotype)
  • bool CheckHealth(int Amount, bool percentage = false)
  • bool isInvulnerable()
  • bool CheckInventory(class<Inventory> item, int amount = 1)
  • protected void DoDrawAutomapHUD(int crdefault, int highlight)
  • int GetTranslation() const

Examples

Nuvolachalk.png Note: This article lists no examples. If you make use of this feature in your own project(s) or know of any basic examples that could be shared, please add them. This will make it easier to understand for future authors seeking assistance. Your contributions are greatly appreciated.