Updated register_types.h and cpp to the current godot 4 style.

This commit is contained in:
Relintai 2023-01-08 15:55:22 +01:00
parent 983090d21a
commit a0ba4f2cab
2 changed files with 57 additions and 53 deletions

View File

@ -24,11 +24,7 @@ SOFTWARE.
#include "core/version.h" #include "core/version.h"
#if VERSION_MAJOR > 3
#include "core/config/engine.h" #include "core/config/engine.h"
#else
#include "core/engine.h"
#endif
#include "tiled_wall/tiled_wall.h" #include "tiled_wall/tiled_wall.h"
#include "tiled_wall/tiled_wall_data.h" #include "tiled_wall/tiled_wall_data.h"
@ -77,83 +73,89 @@ SOFTWARE.
static PropUtils *prop_utils = NULL; static PropUtils *prop_utils = NULL;
static PropCache *prop_texture_cache = NULL; static PropCache *prop_texture_cache = NULL;
void register_props_types() { void initialize_props_module(ModuleInitializationLevel p_level) {
ClassDB::register_class<TiledWall>(); if (p_level == MODULE_INITIALIZATION_LEVEL_SCENE) {
ClassDB::register_class<TiledWallData>(); GDREGISTER_CLASS(TiledWall);
GDREGISTER_CLASS(TiledWallData);
ClassDB::register_class<PropLight>(); GDREGISTER_CLASS(PropLight);
ClassDB::register_class<PropData>(); GDREGISTER_CLASS(PropData);
ClassDB::register_class<PropDataEntry>(); GDREGISTER_CLASS(PropDataEntry);
ClassDB::register_class<PropDataScene>(); GDREGISTER_CLASS(PropDataScene);
ClassDB::register_class<PropDataLight>(); GDREGISTER_CLASS(PropDataLight);
ClassDB::register_class<PropDataProp>(); GDREGISTER_CLASS(PropDataProp);
ClassDB::register_class<PropDataTiledWall>(); GDREGISTER_CLASS(PropDataTiledWall);
#if VERSION_MINOR >= 4 #if VERSION_MINOR >= 4
ClassDB::register_class<PropDataPortal>(); GDREGISTER_CLASS(PropDataPortal);
#endif #endif
ClassDB::register_class<GroundClutter>(); GDREGISTER_CLASS(GroundClutter);
ClassDB::register_class<GroundClutterFoliage>(); GDREGISTER_CLASS(GroundClutterFoliage);
ClassDB::register_class<PropMesher>(); GDREGISTER_CLASS(PropMesher);
ClassDB::register_class<PropMesherJobStep>(); GDREGISTER_CLASS(PropMesherJobStep);
ClassDB::register_class<PropInstance>(); GDREGISTER_CLASS(PropInstance);
ClassDB::register_class<PropInstanceMerger>(); GDREGISTER_CLASS(PropInstanceMerger);
ClassDB::register_class<PropESSEntity>(); GDREGISTER_CLASS(PropESSEntity);
ClassDB::register_class<PropInstanceJob>(); GDREGISTER_CLASS(PropInstanceJob);
ClassDB::register_class<PropInstancePropJob>(); GDREGISTER_CLASS(PropInstancePropJob);
ClassDB::register_class<PropTextureJob>(); GDREGISTER_CLASS(PropTextureJob);
ClassDB::register_class<PropSceneInstance>(); GDREGISTER_CLASS(PropSceneInstance);
ClassDB::register_class<PropMaterialCache>(); GDREGISTER_CLASS(PropMaterialCache);
#ifdef TEXTURE_PACKER_PRESENT #ifdef TEXTURE_PACKER_PRESENT
ClassDB::register_class<PropMaterialCachePCM>(); GDREGISTER_CLASS(PropMaterialCachePCM);
#endif #endif
prop_utils = memnew(PropUtils); prop_utils = memnew(PropUtils);
ClassDB::register_class<PropUtils>(); GDREGISTER_CLASS(PropUtils);
Engine::get_singleton()->add_singleton(Engine::Singleton("PropUtils", PropUtils::get_singleton())); Engine::get_singleton()->add_singleton(Engine::Singleton("PropUtils", PropUtils::get_singleton()));
prop_texture_cache = memnew(PropCache); prop_texture_cache = memnew(PropCache);
ClassDB::register_class<PropCache>(); GDREGISTER_CLASS(PropCache);
Engine::get_singleton()->add_singleton(Engine::Singleton("PropCache", PropCache::get_singleton())); Engine::get_singleton()->add_singleton(Engine::Singleton("PropCache", PropCache::get_singleton()));
Ref<PropDataLight> light_processor = Ref<PropDataLight>(memnew(PropDataLight)); Ref<PropDataLight> light_processor = Ref<PropDataLight>(memnew(PropDataLight));
PropUtils::add_processor(light_processor); PropUtils::add_processor(light_processor);
Ref<PropDataProp> prop_processor = Ref<PropDataProp>(memnew(PropDataProp)); Ref<PropDataProp> prop_processor = Ref<PropDataProp>(memnew(PropDataProp));
PropUtils::add_processor(prop_processor); PropUtils::add_processor(prop_processor);
Ref<PropDataScene> scene_processor = Ref<PropDataScene>(memnew(PropDataScene)); Ref<PropDataScene> scene_processor = Ref<PropDataScene>(memnew(PropDataScene));
PropUtils::add_processor(scene_processor); PropUtils::add_processor(scene_processor);
#if VERSION_MINOR >= 4 #if VERSION_MINOR >= 4
Ref<PropDataPortal> portal_processor = Ref<PropDataPortal>(memnew(PropDataPortal)); Ref<PropDataPortal> portal_processor = Ref<PropDataPortal>(memnew(PropDataPortal));
PropUtils::add_processor(portal_processor); PropUtils::add_processor(portal_processor);
#endif #endif
Ref<PropDataTiledWall> tiled_wall_processor = Ref<PropDataTiledWall>(memnew(PropDataTiledWall)); Ref<PropDataTiledWall> tiled_wall_processor = Ref<PropDataTiledWall>(memnew(PropDataTiledWall));
PropUtils::add_processor(tiled_wall_processor); PropUtils::add_processor(tiled_wall_processor);
}
#ifdef TOOLS_ENABLED #ifdef TOOLS_ENABLED
EditorPlugins::add_by_type<PropEditorPlugin>(); if (p_level == MODULE_INITIALIZATION_LEVEL_EDITOR) {
EditorPlugins::add_by_type<PropEditorPlugin>();
}
#endif #endif
} }
void unregister_props_types() { void uninitialize_props_module(ModuleInitializationLevel p_level) {
if (prop_utils) { if (p_level == MODULE_INITIALIZATION_LEVEL_SCENE) {
memdelete(prop_utils); if (prop_utils) {
} memdelete(prop_utils);
}
if (prop_texture_cache) { if (prop_texture_cache) {
memdelete(prop_texture_cache); memdelete(prop_texture_cache);
}
} }
} }

View File

@ -23,7 +23,9 @@ SOFTWARE.
#ifndef PROPS_REGISTER_TYPES_H #ifndef PROPS_REGISTER_TYPES_H
#define PROPS_REGISTER_TYPES_H #define PROPS_REGISTER_TYPES_H
void register_props_types(); #include "modules/register_module_types.h"
void unregister_props_types();
void initialize_props_module(ModuleInitializationLevel p_level);
void uninitialize_props_module(ModuleInitializationLevel p_level);
#endif #endif