Skip to content

Commit

Permalink
🎉 feat: Node can be added to change_scene and `no_effect_change_sce…
Browse files Browse the repository at this point in the history
…ne` functions
  • Loading branch information
maktoobgar committed Jan 13, 2023
1 parent 070ed00 commit 0d9c98b
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 8 deletions.
11 changes: 7 additions & 4 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@ 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
* 🎉 feat: Node can be added to `change_scene` and `no_effect_change_scene` functions

3.4.0 (2023-01-13)
------------------

* feat: `no_effect_change_scene` function added
* feat: sublist in lists is now possible

3.3.0 (2023-01-06)
------------------
Expand Down
26 changes: 22 additions & 4 deletions addons/scene_manager/scene_manager.gd
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,22 @@ func _change_scene(scene, add_to_back: bool) -> bool:
_append_stack(found_key)
return true

if scene is Node:
var root = get_tree().get_root()
root.get_child(root.get_child_count() - 1).free()
root.add_child(scene)
get_tree().set_current_scene(scene)
var path: String = scene.scene_file_path
var found_key: String = ""
for key in Scenes.scenes:
if key.begins_with("_"):
continue
if Scenes.scenes[key]["value"] == path:
found_key = key
if add_to_back && found_key != "":
_append_stack(found_key)
return true

if scene == "back":
return _back()

Expand Down Expand Up @@ -299,15 +315,16 @@ func get_scene(key: String) -> PackedScene:

# changes current scene to the next scene
func change_scene(scene, fade_out_options: Options, fade_in_options: Options, general_options: GeneralOptions) -> void:
if (scene is PackedScene || (typeof(scene) == TYPE_STRING && safe_validate_scene(scene) && !_in_transition)):
if (scene is PackedScene || scene is Node || (typeof(scene) == TYPE_STRING && safe_validate_scene(scene) && !_in_transition)):
_first_time = false
_set_in_transition()
_set_clickable(general_options.clickable)
_set_pattern(fade_out_options, general_options)
if _fade_out(fade_out_options.fade_speed):
await _animation_player.animation_finished
if _change_scene(scene, general_options.add_to_back):
await get_tree().node_added
if !(scene is Node):
await get_tree().node_added
if _timeout(general_options.timeout):
await get_tree().create_timer(general_options.timeout).timeout
_animation_player.play(NO_COLOR, -1, 1, false)
Expand All @@ -319,12 +336,13 @@ func change_scene(scene, fade_out_options: Options, fade_in_options: Options, ge

# 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)):
if (scene is PackedScene || scene is Node || (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
if !(scene is Node):
await get_tree().node_added
_set_out_transition()

# loads scene interactive
Expand Down

0 comments on commit 0d9c98b

Please sign in to comment.