UIStateManager
Handles UI state management for AtomicPanes. Designed as a standalone state manager that controls which UI components are visible based on named states.
Functions
SetState
UIStateManager:SetState(state: string,--
The name of the state to transition to
forceState: boolean?,--
If true, bypasses any block rules on the current state
) → (boolean,--
Whether the state was successfully set
string?--
The reason the state was blocked, if applicable
)
Sets the current UI state. Hides and shows registered components according
to the state's StateProperties. Returns false and a reason string if
the transition is blocked by the current state.
RegisterState
UIStateManager:RegisterState(name: string,--
The name to register the state under
) → ()Types
interface StateProperties {Hides: {string}?--
Component names to hide when this state is active. Use "*" to hide all.
Shows: {string}?--
Component names to show when this state is active. Use "*" to show all.
CoreGui: {Shows: {string}?,Hides: {string}?}?--
CoreGui elements to show or hide
Blocks: {string}?--
State names that cannot be transitioned to from this state. Use "*" to block all.
GamepadCursorEnabled: boolean?--
Whether the gamepad cursor should be enabled in this state
}Registers a new UI state with the given name and properties. If a state with the same name already exists, registration is skipped with a warning.
RegisterComponent
UIStateManager:RegisterComponent(name: string,--
The name to register the component under
class: {}--
The component object, must have :Show() and :Hide() methods
) → ()
Registers a UI component under the given name so it can be referenced in
state configurations. The component must implement :Show() and :Hide()
methods. If a component with the same name is already registered, the
registration is skipped with a warning.
UnregisterComponent
UIStateManager:UnregisterComponent(name: string,--
The name the component was registered under
class: {}--
The original class reference used during registration
) → ()Unregisters a previously registered UI component by name. Does nothing if the component is not registered or was registered under a different class reference.
GetState
UIStateManager:GetState() → stringReturns the name of the current UI state.
IsComponentShowing
UIStateManager:IsComponentShowing(name: string--
The name of the registered component to check
) → booleanReturns whether the named component is currently visible.
PreviousState
UIStateManager:PreviousState() → ()Reverts to the previous UI state, if one exists.
SetDefault
UIStateManager:SetDefault() → (boolean?,--
true on success, nil if no default is registered
string?--
The reason for failure, if applicable
)
Sets the current state to the registered default state. Returns nil and
a reason string if no default state has been registered.
RegisterDefaultState
UIStateManager:RegisterDefaultState(name: string--
The name of the state to use as the default
) → (boolean?,--
true on success, nil if the state does not exist
string?--
The reason for failure, if applicable
)
Registers the named state as the default state for :SetDefault(). Returns
nil and a reason string if the state has not been registered.
RegisterEventHook
UIStateManager:RegisterEventHook(eventName: string,--
The name of the event to hook into
callback: function--
Called with (newState, oldState) when the event fires
) → ()Registers a callback to be invoked when the specified event occurs.
Valid event names and their callback argument order:
StateChange(newState, oldState)BeforeStateChange(oldState, newState)AfterStateChange(newState, oldState)CoreGuiChange(newState, oldState)
UIStateManager:RegisterEventHook("StateChange", function(newState, oldState)
print("UI State changed to:", newState)
end)