-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Library): add option and menu to hide items in library
- Loading branch information
1 parent
f221c0c
commit b026738
Showing
19 changed files
with
359 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[gd_resource type="Resource" script_class="State" load_steps=2 format=3 uid="uid://bnw36g1l7shcy"] | ||
|
||
[ext_resource type="Script" path="res://core/systems/state/state.gd" id="1_ds0g8"] | ||
|
||
[resource] | ||
script = ExtResource("1_ds0g8") | ||
name = "library" | ||
data = {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[gd_resource type="Resource" script_class="State" load_steps=2 format=3 uid="uid://blcfrofi5oawd"] | ||
|
||
[ext_resource type="Script" path="res://core/systems/state/state.gd" id="1_728sf"] | ||
|
||
[resource] | ||
script = ExtResource("1_728sf") | ||
name = "library" | ||
data = {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
extends ScrollContainer | ||
|
||
var settings_manager := load("res://core/global/settings_manager.tres") as SettingsManager | ||
var library_manager := load("res://core/global/library_manager.tres") as LibraryManager | ||
var library_state := load("res://assets/state/states/game_settings_library.tres") as State | ||
var game_settings_state := load("res://assets/state/states/game_settings.tres") as State | ||
var library_item: LibraryItem | ||
var logger := Log.get_logger("GameSettingsLibrary") | ||
|
||
@onready var hide_toggle := $%HideToggle as Toggle | ||
|
||
|
||
# Called when the node enters the scene tree for the first time. | ||
func _ready() -> void: | ||
library_state.state_entered.connect(_on_state_entered) | ||
library_state.state_exited.connect(_on_state_exited) | ||
|
||
# When the hide button is toggled, update the settings for this library item | ||
var on_hide_toggled := func(is_hidden: bool): | ||
if not library_item: | ||
return | ||
settings_manager.set_library_value(library_item, "hidden", is_hidden) | ||
library_item.is_hidden = is_hidden | ||
if is_hidden: | ||
library_manager.library_item_hidden.emit(library_item) | ||
else: | ||
library_manager.library_item_unhidden.emit(library_item) | ||
hide_toggle.toggled.connect(on_hide_toggled) | ||
|
||
|
||
func _on_state_entered(_from: State) -> void: | ||
# Get the current library item | ||
if game_settings_state.has_meta("item"): | ||
library_item = game_settings_state.get_meta("item") as LibraryItem | ||
elif "item" in game_settings_state.data: | ||
library_item = game_settings_state.data["item"] as LibraryItem | ||
|
||
if not library_item: | ||
logger.warn("No library item set in game settings state to configure") | ||
return | ||
|
||
# Find the settings | ||
var is_hidden := settings_manager.get_library_value(library_item, "hidden", false) as bool | ||
hide_toggle.button_pressed = is_hidden | ||
|
||
|
||
func _on_state_exited(_to: State) -> void: | ||
library_item = null |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
[gd_scene load_steps=8 format=3 uid="uid://bvdasrjrvyp11"] | ||
|
||
[ext_resource type="Script" path="res://core/ui/card_ui/launch/game_settings_library.gd" id="1_f1pex"] | ||
[ext_resource type="PackedScene" uid="uid://shvyhrv5sx3v" path="res://core/systems/state/state_watcher.tscn" id="1_mk47q"] | ||
[ext_resource type="Resource" uid="uid://bnw36g1l7shcy" path="res://assets/state/states/game_settings_library.tres" id="2_j1lqu"] | ||
[ext_resource type="PackedScene" uid="uid://bw8113ocotx2r" path="res://core/systems/effects/fade_effect.tscn" id="3_tkmdj"] | ||
[ext_resource type="PackedScene" uid="uid://8m20p2s0v5gb" path="res://core/systems/input/focus_group.tscn" id="4_qj1l3"] | ||
[ext_resource type="Resource" uid="uid://cc6i4i264dmqd" path="res://core/ui/card_ui/launch/game_settings_focus.tres" id="5_7h7mk"] | ||
[ext_resource type="PackedScene" uid="uid://d1qb7euwlu7bh" path="res://core/ui/components/toggle.tscn" id="6_e3kvo"] | ||
|
||
[node name="LibrarySettings" type="ScrollContainer"] | ||
anchors_preset = 15 | ||
anchor_right = 1.0 | ||
anchor_bottom = 1.0 | ||
grow_horizontal = 2 | ||
grow_vertical = 2 | ||
size_flags_horizontal = 3 | ||
size_flags_vertical = 3 | ||
follow_focus = true | ||
script = ExtResource("1_f1pex") | ||
|
||
[node name="StateWatcher" parent="." instance=ExtResource("1_mk47q")] | ||
state = ExtResource("2_j1lqu") | ||
|
||
[node name="FadeEffect" parent="StateWatcher" node_paths=PackedStringArray("target") instance=ExtResource("3_tkmdj")] | ||
target = NodePath("../..") | ||
on_signal = "state_entered" | ||
fade_out_signal = "state_exited" | ||
on_signal = "state_entered" | ||
|
||
[node name="MarginContainer" type="MarginContainer" parent="."] | ||
layout_mode = 2 | ||
size_flags_horizontal = 3 | ||
size_flags_vertical = 3 | ||
theme_override_constants/margin_left = 4 | ||
theme_override_constants/margin_top = 4 | ||
theme_override_constants/margin_right = 4 | ||
theme_override_constants/margin_bottom = 4 | ||
|
||
[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer"] | ||
layout_mode = 2 | ||
|
||
[node name="FocusGroup" parent="MarginContainer/VBoxContainer" node_paths=PackedStringArray("current_focus") instance=ExtResource("4_qj1l3")] | ||
current_focus = NodePath("../HideToggle") | ||
focus_stack = ExtResource("5_7h7mk") | ||
|
||
[node name="HideToggle" parent="MarginContainer/VBoxContainer" instance=ExtResource("6_e3kvo")] | ||
unique_name_in_owner = true | ||
layout_mode = 2 | ||
text = "Hidden in library" | ||
description = "Prevent this item from showing up in your library" | ||
button_pressed = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.