toolkit-ry
Game UI Toolkit for Ry-Dit - HUD, Menus, Dialogs, Inventory + 5 Pre-built Themes
Overview
toolkit-ry is a comprehensive UI toolkit for building game interfaces in Rust. Built on top of migui (immediate mode GUI) and SDL2, it provides ready-to-use widgets for health bars, mana bars, inventory systems, dialog boxes, menus, loading screens, minimaps, and more.
Includes 5 pre-built visual themes (Dark, Light, Retro, Neon, Minimal) that can be customized or used out of the box.
Features
๐จ 5 Pre-built Themes
| Theme | Style | Use Case |
|---|---|---|
| Dark | Modern dark mode | Default for most games |
| Light | Clean light | Casual, mobile games |
| Retro | 8-bit pixel art | Retro, indie games |
| Neon | Cyberpunk glow | Sci-fi, futuristic games |
| Minimal | Ultra clean, no borders | Minimalist, puzzle games |
๐ HUD Widgets
- Health Bar (HP) - With label and dynamic color
- Mana Bar (MP) - Magic/stamina resource
- XP Bar - Experience/progress tracking
- Score Display - Points counter
- Gold/Currency - Money display (with emoji ๐ช)
- Timer - MM:SS format countdown
- Full HUD - Combined HP + MP + XP + Score in one call
๐ฎ Menu Systems
- Main Menu - Title + options with hover states
- Pause Menu - Continue, Options, Save, Exit
- Game Over - Score display + restart/menu options
- Options Menu - Volume slider, fullscreen toggle
- Loading Screen - Progress bar + percentage
๐ฌ Dialog & Notifications
- NPC Dialog - Character name + text box
- Message Box - Confirmation dialogs with buttons
- Notifications - Toast-style popups
๐ Inventory System
- Inventory Slot - Individual item with count
- Inventory Grid - Configurable cols ร rows grid
- Item selection and hover states
- Stack count display
๐บ๏ธ Minimap
- Player position indicator
- Scaled to world coordinates
- Customizable size
Installation
[]
= "0.1.0"
= "0.4.1"
= "0.37"
Quick Start
Basic Health Bar
use Theme;
use *;
// Create a migui instance (assuming you have SDL2 + migui setup)
// let mut gui = migui::Migui::new();
let theme = dark;
draw_health_bar;
Full HUD in One Call
use Theme;
use draw_full_hud;
let theme = dark;
draw_full_hud;
Main Menu
use Theme;
use draw_main_menu;
let theme = retro;
let mut hover_state = -1;
let selected = draw_main_menu;
if selected >= 0
Inventory Grid
use Theme;
use draw_inventory_grid;
let theme = dark;
let mut selected_slot = 0;
// Create inventory items
let items = vec!;
let selected = draw_inventory_grid;
Dialog with NPC
use Theme;
use draw_dialog;
let theme = light;
draw_dialog;
Loading Screen
use Theme;
use draw_loading;
let theme = neon;
// Update progress each frame (0.0 to 1.0)
let progress = 0.65; // 65% loaded
draw_loading;
Minimap
use Theme;
use draw_minimap;
let theme = dark;
draw_minimap;
API Reference
Theme System
ColorRGBA
Widget Functions
HUD
| Function | Parameters | Description |
|---|---|---|
draw_health_bar |
gui, x, y, w, h, current, max, theme |
HP bar with label |
draw_mana_bar |
gui, x, y, w, h, current, max, theme |
MP/mana bar |
draw_xp_bar |
gui, x, y, w, h, current, max, theme |
Experience bar |
draw_score |
gui, x, y, score, theme |
Score display |
draw_gold |
gui, x, y, gold, theme |
Currency with emoji |
draw_timer |
gui, x, y, seconds, theme |
MM:SS timer |
draw_full_hud |
gui, hp, max_hp, mp, max_mp, xp, max_xp, score, theme |
Complete HUD |
Menus
| Function | Parameters | Returns |
|---|---|---|
draw_main_menu |
gui, title, options, theme, hover_state |
i32 selected index |
draw_pause_menu |
gui, theme, hover_state |
i32 selected index |
draw_game_over |
gui, score, theme, hover_state |
i32 selected index |
draw_options_menu |
gui, theme, volume, fullscreen, hover_state |
() |
draw_loading |
gui, text, progress, theme |
() |
Dialogs
| Function | Parameters | Returns |
|---|---|---|
draw_dialog |
gui, npc_name, text, x, y, w, h, theme |
() |
draw_message_box |
gui, title, message, buttons, theme |
i32 button index |
draw_notification |
gui, text, x, y, theme |
() |
Inventory
| Function | Parameters | Returns |
|---|---|---|
draw_inventory_slot |
gui, x, y, size, item_name, count, selected, theme |
() |
draw_inventory_grid |
gui, x, y, cols, rows, slot_size, spacing, items, selected, theme |
Option<usize> |
Other
| Function | Parameters | Description |
|---|---|---|
draw_minimap |
gui, x, y, size, player_x, player_y, world_w, world_h, theme |
Minimap display |
rgba_to_migui |
ColorRGBA |
Convert to migui::Color |
rgba_to_sdl2 |
ColorRGBA |
Convert to sdl2::pixels::Color |
Theme Customization
All theme properties are public, so you can easily create your own:
use ;
let my_theme = Theme ;
Dependencies
| Crate | Version | Purpose |
|---|---|---|
migui |
0.4.1 | Immediate mode GUI backend |
sdl2 |
0.37 | SDL2 bindings for color types |
ry-gfx |
0.10.8 | Graphics layer (optional) |
Examples
Complete Game Menu Flow
use Theme;
use *;
RPG HUD Example
// Full HUD with HP/MP/XP bars
let theme = retro;
draw_full_hud;
// Add timer and gold
draw_timer; // 5:45
draw_gold; // ๐ช 1250
Performance
- Immediate mode - No retained state overhead
- Zero allocations in widget drawing (pure rendering)
- Theme system is copy-based (ColorRGBA is Copy)
- 10 unit tests ensuring widget correctness
Roadmap
- Scrollable panels
- Text input fields
- Dropdown menus
- Tooltip system
- Animated transitions
- Theme serialization (JSON/TOML)
- Custom widget macro
- Responsive layouts
Contributing
Contributions are welcome! This crate is part of the Ry-Dit game engine project.
- Repository: https://github.com/lapumlbb18-blip/Ry-dit
- Issues: https://github.com/lapumlbb18-blip/Ry-dit/issues
- Pull Requests: Welcome!
Please read CONTRIBUTING.md for guidelines.
License
MIT License - See LICENSE for details.
Related Crates
| Crate | Description |
|---|---|
| migui | Immediate mode GUI backend |
| ry-gfx | Graphics layer with GPU instancing |
| ry-backend | Dual backend (raylib + SDL2) |
| ry-anim | Animation system with Disney principles |
toolkit-ry - Build game UIs faster with pre-built widgets and themes ๐ฎโจ
5 themes ยท 20+ widgets ยท HUD ยท Menus ยท Inventory ยท Dialogs