GetInventoryIcon

From ZDoom Wiki
Jump to navigation Jump to search

BaseStatusBar

native static TextureID, bool GetInventoryIcon(Inventory item, int flags)

Usage

Can be used in a ZScript HUD to obtain a TextureID of the specified item's icon. If not available, looks for alternative icon, Spawn state sprite or Ready state sprite.

BaseStatusBar also has another convenient wrapper for this function: GetIcon. The only significant difference is that GetIcon is not a static function.

Parameters

  • Inventory item
A pointer to an instance of an Inventory class (for example, obtained via FindInventory).
  • int flags
Possible flags:
  • DI_SKIPICON - don't check for Icon
  • DI_SKIPALTICON - don't check for AltIcon
  • DI_SKIPSPAWN - don't check for Spawn state sprite
  • DI_SKIPREADY - don't check for Ready state sprite
  • DI_ALTICONFIRST - look for AltIcon first; only if not availble look for Icon
  • DI_FORCESCALE - don't apply scale to the icon (Verification needed)

Return values

The function has 2 return values:

  • TextureID - the textureID of the icon
  • bool - true if the item's scale was applied to the icon

Examples

This obtains the icon of the player's currently equipped weapon an draws it at the bottom left corner of the screen:

TextureID icon = GetInventoryIcon(CPlayer.readyWeapon, 0);
if (icon.isValid())
{
    DrawTexture(icon, (0,0), DI_SCREEN_LEFT_BOTTOM|DI_ITEM_LEFT_BOTTOM);
}

Note: this example is for educational purposes only. In practice it's not useful because it copies the functionality of DrawInventoryIcon.