# WeaponIcon record

> A weapon's icon on the wheel: one character from a font, as Half-Life 2's are, or an image, or a rectangle of one. A record's icon, icon_selected and ammo_icon are each a table of these keys, and give a font and a character or an image, never both. The wheel draws font icons. An image icon is read and kept, but the wheel doesn't draw one yet, so a weapon with only an image icon shows its title alone.

Namespace `EvilEngine.Formats.Records`, assembly `EvilEngine.Formats`. Engine commit 4ff877b1.

```csharp
public sealed record WeaponIcon
```

A weapon's icon on the wheel: one character from a font, as Half-Life 2's are, or an image, or a rectangle of one. A record's `icon`, `icon_selected` and `ammo_icon` are each a table of these keys, and give a font and a character or an image, never both. The wheel draws font icons. An image icon is read and kept, but the wheel doesn't draw one yet, so a weapon with only an image icon shows its title alone.

```toml
icon = { font = "mygun:fonts/icons.ttf", character = "R" }
icon_selected = { image = "mygun:materials/railgun", region = [0, 0, 128, 64] }
```

## Members

### WeaponIcon (constructor)

```csharp
public WeaponIcon()
```

Makes an icon with nothing set. [Glyph](#glyph) and [Picture](#picture) make the two kinds a record can hold.

### Image (property)

```csharp
public ContentId? Image { get; init; }
```

The image drawn, from `image`, or `null` for a font icon.

### Region (property)

```csharp
public CrosshairRegion? Region { get; init; }
```

The rectangle of the [Image](#image) drawn, from `region`, as `[x, y, width, height]` in whole texels with a size above 0, or `null` for the whole image. A font icon has none.

### Font (property)

```csharp
public ContentId? Font { get; init; }
```

The font the [Character](#character) is drawn from, from `font`, or `null` for an image icon.

### Character (property)

```csharp
public string? Character { get; init; }
```

The one character drawn from the [Font](#font), from `character`, or `null` for an image icon. One character is one Unicode scalar value, so it can be outside the Basic Multilingual Plane.

### Glyph (method)

```csharp
public static WeaponIcon Glyph(ContentId font, string character)
```

Makes a font icon from a font and one character.

### Picture (method)

```csharp
public static WeaponIcon Picture(ContentId image, CrosshairRegion? region = null)
```

Makes an image icon from an image and, optionally, the rectangle of it to draw.
