extends HBoxContainer class_name OwniverseAction signal action_pressed(page_id, amount: float) @onready var action_labels: Array = [ $ActionControl0/Label, $ActionControl1/Label, $ActionControl2/Label, $ActionControl3/Label, $ActionControl4/Label, ] var page_id: int = -1 var current_item_id = "" var action_values: Dictionary = { 0: 0, 1: 0, 2: 0, 3: 0, 4: 0, } func set_actions(item_id: String, value: float) -> void: current_item_id = item_id _set_action_values(_get_distribution(value)) func _get_distribution(value: float) -> Array: var distribution: Array = [value, 0, 0, 0, 0] var exp_value = int(floor(log(abs(value)) / log(10.0))) var floor_value = max(exp_value - 4, -1) for ev in range(exp_value, floor_value, -1): distribution.push_front(pow(10.0, ev)) return distribution func _set_action_values(values: Array) -> void: for ind in range(0, 5): action_values[ind] = values[ind] action_labels[ind].text = Global.format_number(values[ind]) if values[ind] > 0 else "" func _on_action_button_pressed(button_id: int) -> void: action_pressed.emit(page_id, action_values[button_id])