User interface components and systems.
The UI module provides all user interface elements for adventure games,
including dialogs, inventory display, verb interfaces, and HUD elements.
All UI components are designed to work together and respect the game's
visual style and resolution scaling.
## Core Components
- Dialog - Conversation boxes with choices
- FloatingDialog - Speech bubbles above characters
- VerbCoin - Radial verb selection interface
- StatusBar - Game state and description display
- UIManager - Coordinates all UI elements
- CursorManager - Mouse cursor appearances
## UI Layering
UI elements are rendered in this order (back to front):
1. Game world (scenes, characters)
2. Status bar
3. Inventory
4. Dialogs
5. Verb coin
6. Cursor
## Resolution Independence
```crystal
# UI automatically scales with DisplayManager
dialog = Dialog.new("Hello!", Vector2.new(400, 300), Vector2.new(300, 100))
# Position and size are in game coordinates, not screen pixels
```
## Common Patterns
### Modal Dialogs
```crystal
dialog = Dialog.new("Important message!", pos, size)
dialog.on_complete = -> { engine.resume_game }
engine.pause_game
dialog.show
```
### Choice Dialogs
```crystal
dialog = Dialog.new("What will you do?", pos, size)
dialog.add_choice("Fight") { start_combat }
dialog.add_choice("Flee") { escape_scene }
dialog.add_choice("Talk") { start_conversation }
dialog.show
```
## See Also
- Engine#show_dialog - High-level dialog API
- Characters::Character#say - Character speech
- DisplayManager - Resolution scaling