Configuration

B2Lib provides extensive configuration options to customize the appearance, behavior, and functionality of all UI components. This guide covers every aspect of the configuration system, from basic settings to advanced customization.

Overview

The B2Lib configuration system is centralized in the Config.lua file, which contains all settings for:

  • Theme System - Colors, typography, spacing, and visual styles

  • Component Settings - Individual UI component configurations

  • Performance Options - Optimization settings for better performance

  • Feature Toggles - Enable/disable specific components

  • Styling Configurations - Detailed appearance customization

Quick Start

Basic Configuration

-- Enable/disable components
Config.EnabledComponents = {
    notifications = true,
    progress = true,
    menus = true,
    textui = true,
    input = true,
    alert = true,
    contextMenu = true,
    skillcheck = true,
    lockpicking = true,
    hacking = true
}

-- Set default theme
Config.Theme.mode = 'dark' -- 'light', 'dark', 'transparent'

-- Configure notifications
Config.Notifications = {
    defaultDuration = 5000,
    defaultPosition = 'top-right',
    maxVisible = 5,
    showIcon = true,
    playSound = true
}

Performance Optimization

Position System

B2Lib uses a comprehensive 9-position grid system for consistent UI placement across all screen resolutions.

Grid Layout

Valid Positions

Primary Positions:

  • top-left, top-center, top-right

  • center-left, center, center-right

  • bottom-left, bottom-center, bottom-right

Legacy Aliases:

  • left (center-left)

  • right (center-right)

  • center-top, center-bottom, bottom

Best Practices

Position
Best Use Case
Reason

top-right

Notifications

Non-intrusive, natural reading flow

bottom-center

Interaction prompts

Natural eye focus area

center

Important dialogs

Maximum attention

center-left

Menus

Easy access, doesn't block gameplay

Avoid: top-left and bottom-left due to potential conflicts with other UI elements.

Usage Examples

Theme System

The theme system provides comprehensive visual customization with three built-in themes and extensive customization options.

Theme Modes

Dark Theme (Default)

Professional dark theme optimized for low-light environments.

Features:

  • Dark backgrounds with light text

  • High contrast for readability

  • Reduced eye strain in low-light conditions

  • Professional appearance

Light Theme

Clean, bright theme optimized for well-lit environments.

Features:

  • Light backgrounds with dark text

  • Clean, modern appearance

  • Excellent readability in bright conditions

  • Familiar interface patterns

Transparent Theme

Semi-transparent theme for immersive gameplay.

Features:

  • Transparent backgrounds

  • High contrast text for readability

  • Minimal visual interference

  • Immersive gaming experience

Color System

The color system is based on TailwindCSS neutral palette for consistency and accessibility.

Semantic Colors

Background Hierarchy

Text Hierarchy

Border Colors

Typography System

Consistent typography scale based on modern design principles.

Spacing System

Consistent spacing scale based on 4px base unit for pixel-perfect alignment.

Border Radius System

Shadow System

Layered shadow system for depth and elevation.

Animation System

Consistent animation timing and easing for smooth interactions.

Component Configuration

Feature Toggles

Enable or disable specific UI components for performance optimization or to prevent conflicts.

Notifications

Configure the toast-style notification system.

Usage Example:

Progress Bars

Configure progress bars for loading states and timed actions.

Usage Example:

Text UI

Configure contextual text displays with optional keybind hints.

Usage Example:

Configure hierarchical navigation menus with search and dynamic content.

Input Dialogs

Configure input dialogs for collecting user data.

Alert Dialogs

Configure alert and confirmation dialogs.

Context Menus

Configure position-based context menus for right-click interactions.

Skillcheck Minigame

Configure the timing-based skillcheck minigame system with single-zone design.

Component Styling

Detailed styling configurations for each UI component. These settings control the visual appearance and layout.

Notification Styling

Progress Bar Styling

Skillcheck Styling

Lockpicking Styling

Radial Menu Configuration

Comprehensive configuration for the radial menu system.

Basic Settings

The radial menu uses a hierarchical structure with nested items:

Menu Item Properties:

  • id - Unique identifier for the menu item

  • title - Display text for the item

  • icon - Icon to display (emoji or icon name)

  • items - Submenu items (for nested menus)

  • type - Event type ('client' or 'server')

  • event - Event name to trigger

  • shouldClose - Whether to close menu after selection

  • data - Additional data to pass with the event

Performance Configuration

Optimize B2Lib performance based on your server's requirements.

Performance Tips

  1. Reduce maxNotifications for lower-end clients

  2. Increase updateInterval to 33ms (30 FPS) for better performance

  3. Disable fadeAnimations on servers with many players

  4. Lower raycastDistance to reduce CPU usage

  5. Adjust maxCacheSize based on available memory

Debug Configuration

Configure debugging and logging options for development and troubleshooting.

Log Levels

Level
Description

error

Only critical errors

warn

Warnings and errors

info

General information, warnings, and errors

debug

All messages including detailed debugging information

Custom Themes

Create custom themes by modifying the color palette:

Best Practices

Configuration Management

  1. Backup Configuration - Always backup Config.lua before making changes

  2. Test Changes - Test configuration changes on a development server first

  3. Document Modifications - Keep track of custom changes for future updates

  4. Use Version Control - Store configuration in version control for team collaboration

Performance Optimization

  1. Monitor Performance - Enable performance metrics during testing

  2. Optimize for Your Server - Adjust settings based on player count and hardware

  3. Disable Unused Components - Turn off components you don't use

  4. Regular Maintenance - Review and optimize settings periodically

Theme Customization

  1. Maintain Contrast - Ensure sufficient contrast for accessibility

  2. Test All Components - Verify theme changes work across all UI components

  3. Consider Use Cases - Different themes for different times of day or events

  4. User Preferences - Allow players to choose their preferred theme

Troubleshooting

Common Issues

UI Components Not Showing:

  1. Check Config.EnabledComponents settings

  2. Verify position values are valid

  3. Check console for error messages

  4. Ensure resource is properly started

Performance Issues:

  1. Reduce maxNotifications and maxCacheSize

  2. Increase updateInterval to 33ms

  3. Disable fadeAnimations

  4. Lower raycastDistance and entityCheckDistance

Theme Issues:

  1. Verify color values are valid CSS colors

  2. Check theme mode is set correctly

  3. Ensure all required color properties are defined

  4. Test with default theme first

Styling Problems:

  1. Check CSS unit values (px, rem, %)

  2. Verify theme references are correct

  3. Test with default styling first

  4. Check browser developer tools for CSS errors


Last updated