summaryrefslogtreecommitdiff
path: root/editor/property_editor.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'editor/property_editor.cpp')
-rw-r--r--editor/property_editor.cpp79
1 files changed, 66 insertions, 13 deletions
diff --git a/editor/property_editor.cpp b/editor/property_editor.cpp
index 8a9fd2cde5..c2af2445cc 100644
--- a/editor/property_editor.cpp
+++ b/editor/property_editor.cpp
@@ -37,8 +37,6 @@
#include "editor_help.h"
#include "editor_node.h"
#include "editor_settings.h"
-#include "global_config.h"
-#include "global_config.h"
#include "io/image_loader.h"
#include "io/resource_loader.h"
#include "multi_node_edit.h"
@@ -46,6 +44,8 @@
#include "os/keyboard.h"
#include "pair.h"
#include "print_string.h"
+#include "project_settings.h"
+#include "project_settings.h"
#include "property_selector.h"
#include "scene/gui/label.h"
#include "scene/main/viewport.h"
@@ -415,7 +415,7 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant::
int idx = i * 10 + j;
CheckBox *c = checks20[idx];
- c->set_text(GlobalConfig::get_singleton()->get(basename + "/layer_" + itos(idx + 1)));
+ c->set_text(ProjectSettings::get_singleton()->get(basename + "/layer_" + itos(idx + 1)));
c->set_pressed(flgs & (1 << (i * 10 + j)));
c->show();
}
@@ -815,16 +815,12 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant::
color_picker = memnew(ColorPicker);
add_child(color_picker);
color_picker->hide();
- color_picker->set_area_as_parent_rect();
- for (int i = 0; i < 4; i++)
- color_picker->set_margin((Margin)i, 5);
color_picker->connect("color_changed", this, "_color_changed");
}
color_picker->show();
color_picker->set_edit_alpha(hint != PROPERTY_HINT_COLOR_NO_ALPHA);
color_picker->set_pick_color(v);
- set_size(Size2(307 * EDSCALE, 460 * EDSCALE));
color_picker->set_focus_on_line_edit();
/*
int ofs=80;
@@ -1023,7 +1019,7 @@ void CustomPropertyEditor::_file_selected(String p_file) {
if (hint == PROPERTY_HINT_FILE || hint == PROPERTY_HINT_DIR) {
- v = GlobalConfig::get_singleton()->localize_path(p_file);
+ v = ProjectSettings::get_singleton()->localize_path(p_file);
emit_signal("variant_changed");
hide();
}
@@ -3006,8 +3002,18 @@ void PropertyEditor::update_tree() {
String name = (basename.find("/") != -1) ? basename.right(basename.find_last("/") + 1) : basename;
- if (capitalize_paths)
- name = name.camelcase_to_underscore().capitalize();
+ if (capitalize_paths) {
+ int dot = name.find(".");
+ if (dot != -1) {
+ String ov = name.right(dot);
+ name = name.substr(0, dot);
+ name = name.camelcase_to_underscore().capitalize();
+ name += ov;
+
+ } else {
+ name = name.camelcase_to_underscore().capitalize();
+ }
+ }
String path = basename.left(basename.find_last("/"));
@@ -3050,7 +3056,7 @@ void PropertyEditor::update_tree() {
//item->set_custom_bg_color(1,col);
}
item->set_editable(0, false);
- item->set_selectable(0, false);
+ item->set_selectable(0, property_selectable);
if (p.usage & PROPERTY_USAGE_CHECKABLE) {
@@ -3063,6 +3069,18 @@ void PropertyEditor::update_tree() {
item->set_text(0, name);
item->set_tooltip(0, p.name);
+ if (name.find(".") != -1) {
+ Color textcol = get_color("font_color", "Tree");
+ textcol.a *= 0.5;
+ //override :D
+ item->set_custom_color(0, textcol);
+ item->set_custom_color(1, textcol);
+
+ Color iconcol(1, 1, 1, 0.6);
+ item->set_icon_color(0, iconcol);
+ item->set_icon_color(1, iconcol);
+ }
+
if (use_doc_hints) {
StringName setter;
StringName type;
@@ -4312,6 +4330,11 @@ void PropertyEditor::register_text_enter(Node *p_line_edit) {
search_box->connect("text_changed", this, "_filter_changed");
}
+void PropertyEditor::set_property_selectable(bool p_selectable) {
+ property_selectable = p_selectable;
+ update_tree();
+}
+
void PropertyEditor::set_subsection_selectable(bool p_selectable) {
if (p_selectable == subsection_selectable)
@@ -4331,7 +4354,7 @@ PropertyEditor::PropertyEditor() {
_prop_edited = "property_edited";
- hide_script = false;
+ hide_script = true;
use_folding = false;
undo_redo = NULL;
@@ -4398,6 +4421,7 @@ PropertyEditor::PropertyEditor() {
updating_folding = true;
use_filter = false;
subsection_selectable = false;
+ property_selectable = false;
show_type_icons = EDITOR_DEF("interface/show_type_icons", false);
}
@@ -4512,6 +4536,7 @@ public:
void SectionedPropertyEditor::_bind_methods() {
ClassDB::bind_method("_section_selected", &SectionedPropertyEditor::_section_selected);
+ ClassDB::bind_method("_search_changed", &SectionedPropertyEditor::_search_changed);
ClassDB::bind_method("update_category_list", &SectionedPropertyEditor::update_category_list);
}
@@ -4609,6 +4634,10 @@ void SectionedPropertyEditor::update_category_list() {
if (pi.name.find(":") != -1 || pi.name == "script" || pi.name == "resource_name" || pi.name == "resource_path")
continue;
+
+ if (search_box && search_box->get_text() != String() && pi.name.findn(search_box->get_text()) == -1)
+ continue;
+
int sp = pi.name.find("/");
if (sp == -1)
pi.name = "Global/" + pi.name;
@@ -4616,7 +4645,9 @@ void SectionedPropertyEditor::update_category_list() {
Vector<String> sectionarr = pi.name.split("/");
String metasection;
- for (int i = 0; i < MIN(2, sectionarr.size() - 1); i++) {
+ int sc = MIN(2, sectionarr.size() - 1);
+
+ for (int i = 0; i < sc; i++) {
TreeItem *parent = section_map[metasection];
@@ -4631,6 +4662,12 @@ void SectionedPropertyEditor::update_category_list() {
section_map[metasection] = ms;
ms->set_text(0, sectionarr[i].capitalize());
ms->set_metadata(0, metasection);
+ ms->set_selectable(0, false);
+ }
+
+ if (i == sc - 1) {
+ //if it has children, make selectable
+ section_map[metasection]->set_selectable(0, true);
}
}
}
@@ -4638,6 +4675,20 @@ void SectionedPropertyEditor::update_category_list() {
if (section_map.has(selected_category)) {
section_map[selected_category]->select(0);
}
+
+ editor->update_tree();
+}
+
+void SectionedPropertyEditor::register_search_box(LineEdit *p_box) {
+
+ search_box = p_box;
+ editor->register_text_enter(p_box);
+ search_box->connect("text_changed", this, "_search_changed");
+}
+
+void SectionedPropertyEditor::_search_changed(const String &p_what) {
+
+ update_category_list();
}
PropertyEditor *SectionedPropertyEditor::get_property_editor() {
@@ -4649,6 +4700,8 @@ SectionedPropertyEditor::SectionedPropertyEditor() {
obj = -1;
+ search_box = NULL;
+
VBoxContainer *left_vb = memnew(VBoxContainer);
left_vb->set_custom_minimum_size(Size2(160, 0) * EDSCALE);
add_child(left_vb);