summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
Diffstat (limited to 'editor')
-rw-r--r--editor/editor_inspector.cpp2
-rw-r--r--editor/editor_node.cpp3
-rw-r--r--editor/plugins/script_editor_plugin.cpp30
-rw-r--r--editor/plugins/script_text_editor.cpp4
-rw-r--r--editor/plugins/shader_editor_plugin.cpp5
-rw-r--r--editor/plugins/text_editor.cpp2
-rw-r--r--editor/property_editor.cpp44
-rw-r--r--editor/property_editor.h1
-rw-r--r--editor/scene_tree_dock.cpp4
9 files changed, 48 insertions, 47 deletions
diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp
index 9f049a0e58..16567cfebb 100644
--- a/editor/editor_inspector.cpp
+++ b/editor/editor_inspector.cpp
@@ -3490,7 +3490,7 @@ void EditorInspector::_update_script_class_properties(const Object &p_object, Li
String path = s->get_path();
String name = EditorNode::get_editor_data().script_class_get_name(path);
if (name.is_empty()) {
- if (!path.is_empty() && path.find("::") == -1) {
+ if (!s->is_built_in()) {
name = path.get_file();
} else {
name = TTR("Built-in script");
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index a7b8a25186..d855085719 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -2256,7 +2256,8 @@ void EditorNode::_edit_current() {
if (main_plugin) {
// special case if use of external editor is true
- if (main_plugin->get_name() == "Script" && current_obj->get_class_name() != StringName("VisualScript") && (bool(EditorSettings::get_singleton()->get("text_editor/external/use_external_editor")) || overrides_external_editor(current_obj))) {
+ Resource *res = Object::cast_to<Resource>(current_obj);
+ if (main_plugin->get_name() == "Script" && current_obj->get_class_name() != StringName("VisualScript") && res && !res->is_built_in() && (bool(EditorSettings::get_singleton()->get("text_editor/external/use_external_editor")) || overrides_external_editor(current_obj))) {
if (!changing_scene) {
main_plugin->edit(current_obj);
}
diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp
index 3f98560a2f..aad378ecec 100644
--- a/editor/plugins/script_editor_plugin.cpp
+++ b/editor/plugins/script_editor_plugin.cpp
@@ -227,12 +227,6 @@ void ScriptEditorBase::_bind_methods() {
ADD_SIGNAL(MethodInfo("replace_in_files_requested", PropertyInfo(Variant::STRING, "text")));
}
-static bool _is_built_in_script(Script *p_script) {
- String path = p_script->get_path();
-
- return path.find("::") != -1;
-}
-
class EditorScriptCodeCompletionCache : public ScriptCodeCompletionCache {
struct Cache {
uint64_t time_loaded = 0;
@@ -764,7 +758,7 @@ void ScriptEditor::_close_tab(int p_idx, bool p_save, bool p_history_back) {
if (p_save && file.is_valid()) {
// Do not try to save internal scripts, but prompt to save in-memory
// scripts which are not saved to disk yet (have empty path).
- if (file->get_path().find("local://") == -1 && file->get_path().find("::") == -1) {
+ if (file->is_built_in()) {
save_current_script();
}
}
@@ -910,7 +904,7 @@ void ScriptEditor::_resave_scripts(const String &p_str) {
RES script = se->get_edited_resource();
- if (script->get_path() == "" || script->get_path().find("local://") != -1 || script->get_path().find("::") != -1) {
+ if (script->is_built_in()) {
continue; //internal script, who cares
}
@@ -951,7 +945,7 @@ void ScriptEditor::_reload_scripts() {
RES edited_res = se->get_edited_resource();
- if (edited_res->get_path() == "" || edited_res->get_path().find("local://") != -1 || edited_res->get_path().find("::") != -1) {
+ if (edited_res->is_built_in()) {
continue; //internal script, who cares
}
@@ -995,7 +989,7 @@ void ScriptEditor::_res_saved_callback(const Ref<Resource> &p_res) {
RES script = se->get_edited_resource();
- if (script->get_path() == "" || script->get_path().find("local://") != -1 || script->get_path().find("::") != -1) {
+ if (script->is_built_in()) {
continue; //internal script, who cares
}
@@ -1037,7 +1031,7 @@ bool ScriptEditor::_test_script_times_on_disk(RES p_for_script) {
continue;
}
- if (edited_res->get_path() == "" || edited_res->get_path().find("local://") != -1 || edited_res->get_path().find("::") != -1) {
+ if (edited_res->is_built_in()) {
continue; //internal script, who cares
}
@@ -1624,7 +1618,7 @@ void ScriptEditor::close_builtin_scripts_from_scene(const String &p_scene) {
continue;
}
- if (script->get_path().find("::") != -1 && script->get_path().begins_with(p_scene)) { //is an internal script and belongs to scene being closed
+ if (script->is_built_in() && script->get_path().begins_with(p_scene)) { //is an internal script and belongs to scene being closed
_close_tab(i);
i--;
}
@@ -2180,9 +2174,10 @@ bool ScriptEditor::edit(const RES &p_resource, int p_line, int p_col, bool p_gra
Ref<Script> script = p_resource;
// Don't open dominant script if using an external editor.
- const bool use_external_editor =
+ bool use_external_editor =
EditorSettings::get_singleton()->get("text_editor/external/use_external_editor") ||
(script.is_valid() && script->get_language()->overrides_external_editor());
+ use_external_editor = use_external_editor && !(script.is_valid() && script->is_built_in()); // Ignore external editor for built-in scripts.
const bool open_dominant = EditorSettings::get_singleton()->get("text_editor/behavior/files/open_dominant_script_on_scene_change");
const bool should_open = (open_dominant && !use_external_editor) || !EditorNode::get_singleton()->is_changing_scene();
@@ -2450,7 +2445,7 @@ void ScriptEditor::save_all_scripts() {
se->apply_code();
}
- if (edited_res->get_path() != "" && edited_res->get_path().find("local://") == -1 && edited_res->get_path().find("::") == -1) {
+ if (!edited_res->is_built_in()) {
Ref<TextFile> text_file = edited_res;
Ref<Script> script = edited_res;
@@ -2570,7 +2565,7 @@ void ScriptEditor::_add_callback(Object *p_obj, const String &p_function, const
script_list->select(script_list->find_metadata(i));
// Save the current script so the changes can be picked up by an external editor.
- if (!_is_built_in_script(script.ptr())) { // But only if it's not built-in script.
+ if (!script.ptr()->is_built_in()) { // But only if it's not built-in script.
save_current_script();
}
@@ -3346,9 +3341,10 @@ Array ScriptEditor::_get_open_script_editors() const {
void ScriptEditor::set_scene_root_script(Ref<Script> p_script) {
// Don't open dominant script if using an external editor.
- const bool use_external_editor =
+ bool use_external_editor =
EditorSettings::get_singleton()->get("text_editor/external/use_external_editor") ||
(p_script.is_valid() && p_script->get_language()->overrides_external_editor());
+ use_external_editor = use_external_editor && !(p_script.is_valid() && p_script->is_built_in()); // Ignore external editor for built-in scripts.
const bool open_dominant = EditorSettings::get_singleton()->get("text_editor/behavior/files/open_dominant_script_on_scene_change");
if (open_dominant && !use_external_editor && p_script.is_valid()) {
@@ -3858,7 +3854,7 @@ void ScriptEditorPlugin::edit(Object *p_object) {
Script *p_script = Object::cast_to<Script>(p_object);
String res_path = p_script->get_path().get_slice("::", 0);
- if (_is_built_in_script(p_script)) {
+ if (p_script->is_built_in()) {
if (ResourceLoader::get_resource_type(res_path) == "PackedScene") {
if (!EditorNode::get_singleton()->is_scene_open(res_path)) {
EditorNode::get_singleton()->load_scene(res_path);
diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp
index 219498b5e7..24cdc06d78 100644
--- a/editor/plugins/script_text_editor.cpp
+++ b/editor/plugins/script_text_editor.cpp
@@ -375,7 +375,7 @@ void ScriptTextEditor::ensure_focus() {
String ScriptTextEditor::get_name() {
String name;
- if (script->get_path().find("local://") == -1 && script->get_path().find("::") == -1) {
+ if (!script->is_built_in()) {
name = script->get_path().get_file();
if (is_unsaved()) {
if (script->get_path().is_empty()) {
@@ -658,7 +658,7 @@ void ScriptEditor::_update_modified_scripts_for_external_editor(Ref<Script> p_fo
continue;
}
- if (script->get_path() == "" || script->get_path().find("local://") != -1 || script->get_path().find("::") != -1) {
+ if (script->is_built_in()) {
continue; //internal script, who cares, though weird
}
diff --git a/editor/plugins/shader_editor_plugin.cpp b/editor/plugins/shader_editor_plugin.cpp
index 2731582288..9d2b4c88c5 100644
--- a/editor/plugins/shader_editor_plugin.cpp
+++ b/editor/plugins/shader_editor_plugin.cpp
@@ -482,8 +482,7 @@ void ShaderEditor::_check_for_external_edit() {
return;
}
- // internal shader.
- if (shader->get_path() == "" || shader->get_path().find("local://") != -1 || shader->get_path().find("::") != -1) {
+ if (shader->is_built_in()) {
return;
}
@@ -530,7 +529,7 @@ void ShaderEditor::save_external_data(const String &p_str) {
}
apply_shaders();
- if (shader->get_path() != "" && shader->get_path().find("local://") == -1 && shader->get_path().find("::") == -1) {
+ if (!shader->is_built_in()) {
//external shader, save it
ResourceSaver::save(shader->get_path(), shader);
}
diff --git a/editor/plugins/text_editor.cpp b/editor/plugins/text_editor.cpp
index 1fc7eb98e0..3b45f32927 100644
--- a/editor/plugins/text_editor.cpp
+++ b/editor/plugins/text_editor.cpp
@@ -65,7 +65,7 @@ void TextEditor::_load_theme_settings() {
String TextEditor::get_name() {
String name;
- if (text_file->get_path().find("local://") == -1 && text_file->get_path().find("::") == -1) {
+ if (!text_file->is_built_in()) {
name = text_file->get_path().get_file();
if (is_unsaved()) {
if (text_file->get_path().is_empty()) {
diff --git a/editor/property_editor.cpp b/editor/property_editor.cpp
index db560af657..62c5cc5cc1 100644
--- a/editor/property_editor.cpp
+++ b/editor/property_editor.cpp
@@ -1671,7 +1671,7 @@ void CustomPropertyEditor::_focus_exit() {
}
void CustomPropertyEditor::config_action_buttons(const List<String> &p_strings) {
- Ref<StyleBox> sb = action_buttons[0]->get_theme_stylebox(SNAME("panel"));
+ Ref<StyleBox> sb = action_buttons[0]->get_theme_stylebox(SNAME("button"));
int margin_top = sb->get_margin(SIDE_TOP);
int margin_left = sb->get_margin(SIDE_LEFT);
int margin_bottom = sb->get_margin(SIDE_BOTTOM);
@@ -1804,26 +1804,18 @@ CustomPropertyEditor::CustomPropertyEditor() {
}
text_edit = memnew(TextEdit);
- add_child(text_edit);
+ value_vbox->add_child(text_edit);
text_edit->set_anchors_and_offsets_preset(Control::PRESET_WIDE, Control::PRESET_MODE_MINSIZE, 5);
+ text_edit->set_v_size_flags(Control::SIZE_EXPAND_FILL);
text_edit->set_offset(SIDE_BOTTOM, -30);
text_edit->hide();
text_edit->connect("text_changed", callable_mp(this, &CustomPropertyEditor::_text_edit_changed));
- for (int i = 0; i < MAX_ACTION_BUTTONS; i++) {
- action_buttons[i] = memnew(Button);
- action_buttons[i]->hide();
- add_child(action_buttons[i]);
- Vector<Variant> binds;
- binds.push_back(i);
- action_buttons[i]->connect("pressed", callable_mp(this, &CustomPropertyEditor::_action_pressed), binds);
- }
-
color_picker = nullptr;
file = memnew(EditorFileDialog);
- add_child(file);
+ value_vbox->add_child(file);
file->hide();
file->connect("file_selected", callable_mp(this, &CustomPropertyEditor::_file_selected));
@@ -1831,46 +1823,58 @@ CustomPropertyEditor::CustomPropertyEditor() {
error = memnew(ConfirmationDialog);
error->set_title(TTR("Error!"));
- add_child(error);
+ value_vbox->add_child(error);
scene_tree = memnew(SceneTreeDialog);
- add_child(scene_tree);
+ value_vbox->add_child(scene_tree);
scene_tree->connect("selected", callable_mp(this, &CustomPropertyEditor::_node_path_selected));
scene_tree->get_scene_tree()->set_show_enabled_subscene(true);
texture_preview = memnew(TextureRect);
- add_child(texture_preview);
+ value_vbox->add_child(texture_preview);
texture_preview->hide();
easing_draw = memnew(Control);
- add_child(easing_draw);
+ value_vbox->add_child(easing_draw);
easing_draw->hide();
easing_draw->connect("draw", callable_mp(this, &CustomPropertyEditor::_draw_easing));
easing_draw->connect("gui_input", callable_mp(this, &CustomPropertyEditor::_drag_easing));
easing_draw->set_default_cursor_shape(Control::CURSOR_MOVE);
type_button = memnew(MenuButton);
- add_child(type_button);
+ value_vbox->add_child(type_button);
type_button->hide();
type_button->get_popup()->connect("id_pressed", callable_mp(this, &CustomPropertyEditor::_type_create_selected));
menu = memnew(PopupMenu);
// menu->set_pass_on_modal_close_click(false);
- add_child(menu);
+ value_vbox->add_child(menu);
menu->connect("id_pressed", callable_mp(this, &CustomPropertyEditor::_menu_option));
evaluator = nullptr;
spinbox = memnew(SpinBox);
- add_child(spinbox);
+ value_vbox->add_child(spinbox);
spinbox->set_anchors_and_offsets_preset(Control::PRESET_WIDE, Control::PRESET_MODE_MINSIZE, 5);
spinbox->connect("value_changed", callable_mp(this, &CustomPropertyEditor::_range_modified));
slider = memnew(HSlider);
- add_child(slider);
+ value_vbox->add_child(slider);
slider->set_anchors_and_offsets_preset(Control::PRESET_WIDE, Control::PRESET_MODE_MINSIZE, 5);
slider->connect("value_changed", callable_mp(this, &CustomPropertyEditor::_range_modified));
+ action_hboxes = memnew(HBoxContainer);
+ action_hboxes->set_alignment(BoxContainer::ALIGN_CENTER);
+ value_vbox->add_child(action_hboxes);
+ for (int i = 0; i < MAX_ACTION_BUTTONS; i++) {
+ action_buttons[i] = memnew(Button);
+ action_buttons[i]->hide();
+ action_hboxes->add_child(action_buttons[i]);
+ Vector<Variant> binds;
+ binds.push_back(i);
+ action_buttons[i]->connect("pressed", callable_mp(this, &CustomPropertyEditor::_action_pressed), binds);
+ }
+
create_dialog = nullptr;
property_select = nullptr;
}
diff --git a/editor/property_editor.h b/editor/property_editor.h
index 23771b7494..2565c6ee27 100644
--- a/editor/property_editor.h
+++ b/editor/property_editor.h
@@ -110,6 +110,7 @@ class CustomPropertyEditor : public PopupPanel {
int focused_value_editor;
Label *value_label[MAX_VALUE_EDITORS];
HScrollBar *scroll[4];
+ HBoxContainer *action_hboxes;
Button *action_buttons[MAX_ACTION_BUTTONS];
MenuButton *type_button;
Vector<String> inheritors_array;
diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp
index 6798cff7e3..6da3e78da9 100644
--- a/editor/scene_tree_dock.cpp
+++ b/editor/scene_tree_dock.cpp
@@ -3152,7 +3152,7 @@ void SceneTreeDock::_create_remap_for_node(Node *p_node, Map<RES, RES> &r_remap)
}
}
- if ((res->get_path() == "" || res->get_path().find("::") > -1) && !r_remap.has(res)) {
+ if (res->is_built_in() && !r_remap.has(res)) {
_create_remap_for_resource(res, r_remap);
}
}
@@ -3179,7 +3179,7 @@ void SceneTreeDock::_create_remap_for_resource(RES p_resource, Map<RES, RES> &r_
if (v.is_ref()) {
RES res = v;
if (res.is_valid()) {
- if ((res->get_path() == "" || res->get_path().find("::") > -1) && !r_remap.has(res)) {
+ if (res->is_built_in() && !r_remap.has(res)) {
_create_remap_for_resource(res, r_remap);
}
}