Update CLAUDE.md and ARCHITECTURE.md for viewport scrolling, glyph chooser, and sidebar redesign

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-17 17:59:14 -05:00
parent d5d67e988b
commit 5d97f67a64
2 changed files with 30 additions and 15 deletions
+8 -6
View File
@@ -51,14 +51,16 @@ The game is a single Rust binary using **eframe 0.33 / egui 0.33** for the GUI.
- `pub fn load(path: &str) -> Result<Board, Box<dyn std::error::Error>>` — reads and converts a `.toml` map file
**`src/main.rs`** — app entry point:
- `AppMode` enum (`Play` | `Edit`) — gates arrow-key input; toggles the palette panel
- `EditorState` — holds `selected: Archetype` (the archetype to paint on click)
- Loads `maps/start.toml` before creating the window (so board dimensions drive window size)
- Window min-size = `board.width * CELL_W + 2*PANEL_MARGIN` × `board.height * CELL_H + MENU_H + 2*PANEL_MARGIN` (sized for Play mode; Edit mode panel may clip at minimum size)
- Board is centered in the CentralPanel when the window is larger than minimum
- `AppMode` enum (`Play` | `Edit`) — gates arrow-key input; toggles the side panel and viewport mode
- `EditorTab` enum (`Palette` | `Board` | `World`) — which tab is active in the side panel
- `EditorState` — holds `selected: Archetype`, `glyph: Glyph` (the glyph to stamp, independent of archetype default), `glyph_picker_open: bool`, and `tab: EditorTab`. Selecting a new archetype resets `glyph` to that archetype's default.
- Window uses fixed default size (`DEFAULT_WINDOW_W = 840`, `DEFAULT_WINDOW_H = 524`) independent of map dimensions; `board_origin()` handles centering or player-centered scrolling at runtime
- `draw_glyph(painter, origin, x, y, glyph)` draws one cell: filled rect (bg) + monospace char (fg)
- `board_origin(available, board_w, board_h, player)` — if the board fits in the viewport, centers it; if it overflows, centers on the player and clamps to board edges (no empty space shown)
- Player is rendered on top of the board using `Glyph::player()`
- Click-to-paint converts `mouse_pos - origin` to cell coordinates using the same math as rendering
- **Play mode**: arrow keys move player; viewport scrolls to keep player centered when map > window
- **Edit mode**: `ScrollArea::both()` wraps the board so scroll bars appear when map > window; click-to-paint stamps `(self.editor.glyph, self.editor.selected)` at the clicked cell; side panel (200 px, resizable) shows Palette/Board/World tabs
- **Glyph picker dialog** (`egui::Window`): opened from the Palette tab; shows a board-palette of unique glyphs, fg/bg `color_edit_button_srgba` pickers, and a 16×6 grid of printable ASCII chars (0x200x7E)
### Map file format (`maps/*.toml`)