Skip to content

Commit 7f08d5e

Browse files
committed
📖 docs: v3.8.0
1 parent 8ea97f5 commit 7f08d5e

File tree

13 files changed

+187
-81
lines changed

13 files changed

+187
-81
lines changed

CHANGELOG.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@ CHANGELOG
44
UNRELEASED
55
----------
66

7-
* 🎉 feat: added ability to load scenes interactive
7+
3.8.0 (2023-11-22)
8+
------------------
9+
10+
* feat: added ability to load scenes interactive and have a loading phase like world generation or any loading in general
11+
* fix: fixed a bug on when couldn't reload the current scenes when we used loading screen to get to them
812

913
3.7.0 (2023-11-03)
1014
------------------

README.md

Lines changed: 136 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,15 @@ A tool to manage transition between different scenes.\
88
Scene Manager v1.X.X and v2.X.X is compatible with Godot 3.\
99
Scene Manager v3.X.X is compatible with Godot 4.
1010

11+
**Note**: Scene Manager v2.X.X and v1.X.X has heavily less features.
12+
1113
## Features
1214

1315
**Recently Added**:
1416

15-
* [X] Possibility to specify path scenes.db via Project/Settings (Just Godot4)
16-
* [X] 5 new signals added:
17-
- scene_changed
18-
- fade_in_started
19-
- fade_out_started
20-
- fade_in_finished
21-
- fade_out_finished
22-
* [X] added a feature to navigate to the scene path in filesystem on godot when clicked on scene address in Scene Manager tool
23-
* [X] added a feature to open a desired scene from Scene Manager tab
17+
* [X] Added a feature to navigate to the scene path in filesystem on godot when clicked on scene address in Scene Manager tool
18+
* [X] Added a feature to open a desired scene from Scene Manager tab
19+
* [X] Users now can have some time to load their scene in the background with the new changing scene functionality
2420

2521
**All**:
2622

@@ -48,7 +44,13 @@ Scene Manager v3.X.X is compatible with Godot 4.
4844
* [X] sublist in lists of scene manager UI is now possible (Just Godot4)
4945
* [X] `no_effect_change_scene` function added (Just Godot4)
5046
* [X] Node can be added to `change_scene` and `no_effect_change_scene` functions (Just Godot4)
51-
47+
* [X] Possibility to specify path scenes.db via Project/Settings (Just Godot4)
48+
* [X] 5 new signals added:
49+
* scene_changed
50+
* fade_in_started
51+
* fade_out_started
52+
* fade_in_finished
53+
* fade_out_finished
5254

5355
## How To Use?
5456

@@ -69,15 +71,15 @@ This is the tool that you will see on your right side of the godot editor after
6971
<img src="images/tool.png"/>
7072
</p>
7173

72-
### Double key checker:
74+
### Double key checker
7375

7476
If editing of a scene key causes at least two keys of another scene match, both of them will get red color and you have to fix the duplication, otherwise the plugin does not work properly as you expect it to work.
7577

7678
<p align="center">
7779
<img src="images/tool_double_key.png"/>
7880
</p>
7981

80-
### Ignore Folder:
82+
### Ignore Folder
8183

8284
Every folder that is added inside this section will be ignored and scenes inside them will not get included inside scenes categories section(the section above this section).
8385

@@ -107,15 +109,15 @@ As it is visible on previous pictures, it is possible to add sublists in lists a
107109

108110
All you have to do is drag scenes by their buttons on the left and drop them on other sublists.
109111

110-
## Demo
112+
# Demo
111113

112114
Just a simple demo to show some abilities of this addon:
113115

114116
<p align="center">
115117
<img src="./images/demo.gif"/>
116118
</p>
117119

118-
### Demo Description
120+
## Demo Description
119121

120122
1. Scene \<number\>: this button calls `change_scene` function and goes to next scene.
121123
2. Reset: after pressing this button, you don't go back to the previous seen scenes by pressing back button but if you do, you actually restart your scene.
@@ -124,11 +126,11 @@ Just a simple demo to show some abilities of this addon:
124126
5. Nothing: just shows a transition but actually does nothing.
125127
6. Exit: after fading out of the screen, quits the game.
126128

127-
### Demo Code
129+
## Demo Code
128130

129131
**Note**: You can use `SceneManager` node in your game after you activated `scene_manager` plugin.
130132

131-
Example:
133+
### Simple Example Without any Loading Screen
132134

133135
```gdscript
134136
extends Button
@@ -152,27 +154,31 @@ extends Button
152154
@onready var general_options = SceneManager.create_general_options(color, timeout, clickable, add_to_back)
153155
154156
func _ready() -> void:
155-
var fade_in_first_scene_options = SceneManager.create_options(1, "fade")
156-
var first_scene_general_options = SceneManager.create_general_options(Color(0, 0, 0), 1, false)
157-
SceneManager.show_first_scene(fade_in_first_scene_options, first_scene_general_options)
158-
# code breaks if scene is not recognizable
159-
SceneManager.validate_scene(scene)
160-
# code breaks if pattern is not recognizable
161-
SceneManager.validate_pattern(fade_out_pattern)
162-
SceneManager.validate_pattern(fade_in_pattern)
157+
var fade_in_first_scene_options = SceneManager.create_options(1, "fade")
158+
var first_scene_general_options = SceneManager.create_general_options(Color(0, 0, 0), 1, false)
159+
SceneManager.show_first_scene(fade_in_first_scene_options, first_scene_general_options)
160+
# code breaks if scene is not recognizable
161+
SceneManager.validate_scene(scene)
162+
# code breaks if pattern is not recognizable
163+
SceneManager.validate_pattern(fade_out_pattern)
164+
SceneManager.validate_pattern(fade_in_pattern)
163165
164166
func _on_button_button_up():
165-
SceneManager.change_scene(scene, fade_out_options, fade_in_options, general_options)
167+
SceneManager.change_scene(scene, fade_out_options, fade_in_options, general_options)
166168
167169
func _on_reset_button_up():
168-
SceneManager.reset_scene_manager()
170+
SceneManager.reset_scene_manager()
169171
170172
func _on_loading_scene_button_up():
171-
SceneManager.set_recorded_scene(scene)
172-
SceneManager.change_scene("loading", fade_out_options, fade_in_options, general_options)
173+
SceneManager.set_recorded_scene(scene)
174+
SceneManager.change_scene("loading", fade_out_options, fade_in_options, general_options)
175+
176+
func _on_loading_scene_initialization_button_up():
177+
SceneManager.set_recorded_scene(scene)
178+
SceneManager.change_scene("loading_with_initialization", fade_out_options, fade_in_options, general_options)
173179
```
174180

175-
Loading Scene Code Example:
181+
### Simple Example With Loading Screen
176182

177183
```gdscript
178184
extends Control
@@ -183,27 +189,105 @@ extends Control
183189
@onready var next: Button = find_child("Next")
184190
185191
func _ready():
186-
SceneManager.load_percent_changed.connect(Callable(self, "percent_changed"))
187-
SceneManager.load_finished.connect(Callable(self, "loading_finished"))
188-
SceneManager.load_scene_interactive(SceneManager.get_recorded_scene())
192+
SceneManager.load_percent_changed.connect(percent_changed)
193+
SceneManager.load_finished.connect(loading_finished)
194+
SceneManager.load_scene_interactive(SceneManager.get_recorded_scene())
189195
190196
func percent_changed(number: int) -> void:
191-
progress.value = number
197+
progress.value = number
192198
193199
func loading_finished() -> void:
194-
loading.visible = false
195-
next.visible = true
200+
loading.visible = false
201+
next.visible = true
196202
197203
func _on_next_button_up():
198-
var fade_out_options = SceneManager.create_options(1.0, "scribbles", 0.2, true)
199-
var fade_in_options = SceneManager.create_options(1.0, "crooked_tiles", 0.2, true)
200-
var general_options = SceneManager.create_general_options(Color(0, 0, 0), 0, false, true)
201-
SceneManager.change_scene_to_loaded_scene(fade_out_options, fade_in_options, general_options)
204+
var fade_out_options = SceneManager.create_options(1.0, "scribbles", 0.2, true)
205+
var fade_in_options = SceneManager.create_options(1.0, "crooked_tiles", 0.2, true)
206+
var general_options = SceneManager.create_general_options(Color(0, 0, 0), 0, false, true)
207+
SceneManager.change_scene_to_loaded_scene(fade_out_options, fade_in_options, general_options)
208+
```
209+
210+
### More Complex Example With Loading Screen for Scenarios That Scenes Need Some Time in Background
211+
212+
#### First Part
213+
214+
**Note**: This example is for someone who needs to generate a world in the background and then show the scene to the user or someone who generally needs to load some data in the background and then show the new scene to the user/player.
215+
216+
```gdscript
217+
extends Control
218+
219+
# Nodes
220+
@onready var progress: ProgressBar = find_child("Progress")
221+
@onready var loading: AnimatedSprite2D = find_child("Loading")
222+
@onready var next: Button = find_child("Next")
223+
@onready var label: Label = find_child("Label")
224+
225+
var gap = 30
226+
227+
func _ready():
228+
SceneManager.load_percent_changed.connect(percent_changed)
229+
SceneManager.load_finished.connect(loading_finished)
230+
SceneManager.load_scene_interactive(SceneManager.get_recorded_scene())
231+
232+
func percent_changed(number: int) -> void:
233+
# the last `gap%` is for the loaded scene itself to load its own data or initialize or world generate or ...
234+
progress.value = max(number - gap, 0)
235+
if progress.value >= 90:
236+
label.text = "World Generation . . ."
237+
238+
func loading_finished() -> void:
239+
# All loading processes are finished now
240+
if progress.value == 100:
241+
loading.visible = false
242+
next.visible = true
243+
label.text = ""
244+
# Loading finishes and world initialization or world generation or whatever you wanna call it will start
245+
elif progress.value == 70:
246+
SceneManager.add_loaded_scene_to_scene_tree()
247+
gap = 0
248+
label.text = "Scene Initialization . . ."
249+
250+
func _on_next_button_up():
251+
var fade_out_options = SceneManager.create_options(1.0, "scribbles", 0.2, true)
252+
var fade_in_options = SceneManager.create_options(1.0, "crooked_tiles", 0.2, true)
253+
var general_options = SceneManager.create_general_options(Color(0, 0, 0), 0, false, true)
254+
SceneManager.change_scene_to_existing_scene_in_scene_tree(fade_out_options, fade_in_options, general_options)
255+
```
256+
257+
#### Second Part
258+
259+
Assume this part is in the new scene which needs some time in the background:
260+
261+
**Note**: This part emits the signal of `load_percent_changed` of SceneManager to inform the loading screen to change the percentage to inform user that something is happening.
262+
**Note**: After the loading process is finished, `load_finished` will be called to inform the loading screen which everything is ready to change to the new scene.
263+
264+
```gdscript
265+
extends Control
266+
267+
var t = Timer.new()
268+
var count = 0
269+
270+
func _ready():
271+
self.add_child(t)
272+
t.timeout.connect(_on_timeout)
273+
t.start(1)
274+
275+
func _on_timeout():
276+
count += 1
277+
if count == 1:
278+
SceneManager.load_percent_changed.emit(80 + randi_range(0, 9))
279+
elif count == 2:
280+
SceneManager.load_percent_changed.emit(90 + randi_range(0, 9))
281+
if count == 3:
282+
SceneManager.load_percent_changed.emit(100)
283+
SceneManager.load_finished.emit()
284+
t.timeout.disconnect(_on_timeout)
285+
t.start(count + 1)
202286
```
203287

204288
## SceneManager
205289

206-
### Signals:
290+
### Signals
207291

208292
1. load_finished => signal fires when interactively loading a scene finishes
209293
2. load_percent_changed(value: int) => signal fires when interactively loading a scene progress percentage updates
@@ -213,9 +297,10 @@ func _on_next_button_up():
213297
6. fade_in_finished => signal fires when fade in finishes
214298
7. fade_out_finished => signal fires when fade out finishes
215299

216-
### Methods:
300+
### Methods
217301

218302
This is the node you use inside your game code and it has these functions:
303+
219304
1. `validate_scene`(**key**: String) -> void:
220305
* Checks and validates passed **key** in scenes keys. (breaks game if key doesn't exist in scenes keys)
221306
2. `validate_pattern`(**key**: String) -> void:
@@ -249,7 +334,7 @@ This is the node you use inside your game code and it has these functions:
249334
* **timeout** = between this scene and next scene, there would be a gap which can take much longer that usual(default is 0) by your choice by changing this option.
250335
* **clickable** = makes the scene behind the transition visuals clickable or not.
251336
* **add_to_back** = if true, you can go back to current scene after changing scene to next scene by going to "back" scene which means previous scene.
252-
9. `show_first_scene`(**fade_in_options**: Options, **general_options**: GeneralOptions) -> void:
337+
9. `show_first_scene`(**fade_in_options**: Options, **general_options**: GeneralOptions) -> void:
253338
* Call this method inside `_ready` function of a node with a script which that node is inside the first scene that game jumps into it and this causes to have a smooth transition into the first game scene.
254339
* This function works just once at the beginning of the first game scene. After that, if you call this function again, nothing happens.
255340
* **fade_in_options** = creates it by calling `create_options` function.
@@ -261,9 +346,9 @@ This is the node you use inside your game code and it has these functions:
261346
12. `set_back_limit`(**input**: int) -> void:
262347
* Limits how much deep scene manager is allowed to record previous scenes which affects in changing scene to `back`(previous scene) functionality.
263348
* Allowed `input` values:
264-
1. input = -1 => unlimited (default)
265-
2. input = 0 => we can not go back to any previous scenes
266-
3. input > 0 => we can go back to `input` or less previous scenes
349+
1. input = -1 => unlimited (default)
350+
2. input = 0 => we can not go back to any previous scenes
351+
3. input > 0 => we can go back to `input` or less previous scenes
267352
13. `get_scene`(**key**: String) -> PackedScene:
268353
* Returns PackedScene of passed scene key (blocking)
269354
14. `load_scene_interactive`(**key**: String) -> void:
@@ -287,3 +372,9 @@ This is the node you use inside your game code and it has these functions:
287372
* Records a scene key to be used for loading scenes to know where to go after getting loaded into loading scene or just for next scene to know where to go next.
288373
22. `get_recorded_scene`() -> String:
289374
* Returns recorded scene by `set_recorded_scene` function.
375+
23. `add_loaded_scene_to_scene_tree`() -> void:
376+
* Imports loaded scene into the scene tree but doesn't change the current scene
377+
* Maily used when your new loaded scene has a loading phase when added to scene tree
378+
* So to use this, first has to call `load_scene_interactive` to load your scene and then have to listen on `load_finished` signal and after the signal emits, you call this function and this function adds the loaded scene to the scene tree but exactly behind the current scene so that you still can not see the new scene
379+
24. `change_scene_to_existing_scene_in_scene_tree`(**fade_out_options**: Options, **fade_in_options**: Options, **general_options**: GeneralOptions) -> void:
380+
* when you added the loaded scene to the scene tree by `add_loaded_scene_to_scene_tree` function, you call this function after you are sure that the added scene to scene tree is completely ready and functional to change the active scene

addons/scene_manager/plugin.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
name="scene_manager"
44
description="A powerful scene transition manager for godot."
55
author="Maktoobgar"
6-
version="3.7.0"
6+
version="3.8.0"
77
script="plugin.gd"

addons/scene_manager/scene_manager.gd

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,11 @@ func no_effect_change_scene(scene, hold_timeout: float = 0.0, add_to_back: bool
370370
_set_out_transition()
371371

372372
# imports loaded scene into the scene tree but doesn't change the scene
373-
# maily used when your new loaded scene has a loading phase too
373+
# maily used when your new loaded scene has a loading phase when added to scene tree
374+
# so to use this, first has to call `load_scene_interactive` to load your scene
375+
# and then have to listen on `load_finished` signal and after the signal emits,
376+
# you call this function and this function adds the loaded scene to the scene
377+
# tree but exactly behind the current scene so that you still can not see the new scene
374378
func add_loaded_scene_to_scene_tree() -> void:
375379
if _load_scene != "":
376380
var scene_resource = ResourceLoader.load_threaded_get(_load_scene) as PackedScene
@@ -383,8 +387,8 @@ func add_loaded_scene_to_scene_tree() -> void:
383387
_load_scene = ""
384388

385389
# when you added the loaded scene to the scene tree by `add_loaded_scene_to_scene_tree`
386-
# function, you call this one after you are sure that the added scene to scene tree
387-
# is completely ready and functionaly to change the active scene
390+
# function, you call this function after you are sure that the added scene to scene tree
391+
# is completely ready and functional to change the active scene
388392
func change_scene_to_existing_scene_in_scene_tree(fade_out_options: Options, fade_in_options: Options, general_options: GeneralOptions) -> void:
389393
_set_in_transition()
390394
_set_clickable(general_options.clickable)

demo/loading.gd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ extends Control
66
@onready var next: Button = find_child("Next")
77

88
func _ready():
9-
SceneManager.load_percent_changed.connect(Callable(self, "percent_changed"))
10-
SceneManager.load_finished.connect(Callable(self, "loading_finished"))
9+
SceneManager.load_percent_changed.connect(percent_changed)
10+
SceneManager.load_finished.connect(loading_finished)
1111
SceneManager.load_scene_interactive(SceneManager.get_recorded_scene())
1212

1313
func percent_changed(number: int) -> void:

demo/loading_phase_mechanic.gd

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@ func _ready():
99
t.start(1)
1010

1111
func _on_timeout():
12-
if count == 2:
13-
SceneManager.load_percent_changed.emit(130)
12+
count += 1
13+
if count == 1:
14+
SceneManager.load_percent_changed.emit(80 + randi_range(0, 9))
15+
elif count == 2:
16+
SceneManager.load_percent_changed.emit(90 + randi_range(0, 9))
17+
if count == 3:
18+
SceneManager.load_percent_changed.emit(100)
1419
SceneManager.load_finished.emit()
1520
t.timeout.disconnect(_on_timeout)
16-
else:
17-
count += 1
18-
SceneManager.load_percent_changed.emit(100 + (count * 10) + randi_range(0, 9))
19-
t.start(count + 1)
21+
t.start(count + 1)

0 commit comments

Comments
 (0)