From ab094fd6cef6a00eff6c6b965a2b36a507973780 Mon Sep 17 00:00:00 2001 From: Haze Weathers Date: Mon, 1 Apr 2024 14:12:32 -0400 Subject: [PATCH] seperate ui controls from gameplay controls, scrolling controls screen --- autoloads/controls.gd | 19 +- objects/hud/options_screen_scholar.gd | 4 + objects/hud/options_screen_scholar.tscn | 263 ++++++++++++++++++------ objects/hud/scroll_follow_focus.gd | 39 ++++ objects/hud/set_gamepad_button.gd | 1 + objects/hud/set_keyboard_button.gd | 1 + project.godot | 12 +- ui/theme.tres | 5 +- 8 files changed, 273 insertions(+), 71 deletions(-) create mode 100644 objects/hud/scroll_follow_focus.gd diff --git a/autoloads/controls.gd b/autoloads/controls.gd index 77bd5fa..c394522 100644 --- a/autoloads/controls.gd +++ b/autoloads/controls.gd @@ -2,14 +2,19 @@ extends Node const CFG_PATH := "user://controls.pr" -const ACTIONS := ["move_left", "move_right", "move_up", "move_down", "jump", "shoot"] +const ACTIONS := [ + "move_left", "move_right", + "move_up", "move_down", + "jump", "shoot", + "ui_accept", "ui_cancel", +] const LINKED_ACTIONS := { move_left = "ui_left", move_right = "ui_right", move_up = "ui_up", move_down = "ui_down", - jump = "ui_accept", - shoot = "ui_cancel", +# jump = "ui_accept", +# shoot = "ui_cancel", } @@ -47,6 +52,14 @@ func set_button(action: String, button_index: int) -> void: _save_bindings() +func default_controls() -> void: + for action in ACTIONS: + set_key(action, _get_default_key(action)) + set_button(action, _get_default_button(action)) + for button in get_tree().get_nodes_in_group("controls_buttons"): + button._update_text() + + func _save_bindings() -> void: cfg.save(CFG_PATH) diff --git a/objects/hud/options_screen_scholar.gd b/objects/hud/options_screen_scholar.gd index 0cc5d8a..5a6e8f8 100644 --- a/objects/hud/options_screen_scholar.gd +++ b/objects/hud/options_screen_scholar.gd @@ -118,3 +118,7 @@ func _on_SoundVol_value_changed(value: float) -> void: func _on_LandingSound_selected(selection) -> void: Options.landing_sound = selection == 1 + + +func _on_DefaultControls_button_down() -> void: + Controls.default_controls() diff --git a/objects/hud/options_screen_scholar.tscn b/objects/hud/options_screen_scholar.tscn index 5e23e13..3e1f343 100644 --- a/objects/hud/options_screen_scholar.tscn +++ b/objects/hud/options_screen_scholar.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=12 format=2] +[gd_scene load_steps=16 format=2] [ext_resource path="res://objects/hud/options_screen_scholar.gd" type="Script" id=1] [ext_resource path="res://ui/theme.tres" type="Theme" id=2] @@ -9,6 +9,8 @@ [ext_resource path="res://objects/hud/labeled_slider.gd" type="Script" id=7] [ext_resource path="res://objects/hud/set_keyboard_button.gd" type="Script" id=8] [ext_resource path="res://objects/hud/set_gamepad_button.gd" type="Script" id=9] +[ext_resource path="res://objects/hud/scroll_follow_focus.gd" type="Script" id=10] +[ext_resource path="res://graphics/hud/levelselect_nexlevel.png" type="Texture" id=11] [sub_resource type="ShaderMaterial" id=1] shader = ExtResource( 4 ) @@ -24,6 +26,14 @@ shader_param/ammount = Vector2( 2, 0 ) shader_param/offset = Vector2( 0, 0 ) shader_param/delay = Vector2( 4, 0 ) +[sub_resource type="AtlasTexture" id=3] +atlas = ExtResource( 11 ) +region = Rect2( 0, 0, 8, 8 ) + +[sub_resource type="AtlasTexture" id=4] +atlas = ExtResource( 11 ) +region = Rect2( 8, 0, 8, 8 ) + [node name="OptionsScreen" type="Control"] anchor_right = 1.0 anchor_bottom = 1.0 @@ -49,13 +59,13 @@ margin_bottom = 157.0 custom_constants/margin_right = 8 custom_constants/margin_top = 4 custom_constants/margin_left = 8 -custom_constants/margin_bottom = 4 +custom_constants/margin_bottom = 2 [node name="VBoxContainer" type="VBoxContainer" parent="CenterContainer/PanelContainer/MarginContainer"] margin_left = 8.0 margin_top = 4.0 margin_right = 226.0 -margin_bottom = 150.0 +margin_bottom = 152.0 [node name="Label" type="Label" parent="CenterContainer/PanelContainer/MarginContainer/VBoxContainer"] margin_right = 218.0 @@ -83,8 +93,10 @@ margin_bottom = 32.0 unique_name_in_owner = true margin_top = 36.0 margin_right = 218.0 -margin_bottom = 146.0 +margin_bottom = 148.0 focus_mode = 2 +size_flags_horizontal = 3 +size_flags_vertical = 3 tabs_visible = false [node name="Game" type="VBoxContainer" parent="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs"] @@ -449,19 +461,27 @@ options = [ "off", "on" ] [node name="Input" type="VBoxContainer" parent="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs"] anchor_right = 1.0 anchor_bottom = 1.0 -focus_next = NodePath("Left/Keyboard") +focus_next = NodePath("ScrollContainer/ControlsVBox/Left/Keyboard") +size_flags_horizontal = 3 +size_flags_vertical = 3 [node name="Header" type="HBoxContainer" parent="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Input"] margin_right = 218.0 margin_bottom = 12.0 rect_min_size = Vector2( 0, 12 ) -[node name="Spacer" type="Label" parent="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Input/Header"] -margin_top = 1.0 +[node name="Spacer" type="CenterContainer" parent="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Input/Header"] margin_right = 92.0 -margin_bottom = 11.0 +margin_bottom = 12.0 rect_min_size = Vector2( 92, 0 ) -align = 1 + +[node name="UpArrow" type="TextureRect" parent="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Input/Header/Spacer"] +unique_name_in_owner = true +margin_left = 42.0 +margin_top = 2.0 +margin_right = 50.0 +margin_bottom = 10.0 +texture = SubResource( 3 ) [node name="Keyboard" type="Label" parent="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Input/Header"] margin_left = 96.0 @@ -481,29 +501,44 @@ size_flags_horizontal = 3 text = "Gamepad" align = 1 -[node name="Left" type="HBoxContainer" parent="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Input"] +[node name="ScrollContainer" type="ScrollContainer" parent="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Input"] margin_top = 16.0 margin_right = 218.0 -margin_bottom = 26.0 +margin_bottom = 98.0 +size_flags_horizontal = 3 +size_flags_vertical = 3 +script = ExtResource( 10 ) -[node name="Label" type="Label" parent="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Input/Left"] +[node name="ControlsVBox" type="VBoxContainer" parent="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Input/ScrollContainer"] +unique_name_in_owner = true +margin_right = 218.0 +margin_bottom = 122.0 +size_flags_horizontal = 3 +size_flags_vertical = 3 + +[node name="Left" type="HBoxContainer" parent="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Input/ScrollContainer/ControlsVBox"] +margin_right = 218.0 +margin_bottom = 10.0 + +[node name="Label" type="Label" parent="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Input/ScrollContainer/ControlsVBox/Left"] margin_right = 92.0 margin_bottom = 10.0 rect_min_size = Vector2( 92, 0 ) text = "left" align = 1 -[node name="Keyboard" type="Button" parent="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Input/Left"] +[node name="Keyboard" type="Button" parent="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Input/ScrollContainer/ControlsVBox/Left"] margin_left = 96.0 margin_right = 155.0 margin_bottom = 10.0 +focus_neighbour_left = NodePath("../..") size_flags_horizontal = 3 text = "-" script = ExtResource( 8 ) action = "move_left" -options_screen = NodePath("../../../../../../../..") +options_screen = NodePath("../../../../../../../../../..") -[node name="Gamepad" type="Button" parent="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Input/Left"] +[node name="Gamepad" type="Button" parent="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Input/ScrollContainer/ControlsVBox/Left"] margin_left = 159.0 margin_right = 218.0 margin_bottom = 10.0 @@ -512,31 +547,32 @@ text = "-" icon_align = 1 script = ExtResource( 9 ) action = "move_left" -options_screen = NodePath("../../../../../../../..") +options_screen = NodePath("../../../../../../../../../..") -[node name="Right" type="HBoxContainer" parent="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Input"] -margin_top = 30.0 +[node name="Right" type="HBoxContainer" parent="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Input/ScrollContainer/ControlsVBox"] +margin_top = 14.0 margin_right = 218.0 -margin_bottom = 40.0 +margin_bottom = 24.0 -[node name="Label" type="Label" parent="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Input/Right"] +[node name="Label" type="Label" parent="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Input/ScrollContainer/ControlsVBox/Right"] margin_right = 92.0 margin_bottom = 10.0 rect_min_size = Vector2( 92, 0 ) text = "right" align = 1 -[node name="Keyboard" type="Button" parent="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Input/Right"] +[node name="Keyboard" type="Button" parent="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Input/ScrollContainer/ControlsVBox/Right"] margin_left = 96.0 margin_right = 155.0 margin_bottom = 10.0 +focus_neighbour_left = NodePath("../..") size_flags_horizontal = 3 text = "-" script = ExtResource( 8 ) action = "move_right" -options_screen = NodePath("../../../../../../../..") +options_screen = NodePath("../../../../../../../../../..") -[node name="Gamepad" type="Button" parent="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Input/Right"] +[node name="Gamepad" type="Button" parent="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Input/ScrollContainer/ControlsVBox/Right"] margin_left = 159.0 margin_right = 218.0 margin_bottom = 10.0 @@ -544,31 +580,32 @@ size_flags_horizontal = 3 text = "-" script = ExtResource( 9 ) action = "move_right" -options_screen = NodePath("../../../../../../../..") +options_screen = NodePath("../../../../../../../../../..") -[node name="Up" type="HBoxContainer" parent="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Input"] -margin_top = 44.0 +[node name="Up" type="HBoxContainer" parent="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Input/ScrollContainer/ControlsVBox"] +margin_top = 28.0 margin_right = 218.0 -margin_bottom = 54.0 +margin_bottom = 38.0 -[node name="Label" type="Label" parent="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Input/Up"] +[node name="Label" type="Label" parent="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Input/ScrollContainer/ControlsVBox/Up"] margin_right = 92.0 margin_bottom = 10.0 rect_min_size = Vector2( 92, 0 ) text = "up" align = 1 -[node name="Keyboard" type="Button" parent="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Input/Up"] +[node name="Keyboard" type="Button" parent="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Input/ScrollContainer/ControlsVBox/Up"] margin_left = 96.0 margin_right = 155.0 margin_bottom = 10.0 +focus_neighbour_left = NodePath("../..") size_flags_horizontal = 3 text = "-" script = ExtResource( 8 ) action = "move_up" -options_screen = NodePath("../../../../../../../..") +options_screen = NodePath("../../../../../../../../../..") -[node name="Gamepad" type="Button" parent="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Input/Up"] +[node name="Gamepad" type="Button" parent="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Input/ScrollContainer/ControlsVBox/Up"] margin_left = 159.0 margin_right = 218.0 margin_bottom = 10.0 @@ -576,31 +613,32 @@ size_flags_horizontal = 3 text = "-" script = ExtResource( 9 ) action = "move_up" -options_screen = NodePath("../../../../../../../..") +options_screen = NodePath("../../../../../../../../../..") -[node name="Down" type="HBoxContainer" parent="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Input"] -margin_top = 58.0 +[node name="Down" type="HBoxContainer" parent="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Input/ScrollContainer/ControlsVBox"] +margin_top = 42.0 margin_right = 218.0 -margin_bottom = 68.0 +margin_bottom = 52.0 -[node name="Label" type="Label" parent="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Input/Down"] +[node name="Label" type="Label" parent="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Input/ScrollContainer/ControlsVBox/Down"] margin_right = 92.0 margin_bottom = 10.0 rect_min_size = Vector2( 92, 0 ) text = "down" align = 1 -[node name="Keyboard" type="Button" parent="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Input/Down"] +[node name="Keyboard" type="Button" parent="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Input/ScrollContainer/ControlsVBox/Down"] margin_left = 96.0 margin_right = 155.0 margin_bottom = 10.0 +focus_neighbour_left = NodePath("../..") size_flags_horizontal = 3 text = "-" script = ExtResource( 8 ) action = "move_down" -options_screen = NodePath("../../../../../../../..") +options_screen = NodePath("../../../../../../../../../..") -[node name="Gamepad" type="Button" parent="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Input/Down"] +[node name="Gamepad" type="Button" parent="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Input/ScrollContainer/ControlsVBox/Down"] margin_left = 159.0 margin_right = 218.0 margin_bottom = 10.0 @@ -608,31 +646,98 @@ size_flags_horizontal = 3 text = "-" script = ExtResource( 9 ) action = "move_down" -options_screen = NodePath("../../../../../../../..") +options_screen = NodePath("../../../../../../../../../..") -[node name="Jump" type="HBoxContainer" parent="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Input"] -margin_top = 72.0 +[node name="Confirm" type="HBoxContainer" parent="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Input/ScrollContainer/ControlsVBox"] +margin_top = 56.0 margin_right = 218.0 -margin_bottom = 82.0 +margin_bottom = 66.0 -[node name="Label" type="Label" parent="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Input/Jump"] +[node name="Label" type="Label" parent="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Input/ScrollContainer/ControlsVBox/Confirm"] margin_right = 92.0 margin_bottom = 10.0 rect_min_size = Vector2( 92, 0 ) -text = "jump/confirm" +text = "confirm" align = 1 -[node name="Keyboard" type="Button" parent="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Input/Jump"] +[node name="Keyboard" type="Button" parent="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Input/ScrollContainer/ControlsVBox/Confirm"] margin_left = 96.0 margin_right = 155.0 margin_bottom = 10.0 +focus_neighbour_left = NodePath("../..") +size_flags_horizontal = 3 +text = "-" +script = ExtResource( 8 ) +action = "ui_accept" +options_screen = NodePath("../../../../../../../../../..") + +[node name="Gamepad" type="Button" parent="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Input/ScrollContainer/ControlsVBox/Confirm"] +margin_left = 159.0 +margin_right = 218.0 +margin_bottom = 10.0 +size_flags_horizontal = 3 +text = "-" +script = ExtResource( 9 ) +action = "ui_accept" +options_screen = NodePath("../../../../../../../../../..") + +[node name="Back" type="HBoxContainer" parent="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Input/ScrollContainer/ControlsVBox"] +margin_top = 70.0 +margin_right = 218.0 +margin_bottom = 80.0 + +[node name="Label" type="Label" parent="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Input/ScrollContainer/ControlsVBox/Back"] +margin_right = 92.0 +margin_bottom = 10.0 +rect_min_size = Vector2( 92, 0 ) +text = "back" +align = 1 + +[node name="Keyboard" type="Button" parent="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Input/ScrollContainer/ControlsVBox/Back"] +margin_left = 96.0 +margin_right = 155.0 +margin_bottom = 10.0 +focus_neighbour_left = NodePath("../..") +size_flags_horizontal = 3 +text = "-" +script = ExtResource( 8 ) +action = "ui_cancel" +options_screen = NodePath("../../../../../../../../../..") + +[node name="Gamepad" type="Button" parent="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Input/ScrollContainer/ControlsVBox/Back"] +margin_left = 159.0 +margin_right = 218.0 +margin_bottom = 10.0 +size_flags_horizontal = 3 +text = "-" +script = ExtResource( 9 ) +action = "ui_cancel" +options_screen = NodePath("../../../../../../../../../..") + +[node name="Jump" type="HBoxContainer" parent="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Input/ScrollContainer/ControlsVBox"] +margin_top = 84.0 +margin_right = 218.0 +margin_bottom = 94.0 + +[node name="Label" type="Label" parent="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Input/ScrollContainer/ControlsVBox/Jump"] +margin_right = 92.0 +margin_bottom = 10.0 +rect_min_size = Vector2( 92, 0 ) +text = "jump" +align = 1 + +[node name="Keyboard" type="Button" parent="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Input/ScrollContainer/ControlsVBox/Jump"] +margin_left = 96.0 +margin_right = 155.0 +margin_bottom = 10.0 +focus_neighbour_left = NodePath("../..") size_flags_horizontal = 3 text = "-" script = ExtResource( 8 ) action = "jump" -options_screen = NodePath("../../../../../../../..") +options_screen = NodePath("../../../../../../../../../..") -[node name="Gamepad" type="Button" parent="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Input/Jump"] +[node name="Gamepad" type="Button" parent="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Input/ScrollContainer/ControlsVBox/Jump"] margin_left = 159.0 margin_right = 218.0 margin_bottom = 10.0 @@ -640,31 +745,32 @@ size_flags_horizontal = 3 text = "-" script = ExtResource( 9 ) action = "jump" -options_screen = NodePath("../../../../../../../..") +options_screen = NodePath("../../../../../../../../../..") -[node name="Attack" type="HBoxContainer" parent="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Input"] -margin_top = 86.0 +[node name="Attack" type="HBoxContainer" parent="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Input/ScrollContainer/ControlsVBox"] +margin_top = 98.0 margin_right = 218.0 -margin_bottom = 96.0 +margin_bottom = 108.0 -[node name="Label" type="Label" parent="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Input/Attack"] +[node name="Label" type="Label" parent="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Input/ScrollContainer/ControlsVBox/Attack"] margin_right = 92.0 margin_bottom = 10.0 rect_min_size = Vector2( 92, 0 ) -text = "attack/back" +text = "attack" align = 1 -[node name="Keyboard" type="Button" parent="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Input/Attack"] +[node name="Keyboard" type="Button" parent="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Input/ScrollContainer/ControlsVBox/Attack"] margin_left = 96.0 margin_right = 155.0 margin_bottom = 10.0 +focus_neighbour_left = NodePath("../..") size_flags_horizontal = 3 text = "-" script = ExtResource( 8 ) action = "shoot" -options_screen = NodePath("../../../../../../../..") +options_screen = NodePath("../../../../../../../../../..") -[node name="Gamepad" type="Button" parent="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Input/Attack"] +[node name="Gamepad" type="Button" parent="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Input/ScrollContainer/ControlsVBox/Attack"] margin_left = 159.0 margin_right = 218.0 margin_bottom = 10.0 @@ -672,16 +778,50 @@ size_flags_horizontal = 3 text = "-" script = ExtResource( 9 ) action = "shoot" -options_screen = NodePath("../../../../../../../..") +options_screen = NodePath("../../../../../../../../../..") -[node name="DefaultControls" type="Button" parent="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Input"] +[node name="DefaultControls" type="Button" parent="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Input/ScrollContainer/ControlsVBox"] margin_left = 81.0 -margin_top = 100.0 +margin_top = 112.0 margin_right = 137.0 -margin_bottom = 110.0 +margin_bottom = 122.0 +focus_neighbour_left = NodePath("..") +focus_neighbour_right = NodePath("..") size_flags_horizontal = 4 text = "defaults" +[node name="HBoxContainer" type="HBoxContainer" parent="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Input"] +margin_top = 102.0 +margin_right = 218.0 +margin_bottom = 112.0 + +[node name="Spacer" type="CenterContainer" parent="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Input/HBoxContainer"] +margin_right = 92.0 +margin_bottom = 10.0 +rect_min_size = Vector2( 92, 0 ) + +[node name="DownArrow" type="TextureRect" parent="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Input/HBoxContainer/Spacer"] +unique_name_in_owner = true +margin_left = 42.0 +margin_top = 1.0 +margin_right = 50.0 +margin_bottom = 9.0 +texture = SubResource( 4 ) + +[node name="Keyboard" type="Label" parent="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Input/HBoxContainer"] +margin_left = 96.0 +margin_right = 155.0 +margin_bottom = 10.0 +size_flags_horizontal = 3 +align = 1 + +[node name="Gamepad" type="Label" parent="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Input/HBoxContainer"] +margin_left = 159.0 +margin_right = 218.0 +margin_bottom = 10.0 +size_flags_horizontal = 3 +align = 1 + [connection signal="selected" from="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/SelectTab" to="." method="_on_tab_selected"] [connection signal="selected" from="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Game/Rumble/SelectRumble" to="." method="_on_Rumble_selected"] [connection signal="selected" from="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Game/Gore/SelectGore" to="." method="_on_Gore_selected"] @@ -697,3 +837,4 @@ text = "defaults" [connection signal="value_changed" from="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Audio/Music/SelectMusicVol" to="." method="_on_MusicVol_value_changed"] [connection signal="value_changed" from="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Audio/Sound/SelectSoundVol" to="." method="_on_SoundVol_value_changed"] [connection signal="selected" from="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Audio/LandingSound/SelectLandingSound" to="." method="_on_LandingSound_selected"] +[connection signal="button_down" from="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Input/ScrollContainer/ControlsVBox/DefaultControls" to="." method="_on_DefaultControls_button_down"] diff --git a/objects/hud/scroll_follow_focus.gd b/objects/hud/scroll_follow_focus.gd new file mode 100644 index 0000000..89c6282 --- /dev/null +++ b/objects/hud/scroll_follow_focus.gd @@ -0,0 +1,39 @@ +extends ScrollContainer + + +onready var up_arrow: TextureRect = $"%UpArrow" +onready var down_arrow: TextureRect = $"%DownArrow" +onready var controls_v_box: VBoxContainer = $"%ControlsVBox" + + +func _ready() -> void: + yield(get_tree(), "idle_frame") + get_viewport().connect("gui_focus_changed", self, "_on_focus_changed") + connect("visibility_changed", self, "_on_visibility_changed") + + +func _exit_tree() -> void: + get_viewport().disconnect("gui_focus_changed", self, "_on_focus_changed") + + +func _on_focus_changed(focused: Control) -> void: + if is_a_parent_of(focused): + var foc_rect := focused.get_global_rect() + if not get_global_rect().encloses(foc_rect): + var direction := sign(foc_rect.position.y - get_global_rect().position.y) + scroll_vertical += direction * 14.0 + + if scroll_vertical < 1.0: + up_arrow.visible = false + else: + up_arrow.visible = true + + if scroll_vertical > 35.0: + down_arrow.visible = false + else: + down_arrow.visible = true + + +func _on_visibility_changed() -> void: + scroll_vertical = 0.0 + up_arrow.visible = false diff --git a/objects/hud/set_gamepad_button.gd b/objects/hud/set_gamepad_button.gd index b1f51fb..fea23f9 100644 --- a/objects/hud/set_gamepad_button.gd +++ b/objects/hud/set_gamepad_button.gd @@ -15,6 +15,7 @@ var gamepad_buttons := GAMEPAD_BUTTONS.duplicate() func _init() -> void: icon_align = Button.ALIGN_CENTER connect("pressed", self, "_on_pressed") + add_to_group("controls_buttons") func _ready() -> void: diff --git a/objects/hud/set_keyboard_button.gd b/objects/hud/set_keyboard_button.gd index 9bd6076..ba5ae52 100644 --- a/objects/hud/set_keyboard_button.gd +++ b/objects/hud/set_keyboard_button.gd @@ -13,6 +13,7 @@ var listen := false func _init() -> void: connect("pressed", self, "_on_pressed") + add_to_group("controls_buttons") func _ready() -> void: diff --git a/project.godot b/project.godot index f54d298..7ad022f 100644 --- a/project.godot +++ b/project.godot @@ -171,7 +171,7 @@ ogg_vorbis={ ui_accept={ "deadzone": 0.5, "events": [ Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":0,"pressure":0.0,"pressed":false,"script":null) -, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":0,"physical_scancode":88,"unicode":0,"echo":false,"script":null) +, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":0,"physical_scancode":90,"unicode":0,"echo":false,"script":null) , Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777221,"physical_scancode":0,"unicode":0,"echo":false,"script":null) ] } @@ -181,10 +181,10 @@ ui_select={ } ui_cancel={ "deadzone": 0.5, -"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777217,"physical_scancode":0,"unicode":0,"echo":false,"script":null) -, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":1,"pressure":0.0,"pressed":false,"script":null) -, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":0,"physical_scancode":90,"unicode":0,"echo":false,"script":null) +"events": [ Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":1,"pressure":0.0,"pressed":false,"script":null) , Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":2,"pressure":0.0,"pressed":false,"script":null) +, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":0,"physical_scancode":88,"unicode":0,"echo":false,"script":null) +, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777217,"physical_scancode":0,"unicode":0,"echo":false,"script":null) ] } ui_focus_next={ @@ -249,7 +249,7 @@ ui_end={ jump={ "deadzone": 0.5, "events": [ Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":0,"pressure":0.0,"pressed":false,"script":null) -, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":0,"physical_scancode":88,"unicode":0,"echo":false,"script":null) +, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":0,"physical_scancode":90,"unicode":0,"echo":false,"script":null) ] } debug_restart={ @@ -276,7 +276,7 @@ debug_move_player={ shoot={ "deadzone": 0.5, "events": [ Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":2,"pressure":0.0,"pressed":false,"script":null) -, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":0,"physical_scancode":90,"unicode":0,"echo":false,"script":null) +, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":0,"physical_scancode":88,"unicode":0,"echo":false,"script":null) ] } fullscreen={ diff --git a/ui/theme.tres b/ui/theme.tres index 184774d..60e54f1 100644 --- a/ui/theme.tres +++ b/ui/theme.tres @@ -1,4 +1,4 @@ -[gd_resource type="Theme" load_steps=16 format=2] +[gd_resource type="Theme" load_steps=17 format=2] [ext_resource path="res://ui/2ndpuberty_scholar.fnt" type="BitmapFont" id=1] [ext_resource path="res://graphics/hud/hslider_slider.png" type="Texture" id=2] @@ -42,6 +42,8 @@ margin_bottom = 3.0 content_margin_left = 4.0 content_margin_right = 4.0 +[sub_resource type="StyleBoxEmpty" id=18] + [resource] default_font = ExtResource( 1 ) Button/colors/font_color = Color( 0.690196, 0.690196, 0.690196, 1 ) @@ -63,3 +65,4 @@ TabContainer/styles/panel = SubResource( 16 ) TabContainer/styles/tab_bg = SubResource( 2 ) TabContainer/styles/tab_disabled = SubResource( 2 ) TabContainer/styles/tab_fg = SubResource( 2 ) +VScrollBar/styles/scroll = SubResource( 18 )