File tree Expand file tree Collapse file tree
ui_elements/input_hints/components Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -15,6 +15,9 @@ const DEFAULT_VOLUMES: Dictionary[String, float] = {
1515 "Music" : 0.5 ,
1616}
1717
18+ const DISPLAY_SECTION := "Display"
19+ const SHOW_HUD_KEY := "Show HUD"
20+
1821const LANGUAGE_SECTION := "Language"
1922const LOCALE_KEY := "Locale"
2023const DEFAULT_LOCALE := "en"
@@ -25,6 +28,17 @@ const MINIMUM_ASPECT_RATIO := 1.25
2528## An arbitrary wide ratio, lower than 21:9 ("ultrawide").
2629const MAXIMUM_ASPECT_RATIO := 2.2
2730
31+ @export var fullscreen : bool :
32+ get = is_fullscreen ,
33+ set = set_fullscreen
34+
35+ @export var show_input_hud := true :
36+ get :
37+ return _settings .get_value (DISPLAY_SECTION , SHOW_HUD_KEY , true )
38+ set (new_value ):
39+ _settings .set_value (DISPLAY_SECTION , SHOW_HUD_KEY , new_value )
40+ _save ()
41+
2842var _settings := ConfigFile .new ()
2943
3044var _overrides_path : String
@@ -99,7 +113,7 @@ func is_fullscreen() -> bool:
99113 return DisplayServer .window_get_mode () == DisplayServer .WINDOW_MODE_EXCLUSIVE_FULLSCREEN
100114
101115
102- func toggle_fullscreen (toggled_on : bool ) -> void :
116+ func set_fullscreen (toggled_on : bool ) -> void :
103117 if toggled_on :
104118 set_window_mode (DisplayServer .WINDOW_MODE_EXCLUSIVE_FULLSCREEN )
105119 else :
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1+ # SPDX-FileCopyrightText: The Threadbare Authors
2+ # SPDX-License-Identifier: MPL-2.0
3+ @tool
4+ extends CheckButton
5+ ## A [CheckButton] that toggles a property of [Settings].
6+
7+ ## The name of a property of the [Settings] singleton.
8+ @export var setting : StringName :
9+ set = set_setting
10+
11+
12+ func set_setting (new_value : StringName ) -> void :
13+ setting = new_value
14+ update_configuration_warnings ()
15+
16+
17+ func _get_configuration_warnings () -> PackedStringArray :
18+ var warnings : PackedStringArray
19+
20+ if not setting :
21+ warnings .append ("Setting name is not set." )
22+ elif setting not in Settings :
23+ warnings .append ("Settings singleton has no property named " + setting )
24+
25+ return warnings
26+
27+
28+ func _ready () -> void :
29+ if Engine .is_editor_hint ():
30+ return
31+
32+ # There are two instances of this toggle in the game: one on the title screen, and
33+ # another in the pause overlay. At most one is displayed at a time, so we can keep them in
34+ # synch by reading the setting each time each toggle is displayed.
35+ visibility_changed .connect (_refresh )
36+ _refresh ()
37+
38+ toggled .connect (_on_toggled )
39+
40+
41+ func _refresh () -> void :
42+ set_pressed_no_signal (Settings .get (setting ))
43+
44+
45+ func _on_toggled (toggled_on : bool ) -> void :
46+ Settings .set (setting , toggled_on )
File renamed without changes.
Original file line number Diff line number Diff line change 11[gd_scene format =3 uid ="uid://tahf2q1d3e74" ]
22
33[ext_resource type ="Theme" uid ="uid://cvitou84ni7qe" path ="res://scenes/ui_elements/components/theme.tres" id ="1_qb52c" ]
4- [ext_resource type ="Script" uid ="uid://c63sfg6wgj2uy" path ="res://scenes/menus/options/components/fullscreen_toggle .gd" id ="2_qb52c" ]
4+ [ext_resource type ="Script" uid ="uid://c63sfg6wgj2uy" path ="res://scenes/menus/options/components/settings_toggle .gd" id ="2_qb52c" ]
55
66[node name ="VideoSettings" type ="VBoxContainer" unique_id =1199621136 ]
77offset_left = 96.0
@@ -21,12 +21,17 @@ text = "Video Settings"
2121
2222[node name ="GridContainer" type ="GridContainer" parent ="." unique_id =277212195 ]
2323layout_mode = 2
24- columns = 2
24+ theme_override_constants/v_separation = 0
2525
26- [node name ="CheckButton" type ="CheckButton" parent ="GridContainer" unique_id =409098937 ]
26+ [node name ="ShowControlsButton" type ="CheckButton" parent ="GridContainer" unique_id =153771304 ]
27+ layout_mode = 2
28+ text = "Show Controls"
29+ script = ExtResource ("2_qb52c" )
30+ setting = &"show_input_hud"
31+
32+ [node name ="FullscreenButton" type ="CheckButton" parent ="GridContainer" unique_id =409098937 ]
2733layout_mode = 2
2834size_flags_horizontal = 3
2935text = "Fullscreen"
3036script = ExtResource ("2_qb52c" )
31-
32- [connection signal ="toggled" from ="GridContainer/CheckButton" to ="." method ="_on_check_button_toggled" ]
37+ setting = &"fullscreen"
Original file line number Diff line number Diff line change @@ -63,7 +63,12 @@ func _on_scene_changed() -> void:
6363
6464
6565func _update_visibility () -> void :
66- visible = not get_tree ().paused and not Transitions .is_running () and (player or sokoban_ruleset )
66+ visible = (
67+ Settings .show_input_hud
68+ and not get_tree ().paused
69+ and not Transitions .is_running ()
70+ and (player or sokoban_ruleset )
71+ )
6772
6873
6974func _notification (what : int ) -> void :
You can’t perform that action at this time.
0 commit comments