diff options
Diffstat (limited to 'editor')
| -rw-r--r-- | editor/code_editor.cpp | 2 | ||||
| -rw-r--r-- | editor/editor_about.cpp | 3 | ||||
| -rw-r--r-- | editor/editor_fonts.cpp | 17 | ||||
| -rw-r--r-- | editor/editor_log.cpp | 2 | ||||
| -rw-r--r-- | editor/editor_node.cpp | 3 | ||||
| -rw-r--r-- | editor/editor_settings.cpp | 2 | ||||
| -rw-r--r-- | editor/editor_themes.cpp | 11 | ||||
| -rw-r--r-- | editor/filesystem_dock.cpp | 14 | ||||
| -rw-r--r-- | editor/plugins/canvas_item_editor_plugin.cpp | 16 | ||||
| -rw-r--r-- | editor/plugins/script_editor_plugin.cpp | 12 | ||||
| -rw-r--r-- | editor/plugins/script_editor_plugin.h | 1 | ||||
| -rw-r--r-- | editor/plugins/tile_set_editor_plugin.cpp | 69 | ||||
| -rw-r--r-- | editor/plugins/tile_set_editor_plugin.h | 1 | ||||
| -rw-r--r-- | editor/project_manager.cpp | 136 | ||||
| -rw-r--r-- | editor/script_editor_debugger.cpp | 67 | ||||
| -rw-r--r-- | editor/script_editor_debugger.h | 10 |
16 files changed, 274 insertions, 92 deletions
diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp index 256fe302d..4b5965690 100644 --- a/editor/code_editor.cpp +++ b/editor/code_editor.cpp @@ -1251,7 +1251,7 @@ CodeTextEditor::CodeTextEditor() { error = memnew(Label); status_bar->add_child(error); - error->set_clip_text(true); //do not change, or else very long errors can push the whole container to the right + error->set_autowrap(true); error->set_valign(Label::VALIGN_CENTER); error->add_color_override("font_color", EditorNode::get_singleton()->get_gui_base()->get_color("error_color", "Editor")); error->add_font_override("font", EditorNode::get_singleton()->get_gui_base()->get_font("status_source", "EditorFonts")); diff --git a/editor/editor_about.cpp b/editor/editor_about.cpp index 1d6d93392..7fa477614 100644 --- a/editor/editor_about.cpp +++ b/editor/editor_about.cpp @@ -131,7 +131,8 @@ EditorAbout::EditorAbout() { Label *about_text = memnew(Label); about_text->set_v_size_flags(Control::SIZE_SHRINK_CENTER); - about_text->set_text(VERSION_FULL_NAME + hash + String::utf8("\n\xc2\xa9 2007-2018 Juan Linietsky, Ariel Manzur.\n\xc2\xa9 2014-2017 ") + + about_text->set_text(VERSION_FULL_NAME + hash + + String::utf8("\n\xc2\xa9 2007-2018 Juan Linietsky, Ariel Manzur.\n\xc2\xa9 2014-2018 ") + TTR("Godot Engine contributors") + "\n"); hbc->add_child(about_text); diff --git a/editor/editor_fonts.cpp b/editor/editor_fonts.cpp index f2882561a..c50995fc2 100644 --- a/editor/editor_fonts.cpp +++ b/editor/editor_fonts.cpp @@ -77,12 +77,27 @@ static Ref<BitmapFont> make_font(int p_height, int p_ascent, int p_valign, int p Ref<DynamicFont> m_name; \ m_name.instance(); \ m_name->set_size(m_size); \ - m_name->set_font_data(DefaultFont); \ + if (CustomFont.is_valid()) { \ + m_name->set_font_data(CustomFont); \ + m_name->add_fallback(DefaultFont); \ + } else { \ + m_name->set_font_data(DefaultFont); \ + } \ m_name->set_spacing(DynamicFont::SPACING_TOP, -EDSCALE); \ m_name->set_spacing(DynamicFont::SPACING_BOTTOM, -EDSCALE); \ MAKE_FALLBACKS(m_name); void editor_register_fonts(Ref<Theme> p_theme) { + /* Custom font */ + + String custom_font = EditorSettings::get_singleton()->get("interface/editor/custom_font"); + Ref<DynamicFontData> CustomFont; + if (custom_font.length() > 0) { + CustomFont.instance(); + CustomFont->set_font_path(custom_font); + CustomFont->set_force_autohinter(true); //just looks better..i think? + } + /* Droid Sans */ Ref<DynamicFontData> DefaultFont; diff --git a/editor/editor_log.cpp b/editor/editor_log.cpp index cf19af7ef..1b885adf3 100644 --- a/editor/editor_log.cpp +++ b/editor/editor_log.cpp @@ -29,6 +29,7 @@ /*************************************************************************/ #include "editor_log.h" +#include "core/os/keyboard.h" #include "editor_node.h" #include "scene/gui/center_container.h" #include "scene/resources/dynamic_font.h" @@ -154,6 +155,7 @@ EditorLog::EditorLog() { clearbutton = memnew(Button); hb->add_child(clearbutton); clearbutton->set_text(TTR("Clear")); + clearbutton->set_shortcut(ED_SHORTCUT("editor/clear_output", TTR("Clear Output"), KEY_MASK_CMD | KEY_MASK_SHIFT | KEY_K)); clearbutton->connect("pressed", this, "_clear_request"); log = memnew(RichTextLabel); diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index bd37e7d0b..b308d28db 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -4419,10 +4419,11 @@ void EditorNode::_dropped_files(const Vector<String> &p_files, int p_screen) { String to_path = ProjectSettings::get_singleton()->globalize_path(get_filesystem_dock()->get_current_path()); DirAccessRef dir = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); + Vector<String> just_copy = String("ttf,otf").split(","); for (int i = 0; i < p_files.size(); i++) { String from = p_files[i]; - if (!ResourceFormatImporter::get_singleton()->can_be_imported(from)) { + if (!ResourceFormatImporter::get_singleton()->can_be_imported(from) && (just_copy.find(from.get_extension().to_lower()) < 0)) { continue; } String to = to_path.plus_file(from.get_file()); diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp index 5a16ec7ea..dc82a02f4 100644 --- a/editor/editor_settings.cpp +++ b/editor/editor_settings.cpp @@ -277,7 +277,7 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) { _initial_set("interface/editor/source_font_size", 14); hints["interface/editor/source_font_size"] = PropertyInfo(Variant::INT, "interface/editor/source_font_size", PROPERTY_HINT_RANGE, "8,96,1", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED); _initial_set("interface/editor/custom_font", ""); - hints["interface/editor/custom_font"] = PropertyInfo(Variant::STRING, "interface/editor/custom_font", PROPERTY_HINT_GLOBAL_FILE, "*.font,*.tres,*.res", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED); + hints["interface/editor/custom_font"] = PropertyInfo(Variant::STRING, "interface/editor/custom_font", PROPERTY_HINT_GLOBAL_FILE, "*.ttf,*.otf", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED); _initial_set("interface/editor/dim_editor_on_dialog_popup", true); _initial_set("interface/editor/dim_amount", 0.6f); hints["interface/editor/dim_amount"] = PropertyInfo(Variant::REAL, "interface/editor/dim_amount", PROPERTY_HINT_RANGE, "0,1,0.01", PROPERTY_USAGE_DEFAULT); diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp index 364489366..b19d01545 100644 --- a/editor/editor_themes.cpp +++ b/editor/editor_themes.cpp @@ -1135,16 +1135,5 @@ Ref<Theme> create_custom_theme(const Ref<Theme> p_theme) { theme = create_editor_theme(p_theme); } - String global_font = EditorSettings::get_singleton()->get("interface/editor/custom_font"); - if (global_font != "") { - Ref<Font> fnt = ResourceLoader::load(global_font); - if (fnt.is_valid()) { - if (!theme.is_valid()) { - theme.instance(); - } - theme->set_default_theme_font(fnt); - } - } - return theme; } diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp index 949455ff9..b18cd6b74 100644 --- a/editor/filesystem_dock.cpp +++ b/editor/filesystem_dock.cpp @@ -819,7 +819,7 @@ void FileSystemDock::_try_duplicate_item(const FileOrFolder &p_item, const Strin DirAccess *da = DirAccess::create(DirAccess::ACCESS_RESOURCES); print_line("Duplicating " + old_path + " -> " + new_path); - Error err = da->copy(old_path, new_path); + Error err = p_item.is_file ? da->copy(old_path, new_path) : da->copy_dir(old_path, new_path); if (err == OK) { //Move/Rename any corresponding import settings too if (p_item.is_file && FileAccess::exists(old_path + ".import")) { @@ -980,10 +980,12 @@ void FileSystemDock::_duplicate_operation_confirm() { return; } - String old_path = to_duplicate.path.ends_with("/") ? to_duplicate.path.substr(0, to_duplicate.path.length() - 1) : to_rename.path; - String new_path = old_path.get_base_dir().plus_file(new_name); - if (old_path == new_path) { - return; + String new_path; + String base_dir = to_duplicate.path.get_base_dir(); + if (to_duplicate.is_file) { + new_path = base_dir.plus_file(new_name); + } else { + new_path = base_dir.substr(0, base_dir.find_last("/")) + "/" + new_name; } //Present a more user friendly warning for name conflict @@ -995,7 +997,7 @@ void FileSystemDock::_duplicate_operation_confirm() { } memdelete(da); - _try_duplicate_item(to_duplicate, new_name); + _try_duplicate_item(to_duplicate, new_path); //Rescan everything print_line("call rescan!"); diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index 53b52c5f1..052817f40 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -612,6 +612,7 @@ void CanvasItemEditor::_find_canvas_items_at_pos(const Point2 &p_pos, Node *p_no if (Object::cast_to<Viewport>(p_node)) return; + const real_t grab_distance = EDITOR_DEF("editors/poly_editor/point_grab_radius", 8); CanvasItem *c = Object::cast_to<CanvasItem>(p_node); for (int i = p_node->get_child_count() - 1; i >= 0; i--) { @@ -630,9 +631,12 @@ void CanvasItemEditor::_find_canvas_items_at_pos(const Point2 &p_pos, Node *p_no if (c && c->is_visible_in_tree() && !c->has_meta("_edit_lock_") && !Object::cast_to<CanvasLayer>(c)) { Rect2 rect = c->_edit_get_rect(); - Point2 local_pos = (p_parent_xform * p_canvas_xform * c->get_transform()).affine_inverse().xform(p_pos); + Transform2D to_local = (p_parent_xform * p_canvas_xform * c->get_transform()).affine_inverse(); + Point2 local_pos = to_local.xform(p_pos); + const real_t local_grab_distance = (to_local.xform(p_pos + Vector2(grab_distance, 0)) - local_pos).length(); + Rect2 local_pos_rect = Rect2(local_pos, Vector2(0, 0)).grow(local_grab_distance); - if (rect.has_point(local_pos)) { + if (rect.intersects(local_pos_rect) && c->_edit_is_selected_on_click(local_pos, local_grab_distance)) { Node2D *node = Object::cast_to<Node2D>(c); _SelectResult res; @@ -3464,7 +3468,7 @@ void CanvasItemEditor::_popup_callback(int p_op) { for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E->get()); - if (!canvas_item || !canvas_item->is_visible_in_tree()) + if (!canvas_item || !canvas_item->is_inside_tree()) continue; if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root()) @@ -3482,7 +3486,7 @@ void CanvasItemEditor::_popup_callback(int p_op) { for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E->get()); - if (!canvas_item || !canvas_item->is_visible_in_tree()) + if (!canvas_item || !canvas_item->is_inside_tree()) continue; if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root()) @@ -3502,7 +3506,7 @@ void CanvasItemEditor::_popup_callback(int p_op) { for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E->get()); - if (!canvas_item || !canvas_item->is_visible_in_tree()) + if (!canvas_item || !canvas_item->is_inside_tree()) continue; if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root()) @@ -3520,7 +3524,7 @@ void CanvasItemEditor::_popup_callback(int p_op) { for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E->get()); - if (!canvas_item || !canvas_item->is_visible_in_tree()) + if (!canvas_item || !canvas_item->is_inside_tree()) continue; if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root()) diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index 73fd64f8d..bc29c92d7 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -1027,6 +1027,15 @@ void ScriptEditor::_menu_option(int p_option) { case FILE_COPY_PATH: { _copy_script_path(); } break; + case SHOW_IN_FILE_SYSTEM: { + ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_child(tab_container->get_current_tab())); + Ref<Script> script = se->get_edited_script(); + FileSystemDock *file_system_dock = EditorNode::get_singleton()->get_filesystem_dock(); + file_system_dock->navigate_to_path(script->get_path()); + // Ensure that the FileSystem dock is visible. + TabContainer *tab_container = (TabContainer *)file_system_dock->get_parent_control(); + tab_container->set_current_tab(file_system_dock->get_position_in_parent()); + } break; case CLOSE_DOCS: { _close_docs_tab(); } break; @@ -2164,7 +2173,7 @@ void ScriptEditor::_make_script_list_context_menu() { context_menu->add_separator(); context_menu->add_shortcut(ED_GET_SHORTCUT("script_editor/copy_path"), FILE_COPY_PATH); context_menu->add_shortcut(ED_GET_SHORTCUT("script_editor/reload_script_soft"), FILE_TOOL_RELOAD_SOFT); - + context_menu->add_shortcut(ED_GET_SHORTCUT("script_editor/show_in_file_system"), SHOW_IN_FILE_SYSTEM); Ref<Script> scr = se->get_edited_script(); if (!scr.is_null() && scr->is_tool()) { context_menu->add_separator(); @@ -2613,6 +2622,7 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) { file_menu->get_popup()->add_separator(); file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/reload_script_soft", TTR("Soft Reload Script"), KEY_MASK_CMD | KEY_MASK_SHIFT | KEY_R), FILE_TOOL_RELOAD_SOFT); file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/copy_path", TTR("Copy Script Path")), FILE_COPY_PATH); + file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/show_in_file_system", TTR("Show In File System")), SHOW_IN_FILE_SYSTEM); file_menu->get_popup()->add_separator(); file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/history_previous", TTR("History Prev"), KEY_MASK_ALT | KEY_LEFT), WINDOW_PREV); diff --git a/editor/plugins/script_editor_plugin.h b/editor/plugins/script_editor_plugin.h index 330514744..d90cf7b91 100644 --- a/editor/plugins/script_editor_plugin.h +++ b/editor/plugins/script_editor_plugin.h @@ -137,6 +137,7 @@ class ScriptEditor : public PanelContainer { CLOSE_ALL, CLOSE_OTHER_TABS, TOGGLE_SCRIPTS_PANEL, + SHOW_IN_FILE_SYSTEM, FILE_COPY_PATH, FILE_TOOL_RELOAD, FILE_TOOL_RELOAD_SOFT, diff --git a/editor/plugins/tile_set_editor_plugin.cpp b/editor/plugins/tile_set_editor_plugin.cpp index da507db5d..eccb11ba1 100644 --- a/editor/plugins/tile_set_editor_plugin.cpp +++ b/editor/plugins/tile_set_editor_plugin.cpp @@ -333,7 +333,7 @@ AutotileEditor::AutotileEditor(EditorNode *p_editor) { autotile_list = memnew(ItemList); autotile_list->set_v_size_flags(SIZE_EXPAND_FILL); autotile_list->set_h_size_flags(SIZE_EXPAND_FILL); - autotile_list->set_custom_minimum_size(Size2(02, 200)); + autotile_list->set_custom_minimum_size(Size2(10, 200)); autotile_list->connect("item_selected", this, "_on_autotile_selected"); split->add_child(autotile_list); @@ -531,7 +531,7 @@ AutotileEditor::AutotileEditor(EditorNode *p_editor) { main_vb->add_child(toolbar); - ScrollContainer *scroll = memnew(ScrollContainer); + scroll = memnew(ScrollContainer); main_vb->add_child(scroll); scroll->set_v_size_flags(SIZE_EXPAND_FILL); @@ -619,6 +619,7 @@ void AutotileEditor::_on_edit_mode_changed(int p_edit_mode) { tool_containers[TOOLBAR_BITMASK]->hide(); tool_containers[TOOLBAR_SHAPE]->show(); tools[TOOL_SELECT]->set_tooltip(TTR("Select current edited sub-tile.")); + current_shape = PoolVector2Array(); spin_priority->hide(); } break; default: { @@ -1061,20 +1062,43 @@ void AutotileEditor::_on_workspace_input(const Ref<InputEvent> &p_ie) { } else { int t_id = get_current_tile(); if (t_id >= 0) { - Vector<TileSet::ShapeData> sd = tile_set->tile_get_shapes(t_id); - for (int i = 0; i < sd.size(); i++) { - if (sd[i].autotile_coord == edited_shape_coord) { - Ref<ConvexPolygonShape2D> shape = sd[i].shape; + if (edit_mode == EDITMODE_COLLISION) { + Vector<TileSet::ShapeData> sd = tile_set->tile_get_shapes(t_id); + for (int i = 0; i < sd.size(); i++) { + if (sd[i].autotile_coord == edited_shape_coord) { + Ref<ConvexPolygonShape2D> shape = sd[i].shape; - if (!shape.is_null()) { - sd.remove(i); - tile_set->tile_set_shapes(get_current_tile(), sd); - edited_collision_shape = Ref<Shape2D>(); - current_shape.resize(0); - workspace->update(); + if (!shape.is_null()) { + sd.remove(i); + tile_set->tile_set_shapes(get_current_tile(), sd); + edited_collision_shape = Ref<Shape2D>(); + workspace->update(); + } + break; + } + } + } else if (edit_mode == EDITMODE_OCCLUSION) { + Map<Vector2, Ref<OccluderPolygon2D> > map = tile_set->autotile_get_light_oclusion_map(t_id); + for (Map<Vector2, Ref<OccluderPolygon2D> >::Element *E = map.front(); E; E = E->next()) { + if (E->key() == edited_shape_coord) { + tile_set->autotile_set_light_occluder(get_current_tile(), Ref<OccluderPolygon2D>(), edited_shape_coord); + break; + } + } + + edited_occlusion_shape = Ref<OccluderPolygon2D>(); + workspace->update(); + } else if (edit_mode == EDITMODE_NAVIGATION) { + Map<Vector2, Ref<NavigationPolygon> > map = tile_set->autotile_get_navigation_map(t_id); + for (Map<Vector2, Ref<NavigationPolygon> >::Element *E = map.front(); E; E = E->next()) { + if (E->key() == edited_shape_coord) { + tile_set->autotile_set_navigation_polygon(t_id, Ref<NavigationPolygon>(), edited_shape_coord); + break; } - break; } + + edited_navigation_shape = Ref<NavigationPolygon>(); + workspace->update(); } } @@ -1095,6 +1119,16 @@ void AutotileEditor::_on_workspace_input(const Ref<InputEvent> &p_ie) { } } break; } + + //Drag Middle Mouse + if (mm.is_valid()) { + if (mm->get_button_mask() & BUTTON_MASK_MIDDLE) { + + Vector2 dragged(mm->get_relative().x, mm->get_relative().y); + scroll->set_h_scroll(scroll->get_h_scroll() - dragged.x * workspace->get_scale().x); + scroll->set_v_scroll(scroll->get_v_scroll() - dragged.y * workspace->get_scale().x); + } + } } } @@ -1453,11 +1487,20 @@ void AutotileEditor::close_shape(const Vector2 &shape_anchor) { Ref<ConvexPolygonShape2D> shape = memnew(ConvexPolygonShape2D); Vector<Vector2> segments; + float p_total = 0; for (int i = 0; i < current_shape.size(); i++) { segments.push_back(current_shape[i] - shape_anchor); + + if (i != current_shape.size() - 1) + p_total += ((current_shape[i + 1].x - current_shape[i].x) * (-current_shape[i + 1].y + (-current_shape[i].y))); + else + p_total += ((current_shape[0].x - current_shape[i].x) * (-current_shape[0].y + (-current_shape[i].y))); } + if (p_total < 0) + segments.invert(); + shape->set_points(segments); tile_set->tile_add_shape(get_current_tile(), shape, Transform2D(), false, edited_shape_coord); diff --git a/editor/plugins/tile_set_editor_plugin.h b/editor/plugins/tile_set_editor_plugin.h index 7d9558d4e..0f66f04cb 100644 --- a/editor/plugins/tile_set_editor_plugin.h +++ b/editor/plugins/tile_set_editor_plugin.h @@ -86,6 +86,7 @@ class AutotileEditor : public Control { int current_item_index; Sprite *preview; + ScrollContainer *scroll; Control *workspace_container; Control *workspace; Button *tool_editmode[EDITMODE_MAX]; diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp index 041165685..eb5cec2a2 100644 --- a/editor/project_manager.cpp +++ b/editor/project_manager.cpp @@ -89,33 +89,50 @@ private: String created_folder_path; void set_message(const String &p_msg, MessageType p_type = MESSAGE_SUCCESS) { + msg->set_text(p_msg); - if (p_msg == "") { - status_btn->set_icon(get_icon("StatusSuccess", "EditorIcons")); - return; - } - msg->hide(); + Ref<Texture> current_icon = status_btn->get_icon(); + switch (p_type) { - case MESSAGE_ERROR: + + case MESSAGE_ERROR: { + msg->add_color_override("font_color", get_color("error_color", "Editor")); - status_btn->set_icon(get_icon("StatusError", "EditorIcons")); - msg->show(); - break; - case MESSAGE_WARNING: + Ref<Texture> new_icon = get_icon("StatusError", "EditorIcons"); + if (current_icon != new_icon) { + + status_btn->set_icon(new_icon); + msg->show(); + } + } break; + case MESSAGE_WARNING: { + msg->add_color_override("font_color", get_color("warning_color", "Editor")); - status_btn->set_icon(get_icon("StatusWarning", "EditorIcons")); - break; - case MESSAGE_SUCCESS: + Ref<Texture> new_icon = get_icon("StatusWarning", "EditorIcons"); + if (current_icon != new_icon) { + + status_btn->set_icon(new_icon); + if (current_icon != get_icon("StatusSuccess", "EditorIcons")) + msg->hide(); + } + } break; + case MESSAGE_SUCCESS: { + msg->add_color_override("font_color", get_color("success_color", "Editor")); - status_btn->set_icon(get_icon("StatusSuccess", "EditorIcons")); - break; + Ref<Texture> new_icon = get_icon("StatusSuccess", "EditorIcons"); + if (current_icon != new_icon) { + + status_btn->set_icon(new_icon); + msg->hide(); + } + } break; } + + set_size(Size2(500, 0) * EDSCALE); } String _test_path() { - set_message(" "); - get_ok()->set_disabled(true); DirAccess *d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); String valid_path; if (d->change_dir(project_path->get_text()) == OK) { @@ -127,6 +144,7 @@ private: if (valid_path == "") { set_message(TTR("The path does not exist."), MESSAGE_ERROR); memdelete(d); + get_ok()->set_disabled(true); return ""; } @@ -136,6 +154,7 @@ private: set_message(TTR("Please choose a 'project.godot' file."), MESSAGE_ERROR); memdelete(d); + get_ok()->set_disabled(true); return ""; } @@ -155,19 +174,22 @@ private: d->list_dir_end(); if (!is_empty) { + set_message(TTR("Your project will be created in a non empty folder (you might want to create a new folder)."), MESSAGE_WARNING); + memdelete(d); + get_ok()->set_disabled(false); + return valid_path; } - } else { - - if (d->file_exists("project.godot")) { + } else if (d->file_exists("project.godot")) { - set_message(TTR("Please choose a folder that does not contain a 'project.godot' file."), MESSAGE_ERROR); - memdelete(d); - return ""; - } + set_message(TTR("Please choose a folder that does not contain a 'project.godot' file."), MESSAGE_ERROR); + memdelete(d); + get_ok()->set_disabled(true); + return ""; } + set_message(TTR("That's a BINGO!")); memdelete(d); get_ok()->set_disabled(false); return valid_path; @@ -213,7 +235,6 @@ private: } String sp = p.simplify_path(); project_path->set_text(sp); - set_message(" "); // just so it does not disappear get_ok()->call_deferred("grab_focus"); } @@ -242,21 +263,32 @@ private: void _create_folder() { - if (project_name->get_text() == "" || created_folder_path != "") { + if (project_name->get_text() == "" || created_folder_path != "") return; - } DirAccess *d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); if (d->change_dir(project_path->get_text()) == OK) { + if (!d->dir_exists(project_name->get_text())) { + if (d->make_dir(project_name->get_text()) == OK) { + d->change_dir(project_name->get_text()); project_path->set_text(d->get_current_dir()); created_folder_path = d->get_current_dir(); create_dir->set_disabled(true); + } else { + + dialog_error->set_text(TTR("Couldn't create folder.")); + dialog_error->popup_centered_minsize(); } + } else { + + dialog_error->set_text(TTR("There is already a folder in this path with the specified name.")); + dialog_error->popup_centered_minsize(); } } + memdelete(d); } @@ -337,6 +369,7 @@ private: if (!pkg) { dialog_error->set_text(TTR("Error opening package file, not in zip format.")); + dialog_error->popup_centered_minsize(); return; } @@ -448,7 +481,10 @@ private: } void _toggle_message() { + msg->set_visible(!msg->is_visible()); + if (!msg->is_visible()) + set_size(Size2(500, 0) * EDSCALE); } void cancel_pressed() { @@ -457,6 +493,15 @@ private: project_path->clear(); project_name->clear(); + + if (status_btn->get_icon() == get_icon("StatusError", "EditorIcons")) + msg->show(); + } + + void _notification(int p_what) { + + if (p_what == MainLoop::NOTIFICATION_WM_QUIT_REQUEST) + _remove_created_folder(); } protected: @@ -558,7 +603,7 @@ public: _test_path(); } - popup_centered(Size2(500, 125) * EDSCALE); + popup_centered(Size2(500, 0) * EDSCALE); } ProjectDialog() { @@ -610,7 +655,6 @@ public: pphb->add_child(browse); msg = memnew(Label); - msg->set_text(TTR("That's a BINGO!")); msg->set_align(Label::ALIGN_CENTER); msg->hide(); vb->add_child(msg); @@ -652,19 +696,20 @@ struct ProjectItem { void ProjectManager::_notification(int p_what) { - if (p_what == NOTIFICATION_ENTER_TREE) { - - Engine::get_singleton()->set_editor_hint(false); - - } else if (p_what == NOTIFICATION_READY) { + switch (p_what) { + case NOTIFICATION_ENTER_TREE: { - if (scroll_childs->get_child_count() == 0) { - open_templates->popup_centered_minsize(); - } + Engine::get_singleton()->set_editor_hint(false); + } break; + case NOTIFICATION_READY: { - } else if (p_what == NOTIFICATION_VISIBILITY_CHANGED) { + if (scroll_childs->get_child_count() == 0) + open_templates->popup_centered_minsize(); + } break; + case NOTIFICATION_VISIBILITY_CHANGED: { - set_process_unhandled_input(is_visible_in_tree()); + set_process_unhandled_input(is_visible_in_tree()); + } break; } } @@ -1214,7 +1259,6 @@ void ProjectManager::_run_project_confirm() { Error err = OS::get_singleton()->execute(exec, args, false, &pid); ERR_FAIL_COND(err); } - //get_scene()->quit(); do not quit } void ProjectManager::_run_project() { @@ -1556,9 +1600,6 @@ ProjectManager::ProjectManager() { scroll_childs->set_h_size_flags(SIZE_EXPAND_FILL); scroll->add_child(scroll_childs); - //HBoxContainer *hb = memnew( HBoxContainer ); - //vb->add_child(hb); - Button *open = memnew(Button); open->set_text(TTR("Edit")); tree_vb->add_child(open); @@ -1663,7 +1704,7 @@ ProjectManager::ProjectManager() { cancel->connect("pressed", this, "_exit_dialog"); vb->add_child(cc); - // + ////////////////////////////////////////////////////////////// language_restart_ask = memnew(ConfirmationDialog); language_restart_ask->get_ok()->set_text(TTR("Restart Now")); @@ -1772,12 +1813,9 @@ void ProjectListFilter::_filter_option_selected(int p_idx) { } void ProjectListFilter::_notification(int p_what) { - switch (p_what) { - case NOTIFICATION_ENTER_TREE: { - clear_search_button->set_icon(get_icon("Close", "EditorIcons")); - } break; - } + if (p_what == NOTIFICATION_ENTER_TREE) + clear_search_button->set_icon(get_icon("Close", "EditorIcons")); } void ProjectListFilter::_bind_methods() { diff --git a/editor/script_editor_debugger.cpp b/editor/script_editor_debugger.cpp index 4fe7bef9f..f1a5aa465 100644 --- a/editor/script_editor_debugger.cpp +++ b/editor/script_editor_debugger.cpp @@ -1686,6 +1686,45 @@ void ScriptEditorDebugger::_clear_remote_objects() { remote_objects.clear(); } +void ScriptEditorDebugger::_clear_errors_list() { + + error_list->clear(); + error_count = 0; + _notification(NOTIFICATION_PROCESS); +} + +// Right click on specific file(s) or folder(s). +void ScriptEditorDebugger::_error_list_item_rmb_selected(int p_item, const Vector2 &p_pos) { + + item_menu->clear(); + item_menu->set_size(Size2(1, 1)); + + // Allow specific actions only on one item. + bool single_item_selected = error_list->get_selected_items().size() == 1; + + if (single_item_selected) { + item_menu->add_icon_item(get_icon("CopyNodePath", "EditorIcons"), TTR("Copy Error"), ITEM_MENU_COPY_ERROR); + } + + if (item_menu->get_item_count() > 0) { + item_menu->set_position(error_list->get_global_position() + p_pos); + item_menu->popup(); + } +} + +void ScriptEditorDebugger::_item_menu_id_pressed(int p_option) { + + switch (p_option) { + + case ITEM_MENU_COPY_ERROR: { + String title = error_list->get_item_text(error_list->get_current()); + String desc = error_list->get_item_tooltip(error_list->get_current()); + + OS::get_singleton()->set_clipboard(title + "\n----------\n" + desc); + } break; + } +} + void ScriptEditorDebugger::_bind_methods() { ClassDB::bind_method(D_METHOD("_stack_dump_frame_selected"), &ScriptEditorDebugger::_stack_dump_frame_selected); @@ -1705,6 +1744,10 @@ void ScriptEditorDebugger::_bind_methods() { ClassDB::bind_method(D_METHOD("_error_stack_selected"), &ScriptEditorDebugger::_error_stack_selected); ClassDB::bind_method(D_METHOD("_profiler_activate"), &ScriptEditorDebugger::_profiler_activate); ClassDB::bind_method(D_METHOD("_profiler_seeked"), &ScriptEditorDebugger::_profiler_seeked); + ClassDB::bind_method(D_METHOD("_clear_errors_list"), &ScriptEditorDebugger::_clear_errors_list); + + ClassDB::bind_method(D_METHOD("_error_list_item_rmb_selected"), &ScriptEditorDebugger::_error_list_item_rmb_selected); + ClassDB::bind_method(D_METHOD("_item_menu_id_pressed"), &ScriptEditorDebugger::_item_menu_id_pressed); ClassDB::bind_method(D_METHOD("_paused"), &ScriptEditorDebugger::_paused); @@ -1829,9 +1872,31 @@ ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor) { error_split = memnew(HSplitContainer); VBoxContainer *errvb = memnew(VBoxContainer); + HBoxContainer *errhb = memnew(HBoxContainer); errvb->set_h_size_flags(SIZE_EXPAND_FILL); + Label *velb = memnew(Label(TTR("Errors:"))); + velb->set_h_size_flags(SIZE_EXPAND_FILL); + errhb->add_child(velb); + + clearbutton = memnew(Button); + clearbutton->set_text(TTR("Clear")); + clearbutton->connect("pressed", this, "_clear_errors_list"); + errhb->add_child(clearbutton); + errvb->add_child(errhb); + error_list = memnew(ItemList); - errvb->add_margin_child(TTR("Errors:"), error_list, true); + error_list->set_v_size_flags(SIZE_EXPAND_FILL); + error_list->set_h_size_flags(SIZE_EXPAND_FILL); + error_list->connect("item_rmb_selected", this, "_error_list_item_rmb_selected"); + error_list->set_allow_rmb_select(true); + error_list->set_autoscroll_to_bottom(true); + + item_menu = memnew(PopupMenu); + item_menu->connect("id_pressed", this, "_item_menu_id_pressed"); + error_list->add_child(item_menu); + + errvb->add_child(error_list); + error_split->add_child(errvb); errvb = memnew(VBoxContainer); diff --git a/editor/script_editor_debugger.h b/editor/script_editor_debugger.h index e380a56b1..7f8348d82 100644 --- a/editor/script_editor_debugger.h +++ b/editor/script_editor_debugger.h @@ -62,6 +62,10 @@ class ScriptEditorDebugger : public Control { MESSAGE_SUCCESS, }; + enum ItemMenu { + ITEM_MENU_COPY_ERROR, + }; + AcceptDialog *msgdialog; Button *debugger_button; @@ -85,6 +89,8 @@ class ScriptEditorDebugger : public Control { ItemList *error_list; ItemList *error_stack; Tree *inspect_scene_tree; + Button *clearbutton; + PopupMenu *item_menu; int error_count; int last_error_count; @@ -175,6 +181,10 @@ class ScriptEditorDebugger : public Control { void _set_remote_object(ObjectID p_id, ScriptEditorDebuggerInspectedObject *p_obj); void _clear_remote_objects(); + void _clear_errors_list(); + + void _error_list_item_rmb_selected(int p_item, const Vector2 &p_pos); + void _item_menu_id_pressed(int p_option); protected: void _notification(int p_what); |
