Skip to content

Commit 58aff65

Browse files
committed
feat(Library): add toggle to enable/disable local library discovery
1 parent 837ebc5 commit 58aff65

File tree

2 files changed

+45
-1
lines changed

2 files changed

+45
-1
lines changed

core/ui/card_ui/settings/library_settings_menu.gd

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ var settings_state := load("res://assets/state/states/settings.tres") as State
77
var game_settings_state := preload("res://assets/state/states/game_settings.tres") as State
88
var button_scene := load("res://core/ui/components/card_button.tscn") as PackedScene
99

10+
@onready var local_library_toggle := $%LocalLibraryToggle as Toggle
1011
@onready var max_recent_slider := $%MaxRecentAppsSlider
1112
@onready var no_hidden_label := $%NoHiddenLabel
1213
@onready var container := $%VBoxContainer
@@ -21,6 +22,13 @@ func _ready() -> void:
2122
var max_recent := settings_manager.get_value("general.home", "max_home_items", 10) as int
2223
max_recent_slider.value = max_recent
2324

25+
# Configure desktop library
26+
await get_tree().process_frame
27+
var enable_local_library := settings_manager.get_value("general", "enable_local_library", true) as bool
28+
local_library_toggle.button_pressed = enable_local_library
29+
local_library_toggle.toggled.connect(_on_local_library_toggled)
30+
_on_local_library_toggled(enable_local_library)
31+
2432

2533
func _on_state_entered(_from: State) -> void:
2634
# Clear old buttons
@@ -58,3 +66,30 @@ func _on_state_entered(_from: State) -> void:
5866

5967
func _on_state_exited(_to: State) -> void:
6068
pass
69+
70+
71+
func _on_local_library_toggled(enabled: bool) -> void:
72+
if enabled:
73+
_enable_local_library()
74+
return
75+
_disable_local_library()
76+
77+
78+
func _enable_local_library() -> void:
79+
var library := library_manager.get_library_by_id("desktop")
80+
if library:
81+
return
82+
library = load("res://core/systems/library/library_desktop.tscn").instantiate()
83+
84+
var main := get_tree().get_first_node_in_group("main")
85+
if not main:
86+
return
87+
main.add_child(library)
88+
89+
90+
func _disable_local_library() -> void:
91+
var library := library_manager.get_library_by_id("desktop")
92+
if not library:
93+
return
94+
library_manager.unregister_library(library)
95+
library.queue_free()

core/ui/card_ui/settings/library_settings_menu.tscn

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[gd_scene load_steps=13 format=3 uid="uid://drbp6ec8646v3"]
1+
[gd_scene load_steps=14 format=3 uid="uid://drbp6ec8646v3"]
22

33
[ext_resource type="Script" uid="uid://4uyy07dx6rhw" path="res://core/ui/card_ui/settings/library_settings_menu.gd" id="1_0w1vu"]
44
[ext_resource type="PackedScene" uid="uid://cemxrvvjgm4g" path="res://core/ui/components/slider.tscn" id="1_obgkx"]
@@ -11,6 +11,7 @@
1111
[ext_resource type="PackedScene" uid="uid://8m20p2s0v5gb" path="res://core/systems/input/focus_group.tscn" id="5_sh522"]
1212
[ext_resource type="Script" uid="uid://ohebcttenf0j" path="res://core/systems/input/focus_group_setter.gd" id="7_5nxbl"]
1313
[ext_resource type="PackedScene" uid="uid://bk5ld0h1jgd2t" path="res://core/ui/components/card_button_setting.tscn" id="9_3ae07"]
14+
[ext_resource type="PackedScene" uid="uid://d1qb7euwlu7bh" path="res://core/ui/components/toggle.tscn" id="10_xbbsv"]
1415
[ext_resource type="Script" uid="uid://cdkerf1patjqp" path="res://core/systems/library/library_refresher.gd" id="10_xjg34"]
1516

1617
[node name="LibrarySettingsMenu" type="ScrollContainer"]
@@ -59,6 +60,14 @@ current_focus = NodePath("../MaxRecentAppsSlider")
5960
layout_mode = 2
6061
text = "General"
6162

63+
[node name="LocalLibraryToggle" parent="MarginContainer/VBoxContainer" instance=ExtResource("10_xbbsv")]
64+
unique_name_in_owner = true
65+
layout_mode = 2
66+
text = "Enable Desktop Library"
67+
separator_visible = false
68+
description = "Show locally installed games in your library"
69+
button_pressed = true
70+
6271
[node name="RefreshLibraryButton" parent="MarginContainer/VBoxContainer" instance=ExtResource("9_3ae07")]
6372
layout_mode = 2
6473
text = "Refresh Library"

0 commit comments

Comments
 (0)