From a0ba4f2cabf412d45afaecd9eeb9fe750e25948f Mon Sep 17 00:00:00 2001 From: Relintai Date: Sun, 8 Jan 2023 15:55:22 +0100 Subject: [PATCH] Updated register_types.h and cpp to the current godot 4 style. --- register_types.cpp | 104 +++++++++++++++++++++++---------------------- register_types.h | 6 ++- 2 files changed, 57 insertions(+), 53 deletions(-) diff --git a/register_types.cpp b/register_types.cpp index 6946433..167a9f3 100644 --- a/register_types.cpp +++ b/register_types.cpp @@ -24,11 +24,7 @@ SOFTWARE. #include "core/version.h" -#if VERSION_MAJOR > 3 #include "core/config/engine.h" -#else -#include "core/engine.h" -#endif #include "tiled_wall/tiled_wall.h" #include "tiled_wall/tiled_wall_data.h" @@ -77,83 +73,89 @@ SOFTWARE. static PropUtils *prop_utils = NULL; static PropCache *prop_texture_cache = NULL; -void register_props_types() { - ClassDB::register_class(); - ClassDB::register_class(); +void initialize_props_module(ModuleInitializationLevel p_level) { + if (p_level == MODULE_INITIALIZATION_LEVEL_SCENE) { + GDREGISTER_CLASS(TiledWall); + GDREGISTER_CLASS(TiledWallData); - ClassDB::register_class(); + GDREGISTER_CLASS(PropLight); - ClassDB::register_class(); - ClassDB::register_class(); - ClassDB::register_class(); - ClassDB::register_class(); - ClassDB::register_class(); - ClassDB::register_class(); + GDREGISTER_CLASS(PropData); + GDREGISTER_CLASS(PropDataEntry); + GDREGISTER_CLASS(PropDataScene); + GDREGISTER_CLASS(PropDataLight); + GDREGISTER_CLASS(PropDataProp); + GDREGISTER_CLASS(PropDataTiledWall); #if VERSION_MINOR >= 4 - ClassDB::register_class(); + GDREGISTER_CLASS(PropDataPortal); #endif - ClassDB::register_class(); - ClassDB::register_class(); + GDREGISTER_CLASS(GroundClutter); + GDREGISTER_CLASS(GroundClutterFoliage); - ClassDB::register_class(); - ClassDB::register_class(); + GDREGISTER_CLASS(PropMesher); + GDREGISTER_CLASS(PropMesherJobStep); - ClassDB::register_class(); - ClassDB::register_class(); + GDREGISTER_CLASS(PropInstance); + GDREGISTER_CLASS(PropInstanceMerger); - ClassDB::register_class(); + GDREGISTER_CLASS(PropESSEntity); - ClassDB::register_class(); - ClassDB::register_class(); + GDREGISTER_CLASS(PropInstanceJob); + GDREGISTER_CLASS(PropInstancePropJob); - ClassDB::register_class(); + GDREGISTER_CLASS(PropTextureJob); - ClassDB::register_class(); + GDREGISTER_CLASS(PropSceneInstance); - ClassDB::register_class(); + GDREGISTER_CLASS(PropMaterialCache); #ifdef TEXTURE_PACKER_PRESENT - ClassDB::register_class(); + GDREGISTER_CLASS(PropMaterialCachePCM); #endif - prop_utils = memnew(PropUtils); - ClassDB::register_class(); - Engine::get_singleton()->add_singleton(Engine::Singleton("PropUtils", PropUtils::get_singleton())); + prop_utils = memnew(PropUtils); + GDREGISTER_CLASS(PropUtils); + Engine::get_singleton()->add_singleton(Engine::Singleton("PropUtils", PropUtils::get_singleton())); - prop_texture_cache = memnew(PropCache); - ClassDB::register_class(); - Engine::get_singleton()->add_singleton(Engine::Singleton("PropCache", PropCache::get_singleton())); + prop_texture_cache = memnew(PropCache); + GDREGISTER_CLASS(PropCache); + Engine::get_singleton()->add_singleton(Engine::Singleton("PropCache", PropCache::get_singleton())); - Ref light_processor = Ref(memnew(PropDataLight)); - PropUtils::add_processor(light_processor); + Ref light_processor = Ref(memnew(PropDataLight)); + PropUtils::add_processor(light_processor); - Ref prop_processor = Ref(memnew(PropDataProp)); - PropUtils::add_processor(prop_processor); + Ref prop_processor = Ref(memnew(PropDataProp)); + PropUtils::add_processor(prop_processor); - Ref scene_processor = Ref(memnew(PropDataScene)); - PropUtils::add_processor(scene_processor); + Ref scene_processor = Ref(memnew(PropDataScene)); + PropUtils::add_processor(scene_processor); #if VERSION_MINOR >= 4 - Ref portal_processor = Ref(memnew(PropDataPortal)); - PropUtils::add_processor(portal_processor); + Ref portal_processor = Ref(memnew(PropDataPortal)); + PropUtils::add_processor(portal_processor); #endif - Ref tiled_wall_processor = Ref(memnew(PropDataTiledWall)); - PropUtils::add_processor(tiled_wall_processor); + Ref tiled_wall_processor = Ref(memnew(PropDataTiledWall)); + PropUtils::add_processor(tiled_wall_processor); + } #ifdef TOOLS_ENABLED - EditorPlugins::add_by_type(); + if (p_level == MODULE_INITIALIZATION_LEVEL_EDITOR) { + EditorPlugins::add_by_type(); + } #endif } -void unregister_props_types() { - if (prop_utils) { - memdelete(prop_utils); - } +void uninitialize_props_module(ModuleInitializationLevel p_level) { + if (p_level == MODULE_INITIALIZATION_LEVEL_SCENE) { + if (prop_utils) { + memdelete(prop_utils); + } - if (prop_texture_cache) { - memdelete(prop_texture_cache); + if (prop_texture_cache) { + memdelete(prop_texture_cache); + } } } diff --git a/register_types.h b/register_types.h index 3bb73f8..c0552f2 100644 --- a/register_types.h +++ b/register_types.h @@ -23,7 +23,9 @@ SOFTWARE. #ifndef PROPS_REGISTER_TYPES_H #define PROPS_REGISTER_TYPES_H -void register_props_types(); -void unregister_props_types(); +#include "modules/register_module_types.h" + +void initialize_props_module(ModuleInitializationLevel p_level); +void uninitialize_props_module(ModuleInitializationLevel p_level); #endif