2018-08-30 04:38:13 +08:00
|
|
|
/*************************************************************************/
|
|
|
|
/* editor_properties_array_dict.cpp */
|
|
|
|
/*************************************************************************/
|
|
|
|
/* This file is part of: */
|
|
|
|
/* GODOT ENGINE */
|
|
|
|
/* https://godotengine.org */
|
|
|
|
/*************************************************************************/
|
2022-01-04 04:27:34 +08:00
|
|
|
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
|
|
|
|
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
|
2018-08-30 04:38:13 +08:00
|
|
|
/* */
|
|
|
|
/* Permission is hereby granted, free of charge, to any person obtaining */
|
|
|
|
/* a copy of this software and associated documentation files (the */
|
|
|
|
/* "Software"), to deal in the Software without restriction, including */
|
|
|
|
/* without limitation the rights to use, copy, modify, merge, publish, */
|
|
|
|
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
|
|
|
/* permit persons to whom the Software is furnished to do so, subject to */
|
|
|
|
/* the following conditions: */
|
|
|
|
/* */
|
|
|
|
/* The above copyright notice and this permission notice shall be */
|
|
|
|
/* included in all copies or substantial portions of the Software. */
|
|
|
|
/* */
|
|
|
|
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
|
|
|
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
|
|
|
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
|
|
|
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
|
|
|
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
|
|
|
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
|
|
|
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
|
|
|
/*************************************************************************/
|
|
|
|
|
2018-05-20 03:09:38 +08:00
|
|
|
#include "editor_properties_array_dict.h"
|
2019-01-13 22:43:25 +08:00
|
|
|
|
2021-03-30 00:45:42 +08:00
|
|
|
#include "core/input/input.h"
|
2018-11-22 09:10:27 +08:00
|
|
|
#include "core/io/marshalls.h"
|
2022-02-12 09:46:22 +08:00
|
|
|
#include "editor/editor_properties.h"
|
2018-05-20 04:57:44 +08:00
|
|
|
#include "editor/editor_scale.h"
|
2022-02-14 21:00:03 +08:00
|
|
|
#include "editor/inspector_dock.h"
|
2019-01-13 22:43:25 +08:00
|
|
|
|
2018-05-20 03:09:38 +08:00
|
|
|
bool EditorPropertyArrayObject::_set(const StringName &p_name, const Variant &p_value) {
|
2021-03-30 00:45:42 +08:00
|
|
|
String name = p_name;
|
2018-05-20 03:09:38 +08:00
|
|
|
|
2021-03-30 00:45:42 +08:00
|
|
|
if (name.begins_with("indices")) {
|
|
|
|
int index = name.get_slicec('/', 1).to_int();
|
|
|
|
array.set(index, p_value);
|
2018-05-20 03:09:38 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool EditorPropertyArrayObject::_get(const StringName &p_name, Variant &r_ret) const {
|
2021-03-30 00:45:42 +08:00
|
|
|
String name = p_name;
|
2018-05-20 03:09:38 +08:00
|
|
|
|
2021-03-30 00:45:42 +08:00
|
|
|
if (name.begins_with("indices")) {
|
|
|
|
int index = name.get_slicec('/', 1).to_int();
|
2018-05-20 03:09:38 +08:00
|
|
|
bool valid;
|
2021-03-30 00:45:42 +08:00
|
|
|
r_ret = array.get(index, &valid);
|
2018-11-22 09:10:27 +08:00
|
|
|
if (r_ret.get_type() == Variant::OBJECT && Object::cast_to<EncodedObjectAsID>(r_ret)) {
|
|
|
|
r_ret = Object::cast_to<EncodedObjectAsID>(r_ret)->get_object_id();
|
|
|
|
}
|
|
|
|
|
2018-05-20 03:09:38 +08:00
|
|
|
return valid;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void EditorPropertyArrayObject::set_array(const Variant &p_array) {
|
|
|
|
array = p_array;
|
|
|
|
}
|
|
|
|
|
|
|
|
Variant EditorPropertyArrayObject::get_array() {
|
|
|
|
return array;
|
|
|
|
}
|
|
|
|
|
|
|
|
EditorPropertyArrayObject::EditorPropertyArrayObject() {
|
|
|
|
}
|
|
|
|
|
2018-05-20 04:57:44 +08:00
|
|
|
///////////////////
|
|
|
|
|
|
|
|
bool EditorPropertyDictionaryObject::_set(const StringName &p_name, const Variant &p_value) {
|
2021-03-30 00:45:42 +08:00
|
|
|
String name = p_name;
|
2018-05-20 04:57:44 +08:00
|
|
|
|
2021-03-30 00:45:42 +08:00
|
|
|
if (name == "new_item_key") {
|
2018-05-20 04:57:44 +08:00
|
|
|
new_item_key = p_value;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2021-03-30 00:45:42 +08:00
|
|
|
if (name == "new_item_value") {
|
2018-05-20 04:57:44 +08:00
|
|
|
new_item_value = p_value;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2021-03-30 00:45:42 +08:00
|
|
|
if (name.begins_with("indices")) {
|
|
|
|
int index = name.get_slicec('/', 1).to_int();
|
|
|
|
Variant key = dict.get_key_at_index(index);
|
2018-05-20 04:57:44 +08:00
|
|
|
dict[key] = p_value;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool EditorPropertyDictionaryObject::_get(const StringName &p_name, Variant &r_ret) const {
|
2021-03-30 00:45:42 +08:00
|
|
|
String name = p_name;
|
2018-05-20 04:57:44 +08:00
|
|
|
|
2021-03-30 00:45:42 +08:00
|
|
|
if (name == "new_item_key") {
|
2018-05-20 04:57:44 +08:00
|
|
|
r_ret = new_item_key;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2021-03-30 00:45:42 +08:00
|
|
|
if (name == "new_item_value") {
|
2018-05-20 04:57:44 +08:00
|
|
|
r_ret = new_item_value;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2021-03-30 00:45:42 +08:00
|
|
|
if (name.begins_with("indices")) {
|
|
|
|
int index = name.get_slicec('/', 1).to_int();
|
|
|
|
Variant key = dict.get_key_at_index(index);
|
2018-05-20 04:57:44 +08:00
|
|
|
r_ret = dict[key];
|
2018-11-22 09:10:27 +08:00
|
|
|
if (r_ret.get_type() == Variant::OBJECT && Object::cast_to<EncodedObjectAsID>(r_ret)) {
|
|
|
|
r_ret = Object::cast_to<EncodedObjectAsID>(r_ret)->get_object_id();
|
|
|
|
}
|
|
|
|
|
2018-05-20 04:57:44 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void EditorPropertyDictionaryObject::set_dict(const Dictionary &p_dict) {
|
|
|
|
dict = p_dict;
|
|
|
|
}
|
|
|
|
|
|
|
|
Dictionary EditorPropertyDictionaryObject::get_dict() {
|
|
|
|
return dict;
|
|
|
|
}
|
|
|
|
|
|
|
|
void EditorPropertyDictionaryObject::set_new_item_key(const Variant &p_new_item) {
|
|
|
|
new_item_key = p_new_item;
|
|
|
|
}
|
|
|
|
|
|
|
|
Variant EditorPropertyDictionaryObject::get_new_item_key() {
|
|
|
|
return new_item_key;
|
|
|
|
}
|
|
|
|
|
|
|
|
void EditorPropertyDictionaryObject::set_new_item_value(const Variant &p_new_item) {
|
|
|
|
new_item_value = p_new_item;
|
|
|
|
}
|
|
|
|
|
|
|
|
Variant EditorPropertyDictionaryObject::get_new_item_value() {
|
|
|
|
return new_item_value;
|
|
|
|
}
|
|
|
|
|
|
|
|
EditorPropertyDictionaryObject::EditorPropertyDictionaryObject() {
|
|
|
|
}
|
|
|
|
|
|
|
|
///////////////////// ARRAY ///////////////////////////
|
2018-05-20 03:09:38 +08:00
|
|
|
|
2020-03-05 22:33:01 +08:00
|
|
|
void EditorPropertyArray::_property_changed(const String &p_property, Variant p_value, const String &p_name, bool p_changing) {
|
2020-03-03 17:46:03 +08:00
|
|
|
if (p_property.begins_with("indices")) {
|
2021-03-30 00:45:42 +08:00
|
|
|
int index = p_property.get_slice("/", 1).to_int();
|
2018-05-20 03:09:38 +08:00
|
|
|
Variant array = object->get_array();
|
2021-03-30 00:45:42 +08:00
|
|
|
array.set(index, p_value);
|
2019-01-19 00:01:24 +08:00
|
|
|
emit_changed(get_edited_property(), array, "", true);
|
2018-05-20 03:09:38 +08:00
|
|
|
|
|
|
|
if (array.get_type() == Variant::ARRAY) {
|
2021-03-30 00:45:42 +08:00
|
|
|
array = array.call("duplicate"); // Duplicate, so undo/redo works better.
|
2018-05-20 03:09:38 +08:00
|
|
|
}
|
|
|
|
object->set_array(array);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void EditorPropertyArray::_change_type(Object *p_button, int p_index) {
|
|
|
|
Button *button = Object::cast_to<Button>(p_button);
|
2021-03-30 00:45:42 +08:00
|
|
|
changing_type_index = p_index;
|
2020-03-12 20:37:40 +08:00
|
|
|
Rect2 rect = button->get_screen_rect();
|
2022-03-06 07:57:42 +08:00
|
|
|
change_type->reset_size();
|
2021-09-22 16:24:45 +08:00
|
|
|
change_type->set_position(rect.get_end() - Vector2(change_type->get_contents_minimum_size().x, 0));
|
2018-05-20 03:09:38 +08:00
|
|
|
change_type->popup();
|
|
|
|
}
|
|
|
|
|
|
|
|
void EditorPropertyArray::_change_type_menu(int p_index) {
|
2019-06-10 22:37:41 +08:00
|
|
|
if (p_index == Variant::VARIANT_MAX) {
|
2021-03-30 00:45:42 +08:00
|
|
|
_remove_pressed(changing_type_index);
|
2019-06-10 22:37:41 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-05-20 03:09:38 +08:00
|
|
|
Variant value;
|
2020-02-20 03:27:19 +08:00
|
|
|
Callable::CallError ce;
|
2020-11-09 11:19:09 +08:00
|
|
|
Variant::construct(Variant::Type(p_index), value, nullptr, 0, ce);
|
2018-05-20 03:09:38 +08:00
|
|
|
Variant array = object->get_array();
|
2021-03-30 00:45:42 +08:00
|
|
|
array.set(changing_type_index, value);
|
2018-05-20 03:09:38 +08:00
|
|
|
|
2019-01-19 00:01:24 +08:00
|
|
|
emit_changed(get_edited_property(), array, "", true);
|
2018-05-20 03:09:38 +08:00
|
|
|
|
|
|
|
if (array.get_type() == Variant::ARRAY) {
|
2021-03-30 00:45:42 +08:00
|
|
|
array = array.call("duplicate"); // Duplicate, so undo/redo works better.
|
2018-05-20 03:09:38 +08:00
|
|
|
}
|
2019-06-10 22:37:41 +08:00
|
|
|
|
2018-05-20 03:09:38 +08:00
|
|
|
object->set_array(array);
|
|
|
|
update_property();
|
|
|
|
}
|
|
|
|
|
2020-03-03 17:46:03 +08:00
|
|
|
void EditorPropertyArray::_object_id_selected(const StringName &p_property, ObjectID p_id) {
|
2021-07-18 05:22:52 +08:00
|
|
|
emit_signal(SNAME("object_id_selected"), p_property, p_id);
|
2018-11-22 09:10:27 +08:00
|
|
|
}
|
|
|
|
|
2018-05-20 03:09:38 +08:00
|
|
|
void EditorPropertyArray::update_property() {
|
|
|
|
Variant array = get_edited_object()->get(get_edited_property());
|
|
|
|
|
2022-04-21 10:57:21 +08:00
|
|
|
String array_type_name = Variant::get_type_name(array_type);
|
|
|
|
if (array_type == Variant::ARRAY && subtype != Variant::NIL) {
|
|
|
|
array_type_name = vformat("%s[%s]", array_type_name, Variant::get_type_name(subtype));
|
2018-05-20 03:09:38 +08:00
|
|
|
}
|
|
|
|
|
2018-07-24 08:42:31 +08:00
|
|
|
if (array.get_type() == Variant::NIL) {
|
2022-04-21 10:57:21 +08:00
|
|
|
edit->set_text(vformat(TTR("(Nil) %s"), array_type_name));
|
2018-06-19 03:24:31 +08:00
|
|
|
edit->set_pressed(false);
|
|
|
|
if (vbox) {
|
2020-04-02 07:20:12 +08:00
|
|
|
set_bottom_editor(nullptr);
|
2018-06-19 03:24:31 +08:00
|
|
|
memdelete(vbox);
|
2022-03-15 15:51:58 +08:00
|
|
|
button_add_item = nullptr;
|
2020-04-02 07:20:12 +08:00
|
|
|
vbox = nullptr;
|
2018-06-19 03:24:31 +08:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-03-30 00:45:42 +08:00
|
|
|
int size = array.call("size");
|
2022-02-06 08:11:15 +08:00
|
|
|
int max_page = MAX(0, size - 1) / page_length;
|
|
|
|
page_index = MIN(page_index, max_page);
|
2021-03-30 00:45:42 +08:00
|
|
|
int offset = page_index * page_length;
|
|
|
|
|
2022-04-21 10:57:21 +08:00
|
|
|
edit->set_text(vformat(TTR("%s (size %s)"), array_type_name, itos(size)));
|
2018-05-20 03:09:38 +08:00
|
|
|
|
|
|
|
bool unfolded = get_edited_object()->editor_is_section_unfolded(get_edited_property());
|
|
|
|
if (edit->is_pressed() != unfolded) {
|
|
|
|
edit->set_pressed(unfolded);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (unfolded) {
|
|
|
|
updating = true;
|
|
|
|
|
|
|
|
if (!vbox) {
|
|
|
|
vbox = memnew(VBoxContainer);
|
|
|
|
add_child(vbox);
|
|
|
|
set_bottom_editor(vbox);
|
2021-03-30 00:45:42 +08:00
|
|
|
|
|
|
|
HBoxContainer *hbox = memnew(HBoxContainer);
|
|
|
|
vbox->add_child(hbox);
|
|
|
|
|
2018-05-20 03:09:38 +08:00
|
|
|
Label *label = memnew(Label(TTR("Size: ")));
|
|
|
|
label->set_h_size_flags(SIZE_EXPAND_FILL);
|
2021-03-30 00:45:42 +08:00
|
|
|
hbox->add_child(label);
|
2018-05-20 03:09:38 +08:00
|
|
|
|
2021-03-30 00:45:42 +08:00
|
|
|
size_slider = memnew(EditorSpinSlider);
|
|
|
|
size_slider->set_step(1);
|
|
|
|
size_slider->set_max(1000000);
|
|
|
|
size_slider->set_h_size_flags(SIZE_EXPAND_FILL);
|
|
|
|
size_slider->connect("value_changed", callable_mp(this, &EditorPropertyArray::_length_changed));
|
|
|
|
hbox->add_child(size_slider);
|
2018-05-20 03:09:38 +08:00
|
|
|
|
2022-02-06 08:11:15 +08:00
|
|
|
property_vbox = memnew(VBoxContainer);
|
|
|
|
property_vbox->set_h_size_flags(SIZE_EXPAND_FILL);
|
|
|
|
vbox->add_child(property_vbox);
|
2018-05-20 03:09:38 +08:00
|
|
|
|
2022-02-06 08:11:15 +08:00
|
|
|
button_add_item = memnew(Button);
|
|
|
|
button_add_item->set_text(TTR("Add Element"));
|
|
|
|
button_add_item->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons")));
|
|
|
|
button_add_item->connect(SNAME("pressed"), callable_mp(this, &EditorPropertyArray::_add_element));
|
|
|
|
vbox->add_child(button_add_item);
|
2018-05-20 03:09:38 +08:00
|
|
|
|
2022-02-06 08:11:15 +08:00
|
|
|
paginator = memnew(EditorPaginator);
|
|
|
|
paginator->connect("page_changed", callable_mp(this, &EditorPropertyArray::_page_changed));
|
|
|
|
vbox->add_child(paginator);
|
2021-03-30 00:45:42 +08:00
|
|
|
} else {
|
|
|
|
// Bye bye children of the box.
|
2022-02-06 08:11:15 +08:00
|
|
|
for (int i = property_vbox->get_child_count() - 1; i >= 0; i--) {
|
|
|
|
Node *child = property_vbox->get_child(i);
|
2021-03-30 00:45:42 +08:00
|
|
|
if (child == reorder_selected_element_hbox) {
|
|
|
|
continue; // Don't remove the property that the user is moving.
|
|
|
|
}
|
2018-05-20 03:09:38 +08:00
|
|
|
|
2021-03-30 00:45:42 +08:00
|
|
|
child->queue_delete(); // Button still needed after pressed is called.
|
2022-02-06 08:11:15 +08:00
|
|
|
property_vbox->remove_child(child);
|
2021-03-30 00:45:42 +08:00
|
|
|
}
|
|
|
|
}
|
2018-05-20 03:09:38 +08:00
|
|
|
|
2021-03-30 00:45:42 +08:00
|
|
|
size_slider->set_value(size);
|
2022-02-06 08:11:15 +08:00
|
|
|
property_vbox->set_visible(size > 0);
|
|
|
|
button_add_item->set_visible(page_index == max_page);
|
|
|
|
paginator->update(page_index, max_page);
|
|
|
|
paginator->set_visible(max_page > 0);
|
2018-05-20 03:09:38 +08:00
|
|
|
|
|
|
|
if (array.get_type() == Variant::ARRAY) {
|
|
|
|
array = array.call("duplicate");
|
|
|
|
}
|
|
|
|
|
|
|
|
object->set_array(array);
|
|
|
|
|
2021-03-30 00:45:42 +08:00
|
|
|
int amount = MIN(size - offset, page_length);
|
2018-05-20 03:09:38 +08:00
|
|
|
for (int i = 0; i < amount; i++) {
|
2021-03-30 00:45:42 +08:00
|
|
|
bool reorder_is_from_current_page = reorder_from_index / page_length == page_index;
|
|
|
|
if (reorder_is_from_current_page && i == reorder_from_index % page_length) {
|
|
|
|
// Don't duplicate the property that the user is moving.
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (!reorder_is_from_current_page && i == reorder_to_index % page_length) {
|
|
|
|
// Don't create the property the moving property will take the place of,
|
|
|
|
// e.g. (if page_length == 20) don't create element 20 if dragging an item from
|
|
|
|
// the first page to the second page because element 20 would become element 19.
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
HBoxContainer *hbox = memnew(HBoxContainer);
|
2022-02-06 08:11:15 +08:00
|
|
|
property_vbox->add_child(hbox);
|
2021-03-30 00:45:42 +08:00
|
|
|
|
|
|
|
Button *reorder_button = memnew(Button);
|
2021-07-18 05:22:52 +08:00
|
|
|
reorder_button->set_icon(get_theme_icon(SNAME("TripleBar"), SNAME("EditorIcons")));
|
2021-03-30 00:45:42 +08:00
|
|
|
reorder_button->set_default_cursor_shape(Control::CURSOR_MOVE);
|
|
|
|
reorder_button->connect("gui_input", callable_mp(this, &EditorPropertyArray::_reorder_button_gui_input));
|
|
|
|
reorder_button->connect("button_down", callable_mp(this, &EditorPropertyArray::_reorder_button_down), varray(i + offset));
|
|
|
|
reorder_button->connect("button_up", callable_mp(this, &EditorPropertyArray::_reorder_button_up));
|
|
|
|
hbox->add_child(reorder_button);
|
|
|
|
|
2018-05-20 03:09:38 +08:00
|
|
|
String prop_name = "indices/" + itos(i + offset);
|
|
|
|
|
2020-04-02 07:20:12 +08:00
|
|
|
EditorProperty *prop = nullptr;
|
2018-05-20 03:09:38 +08:00
|
|
|
Variant value = array.get(i + offset);
|
2018-12-03 11:41:18 +08:00
|
|
|
Variant::Type value_type = value.get_type();
|
2018-05-20 03:09:38 +08:00
|
|
|
|
2018-12-03 11:41:18 +08:00
|
|
|
if (value_type == Variant::NIL && subtype != Variant::NIL) {
|
|
|
|
value_type = subtype;
|
|
|
|
}
|
2018-05-20 03:09:38 +08:00
|
|
|
|
2018-12-03 11:41:18 +08:00
|
|
|
if (value_type == Variant::OBJECT && Object::cast_to<EncodedObjectAsID>(value)) {
|
|
|
|
EditorPropertyObjectID *editor = memnew(EditorPropertyObjectID);
|
|
|
|
editor->setup("Object");
|
|
|
|
prop = editor;
|
|
|
|
} else {
|
2021-07-01 09:24:34 +08:00
|
|
|
prop = EditorInspector::instantiate_property_editor(nullptr, value_type, "", subtype_hint, subtype_hint_string, PROPERTY_USAGE_NONE);
|
2018-05-20 03:09:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
prop->set_object_and_property(object.ptr(), prop_name);
|
|
|
|
prop->set_label(itos(i + offset));
|
|
|
|
prop->set_selectable(false);
|
2020-03-05 22:33:01 +08:00
|
|
|
prop->connect("property_changed", callable_mp(this, &EditorPropertyArray::_property_changed));
|
2020-02-22 01:28:45 +08:00
|
|
|
prop->connect("object_id_selected", callable_mp(this, &EditorPropertyArray::_object_id_selected));
|
2019-06-10 22:37:41 +08:00
|
|
|
prop->set_h_size_flags(SIZE_EXPAND_FILL);
|
2021-03-30 00:45:42 +08:00
|
|
|
hbox->add_child(prop);
|
2019-01-11 21:31:08 +08:00
|
|
|
|
2019-06-10 22:37:41 +08:00
|
|
|
bool is_untyped_array = array.get_type() == Variant::ARRAY && subtype == Variant::NIL;
|
|
|
|
|
|
|
|
if (is_untyped_array) {
|
|
|
|
Button *edit = memnew(Button);
|
2021-07-18 05:22:52 +08:00
|
|
|
edit->set_icon(get_theme_icon(SNAME("Edit"), SNAME("EditorIcons")));
|
2021-03-30 00:45:42 +08:00
|
|
|
hbox->add_child(edit);
|
2020-02-22 01:28:45 +08:00
|
|
|
edit->connect("pressed", callable_mp(this, &EditorPropertyArray::_change_type), varray(edit, i + offset));
|
2018-05-20 03:09:38 +08:00
|
|
|
} else {
|
2019-06-10 22:37:41 +08:00
|
|
|
Button *remove = memnew(Button);
|
2021-07-18 05:22:52 +08:00
|
|
|
remove->set_icon(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")));
|
2020-02-22 01:28:45 +08:00
|
|
|
remove->connect("pressed", callable_mp(this, &EditorPropertyArray::_remove_pressed), varray(i + offset));
|
2021-03-30 00:45:42 +08:00
|
|
|
hbox->add_child(remove);
|
2018-05-20 03:09:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
prop->update_property();
|
|
|
|
}
|
|
|
|
|
2021-03-30 00:45:42 +08:00
|
|
|
if (reorder_to_index % page_length > 0) {
|
2022-02-06 08:11:15 +08:00
|
|
|
property_vbox->move_child(property_vbox->get_child(0), reorder_to_index % page_length);
|
2021-03-30 00:45:42 +08:00
|
|
|
}
|
|
|
|
|
2018-05-20 03:09:38 +08:00
|
|
|
updating = false;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
if (vbox) {
|
2020-04-02 07:20:12 +08:00
|
|
|
set_bottom_editor(nullptr);
|
2018-05-20 03:09:38 +08:00
|
|
|
memdelete(vbox);
|
2022-03-15 15:51:58 +08:00
|
|
|
button_add_item = nullptr;
|
2020-04-02 07:20:12 +08:00
|
|
|
vbox = nullptr;
|
2018-05-20 03:09:38 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-10 22:37:41 +08:00
|
|
|
void EditorPropertyArray::_remove_pressed(int p_index) {
|
|
|
|
Variant array = object->get_array();
|
2021-07-04 06:17:03 +08:00
|
|
|
array.call("remove_at", p_index);
|
2019-06-10 22:37:41 +08:00
|
|
|
|
|
|
|
emit_changed(get_edited_property(), array, "", false);
|
|
|
|
update_property();
|
|
|
|
}
|
|
|
|
|
2020-04-16 22:25:27 +08:00
|
|
|
void EditorPropertyArray::_button_draw() {
|
|
|
|
if (dropping) {
|
2021-07-18 05:22:52 +08:00
|
|
|
Color color = get_theme_color(SNAME("accent_color"), SNAME("Editor"));
|
2020-04-16 22:25:27 +08:00
|
|
|
edit->draw_rect(Rect2(Point2(), edit->get_size()), color, false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool EditorPropertyArray::_is_drop_valid(const Dictionary &p_drag_data) const {
|
|
|
|
String allowed_type = Variant::get_type_name(subtype);
|
|
|
|
|
2021-07-24 21:12:34 +08:00
|
|
|
// When the subtype is of type Object, an additional subtype may be specified in the hint string
|
|
|
|
// (e.g. Resource, Texture2D, ShaderMaterial, etc). We want the allowed type to be that, not just "Object".
|
2021-12-09 17:42:46 +08:00
|
|
|
if (subtype == Variant::OBJECT && !subtype_hint_string.is_empty()) {
|
2021-07-24 21:12:34 +08:00
|
|
|
allowed_type = subtype_hint_string;
|
|
|
|
}
|
|
|
|
|
2020-04-16 22:25:27 +08:00
|
|
|
Dictionary drag_data = p_drag_data;
|
|
|
|
|
|
|
|
if (drag_data.has("type") && String(drag_data["type"]) == "files") {
|
|
|
|
Vector<String> files = drag_data["files"];
|
|
|
|
|
|
|
|
for (int i = 0; i < files.size(); i++) {
|
|
|
|
String file = files[i];
|
|
|
|
String ftype = EditorFileSystem::get_singleton()->get_file_type(file);
|
|
|
|
|
|
|
|
for (int j = 0; j < allowed_type.get_slice_count(","); j++) {
|
|
|
|
String at = allowed_type.get_slice(",", j).strip_edges();
|
2021-03-30 00:45:42 +08:00
|
|
|
// Fail if one of the files is not of allowed type.
|
2020-04-16 22:25:27 +08:00
|
|
|
if (!ClassDB::is_parent_class(ftype, at)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-30 00:45:42 +08:00
|
|
|
// If no files fail, drop is valid.
|
2020-04-16 22:25:27 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool EditorPropertyArray::can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const {
|
|
|
|
return _is_drop_valid(p_data);
|
|
|
|
}
|
|
|
|
|
|
|
|
void EditorPropertyArray::drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) {
|
|
|
|
ERR_FAIL_COND(!_is_drop_valid(p_data));
|
|
|
|
|
|
|
|
Dictionary drag_data = p_data;
|
|
|
|
|
|
|
|
if (drag_data.has("type") && String(drag_data["type"]) == "files") {
|
|
|
|
Vector<String> files = drag_data["files"];
|
|
|
|
|
|
|
|
Variant array = object->get_array();
|
|
|
|
|
2021-03-30 00:45:42 +08:00
|
|
|
// Handle the case where array is not initialised yet.
|
2020-04-16 22:25:27 +08:00
|
|
|
if (!array.is_array()) {
|
|
|
|
Callable::CallError ce;
|
2020-11-09 11:19:09 +08:00
|
|
|
Variant::construct(array_type, array, nullptr, 0, ce);
|
2020-04-16 22:25:27 +08:00
|
|
|
}
|
|
|
|
|
2021-03-30 00:45:42 +08:00
|
|
|
// Loop the file array and add to existing array.
|
2020-04-16 22:25:27 +08:00
|
|
|
for (int i = 0; i < files.size(); i++) {
|
|
|
|
String file = files[i];
|
|
|
|
|
2022-05-03 07:43:50 +08:00
|
|
|
Ref<Resource> res = ResourceLoader::load(file);
|
2020-04-16 22:25:27 +08:00
|
|
|
if (res.is_valid()) {
|
|
|
|
array.call("push_back", res);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (array.get_type() == Variant::ARRAY) {
|
|
|
|
array = array.call("duplicate");
|
|
|
|
}
|
|
|
|
|
|
|
|
emit_changed(get_edited_property(), array, "", false);
|
|
|
|
object->set_array(array);
|
|
|
|
|
|
|
|
update_property();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-10 22:37:41 +08:00
|
|
|
void EditorPropertyArray::_notification(int p_what) {
|
2022-02-16 07:52:32 +08:00
|
|
|
switch (p_what) {
|
|
|
|
case NOTIFICATION_THEME_CHANGED:
|
|
|
|
case NOTIFICATION_ENTER_TREE: {
|
|
|
|
change_type->clear();
|
|
|
|
for (int i = 0; i < Variant::VARIANT_MAX; i++) {
|
|
|
|
String type = Variant::get_type_name(Variant::Type(i));
|
|
|
|
change_type->add_icon_item(get_theme_icon(type, SNAME("EditorIcons")), type, i);
|
|
|
|
}
|
|
|
|
change_type->add_separator();
|
|
|
|
change_type->add_icon_item(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), TTR("Remove Item"), Variant::VARIANT_MAX);
|
2022-02-06 08:11:15 +08:00
|
|
|
|
2022-02-16 07:52:32 +08:00
|
|
|
if (Object::cast_to<Button>(button_add_item)) {
|
|
|
|
button_add_item->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons")));
|
|
|
|
}
|
|
|
|
} break;
|
2022-01-25 08:16:05 +08:00
|
|
|
|
2022-02-16 07:52:32 +08:00
|
|
|
case NOTIFICATION_DRAG_BEGIN: {
|
|
|
|
if (is_visible_in_tree()) {
|
|
|
|
if (_is_drop_valid(get_viewport()->gui_get_drag_data())) {
|
|
|
|
dropping = true;
|
|
|
|
edit->update();
|
|
|
|
}
|
2020-04-16 22:25:27 +08:00
|
|
|
}
|
2022-02-16 07:52:32 +08:00
|
|
|
} break;
|
2020-04-16 22:25:27 +08:00
|
|
|
|
2022-02-16 07:52:32 +08:00
|
|
|
case NOTIFICATION_DRAG_END: {
|
|
|
|
if (dropping) {
|
|
|
|
dropping = false;
|
|
|
|
edit->update();
|
|
|
|
}
|
|
|
|
} break;
|
2020-04-16 22:25:27 +08:00
|
|
|
}
|
2018-05-20 03:09:38 +08:00
|
|
|
}
|
2020-04-16 22:25:27 +08:00
|
|
|
|
2018-05-20 03:09:38 +08:00
|
|
|
void EditorPropertyArray::_edit_pressed() {
|
2018-06-19 03:24:31 +08:00
|
|
|
Variant array = get_edited_object()->get(get_edited_property());
|
|
|
|
if (!array.is_array()) {
|
2020-02-20 03:27:19 +08:00
|
|
|
Callable::CallError ce;
|
2020-11-09 11:19:09 +08:00
|
|
|
Variant::construct(array_type, array, nullptr, 0, ce);
|
2018-06-19 03:24:31 +08:00
|
|
|
|
|
|
|
get_edited_object()->set(get_edited_property(), array);
|
|
|
|
}
|
|
|
|
|
2018-05-20 03:09:38 +08:00
|
|
|
get_edited_object()->editor_set_section_unfold(get_edited_property(), edit->is_pressed());
|
|
|
|
update_property();
|
|
|
|
}
|
|
|
|
|
2022-02-06 08:11:15 +08:00
|
|
|
void EditorPropertyArray::_page_changed(int p_page) {
|
2020-05-14 22:41:43 +08:00
|
|
|
if (updating) {
|
2018-05-20 03:09:38 +08:00
|
|
|
return;
|
2020-05-14 22:41:43 +08:00
|
|
|
}
|
2021-03-30 00:45:42 +08:00
|
|
|
page_index = p_page;
|
2018-05-20 03:09:38 +08:00
|
|
|
update_property();
|
|
|
|
}
|
|
|
|
|
|
|
|
void EditorPropertyArray::_length_changed(double p_page) {
|
2020-05-14 22:41:43 +08:00
|
|
|
if (updating) {
|
2018-05-20 03:09:38 +08:00
|
|
|
return;
|
2020-05-14 22:41:43 +08:00
|
|
|
}
|
2018-05-20 03:09:38 +08:00
|
|
|
|
|
|
|
Variant array = object->get_array();
|
2019-02-26 20:58:39 +08:00
|
|
|
int previous_size = array.call("size");
|
|
|
|
|
2018-05-20 03:09:38 +08:00
|
|
|
array.call("resize", int(p_page));
|
|
|
|
|
|
|
|
if (array.get_type() == Variant::ARRAY) {
|
2018-12-03 11:41:18 +08:00
|
|
|
if (subtype != Variant::NIL) {
|
|
|
|
int size = array.call("size");
|
2019-02-26 20:58:39 +08:00
|
|
|
for (int i = previous_size; i < size; i++) {
|
2018-12-03 11:41:18 +08:00
|
|
|
if (array.get(i).get_type() == Variant::NIL) {
|
2020-02-20 03:27:19 +08:00
|
|
|
Callable::CallError ce;
|
2020-11-09 11:19:09 +08:00
|
|
|
Variant r;
|
|
|
|
Variant::construct(subtype, r, nullptr, 0, ce);
|
|
|
|
array.set(i, r);
|
2018-12-03 11:41:18 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-03-30 00:45:42 +08:00
|
|
|
array = array.call("duplicate"); // Duplicate, so undo/redo works better.
|
2019-02-26 20:58:39 +08:00
|
|
|
} else {
|
|
|
|
int size = array.call("size");
|
2021-03-30 00:45:42 +08:00
|
|
|
// Pool*Array don't initialize their elements, have to do it manually.
|
2019-02-26 20:58:39 +08:00
|
|
|
for (int i = previous_size; i < size; i++) {
|
2020-02-20 03:27:19 +08:00
|
|
|
Callable::CallError ce;
|
2020-11-09 11:19:09 +08:00
|
|
|
Variant r;
|
|
|
|
Variant::construct(array.get(i).get_type(), r, nullptr, 0, ce);
|
|
|
|
array.set(i, r);
|
2019-02-26 20:58:39 +08:00
|
|
|
}
|
2018-05-20 03:09:38 +08:00
|
|
|
}
|
2019-02-26 20:58:39 +08:00
|
|
|
|
|
|
|
emit_changed(get_edited_property(), array, "", false);
|
2018-05-20 03:09:38 +08:00
|
|
|
object->set_array(array);
|
|
|
|
update_property();
|
|
|
|
}
|
|
|
|
|
2022-02-06 08:11:15 +08:00
|
|
|
void EditorPropertyArray::_add_element() {
|
|
|
|
_length_changed(double(object->get_array().call("size")) + 1.0);
|
|
|
|
}
|
|
|
|
|
2018-12-03 11:41:18 +08:00
|
|
|
void EditorPropertyArray::setup(Variant::Type p_array_type, const String &p_hint_string) {
|
2018-06-19 03:24:31 +08:00
|
|
|
array_type = p_array_type;
|
2018-12-03 11:41:18 +08:00
|
|
|
|
2021-06-25 20:55:26 +08:00
|
|
|
// The format of p_hint_string is:
|
2021-03-30 00:45:42 +08:00
|
|
|
// subType/subTypeHint:nextSubtype ... etc.
|
2020-12-15 20:04:21 +08:00
|
|
|
if (array_type == Variant::ARRAY && !p_hint_string.is_empty()) {
|
2019-10-31 20:40:58 +08:00
|
|
|
int hint_subtype_separator = p_hint_string.find(":");
|
|
|
|
if (hint_subtype_separator >= 0) {
|
|
|
|
String subtype_string = p_hint_string.substr(0, hint_subtype_separator);
|
2018-12-03 11:41:18 +08:00
|
|
|
int slash_pos = subtype_string.find("/");
|
|
|
|
if (slash_pos >= 0) {
|
|
|
|
subtype_hint = PropertyHint(subtype_string.substr(slash_pos + 1, subtype_string.size() - slash_pos - 1).to_int());
|
|
|
|
subtype_string = subtype_string.substr(0, slash_pos);
|
|
|
|
}
|
|
|
|
|
2019-10-31 20:40:58 +08:00
|
|
|
subtype_hint_string = p_hint_string.substr(hint_subtype_separator + 1, p_hint_string.size() - hint_subtype_separator - 1);
|
2018-12-03 11:41:18 +08:00
|
|
|
subtype = Variant::Type(subtype_string.to_int());
|
|
|
|
}
|
|
|
|
}
|
2018-06-19 03:24:31 +08:00
|
|
|
}
|
|
|
|
|
2021-03-30 00:45:42 +08:00
|
|
|
void EditorPropertyArray::_reorder_button_gui_input(const Ref<InputEvent> &p_event) {
|
|
|
|
if (reorder_from_index < 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
Ref<InputEventMouseMotion> mm = p_event;
|
|
|
|
if (mm.is_valid()) {
|
|
|
|
Variant array = object->get_array();
|
|
|
|
int size = array.call("size");
|
|
|
|
|
|
|
|
if ((reorder_to_index == 0 && mm->get_relative().y < 0.0f) || (reorder_to_index == size - 1 && mm->get_relative().y > 0.0f)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
reorder_mouse_y_delta += mm->get_relative().y;
|
|
|
|
float required_y_distance = 20.0f * EDSCALE;
|
|
|
|
if (ABS(reorder_mouse_y_delta) > required_y_distance) {
|
|
|
|
int direction = reorder_mouse_y_delta > 0.0f ? 1 : -1;
|
|
|
|
reorder_mouse_y_delta -= required_y_distance * direction;
|
|
|
|
|
|
|
|
reorder_to_index += direction;
|
|
|
|
if ((direction < 0 && reorder_to_index % page_length == page_length - 1) || (direction > 0 && reorder_to_index % page_length == 0)) {
|
|
|
|
// Automatically move to the next/previous page.
|
2022-02-06 08:11:15 +08:00
|
|
|
_page_changed(page_index + direction);
|
2021-03-30 00:45:42 +08:00
|
|
|
}
|
2022-02-06 08:11:15 +08:00
|
|
|
property_vbox->move_child(reorder_selected_element_hbox, reorder_to_index % page_length);
|
2021-03-30 00:45:42 +08:00
|
|
|
// Ensure the moving element is visible.
|
2021-11-18 04:08:55 +08:00
|
|
|
InspectorDock::get_inspector_singleton()->ensure_control_visible(reorder_selected_element_hbox);
|
2021-03-30 00:45:42 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void EditorPropertyArray::_reorder_button_down(int p_index) {
|
|
|
|
reorder_from_index = p_index;
|
|
|
|
reorder_to_index = p_index;
|
2022-02-06 08:11:15 +08:00
|
|
|
reorder_selected_element_hbox = Object::cast_to<HBoxContainer>(property_vbox->get_child(p_index % page_length));
|
2021-03-30 00:45:42 +08:00
|
|
|
reorder_selected_button = Object::cast_to<Button>(reorder_selected_element_hbox->get_child(0));
|
|
|
|
// Ideally it'd to be able to show the mouse but I had issues with
|
|
|
|
// Control's `mouse_exit()`/`mouse_entered()` signals not getting called.
|
|
|
|
Input::get_singleton()->set_mouse_mode(Input::MOUSE_MODE_CAPTURED);
|
|
|
|
}
|
|
|
|
|
|
|
|
void EditorPropertyArray::_reorder_button_up() {
|
|
|
|
if (reorder_from_index != reorder_to_index) {
|
|
|
|
// Move the element.
|
|
|
|
Variant array = object->get_array();
|
|
|
|
|
|
|
|
Variant value_to_move = array.get(reorder_from_index);
|
2022-02-04 23:28:18 +08:00
|
|
|
array.call("remove_at", reorder_from_index);
|
2021-03-30 00:45:42 +08:00
|
|
|
array.call("insert", reorder_to_index, value_to_move);
|
|
|
|
|
|
|
|
emit_changed(get_edited_property(), array, "", false);
|
|
|
|
object->set_array(array);
|
|
|
|
update_property();
|
|
|
|
}
|
|
|
|
|
|
|
|
reorder_from_index = -1;
|
|
|
|
reorder_to_index = -1;
|
|
|
|
reorder_mouse_y_delta = 0.0f;
|
|
|
|
|
|
|
|
Input::get_singleton()->set_mouse_mode(Input::MOUSE_MODE_VISIBLE);
|
|
|
|
reorder_selected_button->warp_mouse(reorder_selected_button->get_size() / 2.0f);
|
|
|
|
|
|
|
|
reorder_selected_element_hbox = nullptr;
|
|
|
|
reorder_selected_button = nullptr;
|
|
|
|
}
|
|
|
|
|
2018-05-20 03:09:38 +08:00
|
|
|
void EditorPropertyArray::_bind_methods() {
|
2021-05-16 05:48:59 +08:00
|
|
|
ClassDB::bind_method(D_METHOD("_can_drop_data_fw"), &EditorPropertyArray::can_drop_data_fw);
|
|
|
|
ClassDB::bind_method(D_METHOD("_drop_data_fw"), &EditorPropertyArray::drop_data_fw);
|
2018-05-20 03:09:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
EditorPropertyArray::EditorPropertyArray() {
|
2021-06-18 06:03:09 +08:00
|
|
|
object.instantiate();
|
2021-03-30 00:45:42 +08:00
|
|
|
page_length = int(EDITOR_GET("interface/inspector/max_array_dictionary_items_per_page"));
|
2022-02-06 08:11:15 +08:00
|
|
|
|
2018-05-20 03:09:38 +08:00
|
|
|
edit = memnew(Button);
|
|
|
|
edit->set_h_size_flags(SIZE_EXPAND_FILL);
|
|
|
|
edit->set_clip_text(true);
|
2020-02-22 01:28:45 +08:00
|
|
|
edit->connect("pressed", callable_mp(this, &EditorPropertyArray::_edit_pressed));
|
2018-05-20 03:09:38 +08:00
|
|
|
edit->set_toggle_mode(true);
|
2020-04-16 22:25:27 +08:00
|
|
|
edit->set_drag_forwarding(this);
|
|
|
|
edit->connect("draw", callable_mp(this, &EditorPropertyArray::_button_draw));
|
2018-05-20 03:09:38 +08:00
|
|
|
add_child(edit);
|
|
|
|
add_focusable(edit);
|
2022-02-06 08:11:15 +08:00
|
|
|
|
2020-04-02 07:20:12 +08:00
|
|
|
vbox = nullptr;
|
2022-02-06 08:11:15 +08:00
|
|
|
property_vbox = nullptr;
|
2021-03-30 00:45:42 +08:00
|
|
|
size_slider = nullptr;
|
2022-02-06 08:11:15 +08:00
|
|
|
button_add_item = nullptr;
|
|
|
|
paginator = nullptr;
|
2018-05-20 03:09:38 +08:00
|
|
|
change_type = memnew(PopupMenu);
|
|
|
|
add_child(change_type);
|
2020-02-22 01:28:45 +08:00
|
|
|
change_type->connect("id_pressed", callable_mp(this, &EditorPropertyArray::_change_type_menu));
|
2021-03-30 00:45:42 +08:00
|
|
|
changing_type_index = -1;
|
2018-12-03 11:41:18 +08:00
|
|
|
|
|
|
|
subtype = Variant::NIL;
|
|
|
|
subtype_hint = PROPERTY_HINT_NONE;
|
|
|
|
subtype_hint_string = "";
|
2018-05-20 03:09:38 +08:00
|
|
|
}
|
2018-05-20 04:57:44 +08:00
|
|
|
|
|
|
|
///////////////////// DICTIONARY ///////////////////////////
|
|
|
|
|
2020-03-05 22:33:01 +08:00
|
|
|
void EditorPropertyDictionary::_property_changed(const String &p_property, Variant p_value, const String &p_name, bool p_changing) {
|
2020-03-03 17:46:03 +08:00
|
|
|
if (p_property == "new_item_key") {
|
2018-05-20 04:57:44 +08:00
|
|
|
object->set_new_item_key(p_value);
|
2020-03-03 17:46:03 +08:00
|
|
|
} else if (p_property == "new_item_value") {
|
2018-05-20 04:57:44 +08:00
|
|
|
object->set_new_item_value(p_value);
|
2020-03-03 17:46:03 +08:00
|
|
|
} else if (p_property.begins_with("indices")) {
|
2021-03-30 00:45:42 +08:00
|
|
|
int index = p_property.get_slice("/", 1).to_int();
|
2018-05-20 04:57:44 +08:00
|
|
|
Dictionary dict = object->get_dict();
|
2021-03-30 00:45:42 +08:00
|
|
|
Variant key = dict.get_key_at_index(index);
|
2018-05-20 04:57:44 +08:00
|
|
|
dict[key] = p_value;
|
|
|
|
|
2019-01-19 00:01:24 +08:00
|
|
|
emit_changed(get_edited_property(), dict, "", true);
|
2018-05-20 04:57:44 +08:00
|
|
|
|
2022-03-04 21:04:59 +08:00
|
|
|
dict = dict.duplicate(); // Duplicate, so undo/redo works better.
|
2018-05-20 04:57:44 +08:00
|
|
|
object->set_dict(dict);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void EditorPropertyDictionary::_change_type(Object *p_button, int p_index) {
|
|
|
|
Button *button = Object::cast_to<Button>(p_button);
|
|
|
|
|
2020-03-12 20:37:40 +08:00
|
|
|
Rect2 rect = button->get_screen_rect();
|
2022-03-06 07:57:42 +08:00
|
|
|
change_type->reset_size();
|
2021-09-22 16:24:45 +08:00
|
|
|
change_type->set_position(rect.get_end() - Vector2(change_type->get_contents_minimum_size().x, 0));
|
2018-05-20 04:57:44 +08:00
|
|
|
change_type->popup();
|
2021-03-30 00:45:42 +08:00
|
|
|
changing_type_index = p_index;
|
2018-05-20 04:57:44 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void EditorPropertyDictionary::_add_key_value() {
|
2018-07-24 08:42:31 +08:00
|
|
|
// Do not allow nil as valid key. I experienced errors with this
|
|
|
|
if (object->get_new_item_key().get_type() == Variant::NIL) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-05-20 04:57:44 +08:00
|
|
|
Dictionary dict = object->get_dict();
|
2018-07-24 08:42:31 +08:00
|
|
|
|
2018-05-20 04:57:44 +08:00
|
|
|
dict[object->get_new_item_key()] = object->get_new_item_value();
|
|
|
|
object->set_new_item_key(Variant());
|
|
|
|
object->set_new_item_value(Variant());
|
|
|
|
|
2019-01-19 00:01:24 +08:00
|
|
|
emit_changed(get_edited_property(), dict, "", false);
|
2018-05-20 04:57:44 +08:00
|
|
|
|
2021-03-30 00:45:42 +08:00
|
|
|
dict = dict.duplicate(); // Duplicate, so undo/redo works better.
|
2018-05-20 04:57:44 +08:00
|
|
|
object->set_dict(dict);
|
|
|
|
update_property();
|
|
|
|
}
|
|
|
|
|
|
|
|
void EditorPropertyDictionary::_change_type_menu(int p_index) {
|
2021-03-30 00:45:42 +08:00
|
|
|
if (changing_type_index < 0) {
|
2018-05-20 04:57:44 +08:00
|
|
|
Variant value;
|
2020-02-20 03:27:19 +08:00
|
|
|
Callable::CallError ce;
|
2020-11-09 11:19:09 +08:00
|
|
|
Variant::construct(Variant::Type(p_index), value, nullptr, 0, ce);
|
2021-03-30 00:45:42 +08:00
|
|
|
if (changing_type_index == -1) {
|
2018-05-20 04:57:44 +08:00
|
|
|
object->set_new_item_key(value);
|
|
|
|
} else {
|
|
|
|
object->set_new_item_value(value);
|
|
|
|
}
|
|
|
|
update_property();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
Dictionary dict = object->get_dict();
|
|
|
|
|
|
|
|
if (p_index < Variant::VARIANT_MAX) {
|
|
|
|
Variant value;
|
2020-02-20 03:27:19 +08:00
|
|
|
Callable::CallError ce;
|
2020-11-09 11:19:09 +08:00
|
|
|
Variant::construct(Variant::Type(p_index), value, nullptr, 0, ce);
|
2021-03-30 00:45:42 +08:00
|
|
|
Variant key = dict.get_key_at_index(changing_type_index);
|
2018-05-20 04:57:44 +08:00
|
|
|
dict[key] = value;
|
|
|
|
} else {
|
2021-03-30 00:45:42 +08:00
|
|
|
Variant key = dict.get_key_at_index(changing_type_index);
|
2018-05-20 04:57:44 +08:00
|
|
|
dict.erase(key);
|
|
|
|
}
|
|
|
|
|
2019-01-19 00:01:24 +08:00
|
|
|
emit_changed(get_edited_property(), dict, "", false);
|
2018-05-20 04:57:44 +08:00
|
|
|
|
2022-03-04 21:04:59 +08:00
|
|
|
dict = dict.duplicate(); // Duplicate, so undo/redo works better.
|
2018-05-20 04:57:44 +08:00
|
|
|
object->set_dict(dict);
|
|
|
|
update_property();
|
|
|
|
}
|
|
|
|
|
|
|
|
void EditorPropertyDictionary::update_property() {
|
2018-07-24 08:42:31 +08:00
|
|
|
Variant updated_val = get_edited_object()->get(get_edited_property());
|
|
|
|
|
|
|
|
if (updated_val.get_type() == Variant::NIL) {
|
2022-03-04 21:04:59 +08:00
|
|
|
edit->set_text(TTR("Dictionary (Nil)")); // This provides symmetry with the array property.
|
2018-07-24 08:42:31 +08:00
|
|
|
edit->set_pressed(false);
|
|
|
|
if (vbox) {
|
2020-04-02 07:20:12 +08:00
|
|
|
set_bottom_editor(nullptr);
|
2018-07-24 08:42:31 +08:00
|
|
|
memdelete(vbox);
|
2022-03-15 15:51:58 +08:00
|
|
|
button_add_item = nullptr;
|
2020-04-02 07:20:12 +08:00
|
|
|
vbox = nullptr;
|
2018-07-24 08:42:31 +08:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
Dictionary dict = updated_val;
|
2018-05-20 04:57:44 +08:00
|
|
|
|
2022-03-04 21:04:59 +08:00
|
|
|
edit->set_text(vformat(TTR("Dictionary (size %d)"), dict.size()));
|
2018-05-20 04:57:44 +08:00
|
|
|
|
|
|
|
bool unfolded = get_edited_object()->editor_is_section_unfolded(get_edited_property());
|
|
|
|
if (edit->is_pressed() != unfolded) {
|
|
|
|
edit->set_pressed(unfolded);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (unfolded) {
|
|
|
|
updating = true;
|
|
|
|
|
|
|
|
if (!vbox) {
|
|
|
|
vbox = memnew(VBoxContainer);
|
|
|
|
add_child(vbox);
|
|
|
|
set_bottom_editor(vbox);
|
|
|
|
|
2022-02-06 08:11:15 +08:00
|
|
|
property_vbox = memnew(VBoxContainer);
|
|
|
|
property_vbox->set_h_size_flags(SIZE_EXPAND_FILL);
|
|
|
|
vbox->add_child(property_vbox);
|
|
|
|
|
|
|
|
paginator = memnew(EditorPaginator);
|
|
|
|
paginator->connect("page_changed", callable_mp(this, &EditorPropertyDictionary::_page_changed));
|
|
|
|
vbox->add_child(paginator);
|
2018-05-20 04:57:44 +08:00
|
|
|
} else {
|
2019-05-19 18:34:40 +08:00
|
|
|
// Queue children for deletion, deleting immediately might cause errors.
|
2022-02-06 08:11:15 +08:00
|
|
|
for (int i = property_vbox->get_child_count() - 1; i >= 0; i--) {
|
|
|
|
property_vbox->get_child(i)->queue_delete();
|
2018-05-20 04:57:44 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-30 00:45:42 +08:00
|
|
|
int size = dict.size();
|
2018-05-20 04:57:44 +08:00
|
|
|
|
2022-02-06 08:11:15 +08:00
|
|
|
int max_page = MAX(0, size - 1) / page_length;
|
|
|
|
page_index = MIN(page_index, max_page);
|
2018-05-20 04:57:44 +08:00
|
|
|
|
2022-02-06 08:11:15 +08:00
|
|
|
paginator->update(page_index, max_page);
|
|
|
|
paginator->set_visible(max_page > 0);
|
2018-05-20 04:57:44 +08:00
|
|
|
|
2021-03-30 00:45:42 +08:00
|
|
|
int offset = page_index * page_length;
|
2018-05-20 04:57:44 +08:00
|
|
|
|
2021-03-30 00:45:42 +08:00
|
|
|
int amount = MIN(size - offset, page_length);
|
2022-02-06 08:11:15 +08:00
|
|
|
int total_amount = page_index == max_page ? amount + 2 : amount; // For the "Add Key/Value Pair" box on last page.
|
2018-05-20 04:57:44 +08:00
|
|
|
|
|
|
|
dict = dict.duplicate();
|
|
|
|
|
|
|
|
object->set_dict(dict);
|
2020-04-02 07:20:12 +08:00
|
|
|
VBoxContainer *add_vbox = nullptr;
|
2021-10-29 20:24:28 +08:00
|
|
|
double default_float_step = EDITOR_GET("interface/inspector/default_float_step");
|
2018-05-20 04:57:44 +08:00
|
|
|
|
2022-02-06 08:11:15 +08:00
|
|
|
for (int i = 0; i < total_amount; i++) {
|
2018-05-20 04:57:44 +08:00
|
|
|
String prop_name;
|
|
|
|
Variant key;
|
|
|
|
Variant value;
|
|
|
|
|
|
|
|
if (i < amount) {
|
|
|
|
prop_name = "indices/" + itos(i + offset);
|
|
|
|
key = dict.get_key_at_index(i + offset);
|
|
|
|
value = dict.get_value_at_index(i + offset);
|
|
|
|
} else if (i == amount) {
|
|
|
|
prop_name = "new_item_key";
|
|
|
|
value = object->get_new_item_key();
|
|
|
|
} else if (i == amount + 1) {
|
|
|
|
prop_name = "new_item_value";
|
|
|
|
value = object->get_new_item_value();
|
|
|
|
}
|
|
|
|
|
2020-04-02 07:20:12 +08:00
|
|
|
EditorProperty *prop = nullptr;
|
2018-05-20 04:57:44 +08:00
|
|
|
|
|
|
|
switch (value.get_type()) {
|
|
|
|
case Variant::NIL: {
|
|
|
|
prop = memnew(EditorPropertyNil);
|
|
|
|
|
|
|
|
} break;
|
|
|
|
|
2021-03-30 00:45:42 +08:00
|
|
|
// Atomic types.
|
2018-05-20 04:57:44 +08:00
|
|
|
case Variant::BOOL: {
|
|
|
|
prop = memnew(EditorPropertyCheck);
|
|
|
|
|
|
|
|
} break;
|
|
|
|
case Variant::INT: {
|
2018-09-20 05:35:22 +08:00
|
|
|
EditorPropertyInteger *editor = memnew(EditorPropertyInteger);
|
2018-09-25 00:26:39 +08:00
|
|
|
editor->setup(-100000, 100000, 1, true, true);
|
2018-09-20 05:35:22 +08:00
|
|
|
prop = editor;
|
2018-05-20 04:57:44 +08:00
|
|
|
|
|
|
|
} break;
|
Variant: Added 64-bit packed arrays, renamed Variant::REAL to FLOAT.
- Renames PackedIntArray to PackedInt32Array.
- Renames PackedFloatArray to PackedFloat32Array.
- Adds PackedInt64Array and PackedFloat64Array.
- Renames Variant::REAL to Variant::FLOAT for consistency.
Packed arrays are for storing large amount of data and creating stuff like
meshes, buffers. textures, etc. Forcing them to be 64 is a huge waste of
memory. That said, many users requested the ability to have 64 bits packed
arrays for their games, so this is just an optional added type.
For Variant, the float datatype is always 64 bits, and exposed as `float`.
We still have `real_t` which is the datatype that can change from 32 to 64
bits depending on a compile flag (not entirely working right now, but that's
the idea). It affects math related datatypes and code only.
Neither Variant nor PackedArray make use of real_t, which is only intended
for math precision, so the term is removed from there to keep only float.
2020-02-25 02:20:53 +08:00
|
|
|
case Variant::FLOAT: {
|
2018-09-20 05:35:22 +08:00
|
|
|
EditorPropertyFloat *editor = memnew(EditorPropertyFloat);
|
2021-10-29 20:24:28 +08:00
|
|
|
editor->setup(-100000, 100000, default_float_step, true, false, true, true);
|
2018-09-20 05:35:22 +08:00
|
|
|
prop = editor;
|
2018-05-20 04:57:44 +08:00
|
|
|
} break;
|
|
|
|
case Variant::STRING: {
|
|
|
|
prop = memnew(EditorPropertyText);
|
|
|
|
|
|
|
|
} break;
|
|
|
|
|
2021-03-30 00:45:42 +08:00
|
|
|
// Math types.
|
2018-05-20 04:57:44 +08:00
|
|
|
case Variant::VECTOR2: {
|
2018-09-20 05:35:22 +08:00
|
|
|
EditorPropertyVector2 *editor = memnew(EditorPropertyVector2);
|
2021-10-29 20:24:28 +08:00
|
|
|
editor->setup(-100000, 100000, default_float_step, true);
|
2018-09-20 05:35:22 +08:00
|
|
|
prop = editor;
|
2018-05-20 04:57:44 +08:00
|
|
|
|
2020-04-17 10:52:00 +08:00
|
|
|
} break;
|
|
|
|
case Variant::VECTOR2I: {
|
|
|
|
EditorPropertyVector2i *editor = memnew(EditorPropertyVector2i);
|
|
|
|
editor->setup(-100000, 100000, true);
|
|
|
|
prop = editor;
|
|
|
|
|
2018-05-20 04:57:44 +08:00
|
|
|
} break;
|
|
|
|
case Variant::RECT2: {
|
2018-09-20 05:35:22 +08:00
|
|
|
EditorPropertyRect2 *editor = memnew(EditorPropertyRect2);
|
2021-10-29 20:24:28 +08:00
|
|
|
editor->setup(-100000, 100000, default_float_step, true);
|
2018-09-20 05:35:22 +08:00
|
|
|
prop = editor;
|
2018-05-20 04:57:44 +08:00
|
|
|
|
2020-04-17 10:52:00 +08:00
|
|
|
} break;
|
|
|
|
case Variant::RECT2I: {
|
|
|
|
EditorPropertyRect2i *editor = memnew(EditorPropertyRect2i);
|
|
|
|
editor->setup(-100000, 100000, true);
|
|
|
|
prop = editor;
|
|
|
|
|
2018-05-20 04:57:44 +08:00
|
|
|
} break;
|
|
|
|
case Variant::VECTOR3: {
|
2018-09-20 05:35:22 +08:00
|
|
|
EditorPropertyVector3 *editor = memnew(EditorPropertyVector3);
|
2021-10-29 20:24:28 +08:00
|
|
|
editor->setup(-100000, 100000, default_float_step, true);
|
2018-09-20 05:35:22 +08:00
|
|
|
prop = editor;
|
2018-05-20 04:57:44 +08:00
|
|
|
|
2020-04-17 10:52:00 +08:00
|
|
|
} break;
|
|
|
|
case Variant::VECTOR3I: {
|
|
|
|
EditorPropertyVector3i *editor = memnew(EditorPropertyVector3i);
|
|
|
|
editor->setup(-100000, 100000, true);
|
|
|
|
prop = editor;
|
|
|
|
|
2018-05-20 04:57:44 +08:00
|
|
|
} break;
|
|
|
|
case Variant::TRANSFORM2D: {
|
2018-09-20 05:35:22 +08:00
|
|
|
EditorPropertyTransform2D *editor = memnew(EditorPropertyTransform2D);
|
2021-10-29 20:24:28 +08:00
|
|
|
editor->setup(-100000, 100000, default_float_step, true);
|
2018-09-20 05:35:22 +08:00
|
|
|
prop = editor;
|
2018-05-20 04:57:44 +08:00
|
|
|
|
|
|
|
} break;
|
|
|
|
case Variant::PLANE: {
|
2018-09-20 05:35:22 +08:00
|
|
|
EditorPropertyPlane *editor = memnew(EditorPropertyPlane);
|
2021-10-29 20:24:28 +08:00
|
|
|
editor->setup(-100000, 100000, default_float_step, true);
|
2018-09-20 05:35:22 +08:00
|
|
|
prop = editor;
|
2018-05-20 04:57:44 +08:00
|
|
|
|
|
|
|
} break;
|
2021-01-20 15:02:02 +08:00
|
|
|
case Variant::QUATERNION: {
|
|
|
|
EditorPropertyQuaternion *editor = memnew(EditorPropertyQuaternion);
|
2021-10-29 20:24:28 +08:00
|
|
|
editor->setup(-100000, 100000, default_float_step, true);
|
2018-09-20 05:35:22 +08:00
|
|
|
prop = editor;
|
2018-05-20 04:57:44 +08:00
|
|
|
|
|
|
|
} break;
|
|
|
|
case Variant::AABB: {
|
2018-09-20 05:35:22 +08:00
|
|
|
EditorPropertyAABB *editor = memnew(EditorPropertyAABB);
|
2021-10-29 20:24:28 +08:00
|
|
|
editor->setup(-100000, 100000, default_float_step, true);
|
2018-09-20 05:35:22 +08:00
|
|
|
prop = editor;
|
2018-05-20 04:57:44 +08:00
|
|
|
|
|
|
|
} break;
|
|
|
|
case Variant::BASIS: {
|
2018-09-20 05:35:22 +08:00
|
|
|
EditorPropertyBasis *editor = memnew(EditorPropertyBasis);
|
2021-10-29 20:24:28 +08:00
|
|
|
editor->setup(-100000, 100000, default_float_step, true);
|
2018-09-20 05:35:22 +08:00
|
|
|
prop = editor;
|
2018-05-20 04:57:44 +08:00
|
|
|
|
|
|
|
} break;
|
2021-04-28 15:36:08 +08:00
|
|
|
case Variant::TRANSFORM3D: {
|
2021-06-04 09:58:26 +08:00
|
|
|
EditorPropertyTransform3D *editor = memnew(EditorPropertyTransform3D);
|
2021-10-29 20:24:28 +08:00
|
|
|
editor->setup(-100000, 100000, default_float_step, true);
|
2018-09-20 05:35:22 +08:00
|
|
|
prop = editor;
|
2018-05-20 04:57:44 +08:00
|
|
|
|
|
|
|
} break;
|
|
|
|
|
2021-03-30 00:45:42 +08:00
|
|
|
// Miscellaneous types.
|
2018-05-20 04:57:44 +08:00
|
|
|
case Variant::COLOR: {
|
|
|
|
prop = memnew(EditorPropertyColor);
|
|
|
|
|
2020-02-21 05:58:05 +08:00
|
|
|
} break;
|
|
|
|
case Variant::STRING_NAME: {
|
|
|
|
EditorPropertyText *ept = memnew(EditorPropertyText);
|
|
|
|
ept->set_string_name(true);
|
|
|
|
prop = ept;
|
|
|
|
|
2018-05-20 04:57:44 +08:00
|
|
|
} break;
|
|
|
|
case Variant::NODE_PATH: {
|
|
|
|
prop = memnew(EditorPropertyNodePath);
|
|
|
|
|
|
|
|
} break;
|
2020-11-09 21:53:05 +08:00
|
|
|
case Variant::RID: {
|
2019-06-26 21:08:25 +08:00
|
|
|
prop = memnew(EditorPropertyRID);
|
2018-05-20 04:57:44 +08:00
|
|
|
|
|
|
|
} break;
|
|
|
|
case Variant::OBJECT: {
|
2018-11-22 09:10:27 +08:00
|
|
|
if (Object::cast_to<EncodedObjectAsID>(value)) {
|
|
|
|
EditorPropertyObjectID *editor = memnew(EditorPropertyObjectID);
|
|
|
|
editor->setup("Object");
|
|
|
|
prop = editor;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
EditorPropertyResource *editor = memnew(EditorPropertyResource);
|
2021-05-19 20:19:07 +08:00
|
|
|
editor->setup(object.ptr(), prop_name, "Resource");
|
2018-11-22 09:10:27 +08:00
|
|
|
prop = editor;
|
|
|
|
}
|
2018-05-20 04:57:44 +08:00
|
|
|
|
|
|
|
} break;
|
|
|
|
case Variant::DICTIONARY: {
|
|
|
|
prop = memnew(EditorPropertyDictionary);
|
|
|
|
|
|
|
|
} break;
|
|
|
|
case Variant::ARRAY: {
|
2018-09-20 05:35:22 +08:00
|
|
|
EditorPropertyArray *editor = memnew(EditorPropertyArray);
|
|
|
|
editor->setup(Variant::ARRAY);
|
|
|
|
prop = editor;
|
2018-05-20 04:57:44 +08:00
|
|
|
} break;
|
|
|
|
|
2021-03-30 00:45:42 +08:00
|
|
|
// Arrays.
|
2020-02-18 05:06:54 +08:00
|
|
|
case Variant::PACKED_BYTE_ARRAY: {
|
2018-09-20 05:35:22 +08:00
|
|
|
EditorPropertyArray *editor = memnew(EditorPropertyArray);
|
2020-02-18 05:06:54 +08:00
|
|
|
editor->setup(Variant::PACKED_BYTE_ARRAY);
|
2018-09-20 05:35:22 +08:00
|
|
|
prop = editor;
|
2018-05-20 04:57:44 +08:00
|
|
|
} break;
|
Variant: Added 64-bit packed arrays, renamed Variant::REAL to FLOAT.
- Renames PackedIntArray to PackedInt32Array.
- Renames PackedFloatArray to PackedFloat32Array.
- Adds PackedInt64Array and PackedFloat64Array.
- Renames Variant::REAL to Variant::FLOAT for consistency.
Packed arrays are for storing large amount of data and creating stuff like
meshes, buffers. textures, etc. Forcing them to be 64 is a huge waste of
memory. That said, many users requested the ability to have 64 bits packed
arrays for their games, so this is just an optional added type.
For Variant, the float datatype is always 64 bits, and exposed as `float`.
We still have `real_t` which is the datatype that can change from 32 to 64
bits depending on a compile flag (not entirely working right now, but that's
the idea). It affects math related datatypes and code only.
Neither Variant nor PackedArray make use of real_t, which is only intended
for math precision, so the term is removed from there to keep only float.
2020-02-25 02:20:53 +08:00
|
|
|
case Variant::PACKED_INT32_ARRAY: {
|
|
|
|
EditorPropertyArray *editor = memnew(EditorPropertyArray);
|
|
|
|
editor->setup(Variant::PACKED_INT32_ARRAY);
|
|
|
|
prop = editor;
|
|
|
|
} break;
|
|
|
|
case Variant::PACKED_FLOAT32_ARRAY: {
|
|
|
|
EditorPropertyArray *editor = memnew(EditorPropertyArray);
|
|
|
|
editor->setup(Variant::PACKED_FLOAT32_ARRAY);
|
|
|
|
prop = editor;
|
|
|
|
} break;
|
|
|
|
case Variant::PACKED_INT64_ARRAY: {
|
2018-09-20 05:35:22 +08:00
|
|
|
EditorPropertyArray *editor = memnew(EditorPropertyArray);
|
Variant: Added 64-bit packed arrays, renamed Variant::REAL to FLOAT.
- Renames PackedIntArray to PackedInt32Array.
- Renames PackedFloatArray to PackedFloat32Array.
- Adds PackedInt64Array and PackedFloat64Array.
- Renames Variant::REAL to Variant::FLOAT for consistency.
Packed arrays are for storing large amount of data and creating stuff like
meshes, buffers. textures, etc. Forcing them to be 64 is a huge waste of
memory. That said, many users requested the ability to have 64 bits packed
arrays for their games, so this is just an optional added type.
For Variant, the float datatype is always 64 bits, and exposed as `float`.
We still have `real_t` which is the datatype that can change from 32 to 64
bits depending on a compile flag (not entirely working right now, but that's
the idea). It affects math related datatypes and code only.
Neither Variant nor PackedArray make use of real_t, which is only intended
for math precision, so the term is removed from there to keep only float.
2020-02-25 02:20:53 +08:00
|
|
|
editor->setup(Variant::PACKED_INT64_ARRAY);
|
2018-09-20 05:35:22 +08:00
|
|
|
prop = editor;
|
2018-05-20 04:57:44 +08:00
|
|
|
} break;
|
Variant: Added 64-bit packed arrays, renamed Variant::REAL to FLOAT.
- Renames PackedIntArray to PackedInt32Array.
- Renames PackedFloatArray to PackedFloat32Array.
- Adds PackedInt64Array and PackedFloat64Array.
- Renames Variant::REAL to Variant::FLOAT for consistency.
Packed arrays are for storing large amount of data and creating stuff like
meshes, buffers. textures, etc. Forcing them to be 64 is a huge waste of
memory. That said, many users requested the ability to have 64 bits packed
arrays for their games, so this is just an optional added type.
For Variant, the float datatype is always 64 bits, and exposed as `float`.
We still have `real_t` which is the datatype that can change from 32 to 64
bits depending on a compile flag (not entirely working right now, but that's
the idea). It affects math related datatypes and code only.
Neither Variant nor PackedArray make use of real_t, which is only intended
for math precision, so the term is removed from there to keep only float.
2020-02-25 02:20:53 +08:00
|
|
|
case Variant::PACKED_FLOAT64_ARRAY: {
|
2018-09-20 05:35:22 +08:00
|
|
|
EditorPropertyArray *editor = memnew(EditorPropertyArray);
|
Variant: Added 64-bit packed arrays, renamed Variant::REAL to FLOAT.
- Renames PackedIntArray to PackedInt32Array.
- Renames PackedFloatArray to PackedFloat32Array.
- Adds PackedInt64Array and PackedFloat64Array.
- Renames Variant::REAL to Variant::FLOAT for consistency.
Packed arrays are for storing large amount of data and creating stuff like
meshes, buffers. textures, etc. Forcing them to be 64 is a huge waste of
memory. That said, many users requested the ability to have 64 bits packed
arrays for their games, so this is just an optional added type.
For Variant, the float datatype is always 64 bits, and exposed as `float`.
We still have `real_t` which is the datatype that can change from 32 to 64
bits depending on a compile flag (not entirely working right now, but that's
the idea). It affects math related datatypes and code only.
Neither Variant nor PackedArray make use of real_t, which is only intended
for math precision, so the term is removed from there to keep only float.
2020-02-25 02:20:53 +08:00
|
|
|
editor->setup(Variant::PACKED_FLOAT64_ARRAY);
|
2018-09-20 05:35:22 +08:00
|
|
|
prop = editor;
|
2018-05-20 04:57:44 +08:00
|
|
|
} break;
|
2020-02-18 05:06:54 +08:00
|
|
|
case Variant::PACKED_STRING_ARRAY: {
|
2018-09-20 05:35:22 +08:00
|
|
|
EditorPropertyArray *editor = memnew(EditorPropertyArray);
|
2020-02-18 05:06:54 +08:00
|
|
|
editor->setup(Variant::PACKED_STRING_ARRAY);
|
2018-09-20 05:35:22 +08:00
|
|
|
prop = editor;
|
2018-05-20 04:57:44 +08:00
|
|
|
} break;
|
2020-02-18 05:06:54 +08:00
|
|
|
case Variant::PACKED_VECTOR2_ARRAY: {
|
2018-09-20 05:35:22 +08:00
|
|
|
EditorPropertyArray *editor = memnew(EditorPropertyArray);
|
2020-02-18 05:06:54 +08:00
|
|
|
editor->setup(Variant::PACKED_VECTOR2_ARRAY);
|
2018-09-20 05:35:22 +08:00
|
|
|
prop = editor;
|
2018-05-20 04:57:44 +08:00
|
|
|
} break;
|
2020-02-18 05:06:54 +08:00
|
|
|
case Variant::PACKED_VECTOR3_ARRAY: {
|
2018-09-20 05:35:22 +08:00
|
|
|
EditorPropertyArray *editor = memnew(EditorPropertyArray);
|
2020-02-18 05:06:54 +08:00
|
|
|
editor->setup(Variant::PACKED_VECTOR3_ARRAY);
|
2018-09-20 05:35:22 +08:00
|
|
|
prop = editor;
|
2018-05-20 04:57:44 +08:00
|
|
|
} break;
|
2020-02-18 05:06:54 +08:00
|
|
|
case Variant::PACKED_COLOR_ARRAY: {
|
2018-09-20 05:35:22 +08:00
|
|
|
EditorPropertyArray *editor = memnew(EditorPropertyArray);
|
2020-02-18 05:06:54 +08:00
|
|
|
editor->setup(Variant::PACKED_COLOR_ARRAY);
|
2018-09-20 05:35:22 +08:00
|
|
|
prop = editor;
|
2018-05-20 04:57:44 +08:00
|
|
|
} break;
|
2019-04-09 23:08:36 +08:00
|
|
|
default: {
|
|
|
|
}
|
2018-05-20 04:57:44 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (i == amount) {
|
|
|
|
PanelContainer *pc = memnew(PanelContainer);
|
2022-02-06 08:11:15 +08:00
|
|
|
property_vbox->add_child(pc);
|
|
|
|
pc->add_theme_style_override(SNAME("panel"), get_theme_stylebox(SNAME("DictionaryAddItem"), SNAME("EditorStyles")));
|
2018-05-20 04:57:44 +08:00
|
|
|
|
|
|
|
add_vbox = memnew(VBoxContainer);
|
|
|
|
pc->add_child(add_vbox);
|
|
|
|
}
|
|
|
|
prop->set_object_and_property(object.ptr(), prop_name);
|
2018-10-01 23:33:08 +08:00
|
|
|
int change_index = 0;
|
2018-05-20 04:57:44 +08:00
|
|
|
|
|
|
|
if (i < amount) {
|
|
|
|
String cs = key.get_construct_string();
|
|
|
|
prop->set_label(key.get_construct_string());
|
|
|
|
prop->set_tooltip(cs);
|
|
|
|
change_index = i + offset;
|
|
|
|
} else if (i == amount) {
|
|
|
|
prop->set_label(TTR("New Key:"));
|
|
|
|
change_index = -1;
|
|
|
|
} else if (i == amount + 1) {
|
|
|
|
prop->set_label(TTR("New Value:"));
|
|
|
|
change_index = -2;
|
|
|
|
}
|
|
|
|
|
|
|
|
prop->set_selectable(false);
|
2020-03-05 22:33:01 +08:00
|
|
|
prop->connect("property_changed", callable_mp(this, &EditorPropertyDictionary::_property_changed));
|
2020-02-22 01:28:45 +08:00
|
|
|
prop->connect("object_id_selected", callable_mp(this, &EditorPropertyDictionary::_object_id_selected));
|
2018-05-20 04:57:44 +08:00
|
|
|
|
2021-03-30 00:45:42 +08:00
|
|
|
HBoxContainer *hbox = memnew(HBoxContainer);
|
2018-05-20 04:57:44 +08:00
|
|
|
if (add_vbox) {
|
2021-03-30 00:45:42 +08:00
|
|
|
add_vbox->add_child(hbox);
|
2018-05-20 04:57:44 +08:00
|
|
|
} else {
|
2022-02-06 08:11:15 +08:00
|
|
|
property_vbox->add_child(hbox);
|
2018-05-20 04:57:44 +08:00
|
|
|
}
|
2021-03-30 00:45:42 +08:00
|
|
|
hbox->add_child(prop);
|
2018-05-20 04:57:44 +08:00
|
|
|
prop->set_h_size_flags(SIZE_EXPAND_FILL);
|
|
|
|
Button *edit = memnew(Button);
|
2021-07-18 05:22:52 +08:00
|
|
|
edit->set_icon(get_theme_icon(SNAME("Edit"), SNAME("EditorIcons")));
|
2021-03-30 00:45:42 +08:00
|
|
|
hbox->add_child(edit);
|
2020-02-22 01:28:45 +08:00
|
|
|
edit->connect("pressed", callable_mp(this, &EditorPropertyDictionary::_change_type), varray(edit, change_index));
|
2018-05-20 04:57:44 +08:00
|
|
|
|
|
|
|
prop->update_property();
|
|
|
|
|
|
|
|
if (i == amount + 1) {
|
2022-01-25 08:16:05 +08:00
|
|
|
button_add_item = memnew(Button);
|
|
|
|
button_add_item->set_text(TTR("Add Key/Value Pair"));
|
|
|
|
button_add_item->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons")));
|
|
|
|
button_add_item->connect("pressed", callable_mp(this, &EditorPropertyDictionary::_add_key_value));
|
|
|
|
add_vbox->add_child(button_add_item);
|
2018-05-20 04:57:44 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
updating = false;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
if (vbox) {
|
2020-04-02 07:20:12 +08:00
|
|
|
set_bottom_editor(nullptr);
|
2018-05-20 04:57:44 +08:00
|
|
|
memdelete(vbox);
|
2022-03-04 21:04:59 +08:00
|
|
|
button_add_item = nullptr;
|
2020-04-02 07:20:12 +08:00
|
|
|
vbox = nullptr;
|
2018-05-20 04:57:44 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-03 17:46:03 +08:00
|
|
|
void EditorPropertyDictionary::_object_id_selected(const StringName &p_property, ObjectID p_id) {
|
2021-07-18 05:22:52 +08:00
|
|
|
emit_signal(SNAME("object_id_selected"), p_property, p_id);
|
2018-11-22 09:10:27 +08:00
|
|
|
}
|
|
|
|
|
2018-05-20 04:57:44 +08:00
|
|
|
void EditorPropertyDictionary::_notification(int p_what) {
|
2022-02-16 07:52:32 +08:00
|
|
|
switch (p_what) {
|
|
|
|
case NOTIFICATION_THEME_CHANGED:
|
|
|
|
case NOTIFICATION_ENTER_TREE: {
|
|
|
|
change_type->clear();
|
|
|
|
for (int i = 0; i < Variant::VARIANT_MAX; i++) {
|
|
|
|
String type = Variant::get_type_name(Variant::Type(i));
|
|
|
|
change_type->add_icon_item(get_theme_icon(type, SNAME("EditorIcons")), type, i);
|
|
|
|
}
|
|
|
|
change_type->add_separator();
|
|
|
|
change_type->add_icon_item(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), TTR("Remove Item"), Variant::VARIANT_MAX);
|
2022-01-25 08:16:05 +08:00
|
|
|
|
2022-02-16 07:52:32 +08:00
|
|
|
if (Object::cast_to<Button>(button_add_item)) {
|
|
|
|
button_add_item->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons")));
|
|
|
|
}
|
|
|
|
} break;
|
2022-01-25 08:16:05 +08:00
|
|
|
}
|
2018-05-20 04:57:44 +08:00
|
|
|
}
|
2018-07-24 08:42:31 +08:00
|
|
|
|
2018-05-20 04:57:44 +08:00
|
|
|
void EditorPropertyDictionary::_edit_pressed() {
|
2018-07-24 08:42:31 +08:00
|
|
|
Variant prop_val = get_edited_object()->get(get_edited_property());
|
|
|
|
if (prop_val.get_type() == Variant::NIL) {
|
2020-02-20 03:27:19 +08:00
|
|
|
Callable::CallError ce;
|
2020-11-09 11:19:09 +08:00
|
|
|
Variant::construct(Variant::DICTIONARY, prop_val, nullptr, 0, ce);
|
2018-07-24 08:42:31 +08:00
|
|
|
get_edited_object()->set(get_edited_property(), prop_val);
|
|
|
|
}
|
|
|
|
|
2018-05-20 04:57:44 +08:00
|
|
|
get_edited_object()->editor_set_section_unfold(get_edited_property(), edit->is_pressed());
|
|
|
|
update_property();
|
|
|
|
}
|
|
|
|
|
2022-02-06 08:11:15 +08:00
|
|
|
void EditorPropertyDictionary::_page_changed(int p_page) {
|
2020-05-14 22:41:43 +08:00
|
|
|
if (updating) {
|
2018-05-20 04:57:44 +08:00
|
|
|
return;
|
2020-05-14 22:41:43 +08:00
|
|
|
}
|
2021-03-30 00:45:42 +08:00
|
|
|
page_index = p_page;
|
2018-05-20 04:57:44 +08:00
|
|
|
update_property();
|
|
|
|
}
|
|
|
|
|
|
|
|
void EditorPropertyDictionary::_bind_methods() {
|
|
|
|
}
|
|
|
|
|
|
|
|
EditorPropertyDictionary::EditorPropertyDictionary() {
|
2021-06-18 06:03:09 +08:00
|
|
|
object.instantiate();
|
2021-03-30 00:45:42 +08:00
|
|
|
page_length = int(EDITOR_GET("interface/inspector/max_array_dictionary_items_per_page"));
|
2022-02-06 08:11:15 +08:00
|
|
|
|
2018-05-20 04:57:44 +08:00
|
|
|
edit = memnew(Button);
|
|
|
|
edit->set_h_size_flags(SIZE_EXPAND_FILL);
|
|
|
|
edit->set_clip_text(true);
|
2020-02-22 01:28:45 +08:00
|
|
|
edit->connect("pressed", callable_mp(this, &EditorPropertyDictionary::_edit_pressed));
|
2018-05-20 04:57:44 +08:00
|
|
|
edit->set_toggle_mode(true);
|
|
|
|
add_child(edit);
|
|
|
|
add_focusable(edit);
|
2022-02-06 08:11:15 +08:00
|
|
|
|
2020-04-02 07:20:12 +08:00
|
|
|
vbox = nullptr;
|
2022-01-25 08:16:05 +08:00
|
|
|
button_add_item = nullptr;
|
2022-02-06 08:11:15 +08:00
|
|
|
paginator = nullptr;
|
2018-05-20 04:57:44 +08:00
|
|
|
change_type = memnew(PopupMenu);
|
|
|
|
add_child(change_type);
|
2020-02-22 01:28:45 +08:00
|
|
|
change_type->connect("id_pressed", callable_mp(this, &EditorPropertyDictionary::_change_type_menu));
|
2021-03-30 00:45:42 +08:00
|
|
|
changing_type_index = -1;
|
2018-05-20 04:57:44 +08:00
|
|
|
}
|
2022-03-04 21:04:59 +08:00
|
|
|
|
|
|
|
///////////////////// LOCALIZABLE STRING ///////////////////////////
|
|
|
|
|
|
|
|
void EditorPropertyLocalizableString::_property_changed(const String &p_property, Variant p_value, const String &p_name, bool p_changing) {
|
|
|
|
if (p_property.begins_with("indices")) {
|
|
|
|
int index = p_property.get_slice("/", 1).to_int();
|
|
|
|
Dictionary dict = object->get_dict();
|
|
|
|
Variant key = dict.get_key_at_index(index);
|
|
|
|
dict[key] = p_value;
|
|
|
|
|
|
|
|
emit_changed(get_edited_property(), dict, "", true);
|
|
|
|
|
|
|
|
dict = dict.duplicate(); // Duplicate, so undo/redo works better.
|
|
|
|
object->set_dict(dict);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void EditorPropertyLocalizableString::_add_locale_popup() {
|
|
|
|
locale_select->popup_locale_dialog();
|
|
|
|
}
|
|
|
|
|
|
|
|
void EditorPropertyLocalizableString::_add_locale(const String &p_locale) {
|
|
|
|
Dictionary dict = object->get_dict();
|
|
|
|
|
|
|
|
object->set_new_item_key(p_locale);
|
|
|
|
object->set_new_item_value(String());
|
|
|
|
dict[object->get_new_item_key()] = object->get_new_item_value();
|
|
|
|
|
|
|
|
emit_changed(get_edited_property(), dict, "", false);
|
|
|
|
|
|
|
|
dict = dict.duplicate(); // Duplicate, so undo/redo works better.
|
|
|
|
object->set_dict(dict);
|
|
|
|
update_property();
|
|
|
|
}
|
|
|
|
|
|
|
|
void EditorPropertyLocalizableString::_remove_item(Object *p_button, int p_index) {
|
|
|
|
Dictionary dict = object->get_dict();
|
|
|
|
|
|
|
|
Variant key = dict.get_key_at_index(p_index);
|
|
|
|
dict.erase(key);
|
|
|
|
|
|
|
|
emit_changed(get_edited_property(), dict, "", false);
|
|
|
|
|
|
|
|
dict = dict.duplicate(); // Duplicate, so undo/redo works better.
|
|
|
|
object->set_dict(dict);
|
|
|
|
update_property();
|
|
|
|
}
|
|
|
|
|
|
|
|
void EditorPropertyLocalizableString::update_property() {
|
|
|
|
Variant updated_val = get_edited_object()->get(get_edited_property());
|
|
|
|
|
|
|
|
if (updated_val.get_type() == Variant::NIL) {
|
|
|
|
edit->set_text(TTR("Localizable String (Nil)")); // This provides symmetry with the array property.
|
|
|
|
edit->set_pressed(false);
|
|
|
|
if (vbox) {
|
|
|
|
set_bottom_editor(nullptr);
|
|
|
|
memdelete(vbox);
|
2022-03-15 15:51:58 +08:00
|
|
|
button_add_item = nullptr;
|
2022-03-04 21:04:59 +08:00
|
|
|
vbox = nullptr;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
Dictionary dict = updated_val;
|
|
|
|
|
|
|
|
edit->set_text(vformat(TTR("Localizable String (size %d)"), dict.size()));
|
|
|
|
|
|
|
|
bool unfolded = get_edited_object()->editor_is_section_unfolded(get_edited_property());
|
|
|
|
if (edit->is_pressed() != unfolded) {
|
|
|
|
edit->set_pressed(unfolded);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (unfolded) {
|
|
|
|
updating = true;
|
|
|
|
|
|
|
|
if (!vbox) {
|
|
|
|
vbox = memnew(VBoxContainer);
|
|
|
|
add_child(vbox);
|
|
|
|
set_bottom_editor(vbox);
|
|
|
|
|
|
|
|
property_vbox = memnew(VBoxContainer);
|
|
|
|
property_vbox->set_h_size_flags(SIZE_EXPAND_FILL);
|
|
|
|
vbox->add_child(property_vbox);
|
|
|
|
|
|
|
|
paginator = memnew(EditorPaginator);
|
|
|
|
paginator->connect("page_changed", callable_mp(this, &EditorPropertyLocalizableString::_page_changed));
|
|
|
|
vbox->add_child(paginator);
|
|
|
|
} else {
|
|
|
|
// Queue children for deletion, deleting immediately might cause errors.
|
|
|
|
for (int i = property_vbox->get_child_count() - 1; i >= 0; i--) {
|
|
|
|
property_vbox->get_child(i)->queue_delete();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int size = dict.size();
|
|
|
|
|
|
|
|
int max_page = MAX(0, size - 1) / page_length;
|
|
|
|
page_index = MIN(page_index, max_page);
|
|
|
|
|
|
|
|
paginator->update(page_index, max_page);
|
|
|
|
paginator->set_visible(max_page > 0);
|
|
|
|
|
|
|
|
int offset = page_index * page_length;
|
|
|
|
|
|
|
|
int amount = MIN(size - offset, page_length);
|
|
|
|
|
|
|
|
dict = dict.duplicate();
|
|
|
|
|
|
|
|
object->set_dict(dict);
|
|
|
|
|
|
|
|
for (int i = 0; i < amount; i++) {
|
|
|
|
String prop_name;
|
|
|
|
Variant key;
|
|
|
|
Variant value;
|
|
|
|
|
|
|
|
prop_name = "indices/" + itos(i + offset);
|
|
|
|
key = dict.get_key_at_index(i + offset);
|
|
|
|
value = dict.get_value_at_index(i + offset);
|
|
|
|
|
|
|
|
EditorProperty *prop = memnew(EditorPropertyText);
|
|
|
|
|
|
|
|
prop->set_object_and_property(object.ptr(), prop_name);
|
|
|
|
int remove_index = 0;
|
|
|
|
|
|
|
|
String cs = key.get_construct_string();
|
|
|
|
prop->set_label(cs);
|
|
|
|
prop->set_tooltip(cs);
|
|
|
|
remove_index = i + offset;
|
|
|
|
|
|
|
|
prop->set_selectable(false);
|
|
|
|
prop->connect("property_changed", callable_mp(this, &EditorPropertyLocalizableString::_property_changed));
|
|
|
|
prop->connect("object_id_selected", callable_mp(this, &EditorPropertyLocalizableString::_object_id_selected));
|
|
|
|
|
|
|
|
HBoxContainer *hbox = memnew(HBoxContainer);
|
|
|
|
property_vbox->add_child(hbox);
|
|
|
|
hbox->add_child(prop);
|
|
|
|
prop->set_h_size_flags(SIZE_EXPAND_FILL);
|
|
|
|
Button *edit = memnew(Button);
|
|
|
|
edit->set_icon(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")));
|
|
|
|
hbox->add_child(edit);
|
|
|
|
edit->connect("pressed", callable_mp(this, &EditorPropertyLocalizableString::_remove_item), varray(edit, remove_index));
|
|
|
|
|
|
|
|
prop->update_property();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (page_index == max_page) {
|
|
|
|
button_add_item = memnew(Button);
|
|
|
|
button_add_item->set_text(TTR("Add Translation"));
|
|
|
|
button_add_item->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons")));
|
|
|
|
button_add_item->connect("pressed", callable_mp(this, &EditorPropertyLocalizableString::_add_locale_popup));
|
|
|
|
property_vbox->add_child(button_add_item);
|
|
|
|
}
|
|
|
|
|
|
|
|
updating = false;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
if (vbox) {
|
|
|
|
set_bottom_editor(nullptr);
|
|
|
|
memdelete(vbox);
|
|
|
|
button_add_item = nullptr;
|
|
|
|
vbox = nullptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void EditorPropertyLocalizableString::_object_id_selected(const StringName &p_property, ObjectID p_id) {
|
|
|
|
emit_signal(SNAME("object_id_selected"), p_property, p_id);
|
|
|
|
}
|
|
|
|
|
|
|
|
void EditorPropertyLocalizableString::_notification(int p_what) {
|
|
|
|
switch (p_what) {
|
|
|
|
case NOTIFICATION_THEME_CHANGED:
|
|
|
|
case NOTIFICATION_ENTER_TREE: {
|
|
|
|
if (Object::cast_to<Button>(button_add_item)) {
|
|
|
|
button_add_item->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons")));
|
|
|
|
}
|
|
|
|
} break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void EditorPropertyLocalizableString::_edit_pressed() {
|
|
|
|
Variant prop_val = get_edited_object()->get(get_edited_property());
|
|
|
|
if (prop_val.get_type() == Variant::NIL) {
|
|
|
|
Callable::CallError ce;
|
|
|
|
Variant::construct(Variant::DICTIONARY, prop_val, nullptr, 0, ce);
|
|
|
|
get_edited_object()->set(get_edited_property(), prop_val);
|
|
|
|
}
|
|
|
|
|
|
|
|
get_edited_object()->editor_set_section_unfold(get_edited_property(), edit->is_pressed());
|
|
|
|
update_property();
|
|
|
|
}
|
|
|
|
|
|
|
|
void EditorPropertyLocalizableString::_page_changed(int p_page) {
|
|
|
|
if (updating) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
page_index = p_page;
|
|
|
|
update_property();
|
|
|
|
}
|
|
|
|
|
|
|
|
void EditorPropertyLocalizableString::_bind_methods() {
|
|
|
|
}
|
|
|
|
|
|
|
|
EditorPropertyLocalizableString::EditorPropertyLocalizableString() {
|
|
|
|
object.instantiate();
|
|
|
|
page_length = int(EDITOR_GET("interface/inspector/max_array_dictionary_items_per_page"));
|
|
|
|
|
|
|
|
edit = memnew(Button);
|
|
|
|
edit->set_h_size_flags(SIZE_EXPAND_FILL);
|
|
|
|
edit->set_clip_text(true);
|
|
|
|
edit->connect("pressed", callable_mp(this, &EditorPropertyLocalizableString::_edit_pressed));
|
|
|
|
edit->set_toggle_mode(true);
|
|
|
|
add_child(edit);
|
|
|
|
add_focusable(edit);
|
|
|
|
|
|
|
|
vbox = nullptr;
|
|
|
|
button_add_item = nullptr;
|
|
|
|
paginator = nullptr;
|
|
|
|
updating = false;
|
|
|
|
|
|
|
|
locale_select = memnew(EditorLocaleDialog);
|
|
|
|
locale_select->connect("locale_selected", callable_mp(this, &EditorPropertyLocalizableString::_add_locale));
|
|
|
|
add_child(locale_select);
|
|
|
|
}
|