forked from godotengine/godot
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add godot app lifecycle callbacks to modules.
This feature add a mechanism that emits a notification when a specific app lifecycle phase is executed. It call the callback on: - Setup begins (`Main::setup`) LIFECYCLE_PHASE_SETUP_BEGIN - Setup2 begins (`Main::setup2`) LIFECYCLE_PHASE_SETUP2_BEGIN - Setup2 done (`Main::setup2`) LIFECYCLE_PHASE_SETUP2_DONE - Start begins (`Main::start`) LIFECYCLE_PHASE_START_BEGIN - Start done (`Main::start`) LIFECYCLE_PHASE_START_DONE - Cleanup begins (`Main::cleanup`) LIFECYCLE_PHASE_CLEANUP_BEGIN - Cleanup done (`Main::cleanup`) LIFECYCLE_PHASE_CLEANUP_DONE ---- To use it, it's enough to implement the function `void MODULENAME_lifecycle_callback(int);` to `yourmodule/register_types.h` and define the macro: `#define MODULE_MODULENAME_HAS_LIFECYCLE_CALLBACK` For example, if we need to register a new singleton in the GLTF module, we can write the following: ```c++ // .h void gltf_lifecycle_callback(int p_lifecycle_phase); // .cpp void gltf_lifecycle_callback(int p_lifecycle_phase) { switch (p_lifecycle_phase) { case LIFECYCLE_PHASE_STARTUP_BEGIN: // TODO Init here the singleton. break; case LIFECYCLE_PHASE_CLEANUP_BEGIN: // TODO Clear here the singleton. break; } } ``` Implements the proposal: godotengine/godot-proposals#1593 The proposal code is different than this implementation because this code is using the adviced implementation the core dev adviced.
- Loading branch information
1 parent
6bf26fb
commit 9c15657
Showing
4 changed files
with
29 additions
and
0 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
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