# Key Items Window

## 🔑 KeyItemsWindow Class

Window for displaying and selecting key items.

> **Namespace:** `Esper.Inventool.UI`\
> **Access:** `public`\
> **Type:** `class`\
> **Inherits:** `DraggableWindow`

***

### 📦 Fields

| Access      | Field                     | Type             | Description                                         |
| ----------- | ------------------------- | ---------------- | --------------------------------------------------- |
| `protected` | `keyItemsTitle`           | `Label`          | Title label at top of the window.                   |
| `protected` | `keyItemsEmptyLabel`      | `Label`          | Label shown when no key items exist.                |
| `protected` | `closeButton`             | `Button`         | Button to close the window.                         |
| `protected` | `keyItemScroll`           | `ScrollView`     | ScrollView listing all key items.                   |
| `protected` | `keyItemContent`          | `VisualElement`  | Container showing details of the selected key item. |
| `protected` | `keyItemImage`            | `VisualElement`  | Displays the selected key item’s icon.              |
| `protected` | `keyItemNameLabel`        | `Label`          | Shows the selected key item’s name.                 |
| `protected` | `keyItemSubtypeLabel`     | `Label`          | Shows the selected key item’s subtype.              |
| `protected` | `keyItemDescriptionLabel` | `Label`          | Shows the selected key item’s description.          |
| `protected` | `selectedKeyItem`         | `KeyItemElement` | Currently selected key item element.                |

***

### 🔍 Properties

| Access          | Property   | Type             | Description                          |
| --------------- | ---------- | ---------------- | ------------------------------------ |
| `public static` | `Instance` | `KeyItemsWindow` | Active singleton instance of window. |

***

### 🧰 Methods

| Access               | Method                          | Returns | Description                                                   |
| -------------------- | ------------------------------- | ------- | ------------------------------------------------------------- |
| `protected override` | `Awake()`                       | `void`  | Initialize singleton, cache UI elements, and register events. |
| `protected override` | `Start()`                       | `void`  | Load initial key items and hide window by default.            |
| `public`             | `LocalizeElements()`            | `void`  | Localize static UI text when localization is enabled.         |
| `public virtual`     | `Toggle()`                      | `void`  | Toggle the window’s open/close state.                         |
| `public override`    | `Open()`                        | `void`  | Show the window and set it active.                            |
| `public`             | `ReloadKeyItems()`              | `void`  | Populate the scroll list with current key items.              |
| `protected`          | `SelectKeyItem(KeyItemElement)` | `void`  | Highlight and display details for a selected key item.        |
| `protected`          | `DeselectKeyItem()`             | `void`  | Clear any selection and hide the detail display.              |

***

## Active Instance

You can get the active `KeyItemsWindow` instance with `KeyItemsWindow.Instance`. Ensure there's an instance of it in your scene before using this field.

## Opening & Closing

### Open

Call the `Open` method when the player wants to open their equipment.

```csharp
KeyItemsWindow.Instance.Open();
```

### Close

`Close` simply closes the window.

```csharp
KeyItemsWindow.Instance.Close();
```

### Toggle

Optionally, you can use `Toggle` to open or close the window.

```csharp
KeyItemsWindow.Instance.Toggle();
```
