fixed slider issue in A11y settings, moved script to it's own file

This commit is contained in:
betalars 2023-03-21 20:16:30 +01:00
parent 16335c989e
commit 40f48677f9
2 changed files with 51 additions and 6 deletions

View File

@ -0,0 +1,44 @@
extends TabContainer
var focus_list: Array
func _ready():
for child in get_children():
focus_list.append(_find_selectable_in(child))
func _find_selectable_in(parent:Control):
if parent.focus_mode != FOCUS_NONE:
return parent
if parent.get_child_count() == 0:
return self
else:
for child in parent.get_children():
var ret = _find_selectable_in(child)
if not ret == self:
return ret
func _unhandled_input(event):
if event.is_action_type():
if event.is_action_pressed("ui_left"): previous()
elif event.is_action_pressed("ui_right"): next()
func next():
if current_tab < get_tab_count()-1:
if !Input.is_action_just_released("mouse_left"):
if not get_viewport().gui_get_focus_owner() == null:
focus_list[current_tab] = get_viewport().gui_get_focus_owner()
current_tab += 1
focus_list[current_tab].grab_focus()
else:
current_tab += 1
func previous():
if current_tab > 0:
if !Input.is_mouse_button_pressed(MOUSE_BUTTON_LEFT):
if not get_viewport().gui_get_focus_owner() == null:
focus_list[current_tab] = get_viewport().gui_get_focus_owner()
current_tab -= 1
focus_list[current_tab].grab_focus()
else:
current_tab -= 1

View File

@ -5,7 +5,7 @@
[ext_resource type="Script" path="res://logic-scenes/startup/volume_sliders.gd" id="3_q2gbh"]
[ext_resource type="Texture2D" uid="uid://bwicl5q0lw06q" path="res://logic-scenes/startup/start_bottom.png" id="3_s5ssh"]
[sub_resource type="GDScript" id="GDScript_8885d"]
[sub_resource type="GDScript" id="GDScript_ia432"]
script/source = "extends TabContainer
var focus_list: Array
@ -127,9 +127,10 @@ layout_mode = 2
layout_mode = 2
tabs_visible = false
use_hidden_tabs_for_min_size = true
script = SubResource("GDScript_8885d")
script = SubResource("GDScript_ia432")
[node name="physical Accessibility" type="VBoxContainer" parent="CenterContainer/PanelContainer/VBoxContainer/TabContainer"]
visible = false
layout_mode = 2
[node name="Label" type="Label" parent="CenterContainer/PanelContainer/VBoxContainer/TabContainer/physical Accessibility"]
@ -231,7 +232,6 @@ disabled = true
text = "go back"
[node name="Audio Settings" type="VBoxContainer" parent="CenterContainer/PanelContainer/VBoxContainer/TabContainer"]
visible = false
layout_mode = 2
[node name="Label" type="Label" parent="CenterContainer/PanelContainer/VBoxContainer/TabContainer/Audio Settings"]
@ -266,8 +266,9 @@ layout_mode = 2
size_flags_horizontal = 3
size_flags_vertical = 4
max_value = 2.0
step = 0.0
step = 0.05
value = 1.0
ticks_on_borders = true
script = ExtResource("3_q2gbh")
[node name="Label3" type="Label" parent="CenterContainer/PanelContainer/VBoxContainer/TabContainer/Audio Settings/VBoxContainer/GridContainer"]
@ -279,7 +280,7 @@ layout_mode = 2
size_flags_horizontal = 3
size_flags_vertical = 4
max_value = 2.0
step = 0.0
step = 0.05
value = 1.0
[node name="Label4" type="Label" parent="CenterContainer/PanelContainer/VBoxContainer/TabContainer/Audio Settings/VBoxContainer/GridContainer"]
@ -292,7 +293,7 @@ layout_mode = 2
size_flags_horizontal = 3
size_flags_vertical = 4
max_value = 2.0
step = 0.0
step = 0.05
value = 1.0
[node name="Audio Sliders" type="HBoxContainer" parent="CenterContainer/PanelContainer/VBoxContainer/TabContainer/Audio Settings/VBoxContainer"]