Improve Button Focusing
This commit is contained in:
parent
97c467bcf4
commit
1aa2dd2c71
2 changed files with 35 additions and 9 deletions
|
@ -47,36 +47,52 @@ text = "Snake"
|
||||||
horizontal_alignment = 1
|
horizontal_alignment = 1
|
||||||
vertical_alignment = 1
|
vertical_alignment = 1
|
||||||
|
|
||||||
[node name="Menu Butons" type="VBoxContainer" parent="MarginContainer/VBoxContainer"]
|
[node name="Tab Group" type="TabContainer" parent="MarginContainer/VBoxContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
tabs_visible = false
|
||||||
|
|
||||||
|
[node name="Menu Butons" type="VBoxContainer" parent="MarginContainer/VBoxContainer/Tab Group"]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
|
|
||||||
[node name="Start Button" type="Button" parent="MarginContainer/VBoxContainer/Menu Butons"]
|
[node name="Start Button" type="Button" parent="MarginContainer/VBoxContainer/Tab Group/Menu Butons"]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
focus_neighbor_top = NodePath("../Quit Button")
|
focus_neighbor_top = NodePath("../Quit Button")
|
||||||
theme = ExtResource("1_b1d2h")
|
theme = ExtResource("1_b1d2h")
|
||||||
theme_override_font_sizes/font_size = 96
|
theme_override_font_sizes/font_size = 96
|
||||||
text = "Start"
|
text = "Start"
|
||||||
|
|
||||||
[node name="Settings Button" type="Button" parent="MarginContainer/VBoxContainer/Menu Butons"]
|
[node name="Settings Button" type="Button" parent="MarginContainer/VBoxContainer/Tab Group/Menu Butons"]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
theme = ExtResource("1_b1d2h")
|
theme = ExtResource("1_b1d2h")
|
||||||
theme_override_font_sizes/font_size = 96
|
theme_override_font_sizes/font_size = 96
|
||||||
text = "Settings"
|
text = "Settings"
|
||||||
|
|
||||||
[node name="About Button" type="Button" parent="MarginContainer/VBoxContainer/Menu Butons"]
|
[node name="About Button" type="Button" parent="MarginContainer/VBoxContainer/Tab Group/Menu Butons"]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
theme = ExtResource("1_b1d2h")
|
theme = ExtResource("1_b1d2h")
|
||||||
theme_override_font_sizes/font_size = 96
|
theme_override_font_sizes/font_size = 96
|
||||||
text = "About
|
text = "About
|
||||||
"
|
"
|
||||||
|
|
||||||
[node name="Quit Button" type="Button" parent="MarginContainer/VBoxContainer/Menu Butons"]
|
[node name="Quit Button" type="Button" parent="MarginContainer/VBoxContainer/Tab Group/Menu Butons"]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
focus_neighbor_bottom = NodePath("../Start Button")
|
focus_neighbor_bottom = NodePath("../Start Button")
|
||||||
theme = ExtResource("1_b1d2h")
|
theme = ExtResource("1_b1d2h")
|
||||||
theme_override_font_sizes/font_size = 96
|
theme_override_font_sizes/font_size = 96
|
||||||
text = "Quit"
|
text = "Quit"
|
||||||
|
|
||||||
[connection signal="pressed" from="MarginContainer/VBoxContainer/Menu Butons/Start Button" to="." method="_on_start_button_pressed"]
|
[node name="Settings" type="VBoxContainer" parent="MarginContainer/VBoxContainer/Tab Group"]
|
||||||
[connection signal="pressed" from="MarginContainer/VBoxContainer/Menu Butons/About Button" to="." method="_on_about_button_pressed"]
|
visible = false
|
||||||
[connection signal="pressed" from="MarginContainer/VBoxContainer/Menu Butons/Quit Button" to="." method="_on_quit_button_pressed"]
|
layout_mode = 2
|
||||||
|
|
||||||
|
[node name="Back Button" type="Button" parent="MarginContainer/VBoxContainer/Tab Group/Settings"]
|
||||||
|
layout_mode = 2
|
||||||
|
theme = ExtResource("1_b1d2h")
|
||||||
|
theme_override_font_sizes/font_size = 96
|
||||||
|
text = "Back"
|
||||||
|
|
||||||
|
[connection signal="pressed" from="MarginContainer/VBoxContainer/Tab Group/Menu Butons/Start Button" to="." method="_on_start_button_pressed"]
|
||||||
|
[connection signal="pressed" from="MarginContainer/VBoxContainer/Tab Group/Menu Butons/Settings Button" to="." method="_on_settings_button_pressed"]
|
||||||
|
[connection signal="pressed" from="MarginContainer/VBoxContainer/Tab Group/Menu Butons/About Button" to="." method="_on_about_button_pressed"]
|
||||||
|
[connection signal="pressed" from="MarginContainer/VBoxContainer/Tab Group/Menu Butons/Quit Button" to="." method="_on_quit_button_pressed"]
|
||||||
|
[connection signal="pressed" from="MarginContainer/VBoxContainer/Tab Group/Settings/Back Button" to="." method="_on_back_button_pressed"]
|
||||||
|
|
|
@ -3,7 +3,7 @@ extends Control
|
||||||
@onready var game_scene = load("res://Scene/Game.tscn").instantiate()
|
@onready var game_scene = load("res://Scene/Game.tscn").instantiate()
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
$"MarginContainer/VBoxContainer/Menu Butons/Start Button".grab_focus()
|
$"MarginContainer/VBoxContainer/Tab Group/Menu Butons/Start Button".grab_focus()
|
||||||
|
|
||||||
func _on_start_button_pressed():
|
func _on_start_button_pressed():
|
||||||
get_tree().change_scene_to_file("res://Scene/Game.tscn")
|
get_tree().change_scene_to_file("res://Scene/Game.tscn")
|
||||||
|
@ -14,3 +14,13 @@ func _on_quit_button_pressed():
|
||||||
|
|
||||||
func _on_about_button_pressed():
|
func _on_about_button_pressed():
|
||||||
OS.shell_open("https://git.euph.dev/snoweuph/Snake")
|
OS.shell_open("https://git.euph.dev/snoweuph/Snake")
|
||||||
|
|
||||||
|
|
||||||
|
func _on_settings_button_pressed():
|
||||||
|
$"MarginContainer/VBoxContainer/Tab Group".current_tab = 1
|
||||||
|
$"MarginContainer/VBoxContainer/Tab Group/Settings/Back Button".grab_focus()
|
||||||
|
|
||||||
|
|
||||||
|
func _on_back_button_pressed():
|
||||||
|
$"MarginContainer/VBoxContainer/Tab Group".current_tab = 0
|
||||||
|
$"MarginContainer/VBoxContainer/Tab Group/Menu Butons/Start Button".grab_focus()
|
||||||
|
|
Loading…
Reference in a new issue