How john-nagle/ui-mock works
Project Type and Purpose
• This is a Rust-based library plus example binary that provides a mockup of a game-style 2D menu interface over a 3D world. It’s intended as a test fixture for a metaverse client, demonstrating how to integrate a non-intrusive 2D overlay (menus, dialogs) on top of a Rend3-powered 3D scene with Egui for GUI widgets.
• Key indicators:
• README describes a “mockup and test fixture for a game-type user interface,” 2D overlay atop a 3D world.
• Uses safe Rust with Rend3 (3D) and Egui (2D overlay).
• Cargo.toml + src folder + examples/ui-mock suggest a library crate plus an example binary.
File Structure Analysis
• Top-level:
• Cargo.toml, README.md: Rust project manifest and documentation.
• src/: main library code and modules.
• src/assets/: JSON definitions (grids.json), images, locales (menus.json, translations).
• src/basicintl.rs: core internationalization support.
• src/lib.rs: library entry point exporting modules.
• src/examples/ui-mock/: standalone example binary named ui-mock:
• main.rs launches window, sets up Rend3/Egui.
• examplesupport.rs, libdialog/: a dialog-system submodule with multiple dialog variants (login, stats, grids, etc.).
• No separate backend or database—this is purely client-side UI simulation.
README Insights
• Describes runtime behavior (windowed/fullscreen, auto-hide menus).
• Mentions core technologies: Rend3, Egui.
• Emphasizes a “clean screen when possible,” minimal obtrusiveness.
a. Main Components
1. Example Application (ui-mock binary)
2. Core UI Library
• Asset Manager (loads JSON, images, locales)
• Internationalization Module (basicintl)
• State Manager (guistate)
• Dialog System (libdialog in example)
3. Rendering Backends
• Rend3 (3D engine)
• Egui (2D overlay)
4. Input Handling
• Mouse/keyboard events → event switch (examples/ui-mock/libdialog/eventswitch)
5. Configuration & Assets
• JSON files in assets/grids.json, menus.json, locale data
• Images in assets/images
b. Relationships and Interactions
• Example App initializes Rend3 window and Egui context.
• Asset Manager loads configuration and image assets, passes data to UI Modules.
• Input events flow into the Event Switch, which updates the State Manager.
• State Manager invokes UI Modules to build Egui panels/widgets.
• Egui renders 2D overlays; Rend3 renders underlying 3D scene (empty/test scene).
• Internationalization module provides localized strings to menus/dialogs.
c. Architectural Patterns and Principles
• Modular separation: each UI concern in its own Rust module.
• Model-View-Controller style:
• Model = application state (guistate)
• View = Egui GUI modules
• Controller = input event switch, guiutil helpers
• Dependency injection: example binary wires library components to Rend3/Egui backends.
d. Technologies, Frameworks, Libraries
• Rust (100% safe)
• Cargo (build & dependency management)
• Rend3 for 3D rendering
• Egui for immediate-mode GUI overlay
• Serde/JSON for asset parsing (implicit in JSON files)
• Winit (implied for windowing & input)