summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
Diffstat (limited to 'editor')
-rw-r--r--editor/animation_track_editor.cpp33
-rw-r--r--editor/animation_track_editor.h3
-rw-r--r--editor/animation_track_editor_plugins.cpp36
-rw-r--r--editor/animation_track_editor_plugins.h4
-rw-r--r--editor/code_editor.cpp4
-rw-r--r--editor/connections_dialog.cpp1
-rw-r--r--editor/dependency_editor.cpp2
-rw-r--r--editor/editor_export.cpp8
-rw-r--r--editor/editor_export.h10
-rw-r--r--editor/editor_fonts.cpp2
-rw-r--r--editor/editor_help.cpp20
-rw-r--r--editor/editor_help.h4
-rw-r--r--editor/editor_inspector.cpp18
-rw-r--r--editor/editor_node.cpp47
-rw-r--r--editor/editor_node.h1
-rw-r--r--editor/editor_path.cpp9
-rw-r--r--editor/editor_path.h1
-rw-r--r--editor/editor_properties.cpp39
-rw-r--r--editor/editor_properties.h3
-rw-r--r--editor/editor_run_native.cpp14
-rw-r--r--editor/editor_settings.cpp4
-rw-r--r--editor/editor_spin_slider.cpp4
-rw-r--r--editor/export_template_manager.cpp56
-rw-r--r--editor/filesystem_dock.cpp28
-rw-r--r--editor/icons/icon_crypto_key.svg1
-rw-r--r--editor/icons/icon_x509_certificate.svg1
-rw-r--r--editor/import/editor_scene_importer_gltf.cpp2
-rw-r--r--editor/import/resource_importer_obj.h2
-rw-r--r--editor/node_dock.cpp1
-rw-r--r--editor/output_strings.cpp208
-rw-r--r--editor/output_strings.h87
-rw-r--r--editor/plugins/asset_library_editor_plugin.cpp19
-rw-r--r--editor/plugins/asset_library_editor_plugin.h15
-rw-r--r--editor/plugins/canvas_item_editor_plugin.cpp148
-rw-r--r--editor/plugins/canvas_item_editor_plugin.h11
-rw-r--r--editor/plugins/curve_editor_plugin.cpp3
-rw-r--r--editor/plugins/script_editor_plugin.cpp41
-rw-r--r--editor/plugins/script_editor_plugin.h2
-rw-r--r--editor/plugins/script_text_editor.cpp2
-rw-r--r--editor/plugins/spatial_editor_plugin.cpp22
-rw-r--r--editor/plugins/style_box_editor_plugin.cpp13
-rw-r--r--editor/plugins/style_box_editor_plugin.h3
-rw-r--r--editor/plugins/text_editor.cpp2
-rw-r--r--editor/plugins/visual_shader_editor_plugin.cpp3
-rw-r--r--editor/project_export.cpp4
-rw-r--r--editor/project_manager.cpp46
-rw-r--r--editor/project_settings_editor.cpp9
-rw-r--r--editor/property_editor.cpp8
-rw-r--r--editor/property_editor.h3
-rw-r--r--editor/scene_tree_dock.cpp115
-rw-r--r--editor/scene_tree_dock.h4
-rw-r--r--editor/script_editor_debugger.cpp14
-rw-r--r--editor/spatial_editor_gizmos.cpp1
53 files changed, 531 insertions, 610 deletions
diff --git a/editor/animation_track_editor.cpp b/editor/animation_track_editor.cpp
index 74e8df60f9..7183d34d4f 100644
--- a/editor/animation_track_editor.cpp
+++ b/editor/animation_track_editor.cpp
@@ -5727,16 +5727,24 @@ void AnimationTrackEditor::_show_imported_anim_warning() const {
}
void AnimationTrackEditor::_select_all_tracks_for_copy() {
+
TreeItem *track = track_copy_select->get_root()->get_children();
+ if (!track)
+ return;
+
+ bool all_selected = true;
+ while (track) {
+ if (!track->is_checked(0))
+ all_selected = false;
+
+ track = track->get_next();
+ }
+
+ track = track_copy_select->get_root()->get_children();
while (track) {
- track->set_checked(0, selected_all_tracks);
+ track->set_checked(0, !all_selected);
track = track->get_next();
}
- selected_all_tracks = !selected_all_tracks;
- if (selected_all_tracks)
- select_all_button->set_text(TTR("Select All"));
- else
- select_all_button->set_text(TTR("Select None"));
}
void AnimationTrackEditor::_bind_methods() {
@@ -6067,25 +6075,22 @@ AnimationTrackEditor::AnimationTrackEditor() {
track_copy_dialog = memnew(ConfirmationDialog);
add_child(track_copy_dialog);
- track_copy_dialog->set_title(TTR("Select tracks to copy:"));
+ track_copy_dialog->set_title(TTR("Select Tracks to Copy"));
track_copy_dialog->get_ok()->set_text(TTR("Copy"));
VBoxContainer *track_vbox = memnew(VBoxContainer);
track_copy_dialog->add_child(track_vbox);
- selected_all_tracks = true;
+ Button *select_all_button = memnew(Button);
+ select_all_button->set_text(TTR("Select All/None"));
+ select_all_button->connect("pressed", this, "_select_all_tracks_for_copy");
+ track_vbox->add_child(select_all_button);
track_copy_select = memnew(Tree);
track_copy_select->set_h_size_flags(SIZE_EXPAND_FILL);
track_copy_select->set_v_size_flags(SIZE_EXPAND_FILL);
track_copy_select->set_hide_root(true);
track_vbox->add_child(track_copy_select);
- track_copy_options = memnew(HBoxContainer);
- track_vbox->add_child(track_copy_options);
- select_all_button = memnew(Button);
- select_all_button->set_text(TTR("Select All"));
- select_all_button->connect("pressed", this, "_select_all_tracks_for_copy");
- track_copy_options->add_child(select_all_button);
track_copy_dialog->connect("confirmed", this, "_edit_menu_pressed", varray(EDIT_COPY_TRACKS_CONFIRM));
animation_changing_awaiting_update = false;
}
diff --git a/editor/animation_track_editor.h b/editor/animation_track_editor.h
index 830d5b52d3..fd28d8f4d1 100644
--- a/editor/animation_track_editor.h
+++ b/editor/animation_track_editor.h
@@ -465,11 +465,8 @@ class AnimationTrackEditor : public VBoxContainer {
void _selection_changed();
- bool selected_all_tracks;
ConfirmationDialog *track_copy_dialog;
Tree *track_copy_select;
- HBoxContainer *track_copy_options;
- Button *select_all_button;
struct TrackClipboard {
NodePath full_path;
diff --git a/editor/animation_track_editor_plugins.cpp b/editor/animation_track_editor_plugins.cpp
index 226eef9c1e..3e0b644b20 100644
--- a/editor/animation_track_editor_plugins.cpp
+++ b/editor/animation_track_editor_plugins.cpp
@@ -337,7 +337,7 @@ AnimationTrackEditAudio::AnimationTrackEditAudio() {
AudioStreamPreviewGenerator::get_singleton()->connect("preview_updated", this, "_preview_changed");
}
-/// SPRITE FRAME ///
+/// SPRITE FRAME / FRAME_COORDS ///
int AnimationTrackEditSpriteFrame::get_key_height() const {
@@ -439,14 +439,24 @@ void AnimationTrackEditSpriteFrame::draw_key(int p_index, float p_pixels_sec, in
if (Object::cast_to<Sprite>(object) || Object::cast_to<Sprite3D>(object)) {
- int frame = get_animation()->track_get_key_value(get_track(), p_index);
-
texture = object->call("get_texture");
if (!texture.is_valid()) {
AnimationTrackEdit::draw_key(p_index, p_pixels_sec, p_x, p_selected, p_clip_left, p_clip_right);
return;
}
+ int hframes = object->call("get_hframes");
+ int vframes = object->call("get_vframes");
+
+ Vector2 coords;
+ if (is_coords) {
+ coords = get_animation()->track_get_key_value(get_track(), p_index);
+ } else {
+ int frame = get_animation()->track_get_key_value(get_track(), p_index);
+ coords.x = frame % hframes;
+ coords.y = frame / hframes;
+ }
+
region.size = texture->get_size();
if (bool(object->call("is_region"))) {
@@ -454,9 +464,6 @@ void AnimationTrackEditSpriteFrame::draw_key(int p_index, float p_pixels_sec, in
region = Rect2(object->call("get_region_rect"));
}
- int hframes = object->call("get_hframes");
- int vframes = object->call("get_vframes");
-
if (hframes > 1) {
region.size.x /= hframes;
}
@@ -464,8 +471,8 @@ void AnimationTrackEditSpriteFrame::draw_key(int p_index, float p_pixels_sec, in
region.size.y /= vframes;
}
- region.position.x += region.size.x * (frame % hframes);
- region.position.y += region.size.y * (frame / hframes);
+ region.position.x += region.size.x * coords.x;
+ region.position.y += region.size.y * coords.y;
} else if (Object::cast_to<AnimatedSprite>(object) || Object::cast_to<AnimatedSprite3D>(object)) {
@@ -532,6 +539,11 @@ void AnimationTrackEditSpriteFrame::set_node(Object *p_object) {
id = p_object->get_instance_id();
}
+void AnimationTrackEditSpriteFrame::set_as_coords() {
+
+ is_coords = true;
+}
+
/// SUB ANIMATION ///
int AnimationTrackEditSubAnim::get_key_height() const {
@@ -1297,6 +1309,14 @@ AnimationTrackEdit *AnimationTrackEditDefaultPlugin::create_value_track_edit(Obj
return sprite;
}
+ if (p_property == "frame_coords" && (p_object->is_class("Sprite") || p_object->is_class("Sprite3D"))) {
+
+ AnimationTrackEditSpriteFrame *sprite = memnew(AnimationTrackEditSpriteFrame);
+ sprite->set_as_coords();
+ sprite->set_node(p_object);
+ return sprite;
+ }
+
if (p_property == "current_animation" && (p_object->is_class("AnimationPlayer"))) {
AnimationTrackEditSubAnim *player = memnew(AnimationTrackEditSubAnim);
diff --git a/editor/animation_track_editor_plugins.h b/editor/animation_track_editor_plugins.h
index 5f0ea6196c..1013cccf72 100644
--- a/editor/animation_track_editor_plugins.h
+++ b/editor/animation_track_editor_plugins.h
@@ -81,6 +81,7 @@ class AnimationTrackEditSpriteFrame : public AnimationTrackEdit {
GDCLASS(AnimationTrackEditSpriteFrame, AnimationTrackEdit);
ObjectID id;
+ bool is_coords;
public:
virtual int get_key_height() const;
@@ -89,6 +90,9 @@ public:
virtual void draw_key(int p_index, float p_pixels_sec, int p_x, bool p_selected, int p_clip_left, int p_clip_right);
void set_node(Object *p_object);
+ void set_as_coords();
+
+ AnimationTrackEditSpriteFrame() { is_coords = false; }
};
class AnimationTrackEditSubAnim : public AnimationTrackEdit {
diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp
index 4c31797c50..1a821ddd02 100644
--- a/editor/code_editor.cpp
+++ b/editor/code_editor.cpp
@@ -191,7 +191,9 @@ void FindReplaceBar::_replace() {
results_count = -1;
}
- search_current();
+ if (!search_current()) {
+ search_next();
+ }
}
void FindReplaceBar::_replace_all() {
diff --git a/editor/connections_dialog.cpp b/editor/connections_dialog.cpp
index 1e5eabc24e..f5a01dfb04 100644
--- a/editor/connections_dialog.cpp
+++ b/editor/connections_dialog.cpp
@@ -417,6 +417,7 @@ ConnectDialog::ConnectDialog() {
dst_method = memnew(LineEdit);
dst_method->set_h_size_flags(SIZE_EXPAND_FILL);
+ dst_method->connect("text_entered", this, "_builtin_text_entered");
dstm_hb->add_child(dst_method);
advanced = memnew(CheckButton);
diff --git a/editor/dependency_editor.cpp b/editor/dependency_editor.cpp
index 5f8660e108..1f58eda396 100644
--- a/editor/dependency_editor.cpp
+++ b/editor/dependency_editor.cpp
@@ -646,7 +646,7 @@ DependencyErrorDialog::DependencyErrorDialog() {
vb->add_margin_child(TTR("Load failed due to missing dependencies:"), files, true);
files->set_v_size_flags(SIZE_EXPAND_FILL);
- set_custom_minimum_size(Size2(500, 220));
+ set_custom_minimum_size(Size2(500, 220) * EDSCALE);
get_ok()->set_text(TTR("Open Anyway"));
get_cancel()->set_text(TTR("Close"));
diff --git a/editor/editor_export.cpp b/editor/editor_export.cpp
index 9510092a86..7ae8a9e0ce 100644
--- a/editor/editor_export.cpp
+++ b/editor/editor_export.cpp
@@ -376,6 +376,12 @@ Error EditorExportPlatform::_save_zip_file(void *p_userdata, const String &p_pat
return OK;
}
+Ref<ImageTexture> EditorExportPlatform::get_option_icon(int p_index) const {
+ Ref<Theme> theme = EditorNode::get_singleton()->get_editor_theme();
+ ERR_FAIL_COND_V(theme.is_null(), Ref<ImageTexture>());
+ return theme->get_icon("Play", "EditorIcons");
+}
+
String EditorExportPlatform::find_export_template(String template_file_name, String *err) const {
String current_version = VERSION_FULL_CONFIG;
@@ -1403,7 +1409,7 @@ bool EditorExport::poll_export_platforms() {
bool changed = false;
for (int i = 0; i < export_platforms.size(); i++) {
- if (export_platforms.write[i]->poll_devices()) {
+ if (export_platforms.write[i]->poll_export()) {
changed = true;
}
}
diff --git a/editor/editor_export.h b/editor/editor_export.h
index 11dc464b5a..b0e27af629 100644
--- a/editor/editor_export.h
+++ b/editor/editor_export.h
@@ -243,10 +243,12 @@ public:
Error save_pack(const Ref<EditorExportPreset> &p_preset, const String &p_path, Vector<SharedObject> *p_so_files = NULL, bool p_embed = false, int64_t *r_embedded_start = NULL, int64_t *r_embedded_size = NULL);
Error save_zip(const Ref<EditorExportPreset> &p_preset, const String &p_path);
- virtual bool poll_devices() { return false; }
- virtual int get_device_count() const { return 0; }
- virtual String get_device_name(int p_device) const { return ""; }
- virtual String get_device_info(int p_device) const { return ""; }
+ virtual bool poll_export() { return false; }
+ virtual int get_options_count() const { return 0; }
+ virtual String get_options_tooltip() const { return ""; }
+ virtual Ref<ImageTexture> get_option_icon(int p_index) const;
+ virtual String get_option_label(int p_device) const { return ""; }
+ virtual String get_option_tooltip(int p_device) const { return ""; }
enum DebugFlags {
DEBUG_FLAG_DUMB_CLIENT = 1,
diff --git a/editor/editor_fonts.cpp b/editor/editor_fonts.cpp
index b6d27d84e0..97c796c707 100644
--- a/editor/editor_fonts.cpp
+++ b/editor/editor_fonts.cpp
@@ -64,7 +64,7 @@
Ref<DynamicFont> m_name; \
m_name.instance(); \
m_name->set_size(m_size); \
- if (CustomFont.is_valid()) { \
+ if (CustomFontBold.is_valid()) { \
m_name->set_font_data(CustomFontBold); \
m_name->add_fallback(DefaultFontBold); \
} else { \
diff --git a/editor/editor_help.cpp b/editor/editor_help.cpp
index 83434a6d9f..d2306abfd7 100644
--- a/editor/editor_help.cpp
+++ b/editor/editor_help.cpp
@@ -72,9 +72,12 @@ void EditorHelp::_unhandled_key_input(const Ref<InputEvent> &p_ev) {
}
}
-void EditorHelp::_search(const String &) {
+void EditorHelp::_search(bool p_search_previous) {
- find_bar->search_next();
+ if (p_search_previous)
+ find_bar->search_prev();
+ else
+ find_bar->search_next();
}
void EditorHelp::_class_list_select(const String &p_select) {
@@ -169,7 +172,9 @@ void EditorHelp::_class_desc_input(const Ref<InputEvent> &p_input) {
void EditorHelp::_class_desc_resized() {
// Add extra horizontal margins for better readability.
// The margins increase as the width of the editor help container increases.
- const int display_margin = MAX(30 * EDSCALE, get_parent_anchorable_rect().size.width - 900 * EDSCALE) * 0.5;
+ Ref<Font> doc_code_font = get_font("doc_source", "EditorFonts");
+ real_t char_width = doc_code_font->get_char_size('x').width;
+ const int display_margin = MAX(30 * EDSCALE, get_parent_anchorable_rect().size.width - char_width * 120 * EDSCALE) * 0.5;
Ref<StyleBox> class_desc_stylebox = EditorNode::get_singleton()->get_theme_base()->get_stylebox("normal", "RichTextLabel")->duplicate();
class_desc_stylebox->set_default_margin(MARGIN_LEFT, display_margin);
@@ -1464,6 +1469,11 @@ void EditorHelp::_notification(int p_what) {
_update_doc();
} break;
+ case NOTIFICATION_THEME_CHANGED: {
+ if (is_visible_in_tree()) {
+ _class_desc_resized();
+ }
+ } break;
default: break;
}
}
@@ -1502,8 +1512,8 @@ String EditorHelp::get_class() {
return edited_class;
}
-void EditorHelp::search_again() {
- _search(prev_search);
+void EditorHelp::search_again(bool p_search_previous) {
+ _search(p_search_previous);
}
int EditorHelp::get_scroll() const {
diff --git a/editor/editor_help.h b/editor/editor_help.h
index 1019cafffc..23a6e005a0 100644
--- a/editor/editor_help.h
+++ b/editor/editor_help.h
@@ -158,7 +158,7 @@ class EditorHelp : public VBoxContainer {
void _update_doc();
void _request_help(const String &p_string);
- void _search(const String &p_str);
+ void _search(bool p_search_previous = false);
void _unhandled_key_input(const Ref<InputEvent> &p_ev);
@@ -179,7 +179,7 @@ public:
void scroll_to_section(int p_section_index);
void popup_search();
- void search_again();
+ void search_again(bool p_search_previous = false);
String get_class();
diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp
index b29417b4c3..96b6a32914 100644
--- a/editor/editor_inspector.cpp
+++ b/editor/editor_inspector.cpp
@@ -644,7 +644,19 @@ void EditorProperty::_gui_input(const Ref<InputEvent> &p_event) {
emit_signal("property_keyed", property, use_keying_next());
if (use_keying_next()) {
- call_deferred("emit_changed", property, object->get(property).operator int64_t() + 1, "", false);
+ if (property == "frame_coords" && (object->is_class("Sprite") || object->is_class("Sprite3D"))) {
+ Vector2 new_coords = object->get(property);
+ new_coords.x++;
+ if (new_coords.x >= object->get("hframes").operator int64_t()) {
+ new_coords.x = 0;
+ new_coords.y++;
+ }
+
+ call_deferred("emit_changed", property, new_coords, "", false);
+ } else {
+ call_deferred("emit_changed", property, object->get(property).operator int64_t() + 1, "", false);
+ }
+
call_deferred("update_property");
}
}
@@ -1566,11 +1578,11 @@ void EditorInspector::update_tree() {
if (dot != -1) {
String ov = name.right(dot);
name = name.substr(0, dot);
- name = name.camelcase_to_underscore().capitalize();
+ name = name.capitalize();
name += ov;
} else {
- name = name.camelcase_to_underscore().capitalize();
+ name = name.capitalize();
}
}
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index 2c3a84857a..9fa33044e1 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -33,6 +33,7 @@
#include "core/bind/core_bind.h"
#include "core/class_db.h"
#include "core/io/config_file.h"
+#include "core/io/image_loader.h"
#include "core/io/resource_loader.h"
#include "core/io/resource_saver.h"
#include "core/io/stream_peer_ssl.h"
@@ -56,6 +57,7 @@
#include "editor/editor_help.h"
#include "editor/editor_properties.h"
#include "editor/editor_settings.h"
+#include "editor/editor_spin_slider.h"
#include "editor/editor_themes.h"
#include "editor/import/editor_import_collada.h"
#include "editor/import/editor_scene_importer_gltf.h"
@@ -370,7 +372,7 @@ void EditorNode::_notification(int p_what) {
case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
scene_tabs->set_tab_close_display_policy((bool(EDITOR_GET("interface/scene_tabs/always_show_close_button")) ? Tabs::CLOSE_BUTTON_SHOW_ALWAYS : Tabs::CLOSE_BUTTON_SHOW_ACTIVE_ONLY));
- Ref<Theme> theme = create_editor_theme(theme_base->get_theme());
+ theme = create_editor_theme(theme_base->get_theme());
theme_base->set_theme(theme);
gui_base->set_theme(theme);
@@ -1469,7 +1471,7 @@ void EditorNode::_dialog_action(String p_file) {
config.instance();
Error err = config->load(EditorSettings::get_singleton()->get_editor_layouts_config());
- if (err == ERR_CANT_OPEN) {
+ if (err == ERR_FILE_CANT_OPEN || err == ERR_FILE_NOT_FOUND) {
config.instance(); // new config
} else if (err != OK) {
show_warning(TTR("Error trying to save layout!"));
@@ -3558,6 +3560,7 @@ void EditorNode::register_editor_types() {
ClassDB::register_class<AnimationTrackEditPlugin>();
ClassDB::register_class<ScriptCreateDialog>();
ClassDB::register_class<EditorFeatureProfile>();
+ ClassDB::register_class<EditorSpinSlider>();
// FIXME: Is this stuff obsolete, or should it be ported to new APIs?
ClassDB::register_class<EditorScenePostImport>();
@@ -3637,6 +3640,20 @@ StringName EditorNode::get_object_custom_type_name(const Object *p_object) const
return StringName();
}
+Ref<ImageTexture> EditorNode::_load_custom_class_icon(const String &p_path) const {
+ if (p_path.length()) {
+ Ref<Image> img = memnew(Image);
+ Error err = ImageLoader::load_image(p_path, img);
+ if (err == OK) {
+ Ref<ImageTexture> icon = memnew(ImageTexture);
+ img->resize(16 * EDSCALE, 16 * EDSCALE, Image::INTERPOLATE_LANCZOS);
+ icon->create_from_image(img);
+ return icon;
+ }
+ }
+ return NULL;
+}
+
Ref<Texture> EditorNode::get_object_icon(const Object *p_object, const String &p_fallback) const {
ERR_FAIL_COND_V(!p_object || !gui_base, NULL);
@@ -3650,8 +3667,10 @@ Ref<Texture> EditorNode::get_object_icon(const Object *p_object, const String &p
while (base_script.is_valid()) {
StringName name = EditorNode::get_editor_data().script_class_get_name(base_script->get_path());
String icon_path = EditorNode::get_editor_data().script_class_get_icon_path(name);
- if (icon_path.length())
- return ResourceLoader::load(icon_path);
+ Ref<ImageTexture> icon = _load_custom_class_icon(icon_path);
+ if (icon.is_valid()) {
+ return icon;
+ }
// should probably be deprecated in 4.x
StringName base = base_script->get_instance_base_type();
@@ -3689,12 +3708,9 @@ Ref<Texture> EditorNode::get_class_icon(const String &p_class, const String &p_f
if (ScriptServer::is_global_class(p_class)) {
String icon_path = EditorNode::get_editor_data().script_class_get_icon_path(p_class);
- RES icon;
-
- if (FileAccess::exists(icon_path)) {
- icon = ResourceLoader::load(icon_path);
- if (icon.is_valid())
- return icon;
+ Ref<ImageTexture> icon = _load_custom_class_icon(icon_path);
+ if (icon.is_valid()) {
+ return icon;
}
Ref<Script> script = ResourceLoader::load(ScriptServer::get_global_class_path(p_class), "Script");
@@ -3702,10 +3718,9 @@ Ref<Texture> EditorNode::get_class_icon(const String &p_class, const String &p_f
while (script.is_valid()) {
String current_icon_path;
script->get_language()->get_global_class_name(script->get_path(), NULL, &current_icon_path);
- if (FileAccess::exists(current_icon_path)) {
- RES texture = ResourceLoader::load(current_icon_path);
- if (texture.is_valid())
- return texture;
+ icon = _load_custom_class_icon(current_icon_path);
+ if (icon.is_valid()) {
+ return icon;
}
script = script->get_base_script();
}
@@ -5638,6 +5653,9 @@ EditorNode::EditorNode() {
editor_export = memnew(EditorExport);
add_child(editor_export);
+ // Exporters might need the theme
+ theme = create_custom_theme();
+
register_exporters();
GLOBAL_DEF("editor/main_run_args", "");
@@ -5679,7 +5697,6 @@ EditorNode::EditorNode() {
theme_base->add_child(gui_base);
gui_base->set_anchors_and_margins_preset(Control::PRESET_WIDE);
- Ref<Theme> theme = create_custom_theme();
theme_base->set_theme(theme);
gui_base->set_theme(theme);
gui_base->add_style_override("panel", gui_base->get_stylebox("Background", "EditorStyles"));
diff --git a/editor/editor_node.h b/editor/editor_node.h
index 5ecb472e64..fb7e81d2d2 100644
--- a/editor/editor_node.h
+++ b/editor/editor_node.h
@@ -655,6 +655,7 @@ private:
void _feature_profile_changed();
bool _is_class_editor_disabled_by_feature_profile(const StringName &p_class);
+ Ref<ImageTexture> _load_custom_class_icon(const String &p_path) const;
protected:
void _notification(int p_what);
diff --git a/editor/editor_path.cpp b/editor/editor_path.cpp
index f487a3048b..e4a939c379 100644
--- a/editor/editor_path.cpp
+++ b/editor/editor_path.cpp
@@ -132,6 +132,15 @@ void EditorPath::_id_pressed(int p_idx) {
EditorNode::get_singleton()->push_item(obj);
}
+void EditorPath::_notification(int p_what) {
+
+ switch (p_what) {
+ case NOTIFICATION_THEME_CHANGED: {
+ update_path();
+ } break;
+ }
+}
+
void EditorPath::_bind_methods() {
ClassDB::bind_method("_about_to_show", &EditorPath::_about_to_show);
diff --git a/editor/editor_path.h b/editor/editor_path.h
index 2dc4d21f9b..a84da9f5ac 100644
--- a/editor/editor_path.h
+++ b/editor/editor_path.h
@@ -48,6 +48,7 @@ class EditorPath : public MenuButton {
void _add_children_to_popup(Object *p_obj, int p_depth = 0);
protected:
+ void _notification(int p_what);
static void _bind_methods();
public:
diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp
index 460f75eef0..d3d91e6e0d 100644
--- a/editor/editor_properties.cpp
+++ b/editor/editor_properties.cpp
@@ -2205,7 +2205,14 @@ void EditorPropertyResource::_menu_option(int p_which) {
case OBJ_MENU_NEW_SCRIPT: {
if (Object::cast_to<Node>(get_edited_object())) {
- EditorNode::get_singleton()->get_scene_tree_dock()->open_script_dialog(Object::cast_to<Node>(get_edited_object()));
+ EditorNode::get_singleton()->get_scene_tree_dock()->open_script_dialog(Object::cast_to<Node>(get_edited_object()), false);
+ }
+
+ } break;
+ case OBJ_MENU_EXTEND_SCRIPT: {
+
+ if (Object::cast_to<Node>(get_edited_object())) {
+ EditorNode::get_singleton()->get_scene_tree_dock()->open_script_dialog(Object::cast_to<Node>(get_edited_object()), true);
}
} break;
@@ -2338,7 +2345,8 @@ void EditorPropertyResource::_update_menu_items() {
menu->clear();
if (get_edited_property() == "script" && base_type == "Script" && Object::cast_to<Node>(get_edited_object())) {
- menu->add_icon_item(get_icon("Script", "EditorIcons"), TTR("New Script"), OBJ_MENU_NEW_SCRIPT);
+ menu->add_icon_item(get_icon("ScriptCreate", "EditorIcons"), TTR("New Script"), OBJ_MENU_NEW_SCRIPT);
+ menu->add_icon_item(get_icon("ScriptExtend", "EditorIcons"), TTR("Extend Script"), OBJ_MENU_EXTEND_SCRIPT);
menu->add_separator();
} else if (base_type != "") {
int idx = 0;
@@ -2399,19 +2407,11 @@ void EditorPropertyResource::_update_menu_items() {
inheritors_array.push_back(t);
- int id = TYPE_BASE_ID + idx;
-
- if (!icon.is_valid() && has_icon(t, "EditorIcons")) {
- icon = get_icon(t, "EditorIcons");
- }
-
- if (icon.is_valid()) {
+ if (!icon.is_valid())
+ icon = get_icon(has_icon(t, "EditorIcons") ? t : "Object", "EditorIcons");
- menu->add_icon_item(icon, vformat(TTR("New %s"), t), id);
- } else {
-
- menu->add_item(vformat(TTR("New %s"), t), id);
- }
+ int id = TYPE_BASE_ID + idx;
+ menu->add_icon_item(icon, vformat(TTR("New %s"), t), id);
idx++;
}
@@ -2615,14 +2615,6 @@ void EditorPropertyResource::update_property() {
get_tree()->call_deferred("call_group", "_editor_resource_properties", "_fold_other_editors", this);
}
opened_editor = true;
- /*
- Button *open_in_editor = memnew(Button);
- open_in_editor->set_text(TTR("Open Editor"));
- open_in_editor->set_icon(get_icon("Edit", "EditorIcons"));
- sub_inspector_vbox->add_child(open_in_editor);
- open_in_editor->connect("pressed", this, "_open_editor_pressed");
- open_in_editor->set_h_size_flags(SIZE_SHRINK_CENTER);
- */
}
}
@@ -2649,10 +2641,9 @@ void EditorPropertyResource::update_property() {
if (res == RES()) {
assign->set_icon(Ref<Texture>());
assign->set_text(TTR("[empty]"));
- assign->set_tooltip("");
} else {
- assign->set_icon(EditorNode::get_singleton()->get_object_icon(res.operator->(), "Node"));
+ assign->set_icon(EditorNode::get_singleton()->get_object_icon(res.operator->(), "Object"));
if (res->get_name() != String()) {
assign->set_text(res->get_name());
diff --git a/editor/editor_properties.h b/editor/editor_properties.h
index b8d6aa00c2..952b0447e2 100644
--- a/editor/editor_properties.h
+++ b/editor/editor_properties.h
@@ -550,7 +550,8 @@ class EditorPropertyResource : public EditorProperty {
OBJ_MENU_COPY = 5,
OBJ_MENU_PASTE = 6,
OBJ_MENU_NEW_SCRIPT = 7,
- OBJ_MENU_SHOW_IN_FILE_SYSTEM = 8,
+ OBJ_MENU_EXTEND_SCRIPT = 8,
+ OBJ_MENU_SHOW_IN_FILE_SYSTEM = 9,
TYPE_BASE_ID = 100,
CONVERT_BASE_ID = 1000
diff --git a/editor/editor_run_native.cpp b/editor/editor_run_native.cpp
index 585ea0ec69..64e90f2488 100644
--- a/editor/editor_run_native.cpp
+++ b/editor/editor_run_native.cpp
@@ -75,20 +75,18 @@ void EditorRunNative::_notification(int p_what) {
Ref<EditorExportPlatform> eep = EditorExport::get_singleton()->get_export_platform(E->key());
MenuButton *mb = E->get();
- int dc = eep->get_device_count();
+ int dc = eep->get_options_count();
if (dc == 0) {
mb->hide();
} else {
mb->get_popup()->clear();
mb->show();
- if (dc == 1) {
- mb->set_tooltip(eep->get_device_name(0) + "\n\n" + eep->get_device_info(0).strip_edges());
- } else {
- mb->set_tooltip("Select device from the list");
+ mb->set_tooltip(eep->get_options_tooltip());
+ if (dc > 1) {
for (int i = 0; i < dc; i++) {
- mb->get_popup()->add_icon_item(get_icon("Play", "EditorIcons"), eep->get_device_name(i));
- mb->get_popup()->set_item_tooltip(mb->get_popup()->get_item_count() - 1, eep->get_device_info(i).strip_edges());
+ mb->get_popup()->add_icon_item(eep->get_option_icon(i), eep->get_option_label(i));
+ mb->get_popup()->set_item_tooltip(mb->get_popup()->get_item_count() - 1, eep->get_option_tooltip(i));
}
}
}
@@ -111,7 +109,7 @@ void EditorRunNative::_run_native(int p_idx, int p_platform) {
ERR_FAIL_COND(eep.is_null());
if (p_idx == -1) {
- if (eep->get_device_count() == 1) {
+ if (eep->get_options_count() == 1) {
menus[p_platform]->get_popup()->hide();
p_idx = 0;
} else {
diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp
index 3ea59115b0..a3a02dbd4c 100644
--- a/editor/editor_settings.cpp
+++ b/editor/editor_settings.cpp
@@ -436,7 +436,7 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
_initial_set("text_editor/indent/size", 4);
hints["text_editor/indent/size"] = PropertyInfo(Variant::INT, "text_editor/indent/size", PROPERTY_HINT_RANGE, "1, 64, 1"); // size of 0 crashes.
_initial_set("text_editor/indent/auto_indent", true);
- _initial_set("text_editor/indent/convert_indent_on_save", false);
+ _initial_set("text_editor/indent/convert_indent_on_save", true);
_initial_set("text_editor/indent/draw_tabs", true);
_initial_set("text_editor/indent/draw_spaces", false);
@@ -559,8 +559,6 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
hints["editors/3d/freelook/freelook_base_speed"] = PropertyInfo(Variant::REAL, "editors/3d/freelook/freelook_base_speed", PROPERTY_HINT_RANGE, "0.0, 10, 0.01");
_initial_set("editors/3d/freelook/freelook_activation_modifier", 0);
hints["editors/3d/freelook/freelook_activation_modifier"] = PropertyInfo(Variant::INT, "editors/3d/freelook/freelook_activation_modifier", PROPERTY_HINT_ENUM, "None,Shift,Alt,Meta,Ctrl");
- _initial_set("editors/3d/freelook/freelook_modifier_speed_factor", 3.0);
- hints["editors/3d/freelook/freelook_modifier_speed_factor"] = PropertyInfo(Variant::REAL, "editors/3d/freelook/freelook_modifier_speed_factor", PROPERTY_HINT_RANGE, "0.0, 10.0, 0.1");
_initial_set("editors/3d/freelook/freelook_speed_zoom_link", false);
// 2D
diff --git a/editor/editor_spin_slider.cpp b/editor/editor_spin_slider.cpp
index 918b0ef96d..d80176f00d 100644
--- a/editor/editor_spin_slider.cpp
+++ b/editor/editor_spin_slider.cpp
@@ -228,9 +228,9 @@ void EditorSpinSlider::_notification(int p_what) {
draw_style_box(focus, Rect2(Vector2(), get_size()));
}
- draw_string(font, Vector2(sb->get_offset().x, vofs), label, lc * Color(1, 1, 1, 0.5));
+ draw_string(font, Vector2(Math::round(sb->get_offset().x), vofs), label, lc * Color(1, 1, 1, 0.5));
- draw_string(font, Vector2(sb->get_offset().x + string_width + sep, vofs), numstr, fc, number_width);
+ draw_string(font, Vector2(Math::round(sb->get_offset().x + string_width + sep), vofs), numstr, fc, number_width);
if (get_step() == 1) {
Ref<Texture> updown2 = get_icon("updown", "SpinBox");
diff --git a/editor/export_template_manager.cpp b/editor/export_template_manager.cpp
index 1cdf9848ef..f47f9b8b92 100644
--- a/editor/export_template_manager.cpp
+++ b/editor/export_template_manager.cpp
@@ -69,9 +69,15 @@ void ExportTemplateManager::_update_template_list() {
memdelete(d);
String current_version = VERSION_FULL_CONFIG;
- // Downloadable export templates are only available for stable, alpha, beta and RC versions.
+ // Downloadable export templates are only available for stable and official alpha/beta/RC builds
+ // (which always have a number following their status, e.g. "alpha1").
// Therefore, don't display download-related features when using a development version
- const bool downloads_available = String(VERSION_STATUS) != String("dev");
+ // (whose builds aren't numbered).
+ const bool downloads_available =
+ String(VERSION_STATUS) != String("dev") &&
+ String(VERSION_STATUS) != String("alpha") &&
+ String(VERSION_STATUS) != String("beta") &&
+ String(VERSION_STATUS) != String("rc");
Label *current = memnew(Label);
current->set_h_size_flags(SIZE_EXPAND_FILL);
@@ -155,38 +161,27 @@ void ExportTemplateManager::_uninstall_template(const String &p_version) {
void ExportTemplateManager::_uninstall_template_confirm() {
- DirAccess *d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
- Error err = d->change_dir(EditorSettings::get_singleton()->get_templates_dir());
-
- ERR_FAIL_COND(err != OK);
-
- err = d->change_dir(to_remove);
-
- ERR_FAIL_COND(err != OK);
-
- Vector<String> files;
- d->list_dir_begin();
- String c = d->get_next();
- while (c != String()) {
- if (!d->current_is_dir()) {
- files.push_back(c);
- }
- c = d->get_next();
- }
- d->list_dir_end();
+ DirAccessRef da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
+ const String &templates_dir = EditorSettings::get_singleton()->get_templates_dir();
+ Error err = da->change_dir(templates_dir);
+ ERR_FAIL_COND_MSG(err != OK, "Could not access templates directory at '" + templates_dir + "'.");
+ err = da->change_dir(to_remove);
+ ERR_FAIL_COND_MSG(err != OK, "Could not access templates directory at '" + templates_dir.plus_file(to_remove) + "'.");
- for (int i = 0; i < files.size(); i++) {
- d->remove(files[i]);
- }
+ err = da->erase_contents_recursive();
+ ERR_FAIL_COND_MSG(err != OK, "Could not remove all templates in '" + templates_dir.plus_file(to_remove) + "'.");
- d->change_dir("..");
- d->remove(to_remove);
+ da->change_dir("..");
+ da->remove(to_remove);
+ ERR_FAIL_COND_MSG(err != OK, "Could not remove templates directory at '" + templates_dir.plus_file(to_remove) + "'.");
_update_template_list();
}
bool ExportTemplateManager::_install_from_file(const String &p_file, bool p_use_progress) {
+ // unzClose() will take care of closing the file stored in the unzFile,
+ // so we don't need to `memdelete(fa)` in this method.
FileAccess *fa = NULL;
zlib_filefunc_def io = zipio_create_io_from_file(&fa);
@@ -251,7 +246,7 @@ bool ExportTemplateManager::_install_from_file(const String &p_file, bool p_use_
String template_path = EditorSettings::get_singleton()->get_templates_dir().plus_file(version);
- DirAccess *d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
+ DirAccessRef d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
Error err = d->make_dir_recursive(template_path);
if (err != OK) {
EditorNode::get_singleton()->show_warning(TTR("Error creating path for templates:") + "\n" + template_path);
@@ -259,8 +254,6 @@ bool ExportTemplateManager::_install_from_file(const String &p_file, bool p_use_
return false;
}
- memdelete(d);
-
ret = unzGoToFirstFile(pkg);
EditorProgress *p = NULL;
@@ -316,7 +309,7 @@ bool ExportTemplateManager::_install_from_file(const String &p_file, bool p_use_
}
String to_write = template_path.plus_file(file);
- FileAccess *f = FileAccess::open(to_write, FileAccess::WRITE);
+ FileAccessRef f = FileAccess::open(to_write, FileAccess::WRITE);
if (!f) {
ret = unzGoToNextFile(pkg);
@@ -326,8 +319,6 @@ bool ExportTemplateManager::_install_from_file(const String &p_file, bool p_use_
f->store_buffer(data.ptr(), data.size());
- memdelete(f);
-
#ifndef WINDOWS_ENABLED
FileAccess::set_unix_permissions(to_write, (info.external_fa >> 16) & 0x01FF);
#endif
@@ -343,7 +334,6 @@ bool ExportTemplateManager::_install_from_file(const String &p_file, bool p_use_
unzClose(pkg);
_update_template_list();
-
return true;
}
diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp
index e3f0021fbc..be05183f92 100644
--- a/editor/filesystem_dock.cpp
+++ b/editor/filesystem_dock.cpp
@@ -333,10 +333,11 @@ void FileSystemDock::_notification(int p_what) {
case NOTIFICATION_DRAG_BEGIN: {
Dictionary dd = get_viewport()->gui_get_drag_data();
if (tree->is_visible_in_tree() && dd.has("type")) {
- if ((String(dd["type"]) == "files") || (String(dd["type"]) == "files_and_dirs") || (String(dd["type"]) == "resource")) {
+ if (dd.has("favorite")) {
+ if ((String(dd["favorite"]) == "all"))
+ tree->set_drop_mode_flags(Tree::DROP_MODE_INBETWEEN);
+ } else if ((String(dd["type"]) == "files") || (String(dd["type"]) == "files_and_dirs") || (String(dd["type"]) == "resource")) {
tree->set_drop_mode_flags(Tree::DROP_MODE_ON_ITEM | Tree::DROP_MODE_INBETWEEN);
- } else if ((String(dd["type"]) == "favorite")) {
- tree->set_drop_mode_flags(Tree::DROP_MODE_INBETWEEN);
}
}
} break;
@@ -1839,7 +1840,7 @@ Variant FileSystemDock::get_drag_data_fw(const Point2 &p_point, Control *p_from)
all_not_favorites &= !is_favorite;
selected = tree->get_next_selected(selected);
}
- if (all_favorites) {
+ if (!all_not_favorites) {
paths = _tree_get_selected(false);
} else {
paths = _tree_get_selected();
@@ -1857,12 +1858,9 @@ Variant FileSystemDock::get_drag_data_fw(const Point2 &p_point, Control *p_from)
if (paths.empty())
return Variant();
- if (!all_favorites && !all_not_favorites)
- return Variant();
-
Dictionary drag_data = EditorNode::get_singleton()->drag_files_and_dirs(paths, p_from);
- if (all_favorites) {
- drag_data["type"] = "favorite";
+ if (!all_not_favorites) {
+ drag_data["favorite"] = all_favorites ? "all" : "mixed";
}
return drag_data;
}
@@ -1870,7 +1868,11 @@ Variant FileSystemDock::get_drag_data_fw(const Point2 &p_point, Control *p_from)
bool FileSystemDock::can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const {
Dictionary drag_data = p_data;
- if (drag_data.has("type") && String(drag_data["type"]) == "favorite") {
+ if (drag_data.has("favorite")) {
+
+ if (String(drag_data["favorite"]) != "all") {
+ return false;
+ }
// Moving favorite around.
TreeItem *ti = tree->get_item_at_position(p_point);
@@ -1937,7 +1939,11 @@ void FileSystemDock::drop_data_fw(const Point2 &p_point, const Variant &p_data,
Vector<String> dirs = EditorSettings::get_singleton()->get_favorites();
- if (drag_data.has("type") && String(drag_data["type"]) == "favorite") {
+ if (drag_data.has("favorite")) {
+
+ if (String(drag_data["favorite"]) != "all") {
+ return;
+ }
// Moving favorite around.
TreeItem *ti = tree->get_item_at_position(p_point);
if (!ti)
diff --git a/editor/icons/icon_crypto_key.svg b/editor/icons/icon_crypto_key.svg
new file mode 100644
index 0000000000..45b53c815d
--- /dev/null
+++ b/editor/icons/icon_crypto_key.svg
@@ -0,0 +1 @@
+<svg height="16" viewBox="0 0 4.233 4.233" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m2.397.34-.374.373-.375.374v.375l.188.187-1.497 1.496v.375l.374.374h.374l.187-.188.282-.092.092-.282.282-.093.093-.28.094-.28.28-.095.187-.187.187.187h.374l.375-.375.373-.373.001-.374-1.122-1.122zm.374.858a.264.264 0 1 1 .002.528.264.264 0 0 1 -.002-.528z" fill="#e0e0e0"/></svg> \ No newline at end of file
diff --git a/editor/icons/icon_x509_certificate.svg b/editor/icons/icon_x509_certificate.svg
new file mode 100644
index 0000000000..e175fa3234
--- /dev/null
+++ b/editor/icons/icon_x509_certificate.svg
@@ -0,0 +1 @@
+<svg height="16" viewBox="0 0 4.233 4.233" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m3.967.263-3.704.001v2.646h1.427a.993.993 0 0 1 -.022-.096.993.993 0 0 1 -.012-.099.993.993 0 0 1 -.002-.07.993.993 0 0 1 .005-.1.993.993 0 0 1 .014-.097.993.993 0 0 1 .025-.096.993.993 0 0 1 .034-.093.993.993 0 0 1 .043-.09.993.993 0 0 1 .052-.085.993.993 0 0 1 .06-.079.993.993 0 0 1 .068-.072.993.993 0 0 1 .074-.066.993.993 0 0 1 .08-.057.993.993 0 0 1 .087-.05.993.993 0 0 1 .09-.04.993.993 0 0 1 .095-.031.993.993 0 0 1 .096-.022.993.993 0 0 1 .099-.012.993.993 0 0 1 .07-.003.993.993 0 0 1 .099.006.993.993 0 0 1 .098.014.993.993 0 0 1 .096.025.993.993 0 0 1 .094.034.993.993 0 0 1 .089.043.993.993 0 0 1 .084.052.993.993 0 0 1 .08.06.993.993 0 0 1 .072.068.993.993 0 0 1 .065.074.993.993 0 0 1 .058.08.993.993 0 0 1 .05.087.993.993 0 0 1 .04.09.993.993 0 0 1 .031.095.993.993 0 0 1 .022.096.993.993 0 0 1 .012.099.993.993 0 0 1 .002.07.993.993 0 0 1 -.004.1.993.993 0 0 1 -.015.097.993.993 0 0 1 -.017.068h.365z" fill="#e0e0e0"/><g fill="#ff8484"><path d="m2.116 3.175v.793l.53-.253.529.253v-.793z"/><circle cx="2.646" cy="2.645" r=".794"/></g></svg> \ No newline at end of file
diff --git a/editor/import/editor_scene_importer_gltf.cpp b/editor/import/editor_scene_importer_gltf.cpp
index 49091dc812..fcf0e4af6f 100644
--- a/editor/import/editor_scene_importer_gltf.cpp
+++ b/editor/import/editor_scene_importer_gltf.cpp
@@ -1973,7 +1973,7 @@ Error EditorSceneImporterGLTF::_reparent_to_fake_joint(GLTFState &state, GLTFSke
state.nodes.push_back(fake_joint);
// We better not be a joint, or we messed up in our logic
- if (node->joint == true)
+ if (node->joint)
return FAILED;
fake_joint->translation = node->translation;
diff --git a/editor/import/resource_importer_obj.h b/editor/import/resource_importer_obj.h
index b96bc1b656..adad21da61 100644
--- a/editor/import/resource_importer_obj.h
+++ b/editor/import/resource_importer_obj.h
@@ -31,7 +31,7 @@
#ifndef RESOURCEIMPORTEROBJ_H
#define RESOURCEIMPORTEROBJ_H
-#include "import/resource_importer_scene.h"
+#include "resource_importer_scene.h"
class EditorOBJImporter : public EditorSceneImporter {
diff --git a/editor/node_dock.cpp b/editor/node_dock.cpp
index d6df3bd369..7ba1796600 100644
--- a/editor/node_dock.cpp
+++ b/editor/node_dock.cpp
@@ -129,6 +129,7 @@ NodeDock::NodeDock() {
select_a_node = memnew(Label);
select_a_node->set_text(TTR("Select a single node to edit its signals and groups."));
+ select_a_node->set_custom_minimum_size(Size2(100 * EDSCALE, 0));
select_a_node->set_v_size_flags(SIZE_EXPAND_FILL);
select_a_node->set_valign(Label::VALIGN_CENTER);
select_a_node->set_align(Label::ALIGN_CENTER);
diff --git a/editor/output_strings.cpp b/editor/output_strings.cpp
deleted file mode 100644
index baabaff9a8..0000000000
--- a/editor/output_strings.cpp
+++ /dev/null
@@ -1,208 +0,0 @@
-/*************************************************************************/
-/* output_strings.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-
-#include "output_strings.h"
-
-void OutputStrings::update_scrollbars() {
-
- Size2 hmin = h_scroll->get_combined_minimum_size();
- Size2 vmin = v_scroll->get_combined_minimum_size();
-
- v_scroll->set_anchor(MARGIN_LEFT, ANCHOR_END);
- v_scroll->set_anchor(MARGIN_RIGHT, ANCHOR_END);
- v_scroll->set_anchor(MARGIN_BOTTOM, ANCHOR_END);
-
- v_scroll->set_begin(Point2(-vmin.width, 0));
- v_scroll->set_end(Point2(0, 0));
-
- h_scroll->set_anchor(MARGIN_RIGHT, ANCHOR_END);
- h_scroll->set_anchor(MARGIN_TOP, ANCHOR_END);
- h_scroll->set_anchor(MARGIN_BOTTOM, ANCHOR_END);
-
- h_scroll->set_begin(Point2(0, -hmin.y));
- h_scroll->set_end(Point2(-vmin.x, 0));
-
- margin.y = hmin.y;
- margin.x = vmin.x;
-
- Ref<StyleBox> tree_st = get_stylebox("bg", "Tree");
- int page = ((size_height - (int)margin.y - tree_st->get_margin(MARGIN_TOP)) / font_height);
- v_scroll->set_page(page);
-}
-
-void OutputStrings::_notification(int p_what) {
-
- switch (p_what) {
-
- case NOTIFICATION_DRAW: {
-
- if (following) {
-
- updating = true;
- v_scroll->set_value(v_scroll->get_max() - v_scroll->get_page());
- updating = false;
- }
-
- RID ci = get_canvas_item();
- Size2 size = get_size();
-
- Ref<Font> font = get_font("font", "Tree");
- Ref<StyleBox> tree_st = get_stylebox("bg", "Tree");
- tree_st->draw(ci, Rect2(Point2(), size));
- Color color = get_color("font_color", "Tree");
- Ref<Texture> icon_error = get_icon("Error", "EditorIcons");
- Ref<Texture> icon_warning = get_icon("Warning", "EditorIcons");
-
- //int lines = (size_height-(int)margin.y) / font_height;
- Point2 ofs = tree_st->get_offset();
-
- LineMap::Element *E = line_map.find(v_scroll->get_value());
- float h_ofs = (int)h_scroll->get_value();
- Point2 icon_ofs = Point2(0, (font_height - (int)icon_error->get_height()) / 2);
-
- FontDrawer drawer(font, Color(1, 1, 1));
- while (E && ofs.y < (size_height - (int)margin.y)) {
-
- String str = E->get().text;
- Point2 line_ofs = ofs;
-
- switch (E->get().type) {
-
- case LINE_WARNING: {
- icon_warning->draw(ci, line_ofs + icon_ofs);
-
- } break;
- case LINE_ERROR: {
- icon_error->draw(ci, line_ofs + icon_ofs);
- } break;
- case LINE_LINK: {
-
- } break;
- default: {
- }
- }
-
- line_ofs.y += font->get_ascent();
- line_ofs.x += icon_error->get_width() + 4;
-
- for (int i = 0; i < str.length(); i++) {
- if (line_ofs.x - h_ofs < 0) {
- line_ofs.x += font->get_char_size(str[i], str[i + 1]).width;
- } else if (line_ofs.x - h_ofs > size.width - margin.width) {
- break;
- } else {
- line_ofs.x += font->draw_char(ci, Point2(line_ofs.x - h_ofs, line_ofs.y), str[i], str[i + 1], color);
- }
- }
-
- ofs.y += font_height;
- E = E->next();
- }
-
- } break;
-
- case NOTIFICATION_ENTER_TREE:
- case NOTIFICATION_RESIZED: {
-
- font_height = get_font("font", "Tree")->get_height();
- size_height = get_size().height;
- update_scrollbars();
- } break;
- }
-}
-
-void OutputStrings::_hscroll_changed(float p_value) {
-
- if (updating)
- return;
-
- update();
-}
-void OutputStrings::_vscroll_changed(float p_value) {
-
- if (updating)
- return;
- //user changed scroll
- following = (p_value + v_scroll->get_page()) >= v_scroll->get_max();
- update();
-}
-
-void OutputStrings::add_line(const String &p_text, const Variant &p_meta, const LineType p_type) {
-
- Vector<String> strings = p_text.split("\n");
-
- for (int i = 0; i < strings.size(); i++) {
-
- if (strings[i].length() == 0)
- continue;
-
- int last = line_map.empty() ? 0 : (line_map.back()->key() + 1);
-
- Line l;
- l.text = strings[i];
- l.meta = p_meta;
- l.type = p_type;
- line_map.insert(last, l);
-
- updating = true;
- v_scroll->set_max(last + 1);
- v_scroll->set_min(line_map.front()->key());
- updating = false;
- }
-
- while (line_map.size() > line_max_count) {
-
- line_map.erase(line_map.front());
- }
-
- update();
-}
-
-void OutputStrings::_bind_methods() {
-
- ClassDB::bind_method("_vscroll_changed", &OutputStrings::_vscroll_changed);
- ClassDB::bind_method("_hscroll_changed", &OutputStrings::_hscroll_changed);
-}
-
-OutputStrings::OutputStrings() {
-
- following = true;
- updating = false;
- line_max_count = 4096;
- h_scroll = memnew(HScrollBar);
- v_scroll = memnew(VScrollBar);
- add_child(h_scroll);
- add_child(v_scroll);
- size_height = 1;
- font_height = 1;
- update_scrollbars();
- h_scroll->connect("value_changed", this, "_hscroll_changed");
- v_scroll->connect("value_changed", this, "_vscroll_changed");
-}
diff --git a/editor/output_strings.h b/editor/output_strings.h
deleted file mode 100644
index 4fd3f7d836..0000000000
--- a/editor/output_strings.h
+++ /dev/null
@@ -1,87 +0,0 @@
-/*************************************************************************/
-/* output_strings.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-
-#ifndef OUTPUT_STRINGS_H
-#define OUTPUT_STRINGS_H
-
-#include "core/map.h"
-#include "scene/gui/control.h"
-#include "scene/gui/scroll_bar.h"
-
-class OutputStrings : public Control {
-
- GDCLASS(OutputStrings, Control);
-
-public:
- enum LineType {
-
- LINE_NORMAL,
- LINE_WARNING,
- LINE_ERROR,
- LINE_LINK
- };
-
-private:
- struct Line {
-
- LineType type;
- Variant meta;
- String text;
- };
-
- int font_height;
- int size_height;
-
- Size2 margin;
- typedef Map<int, Line> LineMap;
- Map<int, Line> line_map;
-
- VScrollBar *v_scroll;
- HScrollBar *h_scroll;
-
- bool following;
- int line_max_count;
- bool updating;
-
- void _vscroll_changed(float p_value);
- void _hscroll_changed(float p_value);
- void update_scrollbars();
-
-protected:
- static void _bind_methods();
- void _notification(int p_what);
-
-public:
- void add_line(const String &p_text, const Variant &p_meta = Variant(), const LineType p_type = LINE_NORMAL);
-
- OutputStrings();
-};
-
-#endif // OUTPUT_STRINGS_H
diff --git a/editor/plugins/asset_library_editor_plugin.cpp b/editor/plugins/asset_library_editor_plugin.cpp
index 3d161dc5b9..95767a96d8 100644
--- a/editor/plugins/asset_library_editor_plugin.cpp
+++ b/editor/plugins/asset_library_editor_plugin.cpp
@@ -32,8 +32,8 @@
#include "core/io/json.h"
#include "core/version.h"
-#include "editor_node.h"
-#include "editor_settings.h"
+#include "editor/editor_node.h"
+#include "editor/editor_settings.h"
void EditorAssetLibraryItem::configure(const String &p_title, int p_asset_id, const String &p_category, int p_category_id, const String &p_author, int p_author_id, const String &p_cost) {
@@ -1137,9 +1137,12 @@ void EditorAssetLibrary::_http_request_completed(int p_status, int p_code, const
initial_loading = false;
- // The loading text only needs to be displayed before the first page is loaded
+ // The loading text only needs to be displayed before the first page is loaded.
+ // Therefore, we don't need to show it again.
library_loading->hide();
+ library_error->hide();
+
if (asset_items) {
memdelete(asset_items);
}
@@ -1187,6 +1190,11 @@ void EditorAssetLibrary::_http_request_completed(int p_status, int p_code, const
asset_bottom_page = _make_pages(page, pages, page_len, total_items, result.size());
library_vb->add_child(asset_bottom_page);
+ if (result.empty()) {
+ library_error->set_text(vformat(TTR("No results for \"%s\"."), filter->get_text()));
+ library_error->show();
+ }
+
for (int i = 0; i < result.size(); i++) {
Dictionary r = result[i];
@@ -1453,6 +1461,11 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) {
library_loading->set_align(Label::ALIGN_CENTER);
library_vb->add_child(library_loading);
+ library_error = memnew(Label);
+ library_error->set_align(Label::ALIGN_CENTER);
+ library_error->hide();
+ library_vb->add_child(library_error);
+
asset_top_page = memnew(HBoxContainer);
library_vb->add_child(asset_top_page);
diff --git a/editor/plugins/asset_library_editor_plugin.h b/editor/plugins/asset_library_editor_plugin.h
index 7e934ac6cb..70ffbd9eed 100644
--- a/editor/plugins/asset_library_editor_plugin.h
+++ b/editor/plugins/asset_library_editor_plugin.h
@@ -31,24 +31,22 @@
#ifndef ASSET_LIBRARY_EDITOR_PLUGIN_H
#define ASSET_LIBRARY_EDITOR_PLUGIN_H
-#include "editor_plugin.h"
+#include "editor/editor_asset_installer.h"
+#include "editor/editor_plugin.h"
+#include "editor/editor_plugin_settings.h"
#include "scene/gui/box_container.h"
#include "scene/gui/check_box.h"
+#include "scene/gui/grid_container.h"
#include "scene/gui/line_edit.h"
#include "scene/gui/link_button.h"
#include "scene/gui/option_button.h"
#include "scene/gui/panel_container.h"
#include "scene/gui/progress_bar.h"
-#include "scene/gui/separator.h"
-#include "scene/gui/tab_container.h"
-
-#include "editor_plugin_settings.h"
-#include "scene/gui/grid_container.h"
#include "scene/gui/rich_text_label.h"
#include "scene/gui/scroll_container.h"
+#include "scene/gui/separator.h"
+#include "scene/gui/tab_container.h"
#include "scene/gui/texture_button.h"
-
-#include "editor_asset_installer.h"
#include "scene/main/http_request.h"
class EditorAssetLibraryItem : public PanelContainer {
@@ -186,6 +184,7 @@ class EditorAssetLibrary : public PanelContainer {
ScrollContainer *library_scroll;
VBoxContainer *library_vb;
Label *library_loading;
+ Label *library_error;
LineEdit *filter;
OptionButton *categories;
OptionButton *repository;
diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp
index f54411c72b..7659363cdf 100644
--- a/editor/plugins/canvas_item_editor_plugin.cpp
+++ b/editor/plugins/canvas_item_editor_plugin.cpp
@@ -284,7 +284,7 @@ Point2 CanvasItemEditor::snap_point(Point2 p_target, unsigned int p_modes, unsig
snap_target[0] = SNAP_TARGET_NONE;
snap_target[1] = SNAP_TARGET_NONE;
- bool is_snap_active = snap_active ^ Input::get_singleton()->is_key_pressed(KEY_CONTROL);
+ bool is_snap_active = smart_snap_active ^ Input::get_singleton()->is_key_pressed(KEY_CONTROL);
// Smart snap using the canvas position
Vector2 output = p_target;
@@ -384,7 +384,7 @@ Point2 CanvasItemEditor::snap_point(Point2 p_target, unsigned int p_modes, unsig
}
}
- if (((is_snap_active && snap_grid && (p_modes & SNAP_GRID)) || (p_forced_modes & SNAP_GRID)) && fmod(rotation, (real_t)360.0) == 0.0) {
+ if (((grid_snap_active && (p_modes & SNAP_GRID)) || (p_forced_modes & SNAP_GRID)) && fmod(rotation, (real_t)360.0) == 0.0) {
// Grid
Point2 offset = grid_offset;
if (snap_relative) {
@@ -412,7 +412,7 @@ Point2 CanvasItemEditor::snap_point(Point2 p_target, unsigned int p_modes, unsig
}
float CanvasItemEditor::snap_angle(float p_target, float p_start) const {
- return (((snap_active || snap_rotation) ^ Input::get_singleton()->is_key_pressed(KEY_CONTROL)) && snap_rotation_step != 0) ? Math::stepify(p_target - snap_rotation_offset, snap_rotation_step) + snap_rotation_offset : p_target;
+ return (((smart_snap_active || snap_rotation) ^ Input::get_singleton()->is_key_pressed(KEY_CONTROL)) && snap_rotation_step != 0) ? Math::stepify(p_target - snap_rotation_offset, snap_rotation_step) + snap_rotation_offset : p_target;
}
void CanvasItemEditor::_unhandled_key_input(const Ref<InputEvent> &p_ev) {
@@ -427,11 +427,11 @@ void CanvasItemEditor::_unhandled_key_input(const Ref<InputEvent> &p_ev) {
}
if (k->is_pressed() && !k->get_control() && !k->is_echo()) {
- if ((snap_grid || show_grid) && multiply_grid_step_shortcut.is_valid() && multiply_grid_step_shortcut->is_shortcut(p_ev)) {
+ if ((grid_snap_active || show_grid) && multiply_grid_step_shortcut.is_valid() && multiply_grid_step_shortcut->is_shortcut(p_ev)) {
// Multiply the grid size
grid_step_multiplier = MIN(grid_step_multiplier + 1, 12);
viewport->update();
- } else if ((snap_grid || show_grid) && divide_grid_step_shortcut.is_valid() && divide_grid_step_shortcut->is_shortcut(p_ev)) {
+ } else if ((grid_snap_active || show_grid) && divide_grid_step_shortcut.is_valid() && divide_grid_step_shortcut->is_shortcut(p_ev)) {
// Divide the grid size
Point2 new_grid_step = grid_step * Math::pow(2.0, grid_step_multiplier - 1);
if (new_grid_step.x >= 1.0 && new_grid_step.y >= 1.0)
@@ -1197,7 +1197,7 @@ bool CanvasItemEditor::_gui_input_zoom_or_pan(const Ref<InputEvent> &p_event, bo
//Pan the viewport
panning = true;
}
- } else if (panning) {
+ } else {
if (!k->is_pressed()) {
// Stop panning the viewport (for any mouse button press)
panning = false;
@@ -2274,7 +2274,7 @@ bool CanvasItemEditor::_gui_input_ruler_tool(const Ref<InputEvent> &p_event) {
Point2 previous_origin = ruler_tool_origin;
if (!ruler_tool_active)
- ruler_tool_origin = snap_point(viewport->get_local_mouse_position() / zoom + view_offset) * zoom;
+ ruler_tool_origin = snap_point(viewport->get_local_mouse_position() / zoom + view_offset);
if (b.is_valid() && b->get_button_index() == BUTTON_LEFT) {
if (b->is_pressed()) {
@@ -2287,9 +2287,7 @@ bool CanvasItemEditor::_gui_input_ruler_tool(const Ref<InputEvent> &p_event) {
return true;
}
- bool is_snap_active = snap_active ^ Input::get_singleton()->is_key_pressed(KEY_CONTROL);
-
- if (m.is_valid() && (ruler_tool_active || (is_snap_active && previous_origin != ruler_tool_origin))) {
+ if (m.is_valid() && (ruler_tool_active || (grid_snap_active && previous_origin != ruler_tool_origin))) {
viewport->update();
return true;
@@ -2558,11 +2556,10 @@ void CanvasItemEditor::_draw_rulers() {
Color font_color = get_color("font_color", "Editor");
font_color.a = 0.8;
Ref<Font> font = get_font("rulers", "EditorFonts");
- bool is_snap_active = snap_active ^ Input::get_singleton()->is_key_pressed(KEY_CONTROL);
// The rule transform
Transform2D ruler_transform = Transform2D();
- if (show_grid || (is_snap_active && snap_grid)) {
+ if (show_grid || grid_snap_active) {
List<CanvasItem *> selection = _get_edited_canvas_items();
if (snap_relative && selection.size() > 0) {
ruler_transform.translate(_get_encompassing_rect_from_list(selection).position);
@@ -2642,7 +2639,7 @@ void CanvasItemEditor::_draw_rulers() {
}
void CanvasItemEditor::_draw_grid() {
- if (show_grid) {
+ if (show_grid || grid_snap_active) {
//Draw the grid
Size2 s = viewport->get_size();
int last_cell = 0;
@@ -2688,19 +2685,17 @@ void CanvasItemEditor::_draw_ruler_tool() {
if (tool != TOOL_RULER)
return;
- bool is_snap_active = snap_active ^ Input::get_singleton()->is_key_pressed(KEY_CONTROL);
-
if (ruler_tool_active) {
Color ruler_primary_color = get_color("accent_color", "Editor");
Color ruler_secondary_color = ruler_primary_color;
ruler_secondary_color.a = 0.5;
- Point2 begin = ruler_tool_origin - view_offset * zoom;
+ Point2 begin = (ruler_tool_origin - view_offset) * zoom;
Point2 end = snap_point(viewport->get_local_mouse_position() / zoom + view_offset) * zoom - view_offset * zoom;
Point2 corner = Point2(begin.x, end.y);
Vector2 length_vector = (begin - end).abs() / zoom;
- bool draw_secondary_lines = (begin.y != corner.y && end.x != corner.x);
+ bool draw_secondary_lines = !(Math::is_equal_approx(begin.y, corner.y) || Math::is_equal_approx(end.x, corner.x));
viewport->draw_line(begin, end, ruler_primary_color, Math::round(EDSCALE * 3), true);
if (draw_secondary_lines) {
@@ -2722,8 +2717,10 @@ void CanvasItemEditor::_draw_ruler_tool() {
viewport->draw_string(font, text_pos, vformat("%.2f px", length_vector.length()), font_color);
if (draw_secondary_lines) {
- int horizontal_axis_angle = round(180 * atan2(length_vector.y, length_vector.x) / Math_PI);
- int vertictal_axis_angle = 90 - horizontal_axis_angle;
+ const float horizontal_angle_rad = atan2(length_vector.y, length_vector.x);
+ const float vertical_angle_rad = Math_PI / 2.0 - horizontal_angle_rad;
+ const int horizontal_angle = round(180 * horizontal_angle_rad / Math_PI);
+ const int vertical_angle = round(180 * vertical_angle_rad / Math_PI);
Point2 text_pos2 = text_pos;
text_pos2.x = begin.x < text_pos.x ? MIN(text_pos.x - text_width, begin.x - text_width / 2) : MAX(text_pos.x + text_width, begin.x - text_width / 2);
@@ -2732,7 +2729,7 @@ void CanvasItemEditor::_draw_ruler_tool() {
Point2 v_angle_text_pos = Point2();
v_angle_text_pos.x = CLAMP(begin.x - angle_text_width / 2, angle_text_width / 2, viewport->get_rect().size.x - angle_text_width);
v_angle_text_pos.y = begin.y < end.y ? MIN(text_pos2.y - 2 * text_height, begin.y - text_height * 0.5) : MAX(text_pos2.y + text_height * 3, begin.y + text_height * 1.5);
- viewport->draw_string(font, v_angle_text_pos, vformat("%d deg", vertictal_axis_angle), font_secondary_color);
+ viewport->draw_string(font, v_angle_text_pos, vformat("%d deg", vertical_angle), font_secondary_color);
text_pos2 = text_pos;
text_pos2.y = end.y < text_pos.y ? MIN(text_pos.y - text_height * 2, end.y - text_height / 2) : MAX(text_pos.y + text_height * 2, end.y - text_height / 2);
@@ -2743,20 +2740,48 @@ void CanvasItemEditor::_draw_ruler_tool() {
if (begin.y < end.y) {
h_angle_text_pos.y = end.y + text_height * 1.5;
if (ABS(text_pos2.x - h_angle_text_pos.x) < text_width) {
- int height_multiplier = 1.5 + (int)is_snap_active;
+ int height_multiplier = 1.5 + (int)grid_snap_active;
h_angle_text_pos.y = MAX(text_pos.y + height_multiplier * text_height, MAX(end.y + text_height * 1.5, text_pos2.y + height_multiplier * text_height));
}
} else {
h_angle_text_pos.y = end.y - text_height * 0.5;
if (ABS(text_pos2.x - h_angle_text_pos.x) < text_width) {
- int height_multiplier = 1 + (int)is_snap_active;
+ int height_multiplier = 1 + (int)grid_snap_active;
h_angle_text_pos.y = MIN(text_pos.y - height_multiplier * text_height, MIN(end.y - text_height * 0.5, text_pos2.y - height_multiplier * text_height));
}
}
- viewport->draw_string(font, h_angle_text_pos, vformat("%d deg", horizontal_axis_angle), font_secondary_color);
+ viewport->draw_string(font, h_angle_text_pos, vformat("%d deg", horizontal_angle), font_secondary_color);
+
+ // Angle arcs
+ int arc_point_count = 8;
+ float arc_radius_max_length_percent = 0.1;
+ float ruler_length = length_vector.length() * zoom;
+ float arc_max_radius = 50.0;
+ float arc_line_width = 2.0;
+
+ const Vector2 end_to_begin = (end - begin);
+
+ float arc_1_start_angle =
+ end_to_begin.x < 0 ?
+ (end_to_begin.y < 0 ? 3.0 * Math_PI / 2.0 - vertical_angle_rad : Math_PI / 2.0) :
+ (end_to_begin.y < 0 ? 3.0 * Math_PI / 2.0 : Math_PI / 2.0 - vertical_angle_rad);
+ float arc_1_end_angle = arc_1_start_angle + vertical_angle_rad;
+ // Constrain arc to triangle height & max size
+ float arc_1_radius = MIN(MIN(arc_radius_max_length_percent * ruler_length, ABS(end_to_begin.y)), arc_max_radius);
+
+ float arc_2_start_angle =
+ end_to_begin.x < 0 ?
+ (end_to_begin.y < 0 ? 0.0 : -horizontal_angle_rad) :
+ (end_to_begin.y < 0 ? Math_PI - horizontal_angle_rad : Math_PI);
+ float arc_2_end_angle = arc_2_start_angle + horizontal_angle_rad;
+ // Constrain arc to triangle width & max size
+ float arc_2_radius = MIN(MIN(arc_radius_max_length_percent * ruler_length, ABS(end_to_begin.x)), arc_max_radius);
+
+ viewport->draw_arc(begin, arc_1_radius, arc_1_start_angle, arc_1_end_angle, arc_point_count, ruler_primary_color, Math::round(EDSCALE * arc_line_width));
+ viewport->draw_arc(end, arc_2_radius, arc_2_start_angle, arc_2_end_angle, arc_point_count, ruler_primary_color, Math::round(EDSCALE * arc_line_width));
}
- if (is_snap_active) {
+ if (grid_snap_active) {
text_pos = (begin + end) / 2 + Vector2(-text_width / 2, text_height / 2);
text_pos.x = CLAMP(text_pos.x, text_width / 2, viewport->get_rect().size.x - text_width * 1.5);
@@ -2767,20 +2792,20 @@ void CanvasItemEditor::_draw_ruler_tool() {
Point2 text_pos2 = text_pos;
text_pos2.x = begin.x < text_pos.x ? MIN(text_pos.x - text_width, begin.x - text_width / 2) : MAX(text_pos.x + text_width, begin.x - text_width / 2);
- viewport->draw_string(font, text_pos2, vformat("%d units", (int)(length_vector.y / grid_step.y)), font_secondary_color);
+ viewport->draw_string(font, text_pos2, vformat("%d units", roundf(length_vector.y / grid_step.y)), font_secondary_color);
text_pos2 = text_pos;
text_pos2.y = end.y < text_pos.y ? MIN(text_pos.y - text_height * 2, end.y + text_height / 2) : MAX(text_pos.y + text_height * 2, end.y + text_height / 2);
- viewport->draw_string(font, text_pos2, vformat("%d units", (int)(length_vector.x / grid_step.x)), font_secondary_color);
+ viewport->draw_string(font, text_pos2, vformat("%d units", roundf(length_vector.x / grid_step.x)), font_secondary_color);
} else {
viewport->draw_string(font, text_pos, vformat("%d units", roundf((length_vector / grid_step).length())), font_color);
}
}
} else {
- if (is_snap_active) {
+ if (grid_snap_active) {
Ref<Texture> position_icon = get_icon("EditorPosition", "EditorIcons");
- viewport->draw_texture(get_icon("EditorPosition", "EditorIcons"), ruler_tool_origin - view_offset * zoom - position_icon->get_size() / 2);
+ viewport->draw_texture(get_icon("EditorPosition", "EditorIcons"), (ruler_tool_origin - view_offset) * zoom - position_icon->get_size() / 2);
}
}
}
@@ -3697,7 +3722,8 @@ void CanvasItemEditor::_notification(int p_what) {
move_button->set_icon(get_icon("ToolMove", "EditorIcons"));
scale_button->set_icon(get_icon("ToolScale", "EditorIcons"));
rotate_button->set_icon(get_icon("ToolRotate", "EditorIcons"));
- snap_button->set_icon(get_icon("Snap", "EditorIcons"));
+ smart_snap_button->set_icon(get_icon("Snap", "EditorIcons"));
+ grid_snap_button->set_icon(get_icon("SnapGrid", "EditorIcons"));
snap_config_menu->set_icon(get_icon("GuiTabMenu", "EditorIcons"));
skeleton_menu->set_icon(get_icon("Bone", "EditorIcons"));
pan_button->set_icon(get_icon("ToolPan", "EditorIcons"));
@@ -4101,8 +4127,13 @@ void CanvasItemEditor::_button_zoom_plus() {
_zoom_on_position(zoom * Math_SQRT2, viewport_scrollable->get_size() / 2.0);
}
-void CanvasItemEditor::_button_toggle_snap(bool p_status) {
- snap_active = p_status;
+void CanvasItemEditor::_button_toggle_smart_snap(bool p_status) {
+ smart_snap_active = p_status;
+ viewport->update();
+}
+
+void CanvasItemEditor::_button_toggle_grid_snap(bool p_status) {
+ grid_snap_active = p_status;
viewport->update();
}
@@ -4261,11 +4292,6 @@ void CanvasItemEditor::_popup_callback(int p_op) {
int idx = smartsnap_config_popup->get_item_index(SNAP_USE_GUIDES);
smartsnap_config_popup->set_item_checked(idx, snap_guides);
} break;
- case SNAP_USE_GRID: {
- snap_grid = !snap_grid;
- int idx = snap_config_menu->get_popup()->get_item_index(SNAP_USE_GRID);
- snap_config_menu->get_popup()->set_item_checked(idx, snap_grid);
- } break;
case SNAP_USE_ROTATION: {
snap_rotation = !snap_rotation;
int idx = snap_config_menu->get_popup()->get_item_index(SNAP_USE_ROTATION);
@@ -4797,7 +4823,8 @@ void CanvasItemEditor::_bind_methods() {
ClassDB::bind_method("_button_zoom_minus", &CanvasItemEditor::_button_zoom_minus);
ClassDB::bind_method("_button_zoom_reset", &CanvasItemEditor::_button_zoom_reset);
ClassDB::bind_method("_button_zoom_plus", &CanvasItemEditor::_button_zoom_plus);
- ClassDB::bind_method("_button_toggle_snap", &CanvasItemEditor::_button_toggle_snap);
+ ClassDB::bind_method("_button_toggle_smart_snap", &CanvasItemEditor::_button_toggle_smart_snap);
+ ClassDB::bind_method("_button_toggle_grid_snap", &CanvasItemEditor::_button_toggle_grid_snap);
ClassDB::bind_method("_button_toggle_anchor_mode", &CanvasItemEditor::_button_toggle_anchor_mode);
ClassDB::bind_method("_update_scroll", &CanvasItemEditor::_update_scroll);
ClassDB::bind_method("_update_scrollbars", &CanvasItemEditor::_update_scrollbars);
@@ -4832,13 +4859,13 @@ Dictionary CanvasItemEditor::get_state() const {
state["grid_step"] = grid_step;
state["snap_rotation_offset"] = snap_rotation_offset;
state["snap_rotation_step"] = snap_rotation_step;
- state["snap_active"] = snap_active;
+ state["smart_snap_active"] = smart_snap_active;
+ state["grid_snap_active"] = grid_snap_active;
state["snap_node_parent"] = snap_node_parent;
state["snap_node_anchors"] = snap_node_anchors;
state["snap_node_sides"] = snap_node_sides;
state["snap_node_center"] = snap_node_center;
state["snap_other_nodes"] = snap_other_nodes;
- state["snap_grid"] = snap_grid;
state["snap_guides"] = snap_guides;
state["show_grid"] = show_grid;
state["show_origin"] = show_origin;
@@ -4886,9 +4913,14 @@ void CanvasItemEditor::set_state(const Dictionary &p_state) {
snap_rotation_offset = state["snap_rotation_offset"];
}
- if (state.has("snap_active")) {
- snap_active = state["snap_active"];
- snap_button->set_pressed(snap_active);
+ if (state.has("smart_snap_active")) {
+ smart_snap_active = state["smart_snap_active"];
+ smart_snap_button->set_pressed(smart_snap_active);
+ }
+
+ if (state.has("grid_snap_active")) {
+ grid_snap_active = state["grid_snap_active"];
+ grid_snap_button->set_pressed(grid_snap_active);
}
if (state.has("snap_node_parent")) {
@@ -4927,12 +4959,6 @@ void CanvasItemEditor::set_state(const Dictionary &p_state) {
smartsnap_config_popup->set_item_checked(idx, snap_guides);
}
- if (state.has("snap_grid")) {
- snap_grid = state["snap_grid"];
- int idx = snap_config_menu->get_popup()->get_item_index(SNAP_USE_GRID);
- snap_config_menu->get_popup()->set_item_checked(idx, snap_grid);
- }
-
if (state.has("show_grid")) {
show_grid = state["show_grid"];
int idx = view_menu->get_popup()->get_item_index(SHOW_GRID);
@@ -5071,13 +5097,13 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
grid_step_multiplier = 0;
snap_rotation_offset = 0;
snap_rotation_step = 15 / (180 / Math_PI);
- snap_active = false;
+ smart_snap_active = false;
+ grid_snap_active = false;
snap_node_parent = true;
snap_node_anchors = true;
snap_node_sides = true;
snap_node_center = true;
snap_other_nodes = true;
- snap_grid = true;
snap_guides = true;
snap_rotation = false;
snap_relative = false;
@@ -5269,12 +5295,19 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
hb->add_child(memnew(VSeparator));
- snap_button = memnew(ToolButton);
- hb->add_child(snap_button);
- snap_button->set_toggle_mode(true);
- snap_button->connect("toggled", this, "_button_toggle_snap");
- snap_button->set_tooltip(TTR("Toggle snapping."));
- snap_button->set_shortcut(ED_SHORTCUT("canvas_item_editor/use_snap", TTR("Use Snap"), KEY_MASK_SHIFT | KEY_S));
+ smart_snap_button = memnew(ToolButton);
+ hb->add_child(smart_snap_button);
+ smart_snap_button->set_toggle_mode(true);
+ smart_snap_button->connect("toggled", this, "_button_toggle_smart_snap");
+ smart_snap_button->set_tooltip(TTR("Toggle smart snapping."));
+ smart_snap_button->set_shortcut(ED_SHORTCUT("canvas_item_editor/use_smart_snap", TTR("Use Smart Snap"), KEY_MASK_SHIFT | KEY_S));
+
+ grid_snap_button = memnew(ToolButton);
+ hb->add_child(grid_snap_button);
+ grid_snap_button->set_toggle_mode(true);
+ grid_snap_button->connect("toggled", this, "_button_toggle_grid_snap");
+ grid_snap_button->set_tooltip(TTR("Toggle grid snapping."));
+ grid_snap_button->set_shortcut(ED_SHORTCUT("canvas_item_editor/use_grid_snap", TTR("Use Grid Snap"), KEY_MASK_SHIFT | KEY_G));
snap_config_menu = memnew(MenuButton);
hb->add_child(snap_config_menu);
@@ -5285,7 +5318,6 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
PopupMenu *p = snap_config_menu->get_popup();
p->connect("id_pressed", this, "_popup_callback");
p->set_hide_on_checkable_item_selection(false);
- p->add_check_shortcut(ED_SHORTCUT("canvas_item_editor/snap_grid", TTR("Snap to Grid")), SNAP_USE_GRID);
p->add_check_shortcut(ED_SHORTCUT("canvas_item_editor/use_rotation_snap", TTR("Use Rotation Snap")), SNAP_USE_ROTATION);
p->add_check_shortcut(ED_SHORTCUT("canvas_item_editor/snap_relative", TTR("Snap Relative")), SNAP_RELATIVE);
p->add_check_shortcut(ED_SHORTCUT("canvas_item_editor/use_pixel_snap", TTR("Use Pixel Snap")), SNAP_USE_PIXEL);
@@ -5357,7 +5389,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
p = view_menu->get_popup();
p->set_hide_on_checkable_item_selection(false);
- p->add_check_shortcut(ED_SHORTCUT("canvas_item_editor/show_grid", TTR("Show Grid"), KEY_G), SHOW_GRID);
+ p->add_check_shortcut(ED_SHORTCUT("canvas_item_editor/show_grid", TTR("Always Show Grid"), KEY_G), SHOW_GRID);
p->add_check_shortcut(ED_SHORTCUT("canvas_item_editor/show_helpers", TTR("Show Helpers"), KEY_H), SHOW_HELPERS);
p->add_check_shortcut(ED_SHORTCUT("canvas_item_editor/show_rulers", TTR("Show Rulers")), SHOW_RULERS);
p->add_check_shortcut(ED_SHORTCUT("canvas_item_editor/show_guides", TTR("Show Guides"), KEY_Y), SHOW_GUIDES);
diff --git a/editor/plugins/canvas_item_editor_plugin.h b/editor/plugins/canvas_item_editor_plugin.h
index 6cce1ca10e..480fb89621 100644
--- a/editor/plugins/canvas_item_editor_plugin.h
+++ b/editor/plugins/canvas_item_editor_plugin.h
@@ -259,13 +259,14 @@ private:
float snap_rotation_step;
float snap_rotation_offset;
- bool snap_active;
+ bool smart_snap_active;
+ bool grid_snap_active;
+
bool snap_node_parent;
bool snap_node_anchors;
bool snap_node_sides;
bool snap_node_center;
bool snap_other_nodes;
- bool snap_grid;
bool snap_guides;
bool snap_rotation;
bool snap_relative;
@@ -347,7 +348,8 @@ private:
ToolButton *ruler_button;
- ToolButton *snap_button;
+ ToolButton *smart_snap_button;
+ ToolButton *grid_snap_button;
MenuButton *snap_config_menu;
PopupMenu *smartsnap_config_popup;
@@ -529,7 +531,8 @@ private:
void _button_zoom_minus();
void _button_zoom_reset();
void _button_zoom_plus();
- void _button_toggle_snap(bool p_status);
+ void _button_toggle_smart_snap(bool p_status);
+ void _button_toggle_grid_snap(bool p_status);
void _button_tool_select(int p_index);
HSplitContainer *palette_split;
diff --git a/editor/plugins/curve_editor_plugin.cpp b/editor/plugins/curve_editor_plugin.cpp
index 9160920c50..727d92ba05 100644
--- a/editor/plugins/curve_editor_plugin.cpp
+++ b/editor/plugins/curve_editor_plugin.cpp
@@ -736,6 +736,9 @@ void CurveEditor::_draw() {
if (_selected_point > 0 && _selected_point + 1 < curve.get_point_count()) {
text_color.a *= 0.4;
draw_string(font, Vector2(50, font_height), TTR("Hold Shift to edit tangents individually"), text_color);
+ } else if (curve.get_point_count() == 0) {
+ text_color.a *= 0.4;
+ draw_string(font, Vector2(50, font_height), TTR("Right click to add point"), text_color);
}
}
diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp
index 80b0f0738a..f7e997a269 100644
--- a/editor/plugins/script_editor_plugin.cpp
+++ b/editor/plugins/script_editor_plugin.cpp
@@ -43,6 +43,7 @@
#include "editor/plugins/shader_editor_plugin.h"
#include "editor/script_editor_debugger.h"
#include "scene/main/viewport.h"
+#include "scene/scene_string_names.h"
#include "script_text_editor.h"
#include "text_editor.h"
@@ -1325,6 +1326,9 @@ void ScriptEditor::_menu_option(int p_option) {
case HELP_SEARCH_FIND_NEXT: {
help->search_again();
} break;
+ case HELP_SEARCH_FIND_PREVIOUS: {
+ help->search_again(true);
+ } break;
case FILE_CLOSE: {
_close_current_tab();
} break;
@@ -1417,16 +1421,6 @@ void ScriptEditor::_notification(int p_what) {
members_overview->connect("item_selected", this, "_members_overview_selected");
help_overview->connect("item_selected", this, "_help_overview_selected");
script_split->connect("dragged", this, "_script_split_dragged");
- autosave_timer->connect("timeout", this, "_autosave_scripts");
- {
- float autosave_time = EditorSettings::get_singleton()->get("text_editor/files/autosave_interval_secs");
- if (autosave_time > 0) {
- autosave_timer->set_wait_time(autosave_time);
- autosave_timer->start();
- } else {
- autosave_timer->stop();
- }
- }
EditorSettings::get_singleton()->connect("settings_changed", this, "_editor_settings_changed");
FALLTHROUGH;
@@ -2332,13 +2326,7 @@ void ScriptEditor::_editor_settings_changed() {
_update_members_overview_visibility();
_update_help_overview_visibility();
- float autosave_time = EditorSettings::get_singleton()->get("text_editor/files/autosave_interval_secs");
- if (autosave_time > 0) {
- autosave_timer->set_wait_time(autosave_time);
- autosave_timer->start();
- } else {
- autosave_timer->stop();
- }
+ _update_autosave_timer();
if (current_theme == "") {
current_theme = EditorSettings::get_singleton()->get("text_editor/theme/color_theme");
@@ -2366,6 +2354,21 @@ void ScriptEditor::_autosave_scripts() {
save_all_scripts();
}
+void ScriptEditor::_update_autosave_timer() {
+
+ if (!autosave_timer->is_inside_tree()) {
+ return;
+ }
+
+ float autosave_time = EditorSettings::get_singleton()->get("text_editor/files/autosave_interval_secs");
+ if (autosave_time > 0) {
+ autosave_timer->set_wait_time(autosave_time);
+ autosave_timer->start();
+ } else {
+ autosave_timer->stop();
+ }
+}
+
void ScriptEditor::_tree_changed() {
if (waiting_update_names)
@@ -2827,6 +2830,7 @@ void ScriptEditor::_update_selected_editor_menu() {
script_search_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/find", TTR("Find..."), KEY_MASK_CMD | KEY_F), HELP_SEARCH_FIND);
script_search_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/find_next", TTR("Find Next"), KEY_F3), HELP_SEARCH_FIND_NEXT);
+ script_search_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/find_previous", TTR("Find Previous"), KEY_MASK_SHIFT | KEY_F3), HELP_SEARCH_FIND_PREVIOUS);
script_search_menu->get_popup()->add_separator();
script_search_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/find_in_files", TTR("Find in Files"), KEY_MASK_CMD | KEY_MASK_SHIFT | KEY_F), SEARCH_IN_FILES);
script_search_menu->show();
@@ -3088,6 +3092,7 @@ void ScriptEditor::_bind_methods() {
ClassDB::bind_method("_show_debugger", &ScriptEditor::_show_debugger);
ClassDB::bind_method("_get_debug_tooltip", &ScriptEditor::_get_debug_tooltip);
ClassDB::bind_method("_autosave_scripts", &ScriptEditor::_autosave_scripts);
+ ClassDB::bind_method("_update_autosave_timer", &ScriptEditor::_update_autosave_timer);
ClassDB::bind_method("_editor_settings_changed", &ScriptEditor::_editor_settings_changed);
ClassDB::bind_method("_update_script_names", &ScriptEditor::_update_script_names);
ClassDB::bind_method("_update_script_connections", &ScriptEditor::_update_script_connections);
@@ -3424,6 +3429,8 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) {
autosave_timer = memnew(Timer);
autosave_timer->set_one_shot(false);
+ autosave_timer->connect(SceneStringNames::get_singleton()->tree_entered, this, "_update_autosave_timer");
+ autosave_timer->connect("timeout", this, "_autosave_scripts");
add_child(autosave_timer);
grab_focus_block = false;
diff --git a/editor/plugins/script_editor_plugin.h b/editor/plugins/script_editor_plugin.h
index 0c876108a5..294294fc56 100644
--- a/editor/plugins/script_editor_plugin.h
+++ b/editor/plugins/script_editor_plugin.h
@@ -168,6 +168,7 @@ class ScriptEditor : public PanelContainer {
REQUEST_DOCS,
HELP_SEARCH_FIND,
HELP_SEARCH_FIND_NEXT,
+ HELP_SEARCH_FIND_PREVIOUS,
WINDOW_MOVE_UP,
WINDOW_MOVE_DOWN,
WINDOW_NEXT,
@@ -342,6 +343,7 @@ class ScriptEditor : public PanelContainer {
void _save_layout();
void _editor_settings_changed();
void _autosave_scripts();
+ void _update_autosave_timer();
void _update_members_overview_visibility();
void _update_members_overview();
diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp
index ecb2354aa1..5bccb36252 100644
--- a/editor/plugins/script_text_editor.cpp
+++ b/editor/plugins/script_text_editor.cpp
@@ -1186,7 +1186,7 @@ void ScriptTextEditor::_edit_option(int p_op) {
if (expression.parse(line) == OK) {
Variant result = expression.execute(Array(), Variant(), false);
if (expression.get_error_text() == "") {
- results.append(whitespace + (String)result);
+ results.append(whitespace + result.get_construct_string());
} else {
results.append(line);
}
diff --git a/editor/plugins/spatial_editor_plugin.cpp b/editor/plugins/spatial_editor_plugin.cpp
index 095350d0e1..1d8fd38858 100644
--- a/editor/plugins/spatial_editor_plugin.cpp
+++ b/editor/plugins/spatial_editor_plugin.cpp
@@ -2049,12 +2049,11 @@ void SpatialEditorViewport::_update_freelook(real_t delta) {
return;
}
- Vector3 forward = camera->get_transform().basis.xform(Vector3(0, 0, -1));
- Vector3 right = camera->get_transform().basis.xform(Vector3(1, 0, 0));
- Vector3 up = camera->get_transform().basis.xform(Vector3(0, 1, 0));
+ const Vector3 forward = camera->get_transform().basis.xform(Vector3(0, 0, -1));
+ const Vector3 right = camera->get_transform().basis.xform(Vector3(1, 0, 0));
+ const Vector3 up = camera->get_transform().basis.xform(Vector3(0, 1, 0));
Vector3 direction;
- bool speed_modifier = false;
if (is_shortcut_pressed("spatial_editor/freelook_left")) {
direction -= right;
@@ -2074,17 +2073,17 @@ void SpatialEditorViewport::_update_freelook(real_t delta) {
if (is_shortcut_pressed("spatial_editor/freelook_down")) {
direction -= up;
}
- if (is_shortcut_pressed("spatial_editor/freelook_speed_modifier")) {
- speed_modifier = true;
- }
real_t speed = freelook_speed;
- if (speed_modifier) {
- real_t modifier_speed_factor = EditorSettings::get_singleton()->get("editors/3d/freelook/freelook_modifier_speed_factor");
- speed *= modifier_speed_factor;
+
+ if (is_shortcut_pressed("spatial_editor/freelook_speed_modifier")) {
+ speed *= 3.0;
+ }
+ if (is_shortcut_pressed("spatial_editor/freelook_slow_modifier")) {
+ speed *= 0.333333;
}
- Vector3 motion = direction * speed * delta;
+ const Vector3 motion = direction * speed * delta;
cursor.pos += motion;
cursor.eye_pos += motion;
}
@@ -3588,6 +3587,7 @@ SpatialEditorViewport::SpatialEditorViewport(SpatialEditor *p_spatial_editor, Ed
ED_SHORTCUT("spatial_editor/freelook_up", TTR("Freelook Up"), KEY_E);
ED_SHORTCUT("spatial_editor/freelook_down", TTR("Freelook Down"), KEY_Q);
ED_SHORTCUT("spatial_editor/freelook_speed_modifier", TTR("Freelook Speed Modifier"), KEY_SHIFT);
+ ED_SHORTCUT("spatial_editor/freelook_slow_modifier", TTR("Freelook Slow Modifier"), KEY_ALT);
preview_camera = memnew(CheckBox);
preview_camera->set_text(TTR("Preview"));
diff --git a/editor/plugins/style_box_editor_plugin.cpp b/editor/plugins/style_box_editor_plugin.cpp
index defc0a40ea..c4a9803ff4 100644
--- a/editor/plugins/style_box_editor_plugin.cpp
+++ b/editor/plugins/style_box_editor_plugin.cpp
@@ -64,21 +64,24 @@ void StyleBoxPreview::edit(const Ref<StyleBox> &p_stylebox) {
void StyleBoxPreview::_sb_changed() {
preview->update();
+}
+
+void StyleBoxPreview::_redraw() {
if (stylebox.is_valid()) {
- Size2 ms = stylebox->get_minimum_size() * 4 / 3;
- ms.height = MAX(ms.height, 150 * EDSCALE);
- preview->set_custom_minimum_size(ms);
+ preview->draw_style_box(stylebox, preview->get_rect());
}
}
void StyleBoxPreview::_bind_methods() {
ClassDB::bind_method("_sb_changed", &StyleBoxPreview::_sb_changed);
+ ClassDB::bind_method("_redraw", &StyleBoxPreview::_redraw);
}
StyleBoxPreview::StyleBoxPreview() {
-
- preview = memnew(Panel);
+ preview = memnew(Control);
+ preview->set_custom_minimum_size(Size2(0, 150 * EDSCALE));
+ preview->connect("draw", this, "_redraw");
add_margin_child(TTR("Preview:"), preview);
}
diff --git a/editor/plugins/style_box_editor_plugin.h b/editor/plugins/style_box_editor_plugin.h
index d31a28b3e4..fead8e0de8 100644
--- a/editor/plugins/style_box_editor_plugin.h
+++ b/editor/plugins/style_box_editor_plugin.h
@@ -41,10 +41,11 @@ class StyleBoxPreview : public VBoxContainer {
GDCLASS(StyleBoxPreview, VBoxContainer);
- Panel *preview;
+ Control *preview;
Ref<StyleBox> stylebox;
void _sb_changed();
+ void _redraw();
protected:
static void _bind_methods();
diff --git a/editor/plugins/text_editor.cpp b/editor/plugins/text_editor.cpp
index d0320bcd8b..0cef5a8b6f 100644
--- a/editor/plugins/text_editor.cpp
+++ b/editor/plugins/text_editor.cpp
@@ -31,7 +31,7 @@
#include "text_editor.h"
#include "core/os/keyboard.h"
-#include "editor_node.h"
+#include "editor/editor_node.h"
void TextEditor::add_syntax_highlighter(SyntaxHighlighter *p_highlighter) {
highlighters[p_highlighter->get_name()] = p_highlighter;
diff --git a/editor/plugins/visual_shader_editor_plugin.cpp b/editor/plugins/visual_shader_editor_plugin.cpp
index c962751c7a..3a9e48cfdb 100644
--- a/editor/plugins/visual_shader_editor_plugin.cpp
+++ b/editor/plugins/visual_shader_editor_plugin.cpp
@@ -178,6 +178,9 @@ bool VisualShaderEditor::_is_available(int p_mode) {
}
void VisualShaderEditor::update_custom_nodes() {
+ if (members_dialog->is_visible()) {
+ return;
+ }
clear_custom_types();
List<StringName> class_list;
ScriptServer::get_global_class_list(&class_list);
diff --git a/editor/project_export.cpp b/editor/project_export.cpp
index 7456396460..adcbddfb04 100644
--- a/editor/project_export.cpp
+++ b/editor/project_export.cpp
@@ -286,11 +286,13 @@ void ProjectExportDialog::_edit_preset(int p_index) {
export_templates_error->hide();
export_button->set_disabled(true);
+ get_ok()->set_disabled(true);
} else {
export_error->hide();
export_templates_error->hide();
export_button->set_disabled(false);
+ get_ok()->set_disabled(false);
}
custom_features->set_text(current->get_custom_features());
@@ -623,6 +625,7 @@ void ProjectExportDialog::_delete_preset_confirm() {
int idx = presets->get_current();
_edit_preset(-1);
export_button->set_disabled(true);
+ get_ok()->set_disabled(true);
EditorExport::get_singleton()->remove_export_preset(idx);
_update_presets();
}
@@ -1249,6 +1252,7 @@ ProjectExportDialog::ProjectExportDialog() {
export_button->connect("pressed", this, "_export_project");
// Disable initially before we select a valid preset
export_button->set_disabled(true);
+ get_ok()->set_disabled(true);
export_all_dialog = memnew(ConfirmationDialog);
add_child(export_all_dialog);
diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp
index d903e153a7..ab62a59be1 100644
--- a/editor/project_manager.cpp
+++ b/editor/project_manager.cpp
@@ -1023,6 +1023,7 @@ public:
ProjectList();
~ProjectList();
+ void update_dock_menu();
void load_projects();
void set_search_term(String p_search_term);
void set_order_option(ProjectListFilter::FilterOption p_option);
@@ -1210,7 +1211,6 @@ void ProjectList::load_projects() {
_projects.clear();
_last_clicked = "";
_selected_project_keys.clear();
- OS::get_singleton()->global_menu_clear("_dock");
// Load data
// TODO Would be nice to change how projects and favourites are stored... it complicates things a bit.
@@ -1248,14 +1248,38 @@ void ProjectList::load_projects() {
create_project_item_control(i);
}
- OS::get_singleton()->global_menu_add_separator("_dock");
- OS::get_singleton()->global_menu_add_item("_dock", TTR("New Window"), GLOBAL_NEW_WINDOW, Variant());
-
sort_projects();
set_v_scroll(0);
update_icons_async();
+
+ update_dock_menu();
+}
+
+void ProjectList::update_dock_menu() {
+ OS::get_singleton()->global_menu_clear("_dock");
+
+ int favs_added = 0;
+ int total_added = 0;
+ for (int i = 0; i < _projects.size(); ++i) {
+ if (!_projects[i].grayed && !_projects[i].missing) {
+ if (_projects[i].favorite) {
+ favs_added++;
+ } else {
+ if (favs_added != 0) {
+ OS::get_singleton()->global_menu_add_separator("_dock");
+ }
+ favs_added = 0;
+ }
+ OS::get_singleton()->global_menu_add_item("_dock", _projects[i].project_name + " ( " + _projects[i].path + " )", GLOBAL_OPEN_PROJECT, Variant(_projects[i].path.plus_file("project.godot")));
+ total_added++;
+ }
+ }
+ if (total_added != 0) {
+ OS::get_singleton()->global_menu_add_separator("_dock");
+ }
+ OS::get_singleton()->global_menu_add_item("_dock", TTR("New Window"), GLOBAL_NEW_WINDOW, Variant());
}
void ProjectList::create_project_item_control(int p_index) {
@@ -1341,7 +1365,6 @@ void ProjectList::create_project_item_control(int p_index) {
fpath->set_clip_text(true);
_scroll_children->add_child(hb);
- OS::get_singleton()->global_menu_add_item("_dock", item.project_name + " ( " + item.path + " )", GLOBAL_OPEN_PROJECT, Variant(item.path.plus_file("project.godot")));
item.control = hb;
}
@@ -1394,6 +1417,8 @@ void ProjectList::sort_projects() {
// Rewind the coroutine because order of projects changed
update_icons_async();
+
+ update_dock_menu();
}
const Set<String> &ProjectList::get_selected_project_keys() const {
@@ -1470,6 +1495,8 @@ void ProjectList::remove_project(int p_index, bool p_update_settings) {
EditorSettings::get_singleton()->erase("favorite_projects/" + item.project_key);
// Not actually saving the file, in case you are doing more changes to settings
}
+
+ update_dock_menu();
}
bool ProjectList::is_any_project_missing() const {
@@ -1568,6 +1595,7 @@ int ProjectList::refresh_project(const String &dir_path) {
ensure_project_visible(i);
}
load_project_icon(i);
+
index = i;
break;
}
@@ -1642,6 +1670,8 @@ void ProjectList::erase_selected_projects() {
_selected_project_keys.clear();
_last_clicked = "";
+
+ update_dock_menu();
}
// Draws selected project highlight
@@ -1725,6 +1755,8 @@ void ProjectList::_favorite_pressed(Node *p_hb) {
}
}
}
+
+ update_dock_menu();
}
void ProjectList::_show_project(const String &p_path) {
@@ -1929,6 +1961,8 @@ void ProjectManager::_on_projects_updated() {
if (index != -1) {
_project_list->ensure_project_visible(index);
}
+
+ _project_list->update_dock_menu();
}
void ProjectManager::_on_project_created(const String &dir) {
@@ -1937,6 +1971,8 @@ void ProjectManager::_on_project_created(const String &dir) {
_project_list->select_project(i);
_project_list->ensure_project_visible(i);
_open_selected_projects_ask();
+
+ _project_list->update_dock_menu();
}
void ProjectManager::_confirm_update_settings() {
diff --git a/editor/project_settings_editor.cpp b/editor/project_settings_editor.cpp
index 35187214a6..f56f7ef7ca 100644
--- a/editor/project_settings_editor.cpp
+++ b/editor/project_settings_editor.cpp
@@ -845,9 +845,10 @@ void ProjectSettingsEditor::_item_adds(String) {
void ProjectSettingsEditor::_item_add() {
- // Initialize the property with the default value for the given type
+ // Initialize the property with the default value for the given type.
+ // The type list starts at 1 (as we exclude Nil), so add 1 to the selected value.
Variant::CallError ce;
- const Variant value = Variant::construct(Variant::Type(type->get_selected()), NULL, 0, ce);
+ const Variant value = Variant::construct(Variant::Type(type->get_selected() + 1), NULL, 0, ce);
String catname = category->get_text().strip_edges();
String propname = property->get_text().strip_edges();
@@ -1109,6 +1110,8 @@ void ProjectSettingsEditor::drop_data_fw(const Point2 &p_point, const Variant &p
TreeItem *selected = input_editor->get_selected();
TreeItem *item = input_editor->get_item_at_position(p_point);
+ if (!item)
+ return;
TreeItem *target = item->get_parent() == input_editor->get_root() ? item : item->get_parent();
String selected_name = "input/" + selected->get_text(0);
@@ -1833,7 +1836,7 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) {
// Start at 1 to avoid adding "Nil" as an option
for (int i = 1; i < Variant::VARIANT_MAX; i++) {
- type->add_item(Variant::get_type_name(Variant::Type(i)), i);
+ type->add_item(Variant::get_type_name(Variant::Type(i)));
}
Button *add = memnew(Button);
diff --git a/editor/property_editor.cpp b/editor/property_editor.cpp
index ecb272876d..ce82d44164 100644
--- a/editor/property_editor.cpp
+++ b/editor/property_editor.cpp
@@ -246,7 +246,13 @@ void CustomPropertyEditor::_menu_option(int p_which) {
case OBJ_MENU_NEW_SCRIPT: {
if (Object::cast_to<Node>(owner))
- EditorNode::get_singleton()->get_scene_tree_dock()->open_script_dialog(Object::cast_to<Node>(owner));
+ EditorNode::get_singleton()->get_scene_tree_dock()->open_script_dialog(Object::cast_to<Node>(owner), false);
+
+ } break;
+ case OBJ_MENU_EXTEND_SCRIPT: {
+
+ if (Object::cast_to<Node>(owner))
+ EditorNode::get_singleton()->get_scene_tree_dock()->open_script_dialog(Object::cast_to<Node>(owner), true);
} break;
case OBJ_MENU_SHOW_IN_FILE_SYSTEM: {
diff --git a/editor/property_editor.h b/editor/property_editor.h
index 029c2211d5..b1c61c5e25 100644
--- a/editor/property_editor.h
+++ b/editor/property_editor.h
@@ -77,7 +77,8 @@ class CustomPropertyEditor : public Popup {
OBJ_MENU_COPY = 4,
OBJ_MENU_PASTE = 5,
OBJ_MENU_NEW_SCRIPT = 6,
- OBJ_MENU_SHOW_IN_FILE_SYSTEM = 7,
+ OBJ_MENU_EXTEND_SCRIPT = 7,
+ OBJ_MENU_SHOW_IN_FILE_SYSTEM = 8,
TYPE_BASE_ID = 100,
CONVERT_BASE_ID = 1000
};
diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp
index 98ab1bfb54..0884620e5d 100644
--- a/editor/scene_tree_dock.cpp
+++ b/editor/scene_tree_dock.cpp
@@ -421,53 +421,11 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
create_dialog->popup_create(false, true, selected->get_class());
} break;
+ case TOOL_EXTEND_SCRIPT: {
+ attach_script_to_selected(true);
+ } break;
case TOOL_ATTACH_SCRIPT: {
-
- if (!profile_allow_script_editing) {
- break;
- }
-
- List<Node *> selection = editor_selection->get_selected_node_list();
- if (selection.empty())
- break;
-
- Node *selected = scene_tree->get_selected();
- if (!selected)
- selected = selection.front()->get();
-
- Ref<Script> existing = selected->get_script();
-
- String path = selected->get_filename();
- if (path == "") {
- String root_path = editor_data->get_edited_scene_root()->get_filename();
- if (root_path == "") {
- path = String("res://").plus_file(selected->get_name());
- } else {
- path = root_path.get_base_dir().plus_file(selected->get_name());
- }
- }
-
- String inherits = selected->get_class();
- if (existing.is_valid()) {
- for (int i = 0; i < ScriptServer::get_language_count(); i++) {
- ScriptLanguage *l = ScriptServer::get_language(i);
- if (l->get_type() == existing->get_class()) {
- String name = l->get_global_class_name(existing->get_path());
- if (ScriptServer::is_global_class(name) && EDITOR_GET("interface/editors/derive_script_globals_by_name").operator bool()) {
- inherits = name;
- } else if (l->can_inherit_from_file()) {
- inherits = "\"" + existing->get_path() + "\"";
- }
- break;
- }
- }
- }
- script_create_dialog->connect("script_created", this, "_script_created");
- script_create_dialog->connect("popup_hide", this, "_script_creation_closed");
- script_create_dialog->set_inheritance_base_type("Node");
- script_create_dialog->config(inherits, path);
- script_create_dialog->popup_centered();
-
+ attach_script_to_selected(false);
} break;
case TOOL_CLEAR_SCRIPT: {
@@ -2482,10 +2440,9 @@ void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) {
if (profile_allow_script_editing) {
if (selection.size() == 1) {
- if (!existing_script.is_valid()) {
- menu->add_icon_shortcut(get_icon("ScriptCreate", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/attach_script"), TOOL_ATTACH_SCRIPT);
- } else {
- menu->add_icon_shortcut(get_icon("ScriptExtend", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/extend_script"), TOOL_ATTACH_SCRIPT);
+ menu->add_icon_shortcut(get_icon("ScriptCreate", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/attach_script"), TOOL_ATTACH_SCRIPT);
+ if (existing_script.is_valid()) {
+ menu->add_icon_shortcut(get_icon("ScriptExtend", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/extend_script"), TOOL_EXTEND_SCRIPT);
}
}
if (selection.size() > 1 || (existing_script.is_valid() && exisiting_script_removable)) {
@@ -2595,10 +2552,64 @@ void SceneTreeDock::_focus_node() {
}
}
-void SceneTreeDock::open_script_dialog(Node *p_for_node) {
+void SceneTreeDock::attach_script_to_selected(bool p_extend) {
+ if (!profile_allow_script_editing) {
+ return;
+ }
+
+ List<Node *> selection = editor_selection->get_selected_node_list();
+ if (selection.empty())
+ return;
+
+ Node *selected = scene_tree->get_selected();
+ if (!selected)
+ selected = selection.front()->get();
+
+ Ref<Script> existing = selected->get_script();
+
+ String path = selected->get_filename();
+ if (path == "") {
+ String root_path = editor_data->get_edited_scene_root()->get_filename();
+ if (root_path == "") {
+ path = String("res://").plus_file(selected->get_name());
+ } else {
+ path = root_path.get_base_dir().plus_file(selected->get_name());
+ }
+ }
+
+ String inherits = selected->get_class();
+
+ if (p_extend && existing.is_valid()) {
+ for (int i = 0; i < ScriptServer::get_language_count(); i++) {
+ ScriptLanguage *l = ScriptServer::get_language(i);
+ if (l->get_type() == existing->get_class()) {
+ String name = l->get_global_class_name(existing->get_path());
+ if (ScriptServer::is_global_class(name) && EDITOR_GET("interface/editors/derive_script_globals_by_name").operator bool()) {
+ inherits = name;
+ } else if (l->can_inherit_from_file()) {
+ inherits = "\"" + existing->get_path() + "\"";
+ }
+ break;
+ }
+ }
+ }
+
+ script_create_dialog->connect("script_created", this, "_script_created");
+ script_create_dialog->connect("popup_hide", this, "_script_creation_closed");
+ script_create_dialog->set_inheritance_base_type("Node");
+ script_create_dialog->config(inherits, path);
+ script_create_dialog->popup_centered();
+}
+
+void SceneTreeDock::open_script_dialog(Node *p_for_node, bool p_extend) {
scene_tree->set_selected(p_for_node, false);
- _tool_selected(TOOL_ATTACH_SCRIPT);
+
+ if (p_extend) {
+ _tool_selected(TOOL_EXTEND_SCRIPT);
+ } else {
+ _tool_selected(TOOL_ATTACH_SCRIPT);
+ }
}
void SceneTreeDock::add_remote_tree_editor(Control *p_remote) {
diff --git a/editor/scene_tree_dock.h b/editor/scene_tree_dock.h
index 014ce58e88..4e78b84c53 100644
--- a/editor/scene_tree_dock.h
+++ b/editor/scene_tree_dock.h
@@ -64,6 +64,7 @@ class SceneTreeDock : public VBoxContainer {
TOOL_RENAME,
TOOL_BATCH_RENAME,
TOOL_REPLACE,
+ TOOL_EXTEND_SCRIPT,
TOOL_ATTACH_SCRIPT,
TOOL_CLEAR_SCRIPT,
TOOL_MOVE_UP,
@@ -259,7 +260,8 @@ public:
void replace_node(Node *p_node, Node *p_by_node, bool p_keep_properties = true, bool p_remove_old = true);
- void open_script_dialog(Node *p_for_node);
+ void attach_script_to_selected(bool p_extend);
+ void open_script_dialog(Node *p_for_node, bool p_extend);
ScriptCreateDialog *get_script_create_dialog() { return script_create_dialog; }
diff --git a/editor/script_editor_debugger.cpp b/editor/script_editor_debugger.cpp
index 89d275a90b..ccee38422c 100644
--- a/editor/script_editor_debugger.cpp
+++ b/editor/script_editor_debugger.cpp
@@ -597,7 +597,19 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da
if (var.is_zero()) {
var = RES();
} else if (var.get_type() == Variant::STRING) {
- var = ResourceLoader::load(var);
+ String path = var;
+ if (path.find("::") != -1) {
+ // built-in resource
+ String base_path = path.get_slice("::", 0);
+ if (ResourceLoader::get_resource_type(base_path) == "PackedScene") {
+ if (!EditorNode::get_singleton()->is_scene_open(base_path)) {
+ EditorNode::get_singleton()->load_scene(base_path);
+ }
+ } else {
+ EditorNode::get_singleton()->load_resource(base_path);
+ }
+ }
+ var = ResourceLoader::load(path);
if (pinfo.hint_string == "Script")
debugObj->set_script(var);
diff --git a/editor/spatial_editor_gizmos.cpp b/editor/spatial_editor_gizmos.cpp
index 489049c543..16da2771b9 100644
--- a/editor/spatial_editor_gizmos.cpp
+++ b/editor/spatial_editor_gizmos.cpp
@@ -3730,6 +3730,7 @@ void CollisionShapeSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) {
Ref<ConcavePolygonShape> cs2 = s;
Ref<ArrayMesh> mesh = cs2->get_debug_mesh();
p_gizmo->add_mesh(mesh, false, Ref<SkinReference>(), material);
+ p_gizmo->add_collision_segments(cs2->get_debug_mesh_lines());
}
if (Object::cast_to<RayShape>(*s)) {