Gfx egui Ecosystem — Third-Party HUD Improvements
Summary
Adopt vetted egui ecosystem crates in crates/gfx to finish §4.7b HUD polish faster: less hand-rolled list/modal/feedback code, better scalability as inventory/shop/quest content grows, and a clearer path to §4.8 dashboard screens later.
Constraint: Gfx runs egui 0.31 via egui-macroquad 0.17. Every crate must be pinned to a version that compiles against 0.31 before adoption. Phase B assumes an egui bump when macroquad integration catches up (0.33+).
Policy: Keyboard-first play (TUI parity) stays primary. New widgets must not block existing keybind flows (m move, n rename, arrow pickers, etc.).
Current stack (baseline)
| Layer | Crate / path |
|---|---|
| World | macroquad (crates/gfx/src/world_render.rs) |
| HUD | egui 0.31 + egui-macroquad 0.17 (crates/gfx/src/hud/) |
| State | flatland-client-lib::GameState, flatland-client-ui keymap |
| Entry | tools/flatland-gfx play loop |
Touch surfaces: hud/overlays.rs, hud/sidebar.rs, hud/combat.rs, hud/mod.rs, ui/list.rs, theme.rs, lib.rs (GfxRenderer).
Crate shortlist (from wiki review)
Phase A — egui 0.31 compatible (do first)
Verify egui dep in crate Cargo.toml before merging each PR.
| Crate | Use in Flatland3 | Primary files | §4.7b checklist rows |
|---|---|---|---|
egui-notify 0.19 (pins to egui 0.31) |
Craft done, quest update, asset sync, reconnect errors | hud/feedback.rs, lib.rs — toast queue on GfxRenderer |
Log/chat (supplement, not replace) |
| egui_modal (blocked — crate is egui 0.30 only) | Destroy confirm, rename, quest withdraw, connection settings (F2) | hud/modals.rs — native backdrop + centered Window until upstream 0.31 |
Craft/destroy/move pickers |
| egui_virtual_list | Inventory overlay, craft recipes, shop offers, rotation picker, log panel | overlays.rs, sidebar.rs, ui/list.rs |
Inventory, shop, rotation editor |
| iconflow (blocked — egui 0.33+) | Row icons: encumbrance, currency, ability slots, sync status | ui/list.rs, hud/combat.rs, hud/status.rs |
Combat HUD, inventory |
egui_material_icons 0.3 |
Same slots on egui 0.31 (Phase A substitute) | hud/icons.rs, hud/combat.rs, hud/sidebar.rs, hud/overlays.rs |
Combat HUD, inventory |
| egui_commonmark | Rich help (?) + connection quickstart from shipped markdown |
hud/overlays.rs (draw_help_window) |
Help / keybinds |
Phase B — after egui 0.33+ bump
| Crate | Use | Blocker |
|---|---|---|
| egui-async | Asset sync spinner, future market/bank API panels (§4.8) | Needs egui ≥ 0.32; macroquad pin |
| egui_table | Character sheet attribute/skill tables (sortable columns) | Verify 0.31 fork or wait for bump |
| egui_dock | Optional resizable HUD (inventory / log / combat dock) | Larger UX change; post-4.7b |
| catppuccin-egui or egui-shadcn | Theme refresh over hand-rolled GfxTheme |
Theme API drift across versions |
Explicitly deferred / skip
| Crate | Reason |
|---|---|
| walkers | Cartography deferred; macroquad already owns world map |
| egui_plot | Debug tooling only |
| egui_dnd | Conflicts with keyboard-first inventory until we add optional mouse mode |
| egui_router, egui_hooks | Game HUD, not SPA |
| egui_pie_menu | New input model; not TUI parity |
| egui-file-dialog | No filesystem UX in play client |
| egui-gizmo | 3D editor territory |
Phased implementation
Work Phase A → Phase B. Each phase ends with manual smoke on make dev-play-gfx and cargo test -p flatland-gfx-engine.
Phase A1 — Feedback + modals (1–2 PRs)
Goal: Players see immediate feedback; modals behave consistently.
- Add
egui-notify = "0.19"(last release on egui 0.31; newer notify needs egui 0.34+). GfxRendererholdsGfxFeedback/Toasts;draw_egui_hudrenders toasts after overlays.- Wire events from existing
GameStatelog lines (first pass):- Harvest complete / craft complete
- Asset sync result (pushed to log at gfx startup)
- Disconnect / reconnect messages
- Modal chrome via
hud/modals.rs(flatland_modalbackdrop + centered window); migrate:draw_destroy_confirm,draw_rename_promptdraw_connection_settings(F2)- Quest withdraw confirm
- Revisit
egui_modalwhen it ships for egui 0.31+
- Exit: Esc closes modals in fixed order; toasts visible without obscuring combat strip.
Files: crates/gfx/Cargo.toml, src/lib.rs, src/hud/mod.rs, src/hud/overlays.rs.
Phase A2 — Virtual lists (1–2 PRs)
Goal: Smooth scrolling for 50+ row panels.
- Add
egui_virtual_list. - Replace
SelectableList+ fullScrollAreaiteration in:draw_inventory_overlaydraw_craft_overlay- Shop buy/sell lists (when shop panel lands)
draw_rotation_editorability pickerdraw_log_panel(sidebar)
- Keep keyboard selection index in
GameState/ local play state — virtual list is render-only; do not move selection into egui focus. - Exit: Inventory + craft usable with keyboard only; no regression in
↑↓/ Enter behavior.
Files: src/ui/list.rs, src/hud/overlays.rs, src/hud/sidebar.rs.
Phase A3 — Icons + help (1 PR)
Goal: Scannable HUD; self-serve docs for installed players.
- Add
iconflow; define small mapping intheme.rsorui/icons.rs(encumbrance, gold, combat, network). - Use icons in inventory sidebar column, combat action strip, connection settings.
- Add
egui_commonmark; load static markdown:docs/graphical-client.mdexcerpts or a newassets/client/help.md- Render in
draw_help_windowinstead of plainformat_keybindings_plain()only (keep keybind table as primary section).
- Exit:
?help readable; F2 panel shows host/ports with icon + markdown blurb.
Phase A exit gate
Phase B0 — egui version bump (prerequisite)
Goal: Unlock async + table ecosystem.
- Track egui-macroquad releases for egui 0.33/0.34 support.
- Bump workspace:
egui,egui-macroquad, fix breaking API intheme.rs,overlays.rs,input.rs. - Run gfx smoke +
cargo test -p flatland-gfx-engine. - Publish client crates patch release after bump.
Exit: crates/gfx builds on egui 0.33+ with macroquad play unchanged.
Phase B1 — Async HUD bindings
- Add
egui-async; register plugin in gfx frame (per crate docs for target egui version). - Use for:
- Connection settings “Test connection” button
- Asset sync progress in-settings (optional manual sync)
- Future §4.8 market/bank fetch panels
- Do not replace tokio net thread — egui-async only for UI-facing short HTTP/tasks.
Phase B2 — Character sheet table + optional dock
egui_tablefordraw_stats_overlayattribute/skill grids (sort by level/name).- Spike
egui_dockbehindFLATLAND_GFX_DOCK=1env — combat + log + sidebar detachable. - Only promote dock to default if play-testers prefer it over fixed layout.
Phase B exit gate
Dependency policy
- One crate per PR when possible — easier rollback and version debugging.
- Pin exact versions in
crates/gfx/Cargo.toml; document egui compatibility in this plan’s crate table. - No new egui deps in
flatland-client-lib— keep HUD concerns inflatland-gfx-engineonly. - Feature flags for experimental UI (
FLATLAND_GFX_DOCK, debugegui_logger) — default off.
Testing
| Level | What |
|---|---|
| Unit | Keep flatland-gfx-engine tests green; mock-free widget tests only if crate provides them |
| Manual | make dev-play-gfx NAME=… — broker hut shop, destroy item, rotation editor, F2 settings, ? help |
| Installed | flatland3 assets sync + play — toast on sync failure path |
| Regression | Keyboard path: inventory m/n/d, quest q, combat 1–9 unchanged |
Roadmap linkage
Add to specification as §4.7f Gfx egui ecosystem (see checklist there).
Feeds §4.7b exit gate (modal polish, shop/rotation UX) and §4.8 dashboard (Phase B async + tables reuse same crates in gfx or shared crates/gfx helpers).
Suggested PR order
feat(gfx): egui-toast for craft/quest/sync feedbackfeat(gfx): egui_modal for destroy/rename/connection/quest confirmfeat(gfx): virtual lists for inventory, craft, logfeat(gfx): iconflow + commonmark helpchore(gfx): egui 0.33 bump(when macroquad ready)feat(gfx): egui-async connection test + egui_table character sheet
Open questions
| Question | Default if no answer |
|---|---|
egui-toast vs egui-notify? |
Spike both in branch; pick smaller dep + 0.31 support |
| Mouse drag inventory later? | Defer egui_dnd until §4.8 or explicit mouse-mode milestone |
| Ship help markdown in asset bundle? | Yes — include assets/client/help.md in Firebase asset publish (§4.7e) |
Definition of done (track)
| Milestone | Done when |
|---|---|
| A1 | Toasts + modals merged; manual modal Esc order verified |
| A2 | Virtual lists in inventory/craft/log; keyboard nav unchanged |
| A3 | Icons in combat/inventory; markdown help renders |
| Phase A | §4.7f Phase A checkboxes green; 4.7b modal polish signed off |
| B0 | egui 0.33+ on macroquad |
| Phase B | Async + table in character sheet; optional dock spike documented |