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 use BaseStatusBar drawing functions from an event handler's RenderOverlay()/RenderUnderlay() events, and 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.

Static

Non-static

Returns the scale of the HUD relative to the current resolution.
  • void BeginStatusBar(bool forceScaled = false, int resW = -1, int resH = -1, int rel = -1)
Creates a virtual canvas for the HUD with the provided size that covers the designated area on the screen (usually used by statusbar-styled HUDs).
  • void BeginHUD(double Alpha = 1., bool forcescaled = false, int resW = -1, int resH = -1)
Creates a virtual canvas for the HUD with the provided size that covers the whole screen (used by fullscreen HUDs).
  • 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)
Draws a graphic on the HUD. Takes a TextureID.
  • 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)
Draws a graphic on the HUD. Takes the name of the image (or full path to the image file).
  • 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)
Draws a graphic that can be rotated.
  • void DrawInventoryIcon(Inventory item, Vector2 pos, int flags = 0, double alpha = 1.0, Vector2 boxsize = (-1, -1), Vector2 scale = (1.,1.))
Draws the Icon of the given Inventory item.
  • 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))
Draws a text string using the given HUDFont.
  • void DrawHexenArmor(int armortype, String image, Vector2 pos, int flags = 0, double alpha = 1.0, Vector2 boxsize = (-1, -1), Vector2 scale = (1.,1.))
Draws Hexen-specific armor.
  • 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)
Draws a horizontal bar.
  • void DrawInventoryBar(InventoryBarState parms, Vector2 position, int numfields, int flags = 0, double bgalpha = 1.)
Draws an inventory bar, using the data pulled from the InventoryBarState class.
  • 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)
Fills a rectangle of the given width/height at the given area with a solid color.
Creates a rectangular mask area. Everything drawn afterwards will only be drawn within that area.
Clears the previously defined clipping rectangle.
Checks that the player has a valid Inventory item selected in their inventory bar.
Gets the ammo pointers and and ammo amounts for the player's current weapon.
  • TextureID, Vector2 GetIcon(Inventory item, int flags, bool showdepleted = true)
Gets the icon for the given Inventory item.

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.