Skip to main content

UI System

Hyperscape features a sophisticated UI system with draggable windows, responsive layouts, and OSRS-inspired panels.
UI code lives in packages/client/src/game/interface/ and packages/client/src/ui/.

Minimap System

Three-Layer Architecture

The minimap uses a three-layer architecture for optimal performance:
  1. Fixed Canvas Layer — 512×512 rendering canvas (never resizes)
  2. Resizable Viewport Layer — User-controlled window size
  3. Overlay Controls Layer — Compass, teleport, stamina orbs

Independent Width/Height Resizing

The minimap now supports independent width and height resizing (no longer forced square):
Before: Minimap was forced to be square (width === height). After: Width and height resize independently for flexible layouts.

Cached Projection Matrix

The minimap uses a cached projection-view matrix to keep entity pips synced with the throttled 3D background:
Why Cache? The 3D background is throttled for performance, but pips need to stay synced. Using the cached matrix ensures pips don’t desync during fast camera rotation.

Overlay Controls

Overlay controls (compass, teleport, stamina) are now extracted into a reusable component:
Reusability: MinimapOverlayControls can be used with both the minimap window and the fullscreen world map.

Viewport Scaling

Design Resolution

The UI uses a design resolution for proportional scaling:
How it works:
  • Layout positions and sizes are calculated relative to 1920×1080
  • When viewport changes, all panels scale proportionally
  • Maintains consistent layout across different screen sizes

ViewportScaler Component

The ViewportScaler component provides design resolution-based scaling:

Proportional Panel Resize

Panels scale proportionally when the viewport changes:
Responsive Design: Panels maintain their proportional size relative to the viewport, ensuring consistent layouts across different screen sizes.

Default Layout

Right Column Stack

The default layout uses a flush, no-overlap design with panels stacked vertically:
Layout Principles:
  • All right column panels share consistent width (235px)
  • Bottom stack panels touch each other (no gaps)
  • Gap between minimap and combat stack
  • Menubar flush to screen bottom
  • Minimap fills remaining space at top

Left Column Stack


Grid Snapping

Snap to Grid Utility

Windows snap to an 8-pixel grid for alignment:
Usage:
Grid Size: The default grid size is 8 pixels, matching common UI design systems.

Panel Configuration

Panel Registry

All panels are configured in PanelRegistry.tsx with responsive sizing:

Responsive Breakpoints


Combat Panel

Attack Style Layout

The combat panel uses a 1×3 row layout for better mobile UX:
Before: 2×2 grid layout (harder to tap on mobile) After: 1×3 row layout (larger touch targets)

Style Button Improvements

Improvements:
  • Increased padding for easier touch targets
  • Larger icon sizes (18px mobile, 16px desktop)
  • Subtle box shadow for depth
  • Better text alignment and spacing

Skills Panel

OSRS-Style Layout

The skills panel now uses OSRS-style 3-column grid ordering:

Total XP Tooltip

Hovering over the total level now shows total XP:

Spells Panel

Spell Grid

The spells panel displays available combat spells in a responsive grid:

Spell Icons

Spells are displayed with element-colored icons:

Autocast Selection

Players can select a spell for autocast by clicking it:
Autocast Indicator:
  • Selected spell shows checkmark (✓)
  • Glow effect with element color
  • Pulse animation
  • “Currently Selected for Autocast” status

Equipment Panel

Ammo Slot

The equipment panel now includes an ammo slot for arrows:
Ammo Slot Icon:

Equipment Grid Layout

Desktop: 3×3 grid with ammo in top-right Mobile: 2-column grid with ammo in row 3

Content-Based Sizing

The menubar now uses content-based sizing to wrap tightly around buttons:
Button Count:
  • Minimum: 4 buttons
  • Default: 10 buttons (includes new Spells button)
  • Maximum: 10 buttons

New Spells Button


Window Management

Z-Index Normalization

Z-indices are normalized when edit mode is locked to prevent shadow overlap:
Why Normalize?
  • During edit mode, windows can have arbitrary z-indices from dragging
  • When locking, normalize to prevent visual glitches (shadows overlapping incorrectly)
  • Ensures consistent stacking order

Anchor-Based Positioning

Windows use anchor-based positioning to maintain their position relative to viewport edges:
Responsive Layouts: Anchor-based positioning ensures windows stay in the correct position when the viewport resizes.

Drag and Drop

DndKit Integration

The UI uses @dnd-kit for cross-panel item dragging:
Supported Drags:
  • Inventory → Equipment (equip items)
  • Inventory → Action Bar (add item shortcuts)
  • Prayer → Action Bar (add prayer shortcuts)
  • Skill → Action Bar (add skill shortcuts)
  • Action Bar → Action Bar (reorder slots)
  • Action Bar → Rubbish Bin (remove slots)

Mobile UI

Touch Optimizations

Mobile UI includes touch-specific optimizations:
Mobile Features:
  • Larger touch targets (52px vs 40px icons)
  • Increased padding and gaps
  • Long-press to drag (250ms delay)
  • Touch action manipulation to disable double-tap zoom

Mobile Breakpoint