Make UserManagers register themselves.

This commit is contained in:
Relintai 2022-07-21 19:48:37 +02:00
parent a349dbd762
commit d025937074
2 changed files with 13 additions and 0 deletions

View File

@ -1,5 +1,8 @@
#include "user_manager.h"
#include "core/engine.h"
#include "../singleton/user_db.h"
#include "../users/user.h"
Ref<User> 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")));

View File

@ -39,6 +39,8 @@ public:
~UserManager();
protected:
void _notification(int p_what);
static void _bind_methods();
};