Add object(resource) support for variant param editor

This commit is contained in:
Serhii Snitsaruk 2023-12-10 16:32:41 +01:00
parent 678df76c65
commit dfa332490a
1 changed files with 14 additions and 9 deletions

View File

@ -17,6 +17,7 @@
#include "modules/limboai/editor/mode_switch_button.h" #include "modules/limboai/editor/mode_switch_button.h"
#include "core/error/error_macros.h" #include "core/error/error_macros.h"
#include "core/io/marshalls.h"
#include "core/object/class_db.h" #include "core/object/class_db.h"
#include "core/object/ref_counted.h" #include "core/object/ref_counted.h"
#include "core/os/memory.h" #include "core/os/memory.h"
@ -160,14 +161,18 @@ void EditorPropertyBBParam::_create_value_editor(Variant::Type p_type) {
case Variant::NODE_PATH: { case Variant::NODE_PATH: {
value_editor = memnew(EditorPropertyNodePath); value_editor = memnew(EditorPropertyNodePath);
} break; } break;
// case Variant::RID: { // case Variant::RID: {
// } break; // } break;
// case Variant::SIGNAL: { // case Variant::SIGNAL: {
// } break; // } break;
// case Variant::CALLABLE: { // case Variant::CALLABLE: {
// } break; // } break;
// case Variant::OBJECT: { case Variant::OBJECT: {
// } break; // Only resources are supported.
EditorPropertyResource *editor = memnew(EditorPropertyResource);
editor->setup(_get_edited_param().ptr(), SNAME("saved_value"), "Resource");
value_editor = editor;
} break;
case Variant::DICTIONARY: { case Variant::DICTIONARY: {
value_editor = memnew(EditorPropertyDictionary); value_editor = memnew(EditorPropertyDictionary);
} break; } break;
@ -281,7 +286,7 @@ void EditorPropertyBBParam::_notification(int p_what) {
PopupMenu *type_menu = type_choice->get_popup(); PopupMenu *type_menu = type_choice->get_popup();
type_menu->clear(); type_menu->clear();
for (int i = 0; i < Variant::VARIANT_MAX; i++) { for (int i = 0; i < Variant::VARIANT_MAX; i++) {
if (i == Variant::RID || i == Variant::CALLABLE || i == Variant::OBJECT || i == Variant::SIGNAL) { if (i == Variant::RID || i == Variant::CALLABLE || i == Variant::SIGNAL) {
continue; continue;
} }
String type = Variant::get_type_name(Variant::Type(i)); String type = Variant::get_type_name(Variant::Type(i));