From d025937074a671c4cb8961b9e335560fcd62084e Mon Sep 17 00:00:00 2001 From: Relintai Date: Thu, 21 Jul 2022 19:48:37 +0200 Subject: [PATCH] Make UserManagers register themselves. --- modules/users/managers/user_manager.cpp | 11 +++++++++++ modules/users/managers/user_manager.h | 2 ++ 2 files changed, 13 insertions(+) diff --git a/modules/users/managers/user_manager.cpp b/modules/users/managers/user_manager.cpp index 7e45b41d1..d46d9739f 100644 --- a/modules/users/managers/user_manager.cpp +++ b/modules/users/managers/user_manager.cpp @@ -1,5 +1,8 @@ #include "user_manager.h" +#include "core/engine.h" + +#include "../singleton/user_db.h" #include "../users/user.h" Ref UserManager::get_user(const int id) { @@ -52,6 +55,14 @@ UserManager::UserManager() { UserManager::~UserManager() { } +void UserManager::_notification(int p_what) { + if (p_what == NOTIFICATION_POST_ENTER_TREE) { + if (!Engine::get_singleton()->is_editor_hint()) { + UserDB::get_singleton()->set_user_manager(this); + } + } +} + void UserManager::_bind_methods() { BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::OBJECT, "ret", PROPERTY_HINT_RESOURCE_TYPE, "User"), "_get_user", PropertyInfo(Variant::INT, "id"))); BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::OBJECT, "ret", PROPERTY_HINT_RESOURCE_TYPE, "User"), "_get_user_name", PropertyInfo(Variant::STRING, "user_name"))); diff --git a/modules/users/managers/user_manager.h b/modules/users/managers/user_manager.h index b5a615040..88c935f04 100644 --- a/modules/users/managers/user_manager.h +++ b/modules/users/managers/user_manager.h @@ -39,6 +39,8 @@ public: ~UserManager(); protected: + void _notification(int p_what); + static void _bind_methods(); };