forked from sascha/godot
-Project/Editor settings now use new inspector
-Project/Editor settings now show tooltips properly -Settings thar require restart now will show a restart warning -Video driver is now visible all the time, can be changed easily -Added function to request current video driver3.1
parent
76bfe14e00
commit
c69de2ba46
@ -0,0 +1,306 @@
|
||||
#include "editor_sectioned_inspector.h"
|
||||
#include "editor_scale.h"
|
||||
class SectionedInspectorFilter : public Object {
|
||||
|
||||
GDCLASS(SectionedInspectorFilter, Object);
|
||||
|
||||
Object *edited;
|
||||
String section;
|
||||
bool allow_sub;
|
||||
|
||||
bool _set(const StringName &p_name, const Variant &p_value) {
|
||||
|
||||
if (!edited)
|
||||
return false;
|
||||
|
||||
String name = p_name;
|
||||
if (section != "") {
|
||||
name = section + "/" + name;
|
||||
}
|
||||
|
||||
bool valid;
|
||||
edited->set(name, p_value, &valid);
|
||||
return valid;
|
||||
}
|
||||
|
||||
bool _get(const StringName &p_name, Variant &r_ret) const {
|
||||
|
||||
if (!edited)
|
||||
return false;
|
||||
|
||||
String name = p_name;
|
||||
if (section != "") {
|
||||
name = section + "/" + name;
|
||||
}
|
||||
|
||||
bool valid = false;
|
||||
|
||||
r_ret = edited->get(name, &valid);
|
||||
return valid;
|
||||
}
|
||||
void _get_property_list(List<PropertyInfo> *p_list) const {
|
||||
|
||||
if (!edited)
|
||||
return;
|
||||
|
||||
List<PropertyInfo> pinfo;
|
||||
edited->get_property_list(&pinfo);
|
||||
for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) {
|
||||
|
||||
PropertyInfo pi = E->get();
|
||||
int sp = pi.name.find("/");
|
||||
|
||||
if (pi.name == "resource_path" || pi.name == "resource_name" || pi.name == "resource_local_to_scene" || pi.name.begins_with("script/")) //skip resource stuff
|
||||
continue;
|
||||
|
||||
if (sp == -1) {
|
||||
pi.name = "global/" + pi.name;
|
||||
}
|
||||
|
||||
if (pi.name.begins_with(section + "/")) {
|
||||
pi.name = pi.name.replace_first(section + "/", "");
|
||||
if (!allow_sub && pi.name.find("/") != -1)
|
||||
continue;
|
||||
p_list->push_back(pi);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool property_can_revert(const String &p_name) {
|
||||
|
||||
return edited->call("property_can_revert", section + "/" + p_name);
|
||||
}
|
||||
|
||||
Variant property_get_revert(const String &p_name) {
|
||||
|
||||
return edited->call("property_get_revert", section + "/" + p_name);
|
||||
}
|
||||
|
||||
protected:
|
||||
static void _bind_methods() {
|
||||
|
||||
ClassDB::bind_method("property_can_revert", &SectionedInspectorFilter::property_can_revert);
|
||||
ClassDB::bind_method("property_get_revert", &SectionedInspectorFilter::property_get_revert);
|
||||
}
|
||||
|
||||
public:
|
||||
void set_section(const String &p_section, bool p_allow_sub) {
|
||||
|
||||
section = p_section;
|
||||
allow_sub = p_allow_sub;
|
||||
_change_notify();
|
||||
}
|
||||
|
||||
void set_edited(Object *p_edited) {
|
||||
edited = p_edited;
|
||||
_change_notify();
|
||||
}
|
||||
|
||||
SectionedInspectorFilter() {
|
||||
edited = NULL;
|
||||
}
|
||||
};
|
||||
|
||||
void SectionedInspector::_bind_methods() {
|
||||
|
||||
ClassDB::bind_method("_section_selected", &SectionedInspector::_section_selected);
|
||||
ClassDB::bind_method("_search_changed", &SectionedInspector::_search_changed);
|
||||
|
||||
ClassDB::bind_method("update_category_list", &SectionedInspector::update_category_list);
|
||||
}
|
||||
|
||||
void SectionedInspector::_section_selected() {
|
||||
|
||||
if (!sections->get_selected())
|
||||
return;
|
||||
|
||||
filter->set_section(sections->get_selected()->get_metadata(0), sections->get_selected()->get_children() == NULL);
|
||||
inspector->set_property_prefix(String(sections->get_selected()->get_metadata(0)) + "/");
|
||||
}
|
||||
|
||||
void SectionedInspector::set_current_section(const String &p_section) {
|
||||
|
||||
if (section_map.has(p_section)) {
|
||||
section_map[p_section]->select(0);
|
||||
}
|
||||
}
|
||||
|
||||
String SectionedInspector::get_current_section() const {
|
||||
|
||||
if (sections->get_selected())
|
||||
return sections->get_selected()->get_metadata(0);
|
||||
else
|
||||
return "";
|
||||
}
|
||||
|
||||
String SectionedInspector::get_full_item_path(const String &p_item) {
|
||||
|
||||
String base = get_current_section();
|
||||
|
||||
if (base != "")
|
||||
return base + "/" + p_item;
|
||||
else
|
||||
return p_item;
|
||||
}
|
||||
|
||||
void SectionedInspector::edit(Object *p_object) {
|
||||
|
||||
if (!p_object) {
|
||||
obj = -1;
|
||||
sections->clear();
|
||||
|
||||
filter->set_edited(NULL);
|
||||
inspector->edit(NULL);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
ObjectID id = p_object->get_instance_id();
|
||||
|
||||
inspector->set_object_class(p_object->get_class());
|
||||
|
||||
if (obj != id) {
|
||||
|
||||
obj = id;
|
||||
update_category_list();
|
||||
|
||||
filter->set_edited(p_object);
|
||||
inspector->edit(filter);
|
||||
|
||||
if (sections->get_root()->get_children()) {
|
||||
sections->get_root()->get_children()->select(0);
|
||||
}
|
||||
} else {
|
||||
|
||||
update_category_list();
|
||||
}
|
||||
}
|
||||
|
||||
void SectionedInspector::update_category_list() {
|
||||
|
||||
String selected_category = get_current_section();
|
||||
sections->clear();
|
||||
|
||||
Object *o = ObjectDB::get_instance(obj);
|
||||
|
||||
if (!o)
|
||||
return;
|
||||
|
||||
List<PropertyInfo> pinfo;
|
||||
o->get_property_list(&pinfo);
|
||||
|
||||
section_map.clear();
|
||||
|
||||
TreeItem *root = sections->create_item();
|
||||
section_map[""] = root;
|
||||
|
||||
for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) {
|
||||
|
||||
PropertyInfo pi = E->get();
|
||||
|
||||
if (pi.usage & PROPERTY_USAGE_CATEGORY)
|
||||
continue;
|
||||
else if (!(pi.usage & PROPERTY_USAGE_EDITOR))
|
||||
continue;
|
||||
|
||||
if (pi.name.find(":") != -1 || pi.name == "script" || pi.name == "resource_name" || pi.name == "resource_path" || pi.name == "resource_local_to_scene")
|
||||
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;
|
||||
|
||||
Vector<String> sectionarr = pi.name.split("/");
|
||||
String metasection;
|
||||
|
||||
int sc = MIN(2, sectionarr.size() - 1);
|
||||
|
||||
for (int i = 0; i < sc; i++) {
|
||||
|
||||
TreeItem *parent = section_map[metasection];
|
||||
parent->set_custom_bg_color(0, get_color("prop_subsection", "Editor"));
|
||||
|
||||
if (i > 0) {
|
||||
metasection += "/" + sectionarr[i];
|
||||
} else {
|
||||
metasection = sectionarr[i];
|
||||
}
|
||||
|
||||
if (!section_map.has(metasection)) {
|
||||
TreeItem *ms = sections->create_item(parent);
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (section_map.has(selected_category)) {
|
||||
section_map[selected_category]->select(0);
|
||||
}
|
||||
|
||||
inspector->update_tree();
|
||||
}
|
||||
|
||||
void SectionedInspector::register_search_box(LineEdit *p_box) {
|
||||
|
||||
search_box = p_box;
|
||||
inspector->register_text_enter(p_box);
|
||||
search_box->connect("text_changed", this, "_search_changed");
|
||||
}
|
||||
|
||||
void SectionedInspector::_search_changed(const String &p_what) {
|
||||
|
||||
update_category_list();
|
||||
}
|
||||
|
||||
EditorInspector *SectionedInspector::get_inspector() {
|
||||
|
||||
return inspector;
|
||||
}
|
||||
|
||||
SectionedInspector::SectionedInspector() {
|
||||
|
||||
obj = -1;
|
||||
|
||||
search_box = NULL;
|
||||
|
||||
add_constant_override("autohide", 1); // Fixes the dragger always showing up
|
||||
|
||||
VBoxContainer *left_vb = memnew(VBoxContainer);
|
||||
left_vb->set_custom_minimum_size(Size2(170, 0) * EDSCALE);
|
||||
add_child(left_vb);
|
||||
|
||||
sections = memnew(Tree);
|
||||
sections->set_v_size_flags(SIZE_EXPAND_FILL);
|
||||
sections->set_hide_root(true);
|
||||
|
||||
left_vb->add_child(sections, true);
|
||||
|
||||
VBoxContainer *right_vb = memnew(VBoxContainer);
|
||||
right_vb->set_custom_minimum_size(Size2(300, 0) * EDSCALE);
|
||||
right_vb->set_h_size_flags(SIZE_EXPAND_FILL);
|
||||
add_child(right_vb);
|
||||
|
||||
filter = memnew(SectionedInspectorFilter);
|
||||
inspector = memnew(EditorInspector);
|
||||
inspector->set_v_size_flags(SIZE_EXPAND_FILL);
|
||||
right_vb->add_child(inspector, true);
|
||||
inspector->set_use_doc_hints(true);
|
||||
|
||||
sections->connect("cell_selected", this, "_section_selected");
|
||||
}
|
||||
|
||||
SectionedInspector::~SectionedInspector() {
|
||||
|
||||
memdelete(filter);
|
||||
}
|
||||
@ -0,0 +1,42 @@
|
||||
#ifndef EDITOR_SECTIONED_INSPECTOR_H
|
||||
#define EDITOR_SECTIONED_INSPECTOR_H
|
||||
|
||||
#include "editor/editor_inspector.h"
|
||||
#include "scene/gui/split_container.h"
|
||||
#include "scene/gui/tree.h"
|
||||
|
||||
class SectionedInspectorFilter;
|
||||
|
||||
class SectionedInspector : public HSplitContainer {
|
||||
|
||||
GDCLASS(SectionedInspector, HSplitContainer);
|
||||
|
||||
ObjectID obj;
|
||||
|
||||
Tree *sections;
|
||||
SectionedInspectorFilter *filter;
|
||||
|
||||
Map<String, TreeItem *> section_map;
|
||||
EditorInspector *inspector;
|
||||
LineEdit *search_box;
|
||||
|
||||
static void _bind_methods();
|
||||
void _section_selected();
|
||||
|
||||
void _search_changed(const String &p_what);
|
||||
|
||||
public:
|
||||
void register_search_box(LineEdit *p_box);
|
||||
EditorInspector *get_inspector();
|
||||
void edit(Object *p_object);
|
||||
String get_full_item_path(const String &p_item);
|
||||
|
||||
void set_current_section(const String &p_section);
|
||||
String get_current_section() const;
|
||||
|
||||
void update_category_list();
|
||||
|
||||
SectionedInspector();
|
||||
~SectionedInspector();
|
||||
};
|
||||
#endif // EDITOR_SECTIONED_INSPECTOR_H
|
||||
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 7.8 KiB |
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 8.9 KiB |
@ -0,0 +1,127 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
version="1.1"
|
||||
id="svg2"
|
||||
width="48"
|
||||
height="16"
|
||||
viewBox="0 0 47.999999 16"
|
||||
sodipodi:docname="icon_vulkan.svg"
|
||||
inkscape:version="0.92.3 (2405546, 2018-03-11)">
|
||||
<metadata
|
||||
id="metadata8">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
<dc:title />
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<defs
|
||||
id="defs6" />
|
||||
<sodipodi:namedview
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1"
|
||||
objecttolerance="10"
|
||||
gridtolerance="10"
|
||||
guidetolerance="10"
|
||||
inkscape:pageopacity="0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:window-width="1853"
|
||||
inkscape:window-height="1016"
|
||||
id="namedview4"
|
||||
showgrid="false"
|
||||
inkscape:zoom="10.24"
|
||||
inkscape:cx="9.4970674"
|
||||
inkscape:cy="11.192118"
|
||||
inkscape:window-x="67"
|
||||
inkscape:window-y="27"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:current-layer="g8" />
|
||||
<path
|
||||
style="fill:#000000;stroke-width:1.06666672"
|
||||
d=""
|
||||
id="path819"
|
||||
inkscape:connector-curvature="0" />
|
||||
<path
|
||||
style="fill:#000000;stroke-width:1.06666672"
|
||||
d=""
|
||||
id="path817"
|
||||
inkscape:connector-curvature="0" />
|
||||
<g
|
||||
transform="matrix(0.04333868,0,0,0.04333868,-4.0493236,-3.7704963)"
|
||||
id="g8">
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
d="m 724.1,432.41989 h -40.6 c 0,0 0,-99 0,-129.7 13,7.2 30.1,20.5 40.6,33.3 z"
|
||||
id="path10"
|
||||
style="fill:#e6555a;fill-opacity:1" />
|
||||
<g
|
||||
id="g12"
|
||||
style="fill:#e6555a;fill-opacity:1"
|
||||
transform="translate(0,47.319882)">
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
d="m 381.8,385.1 h -50.6 l -66,-204 h 46 l 45.4,143.5 h 0.6 l 46,-143.5 h 46.3 z"
|
||||
id="path14"
|
||||
style="fill:#e6555a;fill-opacity:1" />
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
d="M 585.5,385.1 H 546.9 V 364.5 H 546 c -5.1,8.6 -11.8,14.8 -20,18.6 -8.2,3.8 -16.6,5.7 -25.1,5.7 -10.9,0 -19.8,-1.4 -26.7,-4.3 -7,-2.9 -12.4,-6.9 -16.4,-12.1 -4,-5.2 -6.8,-11.6 -8.4,-19.1 -1.6,-7.5 -2.4,-15.9 -2.4,-25 v -90.9 h 40.6 v 83.4 c 0,12.2 1.9,21.3 5.7,27.3 3.8,6 10.6,9 20.3,9 11,0 19.1,-3.3 24,-9.9 5,-6.6 7.4,-17.4 7.4,-32.4 v -77.4 h 40.6 v 147.7 z"
|
||||
id="path16"
|
||||
style="fill:#e6555a;fill-opacity:1" />
|
||||
</g>
|
||||
<polygon
|
||||
points="730.8,296.2 730.7,290.5 781.9,237.3 829.9,237.3 774.2,291.6 836.2,385.1 787,385.1 "
|
||||
id="polygon18"
|
||||
style="fill:#e6555a;fill-opacity:1"
|
||||
transform="translate(0,47.319882)" />
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
d="m 843.6,330.11989 c 0.6,-9.5 3,-17.4 7.2,-23.7 4.2,-6.3 9.5,-11.3 16,-15.1 6.5,-3.8 13.8,-6.5 21.9,-8.1 8.1,-1.6 16.2,-2.4 24.4,-2.4 7.4,0 15,0.5 22.6,1.6 7.6,1.1 14.6,3.1 20.9,6.1 6.3,3.1 11.4,7.3 15.4,12.7 4,5.4 6,12.6 6,21.6 v 76.9 c 0,6.7 0.4,13.1 1.1,19.1 0.8,6.1 2.1,10.7 4,13.7 h -41.2 c -0.8,-2.3 -1.4,-4.6 -1.9,-7 -0.5,-2.4 -0.8,-4.8 -1,-7.3 -6.5,6.7 -14.1,11.3 -22.9,14 -8.8,2.7 -17.7,4 -26.9,4 -7,0 -13.6,-0.9 -19.7,-2.6 -6.1,-1.7 -11.4,-4.4 -16,-8 -4.6,-3.6 -8.2,-8.2 -10.7,-13.7 -2.6,-5.5 -3.9,-12.1 -3.9,-19.7 0,-8.4 1.5,-15.3 4.4,-20.7 3,-5.4 6.8,-9.8 11.4,-13 4.7,-3.2 10,-5.7 16,-7.3 6,-1.6 12,-2.9 18.1,-3.9 6.1,-0.9 12.1,-1.7 18,-2.3 5.9,-0.6 11.1,-1.4 15.7,-2.6 4.6,-1.1 8.2,-2.8 10.9,-5 2.7,-2.2 3.9,-5.4 3.7,-9.6 0,-4.4 -0.7,-7.9 -2.2,-10.4 -1.4,-2.6 -3.3,-4.6 -5.7,-6 -2.4,-1.4 -5.1,-2.4 -8.3,-2.9 -3.1,-0.5 -6.5,-0.7 -10.1,-0.7 -8,0 -14.3,1.7 -18.9,5.1 -4.6,3.4 -7.2,9.1 -8,17.1 h -40.3 z m 93.8,30 c -1.7,1.5 -3.9,2.7 -6.4,3.6 -2.6,0.9 -5.3,1.6 -8.3,2.2 -2.9,0.6 -6,1 -9.3,1.4 -3.2,0.4 -6.5,0.9 -9.7,1.4 -3,0.6 -6,1.3 -9,2.3 -3,1 -5.5,2.2 -7.7,3.9 -2.2,1.6 -4,3.7 -5.3,6.1 -1.3,2.5 -2,5.6 -2,9.4 0,3.6 0.7,6.7 2,9.1 1.3,2.5 3.1,4.4 5.4,5.9 2.3,1.4 5,2.4 8,3 3.1,0.6 6.2,0.9 9.4,0.9 8,0 14.2,-1.3 18.6,-4 4.4,-2.7 7.6,-5.9 9.7,-9.6 2.1,-3.7 3.4,-7.5 3.9,-11.3 0.5,-3.8 0.7,-6.9 0.7,-9.1 z"
|
||||
id="path20"
|
||||
style="fill:#e6555a;fill-opacity:1" />
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
d="m 1004.2,284.61989 h 38.6 v 20.6 h 0.9 c 5.1,-8.6 11.8,-14.8 20,-18.7 8.2,-3.9 16.6,-5.9 25.1,-5.9 10.9,0 19.8,1.5 26.7,4.4 7,3 12.4,7.1 16.4,12.3 4,5.2 6.8,11.6 8.4,19.1 1.6,7.5 2.4,15.9 2.4,25 v 90.9 h -40.6 v -83.4 c 0,-12.2 -1.9,-21.3 -5.7,-27.3 -3.8,-6 -10.6,-9 -20.3,-9 -11,0 -19,3.3 -24,9.9 -5,6.6 -7.4,17.4 -7.4,32.4 v 77.4 h -40.6 v -147.7 z"
|
||||
id="path22"
|
||||
style="fill:#e6555a;fill-opacity:1" />
|
||||
<g
|
||||
id="g24"
|
||||
style="fill:#e6555a;fill-opacity:1"
|
||||
transform="translate(0,47.319882)">
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
d="M 612.4,211.8 V 385 H 653 V 234.2 c -13.1,-8 -26.6,-15.5 -40.6,-22.4 z"
|
||||
id="path26"
|
||||
style="fill:#e6555a;fill-opacity:1" />
|
||||
</g>
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
d="m 198.4,266.51989 c 23.5,-68.9 164.2,-94.2 314.1,-56.4 90,22.6 163.5,66.5 211.5,109.9 -21.7,-57.6 -127.3,-139.6 -272.8,-167.7 -164.5,-31.8 -326.7,-3.9 -346.8,69.1 -14.5,52.7 49.2,114.5 147.7,156.7 -44.3,-35.8 -65.8,-76 -53.7,-111.6 z"
|
||||
id="path28"
|
||||
style="fill:#e6555a;fill-opacity:1" />
|
||||
<g
|
||||
id="g30"
|
||||
style="fill:#e6555a;fill-opacity:1"
|
||||
transform="translate(0,47.319882)">
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
d="M 724.2,247.6 V 181 h -40.6 v 20.2 c 17.3,15.5 31,31.2 40.6,46.4 z"
|
||||
id="path32"
|
||||
style="fill:#e6555a;fill-opacity:1" />
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 5.9 KiB |
Loading…
Reference in New Issue