parent
037237f518
commit
6c4407bae4
|
@ -37,13 +37,14 @@ class TypeName:
|
|||
|
||||
|
||||
class PropertyDef:
|
||||
def __init__(self, name, type_name, setter, getter, text, default_value): # type: (str, TypeName, Optional[str], Optional[str], Optional[str], Optional[str]) -> None
|
||||
def __init__(self, name, type_name, setter, getter, text, default_value, overridden): # type: (str, TypeName, Optional[str], Optional[str], Optional[str], Optional[str], Optional[bool]) -> None
|
||||
self.name = name
|
||||
self.type_name = type_name
|
||||
self.setter = setter
|
||||
self.getter = getter
|
||||
self.text = text
|
||||
self.default_value = default_value
|
||||
self.overridden = overridden
|
||||
|
||||
class ParameterDef:
|
||||
def __init__(self, name, type_name, default_value): # type: (str, TypeName, Optional[str]) -> None
|
||||
|
@ -147,8 +148,9 @@ class State:
|
|||
setter = property.get("setter") or None # Use or None so '' gets turned into None.
|
||||
getter = property.get("getter") or None
|
||||
default_value = property.get("default") or None
|
||||
overridden = property.get("override") or False
|
||||
|
||||
property_def = PropertyDef(property_name, type_name, setter, getter, property.text, default_value)
|
||||
property_def = PropertyDef(property_name, type_name, setter, getter, property.text, default_value, overridden)
|
||||
class_def.properties[property_name] = property_def
|
||||
|
||||
methods = class_root.find("methods")
|
||||
|
@ -401,12 +403,15 @@ def make_rst_class(class_def, state, dry_run, output_dir): # type: (ClassDef, S
|
|||
# Properties overview
|
||||
if len(class_def.properties) > 0:
|
||||
f.write(make_heading('Properties', '-'))
|
||||
ml = [] # type: List[Tuple[str, str]]
|
||||
ml = [] # type: List[Tuple[str, str, str]]
|
||||
for property_def in class_def.properties.values():
|
||||
type_rst = property_def.type_name.to_rst(state)
|
||||
ref = ":ref:`{0}<class_{1}_property_{0}>`".format(property_def.name, class_name)
|
||||
default = property_def.default_value
|
||||
ml.append((type_rst, ref, default))
|
||||
if property_def.overridden:
|
||||
ml.append((type_rst, property_def.name, "**O:** " + default))
|
||||
else:
|
||||
ref = ":ref:`{0}<class_{1}_property_{0}>`".format(property_def.name, class_name)
|
||||
ml.append((type_rst, ref, default))
|
||||
format_table(f, ml, True)
|
||||
|
||||
# Methods overview
|
||||
|
@ -487,9 +492,12 @@ def make_rst_class(class_def, state, dry_run, output_dir): # type: (ClassDef, S
|
|||
f.write("- " + make_url(link) + "\n\n")
|
||||
|
||||
# Property descriptions
|
||||
if len(class_def.properties) > 0:
|
||||
if any(not p.overridden for p in class_def.properties.values()) > 0:
|
||||
f.write(make_heading('Property Descriptions', '-'))
|
||||
for property_def in class_def.properties.values():
|
||||
if property_def.overridden:
|
||||
continue
|
||||
|
||||
#f.write(".. _class_{}_{}:\n\n".format(class_name, property_def.name))
|
||||
f.write(".. _class_{}_property_{}:\n\n".format(class_name, property_def.name))
|
||||
f.write('- {} **{}**\n\n'.format(property_def.type_name.to_rst(state), property_def.name))
|
||||
|
|
|
@ -811,6 +811,4 @@ CreateDialog::CreateDialog() {
|
|||
|
||||
type_blacklist.insert("PluginScript"); // PluginScript must be initialized before use, which is not possible here
|
||||
type_blacklist.insert("ScriptCreateDialog"); // This is an exposed editor Node that doesn't have an Editor prefix.
|
||||
|
||||
EDITOR_DEF("interface/editors/derive_script_globals_by_name", true);
|
||||
}
|
||||
|
|
|
@ -205,6 +205,29 @@ static void argument_doc_from_arginfo(DocData::ArgumentDoc &p_argument, const Pr
|
|||
}
|
||||
}
|
||||
|
||||
static Variant get_documentation_default_value(const StringName &p_class_name, const StringName &p_property_name, bool &r_default_value_valid) {
|
||||
|
||||
Variant default_value = Variant();
|
||||
r_default_value_valid = false;
|
||||
|
||||
if (ClassDB::can_instance(p_class_name)) {
|
||||
default_value = ClassDB::class_get_default_property_value(p_class_name, p_property_name, &r_default_value_valid);
|
||||
} else {
|
||||
// Cannot get default value of classes that can't be instanced
|
||||
List<StringName> inheriting_classes;
|
||||
ClassDB::get_direct_inheriters_from_class(p_class_name, &inheriting_classes);
|
||||
for (List<StringName>::Element *E2 = inheriting_classes.front(); E2; E2 = E2->next()) {
|
||||
if (ClassDB::can_instance(E2->get())) {
|
||||
default_value = ClassDB::class_get_default_property_value(E2->get(), p_property_name, &r_default_value_valid);
|
||||
if (r_default_value_valid)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return default_value;
|
||||
}
|
||||
|
||||
void DocData::generate(bool p_basic_types) {
|
||||
|
||||
List<StringName> classes;
|
||||
|
@ -229,47 +252,53 @@ void DocData::generate(bool p_basic_types) {
|
|||
c.category = ClassDB::get_category(name);
|
||||
|
||||
List<PropertyInfo> properties;
|
||||
List<PropertyInfo> own_properties;
|
||||
if (name == "ProjectSettings") {
|
||||
//special case for project settings, so settings can be documented
|
||||
ProjectSettings::get_singleton()->get_property_list(&properties);
|
||||
own_properties = properties;
|
||||
} else {
|
||||
ClassDB::get_property_list(name, &properties, true);
|
||||
ClassDB::get_property_list(name, &properties);
|
||||
ClassDB::get_property_list(name, &own_properties, true);
|
||||
}
|
||||
|
||||
List<PropertyInfo>::Element *EO = own_properties.front();
|
||||
for (List<PropertyInfo>::Element *E = properties.front(); E; E = E->next()) {
|
||||
bool inherited = EO == NULL;
|
||||
if (EO && EO->get() == E->get()) {
|
||||
inherited = false;
|
||||
EO = EO->next();
|
||||
}
|
||||
|
||||
if (E->get().usage & PROPERTY_USAGE_GROUP || E->get().usage & PROPERTY_USAGE_CATEGORY || E->get().usage & PROPERTY_USAGE_INTERNAL)
|
||||
continue;
|
||||
|
||||
PropertyDoc prop;
|
||||
StringName setter = ClassDB::get_property_setter(name, E->get().name);
|
||||
StringName getter = ClassDB::get_property_getter(name, E->get().name);
|
||||
|
||||
prop.name = E->get().name;
|
||||
prop.setter = setter;
|
||||
prop.getter = getter;
|
||||
|
||||
Variant default_value = Variant();
|
||||
prop.overridden = inherited;
|
||||
|
||||
bool default_value_valid = false;
|
||||
Variant default_value = get_documentation_default_value(name, E->get().name, default_value_valid);
|
||||
|
||||
if (ClassDB::can_instance(name)) {
|
||||
default_value = ClassDB::class_get_default_property_value(name, E->get().name, &default_value_valid);
|
||||
} else {
|
||||
// Cannot get default value of classes that can't be instanced
|
||||
List<StringName> inheriting_classes;
|
||||
ClassDB::get_direct_inheriters_from_class(name, &inheriting_classes);
|
||||
for (List<StringName>::Element *E2 = inheriting_classes.front(); E2; E2 = E2->next()) {
|
||||
if (ClassDB::can_instance(E2->get())) {
|
||||
default_value = ClassDB::class_get_default_property_value(E2->get(), E->get().name, &default_value_valid);
|
||||
if (default_value_valid)
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (inherited) {
|
||||
bool base_default_value_valid = false;
|
||||
Variant base_default_value = get_documentation_default_value(ClassDB::get_parent_class(name), E->get().name, base_default_value_valid);
|
||||
if (!default_value_valid || !base_default_value_valid || default_value == base_default_value)
|
||||
continue;
|
||||
}
|
||||
|
||||
if (default_value_valid && default_value.get_type() != Variant::OBJECT) {
|
||||
prop.default_value = default_value.get_construct_string().replace("\n", "");
|
||||
}
|
||||
|
||||
StringName setter = ClassDB::get_property_setter(name, E->get().name);
|
||||
StringName getter = ClassDB::get_property_getter(name, E->get().name);
|
||||
|
||||
prop.setter = setter;
|
||||
prop.getter = getter;
|
||||
|
||||
bool found_type = false;
|
||||
if (getter != StringName()) {
|
||||
MethodBind *mb = ClassDB::get_method(name, getter);
|
||||
|
@ -1076,10 +1105,16 @@ Error DocData::save_classes(const String &p_default_path, const Map<String, Stri
|
|||
if (c.properties[i].default_value != String()) {
|
||||
additional_attributes += " default=\"" + c.properties[i].default_value.xml_escape(true) + "\"";
|
||||
}
|
||||
|
||||
const PropertyDoc &p = c.properties[i];
|
||||
_write_string(f, 2, "<member name=\"" + p.name + "\" type=\"" + p.type + "\" setter=\"" + p.setter + "\" getter=\"" + p.getter + "\"" + additional_attributes + ">");
|
||||
_write_string(f, 3, p.description.strip_edges().xml_escape());
|
||||
_write_string(f, 2, "</member>");
|
||||
|
||||
if (c.properties[i].overridden) {
|
||||
_write_string(f, 2, "<member name=\"" + p.name + "\" type=\"" + p.type + "\" setter=\"" + p.setter + "\" getter=\"" + p.getter + "\" override=\"true\"" + additional_attributes + "/>");
|
||||
} else {
|
||||
_write_string(f, 2, "<member name=\"" + p.name + "\" type=\"" + p.type + "\" setter=\"" + p.setter + "\" getter=\"" + p.getter + "\"" + additional_attributes + ">");
|
||||
_write_string(f, 3, p.description.strip_edges().xml_escape());
|
||||
_write_string(f, 2, "</member>");
|
||||
}
|
||||
}
|
||||
_write_string(f, 1, "</members>");
|
||||
}
|
||||
|
|
|
@ -74,6 +74,7 @@ public:
|
|||
String description;
|
||||
String setter, getter;
|
||||
String default_value;
|
||||
bool overridden;
|
||||
bool operator<(const PropertyDoc &p_prop) const {
|
||||
return name < p_prop.name;
|
||||
}
|
||||
|
|
|
@ -487,6 +487,10 @@ void EditorHelp::_update_doc() {
|
|||
describe = true;
|
||||
}
|
||||
|
||||
if (cd.properties[i].overridden) {
|
||||
describe = false;
|
||||
}
|
||||
|
||||
class_desc->push_cell();
|
||||
class_desc->push_font(doc_code_font);
|
||||
class_desc->push_color(headline_color);
|
||||
|
@ -504,7 +508,7 @@ void EditorHelp::_update_doc() {
|
|||
|
||||
if (cd.properties[i].default_value != "") {
|
||||
class_desc->push_color(symbol_color);
|
||||
class_desc->add_text(" [default: ");
|
||||
class_desc->add_text(cd.properties[i].overridden ? " [override: " : " [default: ");
|
||||
class_desc->pop();
|
||||
class_desc->push_color(value_color);
|
||||
_add_text(_fix_constant(cd.properties[i].default_value));
|
||||
|
@ -989,6 +993,9 @@ void EditorHelp::_update_doc() {
|
|||
|
||||
for (int i = 0; i < cd.properties.size(); i++) {
|
||||
|
||||
if (cd.properties[i].overridden)
|
||||
continue;
|
||||
|
||||
property_line[cd.properties[i].name] = class_desc->get_line_count() - 2;
|
||||
|
||||
class_desc->push_table(2);
|
||||
|
|
|
@ -4061,7 +4061,10 @@ void _update_all_gizmos(Node *p_node) {
|
|||
}
|
||||
|
||||
void SpatialEditor::update_all_gizmos(Node *p_node) {
|
||||
if (!p_node) p_node = SceneTree::get_singleton()->get_root();
|
||||
if (!p_node) {
|
||||
if (!SceneTree::get_singleton()) return;
|
||||
p_node = SceneTree::get_singleton()->get_root();
|
||||
}
|
||||
_update_all_gizmos(p_node);
|
||||
}
|
||||
|
||||
|
|
|
@ -2894,5 +2894,6 @@ SceneTreeDock::SceneTreeDock(EditorNode *p_editor, Node *p_scene_root, EditorSel
|
|||
profile_allow_script_editing = true;
|
||||
|
||||
EDITOR_DEF("interface/editors/show_scene_tree_root_selection", true);
|
||||
EDITOR_DEF("interface/editors/derive_script_globals_by_name", true);
|
||||
EDITOR_DEF("_use_favorites_root_selection", false);
|
||||
}
|
||||
|
|
|
@ -55,6 +55,15 @@ void ScriptCreateDialog::_notification(int p_what) {
|
|||
String last_lang = EditorSettings::get_singleton()->get_project_metadata("script_setup", "last_selected_language", "");
|
||||
Ref<Texture> last_lang_icon;
|
||||
if (!last_lang.empty()) {
|
||||
|
||||
for (int i = 0; i < language_menu->get_item_count(); i++) {
|
||||
if (language_menu->get_item_text(i) == last_lang) {
|
||||
language_menu->select(i);
|
||||
current_language = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
last_lang_icon = get_icon(last_lang, "EditorIcons");
|
||||
} else {
|
||||
last_lang_icon = language_menu->get_item_icon(default_language);
|
||||
|
@ -757,7 +766,6 @@ ScriptCreateDialog::ScriptCreateDialog() {
|
|||
|
||||
status_panel = memnew(PanelContainer);
|
||||
status_panel->set_h_size_flags(Control::SIZE_FILL);
|
||||
status_panel->add_style_override("panel", EditorNode::get_singleton()->get_gui_base()->get_stylebox("bg", "Tree"));
|
||||
status_panel->add_child(vb);
|
||||
|
||||
/* Spacing */
|
||||
|
@ -794,19 +802,8 @@ ScriptCreateDialog::ScriptCreateDialog() {
|
|||
}
|
||||
}
|
||||
|
||||
String last_selected_language = EditorSettings::get_singleton()->get_project_metadata("script_setup", "last_selected_language", "");
|
||||
if (last_selected_language != "") {
|
||||
for (int i = 0; i < language_menu->get_item_count(); i++) {
|
||||
if (language_menu->get_item_text(i) == last_selected_language) {
|
||||
language_menu->select(i);
|
||||
current_language = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
language_menu->select(default_language);
|
||||
current_language = default_language;
|
||||
}
|
||||
language_menu->select(default_language);
|
||||
current_language = default_language;
|
||||
|
||||
language_menu->connect("item_selected", this, "_lang_changed");
|
||||
|
||||
|
|
|
@ -1665,7 +1665,6 @@ void LineEdit::_bind_methods() {
|
|||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "secret"), "set_secret", "is_secret");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::STRING, "secret_character"), "set_secret_character", "get_secret_character");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "expand_to_text_length"), "set_expand_to_text_length", "get_expand_to_text_length");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "focus_mode", PROPERTY_HINT_ENUM, "None,Click,All"), "set_focus_mode", "get_focus_mode");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "context_menu_enabled"), "set_context_menu_enabled", "is_context_menu_enabled");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "clear_button_enabled"), "set_clear_button_enabled", "is_clear_button_enabled");
|
||||
ADD_GROUP("Placeholder", "placeholder_");
|
||||
|
|
|
@ -287,7 +287,6 @@ void Slider::_bind_methods() {
|
|||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "scrollable"), "set_scrollable", "is_scrollable");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "tick_count", PROPERTY_HINT_RANGE, "0,4096,1"), "set_ticks", "get_ticks");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "ticks_on_borders"), "set_ticks_on_borders", "get_ticks_on_borders");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "focus_mode", PROPERTY_HINT_ENUM, "None,Click,All"), "set_focus_mode", "get_focus_mode");
|
||||
}
|
||||
|
||||
Slider::Slider(Orientation p_orientation) {
|
||||
|
|
|
@ -466,11 +466,11 @@ Dictionary PolygonPathFinder::_get_data() const {
|
|||
PoolVector<Vector2> p;
|
||||
PoolVector<int> ind;
|
||||
Array connections;
|
||||
p.resize(points.size() - 2);
|
||||
connections.resize(points.size() - 2);
|
||||
p.resize(MAX(0, points.size() - 2));
|
||||
connections.resize(MAX(0, points.size() - 2));
|
||||
ind.resize(edges.size() * 2);
|
||||
PoolVector<float> penalties;
|
||||
penalties.resize(points.size() - 2);
|
||||
penalties.resize(MAX(0, points.size() - 2));
|
||||
{
|
||||
PoolVector<Vector2>::Write wp = p.write();
|
||||
PoolVector<float>::Write pw = penalties.write();
|
||||
|
|
Loading…
Reference in New Issue