Global notification system for displaying messages, achievements, and experience gains to the player.
[heading: "Description"]NotificationSystem provides a centralized way to display temporary messages to the player. It handles queuing, automatic text wrapping, state-aware display, smooth animations, and specialized notifications for achievements and experience gains.
[heading: "Key Features"] [list] * Automatic message queuing * Smart text wrapping * State-aware display restrictions * Smooth fade animations * Preserved notifications across state changes * Achievement notifications with custom styling * Experience gain notifications with animated progress bar * Level up effects [/list] [heading: "Methods"] [table header] [ Method | Parameters | Description ] [ constructor | () | Initializes notification system ] [ setupStateChangeHandling | () | Sets up state transition tracking ] [ onStateChange | (newState) | Handles game state changes ] [ show | (text, duration) | Queues text notification ] [ showAchievement | (achievement, expGain) | Queues achievement notification ] [ showExpGain | (character, expGain, levelBefore, levelAfter, expBefore, expAfter) | Queues experience gain notification ] [ processPendingNotifications | () | Processes queued notifications ] [ processNext | () | Displays next notification in queue ] [ displayTextNotification | (text) | Creates text notification display ] [ displayExpNotification | (notification) | Creates experience notification with animated bar ] [ animateExpBar | (notification, expBar, barWidth) | Animates experience bar filling ] [ showLevelUpEffect | (level) | Shows level up text effect ] [ wrapText | (text) | Wraps text to fit window ] [ breakLongWord | (word) | Breaks very long words ] [ getTextWidth | (text) | Calculates text pixel width ] [ preserveCurrentNotification | () | Saves current notification during state change ] [ restorePreservedNotification | () | Restores saved notification ] [ hideCurrent | () | Hides current notification ] [ cleanupUI | () | Removes notification elements ] [ isStateAllowed | (stateName) | Checks if state permits notifications ] [ clear | () | Clears all notifications ] [ destroy | () | Cleans up notification system ] [/table] [heading: "Properties"] [table header] [ Property | Type | Description ] [ queue | Array | Notification queue ] [ isShowing | Boolean | Whether notification is currently displayed ] [ currentNotification | Object | Currently displayed notification ] [ duration | Number | Default display duration ] [ lineHeight | Number | Line height in pixels (8) ] [ padding | Number | Text padding (8) ] [ maxLineWidth | Number | Maximum text width before wrapping (160) ] [ charWidth | Number | Average character width (4) ] [ restrictedStates | Set | States where notifications are blocked ] [ allowedStates | Set | States where notifications are permitted ] [ notificationWindow | Window | Notification display window ] [ notificationTexts | Array | Text elements for notification ] [ preservedNotification | Object | Notification saved during state change ] [/table] [heading: "State Restrictions"] [table header] [ State | Allowed | Reason ] [ MainMenu | Yes | User is navigating menus ] [ SongSelect | Yes | User is selecting songs ] [ Results | Yes | Showing performance results ] [ CharacterSelect | Yes | Character management ] [ Settings | Yes | Settings menu ] [ Addons | Yes | Addon manager ] [ Title | No | Initial loading screen ] [ Play | No | Gameplay in progress ] [ Load states | No | Loading screens ] [ Boot | No | Initial boot sequence ] [/table] [heading: "Notification Types"] [table header] [ Type | Duration | Special Features ] [ text | 2000ms | Standard text message ] [ achievement | 2500ms | Achievement name and description ] [ exp | 5000ms | Animated experience bar, level up effects ] [/table] [heading: "Example Usage"] [codeblock javascript] // Text notification notifications.show("Hello, world!", 2000); // Achievement notification notifications.showAchievement({ name: "First Game", description: { achieved: "You completed your first game!" } }); // Experience gain notification notifications.showExpGain(character, 25, 1, 2, 10, 5); // Check if notification can be shown if (notifications.isStateAllowed("MainMenu")) { notifications.show("Welcome!"); } [/codeblock] [footer: "© Retora 2026"]