promiscuity/game/scenes/Interaction/RadialCommandMenu.gd
Lucas 98220921bd
All checks were successful
Deploy Promiscuity Auth API / deploy (push) Successful in 51s
Deploy Promiscuity Character API / deploy (push) Successful in 49s
Deploy Promiscuity Crafting API / deploy (push) Successful in 47s
Deploy Promiscuity Inventory API / deploy (push) Successful in 48s
Deploy Promiscuity Locations API / deploy (push) Successful in 47s
Deploy Promiscuity Mail API / deploy (push) Successful in 49s
Deploy Promiscuity World API / deploy (push) Successful in 48s
k8s smoke test / test (push) Successful in 9s
Add radial command menu for minions
2026-05-01 12:24:54 -05:00

57 lines
1.5 KiB
GDScript

extends Control
@export var radius: float = 150.0
@export var transition_speed: float = 0.2
func _ready():
hide() # Start hidden
_arrange_buttons()
func _input(event):
if event.is_action_pressed("OpenRadialCommandMenu"): # Map 'Q' to "open_menu" in Input Map
_toggle_menu()
func _toggle_menu():
visible = !visible
if visible:
# Center the menu on the mouse or screen
global_position = get_viewport().get_mouse_position()
_animate_menu(true)
else:
_animate_menu(false)
func _arrange_buttons():
var buttons = get_children()
var count = buttons.size()
for i in range(count):
# Calculate the angle for each button in radians
var angle = i * (2 * PI / count)
# Standard circle math: x = cos(a) * r, y = sin(a) * r
var target_pos = Vector2(cos(angle), sin(angle)) * radius
# Offset by button size to keep them centered
buttons[i].position = target_pos - (buttons[i].size / 2)
func _animate_menu(opening: bool):
var tween = create_tween().set_parallel(true)
for button in get_children():
var final_scale = Vector2.ONE if opening else Vector2.ZERO
tween.tween_property(button, "scale", final_scale, transition_speed).from(Vector2.ZERO if opening else Vector2.ONE)
func _on_btn_follow_pressed() -> void:
print("Follow command pressed")
_toggle_menu() # Closes the menu after clicking
func _on_btn_go_to_pressed() -> void:
print("Go to command pressed")
_toggle_menu() # Closes the menu after clicking
func _on_btn_attack_pressed() -> void:
print("Attack command pressed")
_toggle_menu() # Closes the menu after clicking