summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
Diffstat (limited to 'editor')
-rw-r--r--editor/animation_track_editor_plugins.cpp36
-rw-r--r--editor/animation_track_editor_plugins.h4
-rw-r--r--editor/editor_export.cpp8
-rw-r--r--editor/editor_export.h10
-rw-r--r--editor/editor_help.cpp5
-rw-r--r--editor/editor_inspector.cpp14
-rw-r--r--editor/editor_node.cpp45
-rw-r--r--editor/editor_node.h1
-rw-r--r--editor/editor_properties.cpp15
-rw-r--r--editor/editor_properties.h3
-rw-r--r--editor/editor_run_native.cpp14
-rw-r--r--editor/editor_spin_slider.cpp4
-rw-r--r--editor/export_template_manager.cpp46
-rw-r--r--editor/plugins/canvas_item_editor_plugin.cpp38
-rw-r--r--editor/plugins/script_text_editor.cpp2
-rw-r--r--editor/project_manager.cpp46
-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
21 files changed, 292 insertions, 143 deletions
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/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_help.cpp b/editor/editor_help.cpp
index e4f64597b1..690538f44c 100644
--- a/editor/editor_help.cpp
+++ b/editor/editor_help.cpp
@@ -1468,8 +1468,9 @@ void EditorHelp::_notification(int p_what) {
_update_doc();
} break;
case NOTIFICATION_THEME_CHANGED: {
-
- _class_desc_resized();
+ if (is_visible_in_tree()) {
+ _class_desc_resized();
+ }
} break;
default: break;
}
diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp
index 78e058eeaa..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");
}
}
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index 6e2a4810cd..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"
@@ -371,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);
@@ -1470,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!"));
@@ -3639,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);
@@ -3652,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();
@@ -3691,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");
@@ -3704,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();
}
@@ -5640,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", "");
@@ -5681,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_properties.cpp b/editor/editor_properties.cpp
index fbb66744a7..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;
@@ -2633,7 +2641,6 @@ 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->(), "Object"));
@@ -2909,7 +2916,7 @@ void EditorInspectorDefaultPlugin::parse_begin(Object *p_object) {
bool EditorInspectorDefaultPlugin::parse_property(Object *p_object, Variant::Type p_type, const String &p_path, PropertyHint p_hint, const String &p_hint_text, int p_usage) {
- double default_float_step = EDITOR_GET("interface/inspector/default_float_step");
+ float default_float_step = EDITOR_GET("interface/inspector/default_float_step");
switch (p_type) {
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_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..95c615afa3 100644
--- a/editor/export_template_manager.cpp
+++ b/editor/export_template_manager.cpp
@@ -155,38 +155,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 +240,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 +248,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 +303,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 +313,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 +328,6 @@ bool ExportTemplateManager::_install_from_file(const String &p_file, bool p_use_
unzClose(pkg);
_update_template_list();
-
return true;
}
diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp
index 2a31d53a7e..f9a7b7caf1 100644
--- a/editor/plugins/canvas_item_editor_plugin.cpp
+++ b/editor/plugins/canvas_item_editor_plugin.cpp
@@ -2721,8 +2721,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);
@@ -2731,7 +2733,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);
@@ -2752,7 +2754,35 @@ void CanvasItemEditor::_draw_ruler_tool() {
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) {
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/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/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);