From 070ed0063a1853783fb421cf7797495443df0a53 Mon Sep 17 00:00:00 2001 From: Mahmood Heidari Date: Fri, 13 Jan 2023 11:20:29 +0330 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=89=20feat:=20no=5Feffect=5Fchange=5Fs?= =?UTF-8?q?cene=20function=20added?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.rst | 1 + addons/scene_manager/scene_manager.gd | 10 ++++++++++ addons/scene_manager/sub_section.gd | 2 ++ addons/scene_manager/sub_section.tscn | 16 ++++++++-------- 4 files changed, 21 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index f1cde2a..85e7487 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -4,6 +4,7 @@ CHANGELOG UNRELEASED ---------- +* 🎉 feat: no_effect_change_scene function added * 🎉 feat: sublist in lists is now possible * 🎉 feat: added sub section basic functionality but not full functionality * 🎉 feat: basics of sub_section added diff --git a/addons/scene_manager/scene_manager.gd b/addons/scene_manager/scene_manager.gd index bde3d7a..33ff391 100644 --- a/addons/scene_manager/scene_manager.gd +++ b/addons/scene_manager/scene_manager.gd @@ -317,6 +317,16 @@ func change_scene(scene, fade_out_options: Options, fade_in_options: Options, ge _set_clickable(true) _set_out_transition() +# Change scene with no effect +func no_effect_change_scene(scene, hold_timeout: float = 0.0, add_to_back: bool = true): + if (scene is PackedScene || (typeof(scene) == TYPE_STRING && safe_validate_scene(scene) && !_in_transition)): + _first_time = false + _set_in_transition() + await get_tree().create_timer(hold_timeout).timeout + if _change_scene(scene, add_to_back): + await get_tree().node_added + _set_out_transition() + # loads scene interactive # connect to `load_percent_changed(value: int)` and `load_finished` signals # to listen to updates on your scene loading status diff --git a/addons/scene_manager/sub_section.gd b/addons/scene_manager/sub_section.gd index e27b3b5..1b9d65e 100644 --- a/addons/scene_manager/sub_section.gd +++ b/addons/scene_manager/sub_section.gd @@ -22,6 +22,7 @@ func add_item(item: Node) -> void: item._sub_section = self list.add_child(item) +# Removes an item from list func remove_item(item: Node) -> void: list.remove_child(item) @@ -46,6 +47,7 @@ func _on_button_up(): else: open() +# Action on child counting func _check_count(): if list.get_child_count() == 0: if name == "All": diff --git a/addons/scene_manager/sub_section.tscn b/addons/scene_manager/sub_section.tscn index 4b8e42e..8eaadd1 100644 --- a/addons/scene_manager/sub_section.tscn +++ b/addons/scene_manager/sub_section.tscn @@ -5,16 +5,16 @@ [ext_resource type="Script" path="res://addons/scene_manager/sub_section_button.gd" id="3_smgrs"] [ext_resource type="Texture2D" uid="uid://bhejhahjk1yaa" path="res://addons/scene_manager/icons/ImportFail.svg" id="4_chjuj"] -[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_vsivh"] +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_nrcyw"] bg_color = Color(0.156863, 0.176471, 0.207843, 1) -[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_ngg5t"] +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_ie52c"] bg_color = Color(0.219608, 0.239216, 0.266667, 1) -[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_joycj"] +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_l26s1"] bg_color = Color(0.129412, 0.14902, 0.180392, 1) -[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_3mngj"] +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_n24xb"] bg_color = Color(0.6, 0.6, 0.6, 0) [node name="All" type="VBoxContainer"] @@ -29,10 +29,10 @@ layout_mode = 2 custom_minimum_size = Vector2(0, 28) layout_mode = 2 size_flags_horizontal = 3 -theme_override_styles/normal = SubResource("StyleBoxFlat_vsivh") -theme_override_styles/hover = SubResource("StyleBoxFlat_ngg5t") -theme_override_styles/pressed = SubResource("StyleBoxFlat_joycj") -theme_override_styles/focus = SubResource("StyleBoxFlat_3mngj") +theme_override_styles/normal = SubResource("StyleBoxFlat_nrcyw") +theme_override_styles/hover = SubResource("StyleBoxFlat_ie52c") +theme_override_styles/pressed = SubResource("StyleBoxFlat_l26s1") +theme_override_styles/focus = SubResource("StyleBoxFlat_n24xb") text = "All" icon = ExtResource("1_yyg5g") alignment = 0