Radial Menu

The Radial Menu module provides sophisticated circular, gesture-based menu interfaces with dynamic positioning, multi-level navigation, and comprehensive interaction handling. Perfect for weapon wheels, quick actions, immersive gameplay interactions, and creating intuitive radial interfaces that enhance user experience with smooth animations and intelligent layout management.

showRadial

Display a radial menu with comprehensive configuration options and advanced positioning control.

Parameters:

  • playerId (number, server-side only): Player server ID to show radial menu to

  • options (table, required): Comprehensive radial menu configuration object

Configuration Options:

  • id (string, optional): Unique radial menu identifier for management and events (default: auto-generated UUID)

  • items (table, optional): Array of radial menu items with full configuration (default: empty array)

  • radius (number, optional): Base radius in pixels with responsive scaling (default: 100)

  • style (string, optional): Visual style preset ('default', 'minimal', 'modern', 'classic') (default: 'default')

  • showLabels (boolean, optional): Display item labels with positioning control (default: true)

  • showCenter (boolean, optional): Show center circle with interactive capabilities (default: true)

  • showConnectors (boolean, optional): Display lines connecting items to center with styling (default: false)

  • centerIcon (string, optional): Lucide icon to display in center circle

  • centerText (string, optional): Text to display in center with formatting support

  • centerSize (number, optional): Center circle size in pixels with scaling (default: 60)

  • itemSize (number, optional): Item circle size in pixels with responsive scaling (default: 50)

  • animationDuration (number, optional): Animation duration in milliseconds (default: 300)

  • expansionDelay (number, optional): Delay between item animations in milliseconds (default: 50)

  • selectionDeadzone (number, optional): Center deadzone radius in pixels (default: 35)

  • enableDynamicRadius (boolean, optional): Auto-adjust radius based on item count (default: false)

  • radiusPerItem (number, optional): Additional radius per item when dynamic (default: 8)

  • minRadius (number, optional): Minimum radius when dynamic scaling (default: 80)

  • maxRadius (number, optional): Maximum radius when dynamic scaling (default: 180)

  • position (table, optional): Custom positioning with anchor points

  • theme (string, optional): Theme override ('auto', 'light', 'dark')

  • zIndex (number, optional): Z-index for menu layering (default: 1000)

  • closeOnSelection (boolean, optional): Auto-close after item selection (default: true)

  • enableHapticFeedback (boolean, optional): Controller vibration feedback (default: true)

  • contextData (table, optional): Context data passed to event handlers

Returns: boolean - Success status indicating radial menu display completion

Example:

hideRadial

Hide the currently active radial menu with smooth animation and proper cleanup.

Parameters:

  • playerId (number, server-side only): Player server ID to hide radial menu for

Returns: boolean - Success status indicating radial menu hide completion

Example:

updateRadialData

Update context data for the currently active radial menu with real-time data refresh.

Parameters:

  • contextData (table, required): Updated context data object with new values

Returns: boolean - Success status indicating data update completion

Example:

isRadialVisible

Check if a radial menu is currently visible and get active menu information.

Returns: boolean|table - False if no radial menu is active, or table with active menu data

  • id (string): Current radial menu identifier

  • itemCount (number): Number of menu items

  • radius (number): Current menu radius

  • contextData (table): Current context data

Example:

updateRadialItems

Update a radial menu's items dynamically while maintaining position and state.

Parameters:

  • items (table, required): Updated array of radial menu items

Returns: boolean - Success status indicating items update completion

Example:

Radial Menu Item Structure

Radial menu items support comprehensive properties for advanced functionality and visual customization:

Server-Side Usage

The Radial Menu module provides comprehensive server-side functionality for managing player-specific radial menus and administrative tools:

Events

The Radial Menu module provides comprehensive event handling for monitoring and responding to radial menu interactions:

Client Events

Server Events

Configuration

Complete Radial Menu configuration options in config.lua:

Advanced Examples

Weapon Wheel System

Vehicle Interaction Radial

Emote Radial Menu

Admin Tools Radial

Best Practices

  1. Optimize Item Count - Keep radial menus to 8-12 items for optimal usability and visual clarity

  2. Use Meaningful Icons - Choose clear, recognizable Lucide icons that represent actions intuitively

  3. Implement Smart Grouping - Use submenus and logical grouping for related functionality and complex workflows

  4. Provide Rich Visual Feedback - Use colors, badges, progress indicators, and animations to convey information effectively

  5. Test Cross-Platform - Ensure radial menus work seamlessly on various screen sizes, resolutions, and input methods

  6. Handle Edge Cases - Validate states, permissions, and context before showing menus to prevent errors

  7. Balance Radius Sizing - Use appropriate radius values that balance visibility with screen space efficiency

  8. Optimize Animation Performance - Keep animations smooth and responsive while avoiding performance overhead

  9. Implement Proper Cleanup - Clean up event handlers, timers, and resources when menus are closed

  10. Use Consistent Styling - Maintain visual consistency across different radial menus in your resource

  11. Provide Keyboard Shortcuts - Include keyboard alternatives for accessibility and power users

  12. Test Input Methods - Verify functionality with mouse, keyboard, and gamepad controllers

  13. Implement Context Awareness - Use condition functions and dynamic items based on player state and permissions

  14. Consider Mobile Users - Ensure touch-friendly interactions and appropriate sizing for mobile devices

  15. Monitor Performance - Track radial menu usage and optimize based on player behavior and system performance

Troubleshooting

Radial Menu Not Showing

  1. Configuration Issues

    • Verify the options parameter is provided and contains valid data structure

    • Check that items array contains properly formatted item objects with required properties

    • Ensure radius values are positive numbers within reasonable ranges (50-300px)

    • Validate that all required properties (label, value, icon) are present in items

  2. Display Problems

    • Ensure no other modal dialogs or UI elements are blocking the display

    • Check for conflicting z-index values with other UI components

    • Verify the radial menu isn't being hidden immediately after being shown

    • Test with fixed positioning and simple configurations first

  3. Debug Information

    • Check console for error messages from B2Lib.Debug system

    • Enable debug mode in configuration to see detailed radial operations

    • Verify B2Lib is properly initialized and all dependencies are loaded

    • Test with minimal radial configurations to isolate issues

Selection and Interaction Issues

  1. Event Handler Problems

    • Verify event handlers are registered before showing radial menus

    • Check that item values are unique within each radial menu

    • Ensure event handler functions are properly defined and accessible

    • Test event firing with console logging to verify event flow

  2. Input Blocking

    • Ensure mouse/controller input is not blocked by other scripts or UI elements

    • Check for conflicting control disabling from other resources

    • Verify deadzone settings are appropriate for your input method

    • Test with different input devices (mouse, gamepad, touch)

  3. Selection Sensitivity

    • Adjust selectionSensitivity configuration for better responsiveness

    • Check that selection deadzone is not too large or too small

    • Verify mouse cursor positioning is accurate and responsive

    • Test selection with different radius sizes and item counts

Performance and Animation Issues

  1. Frame Rate Problems

    • Avoid too many items in a single radial menu (recommended max: 12)

    • Optimize item data calculations and avoid expensive operations in condition functions

    • Use reasonable animation durations (200-400ms) to balance smoothness and responsiveness

    • Monitor CPU usage during radial menu operations

  2. Memory Management

    • Clean up event handlers when radial menus are no longer needed

    • Avoid storing large objects in context data or item properties

    • Implement proper resource cleanup on resource stop/restart

    • Monitor memory usage during extended radial menu usage

  3. Animation Smoothness

    • Use CSS transforms instead of changing position properties for better performance

    • Implement proper easing functions for natural-feeling animations

    • Avoid animating too many properties simultaneously

    • Test animations on lower-end hardware to ensure compatibility

Visual and Styling Issues

  1. Icon and Color Problems

    • Check that icon names are valid Lucide icons and properly spelled

    • Verify color values are in correct format (#hex, rgba, or named colors)

    • Test with different theme modes (dark/light) to ensure proper contrast

    • Ensure custom styling doesn't conflict with default B2Lib styles

  2. Layout and Positioning

    • Ensure radius values are appropriate for screen size and item count

    • Check that labels don't overlap with items or extend outside screen bounds

    • Verify center circle sizing is proportional to overall radial size

    • Test positioning on different screen resolutions and aspect ratios

  3. Theme Integration

    • Verify theme colors are properly applied and accessible

    • Check contrast ratios for accessibility compliance

    • Test with custom themes and ensure proper fallback behavior

    • Ensure theme switching works correctly during runtime

Server-Side Integration Issues

  1. Network Synchronization

    • Account for network latency when showing server-side radial menus

    • Implement proper error handling for failed network operations

    • Use appropriate timeouts for server-side radial menu operations

    • Verify player connection status before sending radial menu data

  2. Permission Validation

    • Verify player exists and is connected before showing server-side radials

    • Implement proper permission checks on both client and server sides

    • Handle permission changes during active radial menu sessions

    • Validate context data on server side to prevent exploitation

  3. Resource Conflicts

    • Check for conflicts with other resources using radial menus

    • Ensure proper resource dependencies are declared in fxmanifest.lua

    • Test radial menu functionality after resource restarts and updates

    • Monitor for conflicts with other UI systems and input handlers

Last updated