summaryrefslogtreecommitdiffstats
path: root/editor
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2024-05-28 15:49:12 +0200
committerRémi Verschelde <rverschelde@gmail.com>2024-05-28 15:49:12 +0200
commitf87be863cacff5d1cc448c061d1d8d0b67172eea (patch)
tree50c50f07de6dc7a2acc9e11e14353c6548fea2e3 /editor
parenta10897ddc0b0ab57fe67e7d0b9b3415ed8e74a5c (diff)
parent85eac455139ae527951bf5fd49cedbac3535fd4d (diff)
downloadredot-engine-f87be863cacff5d1cc448c061d1d8d0b67172eea.tar.gz
Merge pull request #92322 from groud/implement_custom_data_label
Display custom data name instead of indices in TileData inspector
Diffstat (limited to 'editor')
-rw-r--r--editor/editor_inspector.compat.inc41
-rw-r--r--editor/editor_inspector.cpp6
-rw-r--r--editor/editor_inspector.h6
-rw-r--r--editor/plugins/tiles/tile_set_atlas_source_editor.cpp12
4 files changed, 62 insertions, 3 deletions
diff --git a/editor/editor_inspector.compat.inc b/editor/editor_inspector.compat.inc
new file mode 100644
index 0000000000..53c410ba26
--- /dev/null
+++ b/editor/editor_inspector.compat.inc
@@ -0,0 +1,41 @@
+/**************************************************************************/
+/* editor_inspector.compat.inc */
+/**************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/**************************************************************************/
+/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
+/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* */
+/* 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. */
+/**************************************************************************/
+
+#ifndef DISABLE_DEPRECATED
+
+void EditorInspectorPlugin::_add_property_editor_bind_compat_92322(const String &p_for_property, Control *p_prop, bool p_add_to_end) {
+ add_property_editor(p_for_property, p_prop, p_add_to_end, "");
+}
+
+void EditorInspectorPlugin::_bind_compatibility_methods() {
+ ClassDB::bind_compatibility_method(D_METHOD("add_property_editor", "property", "editor", "add_to_end"), &EditorInspectorPlugin::_add_property_editor_bind_compat_92322, DEFVAL(false));
+}
+
+#endif // DISABLE_DEPRECATED
diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp
index a9f32927a8..f4dcc8bd4a 100644
--- a/editor/editor_inspector.cpp
+++ b/editor/editor_inspector.cpp
@@ -29,6 +29,7 @@
/**************************************************************************/
#include "editor_inspector.h"
+#include "editor_inspector.compat.inc"
#include "core/os/keyboard.h"
#include "editor/doc_tools.h"
@@ -1128,11 +1129,12 @@ void EditorInspectorPlugin::add_custom_control(Control *control) {
added_editors.push_back(ae);
}
-void EditorInspectorPlugin::add_property_editor(const String &p_for_property, Control *p_prop, bool p_add_to_end) {
+void EditorInspectorPlugin::add_property_editor(const String &p_for_property, Control *p_prop, bool p_add_to_end, const String &p_label) {
AddedEditor ae;
ae.properties.push_back(p_for_property);
ae.property_editor = p_prop;
ae.add_to_end = p_add_to_end;
+ ae.label = p_label;
added_editors.push_back(ae);
}
@@ -1174,7 +1176,7 @@ void EditorInspectorPlugin::parse_end(Object *p_object) {
void EditorInspectorPlugin::_bind_methods() {
ClassDB::bind_method(D_METHOD("add_custom_control", "control"), &EditorInspectorPlugin::add_custom_control);
- ClassDB::bind_method(D_METHOD("add_property_editor", "property", "editor", "add_to_end"), &EditorInspectorPlugin::add_property_editor, DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("add_property_editor", "property", "editor", "add_to_end", "label"), &EditorInspectorPlugin::add_property_editor, DEFVAL(false), DEFVAL(String()));
ClassDB::bind_method(D_METHOD("add_property_editor_for_multiple_properties", "label", "properties", "editor"), &EditorInspectorPlugin::add_property_editor_for_multiple_properties);
GDVIRTUAL_BIND(_can_handle, "object")
diff --git a/editor/editor_inspector.h b/editor/editor_inspector.h
index e52903101d..a0ced55bd8 100644
--- a/editor/editor_inspector.h
+++ b/editor/editor_inspector.h
@@ -252,9 +252,13 @@ protected:
GDVIRTUAL7R(bool, _parse_property, Object *, Variant::Type, String, PropertyHint, String, BitField<PropertyUsageFlags>, bool)
GDVIRTUAL1(_parse_end, Object *)
+#ifndef DISABLE_DEPRECATED
+ void _add_property_editor_bind_compat_92322(const String &p_for_property, Control *p_prop, bool p_add_to_end);
+ static void _bind_compatibility_methods();
+#endif // DISABLE_DEPRECATED
public:
void add_custom_control(Control *control);
- void add_property_editor(const String &p_for_property, Control *p_prop, bool p_add_to_end = false);
+ void add_property_editor(const String &p_for_property, Control *p_prop, bool p_add_to_end = false, const String &p_label = String());
void add_property_editor_for_multiple_properties(const String &p_label, const Vector<String> &p_properties, Control *p_prop);
virtual bool can_handle(Object *p_object);
diff --git a/editor/plugins/tiles/tile_set_atlas_source_editor.cpp b/editor/plugins/tiles/tile_set_atlas_source_editor.cpp
index 1daba1f665..03070bc6b5 100644
--- a/editor/plugins/tiles/tile_set_atlas_source_editor.cpp
+++ b/editor/plugins/tiles/tile_set_atlas_source_editor.cpp
@@ -2938,6 +2938,18 @@ bool EditorInspectorPluginTileData::parse_property(Object *p_object, const Varia
add_property_editor(p_path, ep);
return true;
}
+ } else if (p_path.begins_with("custom_data_") && p_path.trim_prefix("custom_data_").is_valid_int()) {
+ // Custom data layers.
+ int layer_index = components[0].trim_prefix("custom_data_").to_int();
+ ERR_FAIL_COND_V(layer_index < 0, false);
+ EditorProperty *ep = EditorInspectorDefaultPlugin::get_editor_for_property(p_object, p_type, p_path, PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT);
+ const TileSetAtlasSourceEditor::AtlasTileProxyObject *proxy_obj = Object::cast_to<TileSetAtlasSourceEditor::AtlasTileProxyObject>(p_object);
+ const TileSetAtlasSource *atlas_source = *proxy_obj->get_edited_tile_set_atlas_source();
+ ERR_FAIL_NULL_V(atlas_source, false);
+ const TileSet *tile_set = atlas_source->get_tile_set();
+ ERR_FAIL_NULL_V(tile_set, false);
+ add_property_editor(p_path, ep, false, tile_set->get_custom_data_layer_name(layer_index));
+ return true;
}
return false;
}