Add some UI
This commit is contained in:
@@ -2,9 +2,15 @@ class_name SettingsMenu extends Control
|
||||
|
||||
@export var tabs:TabBar
|
||||
@export var tabControls:Array[Control]
|
||||
@export var checkInvertX:CheckBox
|
||||
@export var checkInvertY:CheckBox
|
||||
|
||||
func _ready() -> void:
|
||||
tabs.tab_changed.connect(onTabChanged)
|
||||
checkInvertX.button_pressed = SETTINGS.invertCameraX
|
||||
checkInvertY.button_pressed = SETTINGS.invertCameraY
|
||||
checkInvertX.toggled.connect(func(v:bool): SETTINGS.invertCameraX = v)
|
||||
checkInvertY.toggled.connect(func(v:bool): SETTINGS.invertCameraY = v)
|
||||
onTabChanged(tabs.current_tab)
|
||||
|
||||
func _notification(what:int) -> void:
|
||||
@@ -16,3 +22,10 @@ func onTabChanged(tabIndex:int) -> void:
|
||||
control.visible = false
|
||||
if tabIndex >= 0 and tabIndex < tabControls.size():
|
||||
tabControls[tabIndex].visible = true
|
||||
_focusFirstIn(tabControls[tabIndex])
|
||||
|
||||
func _focusFirstIn(container:Control) -> void:
|
||||
for child in container.get_children():
|
||||
if child is Control and child.focus_mode != Control.FOCUS_NONE:
|
||||
child.grab_focus()
|
||||
return
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
[ext_resource type="Script" uid="uid://efmr0xkbw1py" path="res://ui/settings/SettingsMenu.gd" id="1_4lnig"]
|
||||
|
||||
[node name="SettingsMenu" type="Control" node_paths=PackedStringArray("tabs", "tabControls")]
|
||||
[node name="SettingsMenu" type="Control" node_paths=PackedStringArray("tabs", "tabControls", "checkInvertX", "checkInvertY")]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
@@ -11,7 +11,9 @@ grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
script = ExtResource("1_4lnig")
|
||||
tabs = NodePath("VBoxContainer/TabBar")
|
||||
tabControls = [NodePath("VBoxContainer/ScrollContainer/LabelGameplay"), NodePath("VBoxContainer/ScrollContainer/LabelSound"), NodePath("VBoxContainer/ScrollContainer/LabelGraphics")]
|
||||
tabControls = [NodePath("VBoxContainer/ScrollContainer/LabelGameplay"), NodePath("VBoxContainer/ScrollContainer/LabelSound"), NodePath("VBoxContainer/ScrollContainer/LabelGraphics"), NodePath("VBoxContainer/ScrollContainer/PanelControls")]
|
||||
checkInvertX = NodePath("VBoxContainer/ScrollContainer/PanelControls/CheckInvertX")
|
||||
checkInvertY = NodePath("VBoxContainer/ScrollContainer/PanelControls/CheckInvertY")
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="."]
|
||||
layout_mode = 1
|
||||
@@ -24,10 +26,11 @@ grow_vertical = 2
|
||||
[node name="TabBar" type="TabBar" parent="VBoxContainer"]
|
||||
layout_mode = 2
|
||||
current_tab = 0
|
||||
tab_count = 3
|
||||
tab_count = 4
|
||||
tab_0/title = "Gameplay"
|
||||
tab_1/title = "Sound"
|
||||
tab_2/title = "Graphics"
|
||||
tab_3/title = "Controls"
|
||||
|
||||
[node name="ScrollContainer" type="ScrollContainer" parent="VBoxContainer"]
|
||||
layout_mode = 2
|
||||
@@ -47,3 +50,21 @@ text = "Sound"
|
||||
visible = false
|
||||
layout_mode = 2
|
||||
text = "Gameplay"
|
||||
|
||||
[node name="PanelControls" type="VBoxContainer" parent="VBoxContainer/ScrollContainer"]
|
||||
visible = false
|
||||
layout_mode = 2
|
||||
|
||||
[node name="LabelController" type="Label" parent="VBoxContainer/ScrollContainer/PanelControls"]
|
||||
layout_mode = 2
|
||||
text = "Controller"
|
||||
|
||||
[node name="CheckInvertX" type="CheckBox" parent="VBoxContainer/ScrollContainer/PanelControls"]
|
||||
layout_mode = 2
|
||||
focus_mode = 2
|
||||
text = "Invert Camera X"
|
||||
|
||||
[node name="CheckInvertY" type="CheckBox" parent="VBoxContainer/ScrollContainer/PanelControls"]
|
||||
layout_mode = 2
|
||||
focus_mode = 2
|
||||
text = "Invert Camera Y"
|
||||
|
||||
Reference in New Issue
Block a user