[PR #102] [MERGED] feat(game): movable lockable HUD panels + layout/drag fixes #4467

Closed
opened 2026-10-22 04:07:52 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/102
Author: @LukaTheHero
Created: 4/19/2026
Status: ✅ Merged
Merged: 4/19/2026
Merged by: @SpicyMarinara

Base: main ← Head: feat/game-movable-hud-panels


📝 Commits (1)

  • e12f501 feat(game): movable lockable HUD panels + fix column reshuffle

📊 Changes

4 files changed (+225 additions, -28 deletions)

View changed files

➕ packages/client/src/components/game/DraggablePanel.tsx (+115 -0)
📝 packages/client/src/components/game/GameMap.tsx (+42 -8)
📝 packages/client/src/components/game/GameSurface.tsx (+18 -8)
📝 packages/client/src/components/game/GameWidgetPanel.tsx (+50 -12)

📄 Description

Summary

Adds a small lock icon next to the collapse toggle on every Game Mode HUD panel (map, Bonds, Leads, Mana Stability, Exposure Risk). Panels are locked by default; clicking the lock swaps it to an open padlock, draws a faint ring around the card, and makes it free-draggable within the game surface. Lock state and position persist per chat so layouts don't leak between games.

What's in the box

New: packages/client/src/components/game/DraggablePanel.tsx

  • useDraggablePanel(chatId, panelId) hook — returns { locked, toggleLocked, x, y, handleDragEnd }. Storage key is marinara-game-panel:<chatId>:<panelId>, so every game gets its own HUD layout.
  • Reads localStorage synchronously via a useRef seed on first render, so moved panels paint at their saved position with no origin-flash flicker.
  • PanelLockButton — lucide Lock/Unlock toggle styled to match the existing chevron/collapse indicators (text-white/30 hover:text-white/70), with stopPropagation so it doesn't fire the header's collapse click.

Updated: GameWidgetPanel.tsx, GameMap.tsx

  • Cards render as motion.div with drag={!locked}, dragMomentum={false}, dragElastic={0}, and dragConstraints pointed at the game surface — panels can't be dragged off-screen.
  • WidgetCard keyed by ${chatId}:${widget.id} so switching games remounts with fresh motion values.
  • Map card styling (w-52, border, bg, shadow, blur) moved from the GameSurface wrapper onto GameMapPanel's draggable root, so the whole visual card translates together.
  • data-tour="game-map" moved from the static wrapper onto the draggable map root, so the onboarding tutorial highlight tracks it wherever it's dragged.

Updated: GameSurface.tsx

  • New hudSurfaceRef on the main game content <div>, passed as constraintsRef to both map and widget panels.
  • activeChatId threaded down as chatId to both panels for storage scoping.
  • HUD flex container: items-start → items-end (fix below).

Pre-existing bugs fixed along the way

  • Column reshuffle on expand/collapse — the HUD flex container was items-start but anchored at bottom-24 with no fixed height, so growing the left column pushed the container top upward and dragged the top-aligned right column with it. Switched to items-end so both columns bottom-anchor and grow independently upward.
  • Drag lag — WidgetCard had transition-all, which made the browser tween every transform update framer-motion pushed during drag. Narrowed to transition-colors so only color state animates; transform updates are immediate.

Test plan

  • pnpm check passes (client build + typecheck clean)
  • All five desktop panels show a lock icon and are locked by default
  • Clicking lock → open padlock + ring + grab cursor; drag works; re-lock restores normal behavior
  • Collapse/expand still toggles whether locked or unlocked
  • Lock state and drag position persist across reload
  • Switching chats resets layout to that chat's saved positions (doesn't carry over)
  • Cannot drag any panel off-screen (clamped to game surface)
  • No paint-flicker when reloading a chat with moved panels
  • Expanding/collapsing a widget on the left no longer shifts the right column (and vice versa)
  • Drag feels smooth — no CSS-transition lag
  • Tutorial highlight still targets the map after it's been moved

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/102 **Author:** [@LukaTheHero](https://github.com/LukaTheHero) **Created:** 4/19/2026 **Status:** ✅ Merged **Merged:** 4/19/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `main` ← **Head:** `feat/game-movable-hud-panels` --- ### 📝 Commits (1) - [`e12f501`](https://github.com/Pasta-Devs/Marinara-Engine/commit/e12f501da95af9768760cddb1072f57d8a584a0f) feat(game): movable lockable HUD panels + fix column reshuffle ### 📊 Changes **4 files changed** (+225 additions, -28 deletions) <details> <summary>View changed files</summary> ➕ `packages/client/src/components/game/DraggablePanel.tsx` (+115 -0) 📝 `packages/client/src/components/game/GameMap.tsx` (+42 -8) 📝 `packages/client/src/components/game/GameSurface.tsx` (+18 -8) 📝 `packages/client/src/components/game/GameWidgetPanel.tsx` (+50 -12) </details> ### 📄 Description ## Summary Adds a small lock icon next to the collapse toggle on every Game Mode HUD panel (map, Bonds, Leads, Mana Stability, Exposure Risk). Panels are locked by default; clicking the lock swaps it to an open padlock, draws a faint ring around the card, and makes it free-draggable within the game surface. Lock state and position persist **per chat** so layouts don't leak between games. ## What's in the box **New:** `packages/client/src/components/game/DraggablePanel.tsx` - `useDraggablePanel(chatId, panelId)` hook — returns `{ locked, toggleLocked, x, y, handleDragEnd }`. Storage key is `marinara-game-panel:<chatId>:<panelId>`, so every game gets its own HUD layout. - Reads localStorage synchronously via a `useRef` seed on first render, so moved panels paint at their saved position with no origin-flash flicker. - `PanelLockButton` — lucide `Lock`/`Unlock` toggle styled to match the existing chevron/collapse indicators (`text-white/30 hover:text-white/70`), with `stopPropagation` so it doesn't fire the header's collapse click. **Updated:** `GameWidgetPanel.tsx`, `GameMap.tsx` - Cards render as `motion.div` with `drag={!locked}`, `dragMomentum={false}`, `dragElastic={0}`, and `dragConstraints` pointed at the game surface — **panels can't be dragged off-screen**. - `WidgetCard` keyed by `${chatId}:${widget.id}` so switching games remounts with fresh motion values. - Map card styling (`w-52`, border, bg, shadow, blur) moved from the `GameSurface` wrapper onto `GameMapPanel`'s draggable root, so the whole visual card translates together. - `data-tour="game-map"` moved from the static wrapper onto the draggable map root, so the onboarding tutorial highlight tracks it wherever it's dragged. **Updated:** `GameSurface.tsx` - New `hudSurfaceRef` on the main game content `<div>`, passed as `constraintsRef` to both map and widget panels. - `activeChatId` threaded down as `chatId` to both panels for storage scoping. - HUD flex container: `items-start` → `items-end` (fix below). ## Pre-existing bugs fixed along the way - **Column reshuffle on expand/collapse** — the HUD flex container was `items-start` but anchored at `bottom-24` with no fixed height, so growing the left column pushed the container top upward and dragged the top-aligned right column with it. Switched to `items-end` so both columns bottom-anchor and grow independently upward. - **Drag lag** — `WidgetCard` had `transition-all`, which made the browser tween every transform update framer-motion pushed during drag. Narrowed to `transition-colors` so only color state animates; transform updates are immediate. ## Test plan - [x] `pnpm check` passes (client build + typecheck clean) - [x] All five desktop panels show a lock icon and are locked by default - [x] Clicking lock → open padlock + ring + grab cursor; drag works; re-lock restores normal behavior - [x] Collapse/expand still toggles whether locked or unlocked - [x] Lock state and drag position persist across reload - [x] Switching chats resets layout to that chat's saved positions (doesn't carry over) - [x] Cannot drag any panel off-screen (clamped to game surface) - [x] No paint-flicker when reloading a chat with moved panels - [x] Expanding/collapsing a widget on the left no longer shifts the right column (and vice versa) - [x] Drag feels smooth — no CSS-transition lag - [x] Tutorial highlight still targets the map after it's been moved --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-22 04:07:52 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#4467
No description provided.