diff options
Diffstat (limited to 'editor')
-rw-r--r-- | editor/animation_track_editor.cpp | 5 | ||||
-rw-r--r-- | editor/code_editor.cpp | 2 | ||||
-rw-r--r-- | editor/editor_data.cpp | 2 | ||||
-rw-r--r-- | editor/filesystem_dock.cpp | 2 | ||||
-rw-r--r-- | editor/groups_editor.cpp | 12 | ||||
-rw-r--r-- | editor/import/editor_scene_importer_gltf.cpp | 10 | ||||
-rw-r--r-- | editor/import/editor_scene_importer_gltf.h | 1 | ||||
-rw-r--r-- | editor/import/resource_importer_obj.cpp | 14 | ||||
-rw-r--r-- | editor/plugins/animation_tree_editor_plugin.cpp | 3 | ||||
-rw-r--r-- | editor/plugins/audio_stream_editor_plugin.cpp | 3 | ||||
-rw-r--r-- | editor/plugins/resource_preloader_editor_plugin.cpp | 3 | ||||
-rw-r--r-- | editor/plugins/script_editor_plugin.cpp | 2 | ||||
-rw-r--r-- | editor/plugins/shader_editor_plugin.cpp | 3 | ||||
-rw-r--r-- | editor/plugins/tile_set_editor_plugin.cpp | 28 | ||||
-rw-r--r-- | editor/plugins/visual_shader_editor_plugin.cpp | 2 | ||||
-rw-r--r-- | editor/script_create_dialog.cpp | 40 | ||||
-rw-r--r-- | editor/script_create_dialog.h | 3 |
17 files changed, 86 insertions, 49 deletions
diff --git a/editor/animation_track_editor.cpp b/editor/animation_track_editor.cpp index cd19ceb868..f6d5312fc7 100644 --- a/editor/animation_track_editor.cpp +++ b/editor/animation_track_editor.cpp @@ -3790,8 +3790,9 @@ void AnimationTrackEditor::insert_value_key(const String &p_property, const Vari value = p_value; //all good } else { String tpath = animation->track_get_path(i); - if (NodePath(tpath.get_basename()) == np) { - String subindex = tpath.get_extension(); + int index = tpath.find_last(":"); + if (NodePath(tpath.substr(0, index + 1)) == np) { + String subindex = tpath.substr(index + 1, tpath.length() - index); value = p_value.get(subindex); } else { continue; diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp index e5b4cbdda1..fa713349d4 100644 --- a/editor/code_editor.cpp +++ b/editor/code_editor.cpp @@ -900,7 +900,7 @@ void CodeTextEditor::update_editor_settings() { text_editor->set_smooth_scroll_enabled(EditorSettings::get_singleton()->get("text_editor/navigation/smooth_scrolling")); text_editor->set_v_scroll_speed(EditorSettings::get_singleton()->get("text_editor/navigation/v_scroll_speed")); text_editor->set_draw_minimap(EditorSettings::get_singleton()->get("text_editor/navigation/show_minimap")); - text_editor->set_minimap_width(EditorSettings::get_singleton()->get("text_editor/navigation/minimap_width")); + text_editor->set_minimap_width((int)EditorSettings::get_singleton()->get("text_editor/navigation/minimap_width") * EDSCALE); text_editor->set_show_line_numbers(EditorSettings::get_singleton()->get("text_editor/appearance/show_line_numbers")); text_editor->set_line_numbers_zero_padded(EditorSettings::get_singleton()->get("text_editor/appearance/line_numbers_zero_padded")); text_editor->set_bookmark_gutter_enabled(EditorSettings::get_singleton()->get("text_editor/appearance/show_bookmark_gutter")); diff --git a/editor/editor_data.cpp b/editor/editor_data.cpp index 8ca202a411..0b43fd5ac0 100644 --- a/editor/editor_data.cpp +++ b/editor/editor_data.cpp @@ -314,7 +314,7 @@ void EditorData::copy_object_params(Object *p_object) { for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) { - if (!(E->get().usage & PROPERTY_USAGE_EDITOR)) + if (!(E->get().usage & PROPERTY_USAGE_EDITOR) || E->get().name == "script" || E->get().name == "scripts") continue; PropertyData pd; diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp index f74cadf67e..93e9cc58fb 100644 --- a/editor/filesystem_dock.cpp +++ b/editor/filesystem_dock.cpp @@ -1761,7 +1761,7 @@ void FileSystemDock::_file_option(int p_option, const Vector<String> &p_selected if (!fpath.ends_with("/")) { fpath = fpath.get_base_dir(); } - make_script_dialog->config("Node", fpath.plus_file("new_script.gd"), false); + make_script_dialog->config("Node", fpath.plus_file("new_script.gd"), false, false); make_script_dialog->popup_centered(); } break; diff --git a/editor/groups_editor.cpp b/editor/groups_editor.cpp index c19bee321a..83259afb35 100644 --- a/editor/groups_editor.cpp +++ b/editor/groups_editor.cpp @@ -215,7 +215,7 @@ void GroupDialog::_group_renamed() { return; } - String name = renamed_group->get_text(0).strip_edges(); + const String name = renamed_group->get_text(0).strip_edges(); for (TreeItem *E = groups_root->get_children(); E; E = E->get_next()) { if (E != renamed_group && E->get_text(0) == name) { renamed_group->set_text(0, selected_group); @@ -232,6 +232,8 @@ void GroupDialog::_group_renamed() { return; } + renamed_group->set_text(0, name); // Spaces trimmed. + undo_redo->create_action(TTR("Rename Group")); List<Node *> nodes; @@ -254,8 +256,8 @@ void GroupDialog::_group_renamed() { undo_redo->add_undo_method(this, "_delete_group_item", selected_group); } - undo_redo->add_do_method(this, "_rename_group_item", selected_group, renamed_group->get_text(0)); - undo_redo->add_undo_method(this, "_rename_group_item", renamed_group->get_text(0), selected_group); + undo_redo->add_do_method(this, "_rename_group_item", selected_group, name); + undo_redo->add_undo_method(this, "_rename_group_item", name, selected_group); undo_redo->add_do_method(this, "_group_selected"); undo_redo->add_undo_method(this, "_group_selected"); undo_redo->add_do_method(this, "emit_signal", "group_edited"); @@ -550,8 +552,8 @@ void GroupsEditor::_add_group(const String &p_group) { if (!node) return; - String name = group_name->get_text(); - if (name.strip_edges() == "") + const String name = group_name->get_text().strip_edges(); + if (name.empty()) return; if (node->is_in_group(name)) diff --git a/editor/import/editor_scene_importer_gltf.cpp b/editor/import/editor_scene_importer_gltf.cpp index f5128103f3..7de6db7add 100644 --- a/editor/import/editor_scene_importer_gltf.cpp +++ b/editor/import/editor_scene_importer_gltf.cpp @@ -2329,7 +2329,11 @@ Error EditorSceneImporterGLTF::_parse_animations(GLTFState &state) { Array samplers = d["samplers"]; if (d.has("name")) { - animation.name = _sanitize_scene_name(d["name"]); + String name = d["name"]; + if (name.begins_with("loop") || name.ends_with("loop") || name.begins_with("cycle") || name.ends_with("cycle")) { + animation.loop = true; + } + animation.name = _sanitize_scene_name(name); } for (int j = 0; j < channels.size(); j++) { @@ -2735,6 +2739,10 @@ void EditorSceneImporterGLTF::_import_animation(GLTFState &state, AnimationPlaye animation.instance(); animation->set_name(name); + if (anim.loop) { + animation->set_loop(true); + } + float length = 0; for (Map<int, GLTFAnimation::Track>::Element *E = anim.tracks.front(); E; E = E->next()) { diff --git a/editor/import/editor_scene_importer_gltf.h b/editor/import/editor_scene_importer_gltf.h index 4a91b99aa7..78d7106b0d 100644 --- a/editor/import/editor_scene_importer_gltf.h +++ b/editor/import/editor_scene_importer_gltf.h @@ -262,6 +262,7 @@ class EditorSceneImporterGLTF : public EditorSceneImporter { }; struct GLTFAnimation { + bool loop = false; enum Interpolation { INTERP_LINEAR, diff --git a/editor/import/resource_importer_obj.cpp b/editor/import/resource_importer_obj.cpp index 06bbe17785..b1ed59a2db 100644 --- a/editor/import/resource_importer_obj.cpp +++ b/editor/import/resource_importer_obj.cpp @@ -203,7 +203,7 @@ static Error _parse_material_library(const String &p_path, Map<String, Ref<Spati return OK; } -static Error _parse_obj(const String &p_path, List<Ref<Mesh> > &r_meshes, bool p_single_mesh, bool p_generate_tangents, bool p_optimize, Vector3 p_scale_mesh, List<String> *r_missing_deps) { +static Error _parse_obj(const String &p_path, List<Ref<Mesh> > &r_meshes, bool p_single_mesh, bool p_generate_tangents, bool p_optimize, Vector3 p_scale_mesh, Vector3 p_offset_mesh, List<String> *r_missing_deps) { FileAccessRef f = FileAccess::open(p_path, FileAccess::READ); ERR_FAIL_COND_V_MSG(!f, ERR_CANT_OPEN, vformat("Couldn't open OBJ file '%s', it may not exist or not be readable.", p_path)); @@ -213,6 +213,7 @@ static Error _parse_obj(const String &p_path, List<Ref<Mesh> > &r_meshes, bool p bool generate_tangents = p_generate_tangents; Vector3 scale_mesh = p_scale_mesh; + Vector3 offset_mesh = p_offset_mesh; int mesh_flags = p_optimize ? Mesh::ARRAY_COMPRESS_DEFAULT : 0; Vector<Vector3> vertices; @@ -245,9 +246,9 @@ static Error _parse_obj(const String &p_path, List<Ref<Mesh> > &r_meshes, bool p Vector<String> v = l.split(" ", false); ERR_FAIL_COND_V(v.size() < 4, ERR_FILE_CORRUPT); Vector3 vtx; - vtx.x = v[1].to_float() * scale_mesh.x; - vtx.y = v[2].to_float() * scale_mesh.y; - vtx.z = v[3].to_float() * scale_mesh.z; + vtx.x = v[1].to_float() * scale_mesh.x + offset_mesh.x; + vtx.y = v[2].to_float() * scale_mesh.y + offset_mesh.y; + vtx.z = v[3].to_float() * scale_mesh.z + offset_mesh.z; vertices.push_back(vtx); } else if (l.begins_with("vt ")) { //uv @@ -421,7 +422,7 @@ Node *EditorOBJImporter::import_scene(const String &p_path, uint32_t p_flags, in List<Ref<Mesh> > meshes; - Error err = _parse_obj(p_path, meshes, false, p_flags & IMPORT_GENERATE_TANGENT_ARRAYS, p_flags & IMPORT_USE_COMPRESSION, Vector3(1, 1, 1), r_missing_deps); + Error err = _parse_obj(p_path, meshes, false, p_flags & IMPORT_GENERATE_TANGENT_ARRAYS, p_flags & IMPORT_USE_COMPRESSION, Vector3(1, 1, 1), Vector3(0, 0, 0), r_missing_deps); if (err != OK) { if (r_err) { @@ -489,6 +490,7 @@ void ResourceImporterOBJ::get_import_options(List<ImportOption> *r_options, int r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "generate_tangents"), true)); r_options->push_back(ImportOption(PropertyInfo(Variant::VECTOR3, "scale_mesh"), Vector3(1, 1, 1))); + r_options->push_back(ImportOption(PropertyInfo(Variant::VECTOR3, "offset_mesh"), Vector3(0, 0, 0))); r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "optimize_mesh"), true)); } bool ResourceImporterOBJ::get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const { @@ -500,7 +502,7 @@ Error ResourceImporterOBJ::import(const String &p_source_file, const String &p_s List<Ref<Mesh> > meshes; - Error err = _parse_obj(p_source_file, meshes, true, p_options["generate_tangents"], p_options["optimize_mesh"], p_options["scale_mesh"], NULL); + Error err = _parse_obj(p_source_file, meshes, true, p_options["generate_tangents"], p_options["optimize_mesh"], p_options["scale_mesh"], p_options["offset_mesh"], NULL); ERR_FAIL_COND_V(err != OK, err); ERR_FAIL_COND_V(meshes.size() != 1, ERR_BUG); diff --git a/editor/plugins/animation_tree_editor_plugin.cpp b/editor/plugins/animation_tree_editor_plugin.cpp index a0b58b8f7e..8dc7e4638d 100644 --- a/editor/plugins/animation_tree_editor_plugin.cpp +++ b/editor/plugins/animation_tree_editor_plugin.cpp @@ -39,6 +39,7 @@ #include "core/os/input.h" #include "core/os/keyboard.h" #include "core/project_settings.h" +#include "editor/editor_scale.h" #include "scene/animation/animation_blend_tree.h" #include "scene/animation/animation_player.h" #include "scene/gui/menu_button.h" @@ -284,7 +285,7 @@ AnimationTreeEditorPlugin::AnimationTreeEditorPlugin(EditorNode *p_node) { editor = p_node; anim_tree_editor = memnew(AnimationTreeEditor); - anim_tree_editor->set_custom_minimum_size(Size2(0, 300)); + anim_tree_editor->set_custom_minimum_size(Size2(0, 300) * EDSCALE); button = editor->add_bottom_panel_item(TTR("AnimationTree"), anim_tree_editor); button->hide(); diff --git a/editor/plugins/audio_stream_editor_plugin.cpp b/editor/plugins/audio_stream_editor_plugin.cpp index b6e5d48a83..60cb2ff54d 100644 --- a/editor/plugins/audio_stream_editor_plugin.cpp +++ b/editor/plugins/audio_stream_editor_plugin.cpp @@ -33,6 +33,7 @@ #include "core/io/resource_loader.h" #include "core/project_settings.h" #include "editor/audio_stream_preview.h" +#include "editor/editor_scale.h" #include "editor/editor_settings.h" void AudioStreamEditor::_notification(int p_what) { @@ -208,7 +209,7 @@ void AudioStreamEditor::_bind_methods() { AudioStreamEditor::AudioStreamEditor() { - set_custom_minimum_size(Size2(1, 100)); + set_custom_minimum_size(Size2(1, 100) * EDSCALE); _current = 0; _dragging = false; diff --git a/editor/plugins/resource_preloader_editor_plugin.cpp b/editor/plugins/resource_preloader_editor_plugin.cpp index d423be7d24..fb04f50827 100644 --- a/editor/plugins/resource_preloader_editor_plugin.cpp +++ b/editor/plugins/resource_preloader_editor_plugin.cpp @@ -32,6 +32,7 @@ #include "core/io/resource_loader.h" #include "core/project_settings.h" +#include "editor/editor_scale.h" #include "editor/editor_settings.h" void ResourcePreloaderEditor::_gui_input(Ref<InputEvent> p_event) { @@ -438,7 +439,7 @@ ResourcePreloaderEditorPlugin::ResourcePreloaderEditorPlugin(EditorNode *p_node) editor = p_node; preloader_editor = memnew(ResourcePreloaderEditor); - preloader_editor->set_custom_minimum_size(Size2(0, 250)); + preloader_editor->set_custom_minimum_size(Size2(0, 250) * EDSCALE); button = editor->add_bottom_panel_item(TTR("ResourcePreloader"), preloader_editor); button->hide(); diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index d0bd57d658..f13abd47a9 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -1004,7 +1004,7 @@ void ScriptEditor::_menu_option(int p_option) { ScriptEditorBase *current = _get_current_editor(); switch (p_option) { case FILE_NEW: { - script_create_dialog->config("Node", "new_script", false); + script_create_dialog->config("Node", "new_script", false, false); script_create_dialog->popup_centered(); } break; case FILE_NEW_TEXTFILE: { diff --git a/editor/plugins/shader_editor_plugin.cpp b/editor/plugins/shader_editor_plugin.cpp index 7e55415134..c0b5053f9d 100644 --- a/editor/plugins/shader_editor_plugin.cpp +++ b/editor/plugins/shader_editor_plugin.cpp @@ -35,6 +35,7 @@ #include "core/os/keyboard.h" #include "core/os/os.h" #include "editor/editor_node.h" +#include "editor/editor_scale.h" #include "editor/editor_settings.h" #include "editor/property_editor.h" #include "servers/visual/shader_types.h" @@ -756,7 +757,7 @@ ShaderEditorPlugin::ShaderEditorPlugin(EditorNode *p_node) { editor = p_node; shader_editor = memnew(ShaderEditor(p_node)); - shader_editor->set_custom_minimum_size(Size2(0, 300)); + shader_editor->set_custom_minimum_size(Size2(0, 300) * EDSCALE); button = editor->add_bottom_panel_item(TTR("Shader"), shader_editor); button->hide(); } diff --git a/editor/plugins/tile_set_editor_plugin.cpp b/editor/plugins/tile_set_editor_plugin.cpp index b64ff6119c..b24d5add9f 100644 --- a/editor/plugins/tile_set_editor_plugin.cpp +++ b/editor/plugins/tile_set_editor_plugin.cpp @@ -1303,12 +1303,14 @@ void TileSetEditor::_on_workspace_input(const Ref<InputEvent> &p_ie) { Size2 tile_workspace_size = edited_region.position + edited_region.size + WORKSPACE_MARGIN * 2; Size2 workspace_minsize = workspace->get_custom_minimum_size(); - if (tile_workspace_size.x > workspace_minsize.x && tile_workspace_size.y > workspace_minsize.y) { - undo_redo->add_do_method(workspace, "set_custom_minimum_size", tile_workspace_size); + // If the new region is bigger, just directly change the workspace size to avoid checking all other tiles. + if (tile_workspace_size.x > workspace_minsize.x || tile_workspace_size.y > workspace_minsize.y) { + Size2 max_workspace_size = Size2(MAX(tile_workspace_size.x, workspace_minsize.x), MAX(tile_workspace_size.y, workspace_minsize.y)); + undo_redo->add_do_method(workspace, "set_custom_minimum_size", max_workspace_size); undo_redo->add_undo_method(workspace, "set_custom_minimum_size", workspace_minsize); - undo_redo->add_do_method(workspace_container, "set_custom_minimum_size", tile_workspace_size); + undo_redo->add_do_method(workspace_container, "set_custom_minimum_size", max_workspace_size); undo_redo->add_undo_method(workspace_container, "set_custom_minimum_size", workspace_minsize); - undo_redo->add_do_method(workspace_overlay, "set_custom_minimum_size", tile_workspace_size); + undo_redo->add_do_method(workspace_overlay, "set_custom_minimum_size", max_workspace_size); undo_redo->add_undo_method(workspace_overlay, "set_custom_minimum_size", workspace_minsize); } else if (workspace_minsize.x > get_current_texture()->get_size().x + WORKSPACE_MARGIN.x * 2 || workspace_minsize.y > get_current_texture()->get_size().y + WORKSPACE_MARGIN.y * 2) { undo_redo->add_do_method(this, "update_workspace_minsize"); @@ -1803,8 +1805,6 @@ void TileSetEditor::_on_tool_clicked(int p_tool) { Ref<ConvexPolygonShape2D> _convex = memnew(ConvexPolygonShape2D); edited_collision_shape = _convex; _set_edited_shape_points(_get_collision_shape_points(concave)); - } else { - // Shouldn't happen } for (int i = 0; i < sd.size(); i++) { if (sd[i].get("shape") == previous_shape) { @@ -3267,12 +3267,16 @@ void TileSetEditor::update_workspace_minsize() { List<int> *tiles = new List<int>(); tileset->get_tile_list(tiles); for (List<int>::Element *E = tiles->front(); E; E = E->next()) { - if (tileset->tile_get_texture(E->get())->get_rid() == current_texture_rid) { - Rect2i region = tileset->tile_get_region(E->get()); - if (region.position.x + region.size.x > workspace_min_size.x) - workspace_min_size.x = region.position.x + region.size.x; - if (region.position.y + region.size.y > workspace_min_size.y) - workspace_min_size.y = region.position.y + region.size.y; + if (tileset->tile_get_texture(E->get())->get_rid() != current_texture_rid) { + continue; + } + + Rect2i region = tileset->tile_get_region(E->get()); + if (region.position.x + region.size.x > workspace_min_size.x) { + workspace_min_size.x = region.position.x + region.size.x; + } + if (region.position.y + region.size.y > workspace_min_size.y) { + workspace_min_size.y = region.position.y + region.size.y; } } delete tiles; diff --git a/editor/plugins/visual_shader_editor_plugin.cpp b/editor/plugins/visual_shader_editor_plugin.cpp index 972e4f2172..e334d4b093 100644 --- a/editor/plugins/visual_shader_editor_plugin.cpp +++ b/editor/plugins/visual_shader_editor_plugin.cpp @@ -2852,7 +2852,7 @@ VisualShaderEditorPlugin::VisualShaderEditorPlugin(EditorNode *p_node) { editor = p_node; visual_shader_editor = memnew(VisualShaderEditor); - visual_shader_editor->set_custom_minimum_size(Size2(0, 300)); + visual_shader_editor->set_custom_minimum_size(Size2(0, 300) * EDSCALE); button = editor->add_bottom_panel_item(TTR("VisualShader"), visual_shader_editor); button->hide(); diff --git a/editor/script_create_dialog.cpp b/editor/script_create_dialog.cpp index 25bc13033c..35d5fe5f70 100644 --- a/editor/script_create_dialog.cpp +++ b/editor/script_create_dialog.cpp @@ -99,7 +99,7 @@ bool ScriptCreateDialog::_can_be_built_in() { return (supports_built_in && built_in_enabled); } -void ScriptCreateDialog::config(const String &p_base_name, const String &p_base_path, bool p_built_in_enabled) { +void ScriptCreateDialog::config(const String &p_base_name, const String &p_base_path, bool p_built_in_enabled, bool p_load_enabled) { class_name->set_text(""); class_name->deselect(); @@ -117,6 +117,7 @@ void ScriptCreateDialog::config(const String &p_base_name, const String &p_base_ file_path->deselect(); built_in_enabled = p_built_in_enabled; + load_enabled = p_load_enabled; _lang_changed(current_language); _class_name_changed(""); @@ -623,12 +624,12 @@ void ScriptCreateDialog::_msg_path_valid(bool valid, const String &p_msg) { void ScriptCreateDialog::_update_dialog() { + /* "Add Script Dialog" GUI logic and script checks. */ + bool script_ok = true; - /* "Add Script Dialog" gui logic and script checks */ + // Is script path/name valid (order from top to bottom)? - // Is Script Valid (order from top to bottom) - get_ok()->set_disabled(true); if (!is_built_in && !is_path_valid) { _msg_script_valid(false, TTR("Invalid path.")); script_ok = false; @@ -641,12 +642,12 @@ void ScriptCreateDialog::_update_dialog() { _msg_script_valid(false, TTR("Invalid inherited parent name or path.")); script_ok = false; } + if (script_ok) { _msg_script_valid(true, TTR("Script is valid.")); - get_ok()->set_disabled(false); } - /* Does script have named classes */ + // Does script have named classes? if (has_named_classes) { if (is_new_script_created) { @@ -663,7 +664,7 @@ void ScriptCreateDialog::_update_dialog() { class_name->set_text(""); } - /* Is script Built-in */ + // Is script Built-in? if (is_built_in) { file_path->set_editable(false); @@ -683,7 +684,7 @@ void ScriptCreateDialog::_update_dialog() { } internal->set_disabled(!_can_be_built_in()); - /* Is Script created or loaded from existing file */ + // Is Script created or loaded from existing file? if (is_built_in) { get_ok()->set_text(TTR("Create")); @@ -692,7 +693,8 @@ void ScriptCreateDialog::_update_dialog() { parent_browse_button->set_disabled(!can_inherit_from_file); _msg_path_valid(true, TTR("Built-in script (into scene file).")); } else if (is_new_script_created) { - // New Script Created + // New script created. + get_ok()->set_text(TTR("Create")); parent_name->set_editable(true); parent_search_button->set_disabled(false); @@ -700,8 +702,9 @@ void ScriptCreateDialog::_update_dialog() { if (is_path_valid) { _msg_path_valid(true, TTR("Will create a new script file.")); } - } else { - // Script Loaded + } else if (load_enabled) { + // Script loaded. + get_ok()->set_text(TTR("Load")); parent_name->set_editable(false); parent_search_button->set_disabled(true); @@ -709,7 +712,17 @@ void ScriptCreateDialog::_update_dialog() { if (is_path_valid) { _msg_path_valid(true, TTR("Will load an existing script file.")); } + } else { + get_ok()->set_text(TTR("Create")); + parent_name->set_editable(true); + parent_search_button->set_disabled(false); + parent_browse_button->set_disabled(!can_inherit_from_file); + _msg_path_valid(false, TTR("Script file already exists.")); + + script_ok = false; } + + get_ok()->set_disabled(!script_ok); } void ScriptCreateDialog::_bind_methods() { @@ -727,7 +740,7 @@ void ScriptCreateDialog::_bind_methods() { ClassDB::bind_method("_create", &ScriptCreateDialog::_create); ClassDB::bind_method("_browse_class_in_tree", &ScriptCreateDialog::_browse_class_in_tree); - ClassDB::bind_method(D_METHOD("config", "inherits", "path", "built_in_enabled"), &ScriptCreateDialog::config, DEFVAL(true)); + ClassDB::bind_method(D_METHOD("config", "inherits", "path", "built_in_enabled", "load_enabled"), &ScriptCreateDialog::config, DEFVAL(true), DEFVAL(true)); ADD_SIGNAL(MethodInfo("script_created", PropertyInfo(Variant::OBJECT, "script", PROPERTY_HINT_RESOURCE_TYPE, "Script"))); } @@ -884,8 +897,9 @@ ScriptCreateDialog::ScriptCreateDialog() { has_named_classes = false; supports_built_in = false; can_inherit_from_file = false; - built_in_enabled = true; is_built_in = false; + built_in_enabled = true; + load_enabled = true; is_new_script_created = true; } diff --git a/editor/script_create_dialog.h b/editor/script_create_dialog.h index 91d6315a78..00f642fcf7 100644 --- a/editor/script_create_dialog.h +++ b/editor/script_create_dialog.h @@ -74,6 +74,7 @@ class ScriptCreateDialog : public ConfirmationDialog { bool is_class_name_valid; bool is_built_in; bool built_in_enabled; + bool load_enabled; int current_language; int default_language; bool re_check_path; @@ -126,7 +127,7 @@ protected: static void _bind_methods(); public: - void config(const String &p_base_name, const String &p_base_path, bool p_built_in_enabled = true); + void config(const String &p_base_name, const String &p_base_path, bool p_built_in_enabled = true, bool p_load_enabled = true); void set_inheritance_base_type(const String &p_base); ScriptCreateDialog(); }; |