full gamepad support
This commit is contained in:
parent
31ba172123
commit
a57d79e84a
21 changed files with 213 additions and 46 deletions
|
|
@ -25,7 +25,6 @@ config/windows_native_icon="res://icon.ico"
|
||||||
[autoload]
|
[autoload]
|
||||||
|
|
||||||
LevelController="*res://scripts/level/LevelController.cs"
|
LevelController="*res://scripts/level/LevelController.cs"
|
||||||
Cursor="*res://scripts/Cursor.cs"
|
|
||||||
GameRegistry="*res://scripts/systems/GameRegistry.cs"
|
GameRegistry="*res://scripts/systems/GameRegistry.cs"
|
||||||
Cheats="*res://scripts/debug/Cheats.cs"
|
Cheats="*res://scripts/debug/Cheats.cs"
|
||||||
AudioSequencer="*res://scenes/audio_sequencer.tscn"
|
AudioSequencer="*res://scenes/audio_sequencer.tscn"
|
||||||
|
|
@ -96,7 +95,6 @@ ui_left={
|
||||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194319,"physical_keycode":0,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194319,"physical_keycode":0,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
|
||||||
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":13,"pressure":0.0,"pressed":false,"script":null)
|
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":13,"pressure":0.0,"pressed":false,"script":null)
|
||||||
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":9,"pressure":0.0,"pressed":true,"script":null)
|
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":9,"pressure":0.0,"pressed":true,"script":null)
|
||||||
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":2,"axis_value":-1.0,"script":null)
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
ui_right={
|
ui_right={
|
||||||
|
|
@ -104,20 +102,29 @@ ui_right={
|
||||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194321,"physical_keycode":0,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194321,"physical_keycode":0,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
|
||||||
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":14,"pressure":0.0,"pressed":false,"script":null)
|
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":14,"pressure":0.0,"pressed":false,"script":null)
|
||||||
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":10,"pressure":0.0,"pressed":true,"script":null)
|
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":10,"pressure":0.0,"pressed":true,"script":null)
|
||||||
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":2,"axis_value":1.0,"script":null)
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
ui_up={
|
ui_up={
|
||||||
"deadzone": 0.5,
|
"deadzone": 0.5,
|
||||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194320,"physical_keycode":0,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194320,"physical_keycode":0,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
|
||||||
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":11,"pressure":0.0,"pressed":false,"script":null)
|
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":11,"pressure":0.0,"pressed":false,"script":null)
|
||||||
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":3,"axis_value":-1.0,"script":null)
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
ui_down={
|
ui_down={
|
||||||
"deadzone": 0.5,
|
"deadzone": 0.5,
|
||||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194322,"physical_keycode":0,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194322,"physical_keycode":0,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
|
||||||
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":12,"pressure":0.0,"pressed":false,"script":null)
|
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":12,"pressure":0.0,"pressed":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
ui_page_up={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194323,"physical_keycode":0,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
|
||||||
|
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":3,"axis_value":-1.0,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
ui_page_down={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194324,"physical_keycode":0,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
|
||||||
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":3,"axis_value":1.0,"script":null)
|
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":3,"axis_value":1.0,"script":null)
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,24 @@
|
||||||
extends TabContainer
|
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:
|
func _on_quit_button_pressed() -> void:
|
||||||
visible = false
|
visible = false
|
||||||
$ChannelPlayer.call("Play")
|
$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
|
||||||
|
|
|
||||||
|
|
@ -12,12 +12,12 @@
|
||||||
[sub_resource type="ViewportTexture" id="ViewportTexture_ru62c"]
|
[sub_resource type="ViewportTexture" id="ViewportTexture_ru62c"]
|
||||||
viewport_path = NodePath("plants/Infobox/FrameAndTitle/VboxContainer/Frame/Previewport")
|
viewport_path = NodePath("plants/Infobox/FrameAndTitle/VboxContainer/Frame/Previewport")
|
||||||
|
|
||||||
[sub_resource type="InputEventAction" id="InputEventAction_vvhxq"]
|
[sub_resource type="InputEventJoypadButton" id="InputEventJoypadButton_vvhxq"]
|
||||||
action = &"ui_cancel"
|
button_index = 1
|
||||||
pressed = true
|
pressed = true
|
||||||
|
|
||||||
[sub_resource type="Shortcut" id="Shortcut_lmmwe"]
|
[sub_resource type="Shortcut" id="Shortcut_lmmwe"]
|
||||||
events = [SubResource("InputEventAction_vvhxq")]
|
events = [SubResource("InputEventJoypadButton_vvhxq")]
|
||||||
|
|
||||||
[sub_resource type="ViewportTexture" id="ViewportTexture_7yl8g"]
|
[sub_resource type="ViewportTexture" id="ViewportTexture_7yl8g"]
|
||||||
viewport_path = NodePath("zombies/Infobox/FrameAndTitle/VBoxContainer/Frame/Previewport")
|
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"]
|
[node name="QuitButton" type="Button" parent="zombies/Infobox/FrameAndTitle/VBoxContainer"]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
size_flags_vertical = 4
|
size_flags_vertical = 4
|
||||||
|
shortcut = SubResource("Shortcut_lmmwe")
|
||||||
text = "exit"
|
text = "exit"
|
||||||
|
|
||||||
[node name="Label" type="Label" parent="zombies/Infobox/FrameAndTitle"]
|
[node name="Label" type="Label" parent="zombies/Infobox/FrameAndTitle"]
|
||||||
|
|
|
||||||
|
|
@ -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="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"]
|
[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="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="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="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="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://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="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="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="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="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://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"]
|
[sub_resource type="ViewportTexture" id="ViewportTexture_rmoaa"]
|
||||||
viewport_path = NodePath("Panel/MarginContainer/VBoxContainer/HBoxContainer/Frame/Previewport")
|
viewport_path = NodePath("Panel/MarginContainer/VBoxContainer/HBoxContainer/Frame/Previewport")
|
||||||
|
|
@ -28,8 +31,8 @@ script/source = "extends Button
|
||||||
|
|
||||||
|
|
||||||
func _pressed() -> void:
|
func _pressed() -> void:
|
||||||
$\"../../Independer/Almanach\".visible = true
|
$\"../../../Independer/Almanach\".visible = true
|
||||||
$\"../../ChannelPlayer\".call(\"Play\")
|
$\"../../../ChannelPlayer\".call(\"Play\")
|
||||||
"
|
"
|
||||||
|
|
||||||
[sub_resource type="Resource" id="Resource_l66rp"]
|
[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"]
|
[node name="ScrollContainer" type="ScrollContainer" parent="Panel/MarginContainer/VBoxContainer/HBoxContainer/PanelContainer"]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
|
focus_mode = 2
|
||||||
horizontal_scroll_mode = 0
|
horizontal_scroll_mode = 0
|
||||||
|
|
||||||
[node name="VBoxContainer" type="VBoxContainer" parent="Panel/MarginContainer/VBoxContainer/HBoxContainer/PanelContainer/ScrollContainer"]
|
[node name="VBoxContainer" type="VBoxContainer" parent="Panel/MarginContainer/VBoxContainer/HBoxContainer/PanelContainer/ScrollContainer"]
|
||||||
|
|
@ -141,22 +145,33 @@ layout_mode = 2
|
||||||
columns = 7
|
columns = 7
|
||||||
script = ExtResource("4_i7sou")
|
script = ExtResource("4_i7sou")
|
||||||
|
|
||||||
[node name="LevelRunButton" parent="Panel" instance=ExtResource("5_n80ic")]
|
[node name="ButtonContainer" type="VBoxContainer" parent="Panel"]
|
||||||
layout_mode = 1
|
layout_mode = 1
|
||||||
|
anchors_preset = -1
|
||||||
anchor_left = 1.0
|
anchor_left = 1.0
|
||||||
anchor_right = 1.181
|
anchor_right = 1.18889
|
||||||
anchor_bottom = 0.131
|
anchor_bottom = 0.997024
|
||||||
offset_right = -16.16
|
grow_vertical = 2
|
||||||
offset_bottom = -16.016
|
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")
|
script = ExtResource("7_k6b6g")
|
||||||
|
|
||||||
[node name="AlmanachButton" type="Button" parent="Panel"]
|
[node name="Button" type="Button" parent="Panel/ButtonContainer"]
|
||||||
layout_mode = 0
|
layout_mode = 2
|
||||||
anchor_left = 1.0
|
focus_neighbor_top = NodePath("../LevelRunButton")
|
||||||
anchor_top = 0.883929
|
focus_neighbor_bottom = NodePath("../AlmanachButton")
|
||||||
anchor_right = 1.14167
|
icon = ExtResource("8_f8xw6")
|
||||||
anchor_bottom = 1.0
|
icon_alignment = 1
|
||||||
offset_bottom = -3.05176e-05
|
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 = ExtResource("8_hmdmm")
|
||||||
icon_alignment = 1
|
icon_alignment = 1
|
||||||
script = SubResource("GDScript_hmdmm")
|
script = SubResource("GDScript_hmdmm")
|
||||||
|
|
@ -180,4 +195,10 @@ autoplay = true
|
||||||
bus = &"MusicBus"
|
bus = &"MusicBus"
|
||||||
script = ExtResource("14_rptyw")
|
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"]
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
[gd_scene load_steps=3 format=3 uid="uid://u5l3jd00s8vd"]
|
[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="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"]
|
[node name="PauseButton" type="Button"]
|
||||||
anchors_preset = -1
|
anchors_preset = -1
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
[gd_scene load_steps=11 format=3 uid="uid://fm471x22n8kr"]
|
[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="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://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="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"]
|
[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
|
affects = 1
|
||||||
|
|
||||||
[node name="ContinueButton" type="Button" parent="Pause/MarginContainer/Buttons"]
|
[node name="ContinueButton" type="Button" parent="Pause/MarginContainer/Buttons"]
|
||||||
|
unique_name_in_owner = true
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
icon = SubResource("AtlasTexture_4k24j")
|
icon = SubResource("AtlasTexture_4k24j")
|
||||||
icon_alignment = 1
|
icon_alignment = 1
|
||||||
|
|
|
||||||
|
|
@ -35,9 +35,13 @@ public partial class Cursor : Node2D
|
||||||
case CursorMode.Mouse:
|
case CursorMode.Mouse:
|
||||||
break;
|
break;
|
||||||
case CursorMode.Gamepad:
|
case CursorMode.Gamepad:
|
||||||
|
if (GamepadHandler.Instance.IsGamepadControlled == false) return;
|
||||||
|
|
||||||
var vector = Input.GetVector("cursor_left", "cursor_right", "cursor_up", "cursor_down");
|
var vector = Input.GetVector("cursor_left", "cursor_right", "cursor_up", "cursor_down");
|
||||||
|
|
||||||
var set_position = GetGlobalMousePosition() + vector * (float)delta * sensitivity;
|
if (vector == Vector2.Zero) return;
|
||||||
|
|
||||||
|
var set_position = GetGlobalMousePosition() + vector * (float)delta * sensitivity / (float)Engine.TimeScale;
|
||||||
|
|
||||||
GetViewport().WarpMouse(GetGlobalTransformWithCanvas() * set_position);
|
GetViewport().WarpMouse(GetGlobalTransformWithCanvas() * set_position);
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,16 @@ namespace Newlon.Components.Droppables;
|
||||||
public partial class DroppableItem : Area2D
|
public partial class DroppableItem : Area2D
|
||||||
{
|
{
|
||||||
[Signal] public delegate void PickedUpEventHandler();
|
[Signal] public delegate void PickedUpEventHandler();
|
||||||
|
public override void _MouseEnter()
|
||||||
|
{
|
||||||
|
if (GamepadHandler.Instance.IsGamepadControlled)
|
||||||
|
{
|
||||||
|
GetViewport().SetInputAsHandled();
|
||||||
|
PickUp();
|
||||||
|
EmitSignal(SignalName.PickedUp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public override void _InputEvent(Viewport viewport, InputEvent @event, int shapeIdx)
|
public override void _InputEvent(Viewport viewport, InputEvent @event, int shapeIdx)
|
||||||
{
|
{
|
||||||
if (@event.IsActionPressed("primary_action"))
|
if (@event.IsActionPressed("primary_action"))
|
||||||
|
|
|
||||||
|
|
@ -181,6 +181,7 @@ public partial class Entity : Node2D
|
||||||
if (_activeEffectSlots[slot] != null)
|
if (_activeEffectSlots[slot] != null)
|
||||||
{
|
{
|
||||||
_activeEffectSlots[slot].Exit(this);
|
_activeEffectSlots[slot].Exit(this);
|
||||||
|
_effectSlotTimers[slot].Stop();
|
||||||
_activeEffectSlots[slot] = null;
|
_activeEffectSlots[slot] = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,48 +4,39 @@ using System;
|
||||||
|
|
||||||
public partial class GamepadHandler : Node
|
public partial class GamepadHandler : Node
|
||||||
{
|
{
|
||||||
|
[Signal] public delegate void GamepadControlledEventHandler(bool isControlled);
|
||||||
public static GamepadHandler Instance { get; private set; }
|
public static GamepadHandler Instance { get; private set; }
|
||||||
public int CurrentDevice { get; private set; } = 0;
|
public int CurrentDevice { get; private set; } = 0;
|
||||||
public bool IsGamepadControlled => focused && controlled;
|
public bool IsGamepadControlled => controlled;
|
||||||
private bool focused;
|
|
||||||
private bool controlled;
|
private bool controlled;
|
||||||
public override void _EnterTree()
|
public override void _EnterTree()
|
||||||
{
|
{
|
||||||
Instance = this;
|
Instance = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void _Notification(int what)
|
|
||||||
{
|
|
||||||
if (what == NotificationApplicationFocusIn)
|
|
||||||
{
|
|
||||||
focused = true;
|
|
||||||
}
|
|
||||||
if (what == NotificationApplicationFocusOut)
|
|
||||||
{
|
|
||||||
focused = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public override void _Input(InputEvent @event)
|
public override void _Input(InputEvent @event)
|
||||||
{
|
{
|
||||||
if (@event is InputEventJoypadButton || @event is InputEventJoypadMotion)
|
if (@event is InputEventJoypadButton || @event is InputEventJoypadMotion)
|
||||||
{
|
{
|
||||||
SetControlled(true);
|
SetControlled(true);
|
||||||
}
|
}
|
||||||
if ((@event is InputEventMouse && Input.GetVector("cursor_left", "cursor_right", "cursor_up", "cursor_down") == Vector2.Zero) || @event is InputEventKey)
|
else if (@event is InputEventMouseButton || @event is InputEventKey)
|
||||||
{
|
{
|
||||||
SetControlled(false);
|
SetControlled(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void SetControlled(bool to)
|
private void SetControlled(bool to)
|
||||||
{
|
{
|
||||||
|
if (controlled == to) return;
|
||||||
controlled = to;
|
controlled = to;
|
||||||
if (controlled)
|
if (controlled)
|
||||||
{
|
{
|
||||||
Cursor.Mode = Cursor.CursorMode.Gamepad;
|
Cursor.Mode = Cursor.CursorMode.Gamepad;
|
||||||
|
EmitSignal(SignalName.GamepadControlled, true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Cursor.Mode = Cursor.CursorMode.Mouse;
|
Cursor.Mode = Cursor.CursorMode.Mouse;
|
||||||
|
EmitSignal(SignalName.GamepadControlled, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ public partial class LevelGUIElements : Control
|
||||||
public HBoxContainer SeedpacketsHotbar;
|
public HBoxContainer SeedpacketsHotbar;
|
||||||
[Export]
|
[Export]
|
||||||
public SunCounter SunCounter;
|
public SunCounter SunCounter;
|
||||||
public override void _Ready()
|
public override void _EnterTree()
|
||||||
{
|
{
|
||||||
Instance = this;
|
Instance = this;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
62
scripts/gui/choose_your_seeds/CYSFocusSetup.cs
Normal file
62
scripts/gui/choose_your_seeds/CYSFocusSetup.cs
Normal file
|
|
@ -0,0 +1,62 @@
|
||||||
|
using Godot;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
public partial class CYSFocusSetup : Node
|
||||||
|
{
|
||||||
|
[Export] private GridContainer grid;
|
||||||
|
[Export] private Button button;
|
||||||
|
[Export] private ScrollContainer textContainer;
|
||||||
|
public override void _Ready()
|
||||||
|
{
|
||||||
|
for (int i = 0; i < grid.GetChildCount(); i++)
|
||||||
|
{
|
||||||
|
int x = i % grid.Columns;
|
||||||
|
int y = i / grid.Columns;
|
||||||
|
|
||||||
|
Control control = grid.GetChild<Control>(i);
|
||||||
|
|
||||||
|
// If it isn't leftmost element
|
||||||
|
if (x != 0)
|
||||||
|
{
|
||||||
|
control.FocusNeighborLeft = control.GetPathTo(grid.GetChild(PositionToIndex(x - 1, y)));
|
||||||
|
}
|
||||||
|
// If it isn't upmost element
|
||||||
|
if (y != 0)
|
||||||
|
{
|
||||||
|
control.FocusNeighborTop = control.GetPathTo(grid.GetChild(PositionToIndex(x, y - 1)));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
control.FocusNeighborTop = control.GetPathTo(textContainer);
|
||||||
|
}
|
||||||
|
// If it isn't rightmost element
|
||||||
|
if (x != grid.Columns - 1 && i != grid.GetChildCount())
|
||||||
|
{
|
||||||
|
control.FocusNeighborRight = control.GetPathTo(grid.GetChild(PositionToIndex(x + 1, y)));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (y != 0)
|
||||||
|
{
|
||||||
|
control.FocusNeighborRight = control.GetPathTo(grid.GetChild(PositionToIndex(x + 1, y - 1)));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
control.FocusNeighborRight = control.GetPathTo(button);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (PositionToIndex(x, y + 1) < grid.GetChildCount())
|
||||||
|
{
|
||||||
|
control.FocusNeighborBottom = control.GetPathTo(grid.GetChild(PositionToIndex(x, y + 1)));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
QueueFree();
|
||||||
|
}
|
||||||
|
private int PositionToIndex(int x, int y)
|
||||||
|
{
|
||||||
|
return y * grid.Columns + x;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
1
scripts/gui/choose_your_seeds/CYSFocusSetup.cs.uid
Normal file
1
scripts/gui/choose_your_seeds/CYSFocusSetup.cs.uid
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
uid://bksslrqq5vhm3
|
||||||
17
scripts/gui/choose_your_seeds/CYSResetButton.cs
Normal file
17
scripts/gui/choose_your_seeds/CYSResetButton.cs
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
using Godot;
|
||||||
|
using Newlon.Components;
|
||||||
|
using Newlon.Components.GUI.Seedpackets;
|
||||||
|
|
||||||
|
public partial class CYSResetButton : Button
|
||||||
|
{
|
||||||
|
public override void _Pressed()
|
||||||
|
{
|
||||||
|
foreach (Seedpacket packet in LevelGUIElements.Instance.SeedpacketsHotbar.GetChildren())
|
||||||
|
{
|
||||||
|
packet._Pressed();
|
||||||
|
packet.EmitSignal(Seedpacket.SignalName.Pressed);
|
||||||
|
}
|
||||||
|
GrabFocus();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
1
scripts/gui/choose_your_seeds/CYSResetButton.cs.uid
Normal file
1
scripts/gui/choose_your_seeds/CYSResetButton.cs.uid
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
uid://diwjgekhvn017
|
||||||
15
scripts/gui/pause_menu/PM_GamepadFocus.cs
Normal file
15
scripts/gui/pause_menu/PM_GamepadFocus.cs
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
using Godot;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
public partial class PM_GamepadFocus : Node
|
||||||
|
{
|
||||||
|
// Called when the node enters the scene tree for the first time.
|
||||||
|
public override void _Ready()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
// Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
|
public override void _Process(double delta)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
1
scripts/gui/pause_menu/PM_GamepadFocus.cs.uid
Normal file
1
scripts/gui/pause_menu/PM_GamepadFocus.cs.uid
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
uid://cc8loabsf43m0
|
||||||
|
|
@ -8,9 +8,11 @@ public partial class PauseMenu : Control
|
||||||
private bool previousPaused;
|
private bool previousPaused;
|
||||||
private bool currently_paused = false;
|
private bool currently_paused = false;
|
||||||
private AudioStream pauseSound = ResourceLoader.Load<AudioStream>("uid://ckja8ym50y0d4");
|
private AudioStream pauseSound = ResourceLoader.Load<AudioStream>("uid://ckja8ym50y0d4");
|
||||||
|
private Control stolenFocus;
|
||||||
public override void _Ready()
|
public override void _Ready()
|
||||||
{
|
{
|
||||||
Instance = this;
|
Instance = this;
|
||||||
|
GetViewport().GuiFocusChanged += OnFocusChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Continue()
|
public void Continue()
|
||||||
|
|
@ -18,6 +20,7 @@ public partial class PauseMenu : Control
|
||||||
GetParent<Control>().Visible = false;
|
GetParent<Control>().Visible = false;
|
||||||
GetTree().Paused = previousPaused;
|
GetTree().Paused = previousPaused;
|
||||||
currently_paused = false;
|
currently_paused = false;
|
||||||
|
stolenFocus.GrabFocus();
|
||||||
}
|
}
|
||||||
public void Restart()
|
public void Restart()
|
||||||
{
|
{
|
||||||
|
|
@ -36,10 +39,22 @@ public partial class PauseMenu : Control
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Instance.currently_paused = true;
|
||||||
|
Instance.GetNode<Control>("%ContinueButton").GrabFocus();
|
||||||
|
|
||||||
Instance.GetParent<Control>().Visible = true;
|
Instance.GetParent<Control>().Visible = true;
|
||||||
Instance.previousPaused = Instance.GetTree().Paused;
|
Instance.previousPaused = Instance.GetTree().Paused;
|
||||||
Instance.GetTree().Paused = true;
|
Instance.GetTree().Paused = true;
|
||||||
Instance.currently_paused = true;
|
AudioSequencer.Play("pause", Instance.pauseSound);
|
||||||
AudioSequencer.Play("pause",Instance.pauseSound);
|
}
|
||||||
|
public override void _ExitTree()
|
||||||
|
{
|
||||||
|
GetViewport().GuiFocusChanged -= OnFocusChanged;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnFocusChanged(Control to)
|
||||||
|
{
|
||||||
|
if (currently_paused) return;
|
||||||
|
stolenFocus = to;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue