|
Note: This feature is for ZScript only.
|
BaseStatusBar
void DrawBar(String ongfx, String offgfx, double curval, double maxval, Vector2 position, int border, int vertical, int flags = 0, double Alpha = 1.0)
Usage
Can be used in a ZScript HUD to draw a horizontal or vertical bar, drawing a portion of the ongfx image on top of the offgfx image. Both arguments take image lump names.
Parameters
- string ongfx
- string offgfx
- The names of the foreground (on) and background (off) images that make up the bar. Any type of graphic can be used here (sprites, textures, graphics, ANIMDEFS definitions, TEXTURES definitions, etc.). The name must be provided in double quotation marks.
- If the filename of the image is over 8 characters, a full path (with subfolders and the file extension) must be provided, for example
"graphics/hud/health_bar.png"
- The images are anchored at their centre by default (this can be changed with flags). The built-in offsets of the images are ignored, unless the DI_ITEM_OFFSETS flag is passed.
- double curval
- double maxval
- The current and maximum values for the bar. The ratio between the current and maximum values determine how much of the foreground image will be drawn.
- The position of the element on the screen relative to the HUD's virtual resolution. Positive X moves it to the right, positive Y moves it down. By default, like with all other BaseStatusBar elements,
(0, 0)
equals to top left corner of the HUD area.
- If you're making a fullscreen HUD, unless it's forcescaled (the
forcescaled
argument of the BeginHUD
call is set to true), pos should never be used globally. Instead, DI_SCREEN* and DI_ITEM* flags (see below) should be used to move the anchor point of the image and the origin point of the coordinates, so that it's drawn relative to screen corners and/or sides. This is the only way to make sure that the image doesn't end up being misplaced at different screen resolutions and aspect ratios.
- If this is above 0, the edges of the foreground image will be cut off by border pixels on all sides, letting the edges of the background image show through.
- A set of flags that alter the direction the bar is drawn:
- SHADER_HORZ - Draw the bar horizontally, increasing from left to right (this is the default)
- SHADER_VERT - Draw the bar vertically, increasing from top to bottom
- SHADER_REVERSE - Reverse the direction the bar increases in (vertical bar will count bottom to top, horizontal bar will count right to left)
- The DI_SCREEN* flags will change the origin point of the coordinates where the element is drawn (essentially, moving where the (0, 0) point is located.
- DI_SCREEN_LEFT_TOP - The coordinates begin at the top left corner of the screen
- DI_SCREEN_CENTER_TOP - The coordinates begin at the top center of the screen
- DI_SCREEN_RIGHT_TOP - The coordinates begin at the top right corner of the screen
- DI_SCREEN_LEFT_CENTER - The coordinates begin at the center left side of the screen
- DI_SCREEN_CENTER - The coordinates begin at the center of the screen
- DI_SCREEN_RIGHT_CENTER - The coordinates begin at the center right side of the screen
- DI_SCREEN_LEFT_BOTTOM - The coordinates begin at the bottom left corner of the screen
- DI_SCREEN_CENTER_BOTTOM - The coordinates begin at the bottom center of the screen
- DI_SCREEN_RIGHT_BOTTOM - The coordinates begin at the bottom right corner of the screen
- Note, these flags do not change the orientation of coordinates. Regardless of where the element is drawn, positive X moves it to the right, positive Y moves it down.
- More flags are defined in the StatusBarCore class, but they're mostly aliases of the above ones.
- The DI_ITEM* flags determine the anchor point of the HUD element, i.e. how it is placed relative to the specified position. By default elements are drawn from their top left corner. The following flags determine the anchor point:
- DI_ITEM_TOP - top center
- DI_ITEM_BOTTOM - bottom cemter
- DI_ITEM_LEFT - center of left side
- DI_ITEM_RIGHT - center of right side
- DI_ITEM_LEFT_TOP - top left corner
- DI_ITEM_RIGHT_TOP - top right corner
- DI_ITEM_LEFT_BOTTOM - bottom left corner
- DI_ITEM_RIGHT_BOTTOM - bottom right corner
- DI_ITEM_CENTER - center point
- DI_ITEM_OFFSETS - The element's built-in offsets (as set in SLADE) are taken into account.
- Note, these flags do not change the orientation of coordinates. Regardless of the element's anchor point, positive X moves it to the right, positive Y moves it down.
- More flags are defined in the StatusBarCore class), but they're mostly aliases of the above ones.
- Determines the translucency of the image in the 0.0-1.0 range.
Example
|
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.
|