full gamepad support

This commit is contained in:
Rendo 2025-07-28 18:03:26 +05:00
commit a57d79e84a
21 changed files with 213 additions and 46 deletions

View file

@ -1,5 +1,24 @@
extends TabContainer
var stolen_focus : Control
func _ready() -> void:
get_viewport().gui_focus_changed.connect(on_focus_changed)
visibility_changed.connect(on_visibility_changed)
func _exit_tree() -> void:
get_viewport().gui_focus_changed.disconnect(on_focus_changed)
func _on_quit_button_pressed() -> void:
visible = false
$ChannelPlayer.call("Play")
func on_visibility_changed():
if visible:
await get_tree().process_frame
$plants/SeedpacketsContainer/GridContainer.get_child(0).grab_focus()
else:
stolen_focus.grab_focus()
func on_focus_changed(to : Control):
if visible: return
stolen_focus = to

View file

@ -12,12 +12,12 @@
[sub_resource type="ViewportTexture" id="ViewportTexture_ru62c"]
viewport_path = NodePath("plants/Infobox/FrameAndTitle/VboxContainer/Frame/Previewport")
[sub_resource type="InputEventAction" id="InputEventAction_vvhxq"]
action = &"ui_cancel"
[sub_resource type="InputEventJoypadButton" id="InputEventJoypadButton_vvhxq"]
button_index = 1
pressed = true
[sub_resource type="Shortcut" id="Shortcut_lmmwe"]
events = [SubResource("InputEventAction_vvhxq")]
events = [SubResource("InputEventJoypadButton_vvhxq")]
[sub_resource type="ViewportTexture" id="ViewportTexture_7yl8g"]
viewport_path = NodePath("zombies/Infobox/FrameAndTitle/VBoxContainer/Frame/Previewport")
@ -180,6 +180,7 @@ expand_mode = 1
[node name="QuitButton" type="Button" parent="zombies/Infobox/FrameAndTitle/VBoxContainer"]
layout_mode = 2
size_flags_vertical = 4
shortcut = SubResource("Shortcut_lmmwe")
text = "exit"
[node name="Label" type="Label" parent="zombies/Infobox/FrameAndTitle"]

View file

@ -1,4 +1,4 @@
[gd_scene load_steps=20 format=3 uid="uid://dpxxjfd5lv5sv"]
[gd_scene load_steps=23 format=3 uid="uid://dpxxjfd5lv5sv"]
[ext_resource type="Theme" uid="uid://e8n88g31w7x7" path="res://assets/themes/ChooseYourSeeds.tres" id="1_bfo8i"]
[ext_resource type="Texture2D" uid="uid://dr8a0rx42o3qy" path="res://assets/sprites/gui/ChooseYourSeeds/PlantFrame.tres" id="2_so2bw"]
@ -7,13 +7,16 @@
[ext_resource type="Script" uid="uid://eq3ecja30mlj" path="res://scripts/gui/choose_your_seeds/GridLoader.cs" id="4_i7sou"]
[ext_resource type="PackedScene" uid="uid://10b1egek6upx" path="res://scenes/gui/level_run_button.tscn" id="5_n80ic"]
[ext_resource type="Script" uid="uid://d26waisd3v488" path="res://scripts/gui/choose_your_seeds/LevelRunButton.cs" id="7_k6b6g"]
[ext_resource type="Texture2D" uid="uid://y2hhywmmy0t5" path="res://assets/sprites/lehauico.png" id="8_f8xw6"]
[ext_resource type="Texture2D" uid="uid://drydueofrb448" path="res://assets/sprites/gui/almanach/book.tres" id="8_hmdmm"]
[ext_resource type="Script" uid="uid://c36bj8u7jghc7" path="res://scripts/audio/ChannelPlayer.cs" id="8_v7xff"]
[ext_resource type="Script" uid="uid://diwjgekhvn017" path="res://scripts/gui/choose_your_seeds/CYSResetButton.cs" id="9_kwnqh"]
[ext_resource type="AudioStream" uid="uid://bdx83fokp6kha" path="res://assets/audio/sfx/buttonclick.mp3" id="9_v7xff"]
[ext_resource type="Script" uid="uid://c1x4n4nqyq72f" path="res://scripts/audio/ChannelSettings.cs" id="10_nlh6x"]
[ext_resource type="PackedScene" uid="uid://bvpt0q4j6nx18" path="res://scenes/gui/almanach.tscn" id="11_nlh6x"]
[ext_resource type="AudioStream" uid="uid://mu86q1r1dvgo" path="res://assets/audio/music/03. Choose Your Seeds.mp3" id="13_y65t1"]
[ext_resource type="Script" uid="uid://b4ysi1iutmju3" path="res://scripts/audio/ChooseYourSeedsMusic.cs" id="14_rptyw"]
[ext_resource type="Script" uid="uid://bksslrqq5vhm3" path="res://scripts/gui/choose_your_seeds/CYSFocusSetup.cs" id="15_rptyw"]
[sub_resource type="ViewportTexture" id="ViewportTexture_rmoaa"]
viewport_path = NodePath("Panel/MarginContainer/VBoxContainer/HBoxContainer/Frame/Previewport")
@ -28,8 +31,8 @@ script/source = "extends Button
func _pressed() -> void:
$\"../../Independer/Almanach\".visible = true
$\"../../ChannelPlayer\".call(\"Play\")
$\"../../../Independer/Almanach\".visible = true
$\"../../../ChannelPlayer\".call(\"Play\")
"
[sub_resource type="Resource" id="Resource_l66rp"]
@ -114,6 +117,7 @@ size_flags_horizontal = 3
[node name="ScrollContainer" type="ScrollContainer" parent="Panel/MarginContainer/VBoxContainer/HBoxContainer/PanelContainer"]
layout_mode = 2
focus_mode = 2
horizontal_scroll_mode = 0
[node name="VBoxContainer" type="VBoxContainer" parent="Panel/MarginContainer/VBoxContainer/HBoxContainer/PanelContainer/ScrollContainer"]
@ -141,22 +145,33 @@ layout_mode = 2
columns = 7
script = ExtResource("4_i7sou")
[node name="LevelRunButton" parent="Panel" instance=ExtResource("5_n80ic")]
[node name="ButtonContainer" type="VBoxContainer" parent="Panel"]
layout_mode = 1
anchors_preset = -1
anchor_left = 1.0
anchor_right = 1.181
anchor_bottom = 0.131
offset_right = -16.16
offset_bottom = -16.016
anchor_right = 1.18889
anchor_bottom = 0.997024
grow_vertical = 2
metadata/_edit_use_anchors_ = true
[node name="LevelRunButton" parent="Panel/ButtonContainer" instance=ExtResource("5_n80ic")]
layout_mode = 2
focus_neighbor_left = NodePath("../../MarginContainer/VBoxContainer/HBoxContainer/PanelContainer/ScrollContainer")
focus_neighbor_bottom = NodePath("../Button")
script = ExtResource("7_k6b6g")
[node name="AlmanachButton" type="Button" parent="Panel"]
layout_mode = 0
anchor_left = 1.0
anchor_top = 0.883929
anchor_right = 1.14167
anchor_bottom = 1.0
offset_bottom = -3.05176e-05
[node name="Button" type="Button" parent="Panel/ButtonContainer"]
layout_mode = 2
focus_neighbor_top = NodePath("../LevelRunButton")
focus_neighbor_bottom = NodePath("../AlmanachButton")
icon = ExtResource("8_f8xw6")
icon_alignment = 1
script = ExtResource("9_kwnqh")
[node name="AlmanachButton" type="Button" parent="Panel/ButtonContainer"]
layout_mode = 2
focus_neighbor_left = NodePath("../../MarginContainer/VBoxContainer/HBoxContainer/PanelContainer/ScrollContainer")
focus_neighbor_top = NodePath("../Button")
icon = ExtResource("8_hmdmm")
icon_alignment = 1
script = SubResource("GDScript_hmdmm")
@ -180,4 +195,10 @@ autoplay = true
bus = &"MusicBus"
script = ExtResource("14_rptyw")
[connection signal="pressed" from="Panel/LevelRunButton" to="ChannelPlayer" method="Play"]
[node name="FocusSetup" type="Node" parent="." node_paths=PackedStringArray("grid", "button", "textContainer")]
script = ExtResource("15_rptyw")
grid = NodePath("../Panel/MarginContainer/VBoxContainer/ScrollContainer/GridContainer")
button = NodePath("../Panel/ButtonContainer/LevelRunButton")
textContainer = NodePath("../Panel/MarginContainer/VBoxContainer/HBoxContainer/PanelContainer/ScrollContainer")
[connection signal="pressed" from="Panel/ButtonContainer/LevelRunButton" to="ChannelPlayer" method="Play"]

View file

@ -1,7 +1,7 @@
[gd_scene load_steps=3 format=3 uid="uid://u5l3jd00s8vd"]
[ext_resource type="Texture2D" uid="uid://dm0hjd67a6mva" path="res://assets/sprites/gui/Pause.tres" id="1_7k3tg"]
[ext_resource type="Script" uid="uid://cmfhiun6yrlr6" path="res://scripts/gui/PauseButton.cs" id="2_01o3l"]
[ext_resource type="Script" uid="uid://cmfhiun6yrlr6" path="res://scripts/gui/pause_menu/PauseButton.cs" id="2_01o3l"]
[node name="PauseButton" type="Button"]
anchors_preset = -1

View file

@ -1,7 +1,7 @@
[gd_scene load_steps=11 format=3 uid="uid://fm471x22n8kr"]
[ext_resource type="Texture2D" uid="uid://dvldjlg0nr355" path="res://assets/sprites/atlases/atlas1.png" id="1_loim0"]
[ext_resource type="Script" uid="uid://gvwhpjoame6m" path="res://scripts/gui/PauseMenu.cs" id="2_4vp8g"]
[ext_resource type="Script" uid="uid://gvwhpjoame6m" path="res://scripts/gui/pause_menu/PauseMenu.cs" id="2_4vp8g"]
[ext_resource type="Script" uid="uid://c36bj8u7jghc7" path="res://scripts/audio/ChannelPlayer.cs" id="3_4vp8g"]
[ext_resource type="Script" uid="uid://ciccaxqo70s13" path="res://scripts/audio/AudioSlider.cs" id="3_e3p60"]
[ext_resource type="AudioStream" uid="uid://bdx83fokp6kha" path="res://assets/audio/sfx/buttonclick.mp3" id="4_e3p60"]
@ -108,6 +108,7 @@ script = ExtResource("3_e3p60")
affects = 1
[node name="ContinueButton" type="Button" parent="Pause/MarginContainer/Buttons"]
unique_name_in_owner = true
layout_mode = 2
icon = SubResource("AtlasTexture_4k24j")
icon_alignment = 1