summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--editor/editor_autoload_settings.cpp63
-rw-r--r--editor/editor_autoload_settings.h22
-rw-r--r--editor/filesystem_dock.cpp4
-rw-r--r--editor/filesystem_dock.h2
-rw-r--r--editor/plugins/animation_state_machine_editor.cpp45
-rw-r--r--editor/plugins/animation_state_machine_editor.h2
-rw-r--r--editor/plugins/canvas_item_editor_plugin.cpp2
7 files changed, 93 insertions, 47 deletions
diff --git a/editor/editor_autoload_settings.cpp b/editor/editor_autoload_settings.cpp
index 829948d3cb..b37b06748d 100644
--- a/editor/editor_autoload_settings.cpp
+++ b/editor/editor_autoload_settings.cpp
@@ -35,6 +35,7 @@
#include "editor/editor_file_dialog.h"
#include "editor/editor_node.h"
#include "editor/editor_scale.h"
+#include "editor/filesystem_dock.h"
#include "project_settings_editor.h"
#include "scene/main/window.h"
#include "scene/resources/packed_scene.h"
@@ -63,6 +64,28 @@ void EditorAutoloadSettings::_notification(int p_what) {
case NOTIFICATION_THEME_CHANGED: {
browse_button->set_icon(get_theme_icon(SNAME("Folder"), SNAME("EditorIcons")));
} break;
+
+ case NOTIFICATION_VISIBILITY_CHANGED: {
+ FileSystemDock *dock = FileSystemDock::get_singleton();
+
+ if (dock != nullptr) {
+ ScriptCreateDialog *dialog = dock->get_script_create_dialog();
+
+ if (dialog != nullptr) {
+ Callable script_created = callable_mp(this, &EditorAutoloadSettings::_script_created);
+
+ if (is_visible_in_tree()) {
+ if (!dialog->is_connected(SNAME("script_created"), script_created)) {
+ dialog->connect("script_created", script_created);
+ }
+ } else {
+ if (dialog->is_connected(SNAME("script_created"), script_created)) {
+ dialog->disconnect("script_created", script_created);
+ }
+ }
+ }
+ }
+ } break;
}
}
@@ -134,12 +157,22 @@ bool EditorAutoloadSettings::_autoload_name_is_valid(const String &p_name, Strin
}
void EditorAutoloadSettings::_autoload_add() {
- if (autoload_add(autoload_add_name->get_text(), autoload_add_path->get_text())) {
- autoload_add_path->set_text("");
- }
+ if (autoload_add_path->get_text().is_empty()) {
+ ScriptCreateDialog *dialog = FileSystemDock::get_singleton()->get_script_create_dialog();
+ String fpath = path;
+ if (!fpath.ends_with("/")) {
+ fpath = fpath.get_base_dir();
+ }
+ dialog->config("Node", fpath.plus_file(vformat("%s.gd", autoload_add_name->get_text().camelcase_to_underscore())), false, false);
+ dialog->popup_centered();
+ } else {
+ if (autoload_add(autoload_add_name->get_text(), autoload_add_path->get_text())) {
+ autoload_add_path->set_text("");
+ }
- autoload_add_name->set_text("");
- add_autoload->set_disabled(true);
+ autoload_add_name->set_text("");
+ add_autoload->set_disabled(true);
+ }
}
void EditorAutoloadSettings::_autoload_selected() {
@@ -351,14 +384,13 @@ void EditorAutoloadSettings::_autoload_text_submitted(const String p_name) {
}
void EditorAutoloadSettings::_autoload_path_text_changed(const String p_path) {
- add_autoload->set_disabled(
- p_path.is_empty() || !_autoload_name_is_valid(autoload_add_name->get_text(), nullptr));
+ add_autoload->set_disabled(!_autoload_name_is_valid(autoload_add_name->get_text(), nullptr));
}
void EditorAutoloadSettings::_autoload_text_changed(const String p_name) {
String error_string;
bool is_name_valid = _autoload_name_is_valid(p_name, &error_string);
- add_autoload->set_disabled(autoload_add_path->get_text().is_empty() || !is_name_valid);
+ add_autoload->set_disabled(!is_name_valid);
error_message->set_text(error_string);
error_message->set_visible(!autoload_add_name->get_text().is_empty() && !is_name_valid);
}
@@ -540,6 +572,14 @@ void EditorAutoloadSettings::update_autoload() {
updating_autoload = false;
}
+void EditorAutoloadSettings::_script_created(Ref<Script> p_script) {
+ FileSystemDock::get_singleton()->get_script_create_dialog()->hide();
+ path = p_script->get_path().get_base_dir();
+ autoload_add_path->set_text(p_script->get_path());
+ autoload_add_name->set_text(p_script->get_path().get_file().get_basename().capitalize().replace(" ", ""));
+ _autoload_add();
+}
+
Variant EditorAutoloadSettings::get_drag_data_fw(const Point2 &p_point, Control *p_control) {
if (autoload_cache.size() <= 1) {
return false;
@@ -833,11 +873,6 @@ EditorAutoloadSettings::EditorAutoloadSettings() {
}
}
- autoload_changed = "autoload_changed";
-
- updating_autoload = false;
- selected_autoload = "";
-
HBoxContainer *hbc = memnew(HBoxContainer);
add_child(hbc);
@@ -854,6 +889,8 @@ EditorAutoloadSettings::EditorAutoloadSettings() {
autoload_add_path = memnew(LineEdit);
hbc->add_child(autoload_add_path);
autoload_add_path->set_h_size_flags(Control::SIZE_EXPAND_FILL);
+ autoload_add_path->set_clear_button_enabled(true);
+ autoload_add_path->set_placeholder(vformat(TTR(R"(Set path or press "%s" to create a script.)"), TTR("Add")));
autoload_add_path->connect("text_changed", callable_mp(this, &EditorAutoloadSettings::_autoload_path_text_changed));
browse_button = memnew(Button);
diff --git a/editor/editor_autoload_settings.h b/editor/editor_autoload_settings.h
index 044eea4245..380cadbebb 100644
--- a/editor/editor_autoload_settings.h
+++ b/editor/editor_autoload_settings.h
@@ -47,7 +47,8 @@ class EditorAutoloadSettings : public VBoxContainer {
BUTTON_DELETE
};
- String autoload_changed;
+ String path = "res://";
+ String autoload_changed = "autoload_changed";
struct AutoloadInfo {
String name;
@@ -64,17 +65,16 @@ class EditorAutoloadSettings : public VBoxContainer {
List<AutoloadInfo> autoload_cache;
- bool updating_autoload;
- int number_of_autoloads;
+ bool updating_autoload = false;
String selected_autoload;
- Tree *tree;
- LineEdit *autoload_add_name;
- Button *add_autoload;
- LineEdit *autoload_add_path;
- Label *error_message;
- Button *browse_button;
- EditorFileDialog *file_dialog;
+ Tree *tree = nullptr;
+ LineEdit *autoload_add_name = nullptr;
+ Button *add_autoload = nullptr;
+ LineEdit *autoload_add_path = nullptr;
+ Label *error_message = nullptr;
+ Button *browse_button = nullptr;
+ EditorFileDialog *file_dialog = nullptr;
bool _autoload_name_is_valid(const String &p_name, String *r_error = nullptr);
@@ -90,6 +90,8 @@ class EditorAutoloadSettings : public VBoxContainer {
void _autoload_file_callback(const String &p_path);
Node *_create_autoload(const String &p_path);
+ void _script_created(Ref<Script> p_script);
+
Variant get_drag_data_fw(const Point2 &p_point, Control *p_control);
bool can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_control) const;
void drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_control);
diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp
index 4a25e44ed6..d9539784ac 100644
--- a/editor/filesystem_dock.cpp
+++ b/editor/filesystem_dock.cpp
@@ -2087,6 +2087,10 @@ void FileSystemDock::focus_on_filter() {
}
}
+ScriptCreateDialog *FileSystemDock::get_script_create_dialog() const {
+ return make_script_dialog;
+}
+
void FileSystemDock::set_file_list_display_mode(FileListDisplayMode p_mode) {
if (p_mode == file_list_display_mode) {
return;
diff --git a/editor/filesystem_dock.h b/editor/filesystem_dock.h
index d457c6acd4..e98ffd68b4 100644
--- a/editor/filesystem_dock.h
+++ b/editor/filesystem_dock.h
@@ -320,6 +320,8 @@ public:
void navigate_to_path(const String &p_path);
void focus_on_filter();
+ ScriptCreateDialog *get_script_create_dialog() const;
+
void fix_dependencies(const String &p_for_file);
int get_split_offset() { return split_box->get_split_offset(); }
diff --git a/editor/plugins/animation_state_machine_editor.cpp b/editor/plugins/animation_state_machine_editor.cpp
index 2f94176e2a..bd0c1afd19 100644
--- a/editor/plugins/animation_state_machine_editor.cpp
+++ b/editor/plugins/animation_state_machine_editor.cpp
@@ -346,29 +346,21 @@ void AnimationNodeStateMachineEditor::_state_machine_gui_input(const Ref<InputEv
state_machine_draw->update();
}
- //put ibeam (text cursor) over names to make it clearer that they are editable
if (mm.is_valid()) {
state_machine_draw->grab_focus();
- bool over_text_now = false;
String new_over_node = StringName();
int new_over_node_what = -1;
if (tool_select->is_pressed()) {
- for (int i = node_rects.size() - 1; i >= 0; i--) { //inverse to draw order
-
- if (node_rects[i].name.has_point(mm->get_position())) {
- over_text_now = true;
- break;
- }
-
+ for (int i = node_rects.size() - 1; i >= 0; i--) { // Inverse to draw order.
if (node_rects[i].node.has_point(mm->get_position())) {
new_over_node = node_rects[i].node_name;
if (node_rects[i].play.has_point(mm->get_position())) {
new_over_node_what = 0;
- }
- if (node_rects[i].edit.has_point(mm->get_position())) {
+ } else if (node_rects[i].edit.has_point(mm->get_position())) {
new_over_node_what = 1;
}
+ break;
}
}
}
@@ -378,16 +370,6 @@ void AnimationNodeStateMachineEditor::_state_machine_gui_input(const Ref<InputEv
over_node_what = new_over_node_what;
state_machine_draw->update();
}
-
- if (over_text != over_text_now) {
- if (over_text_now) {
- state_machine_draw->set_default_cursor_shape(CURSOR_IBEAM);
- } else {
- state_machine_draw->set_default_cursor_shape(CURSOR_ARROW);
- }
-
- over_text = over_text_now;
- }
}
Ref<InputEventPanGesture> pan_gesture = p_event;
@@ -397,6 +379,23 @@ void AnimationNodeStateMachineEditor::_state_machine_gui_input(const Ref<InputEv
}
}
+Control::CursorShape AnimationNodeStateMachineEditor::get_cursor_shape(const Point2 &p_pos) const {
+ // Put ibeam (text cursor) over names to make it clearer that they are editable.
+ Transform2D xform = panel->get_transform() * state_machine_draw->get_transform();
+ Point2 pos = xform.xform_inv(p_pos);
+ Control::CursorShape cursor_shape = get_default_cursor_shape();
+
+ for (int i = node_rects.size() - 1; i >= 0; i--) { // Inverse to draw order.
+ if (node_rects[i].node.has_point(pos)) {
+ if (node_rects[i].name.has_point(pos)) {
+ cursor_shape = Control::CURSOR_IBEAM;
+ }
+ break;
+ }
+ }
+ return cursor_shape;
+}
+
void AnimationNodeStateMachineEditor::_file_opened(const String &p_file) {
file_loaded = ResourceLoader::load(p_file);
if (file_loaded.is_valid()) {
@@ -1287,6 +1286,7 @@ AnimationNodeStateMachineEditor::AnimationNodeStateMachineEditor() {
panel = memnew(PanelContainer);
panel->set_clip_contents(true);
+ panel->set_mouse_filter(Control::MOUSE_FILTER_PASS);
add_child(panel);
panel->set_v_size_flags(SIZE_EXPAND_FILL);
@@ -1295,6 +1295,7 @@ AnimationNodeStateMachineEditor::AnimationNodeStateMachineEditor() {
state_machine_draw->connect("gui_input", callable_mp(this, &AnimationNodeStateMachineEditor::_state_machine_gui_input));
state_machine_draw->connect("draw", callable_mp(this, &AnimationNodeStateMachineEditor::_state_machine_draw));
state_machine_draw->set_focus_mode(FOCUS_ALL);
+ state_machine_draw->set_mouse_filter(Control::MOUSE_FILTER_PASS);
state_machine_play_pos = memnew(Control);
state_machine_draw->add_child(state_machine_play_pos);
@@ -1347,8 +1348,6 @@ AnimationNodeStateMachineEditor::AnimationNodeStateMachineEditor() {
open_file->connect("file_selected", callable_mp(this, &AnimationNodeStateMachineEditor::_file_opened));
undo_redo = EditorNode::get_undo_redo();
- over_text = false;
-
over_node_what = -1;
dragging_selected_attempt = false;
connecting = false;
diff --git a/editor/plugins/animation_state_machine_editor.h b/editor/plugins/animation_state_machine_editor.h
index 208bd27f8e..03991d00f9 100644
--- a/editor/plugins/animation_state_machine_editor.h
+++ b/editor/plugins/animation_state_machine_editor.h
@@ -138,7 +138,6 @@ class AnimationNodeStateMachineEditor : public AnimationTreeNodeEditorPlugin {
StringName selected_transition_from;
StringName selected_transition_to;
- bool over_text;
StringName over_node;
int over_node_what;
@@ -185,6 +184,7 @@ public:
static AnimationNodeStateMachineEditor *get_singleton() { return singleton; }
virtual bool can_edit(const Ref<AnimationNode> &p_node) override;
virtual void edit(const Ref<AnimationNode> &p_node) override;
+ virtual CursorShape get_cursor_shape(const Point2 &p_pos) const override;
AnimationNodeStateMachineEditor();
};
diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp
index 75f97efdbc..4ee4eb86af 100644
--- a/editor/plugins/canvas_item_editor_plugin.cpp
+++ b/editor/plugins/canvas_item_editor_plugin.cpp
@@ -1139,6 +1139,8 @@ bool CanvasItemEditor::_gui_input_rulers_and_guides(const Ref<InputEvent> &p_eve
}
}
}
+ snap_target[0] = SNAP_TARGET_NONE;
+ snap_target[1] = SNAP_TARGET_NONE;
drag_type = DRAG_NONE;
viewport->update();
return true;