diff options
-rw-r--r-- | core/math/dynamic_bvh.cpp | 5 | ||||
-rw-r--r-- | doc/classes/ScrollContainer.xml | 9 | ||||
-rw-r--r-- | doc/classes/TileMap.xml | 10 | ||||
-rw-r--r-- | editor/editor_feature_profile.cpp | 131 | ||||
-rw-r--r-- | editor/editor_feature_profile.h | 4 | ||||
-rw-r--r-- | editor/project_manager.cpp | 11 | ||||
-rw-r--r-- | modules/gdscript/gdscript_compiler.cpp | 2 | ||||
-rw-r--r-- | scene/2d/tile_map.cpp | 61 | ||||
-rw-r--r-- | scene/2d/tile_map.h | 48 | ||||
-rw-r--r-- | scene/gui/scroll_container.cpp | 42 | ||||
-rw-r--r-- | scene/gui/scroll_container.h | 3 | ||||
-rw-r--r-- | scene/resources/texture.cpp | 18 | ||||
-rw-r--r-- | scene/resources/texture.h | 2 | ||||
-rw-r--r-- | scene/resources/tile_set.cpp | 36 | ||||
-rw-r--r-- | servers/audio_server.cpp | 3 | ||||
-rw-r--r-- | tests/test_main.cpp | 33 |
16 files changed, 261 insertions, 157 deletions
diff --git a/core/math/dynamic_bvh.cpp b/core/math/dynamic_bvh.cpp index 200095d8cb..8e596f0f9d 100644 --- a/core/math/dynamic_bvh.cpp +++ b/core/math/dynamic_bvh.cpp @@ -312,8 +312,11 @@ void DynamicBVH::optimize_incremental(int passes) { if (passes < 0) { passes = total_leaves; } - if (bvh_root && (passes > 0)) { + if (passes > 0) { do { + if (!bvh_root) { + break; + } Node *node = bvh_root; unsigned bit = 0; while (node->is_internal()) { diff --git a/doc/classes/ScrollContainer.xml b/doc/classes/ScrollContainer.xml index 40e29ac74b..60f3106b4b 100644 --- a/doc/classes/ScrollContainer.xml +++ b/doc/classes/ScrollContainer.xml @@ -11,6 +11,15 @@ <tutorials> </tutorials> <methods> + <method name="ensure_control_visible"> + <return type="void"> + </return> + <argument index="0" name="control" type="Control"> + </argument> + <description> + Ensures the given [code]control[/code] is visible (must be a direct or indirect child of the ScrollContainer). Used by [member follow_focus]. + </description> + </method> <method name="get_h_scrollbar"> <return type="HScrollBar"> </return> diff --git a/doc/classes/TileMap.xml b/doc/classes/TileMap.xml index fd52a28486..93d5dd8037 100644 --- a/doc/classes/TileMap.xml +++ b/doc/classes/TileMap.xml @@ -132,6 +132,10 @@ <member name="cell_quadrant_size" type="int" setter="set_quadrant_size" getter="get_quadrant_size" default="16"> The TileMap's quadrant size. Optimizes drawing by batching, using chunks of this size. </member> + <member name="show_collision" type="int" setter="set_collision_visibility_mode" getter="get_collision_visibility_mode" enum="TileMap.VisibilityMode" default="0"> + </member> + <member name="show_navigation" type="int" setter="set_navigation_visibility_mode" getter="get_navigation_visibility_mode" enum="TileMap.VisibilityMode" default="0"> + </member> <member name="tile_set" type="TileSet" setter="set_tileset" getter="get_tileset"> The assigned [TileSet]. </member> @@ -144,5 +148,11 @@ </signal> </signals> <constants> + <constant name="VISIBILITY_MODE_DEFAULT" value="0" enum="VisibilityMode"> + </constant> + <constant name="VISIBILITY_MODE_FORCE_HIDE" value="2" enum="VisibilityMode"> + </constant> + <constant name="VISIBILITY_MODE_FORCE_SHOW" value="1" enum="VisibilityMode"> + </constant> </constants> </class> diff --git a/editor/editor_feature_profile.cpp b/editor/editor_feature_profile.cpp index 529bbe97eb..d232153206 100644 --- a/editor/editor_feature_profile.cpp +++ b/editor/editor_feature_profile.cpp @@ -46,6 +46,16 @@ const char *EditorFeatureProfile::feature_names[FEATURE_MAX] = { TTRC("Import Dock"), }; +const char *EditorFeatureProfile::feature_descriptions[FEATURE_MAX] = { + TTRC("Allows to view and edit 3D scenes."), + TTRC("Allows to edit scripts using the integrated script editor."), + TTRC("Provides built-in access to the Asset Library."), + TTRC("Allows editing the node hierarchy in the Scene dock."), + TTRC("Allows to work with signals and groups of the node selected in the Scene dock."), + TTRC("Allows to browse the local file system via a dedicated dock."), + TTRC("Allows to configure import settings for individual assets. Requires the FileSystem dock to function."), +}; + const char *EditorFeatureProfile::feature_identifiers[FEATURE_MAX] = { "3d", "script", @@ -145,6 +155,11 @@ String EditorFeatureProfile::get_feature_name(Feature p_feature) { return feature_names[p_feature]; } +String EditorFeatureProfile::get_feature_description(Feature p_feature) { + ERR_FAIL_INDEX_V(p_feature, FEATURE_MAX, String()); + return feature_descriptions[p_feature]; +} + Error EditorFeatureProfile::save_to_file(const String &p_path) { Dictionary json; json["type"] = "feature_profile"; @@ -418,7 +433,7 @@ void EditorFeatureProfileManager::_profile_action(int p_action) { export_profile->set_current_file(_get_selected_profile() + ".profile"); } break; case PROFILE_NEW: { - new_profile_dialog->popup_centered(); + new_profile_dialog->popup_centered(Size2(240, 60) * EDSCALE); new_profile_name->clear(); new_profile_name->grab_focus(); } break; @@ -426,8 +441,8 @@ void EditorFeatureProfileManager::_profile_action(int p_action) { String selected = _get_selected_profile(); ERR_FAIL_COND(selected == String()); - erase_profile_dialog->set_text(vformat(TTR("Erase profile '%s'? (no undo)"), selected)); - erase_profile_dialog->popup_centered(); + erase_profile_dialog->set_text(vformat(TTR("Remove currently selected profile, '%s'? Cannot be undone."), selected)); + erase_profile_dialog->popup_centered(Size2(240, 60) * EDSCALE); } break; } } @@ -535,12 +550,28 @@ void EditorFeatureProfileManager::_class_list_item_selected() { } Variant md = item->get_metadata(0); - if (md.get_type() != Variant::STRING && md.get_type() != Variant::STRING_NAME) { + if (md.get_type() == Variant::STRING || md.get_type() == Variant::STRING_NAME) { + String class_name = md; + String class_description; + + DocTools *dd = EditorHelp::get_doc_data(); + Map<String, DocData::ClassDoc>::Element *E = dd->class_list.find(class_name); + if (E) { + class_description = DTR(E->get().brief_description); + } + + description_bit->set_text(class_description); + } else if (md.get_type() == Variant::INT) { + int feature_id = md; + String feature_description = EditorFeatureProfile::get_feature_description(EditorFeatureProfile::Feature(feature_id)); + + description_bit->set_text(feature_description); + return; + } else { return; } String class_name = md; - if (edited->is_class_disabled(class_name)) { return; } @@ -560,27 +591,28 @@ void EditorFeatureProfileManager::_class_list_item_selected() { option->set_metadata(0, CLASS_OPTION_DISABLE_EDITOR); } - TreeItem *properties = property_list->create_item(root); - properties->set_text(0, TTR("Enabled Properties:")); - List<PropertyInfo> props; - ClassDB::get_property_list(class_name, &props, true); - for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) { - String name = E->get().name; - if (!(E->get().usage & PROPERTY_USAGE_EDITOR)) { - continue; + if (props.size() > 0) { + TreeItem *properties = property_list->create_item(root); + properties->set_text(0, TTR("Class Properties:")); + + for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) { + String name = E->get().name; + if (!(E->get().usage & PROPERTY_USAGE_EDITOR)) { + continue; + } + TreeItem *property = property_list->create_item(properties); + property->set_cell_mode(0, TreeItem::CELL_MODE_CHECK); + property->set_editable(0, true); + property->set_selectable(0, true); + property->set_checked(0, !edited->is_class_property_disabled(class_name, name)); + property->set_text(0, name.capitalize()); + property->set_metadata(0, name); + String icon_type = Variant::get_type_name(E->get().type); + property->set_icon(0, EditorNode::get_singleton()->get_class_icon(icon_type)); } - TreeItem *property = property_list->create_item(properties); - property->set_cell_mode(0, TreeItem::CELL_MODE_CHECK); - property->set_editable(0, true); - property->set_selectable(0, true); - property->set_checked(0, !edited->is_class_property_disabled(class_name, name)); - property->set_text(0, name.capitalize()); - property->set_metadata(0, name); - String icon_type = Variant::get_type_name(E->get().type); - property->set_icon(0, EditorNode::get_singleton()->get_class_icon(icon_type)); } updating_features = false; @@ -710,7 +742,7 @@ void EditorFeatureProfileManager::_update_selected_profile() { TreeItem *features = class_list->create_item(root); TreeItem *last_feature; - features->set_text(0, TTR("Enabled Features:")); + features->set_text(0, TTR("Main Features") + ":"); for (int i = 0; i < EditorFeatureProfile::FEATURE_MAX; i++) { TreeItem *feature; if (i == EditorFeatureProfile::FEATURE_IMPORT_DOCK) { @@ -734,7 +766,7 @@ void EditorFeatureProfileManager::_update_selected_profile() { } TreeItem *classes = class_list->create_item(root); - classes->set_text(0, TTR("Enabled Classes:")); + classes->set_text(0, TTR("Nodes and Classes") + ":"); _fill_classes_from(classes, "Node", class_selected); _fill_classes_from(classes, "Resource", class_selected); @@ -832,47 +864,51 @@ EditorFeatureProfileManager::EditorFeatureProfileManager() { current_profile_name->set_text(TTR("(none)")); current_profile_name->set_editable(false); current_profile_name->set_h_size_flags(Control::SIZE_EXPAND_FILL); - profile_actions[PROFILE_CLEAR] = memnew(Button(TTR("Unset"))); + profile_actions[PROFILE_CLEAR] = memnew(Button(TTR("Reset to Default"))); name_hbc->add_child(profile_actions[PROFILE_CLEAR]); profile_actions[PROFILE_CLEAR]->set_disabled(true); profile_actions[PROFILE_CLEAR]->connect("pressed", callable_mp(this, &EditorFeatureProfileManager::_profile_action), varray(PROFILE_CLEAR)); main_vbc->add_margin_child(TTR("Current Profile:"), name_hbc); + main_vbc->add_child(memnew(HSeparator)); + HBoxContainer *profiles_hbc = memnew(HBoxContainer); profile_list = memnew(OptionButton); profile_list->set_h_size_flags(Control::SIZE_EXPAND_FILL); profiles_hbc->add_child(profile_list); profile_list->connect("item_selected", callable_mp(this, &EditorFeatureProfileManager::_profile_selected)); - profile_actions[PROFILE_SET] = memnew(Button(TTR("Make Current"))); - profiles_hbc->add_child(profile_actions[PROFILE_SET]); - profile_actions[PROFILE_SET]->set_disabled(true); - profile_actions[PROFILE_SET]->connect("pressed", callable_mp(this, &EditorFeatureProfileManager::_profile_action), varray(PROFILE_SET)); + profile_actions[PROFILE_NEW] = memnew(Button(TTR("Create Profile"))); + profiles_hbc->add_child(profile_actions[PROFILE_NEW]); + profile_actions[PROFILE_NEW]->connect("pressed", callable_mp(this, &EditorFeatureProfileManager::_profile_action), varray(PROFILE_NEW)); - profile_actions[PROFILE_ERASE] = memnew(Button(TTR("Remove"))); + profile_actions[PROFILE_ERASE] = memnew(Button(TTR("Remove Profile"))); profiles_hbc->add_child(profile_actions[PROFILE_ERASE]); profile_actions[PROFILE_ERASE]->set_disabled(true); profile_actions[PROFILE_ERASE]->connect("pressed", callable_mp(this, &EditorFeatureProfileManager::_profile_action), varray(PROFILE_ERASE)); - profiles_hbc->add_child(memnew(VSeparator)); + main_vbc->add_margin_child(TTR("Available Profiles:"), profiles_hbc); - profile_actions[PROFILE_NEW] = memnew(Button(TTR("New"))); - profiles_hbc->add_child(profile_actions[PROFILE_NEW]); - profile_actions[PROFILE_NEW]->connect("pressed", callable_mp(this, &EditorFeatureProfileManager::_profile_action), varray(PROFILE_NEW)); + HBoxContainer *current_profile_hbc = memnew(HBoxContainer); + + profile_actions[PROFILE_SET] = memnew(Button(TTR("Make Current"))); + current_profile_hbc->add_child(profile_actions[PROFILE_SET]); + profile_actions[PROFILE_SET]->set_disabled(true); + profile_actions[PROFILE_SET]->connect("pressed", callable_mp(this, &EditorFeatureProfileManager::_profile_action), varray(PROFILE_SET)); - profiles_hbc->add_child(memnew(VSeparator)); + current_profile_hbc->add_child(memnew(VSeparator)); profile_actions[PROFILE_IMPORT] = memnew(Button(TTR("Import"))); - profiles_hbc->add_child(profile_actions[PROFILE_IMPORT]); + current_profile_hbc->add_child(profile_actions[PROFILE_IMPORT]); profile_actions[PROFILE_IMPORT]->connect("pressed", callable_mp(this, &EditorFeatureProfileManager::_profile_action), varray(PROFILE_IMPORT)); profile_actions[PROFILE_EXPORT] = memnew(Button(TTR("Export"))); - profiles_hbc->add_child(profile_actions[PROFILE_EXPORT]); + current_profile_hbc->add_child(profile_actions[PROFILE_EXPORT]); profile_actions[PROFILE_EXPORT]->set_disabled(true); profile_actions[PROFILE_EXPORT]->connect("pressed", callable_mp(this, &EditorFeatureProfileManager::_profile_action), varray(PROFILE_EXPORT)); - main_vbc->add_margin_child(TTR("Available Profiles:"), profiles_hbc); + main_vbc->add_child(current_profile_hbc); h_split = memnew(HSplitContainer); h_split->set_v_size_flags(Control::SIZE_EXPAND_FILL); @@ -883,7 +919,7 @@ EditorFeatureProfileManager::EditorFeatureProfileManager() { class_list_vbc->set_h_size_flags(Control::SIZE_EXPAND_FILL); class_list = memnew(Tree); - class_list_vbc->add_margin_child(TTR("Enabled Classes:"), class_list, true); + class_list_vbc->add_margin_child(TTR("Configure Selected Profile") + ":", class_list, true); class_list->set_hide_root(true); class_list->set_edit_checkbox_cell_only_when_checkbox_is_pressed(true); class_list->connect("cell_selected", callable_mp(this, &EditorFeatureProfileManager::_class_list_item_selected)); @@ -896,8 +932,12 @@ EditorFeatureProfileManager::EditorFeatureProfileManager() { h_split->add_child(property_list_vbc); property_list_vbc->set_h_size_flags(Control::SIZE_EXPAND_FILL); + description_bit = memnew(EditorHelpBit); + property_list_vbc->add_margin_child(TTR("Description") + ":", description_bit, false); + description_bit->set_custom_minimum_size(Size2(0, 80) * EDSCALE); + property_list = memnew(Tree); - property_list_vbc->add_margin_child(TTR("Class Options:"), property_list, true); + property_list_vbc->add_margin_child(TTR("Extra Options") + ":", property_list, true); property_list->set_hide_root(true); property_list->set_hide_folding(true); property_list->set_edit_checkbox_cell_only_when_checkbox_is_pressed(true); @@ -915,9 +955,14 @@ EditorFeatureProfileManager::EditorFeatureProfileManager() { h_split->add_child(no_profile_selected_help); new_profile_dialog = memnew(ConfirmationDialog); - new_profile_dialog->set_title(TTR("New profile name:")); + new_profile_dialog->set_title(TTR("Create Profile")); + VBoxContainer *new_profile_vb = memnew(VBoxContainer); + new_profile_dialog->add_child(new_profile_vb); + Label *new_profile_label = memnew(Label); + new_profile_label->set_text(TTR("New profile name") + ":"); + new_profile_vb->add_child(new_profile_label); new_profile_name = memnew(LineEdit); - new_profile_dialog->add_child(new_profile_name); + new_profile_vb->add_child(new_profile_name); new_profile_name->set_custom_minimum_size(Size2(300 * EDSCALE, 1)); add_child(new_profile_dialog); new_profile_dialog->connect("confirmed", callable_mp(this, &EditorFeatureProfileManager::_create_new_profile)); @@ -926,7 +971,7 @@ EditorFeatureProfileManager::EditorFeatureProfileManager() { erase_profile_dialog = memnew(ConfirmationDialog); add_child(erase_profile_dialog); - erase_profile_dialog->set_title(TTR("Erase Profile")); + erase_profile_dialog->set_title(TTR("Remove Profile")); erase_profile_dialog->connect("confirmed", callable_mp(this, &EditorFeatureProfileManager::_erase_selected_profile)); import_profiles = memnew(EditorFileDialog); diff --git a/editor/editor_feature_profile.h b/editor/editor_feature_profile.h index 9561e11c81..e118b5f287 100644 --- a/editor/editor_feature_profile.h +++ b/editor/editor_feature_profile.h @@ -34,6 +34,7 @@ #include "core/object/reference.h" #include "core/os/file_access.h" #include "editor/editor_file_dialog.h" +#include "editor_help.h" #include "scene/gui/dialogs.h" #include "scene/gui/option_button.h" #include "scene/gui/separator.h" @@ -64,6 +65,7 @@ private: bool features_disabled[FEATURE_MAX]; static const char *feature_names[FEATURE_MAX]; + static const char *feature_descriptions[FEATURE_MAX]; static const char *feature_identifiers[FEATURE_MAX]; String _get_feature_name(Feature p_feature) { return get_feature_name(p_feature); } @@ -92,6 +94,7 @@ public: Error load_from_file(const String &p_path); static String get_feature_name(Feature p_feature); + static String get_feature_description(Feature p_feature); EditorFeatureProfile(); }; @@ -129,6 +132,7 @@ class EditorFeatureProfileManager : public AcceptDialog { Tree *class_list; VBoxContainer *property_list_vbc; Tree *property_list; + EditorHelpBit *description_bit; Label *no_profile_selected_help; EditorFileDialog *import_profiles; diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp index 49a6d28dc1..8bde397b5c 100644 --- a/editor/project_manager.cpp +++ b/editor/project_manager.cpp @@ -1484,16 +1484,7 @@ Vector<ProjectList::Item> ProjectList::get_selected_projects() const { void ProjectList::ensure_project_visible(int p_index) { const Item &item = _projects[p_index]; - - int item_top = item.control->get_position().y; - int item_bottom = item.control->get_position().y + item.control->get_size().y; - - if (item_top < get_v_scroll()) { - set_v_scroll(item_top); - - } else if (item_bottom > get_v_scroll() + get_size().y) { - set_v_scroll(item_bottom - get_size().y); - } + ensure_control_visible(item.control); } int ProjectList::get_single_selected_index() const { diff --git a/modules/gdscript/gdscript_compiler.cpp b/modules/gdscript/gdscript_compiler.cpp index 179316b97e..c7ca9449c2 100644 --- a/modules/gdscript/gdscript_compiler.cpp +++ b/modules/gdscript/gdscript_compiler.cpp @@ -2223,7 +2223,7 @@ Error GDScriptCompiler::_parse_class_level(GDScript *p_script, const GDScriptPar if (err) { return err; } - if (base.is_null() && !base->is_valid()) { + if (base.is_null() || !base->is_valid()) { return ERR_COMPILATION_FAILED; } } diff --git a/scene/2d/tile_map.cpp b/scene/2d/tile_map.cpp index 8666361e88..24b907fe6c 100644 --- a/scene/2d/tile_map.cpp +++ b/scene/2d/tile_map.cpp @@ -314,37 +314,24 @@ void TileMap::set_quadrant_size(int p_size) { emit_signal("changed"); } -void TileMap::_fix_cell_transform(Transform2D &xform, const TileMapCell &p_cell, const Vector2 &p_offset, const Size2 &p_sc) { - Size2 s = p_sc; - Vector2 offset = p_offset; - - // Flip/transpose: update the tile transform. - TileSetSource *source = *tile_set->get_source(p_cell.source_id); - TileSetAtlasSource *atlas_source = Object::cast_to<TileSetAtlasSource>(source); - if (!atlas_source) { - return; - } - TileData *tile_data = Object::cast_to<TileData>(atlas_source->get_tile_data(p_cell.get_atlas_coords(), p_cell.alternative_tile)); - if (tile_data->get_transpose()) { - SWAP(xform.elements[0].x, xform.elements[0].y); - SWAP(xform.elements[1].x, xform.elements[1].y); - SWAP(offset.x, offset.y); - SWAP(s.x, s.y); - } +void TileMap::set_collision_visibility_mode(TileMap::VisibilityMode p_show_collision) { + show_collision = p_show_collision; + _recreate_quadrants(); + emit_signal("changed"); +} - if (tile_data->get_flip_h()) { - xform.elements[0].x = -xform.elements[0].x; - xform.elements[1].x = -xform.elements[1].x; - offset.x = s.x - offset.x; - } +TileMap::VisibilityMode TileMap::get_collision_visibility_mode() { + return show_collision; +} - if (tile_data->get_flip_v()) { - xform.elements[0].y = -xform.elements[0].y; - xform.elements[1].y = -xform.elements[1].y; - offset.y = s.y - offset.y; - } +void TileMap::set_navigation_visibility_mode(TileMap::VisibilityMode p_show_navigation) { + show_navigation = p_show_navigation; + _recreate_quadrants(); + emit_signal("changed"); +} - xform.elements[2] += offset; +TileMap::VisibilityMode TileMap::get_navigation_visibility_mode() { + return show_navigation; } void TileMap::update_dirty_quadrants() { @@ -1723,6 +1710,12 @@ void TileMap::_bind_methods() { ClassDB::bind_method(D_METHOD("set_quadrant_size", "size"), &TileMap::set_quadrant_size); ClassDB::bind_method(D_METHOD("get_quadrant_size"), &TileMap::get_quadrant_size); + ClassDB::bind_method(D_METHOD("set_collision_visibility_mode", "show_collision"), &TileMap::set_collision_visibility_mode); + ClassDB::bind_method(D_METHOD("get_collision_visibility_mode"), &TileMap::get_collision_visibility_mode); + + ClassDB::bind_method(D_METHOD("set_navigation_visibility_mode", "show_navigation"), &TileMap::set_navigation_visibility_mode); + ClassDB::bind_method(D_METHOD("get_navigation_visibility_mode"), &TileMap::get_navigation_visibility_mode); + ClassDB::bind_method(D_METHOD("set_cell", "coords", "source_id", "atlas_coords", "alternative_tile"), &TileMap::set_cell, DEFVAL(-1), DEFVAL(TileSetSource::INVALID_ATLAS_COORDS), DEFVAL(TileSetSource::INVALID_TILE_ALTERNATIVE)); ClassDB::bind_method(D_METHOD("get_cell_source_id", "coords"), &TileMap::get_cell_source_id); ClassDB::bind_method(D_METHOD("get_cell_atlas_coords", "coords"), &TileMap::get_cell_atlas_coords); @@ -1747,10 +1740,16 @@ void TileMap::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "tile_set", PROPERTY_HINT_RESOURCE_TYPE, "TileSet"), "set_tileset", "get_tileset"); ADD_PROPERTY(PropertyInfo(Variant::INT, "cell_quadrant_size", PROPERTY_HINT_RANGE, "1,128,1"), "set_quadrant_size", "get_quadrant_size"); + ADD_PROPERTY(PropertyInfo(Variant::INT, "show_collision", PROPERTY_HINT_ENUM, "Default,Force Show,Force Hide"), "set_collision_visibility_mode", "get_collision_visibility_mode"); + ADD_PROPERTY(PropertyInfo(Variant::INT, "show_navigation", PROPERTY_HINT_ENUM, "Default,Force Show,Force Hide"), "set_navigation_visibility_mode", "get_navigation_visibility_mode"); ADD_PROPERTY_DEFAULT("format", FORMAT_1); ADD_SIGNAL(MethodInfo("changed")); + + BIND_ENUM_CONSTANT(VISIBILITY_MODE_DEFAULT); + BIND_ENUM_CONSTANT(VISIBILITY_MODE_FORCE_HIDE); + BIND_ENUM_CONSTANT(VISIBILITY_MODE_FORCE_SHOW); } void TileMap::_tile_set_changed() { @@ -1759,12 +1758,6 @@ void TileMap::_tile_set_changed() { } TileMap::TileMap() { - rect_cache_dirty = true; - used_size_cache_dirty = true; - pending_update = false; - quadrant_size = 16; - format = FORMAT_1; // Assume lowest possible format if none is present - set_notify_transform(true); set_notify_local_transform(false); } diff --git a/scene/2d/tile_map.h b/scene/2d/tile_map.h index 2703e1980e..f02455a84b 100644 --- a/scene/2d/tile_map.h +++ b/scene/2d/tile_map.h @@ -179,37 +179,45 @@ class TileMap : public Node2D { GDCLASS(TileMap, Node2D); public: + enum VisibilityMode { + VISIBILITY_MODE_DEFAULT, + VISIBILITY_MODE_FORCE_SHOW, + VISIBILITY_MODE_FORCE_HIDE, + }; + private: friend class TileSetPlugin; + // A compatibility enum to specify how is the data if formatted. enum DataFormat { FORMAT_1 = 0, FORMAT_2, FORMAT_3 }; + mutable DataFormat format = FORMAT_1; // Assume lowest possible format if none is present; + // Properties. Ref<TileSet> tile_set; - int quadrant_size; - Transform2D custom_transform; - - // Map of cells - Map<Vector2i, TileMapCell> tile_map; - - Vector2i _coords_to_quadrant_coords(const Vector2i &p_coords) const; - - Map<Vector2i, TileMapQuadrant> quadrant_map; - - SelfList<TileMapQuadrant>::List dirty_quadrant_list; + int quadrant_size = 16; + VisibilityMode show_collision = VISIBILITY_MODE_DEFAULT; + VisibilityMode show_navigation = VISIBILITY_MODE_DEFAULT; + // Updates. bool pending_update = false; + // Rect. Rect2 rect_cache; bool rect_cache_dirty = true; Rect2 used_size_cache; - bool used_size_cache_dirty; - mutable DataFormat format; + bool used_size_cache_dirty = true; - void _fix_cell_transform(Transform2D &xform, const TileMapCell &p_cell, const Vector2 &p_offset, const Size2 &p_sc); + // Map of cells. + Map<Vector2i, TileMapCell> tile_map; + + // Quadrants management. + Map<Vector2i, TileMapQuadrant> quadrant_map; + Vector2i _coords_to_quadrant_coords(const Vector2i &p_coords) const; + SelfList<TileMapQuadrant>::List dirty_quadrant_list; Map<Vector2i, TileMapQuadrant>::Element *_create_quadrant(const Vector2i &p_qk); void _erase_quadrant(Map<Vector2i, TileMapQuadrant>::Element *Q); @@ -219,8 +227,7 @@ private: void _clear_quadrants(); void _recompute_rect_cache(); - void _update_all_items_material_state(); - + // Set and get tiles from data arrays. void _set_tile_data(const Vector<int> &p_data); Vector<int> _get_tile_data() const; @@ -251,6 +258,12 @@ public: void set_quadrant_size(int p_size); int get_quadrant_size() const; + void set_collision_visibility_mode(VisibilityMode p_show_collision); + VisibilityMode get_collision_visibility_mode(); + + void set_navigation_visibility_mode(VisibilityMode p_show_navigation); + VisibilityMode get_navigation_visibility_mode(); + void set_cell(const Vector2i &p_coords, int p_source_id = -1, const Vector2i p_atlas_coords = TileSetSource::INVALID_ATLAS_COORDS, int p_alternative_tile = TileSetSource::INVALID_TILE_ALTERNATIVE); int get_cell_source_id(const Vector2i &p_coords) const; Vector2i get_cell_atlas_coords(const Vector2i &p_coords) const; @@ -293,4 +306,7 @@ public: TileMap(); ~TileMap(); }; + +VARIANT_ENUM_CAST(TileMap::VisibilityMode); + #endif // TILE_MAP_H diff --git a/scene/gui/scroll_container.cpp b/scene/gui/scroll_container.cpp index 46db4a3c2f..5f872644ab 100644 --- a/scene/gui/scroll_container.cpp +++ b/scene/gui/scroll_container.cpp @@ -238,32 +238,25 @@ void ScrollContainer::_update_scrollbar_position() { _updating_scrollbars = false; } -void ScrollContainer::_ensure_focused_visible(Control *p_control) { - if (!follow_focus) { - return; +void ScrollContainer::_gui_focus_changed(Control *p_control) { + if (follow_focus && is_a_parent_of(p_control)) { + ensure_control_visible(p_control); } +} - if (is_a_parent_of(p_control)) { - Rect2 global_rect = get_global_rect(); - Rect2 other_rect = p_control->get_global_rect(); - float right_margin = 0.0; - if (v_scroll->is_visible()) { - right_margin += v_scroll->get_size().x; - } - float bottom_margin = 0.0; - if (h_scroll->is_visible()) { - bottom_margin += h_scroll->get_size().y; - } +void ScrollContainer::ensure_control_visible(Control *p_control) { + ERR_FAIL_COND_MSG(!is_a_parent_of(p_control), "Must be a parent of the control."); - float diff = MAX(MIN(other_rect.position.y, global_rect.position.y), other_rect.position.y + other_rect.size.y - global_rect.size.y + bottom_margin); - set_v_scroll(get_v_scroll() + (diff - global_rect.position.y)); - if (is_layout_rtl()) { - diff = MAX(MIN(other_rect.position.x, global_rect.position.x), other_rect.position.x + other_rect.size.x - global_rect.size.x); - } else { - diff = MAX(MIN(other_rect.position.x, global_rect.position.x), other_rect.position.x + other_rect.size.x - global_rect.size.x + right_margin); - } - set_h_scroll(get_h_scroll() + (diff - global_rect.position.x)); - } + Rect2 global_rect = get_global_rect(); + Rect2 other_rect = p_control->get_global_rect(); + float right_margin = v_scroll->is_visible() ? v_scroll->get_size().x : 0.0f; + float bottom_margin = h_scroll->is_visible() ? h_scroll->get_size().y : 0.0f; + + Vector2 diff = Vector2(MAX(MIN(other_rect.position.x, global_rect.position.x), other_rect.position.x + other_rect.size.x - global_rect.size.x + (!is_layout_rtl() ? right_margin : 0.0f)), + MAX(MIN(other_rect.position.y, global_rect.position.y), other_rect.position.y + other_rect.size.y - global_rect.size.y + bottom_margin)); + + set_h_scroll(get_h_scroll() + (diff.x - global_rect.position.x)); + set_v_scroll(get_v_scroll() + (diff.y - global_rect.position.y)); } void ScrollContainer::_update_dimensions() { @@ -334,7 +327,7 @@ void ScrollContainer::_notification(int p_what) { }; if (p_what == NOTIFICATION_READY) { - get_viewport()->connect("gui_focus_changed", callable_mp(this, &ScrollContainer::_ensure_focused_visible)); + get_viewport()->connect("gui_focus_changed", callable_mp(this, &ScrollContainer::_gui_focus_changed)); _update_dimensions(); } @@ -608,6 +601,7 @@ void ScrollContainer::_bind_methods() { ClassDB::bind_method(D_METHOD("get_h_scrollbar"), &ScrollContainer::get_h_scrollbar); ClassDB::bind_method(D_METHOD("get_v_scrollbar"), &ScrollContainer::get_v_scrollbar); + ClassDB::bind_method(D_METHOD("ensure_control_visible", "control"), &ScrollContainer::ensure_control_visible); ADD_SIGNAL(MethodInfo("scroll_started")); ADD_SIGNAL(MethodInfo("scroll_ended")); diff --git a/scene/gui/scroll_container.h b/scene/gui/scroll_container.h index f61df70b85..c77a0d62f5 100644 --- a/scene/gui/scroll_container.h +++ b/scene/gui/scroll_container.h @@ -69,6 +69,7 @@ protected: Size2 get_minimum_size() const override; void _gui_input(const Ref<InputEvent> &p_gui_input); + void _gui_focus_changed(Control *p_control); void _update_dimensions(); void _notification(int p_what); @@ -77,7 +78,6 @@ protected: bool _updating_scrollbars = false; void _update_scrollbar_position(); - void _ensure_focused_visible(Control *p_node); public: void set_h_scroll(int p_pos); @@ -106,6 +106,7 @@ public: HScrollBar *get_h_scrollbar(); VScrollBar *get_v_scrollbar(); + void ensure_control_visible(Control *p_control); virtual bool clips_input() const override; diff --git a/scene/resources/texture.cpp b/scene/resources/texture.cpp index 1b2176d30a..4475179431 100644 --- a/scene/resources/texture.cpp +++ b/scene/resources/texture.cpp @@ -490,7 +490,7 @@ Image::Format StreamTexture2D::get_format() const { return format; } -Error StreamTexture2D::_load_data(const String &p_path, int &tw, int &th, int &tw_custom, int &th_custom, Ref<Image> &image, bool &r_request_3d, bool &r_request_normal, bool &r_request_roughness, int &mipmap_limit, int p_size_limit) { +Error StreamTexture2D::_load_data(const String &p_path, int &r_width, int &r_height, Ref<Image> &image, bool &r_request_3d, bool &r_request_normal, bool &r_request_roughness, int &mipmap_limit, int p_size_limit) { alpha_cache.unref(); ERR_FAIL_COND_V(image.is_null(), ERR_INVALID_PARAMETER); @@ -511,8 +511,8 @@ Error StreamTexture2D::_load_data(const String &p_path, int &tw, int &th, int &t memdelete(f); ERR_FAIL_V_MSG(ERR_FILE_CORRUPT, "Stream texture file is too new."); } - tw_custom = f->get_32(); - th_custom = f->get_32(); + r_width = f->get_32(); + r_height = f->get_32(); uint32_t df = f->get_32(); //data format //skip reserved @@ -551,7 +551,7 @@ Error StreamTexture2D::_load_data(const String &p_path, int &tw, int &th, int &t } Error StreamTexture2D::load(const String &p_path) { - int lw, lh, lwc, lhc; + int lw, lh; Ref<Image> image; image.instance(); @@ -560,7 +560,7 @@ Error StreamTexture2D::load(const String &p_path) { bool request_roughness; int mipmap_limit; - Error err = _load_data(p_path, lw, lh, lwc, lhc, image, request_3d, request_normal, request_roughness, mipmap_limit); + Error err = _load_data(p_path, lw, lh, image, request_3d, request_normal, request_roughness, mipmap_limit); if (err) { return err; } @@ -571,12 +571,12 @@ Error StreamTexture2D::load(const String &p_path) { } else { texture = RS::get_singleton()->texture_2d_create(image); } - if (lwc || lhc) { - RS::get_singleton()->texture_set_size_override(texture, lwc, lhc); + if (lw || lh) { + RS::get_singleton()->texture_set_size_override(texture, lw, lh); } - w = lwc ? lwc : lw; - h = lhc ? lhc : lh; + w = lw; + h = lh; path_to_file = p_path; format = image->get_format(); diff --git a/scene/resources/texture.h b/scene/resources/texture.h index 264d85d187..df8c00f8ff 100644 --- a/scene/resources/texture.h +++ b/scene/resources/texture.h @@ -158,7 +158,7 @@ public: }; private: - Error _load_data(const String &p_path, int &tw, int &th, int &tw_custom, int &th_custom, Ref<Image> &image, bool &r_request_3d, bool &r_request_normal, bool &r_request_roughness, int &mipmap_limit, int p_size_limit = 0); + Error _load_data(const String &p_path, int &r_width, int &r_height, Ref<Image> &image, bool &r_request_3d, bool &r_request_normal, bool &r_request_roughness, int &mipmap_limit, int p_size_limit = 0); String path_to_file; mutable RID texture; Image::Format format = Image::FORMAT_MAX; diff --git a/scene/resources/tile_set.cpp b/scene/resources/tile_set.cpp index 59c1a4e915..2c2c8ea0e8 100644 --- a/scene/resources/tile_set.cpp +++ b/scene/resources/tile_set.cpp @@ -4297,7 +4297,23 @@ void TileSetPluginAtlasPhysics::draw_quadrant_debug(TileMap *p_tile_map, TileMap Ref<TileSet> tile_set = p_tile_map->get_tileset(); ERR_FAIL_COND(!tile_set.is_valid()); - if (!p_tile_map->get_tree() || !(Engine::get_singleton()->is_editor_hint() || p_tile_map->get_tree()->is_debugging_collisions_hint())) { + if (!p_tile_map->get_tree()) { + return; + } + + bool show_collision = false; + switch (p_tile_map->get_collision_visibility_mode()) { + case TileMap::VISIBILITY_MODE_DEFAULT: + show_collision = !Engine::get_singleton()->is_editor_hint() && (p_tile_map->get_tree() && p_tile_map->get_tree()->is_debugging_navigation_hint()); + break; + case TileMap::VISIBILITY_MODE_FORCE_HIDE: + show_collision = false; + break; + case TileMap::VISIBILITY_MODE_FORCE_SHOW: + show_collision = true; + break; + } + if (!show_collision) { return; } @@ -4456,7 +4472,23 @@ void TileSetPluginAtlasNavigation::draw_quadrant_debug(TileMap *p_tile_map, Tile Ref<TileSet> tile_set = p_tile_map->get_tileset(); ERR_FAIL_COND(!tile_set.is_valid()); - if (!p_tile_map->get_tree() || !(Engine::get_singleton()->is_editor_hint() || p_tile_map->get_tree()->is_debugging_navigation_hint())) { + if (!p_tile_map->get_tree()) { + return; + } + + bool show_navigation = false; + switch (p_tile_map->get_navigation_visibility_mode()) { + case TileMap::VISIBILITY_MODE_DEFAULT: + show_navigation = !Engine::get_singleton()->is_editor_hint() && (p_tile_map->get_tree() && p_tile_map->get_tree()->is_debugging_navigation_hint()); + break; + case TileMap::VISIBILITY_MODE_FORCE_HIDE: + show_navigation = false; + break; + case TileMap::VISIBILITY_MODE_FORCE_SHOW: + show_navigation = true; + break; + } + if (!show_navigation) { return; } diff --git a/servers/audio_server.cpp b/servers/audio_server.cpp index 08c482553b..0e816fd4f8 100644 --- a/servers/audio_server.cpp +++ b/servers/audio_server.cpp @@ -1164,6 +1164,9 @@ void AudioServer::set_bus_layout(const Ref<AudioBusLayout> &p_bus_layout) { Bus::Effect bfx; bfx.effect = fx; bfx.enabled = p_bus_layout->buses[i].effects[j].enabled; +#if DEBUG_ENABLED + bfx.prof_time = 0; +#endif bus->effects.push_back(bfx); } } diff --git a/tests/test_main.cpp b/tests/test_main.cpp index 67fb38aa86..54327caf3d 100644 --- a/tests/test_main.cpp +++ b/tests/test_main.cpp @@ -121,24 +121,27 @@ int test_main(int argc, char *argv[]) { test_args.push_back(arg); } } - // Convert Godot command line arguments back to standard arguments. - char **doctest_args = new char *[test_args.size()]; - for (int x = 0; x < test_args.size(); x++) { - // Operation to convert Godot string to non wchar string. - CharString cs = test_args[x].utf8(); - const char *str = cs.get_data(); - // Allocate the string copy. - doctest_args[x] = new char[strlen(str) + 1]; - // Copy this into memory. - memcpy(doctest_args[x], str, strlen(str) + 1); - } - test_context.applyCommandLine(test_args.size(), doctest_args); + if (test_args.size() > 0) { + // Convert Godot command line arguments back to standard arguments. + char **doctest_args = new char *[test_args.size()]; + for (int x = 0; x < test_args.size(); x++) { + // Operation to convert Godot string to non wchar string. + CharString cs = test_args[x].utf8(); + const char *str = cs.get_data(); + // Allocate the string copy. + doctest_args[x] = new char[strlen(str) + 1]; + // Copy this into memory. + memcpy(doctest_args[x], str, strlen(str) + 1); + } + + test_context.applyCommandLine(test_args.size(), doctest_args); - for (int x = 0; x < test_args.size(); x++) { - delete[] doctest_args[x]; + for (int x = 0; x < test_args.size(); x++) { + delete[] doctest_args[x]; + } + delete[] doctest_args; } - delete[] doctest_args; return test_context.run(); } |