Add default values to the editor help, docs, and generated RST
Also, make spacing of "=" in the editor help a bit more consistent. Closes #16086
This commit is contained in:
parent
2df8b5606b
commit
0c4c36d823
|
@ -545,6 +545,11 @@ bool ClassDB::can_instance(const StringName &p_class) {
|
|||
|
||||
ClassInfo *ti = classes.getptr(p_class);
|
||||
ERR_FAIL_COND_V(!ti, false);
|
||||
#ifdef TOOLS_ENABLED
|
||||
if (ti->api == API_EDITOR && !Engine::get_singleton()->is_editor_hint()) {
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
return (!ti->disabled && ti->creation_func != NULL);
|
||||
}
|
||||
|
||||
|
@ -980,6 +985,13 @@ void ClassDB::add_property(StringName p_class, const PropertyInfo &p_pinfo, cons
|
|||
type->property_setget[p_pinfo.name] = psg;
|
||||
}
|
||||
|
||||
void ClassDB::set_property_default_value(StringName p_class, const StringName &p_name, const Variant &p_default) {
|
||||
if (!default_values.has(p_class)) {
|
||||
default_values[p_class] = HashMap<StringName, Variant>();
|
||||
}
|
||||
default_values[p_class][p_name] = p_default;
|
||||
}
|
||||
|
||||
void ClassDB::get_property_list(StringName p_class, List<PropertyInfo> *p_list, bool p_no_inheritance, const Object *p_validator) {
|
||||
|
||||
OBJTYPE_RLOCK;
|
||||
|
@ -1383,29 +1395,49 @@ void ClassDB::get_extensions_for_type(const StringName &p_class, List<String> *p
|
|||
}
|
||||
|
||||
HashMap<StringName, HashMap<StringName, Variant> > ClassDB::default_values;
|
||||
Set<StringName> ClassDB::default_values_cached;
|
||||
|
||||
Variant ClassDB::class_get_default_property_value(const StringName &p_class, const StringName &p_property) {
|
||||
|
||||
if (!default_values_cached.has(p_class)) {
|
||||
|
||||
if (!default_values.has(p_class)) {
|
||||
|
||||
default_values[p_class] = HashMap<StringName, Variant>();
|
||||
}
|
||||
|
||||
if (ClassDB::can_instance(p_class)) {
|
||||
Object *c = NULL;
|
||||
bool cleanup_c = false;
|
||||
|
||||
if (Engine::get_singleton()->has_singleton(p_class)) {
|
||||
c = Engine::get_singleton()->get_singleton_object(p_class);
|
||||
cleanup_c = false;
|
||||
} else if (ClassDB::can_instance(p_class)) {
|
||||
c = ClassDB::instance(p_class);
|
||||
cleanup_c = true;
|
||||
}
|
||||
|
||||
if (c) {
|
||||
|
||||
Object *c = ClassDB::instance(p_class);
|
||||
List<PropertyInfo> plist;
|
||||
c->get_property_list(&plist);
|
||||
for (List<PropertyInfo>::Element *E = plist.front(); E; E = E->next()) {
|
||||
if (E->get().usage & (PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_EDITOR)) {
|
||||
|
||||
if (!default_values[p_class].has(E->get().name)) {
|
||||
Variant v = c->get(E->get().name);
|
||||
default_values[p_class][E->get().name] = v;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (cleanup_c) {
|
||||
memdelete(c);
|
||||
}
|
||||
}
|
||||
|
||||
default_values_cached.insert(p_class);
|
||||
}
|
||||
|
||||
if (!default_values.has(p_class)) {
|
||||
return Variant();
|
||||
}
|
||||
|
@ -1424,6 +1456,12 @@ void ClassDB::init() {
|
|||
lock = RWLock::create();
|
||||
}
|
||||
|
||||
void ClassDB::cleanup_defaults() {
|
||||
|
||||
default_values.clear();
|
||||
default_values_cached.clear();
|
||||
}
|
||||
|
||||
void ClassDB::cleanup() {
|
||||
|
||||
//OBJTYPE_LOCK; hah not here
|
||||
|
@ -1443,7 +1481,6 @@ void ClassDB::cleanup() {
|
|||
classes.clear();
|
||||
resource_base_extensions.clear();
|
||||
compat_classes.clear();
|
||||
default_values.clear();
|
||||
|
||||
memdelete(lock);
|
||||
}
|
||||
|
|
|
@ -162,6 +162,7 @@ public:
|
|||
static void _add_class2(const StringName &p_class, const StringName &p_inherits);
|
||||
|
||||
static HashMap<StringName, HashMap<StringName, Variant> > default_values;
|
||||
static Set<StringName> default_values_cached;
|
||||
|
||||
public:
|
||||
// DO NOT USE THIS!!!!!! NEEDS TO BE PUBLIC BUT DO NOT USE NO MATTER WHAT!!!
|
||||
|
@ -329,6 +330,7 @@ public:
|
|||
|
||||
static void add_property_group(StringName p_class, const String &p_name, const String &p_prefix = "");
|
||||
static void add_property(StringName p_class, const PropertyInfo &p_pinfo, const StringName &p_setter, const StringName &p_getter, int p_index = -1);
|
||||
static void set_property_default_value(StringName p_class, const StringName &p_name, const Variant &p_default);
|
||||
static void get_property_list(StringName p_class, List<PropertyInfo> *p_list, bool p_no_inheritance = false, const Object *p_validator = NULL);
|
||||
static bool set_property(Object *p_object, const StringName &p_property, const Variant &p_value, bool *r_valid = NULL);
|
||||
static bool get_property(Object *p_object, const StringName &p_property, Variant &r_value);
|
||||
|
@ -373,6 +375,7 @@ public:
|
|||
|
||||
static void set_current_api(APIType p_api);
|
||||
static APIType get_current_api();
|
||||
static void cleanup_defaults();
|
||||
static void cleanup();
|
||||
};
|
||||
|
||||
|
|
|
@ -874,6 +874,7 @@ void MultiplayerAPI::_bind_methods() {
|
|||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "allow_object_decoding"), "set_allow_object_decoding", "is_object_decoding_allowed");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "refuse_new_network_connections"), "set_refuse_new_network_connections", "is_refusing_new_network_connections");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "network_peer", PROPERTY_HINT_RESOURCE_TYPE, "NetworkedMultiplayerPeer", 0), "set_network_peer", "get_network_peer");
|
||||
ADD_PROPERTY_DEFAULT("refuse_new_network_connections", false);
|
||||
|
||||
ADD_SIGNAL(MethodInfo("network_peer_connected", PropertyInfo(Variant::INT, "id")));
|
||||
ADD_SIGNAL(MethodInfo("network_peer_disconnected", PropertyInfo(Variant::INT, "id")));
|
||||
|
|
|
@ -130,6 +130,7 @@ enum PropertyUsageFlags {
|
|||
#define ADD_SIGNAL(m_signal) ClassDB::add_signal(get_class_static(), m_signal)
|
||||
#define ADD_PROPERTY(m_property, m_setter, m_getter) ClassDB::add_property(get_class_static(), m_property, _scs_create(m_setter), _scs_create(m_getter))
|
||||
#define ADD_PROPERTYI(m_property, m_setter, m_getter, m_index) ClassDB::add_property(get_class_static(), m_property, _scs_create(m_setter), _scs_create(m_getter), m_index)
|
||||
#define ADD_PROPERTY_DEFAULT(m_property, m_default) ClassDB::set_property_default_value(get_class_static(), m_property, m_default)
|
||||
#define ADD_GROUP(m_name, m_prefix) ClassDB::add_property_group(get_class_static(), m_name, m_prefix)
|
||||
|
||||
struct PropertyInfo {
|
||||
|
|
|
@ -273,6 +273,7 @@ void unregister_core_types() {
|
|||
|
||||
ResourceLoader::finalize();
|
||||
|
||||
ClassDB::cleanup_defaults();
|
||||
ObjectDB::cleanup();
|
||||
|
||||
unregister_variant_methods();
|
||||
|
|
|
@ -37,12 +37,13 @@ class TypeName:
|
|||
|
||||
|
||||
class PropertyDef:
|
||||
def __init__(self, name, type_name, setter, getter, text): # type: (str, TypeName, Optional[str], Optional[str], Optional[str]) -> None
|
||||
def __init__(self, name, type_name, setter, getter, text, default_value): # type: (str, TypeName, Optional[str], Optional[str], Optional[str], Optional[str]) -> None
|
||||
self.name = name
|
||||
self.type_name = type_name
|
||||
self.setter = setter
|
||||
self.getter = getter
|
||||
self.text = text
|
||||
self.default_value = default_value
|
||||
|
||||
class ParameterDef:
|
||||
def __init__(self, name, type_name, default_value): # type: (str, TypeName, Optional[str]) -> None
|
||||
|
@ -81,9 +82,10 @@ class EnumDef:
|
|||
|
||||
|
||||
class ThemeItemDef:
|
||||
def __init__(self, name, type_name): # type: (str, TypeName) -> None
|
||||
def __init__(self, name, type_name, default_value): # type: (str, TypeName, Optional[str]) -> None
|
||||
self.name = name
|
||||
self.type_name = type_name
|
||||
self.default_value = default_value
|
||||
|
||||
|
||||
class ClassDef:
|
||||
|
@ -144,8 +146,9 @@ class State:
|
|||
type_name = TypeName.from_element(property)
|
||||
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
|
||||
|
||||
property_def = PropertyDef(property_name, type_name, setter, getter, property.text)
|
||||
property_def = PropertyDef(property_name, type_name, setter, getter, property.text, default_value)
|
||||
class_def.properties[property_name] = property_def
|
||||
|
||||
methods = class_root.find("methods")
|
||||
|
@ -230,7 +233,8 @@ class State:
|
|||
assert theme_item.tag == "theme_item"
|
||||
|
||||
theme_item_name = theme_item.attrib["name"]
|
||||
theme_item_def = ThemeItemDef(theme_item_name, TypeName.from_element(theme_item))
|
||||
default_value = theme_item.get("default") or None
|
||||
theme_item_def = ThemeItemDef(theme_item_name, TypeName.from_element(theme_item), default_value)
|
||||
if theme_item_name not in class_def.theme_items:
|
||||
class_def.theme_items[theme_item_name] = []
|
||||
class_def.theme_items[theme_item_name].append(theme_item_def)
|
||||
|
@ -400,8 +404,9 @@ def make_rst_class(class_def, state, dry_run, output_dir): # type: (ClassDef, S
|
|||
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)
|
||||
ml.append((type_rst, ref))
|
||||
format_table(f, ml)
|
||||
default = property_def.default_value
|
||||
ml.append((type_rst, ref, default))
|
||||
format_table(f, ml, True)
|
||||
|
||||
# Methods overview
|
||||
if len(class_def.methods) > 0:
|
||||
|
@ -415,11 +420,11 @@ def make_rst_class(class_def, state, dry_run, output_dir): # type: (ClassDef, S
|
|||
# Theme properties
|
||||
if class_def.theme_items is not None and len(class_def.theme_items) > 0:
|
||||
f.write(make_heading('Theme Properties', '-'))
|
||||
ml = []
|
||||
pl = []
|
||||
for theme_item_list in class_def.theme_items.values():
|
||||
for theme_item in theme_item_list:
|
||||
ml.append((theme_item.type_name.to_rst(state), theme_item.name))
|
||||
format_table(f, ml)
|
||||
pl.append((theme_item.type_name.to_rst(state), theme_item.name, theme_item.default_value))
|
||||
format_table(f, pl, True)
|
||||
|
||||
# Signals
|
||||
if len(class_def.signals) > 0:
|
||||
|
@ -488,14 +493,16 @@ def make_rst_class(class_def, state, dry_run, output_dir): # type: (ClassDef, S
|
|||
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))
|
||||
|
||||
setget = []
|
||||
info = []
|
||||
if property_def.default_value is not None:
|
||||
info.append(("*Default*", property_def.default_value))
|
||||
if property_def.setter is not None and not property_def.setter.startswith("_"):
|
||||
setget.append(("*Setter*", property_def.setter + '(value)'))
|
||||
info.append(("*Setter*", property_def.setter + '(value)'))
|
||||
if property_def.getter is not None and not property_def.getter.startswith("_"):
|
||||
setget.append(('*Getter*', property_def.getter + '()'))
|
||||
info.append(('*Getter*', property_def.getter + '()'))
|
||||
|
||||
if len(setget) > 0:
|
||||
format_table(f, setget)
|
||||
if len(info) > 0:
|
||||
format_table(f, info)
|
||||
|
||||
if property_def.text is not None and property_def.text.strip() != '':
|
||||
f.write(rstize_text(property_def.text.strip(), state))
|
||||
|
@ -873,33 +880,33 @@ def rstize_text(text, state): # type: (str, State) -> str
|
|||
return text
|
||||
|
||||
|
||||
def format_table(f, pp): # type: (TextIO, Iterable[Tuple[str, ...]]) -> None
|
||||
longest_t = 0
|
||||
longest_s = 0
|
||||
for s in pp:
|
||||
sl = len(s[0])
|
||||
if sl > longest_s:
|
||||
longest_s = sl
|
||||
tl = len(s[1])
|
||||
if tl > longest_t:
|
||||
longest_t = tl
|
||||
def format_table(f, data, remove_empty_columns=False): # type: (TextIO, Iterable[Tuple[str, ...]]) -> None
|
||||
if len(data) == 0:
|
||||
return
|
||||
|
||||
sep = "+"
|
||||
for i in range(longest_s + 2):
|
||||
sep += "-"
|
||||
sep += "+"
|
||||
for i in range(longest_t + 2):
|
||||
sep += "-"
|
||||
column_sizes = [0] * len(data[0])
|
||||
for row in data:
|
||||
for i, text in enumerate(row):
|
||||
text_length = len(text or '')
|
||||
if text_length > column_sizes[i]:
|
||||
column_sizes[i] = text_length
|
||||
|
||||
sep = ""
|
||||
for size in column_sizes:
|
||||
if size == 0 and remove_empty_columns:
|
||||
continue
|
||||
sep += "+" + "-" * (size + 2)
|
||||
sep += "+\n"
|
||||
f.write(sep)
|
||||
for s in pp:
|
||||
rt = s[0]
|
||||
while len(rt) < longest_s:
|
||||
rt += " "
|
||||
st = s[1]
|
||||
while len(st) < longest_t:
|
||||
st += " "
|
||||
f.write("| " + rt + " | " + st + " |\n")
|
||||
|
||||
for row in data:
|
||||
row_text = "|"
|
||||
for i, text in enumerate(row):
|
||||
if column_sizes[i] == 0 and remove_empty_columns:
|
||||
continue
|
||||
row_text += " " + (text or '').ljust(column_sizes[i]) + " |"
|
||||
row_text += "\n"
|
||||
f.write(row_text)
|
||||
f.write(sep)
|
||||
f.write('\n')
|
||||
|
||||
|
|
|
@ -248,6 +248,21 @@ void DocData::generate(bool p_basic_types) {
|
|||
prop.setter = setter;
|
||||
prop.getter = getter;
|
||||
|
||||
if (ClassDB::can_instance(name)) { // Cannot get default value of classes that can't be instanced
|
||||
Variant default_value = ClassDB::class_get_default_property_value(name, E->get().name);
|
||||
prop.default_value = default_value.get_construct_string();
|
||||
} else {
|
||||
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())) {
|
||||
Variant default_value = ClassDB::class_get_default_property_value(E2->get(), E->get().name);
|
||||
prop.default_value = default_value.get_construct_string();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool found_type = false;
|
||||
if (getter != StringName()) {
|
||||
MethodBind *mb = ClassDB::get_method(name, getter);
|
||||
|
@ -412,6 +427,7 @@ void DocData::generate(bool p_basic_types) {
|
|||
PropertyDoc pd;
|
||||
pd.name = E->get();
|
||||
pd.type = "int";
|
||||
pd.default_value = itos(Theme::get_default()->get_constant(E->get(), cname));
|
||||
c.theme_properties.push_back(pd);
|
||||
}
|
||||
|
||||
|
@ -422,6 +438,7 @@ void DocData::generate(bool p_basic_types) {
|
|||
PropertyDoc pd;
|
||||
pd.name = E->get();
|
||||
pd.type = "Color";
|
||||
pd.default_value = Variant(Theme::get_default()->get_color(E->get(), cname)).get_construct_string();
|
||||
c.theme_properties.push_back(pd);
|
||||
}
|
||||
|
||||
|
@ -530,6 +547,7 @@ void DocData::generate(bool p_basic_types) {
|
|||
PropertyDoc property;
|
||||
property.name = pi.name;
|
||||
property.type = Variant::get_type_name(pi.type);
|
||||
property.default_value = v.get(pi.name).get_construct_string();
|
||||
|
||||
c.properties.push_back(property);
|
||||
}
|
||||
|
@ -1063,12 +1081,15 @@ Error DocData::save_classes(const String &p_default_path, const Map<String, Stri
|
|||
|
||||
for (int i = 0; i < c.properties.size(); i++) {
|
||||
|
||||
String enum_text;
|
||||
String additional_attributes;
|
||||
if (c.properties[i].enumeration != String()) {
|
||||
enum_text = " enum=\"" + c.properties[i].enumeration + "\"";
|
||||
additional_attributes += " enum=\"" + c.properties[i].enumeration + "\"";
|
||||
}
|
||||
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 + "\"" + enum_text + ">");
|
||||
_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>");
|
||||
}
|
||||
|
@ -1125,8 +1146,14 @@ Error DocData::save_classes(const String &p_default_path, const Map<String, Stri
|
|||
for (int i = 0; i < c.theme_properties.size(); i++) {
|
||||
|
||||
const PropertyDoc &p = c.theme_properties[i];
|
||||
|
||||
if (p.default_value != "")
|
||||
_write_string(f, 2, "<theme_item name=\"" + p.name + "\" type=\"" + p.type + "\" default=\"" + p.default_value.xml_escape(true) + "\">");
|
||||
else
|
||||
_write_string(f, 2, "<theme_item name=\"" + p.name + "\" type=\"" + p.type + "\">");
|
||||
|
||||
_write_string(f, 3, p.description.strip_edges().xml_escape());
|
||||
|
||||
_write_string(f, 2, "</theme_item>");
|
||||
}
|
||||
_write_string(f, 1, "</theme_items>");
|
||||
|
|
|
@ -73,6 +73,7 @@ public:
|
|||
String enumeration;
|
||||
String description;
|
||||
String setter, getter;
|
||||
String default_value;
|
||||
bool operator<(const PropertyDoc &p_prop) const {
|
||||
return name < p_prop.name;
|
||||
}
|
||||
|
|
|
@ -48,9 +48,9 @@ void EditorHelp::_init_colors() {
|
|||
text_color = get_color("default_color", "RichTextLabel");
|
||||
headline_color = get_color("headline_color", "EditorHelp");
|
||||
base_type_color = title_color.linear_interpolate(text_color, 0.5);
|
||||
comment_color = text_color * Color(1, 1, 1, 0.6);
|
||||
comment_color = text_color * Color(1, 1, 1, 0.4);
|
||||
symbol_color = comment_color;
|
||||
value_color = text_color * Color(1, 1, 1, 0.4);
|
||||
value_color = text_color * Color(1, 1, 1, 0.6);
|
||||
qualifier_color = text_color * Color(1, 1, 1, 0.8);
|
||||
type_color = get_color("accent_color", "Editor").linear_interpolate(text_color, 0.5);
|
||||
class_desc->add_color_override("selection_color", get_color("accent_color", "Editor") * Color(1, 1, 1, 0.4));
|
||||
|
@ -260,7 +260,9 @@ void EditorHelp::_add_method(const DocData::MethodDoc &p_method, bool p_overview
|
|||
class_desc->push_color(symbol_color);
|
||||
class_desc->add_text(" = ");
|
||||
class_desc->pop();
|
||||
class_desc->push_color(value_color);
|
||||
_add_text(_fix_constant(p_method.arguments[j].default_value));
|
||||
class_desc->pop();
|
||||
}
|
||||
|
||||
class_desc->pop();
|
||||
|
@ -471,23 +473,37 @@ void EditorHelp::_update_doc() {
|
|||
if (cd.properties[i].description != "") {
|
||||
describe = true;
|
||||
}
|
||||
|
||||
class_desc->push_cell();
|
||||
class_desc->push_font(doc_code_font);
|
||||
class_desc->push_color(headline_color);
|
||||
|
||||
if (describe) {
|
||||
class_desc->push_meta("@member " + cd.properties[i].name);
|
||||
}
|
||||
|
||||
class_desc->push_font(doc_code_font);
|
||||
class_desc->push_color(headline_color);
|
||||
_add_text(cd.properties[i].name);
|
||||
|
||||
class_desc->pop();
|
||||
class_desc->pop();
|
||||
|
||||
if (describe) {
|
||||
class_desc->pop();
|
||||
property_descr = true;
|
||||
}
|
||||
|
||||
if (cd.properties[i].default_value != "") {
|
||||
class_desc->push_color(symbol_color);
|
||||
class_desc->add_text(" [default: ");
|
||||
class_desc->pop();
|
||||
class_desc->push_color(value_color);
|
||||
_add_text(_fix_constant(cd.properties[i].default_value));
|
||||
class_desc->pop();
|
||||
class_desc->push_color(symbol_color);
|
||||
class_desc->add_text("]");
|
||||
class_desc->pop();
|
||||
}
|
||||
|
||||
class_desc->pop();
|
||||
class_desc->pop();
|
||||
|
||||
class_desc->pop();
|
||||
}
|
||||
|
||||
|
@ -613,6 +629,19 @@ void EditorHelp::_update_doc() {
|
|||
class_desc->push_color(headline_color);
|
||||
_add_text(cd.theme_properties[i].name);
|
||||
class_desc->pop();
|
||||
|
||||
if (cd.theme_properties[i].default_value != "") {
|
||||
class_desc->push_color(symbol_color);
|
||||
class_desc->add_text(" [default: ");
|
||||
class_desc->pop();
|
||||
class_desc->push_color(value_color);
|
||||
_add_text(_fix_constant(cd.theme_properties[i].default_value));
|
||||
class_desc->pop();
|
||||
class_desc->push_color(symbol_color);
|
||||
class_desc->add_text("]");
|
||||
class_desc->pop();
|
||||
}
|
||||
|
||||
class_desc->pop();
|
||||
|
||||
if (cd.theme_properties[i].description != "") {
|
||||
|
@ -777,7 +806,7 @@ void EditorHelp::_update_doc() {
|
|||
class_desc->add_text(" = ");
|
||||
class_desc->pop();
|
||||
class_desc->push_color(value_color);
|
||||
_add_text(enum_list[i].value);
|
||||
_add_text(_fix_constant(enum_list[i].value));
|
||||
class_desc->pop();
|
||||
class_desc->pop();
|
||||
if (enum_list[i].description != "") {
|
||||
|
@ -843,7 +872,7 @@ void EditorHelp::_update_doc() {
|
|||
class_desc->add_text(" = ");
|
||||
class_desc->pop();
|
||||
class_desc->push_color(value_color);
|
||||
_add_text(constants[i].value);
|
||||
_add_text(_fix_constant(constants[i].value));
|
||||
class_desc->pop();
|
||||
|
||||
class_desc->pop();
|
||||
|
@ -963,6 +992,21 @@ void EditorHelp::_update_doc() {
|
|||
class_desc->push_color(headline_color);
|
||||
_add_text(cd.properties[i].name);
|
||||
class_desc->pop(); // color
|
||||
|
||||
if (cd.properties[i].default_value != "") {
|
||||
class_desc->push_color(symbol_color);
|
||||
class_desc->add_text(" [default: ");
|
||||
class_desc->pop(); // color
|
||||
|
||||
class_desc->push_color(value_color);
|
||||
_add_text(_fix_constant(cd.properties[i].default_value));
|
||||
class_desc->pop(); // color
|
||||
|
||||
class_desc->push_color(symbol_color);
|
||||
class_desc->add_text("]");
|
||||
class_desc->pop(); // color
|
||||
}
|
||||
|
||||
class_desc->pop(); // font
|
||||
class_desc->pop(); // cell
|
||||
|
||||
|
|
|
@ -1473,6 +1473,10 @@ void EditorSettings::get_shortcut_list(List<String> *r_shortcuts) {
|
|||
|
||||
Ref<ShortCut> ED_GET_SHORTCUT(const String &p_path) {
|
||||
|
||||
if (!EditorSettings::get_singleton()) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Ref<ShortCut> sc = EditorSettings::get_singleton()->get_shortcut(p_path);
|
||||
if (!sc.is_valid()) {
|
||||
ERR_EXPLAIN("Used ED_GET_SHORTCUT with invalid shortcut: " + p_path);
|
||||
|
@ -1508,6 +1512,15 @@ Ref<ShortCut> ED_SHORTCUT(const String &p_path, const String &p_name, uint32_t p
|
|||
ie->set_metakey(bool(p_keycode & KEY_MASK_META));
|
||||
}
|
||||
|
||||
if (!EditorSettings::get_singleton()) {
|
||||
Ref<ShortCut> sc;
|
||||
sc.instance();
|
||||
sc->set_name(p_name);
|
||||
sc->set_shortcut(ie);
|
||||
sc->set_meta("original", ie);
|
||||
return sc;
|
||||
}
|
||||
|
||||
Ref<ShortCut> sc = EditorSettings::get_singleton()->get_shortcut(p_path);
|
||||
if (sc.is_valid()) {
|
||||
|
||||
|
|
|
@ -1375,6 +1375,8 @@ bool Main::start() {
|
|||
#ifdef TOOLS_ENABLED
|
||||
if (doc_tool != "") {
|
||||
|
||||
Engine::get_singleton()->set_editor_hint(true); // Needed to instance editor-only classes for their default values
|
||||
|
||||
{
|
||||
DirAccessRef da = DirAccess::open(doc_tool);
|
||||
if (!da) {
|
||||
|
|
|
@ -882,8 +882,10 @@ NetworkedMultiplayerENet::NetworkedMultiplayerENet() {
|
|||
|
||||
NetworkedMultiplayerENet::~NetworkedMultiplayerENet() {
|
||||
|
||||
if (active) {
|
||||
close_connection();
|
||||
}
|
||||
}
|
||||
|
||||
// Sets IP for ENet to bind when using create_server or create_client
|
||||
// if no IP is set, then ENet bind to ENET_HOST_ANY
|
||||
|
|
|
@ -33,9 +33,13 @@
|
|||
#include "servers/arvr/arvr_positional_tracker.h"
|
||||
#include "servers/visual/visual_server_globals.h"
|
||||
|
||||
void ARVRInterfaceGDNative::_bind_methods() {
|
||||
ADD_PROPERTY_DEFAULT("interface_is_initialized", false);
|
||||
ADD_PROPERTY_DEFAULT("ar_is_anchor_detection_enabled", false);
|
||||
}
|
||||
|
||||
ARVRInterfaceGDNative::ARVRInterfaceGDNative() {
|
||||
// testing
|
||||
printf("Construct gdnative interface\n");
|
||||
print_verbose("Construct gdnative interface\n");
|
||||
|
||||
// we won't have our data pointer until our library gets set
|
||||
data = NULL;
|
||||
|
@ -44,9 +48,9 @@ ARVRInterfaceGDNative::ARVRInterfaceGDNative() {
|
|||
}
|
||||
|
||||
ARVRInterfaceGDNative::~ARVRInterfaceGDNative() {
|
||||
printf("Destruct gdnative interface\n");
|
||||
print_verbose("Destruct gdnative interface\n");
|
||||
|
||||
if (is_initialized()) {
|
||||
if (interface != NULL && is_initialized()) {
|
||||
uninitialize();
|
||||
};
|
||||
|
||||
|
@ -99,13 +103,10 @@ int ARVRInterfaceGDNative::get_capabilities() const {
|
|||
}
|
||||
|
||||
bool ARVRInterfaceGDNative::get_anchor_detection_is_enabled() const {
|
||||
bool enabled;
|
||||
|
||||
ERR_FAIL_COND_V(interface == NULL, false);
|
||||
|
||||
enabled = interface->get_anchor_detection_is_enabled(data);
|
||||
|
||||
return enabled;
|
||||
return interface->get_anchor_detection_is_enabled(data);
|
||||
}
|
||||
|
||||
void ARVRInterfaceGDNative::set_anchor_detection_is_enabled(bool p_enable) {
|
||||
|
@ -137,21 +138,16 @@ bool ARVRInterfaceGDNative::is_stereo() {
|
|||
}
|
||||
|
||||
bool ARVRInterfaceGDNative::is_initialized() const {
|
||||
bool initialized;
|
||||
|
||||
ERR_FAIL_COND_V(interface == NULL, false);
|
||||
|
||||
initialized = interface->is_initialized(data);
|
||||
|
||||
return initialized;
|
||||
return interface->is_initialized(data);
|
||||
}
|
||||
|
||||
bool ARVRInterfaceGDNative::initialize() {
|
||||
bool initialized;
|
||||
|
||||
ERR_FAIL_COND_V(interface == NULL, false);
|
||||
|
||||
initialized = interface->initialize(data);
|
||||
bool initialized = interface->initialize(data);
|
||||
|
||||
if (initialized) {
|
||||
// if we successfully initialize our interface and we don't have a primary interface yet, this becomes our primary interface
|
||||
|
|
|
@ -49,6 +49,8 @@ protected:
|
|||
const godot_arvr_interface_gdnative *interface;
|
||||
void *data;
|
||||
|
||||
static void _bind_methods();
|
||||
|
||||
public:
|
||||
/** general interface information **/
|
||||
ARVRInterfaceGDNative();
|
||||
|
|
|
@ -113,6 +113,8 @@ NetworkedMultiplayerPeer::ConnectionStatus MultiplayerPeerGDNative::get_connecti
|
|||
}
|
||||
|
||||
void MultiplayerPeerGDNative::_bind_methods() {
|
||||
ADD_PROPERTY_DEFAULT("transfer_mode", TRANSFER_MODE_UNRELIABLE);
|
||||
ADD_PROPERTY_DEFAULT("refuse_new_connections", true);
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#include "modules/gdnative/nativescript/nativescript.h"
|
||||
|
||||
void WebRTCDataChannelGDNative::_bind_methods() {
|
||||
ADD_PROPERTY_DEFAULT("write_mode", WRITE_MODE_BINARY);
|
||||
}
|
||||
|
||||
WebRTCDataChannelGDNative::WebRTCDataChannelGDNative() {
|
||||
|
|
|
@ -1541,7 +1541,7 @@ Vector2 KinematicCollision2D::get_remainder() const {
|
|||
return collision.remainder;
|
||||
}
|
||||
Object *KinematicCollision2D::get_local_shape() const {
|
||||
ERR_FAIL_COND_V(!owner, NULL);
|
||||
if (!owner) return NULL;
|
||||
uint32_t ownerid = owner->shape_find_owner(collision.local_shape);
|
||||
return owner->shape_owner_get_owner(ownerid);
|
||||
}
|
||||
|
|
|
@ -264,6 +264,7 @@ void ARVRController::_bind_methods() {
|
|||
ClassDB::bind_method(D_METHOD("get_rumble"), &ARVRController::get_rumble);
|
||||
ClassDB::bind_method(D_METHOD("set_rumble", "rumble"), &ARVRController::set_rumble);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "rumble", PROPERTY_HINT_RANGE, "0.0,1.0,0.01"), "set_rumble", "get_rumble");
|
||||
ADD_PROPERTY_DEFAULT("rumble", 0.0);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_mesh"), &ARVRController::get_mesh);
|
||||
|
||||
|
|
|
@ -1470,7 +1470,7 @@ Vector3 KinematicCollision::get_remainder() const {
|
|||
return collision.remainder;
|
||||
}
|
||||
Object *KinematicCollision::get_local_shape() const {
|
||||
ERR_FAIL_COND_V(!owner, NULL);
|
||||
if (!owner) return NULL;
|
||||
uint32_t ownerid = owner->shape_find_owner(collision.local_shape);
|
||||
return owner->shape_owner_get_owner(ownerid);
|
||||
}
|
||||
|
|
|
@ -614,6 +614,7 @@ void SceneTree::finish() {
|
|||
root->_set_tree(NULL);
|
||||
root->_propagate_after_exit_tree();
|
||||
memdelete(root); //delete root
|
||||
root = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1889,6 +1890,7 @@ void SceneTree::_bind_methods() {
|
|||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "debug_navigation_hint"), "set_debug_navigation_hint", "is_debugging_navigation_hint");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "paused"), "set_pause", "is_paused");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "refuse_new_network_connections"), "set_refuse_new_network_connections", "is_refusing_new_network_connections");
|
||||
ADD_PROPERTY_DEFAULT("refuse_new_network_connections", false);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "use_font_oversampling"), "set_use_font_oversampling", "is_using_font_oversampling");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "edited_scene_root", PROPERTY_HINT_RESOURCE_TYPE, "Node", 0), "set_edited_scene_root", "get_edited_scene_root");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "current_scene", PROPERTY_HINT_RESOURCE_TYPE, "Node", 0), "set_current_scene", "get_current_scene");
|
||||
|
@ -1962,7 +1964,7 @@ bool SceneTree::is_using_font_oversampling() const {
|
|||
|
||||
SceneTree::SceneTree() {
|
||||
|
||||
singleton = this;
|
||||
if (singleton == NULL) singleton = this;
|
||||
_quit = false;
|
||||
accept_quit = true;
|
||||
quit_on_go_back = true;
|
||||
|
@ -2107,4 +2109,11 @@ SceneTree::SceneTree() {
|
|||
}
|
||||
|
||||
SceneTree::~SceneTree() {
|
||||
if (root) {
|
||||
root->_set_tree(NULL);
|
||||
root->_propagate_after_exit_tree();
|
||||
memdelete(root);
|
||||
}
|
||||
|
||||
if (singleton == this) singleton = NULL;
|
||||
}
|
||||
|
|
|
@ -104,4 +104,6 @@ void ConcavePolygonShape2D::_bind_methods() {
|
|||
|
||||
ConcavePolygonShape2D::ConcavePolygonShape2D() :
|
||||
Shape2D(Physics2DServer::get_singleton()->concave_polygon_shape_create()) {
|
||||
PoolVector<Vector2> empty;
|
||||
set_segments(empty);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue