Add radial command menu for minions
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
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
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
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
|
||||
@@ -0,0 +1 @@
|
||||
uid://cjfhlslc5vp7b
|
||||
@@ -0,0 +1,42 @@
|
||||
[gd_scene format=3 uid="uid://bnwpu7p8sbsfa"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://cjfhlslc5vp7b" path="res://scenes/Interaction/RadialCommandMenu.gd" id="1_j0xof"]
|
||||
|
||||
[node name="RadialCommandCanvas" type="CanvasLayer" unique_id=1002896311]
|
||||
|
||||
[node name="PivotControl" type="Control" parent="." unique_id=374070149]
|
||||
layout_mode = 3
|
||||
anchors_preset = 8
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
offset_left = -20.0
|
||||
offset_top = -20.0
|
||||
offset_right = 20.0
|
||||
offset_bottom = 20.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
script = ExtResource("1_j0xof")
|
||||
|
||||
[node name="BtnFollow" type="Button" parent="PivotControl" unique_id=1839549428]
|
||||
layout_mode = 0
|
||||
offset_right = 8.0
|
||||
offset_bottom = 8.0
|
||||
text = "Follow"
|
||||
|
||||
[node name="BtnGoTo" type="Button" parent="PivotControl" unique_id=818273339]
|
||||
layout_mode = 0
|
||||
offset_right = 8.0
|
||||
offset_bottom = 8.0
|
||||
text = "Go To"
|
||||
|
||||
[node name="BtnAttack" type="Button" parent="PivotControl" unique_id=744805255]
|
||||
layout_mode = 0
|
||||
offset_right = 8.0
|
||||
offset_bottom = 8.0
|
||||
text = "Attack"
|
||||
|
||||
[connection signal="pressed" from="PivotControl/BtnFollow" to="PivotControl" method="_on_btn_follow_pressed"]
|
||||
[connection signal="pressed" from="PivotControl/BtnGoTo" to="PivotControl" method="_on_btn_go_to_pressed"]
|
||||
[connection signal="pressed" from="PivotControl/BtnAttack" to="PivotControl" method="_on_btn_attack_pressed"]
|
||||
Reference in New Issue
Block a user