Skip to content

@tool YggdrasilAllocationService API

Service for allocating, preallocating, refunding, and deallocating nodes in YggdrasilTreeView.


Signals

Name
node_preallocated(node: YggdrasilNodeButton)
node_unpreallocated(node: YggdrasilNodeButton)
node_allocated(node: YggdrasilNodeButton)
node_deallocated(node: YggdrasilNodeButton)
refund_mode_entered()
refund_mode_exited()
node_refund_added(node: YggdrasilNodeButton)
node_refund_removed(node: YggdrasilNodeButton)

Properties

Type Name Default
Callable preallocation_check Callable()
Callable allocation_check Callable()
Callable deallocation_check Callable()
Callable refund_check Callable()
Array[int] _preallocated_nodes []
Array[int] _refund_nodes []
bool _refund_mode false

Methods

Type Name
void load_tree(tree_data: YggdrasilTree)
void on_node_pressed(node: YggdrasilNodeButton)
void confirm_preallocations()
void clear_preallocations()
void enter_refund_mode()
void exit_refund_mode()
void confirm_refund()
bool is_refund_mode()
Array[int] get_refund_nodes()

Signal Descriptions

node_preallocated(node: YggdrasilNodeButton)

Emitted when a node is marked as preallocated.

node_unpreallocated(node: YggdrasilNodeButton)

Emitted when a node is removed from the preallocated state.

node_allocated(node: YggdrasilNodeButton)

Emitted when a node becomes allocated.

node_deallocated(node: YggdrasilNodeButton)

Emitted when a node becomes deallocated.

refund_mode_entered()

Emitted when refund mode is entered.

refund_mode_exited()

Emitted when refund mode is exited.

node_refund_added(node: YggdrasilNodeButton)

Emitted when a node is staged for refund.

node_refund_removed(node: YggdrasilNodeButton)

Emitted when a node is removed from the refund list.

Property Descriptions

Callable preallocation_check = Callable()

Optional callback used to validate whether preallocation is allowed.

Callable allocation_check = Callable()

Optional callback used to validate whether allocation is allowed.

Callable deallocation_check = Callable()

Optional callback used to validate whether deallocation is allowed.

Callable refund_check = Callable()

Optional callback used to validate whether refund staging is allowed.

Array[int] _preallocated_nodes = []

Stores ids of currently preallocated nodes.

Array[int] _refund_nodes = []

Stores ids of nodes currently staged for refund.

bool _refund_mode = false

Tracks whether refund mode is active.

Method Descriptions

void load_tree(tree_data: YggdrasilTree)

Loads allocation state from tree_data.tree_state.allocated_nodes, marks matching nodes as allocated, updates their state to active, and emits node_allocated.

void on_node_pressed(node: YggdrasilNodeButton)

Handles node press behavior for allocation, preallocation, refund staging, refund unstaging, or deallocation depending on current tree settings and refund mode.

void confirm_preallocations()

Converts all preallocated nodes into allocated nodes, emits node_allocated for each one, and clears the preallocation list.

void clear_preallocations()

Clears all preallocated nodes, emits node_unpreallocated for each one, and empties the preallocation list.

void enter_refund_mode()

Enables refund mode, clears staged refund nodes, and emits refund_mode_entered.

void exit_refund_mode()

Clears staged refund nodes, emits node_refund_removed for each one, disables refund mode, and emits refund_mode_exited.

void confirm_refund()

Deallocates all nodes staged for refund, clears the refund list, disables refund mode, and emits refund_mode_exited.

bool is_refund_mode()

Returns whether refund mode is currently active.

Array[int] get_refund_nodes()

Returns a duplicate of the current refund node id list.