diff options
24 files changed, 273 insertions, 81 deletions
diff --git a/core/io/resource.h b/core/io/resource.h index 9ccc247887..109c0f6611 100644 --- a/core/io/resource.h +++ b/core/io/resource.h @@ -103,6 +103,7 @@ public: virtual void set_path(const String &p_path, bool p_take_over = false); String get_path() const; + _FORCE_INLINE_ bool is_built_in() const { return path_cache.is_empty() || path_cache.find("::") != -1 || path_cache.begins_with("local://"); } static String generate_scene_unique_id(); void set_scene_unique_id(const String &p_id); diff --git a/core/io/resource_format_binary.cpp b/core/io/resource_format_binary.cpp index cbb033f6c6..a5a195f859 100644 --- a/core/io/resource_format_binary.cpp +++ b/core/io/resource_format_binary.cpp @@ -1572,7 +1572,7 @@ void ResourceFormatSaverBinaryInstance::write_variant(FileAccess *f, const Varia return; // don't save it } - if (res->get_path().length() && res->get_path().find("::") == -1) { + if (!res->is_built_in()) { f->store_32(OBJECT_EXTERNAL_RESOURCE_INDEX); f->store_32(external_resources[res]); } else { @@ -1743,7 +1743,7 @@ void ResourceFormatSaverBinaryInstance::_find_resources(const Variant &p_variant return; } - if (!p_main && (!bundle_resources) && res->get_path().length() && res->get_path().find("::") == -1) { + if (!p_main && (!bundle_resources) && !res->is_built_in()) { if (res->get_path() == path) { ERR_PRINT("Circular reference to resource being saved found: '" + local_path + "' will be null next time it's loaded."); return; @@ -1978,7 +1978,7 @@ Error ResourceFormatSaverBinaryInstance::save(const String &p_path, const RES &p Set<String> used_unique_ids; for (RES &r : saved_resources) { - if (r->get_path() == "" || r->get_path().find("::") != -1) { + if (r->is_built_in()) { if (r->get_scene_unique_id() != "") { if (used_unique_ids.has(r->get_scene_unique_id())) { r->set_scene_unique_id(""); @@ -1992,7 +1992,7 @@ Error ResourceFormatSaverBinaryInstance::save(const String &p_path, const RES &p Map<RES, int> resource_map; int res_index = 0; for (RES &r : saved_resources) { - if (r->get_path() == "" || r->get_path().find("::") != -1) { + if (r->is_built_in()) { if (r->get_scene_unique_id() == "") { String new_id; diff --git a/core/object/object.cpp b/core/object/object.cpp index 476fdec1f7..498f116997 100644 --- a/core/object/object.cpp +++ b/core/object/object.cpp @@ -1475,7 +1475,7 @@ void Object::_clear_internal_resource_paths(const Variant &p_var) { return; } - if (!r->get_path().begins_with("res://") || r->get_path().find("::") == -1) { + if (!r->is_built_in()) { return; //not an internal resource } diff --git a/doc/classes/InputEventScreenDrag.xml b/doc/classes/InputEventScreenDrag.xml index 373936225b..f86b5f3b4d 100644 --- a/doc/classes/InputEventScreenDrag.xml +++ b/doc/classes/InputEventScreenDrag.xml @@ -17,7 +17,7 @@ The drag position. </member> <member name="relative" type="Vector2" setter="set_relative" getter="get_relative" default="Vector2(0, 0)"> - The drag position relative to its start position. + The drag position relative to the previous position (position at the last frame). </member> <member name="speed" type="Vector2" setter="set_speed" getter="get_speed" default="Vector2(0, 0)"> The drag speed. diff --git a/doc/classes/TileMapPattern.xml b/doc/classes/TileMapPattern.xml index 4c46625423..ab7c95bb7b 100644 --- a/doc/classes/TileMapPattern.xml +++ b/doc/classes/TileMapPattern.xml @@ -59,7 +59,7 @@ <method name="remove_cell"> <return type="void" /> <argument index="0" name="coords" type="Vector2i" /> - <argument index="1" name="arg1" type="bool" /> + <argument index="1" name="update_size" type="bool" /> <description> Remove the cell at the given coordinates. </description> diff --git a/doc/tools/make_rst.py b/doc/tools/make_rst.py index ad9e5f4897..fe8083f218 100755 --- a/doc/tools/make_rst.py +++ b/doc/tools/make_rst.py @@ -108,7 +108,9 @@ class ClassDef: self.constants = OrderedDict() # type: OrderedDict[str, ConstantDef] self.enums = OrderedDict() # type: OrderedDict[str, EnumDef] self.properties = OrderedDict() # type: OrderedDict[str, PropertyDef] + self.constructors = OrderedDict() # type: OrderedDict[str, List[MethodDef]] self.methods = OrderedDict() # type: OrderedDict[str, List[MethodDef]] + self.operators = OrderedDict() # type: OrderedDict[str, List[MethodDef]] self.signals = OrderedDict() # type: OrderedDict[str, SignalDef] self.theme_items = OrderedDict() # type: OrderedDict[str, ThemeItemDef] self.inherits = None # type: Optional[str] @@ -169,6 +171,34 @@ class State: ) class_def.properties[property_name] = property_def + constructors = class_root.find("constructors") + if constructors is not None: + for constructor in constructors: + assert constructor.tag == "constructor" + + method_name = constructor.attrib["name"] + qualifiers = constructor.get("qualifiers") + + return_element = constructor.find("return") + if return_element is not None: + return_type = TypeName.from_element(return_element) + + else: + return_type = TypeName("void") + + params = parse_arguments(constructor) + + desc_element = constructor.find("description") + method_desc = None + if desc_element is not None: + method_desc = desc_element.text + + method_def = MethodDef(method_name, return_type, params, method_desc, qualifiers) + if method_name not in class_def.constructors: + class_def.constructors[method_name] = [] + + class_def.constructors[method_name].append(method_def) + methods = class_root.find("methods") if methods is not None: for method in methods: @@ -197,6 +227,34 @@ class State: class_def.methods[method_name].append(method_def) + operators = class_root.find("operators") + if operators is not None: + for operator in operators: + assert operator.tag == "operator" + + method_name = operator.attrib["name"] + qualifiers = operator.get("qualifiers") + + return_element = operator.find("return") + if return_element is not None: + return_type = TypeName.from_element(return_element) + + else: + return_type = TypeName("void") + + params = parse_arguments(operator) + + desc_element = operator.find("description") + method_desc = None + if desc_element is not None: + method_desc = desc_element.text + + method_def = MethodDef(method_name, return_type, params, method_desc, qualifiers) + if method_name not in class_def.operators: + class_def.operators[method_name] = [] + + class_def.operators[method_name].append(method_def) + constants = class_root.find("constants") if constants is not None: for constant in constants: @@ -471,13 +529,29 @@ def make_rst_class(class_def, state, dry_run, output_dir): # type: (ClassDef, S ml.append((type_rst, ref, default)) format_table(f, ml, True) - # Methods overview + # Constructors, Methods, Operators overview + if len(class_def.constructors) > 0: + f.write(make_heading("Constructors", "-")) + ml = [] + for method_list in class_def.constructors.values(): + for m in method_list: + ml.append(make_method_signature(class_def, m, "constructor", state)) + format_table(f, ml) + if len(class_def.methods) > 0: f.write(make_heading("Methods", "-")) ml = [] for method_list in class_def.methods.values(): for m in method_list: - ml.append(make_method_signature(class_def, m, True, state)) + ml.append(make_method_signature(class_def, m, "method", state)) + format_table(f, ml) + + if len(class_def.operators) > 0: + f.write(make_heading("Operators", "-")) + ml = [] + for method_list in class_def.operators.values(): + for m in method_list: + ml.append(make_method_signature(class_def, m, "operator", state)) format_table(f, ml) # Theme properties @@ -501,7 +575,7 @@ def make_rst_class(class_def, state, dry_run, output_dir): # type: (ClassDef, S f.write("----\n\n") f.write(".. _class_{}_signal_{}:\n\n".format(class_name, signal.name)) - _, signature = make_method_signature(class_def, signal, False, state) + _, signature = make_method_signature(class_def, signal, "", state) f.write("- {}\n\n".format(signature)) if signal.description is not None and signal.description.strip() != "": @@ -582,7 +656,27 @@ def make_rst_class(class_def, state, dry_run, output_dir): # type: (ClassDef, S index += 1 - # Method descriptions + # Constructor, Method, Operator descriptions + if len(class_def.constructors) > 0: + f.write(make_heading("Constructor Descriptions", "-")) + index = 0 + + for method_list in class_def.constructors.values(): + for i, m in enumerate(method_list): + if index != 0: + f.write("----\n\n") + + if i == 0: + f.write(".. _class_{}_constructor_{}:\n\n".format(class_name, m.name)) + + ret_type, signature = make_method_signature(class_def, m, "", state) + f.write("- {} {}\n\n".format(ret_type, signature)) + + if m.description is not None and m.description.strip() != "": + f.write(rstize_text(m.description.strip(), state) + "\n\n") + + index += 1 + if len(class_def.methods) > 0: f.write(make_heading("Method Descriptions", "-")) index = 0 @@ -595,7 +689,31 @@ def make_rst_class(class_def, state, dry_run, output_dir): # type: (ClassDef, S if i == 0: f.write(".. _class_{}_method_{}:\n\n".format(class_name, m.name)) - ret_type, signature = make_method_signature(class_def, m, False, state) + ret_type, signature = make_method_signature(class_def, m, "", state) + f.write("- {} {}\n\n".format(ret_type, signature)) + + if m.description is not None and m.description.strip() != "": + f.write(rstize_text(m.description.strip(), state) + "\n\n") + + index += 1 + + if len(class_def.operators) > 0: + f.write(make_heading("Operator Descriptions", "-")) + index = 0 + + for method_list in class_def.operators.values(): + for i, m in enumerate(method_list): + if index != 0: + f.write("----\n\n") + + if i == 0: + f.write( + ".. _class_{}_operator_{}_{}:\n\n".format( + class_name, sanitize_operator_name(m.name, state), m.return_type.type_name + ) + ) + + ret_type, signature = make_method_signature(class_def, m, "", state) f.write("- {} {}\n\n".format(ret_type, signature)) if m.description is not None and m.description.strip() != "": @@ -810,10 +928,20 @@ def rstize_text(text, state): # type: (str, State) -> str ref_type = "" if class_param in state.classes: class_def = state.classes[class_param] + if cmd.startswith("constructor"): + if method_param not in class_def.constructors: + print_error( + "Unresolved constructor '{}', file: {}".format(param, state.current_class), state + ) + ref_type = "_constructor" if cmd.startswith("method"): if method_param not in class_def.methods: print_error("Unresolved method '{}', file: {}".format(param, state.current_class), state) ref_type = "_method" + if cmd.startswith("operator"): + if method_param not in class_def.operators: + print_error("Unresolved operator '{}', file: {}".format(param, state.current_class), state) + ref_type = "_operator" elif cmd.startswith("member"): if method_param not in class_def.properties: @@ -1046,24 +1174,26 @@ def make_enum(t, state): # type: (str, State) -> str def make_method_signature( - class_def, method_def, make_ref, state -): # type: (ClassDef, Union[MethodDef, SignalDef], bool, State) -> Tuple[str, str] + class_def, method_def, ref_type, state +): # type: (ClassDef, Union[MethodDef, SignalDef], str, State) -> Tuple[str, str] ret_type = " " - ref_type = "signal" if isinstance(method_def, MethodDef): ret_type = method_def.return_type.to_rst(state) - ref_type = "method" - - # FIXME: Need to add proper support for operator methods, but generating a unique - # and valid ref for them is not trivial. - if method_def.name.startswith("operator "): - make_ref = False out = "" - if make_ref: - out += ":ref:`{0}<class_{1}_{2}_{0}>` ".format(method_def.name, class_def.name, ref_type) + if ref_type != "": + if ref_type == "operator": + out += ":ref:`{0}<class_{1}_{2}_{3}_{4}>` ".format( + method_def.name, + class_def.name, + ref_type, + sanitize_operator_name(method_def.name, state), + method_def.return_type.type_name, + ) + else: + out += ":ref:`{0}<class_{1}_{2}_{0}>` ".format(method_def.name, class_def.name, ref_type) else: out += "**{}** ".format(method_def.name) @@ -1139,5 +1269,61 @@ def make_link(url, title): # type: (str, str) -> str return "`" + url + " <" + url + ">`__" +def sanitize_operator_name(dirty_name, state): # type: (str, State) -> str + clear_name = dirty_name.replace("operator ", "") + + if clear_name == "!=": + clear_name = "neq" + elif clear_name == "==": + clear_name = "eq" + + elif clear_name == "<": + clear_name = "lt" + elif clear_name == "<=": + clear_name = "lte" + elif clear_name == ">": + clear_name = "gt" + elif clear_name == ">=": + clear_name = "gte" + + elif clear_name == "+": + clear_name = "sum" + elif clear_name == "-": + clear_name = "dif" + elif clear_name == "*": + clear_name = "mul" + elif clear_name == "/": + clear_name = "div" + elif clear_name == "%": + clear_name = "mod" + + elif clear_name == "unary+": + clear_name = "unplus" + elif clear_name == "unary-": + clear_name = "unminus" + + elif clear_name == "<<": + clear_name = "bwsl" + elif clear_name == ">>": + clear_name = "bwsr" + elif clear_name == "&": + clear_name = "bwand" + elif clear_name == "|": + clear_name = "bwor" + elif clear_name == "^": + clear_name = "bwxor" + elif clear_name == "~": + clear_name = "bwnot" + + elif clear_name == "[]": + clear_name = "idx" + + else: + clear_name = "xxx" + print_error("Unsupported operator type '{}', please add the missing rule.".format(dirty_name), state) + + return clear_name + + if __name__ == "__main__": main() diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp index 9f049a0e58..16567cfebb 100644 --- a/editor/editor_inspector.cpp +++ b/editor/editor_inspector.cpp @@ -3490,7 +3490,7 @@ void EditorInspector::_update_script_class_properties(const Object &p_object, Li String path = s->get_path(); String name = EditorNode::get_editor_data().script_class_get_name(path); if (name.is_empty()) { - if (!path.is_empty() && path.find("::") == -1) { + if (!s->is_built_in()) { name = path.get_file(); } else { name = TTR("Built-in script"); diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index a7b8a25186..d855085719 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -2256,7 +2256,8 @@ void EditorNode::_edit_current() { if (main_plugin) { // special case if use of external editor is true - if (main_plugin->get_name() == "Script" && current_obj->get_class_name() != StringName("VisualScript") && (bool(EditorSettings::get_singleton()->get("text_editor/external/use_external_editor")) || overrides_external_editor(current_obj))) { + Resource *res = Object::cast_to<Resource>(current_obj); + if (main_plugin->get_name() == "Script" && current_obj->get_class_name() != StringName("VisualScript") && res && !res->is_built_in() && (bool(EditorSettings::get_singleton()->get("text_editor/external/use_external_editor")) || overrides_external_editor(current_obj))) { if (!changing_scene) { main_plugin->edit(current_obj); } diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index 3f98560a2f..aad378ecec 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -227,12 +227,6 @@ void ScriptEditorBase::_bind_methods() { ADD_SIGNAL(MethodInfo("replace_in_files_requested", PropertyInfo(Variant::STRING, "text"))); } -static bool _is_built_in_script(Script *p_script) { - String path = p_script->get_path(); - - return path.find("::") != -1; -} - class EditorScriptCodeCompletionCache : public ScriptCodeCompletionCache { struct Cache { uint64_t time_loaded = 0; @@ -764,7 +758,7 @@ void ScriptEditor::_close_tab(int p_idx, bool p_save, bool p_history_back) { if (p_save && file.is_valid()) { // Do not try to save internal scripts, but prompt to save in-memory // scripts which are not saved to disk yet (have empty path). - if (file->get_path().find("local://") == -1 && file->get_path().find("::") == -1) { + if (file->is_built_in()) { save_current_script(); } } @@ -910,7 +904,7 @@ void ScriptEditor::_resave_scripts(const String &p_str) { RES script = se->get_edited_resource(); - if (script->get_path() == "" || script->get_path().find("local://") != -1 || script->get_path().find("::") != -1) { + if (script->is_built_in()) { continue; //internal script, who cares } @@ -951,7 +945,7 @@ void ScriptEditor::_reload_scripts() { RES edited_res = se->get_edited_resource(); - if (edited_res->get_path() == "" || edited_res->get_path().find("local://") != -1 || edited_res->get_path().find("::") != -1) { + if (edited_res->is_built_in()) { continue; //internal script, who cares } @@ -995,7 +989,7 @@ void ScriptEditor::_res_saved_callback(const Ref<Resource> &p_res) { RES script = se->get_edited_resource(); - if (script->get_path() == "" || script->get_path().find("local://") != -1 || script->get_path().find("::") != -1) { + if (script->is_built_in()) { continue; //internal script, who cares } @@ -1037,7 +1031,7 @@ bool ScriptEditor::_test_script_times_on_disk(RES p_for_script) { continue; } - if (edited_res->get_path() == "" || edited_res->get_path().find("local://") != -1 || edited_res->get_path().find("::") != -1) { + if (edited_res->is_built_in()) { continue; //internal script, who cares } @@ -1624,7 +1618,7 @@ void ScriptEditor::close_builtin_scripts_from_scene(const String &p_scene) { continue; } - if (script->get_path().find("::") != -1 && script->get_path().begins_with(p_scene)) { //is an internal script and belongs to scene being closed + if (script->is_built_in() && script->get_path().begins_with(p_scene)) { //is an internal script and belongs to scene being closed _close_tab(i); i--; } @@ -2180,9 +2174,10 @@ bool ScriptEditor::edit(const RES &p_resource, int p_line, int p_col, bool p_gra Ref<Script> script = p_resource; // Don't open dominant script if using an external editor. - const bool use_external_editor = + bool use_external_editor = EditorSettings::get_singleton()->get("text_editor/external/use_external_editor") || (script.is_valid() && script->get_language()->overrides_external_editor()); + use_external_editor = use_external_editor && !(script.is_valid() && script->is_built_in()); // Ignore external editor for built-in scripts. const bool open_dominant = EditorSettings::get_singleton()->get("text_editor/behavior/files/open_dominant_script_on_scene_change"); const bool should_open = (open_dominant && !use_external_editor) || !EditorNode::get_singleton()->is_changing_scene(); @@ -2450,7 +2445,7 @@ void ScriptEditor::save_all_scripts() { se->apply_code(); } - if (edited_res->get_path() != "" && edited_res->get_path().find("local://") == -1 && edited_res->get_path().find("::") == -1) { + if (!edited_res->is_built_in()) { Ref<TextFile> text_file = edited_res; Ref<Script> script = edited_res; @@ -2570,7 +2565,7 @@ void ScriptEditor::_add_callback(Object *p_obj, const String &p_function, const script_list->select(script_list->find_metadata(i)); // Save the current script so the changes can be picked up by an external editor. - if (!_is_built_in_script(script.ptr())) { // But only if it's not built-in script. + if (!script.ptr()->is_built_in()) { // But only if it's not built-in script. save_current_script(); } @@ -3346,9 +3341,10 @@ Array ScriptEditor::_get_open_script_editors() const { void ScriptEditor::set_scene_root_script(Ref<Script> p_script) { // Don't open dominant script if using an external editor. - const bool use_external_editor = + bool use_external_editor = EditorSettings::get_singleton()->get("text_editor/external/use_external_editor") || (p_script.is_valid() && p_script->get_language()->overrides_external_editor()); + use_external_editor = use_external_editor && !(p_script.is_valid() && p_script->is_built_in()); // Ignore external editor for built-in scripts. const bool open_dominant = EditorSettings::get_singleton()->get("text_editor/behavior/files/open_dominant_script_on_scene_change"); if (open_dominant && !use_external_editor && p_script.is_valid()) { @@ -3858,7 +3854,7 @@ void ScriptEditorPlugin::edit(Object *p_object) { Script *p_script = Object::cast_to<Script>(p_object); String res_path = p_script->get_path().get_slice("::", 0); - if (_is_built_in_script(p_script)) { + if (p_script->is_built_in()) { if (ResourceLoader::get_resource_type(res_path) == "PackedScene") { if (!EditorNode::get_singleton()->is_scene_open(res_path)) { EditorNode::get_singleton()->load_scene(res_path); diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp index 219498b5e7..24cdc06d78 100644 --- a/editor/plugins/script_text_editor.cpp +++ b/editor/plugins/script_text_editor.cpp @@ -375,7 +375,7 @@ void ScriptTextEditor::ensure_focus() { String ScriptTextEditor::get_name() { String name; - if (script->get_path().find("local://") == -1 && script->get_path().find("::") == -1) { + if (!script->is_built_in()) { name = script->get_path().get_file(); if (is_unsaved()) { if (script->get_path().is_empty()) { @@ -658,7 +658,7 @@ void ScriptEditor::_update_modified_scripts_for_external_editor(Ref<Script> p_fo continue; } - if (script->get_path() == "" || script->get_path().find("local://") != -1 || script->get_path().find("::") != -1) { + if (script->is_built_in()) { continue; //internal script, who cares, though weird } diff --git a/editor/plugins/shader_editor_plugin.cpp b/editor/plugins/shader_editor_plugin.cpp index 2731582288..9d2b4c88c5 100644 --- a/editor/plugins/shader_editor_plugin.cpp +++ b/editor/plugins/shader_editor_plugin.cpp @@ -482,8 +482,7 @@ void ShaderEditor::_check_for_external_edit() { return; } - // internal shader. - if (shader->get_path() == "" || shader->get_path().find("local://") != -1 || shader->get_path().find("::") != -1) { + if (shader->is_built_in()) { return; } @@ -530,7 +529,7 @@ void ShaderEditor::save_external_data(const String &p_str) { } apply_shaders(); - if (shader->get_path() != "" && shader->get_path().find("local://") == -1 && shader->get_path().find("::") == -1) { + if (!shader->is_built_in()) { //external shader, save it ResourceSaver::save(shader->get_path(), shader); } diff --git a/editor/plugins/text_editor.cpp b/editor/plugins/text_editor.cpp index 1fc7eb98e0..3b45f32927 100644 --- a/editor/plugins/text_editor.cpp +++ b/editor/plugins/text_editor.cpp @@ -65,7 +65,7 @@ void TextEditor::_load_theme_settings() { String TextEditor::get_name() { String name; - if (text_file->get_path().find("local://") == -1 && text_file->get_path().find("::") == -1) { + if (!text_file->is_built_in()) { name = text_file->get_path().get_file(); if (is_unsaved()) { if (text_file->get_path().is_empty()) { diff --git a/editor/property_editor.cpp b/editor/property_editor.cpp index db560af657..62c5cc5cc1 100644 --- a/editor/property_editor.cpp +++ b/editor/property_editor.cpp @@ -1671,7 +1671,7 @@ void CustomPropertyEditor::_focus_exit() { } void CustomPropertyEditor::config_action_buttons(const List<String> &p_strings) { - Ref<StyleBox> sb = action_buttons[0]->get_theme_stylebox(SNAME("panel")); + Ref<StyleBox> sb = action_buttons[0]->get_theme_stylebox(SNAME("button")); int margin_top = sb->get_margin(SIDE_TOP); int margin_left = sb->get_margin(SIDE_LEFT); int margin_bottom = sb->get_margin(SIDE_BOTTOM); @@ -1804,26 +1804,18 @@ CustomPropertyEditor::CustomPropertyEditor() { } text_edit = memnew(TextEdit); - add_child(text_edit); + value_vbox->add_child(text_edit); text_edit->set_anchors_and_offsets_preset(Control::PRESET_WIDE, Control::PRESET_MODE_MINSIZE, 5); + text_edit->set_v_size_flags(Control::SIZE_EXPAND_FILL); text_edit->set_offset(SIDE_BOTTOM, -30); text_edit->hide(); text_edit->connect("text_changed", callable_mp(this, &CustomPropertyEditor::_text_edit_changed)); - for (int i = 0; i < MAX_ACTION_BUTTONS; i++) { - action_buttons[i] = memnew(Button); - action_buttons[i]->hide(); - add_child(action_buttons[i]); - Vector<Variant> binds; - binds.push_back(i); - action_buttons[i]->connect("pressed", callable_mp(this, &CustomPropertyEditor::_action_pressed), binds); - } - color_picker = nullptr; file = memnew(EditorFileDialog); - add_child(file); + value_vbox->add_child(file); file->hide(); file->connect("file_selected", callable_mp(this, &CustomPropertyEditor::_file_selected)); @@ -1831,46 +1823,58 @@ CustomPropertyEditor::CustomPropertyEditor() { error = memnew(ConfirmationDialog); error->set_title(TTR("Error!")); - add_child(error); + value_vbox->add_child(error); scene_tree = memnew(SceneTreeDialog); - add_child(scene_tree); + value_vbox->add_child(scene_tree); scene_tree->connect("selected", callable_mp(this, &CustomPropertyEditor::_node_path_selected)); scene_tree->get_scene_tree()->set_show_enabled_subscene(true); texture_preview = memnew(TextureRect); - add_child(texture_preview); + value_vbox->add_child(texture_preview); texture_preview->hide(); easing_draw = memnew(Control); - add_child(easing_draw); + value_vbox->add_child(easing_draw); easing_draw->hide(); easing_draw->connect("draw", callable_mp(this, &CustomPropertyEditor::_draw_easing)); easing_draw->connect("gui_input", callable_mp(this, &CustomPropertyEditor::_drag_easing)); easing_draw->set_default_cursor_shape(Control::CURSOR_MOVE); type_button = memnew(MenuButton); - add_child(type_button); + value_vbox->add_child(type_button); type_button->hide(); type_button->get_popup()->connect("id_pressed", callable_mp(this, &CustomPropertyEditor::_type_create_selected)); menu = memnew(PopupMenu); // menu->set_pass_on_modal_close_click(false); - add_child(menu); + value_vbox->add_child(menu); menu->connect("id_pressed", callable_mp(this, &CustomPropertyEditor::_menu_option)); evaluator = nullptr; spinbox = memnew(SpinBox); - add_child(spinbox); + value_vbox->add_child(spinbox); spinbox->set_anchors_and_offsets_preset(Control::PRESET_WIDE, Control::PRESET_MODE_MINSIZE, 5); spinbox->connect("value_changed", callable_mp(this, &CustomPropertyEditor::_range_modified)); slider = memnew(HSlider); - add_child(slider); + value_vbox->add_child(slider); slider->set_anchors_and_offsets_preset(Control::PRESET_WIDE, Control::PRESET_MODE_MINSIZE, 5); slider->connect("value_changed", callable_mp(this, &CustomPropertyEditor::_range_modified)); + action_hboxes = memnew(HBoxContainer); + action_hboxes->set_alignment(BoxContainer::ALIGN_CENTER); + value_vbox->add_child(action_hboxes); + for (int i = 0; i < MAX_ACTION_BUTTONS; i++) { + action_buttons[i] = memnew(Button); + action_buttons[i]->hide(); + action_hboxes->add_child(action_buttons[i]); + Vector<Variant> binds; + binds.push_back(i); + action_buttons[i]->connect("pressed", callable_mp(this, &CustomPropertyEditor::_action_pressed), binds); + } + create_dialog = nullptr; property_select = nullptr; } diff --git a/editor/property_editor.h b/editor/property_editor.h index 23771b7494..2565c6ee27 100644 --- a/editor/property_editor.h +++ b/editor/property_editor.h @@ -110,6 +110,7 @@ class CustomPropertyEditor : public PopupPanel { int focused_value_editor; Label *value_label[MAX_VALUE_EDITORS]; HScrollBar *scroll[4]; + HBoxContainer *action_hboxes; Button *action_buttons[MAX_ACTION_BUTTONS]; MenuButton *type_button; Vector<String> inheritors_array; diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp index 6798cff7e3..6da3e78da9 100644 --- a/editor/scene_tree_dock.cpp +++ b/editor/scene_tree_dock.cpp @@ -3152,7 +3152,7 @@ void SceneTreeDock::_create_remap_for_node(Node *p_node, Map<RES, RES> &r_remap) } } - if ((res->get_path() == "" || res->get_path().find("::") > -1) && !r_remap.has(res)) { + if (res->is_built_in() && !r_remap.has(res)) { _create_remap_for_resource(res, r_remap); } } @@ -3179,7 +3179,7 @@ void SceneTreeDock::_create_remap_for_resource(RES p_resource, Map<RES, RES> &r_ if (v.is_ref()) { RES res = v; if (res.is_valid()) { - if ((res->get_path() == "" || res->get_path().find("::") > -1) && !r_remap.has(res)) { + if (res->is_built_in() && !r_remap.has(res)) { _create_remap_for_resource(res, r_remap); } } diff --git a/modules/visual_script/visual_script_editor.cpp b/modules/visual_script/visual_script_editor.cpp index a40804cb2e..49ae79e22a 100644 --- a/modules/visual_script/visual_script_editor.cpp +++ b/modules/visual_script/visual_script_editor.cpp @@ -2582,7 +2582,7 @@ void VisualScriptEditor::reload_text() { String VisualScriptEditor::get_name() { String name; - if (script->get_path().find("local://") == -1 && script->get_path().find("::") == -1) { + if (!script->is_built_in()) { name = script->get_path().get_file(); if (is_unsaved()) { if (script->get_path().is_empty()) { diff --git a/platform/android/java/app/config.gradle b/platform/android/java/app/config.gradle index 3fafdf8573..2a2850df0f 100644 --- a/platform/android/java/app/config.gradle +++ b/platform/android/java/app/config.gradle @@ -1,8 +1,8 @@ ext.versions = [ androidGradlePlugin: '7.0.3', compileSdk : 30, - minSdk : 19, - targetSdk : 30, + minSdk : 19, // Also update 'platform/android/java/lib/AndroidManifest.xml#minSdkVersion' value + targetSdk : 30, // Also update 'platform/android/java/lib/AndroidManifest.xml#targetSdkVersion' value buildTools : '30.0.3', kotlinVersion : '1.5.10', fragmentVersion : '1.3.6', diff --git a/platform/android/java/lib/AndroidManifest.xml b/platform/android/java/lib/AndroidManifest.xml index 3034794d69..2de62271c4 100644 --- a/platform/android/java/lib/AndroidManifest.xml +++ b/platform/android/java/lib/AndroidManifest.xml @@ -4,6 +4,9 @@ android:versionCode="1" android:versionName="1.0"> + <!-- Should match the mindSdk and targetSdk values in platform/android/java/app/config.gradle --> + <uses-sdk android:minSdkVersion="19" android:targetSdkVersion="30" /> + <application> <!-- Records the version of the Godot library --> diff --git a/scene/gui/item_list.cpp b/scene/gui/item_list.cpp index 4215c9aff4..8470003b3e 100644 --- a/scene/gui/item_list.cpp +++ b/scene/gui/item_list.cpp @@ -29,6 +29,7 @@ /*************************************************************************/ #include "item_list.h" + #include "core/config/project_settings.h" #include "core/os/os.h" #include "core/string/translation.h" @@ -1605,7 +1606,7 @@ void ItemList::_bind_methods() { ClassDB::bind_method(D_METHOD("move_item", "from_idx", "to_idx"), &ItemList::move_item); - ClassDB::bind_method(D_METHOD("set_item_count"), &ItemList::set_item_count); + ClassDB::bind_method(D_METHOD("set_item_count", "count"), &ItemList::set_item_count); ClassDB::bind_method(D_METHOD("get_item_count"), &ItemList::get_item_count); ClassDB::bind_method(D_METHOD("remove_item", "idx"), &ItemList::remove_item); diff --git a/scene/gui/menu_button.cpp b/scene/gui/menu_button.cpp index 2561d10f25..39c7b04955 100644 --- a/scene/gui/menu_button.cpp +++ b/scene/gui/menu_button.cpp @@ -203,7 +203,7 @@ void MenuButton::_bind_methods() { ClassDB::bind_method(D_METHOD("is_switch_on_hover"), &MenuButton::is_switch_on_hover); ClassDB::bind_method(D_METHOD("set_disable_shortcuts", "disabled"), &MenuButton::set_disable_shortcuts); - ClassDB::bind_method(D_METHOD("set_item_count"), &MenuButton::set_item_count); + ClassDB::bind_method(D_METHOD("set_item_count", "count"), &MenuButton::set_item_count); ClassDB::bind_method(D_METHOD("get_item_count"), &MenuButton::get_item_count); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "switch_on_hover"), "set_switch_on_hover", "is_switch_on_hover"); diff --git a/scene/gui/popup_menu.cpp b/scene/gui/popup_menu.cpp index 4fef292f2f..54af9f3885 100644 --- a/scene/gui/popup_menu.cpp +++ b/scene/gui/popup_menu.cpp @@ -1733,7 +1733,7 @@ void PopupMenu::_bind_methods() { ClassDB::bind_method(D_METHOD("get_item_shortcut", "idx"), &PopupMenu::get_item_shortcut); ClassDB::bind_method(D_METHOD("get_current_index"), &PopupMenu::get_current_index); - ClassDB::bind_method(D_METHOD("set_item_count"), &PopupMenu::set_item_count); + ClassDB::bind_method(D_METHOD("set_item_count", "count"), &PopupMenu::set_item_count); ClassDB::bind_method(D_METHOD("get_item_count"), &PopupMenu::get_item_count); ClassDB::bind_method(D_METHOD("remove_item", "idx"), &PopupMenu::remove_item); diff --git a/scene/resources/packed_scene.cpp b/scene/resources/packed_scene.cpp index 60cda637ca..978be2d46e 100644 --- a/scene/resources/packed_scene.cpp +++ b/scene/resources/packed_scene.cpp @@ -1651,7 +1651,7 @@ Node *PackedScene::instantiate(GenEditState p_edit_state) const { s->set_scene_instance_state(state); } - if (get_path() != "" && get_path().find("::") == -1) { + if (!is_built_in()) { s->set_scene_file_path(get_path()); } diff --git a/scene/resources/resource_format_text.cpp b/scene/resources/resource_format_text.cpp index 77d915aef9..ea3b72af1b 100644 --- a/scene/resources/resource_format_text.cpp +++ b/scene/resources/resource_format_text.cpp @@ -1492,7 +1492,7 @@ String ResourceFormatSaverTextInstance::_write_resource(const RES &res) { } else { if (internal_resources.has(res)) { return "SubResource( \"" + internal_resources[res] + "\" )"; - } else if (res->get_path().length() && res->get_path().find("::") == -1) { + } else if (!res->is_built_in()) { if (res->get_path() == local_path) { //circular reference attempt return "null"; } @@ -1515,7 +1515,7 @@ void ResourceFormatSaverTextInstance::_find_resources(const Variant &p_variant, return; } - if (!p_main && (!bundle_resources) && res->get_path().length() && res->get_path().find("::") == -1) { + if (!p_main && (!bundle_resources) && !res->is_built_in()) { if (res->get_path() == local_path) { ERR_PRINT("Circular reference to resource being saved found: '" + local_path + "' will be null next time it's loaded."); return; @@ -1728,7 +1728,7 @@ Error ResourceFormatSaverTextInstance::save(const String &p_path, const RES &p_r for (List<RES>::Element *E = saved_resources.front(); E; E = E->next()) { RES res = E->get(); - if (E->next() && (res->get_path() == "" || res->get_path().find("::") != -1)) { + if (E->next() && res->is_built_in()) { if (res->get_scene_unique_id() != "") { if (used_unique_ids.has(res->get_scene_unique_id())) { res->set_scene_unique_id(""); // Repeated. diff --git a/scene/resources/tile_set.cpp b/scene/resources/tile_set.cpp index d5eebb1fbf..5256803d56 100644 --- a/scene/resources/tile_set.cpp +++ b/scene/resources/tile_set.cpp @@ -212,7 +212,7 @@ void TileMapPattern::_bind_methods() { ClassDB::bind_method(D_METHOD("set_cell", "coords", "source_id", "atlas_coords", "alternative_tile"), &TileMapPattern::set_cell, DEFVAL(TileSet::INVALID_SOURCE), DEFVAL(TileSetSource::INVALID_ATLAS_COORDS), DEFVAL(TileSetSource::INVALID_TILE_ALTERNATIVE)); ClassDB::bind_method(D_METHOD("has_cell", "coords"), &TileMapPattern::has_cell); - ClassDB::bind_method(D_METHOD("remove_cell", "coords"), &TileMapPattern::remove_cell); + ClassDB::bind_method(D_METHOD("remove_cell", "coords", "update_size"), &TileMapPattern::remove_cell); ClassDB::bind_method(D_METHOD("get_cell_source_id", "coords"), &TileMapPattern::get_cell_source_id); ClassDB::bind_method(D_METHOD("get_cell_atlas_coords", "coords"), &TileMapPattern::get_cell_atlas_coords); ClassDB::bind_method(D_METHOD("get_cell_alternative_tile", "coords"), &TileMapPattern::get_cell_alternative_tile); |