diff --git a/godot/combat/interface/CombatInterface.gd b/godot/combat/interface/CombatInterface.gd index d93e15f9cb1db75c19dd2bac4617bc0939b9140c..83d5018948f038f20c238de7afc3feaa8a886fb4 100644 --- a/godot/combat/interface/CombatInterface.gd +++ b/godot/combat/interface/CombatInterface.gd @@ -21,6 +21,7 @@ func open_actions_menu(battler : Battler) -> void: var extents : RectExtents = battler.skin.get_extents() menu.rect_position = battler.global_position - Vector2(0.0, extents.size.y) + buttons_offset menu.initialize(battler) + menu.open() var selected_action : CombatAction = yield(menu, "action_selected") emit_signal("action_selected", selected_action) diff --git a/godot/combat/interface/circular_menu/CircularButton.gd b/godot/combat/interface/circular_menu/CircularButton.gd index 8cfb3fa36d28440f89394ca4eee9fc9b08c3b113..69554ed40ecb5e456e27978f25bf84ae43755802 100644 --- a/godot/combat/interface/circular_menu/CircularButton.gd +++ b/godot/combat/interface/circular_menu/CircularButton.gd @@ -15,13 +15,25 @@ func initialize(action : CombatAction, target_position : Vector2, active : bool) connect('mouse_exited', self, '_on_mouse_exited') connect('mouse_entered', self, '_on_mouse_entered') -func _on_mouse_entered() -> void: +func enter_focus(): raise() tooltip.show() animation_player.play('activate') yield(animation_player, "animation_finished") animation_player.play('active') -func _on_mouse_exited() -> void: +func exit_focus(): tooltip.hide() animation_player.play('deactivate') + +func _on_mouse_entered() -> void: + enter_focus() + +func _on_mouse_exited() -> void: + exit_focus() + +func _on_focus_entered() -> void: + enter_focus() + +func _on_focus_exited() -> void: + exit_focus() diff --git a/godot/combat/interface/circular_menu/CircularButton.tscn b/godot/combat/interface/circular_menu/CircularButton.tscn index f9797edd24c5e180b4fec1e116e6971dca804784..d8a6f766f2c706b40bee105c162e747bff1bea46 100644 --- a/godot/combat/interface/circular_menu/CircularButton.tscn +++ b/godot/combat/interface/circular_menu/CircularButton.tscn @@ -9,44 +9,43 @@ [ext_resource path="res://interface/theme/icons/sword.png" type="Texture" id=7] [ext_resource path="res://combat/interface/circular_menu/background-selected.png" type="Texture" id=8] -[sub_resource type="StyleBoxEmpty" id=4] +[sub_resource type="StyleBoxEmpty" id=9] content_margin_left = -1.0 content_margin_right = -1.0 content_margin_top = -1.0 content_margin_bottom = -1.0 -[sub_resource type="StyleBoxEmpty" id=5] +[sub_resource type="StyleBoxEmpty" id=10] content_margin_left = -1.0 content_margin_right = -1.0 content_margin_top = -1.0 content_margin_bottom = -1.0 -[sub_resource type="StyleBoxEmpty" id=6] +[sub_resource type="StyleBoxEmpty" id=11] content_margin_left = -1.0 content_margin_right = -1.0 content_margin_top = -1.0 content_margin_bottom = -1.0 -[sub_resource type="StyleBoxEmpty" id=7] +[sub_resource type="StyleBoxEmpty" id=4] content_margin_left = -1.0 content_margin_right = -1.0 content_margin_top = -1.0 content_margin_bottom = -1.0 -[sub_resource type="StyleBoxEmpty" id=8] +[sub_resource type="StyleBoxEmpty" id=5] content_margin_left = -1.0 content_margin_right = -1.0 content_margin_top = -1.0 content_margin_bottom = -1.0 -[sub_resource type="Animation" id=1] +[sub_resource type="Animation" id=6] -resource_name = "activate" length = 0.2 loop = false step = 0.1 @@ -75,7 +74,7 @@ tracks/1/keys = { "values": [ ExtResource( 5 ), ExtResource( 8 ) ] } -[sub_resource type="Animation" id=2] +[sub_resource type="Animation" id=7] length = 1.0 loop = true @@ -93,9 +92,8 @@ tracks/0/keys = { "values": [ 0.0, 360.0 ] } -[sub_resource type="Animation" id=3] +[sub_resource type="Animation" id=8] -resource_name = "deactivate" length = 0.2 loop = false step = 0.1 @@ -141,11 +139,11 @@ mouse_filter = 1 mouse_default_cursor_shape = 0 size_flags_horizontal = 1 size_flags_vertical = 1 -custom_styles/hover = SubResource( 4 ) -custom_styles/pressed = SubResource( 5 ) -custom_styles/focus = SubResource( 6 ) -custom_styles/disabled = SubResource( 7 ) -custom_styles/normal = SubResource( 8 ) +custom_styles/hover = SubResource( 9 ) +custom_styles/pressed = SubResource( 10 ) +custom_styles/focus = SubResource( 11 ) +custom_styles/disabled = SubResource( 4 ) +custom_styles/normal = SubResource( 5 ) toggle_mode = false enabled_focus_mode = 2 shortcut = null @@ -281,8 +279,10 @@ autoplay = "" playback_process_mode = 1 playback_default_blend_time = 0.0 playback_speed = 1.0 -anims/activate = SubResource( 1 ) -anims/active = SubResource( 2 ) -anims/deactivate = SubResource( 3 ) +anims/activate = SubResource( 6 ) +anims/active = SubResource( 7 ) +anims/deactivate = SubResource( 8 ) blend_times = [ ] +[connection signal="focus_entered" from="." to="." method="_on_focus_entered"] +[connection signal="focus_exited" from="." to="." method="_on_focus_exited"] diff --git a/godot/combat/interface/circular_menu/CircularMenu.gd b/godot/combat/interface/circular_menu/CircularMenu.gd index a3c6f237a36c5040847d2224c297e43da18223b3..45e2736123ed8e2a3146ab3d3a329793faa6a423 100644 --- a/godot/combat/interface/circular_menu/CircularMenu.gd +++ b/godot/combat/interface/circular_menu/CircularMenu.gd @@ -29,6 +29,18 @@ func initialize(actor : Battler) -> void: func open(): show() + var first_button = get_child(0) + first_button.grab_focus() + +func _unhandled_input(event: InputEvent) -> void: + if event.is_action_pressed("ui_right") or event.is_action_pressed("ui_focus_next"): + var next_button_index = (get_focus_owner().get_index() + 1) % get_child_count() + get_child(next_button_index).grab_focus() + accept_event() + if event.is_action_pressed("ui_left") or event.is_action_pressed("ui_focus_prev"): + var next_button_index = (get_focus_owner().get_index() - 1 + get_child_count()) % get_child_count() + get_child(next_button_index).grab_focus() + accept_event() func close(): queue_free()