DrawInventoryIcon
Jump to navigation
Jump to search
void DrawInventoryIcon(Inventory item, Vector2 pos, int flags = 0, double alpha = 1.0, Vector2 boxsize = (-1, -1), Vector2 scale = (1.,1.))
Usage
Functions similarly to DrawTexture, but automatically obtains a specified item's icon and draws it.
Uses GetIcon to obtain the icon. As such, the flags of that function can be passed to the flags parameter to determine how the icon is obtained (Verification needed).
Parameters
- Inventory item
- A pointer to an instance of an Inventory class (for example, obtained via FindInventory).
- vector2 pos
- 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 theBeginHUD
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.
- int flags
- 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.
- double alpha
- Determines the translucency of the image in the 0.0-1.0 range.
- vector2 boxsize
- Determines the size of the box the image will be drawn in. If the size is smaller than the image, the image will be scaled to the size. The default value of (-1, -1) doesn't apply any box.
- vector2 scale
- Determines the scale of the image.
Example
Draw the icon of the player's currently equipped weapon at the bottom left corner of the screen:
DrawInventoryIcon(CPlayer.readyweapon, (0,0), DI_SCREEN_LEFT_BOTTOM|DI_ITEM_LEFT_BOTTOM);