ScrapbookToast
Based on game build 714014 | Last updated: 2026-03-08
Overview
ScrapbookToast is a UI widget component responsible for presenting a dynamic notification when the player's scrapbook receives a new entry. It controls the visibility and behavior of a toast icon (tab_gift) that appears in the HUD, plays a sound, and launches the scrapbook screen when clicked. The component integrates with the player HUD, global profile settings, and HUD focus state to conditionally show or hide the notification.
Usage example
-- Typically instantiated by the HUD system:
local toast = ScrapbookToast(ThePlayer, ThePlayer.HUD:GetControls())
-- The component listens for "scrapbookupdated" events and updates automatically.
Dependencies & tags
Components used: None identified
Tags: None added, removed, or checked.
Properties
| Property | Type | Default Value | Description |
|---|---|---|---|
controls | table | nil | Reference to the parent HUD controls manager, used to show/hide the toast via ManageToast. |
owner | entity | nil | The entity (player) that owns this toast instance. |
tab_gift | UIAnimButton | nil | The interactive button widget representing the toast icon. |
hasnewupdate | boolean | false | Flag indicating whether a new scrapbook entry is pending notification. |
controller_hide | boolean | false | When true, hides the toast due to controller mode. |
craft_hide | boolean | false | When true, hides the toast while crafting UI is active. |
opened | boolean | false | Tracks whether the toast is currently shown. |
hud_focus | boolean | owner.HUD.focus | Reflects the HUD focus state (e.g., inventory open). |
shownotification | boolean | Profile:GetScrapbookHudDisplay() | Controls whether the toast should be shown based on user profile settings. |
Main functions
UpdateElements()
- Description: Checks internal state (
hasnewupdate,controller_hide,craft_hide,shownotification) and toggles the toast visibility accordingly. If a new update is pending, it shows the toast, plays the scrapbook dropdown sound, starts thepreanimation ontab_gift, and marks the toast as opened. - Parameters: None.
- Returns: Nothing.
ToggleHUDFocus(focus)
- Description: Updates the
hud_focusproperty to reflect whether the HUD is currently focused (e.g., inventory or menu active). Used to adjust toast behavior based on context. - Parameters:
focus(boolean) — whether the HUD has focus. - Returns: Nothing.
ToggleController(hide)
- Description: Sets the
controller_hideflag. Whentrue, prevents the toast from showing during controller navigation. CallsUpdateElements()to apply the change. - Parameters:
hide(boolean) — iftrue, hides the toast for controller input. - Returns: Nothing.
ToggleCrafting(hide)
- Description: Sets the
craft_hideflag. Whentrue, suppresses toast visibility during crafting UI activity. CallsUpdateElements()to apply the change. - Parameters:
hide(boolean) — iftrue, hides the toast while crafting. - Returns: Nothing.
CheckControl(control, down)
- Description: Handles direct control input (e.g., keyboard shortcuts) to open the scrapbook. Returns
trueif the control was consumed. - Parameters:
control(number) — the control code (e.g.,CONTROL_INSPECT_SELF).down(boolean) — whether the control key was pressed (true) or released (false).
- Returns:
trueif the control matchesCONTROL_INSPECT_SELFanddownistrue; otherwisenil. - Error states: Returns
nilif the toast is not visible (self.shownis falsy) or the control does not match.
Events & listeners
- Listens to:
scrapbookupdated(onThePlayer) — setshasnewupdate = trueand callsUpdateElements().continuefrompause(onTheWorld) — refreshesshownotificationfromProfile:GetScrapbookHudDisplay()and callsUpdateElements().scrapbookopened(onThePlayer) — setshasnewupdate = false, hidestab_gift, and callsManageToast(..., true)if the toast was previously opened.animover(ontab_gift.inst) — plays theidleanimation automatically when thepreanimation completes.
- Pushes:
ScrapbookToastdoes not fire any custom events.