diff options
Diffstat (limited to 'editor')
36 files changed, 709 insertions, 481 deletions
diff --git a/editor/animation_track_editor.cpp b/editor/animation_track_editor.cpp index 7dadbf88fb..0385220baa 100644 --- a/editor/animation_track_editor.cpp +++ b/editor/animation_track_editor.cpp @@ -1214,7 +1214,7 @@ void AnimationTrackEdit::_notification(int p_what) { Color accent = get_color("accent_color", "Editor"); accent.a *= 0.7; // Offside so the horizontal sides aren't cutoff. - draw_rect(Rect2(Point2(1, 0), get_size() - Size2(1, 0)), accent, false); + draw_rect(Rect2(Point2(1 * EDSCALE, 0), get_size() - Size2(1 * EDSCALE, 0)), accent, false); } Ref<Font> font = get_font("font", "Label"); diff --git a/editor/audio_stream_preview.cpp b/editor/audio_stream_preview.cpp index 85db8b77f9..b30b94ab26 100644 --- a/editor/audio_stream_preview.cpp +++ b/editor/audio_stream_preview.cpp @@ -129,7 +129,7 @@ void AudioStreamPreviewGenerator::_preview_thread(void *p_preview) { float max = -1000; float min = 1000; int from = uint64_t(i) * to_read / to_write; - int to = uint64_t(i + 1) * to_read / to_write; + int to = (uint64_t(i) + 1) * to_read / to_write; to = MIN(to, to_read); from = MIN(from, to_read - 1); if (to == from) { diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp index 4a440510db..01773a0bcd 100644 --- a/editor/code_editor.cpp +++ b/editor/code_editor.cpp @@ -930,7 +930,7 @@ void CodeTextEditor::convert_case(CaseStyle p_case) { for (int i = begin; i <= end; i++) { int len = text_editor->get_line(i).length(); if (i == end) - len -= len - end_col; + len = end_col; if (i == begin) len -= begin_col; String new_line = text_editor->get_line(i).substr(i == begin ? begin_col : 0, len); diff --git a/editor/connections_dialog.cpp b/editor/connections_dialog.cpp index 82fc8e5cfa..6d3603f31b 100644 --- a/editor/connections_dialog.cpp +++ b/editor/connections_dialog.cpp @@ -126,7 +126,6 @@ void ConnectDialog::ok_pressed() { } } emit_signal("connected"); - hide(); } void ConnectDialog::_cancel_pressed() { @@ -364,7 +363,7 @@ ConnectDialog::ConnectDialog() { tree->connect("node_selected", this, "_tree_node_selected"); tree->set_connect_to_script_mode(true); - Node *mc = vbc_left->add_margin_child(TTR("Connect To Script:"), tree, true); + Node *mc = vbc_left->add_margin_child(TTR("Connect to Script:"), tree, true); connect_to_label = Object::cast_to<Label>(vbc_left->get_child(mc->get_index() - 1)); error_label = memnew(Label); @@ -414,7 +413,7 @@ ConnectDialog::ConnectDialog() { vbc_right->add_margin_child(TTR("Extra Call Arguments:"), bind_editor, true); HBoxContainer *dstm_hb = memnew(HBoxContainer); - vbc_left->add_margin_child("Method to Create:", dstm_hb); + vbc_left->add_margin_child("Receiver Method:", dstm_hb); dst_method = memnew(LineEdit); dst_method->set_h_size_flags(SIZE_EXPAND_FILL); @@ -458,7 +457,7 @@ ConnectDialog::~ConnectDialog() { memdelete(cdbinds); } -//ConnectionsDock ========================== +////////////////////////////////////////// struct _ConnectionsDockMethodInfoSort { @@ -490,11 +489,29 @@ void ConnectionsDock::_make_or_edit_connection() { bool oshot = connect_dialog->get_oneshot(); cToMake.flags = CONNECT_PERSIST | (defer ? CONNECT_DEFERRED : 0) | (oshot ? CONNECT_ONESHOT : 0); - //conditions to add function, must have a script and must have a method - bool add_script_function = !target->get_script().is_null() && !ClassDB::has_method(target->get_class(), cToMake.method); + // Conditions to add function: must have a script and must not have the method already + // (in the class, the script itself, or inherited). + bool add_script_function = false; + Ref<Script> script = target->get_script(); + if (!target->get_script().is_null() && !ClassDB::has_method(target->get_class(), cToMake.method)) { + // There is a chance that the method is inherited from another script. + bool found_inherited_function = false; + Ref<Script> inherited_script = script->get_base_script(); + while (!inherited_script.is_null()) { + int line = inherited_script->get_language()->find_function(cToMake.method, inherited_script->get_source_code()); + if (line != -1) { + found_inherited_function = true; + break; + } + + inherited_script = inherited_script->get_base_script(); + } + + add_script_function = !found_inherited_function; + } PoolStringArray script_function_args; if (add_script_function) { - // pick up args here before "it" is deleted by update_tree + // Pick up args here before "it" is deleted by update_tree. script_function_args = it->get_metadata(0).operator Dictionary()["args"]; for (int i = 0; i < cToMake.binds.size(); i++) { script_function_args.append("extra_arg_" + itos(i)); @@ -508,8 +525,7 @@ void ConnectionsDock::_make_or_edit_connection() { _connect(cToMake); } - // IMPORTANT NOTE: _disconnect and _connect cause an update_tree, - // which will delete the object "it" is pointing to + // IMPORTANT NOTE: _disconnect and _connect cause an update_tree, which will delete the object "it" is pointing to. it = NULL; if (add_script_function) { @@ -549,7 +565,7 @@ Break single connection w/ undo-redo functionality. void ConnectionsDock::_disconnect(TreeItem &item) { Connection c = item.get_metadata(0); - ERR_FAIL_COND(c.source != selectedNode); //shouldn't happen but...bugcheck + ERR_FAIL_COND(c.source != selectedNode); // Shouldn't happen but... Bugcheck. undo_redo->create_action(vformat(TTR("Disconnect '%s' from '%s'"), c.signal, c.method)); @@ -557,7 +573,7 @@ void ConnectionsDock::_disconnect(TreeItem &item) { undo_redo->add_undo_method(selectedNode, "connect", c.signal, c.target, c.method, c.binds, c.flags); undo_redo->add_do_method(this, "update_tree"); undo_redo->add_undo_method(this, "update_tree"); - undo_redo->add_do_method(EditorNode::get_singleton()->get_scene_tree_dock()->get_tree_editor(), "update_tree"); //to force redraw of scene tree + undo_redo->add_do_method(EditorNode::get_singleton()->get_scene_tree_dock()->get_tree_editor(), "update_tree"); // To force redraw of scene tree. undo_redo->add_undo_method(EditorNode::get_singleton()->get_scene_tree_dock()->get_tree_editor(), "update_tree"); undo_redo->commit_action(); @@ -596,7 +612,7 @@ void ConnectionsDock::_disconnect_all() { void ConnectionsDock::_tree_item_selected() { TreeItem *item = tree->get_selected(); - if (!item) { //Unlikely. Disable button just in case. + if (!item) { // Unlikely. Disable button just in case. connect_button->set_text(TTR("Connect...")); connect_button->set_disabled(true); } else if (_is_item_signal(*item)) { @@ -608,7 +624,7 @@ void ConnectionsDock::_tree_item_selected() { } } -void ConnectionsDock::_tree_item_activated() { //"Activation" on double-click. +void ConnectionsDock::_tree_item_activated() { // "Activation" on double-click. TreeItem *item = tree->get_selected(); @@ -630,7 +646,6 @@ bool ConnectionsDock::_is_item_signal(TreeItem &item) { /* Open connection dialog with TreeItem data to CREATE a brand-new connection. */ - void ConnectionsDock::_open_connection_dialog(TreeItem &item) { String signal = item.get_metadata(0).operator Dictionary()["name"]; @@ -640,10 +655,10 @@ void ConnectionsDock::_open_connection_dialog(TreeItem &item) { CharType c = midname[i]; if (!((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || c == '_')) { if (c == ' ') { - //Replace spaces with underlines. + // Replace spaces with underlines. c = '_'; } else { - //Remove any other characters. + // Remove any other characters. midname.remove(i); i--; continue; @@ -679,7 +694,7 @@ void ConnectionsDock::_open_connection_dialog(Connection cToEdit) { if (src && dst) { connect_dialog->set_title(TTR("Edit Connection:") + cToEdit.signal); - connect_dialog->popup_centered_ratio(); + connect_dialog->popup_centered(); connect_dialog->init(cToEdit, true); } } @@ -828,7 +843,6 @@ void ConnectionsDock::update_tree() { selectedNode->get_signal_list(&node_signals); - //node_signals.sort_custom<_ConnectionsDockMethodInfoSort>(); bool did_script = false; StringName base = selectedNode->get_class(); @@ -955,7 +969,7 @@ void ConnectionsDock::update_tree() { } } - connect_button->set_text(TTR("Connect")); + connect_button->set_text(TTR("Connect...")); connect_button->set_disabled(true); } @@ -975,7 +989,6 @@ ConnectionsDock::ConnectionsDock(EditorNode *p_editor) { tree->set_allow_rmb_select(true); connect_button = memnew(Button); - connect_button->set_text(TTR("Connect")); HBoxContainer *hb = memnew(HBoxContainer); vbc->add_child(hb); hb->add_spacer(); @@ -1005,15 +1018,6 @@ ConnectionsDock::ConnectionsDock(EditorNode *p_editor) { slot_menu->add_item(TTR("Go To Method"), GO_TO_SCRIPT); slot_menu->add_item(TTR("Disconnect"), DISCONNECT); - /* - node_only->set_anchor( MARGIN_TOP, ANCHOR_END ); - node_only->set_anchor( MARGIN_BOTTOM, ANCHOR_END ); - node_only->set_anchor( MARGIN_RIGHT, ANCHOR_END ); - - node_only->set_begin( Point2( 20,51) ); - node_only->set_end( Point2( 10,44) ); - */ - connect_dialog->connect("connected", this, "_make_or_edit_connection"); tree->connect("item_selected", this, "_tree_item_selected"); tree->connect("item_activated", this, "_tree_item_activated"); diff --git a/editor/connections_dialog.h b/editor/connections_dialog.h index 94f1510810..195c9e1e7d 100644 --- a/editor/connections_dialog.h +++ b/editor/connections_dialog.h @@ -104,7 +104,7 @@ public: ~ConnectDialog(); }; -//======================================== +////////////////////////////////////////// class ConnectionsDock : public VBoxContainer { diff --git a/editor/create_dialog.cpp b/editor/create_dialog.cpp index 604a050fcd..e84602b29f 100644 --- a/editor/create_dialog.cpp +++ b/editor/create_dialog.cpp @@ -246,13 +246,14 @@ bool CreateDialog::_is_class_disabled_by_feature_profile(const StringName &p_cla if (profile->is_class_disabled(class_name)) { return true; } - class_name = ClassDB::get_parent_class(class_name); + class_name = ClassDB::get_parent_class_nocheck(class_name); } return false; } void CreateDialog::select_type(const String &p_type) { + TreeItem *to_select; if (search_options_types.has(p_type)) { to_select = search_options_types[p_type]; @@ -279,10 +280,6 @@ void CreateDialog::_update_search() { favorite->set_disabled(true); help_bit->set_text(""); - /* - TreeItem *root = search_options->create_item(); - _parse_fs(EditorFileSystem::get_singleton()->get_filesystem()); -*/ search_options_types.clear(); @@ -733,6 +730,7 @@ CreateDialog::CreateDialog() { fav_vb->add_margin_child(TTR("Favorites:"), favorites, true); favorites->set_hide_root(true); favorites->set_hide_folding(true); + favorites->set_allow_reselect(true); favorites->connect("cell_selected", this, "_favorite_selected"); favorites->connect("item_activated", this, "_favorite_activated"); favorites->set_drag_forwarding(this); @@ -747,6 +745,7 @@ CreateDialog::CreateDialog() { rec_vb->add_margin_child(TTR("Recent:"), recent, true); recent->set_hide_root(true); recent->set_hide_folding(true); + recent->set_allow_reselect(true); recent->connect("cell_selected", this, "_history_selected"); recent->connect("item_activated", this, "_history_activated"); recent->add_constant_override("draw_guides", 1); diff --git a/editor/dependency_editor.cpp b/editor/dependency_editor.cpp index cc9e2c12e8..9a049f3ae3 100644 --- a/editor/dependency_editor.cpp +++ b/editor/dependency_editor.cpp @@ -35,9 +35,6 @@ #include "editor_node.h" #include "scene/gui/margin_container.h" -void DependencyEditor::_notification(int p_what) { -} - void DependencyEditor::_searched(const String &p_path) { Map<String, String> dep_rename; @@ -63,7 +60,7 @@ void DependencyEditor::_load_pressed(Object *p_item, int p_cell, int p_button) { for (List<String>::Element *E = ext.front(); E; E = E->next()) { search->add_filter("*" + E->get()); } - search->popup_centered_ratio(); + search->popup_centered_ratio(0.65); // So it doesn't completely cover the dialog below it. } void DependencyEditor::_fix_and_find(EditorFileSystemDirectory *efsd, Map<String, Map<String, String> > &candidates) { @@ -222,7 +219,7 @@ void DependencyEditor::edit(const String &p_path) { set_title(TTR("Dependencies For:") + " " + p_path.get_file()); _update_list(); - popup_centered_ratio(); + popup_centered_ratio(0.7); // So it doesn't completely cover the dialog below it. if (EditorNode::get_singleton()->is_scene_open(p_path)) { EditorNode::get_singleton()->show_warning(vformat(TTR("Scene '%s' is currently being edited.\nChanges will only take effect when reloaded."), p_path.get_file())); @@ -478,12 +475,13 @@ void DependencyRemoveDialog::show(const Vector<String> &p_folders, const Vector< if (removed_deps.empty()) { owners->hide(); text->set_text(TTR("Remove selected files from the project? (no undo)")); - popup_centered_minsize(Size2(400, 100)); + set_size(Size2()); + popup_centered(); } else { _build_removed_dependency_tree(removed_deps); owners->show(); text->set_text(TTR("The files being removed are required by other resources in order for them to work.\nRemove them anyway? (no undo)")); - popup_centered_minsize(Size2(500, 350)); + popup_centered(Size2(500, 350)); } EditorFileSystem::get_singleton()->scan_changes(); } @@ -579,6 +577,8 @@ void DependencyRemoveDialog::_bind_methods() { DependencyRemoveDialog::DependencyRemoveDialog() { + get_ok()->set_text(TTR("Remove")); + VBoxContainer *vb = memnew(VBoxContainer); add_child(vb); @@ -589,7 +589,6 @@ DependencyRemoveDialog::DependencyRemoveDialog() { owners->set_hide_root(true); vb->add_child(owners); owners->set_v_size_flags(SIZE_EXPAND_FILL); - get_ok()->set_text(TTR("Remove")); } ////////////// @@ -617,7 +616,7 @@ void DependencyErrorDialog::show(Mode p_mode, const String &p_for_file, const Ve ti->set_icon(0, icon); } - popup_centered_minsize(Size2(500, 220)); + popup_centered(); } void DependencyErrorDialog::ok_pressed() { @@ -646,7 +645,8 @@ DependencyErrorDialog::DependencyErrorDialog() { files->set_hide_root(true); vb->add_margin_child(TTR("Load failed due to missing dependencies:"), files, true); files->set_v_size_flags(SIZE_EXPAND_FILL); - files->set_custom_minimum_size(Size2(1, 200)); + + set_custom_minimum_size(Size2(500, 220)); get_ok()->set_text(TTR("Open Anyway")); get_cancel()->set_text(TTR("Close")); @@ -670,7 +670,7 @@ void OrphanResourcesDialog::ok_pressed() { return; delete_confirm->set_text(vformat(TTR("Permanently delete %d item(s)? (No undo!)"), paths.size())); - delete_confirm->popup_centered_minsize(); + delete_confirm->popup_centered_clamped(delete_confirm->get_minimum_size()); } bool OrphanResourcesDialog::_fill_owners(EditorFileSystemDirectory *efsd, HashMap<String, int> &refs, TreeItem *p_parent) { @@ -794,6 +794,15 @@ void OrphanResourcesDialog::_bind_methods() { OrphanResourcesDialog::OrphanResourcesDialog() { + set_title(TTR("Orphan Resource Explorer")); + delete_confirm = memnew(ConfirmationDialog); + get_ok()->set_text(TTR("Delete")); + add_child(delete_confirm); + dep_edit = memnew(DependencyEditor); + add_child(dep_edit); + delete_confirm->connect("confirmed", this, "_delete_confirm"); + set_hide_on_ok(false); + VBoxContainer *vbc = memnew(VBoxContainer); add_child(vbc); @@ -807,14 +816,5 @@ OrphanResourcesDialog::OrphanResourcesDialog() { files->set_column_title(1, TTR("Owns")); files->set_hide_root(true); vbc->add_margin_child(TTR("Resources Without Explicit Ownership:"), files, true); - set_title(TTR("Orphan Resource Explorer")); - delete_confirm = memnew(ConfirmationDialog); - delete_confirm->set_text(TTR("Delete selected files?")); - get_ok()->set_text(TTR("Delete")); - add_child(delete_confirm); - dep_edit = memnew(DependencyEditor); - add_child(dep_edit); files->connect("button_pressed", this, "_button_pressed"); - delete_confirm->connect("confirmed", this, "_delete_confirm"); - set_hide_on_ok(false); } diff --git a/editor/dependency_editor.h b/editor/dependency_editor.h index 23c3cc031c..22e28a4d26 100644 --- a/editor/dependency_editor.h +++ b/editor/dependency_editor.h @@ -63,7 +63,6 @@ class DependencyEditor : public AcceptDialog { protected: static void _bind_methods(); - void _notification(int p_what); public: void edit(const String &p_path); diff --git a/editor/editor_audio_buses.cpp b/editor/editor_audio_buses.cpp index 9cd7d781a4..57fac241b0 100644 --- a/editor/editor_audio_buses.cpp +++ b/editor/editor_audio_buses.cpp @@ -63,118 +63,132 @@ void EditorAudioBus::_update_visible_channels() { void EditorAudioBus::_notification(int p_what) { - if (p_what == NOTIFICATION_READY) { - - for (int i = 0; i < CHANNELS_MAX; i++) { - channel[i].vu_l->set_under_texture(get_icon("BusVuEmpty", "EditorIcons")); - channel[i].vu_l->set_progress_texture(get_icon("BusVuFull", "EditorIcons")); - channel[i].vu_r->set_under_texture(get_icon("BusVuEmpty", "EditorIcons")); - channel[i].vu_r->set_progress_texture(get_icon("BusVuFull", "EditorIcons")); - channel[i].prev_active = true; - } - - disabled_vu = get_icon("BusVuFrozen", "EditorIcons"); - - Color solo_color = Color::html(EditorSettings::get_singleton()->is_dark_theme() ? "#ffe337" : "#ffeb70"); - Color mute_color = Color::html(EditorSettings::get_singleton()->is_dark_theme() ? "#ff2929" : "#ff7070"); - Color bypass_color = Color::html(EditorSettings::get_singleton()->is_dark_theme() ? "#22ccff" : "#70deff"); - - solo->set_icon(get_icon("AudioBusSolo", "EditorIcons")); - solo->add_color_override("icon_color_pressed", solo_color); - mute->set_icon(get_icon("AudioBusMute", "EditorIcons")); - mute->add_color_override("icon_color_pressed", mute_color); - bypass->set_icon(get_icon("AudioBusBypass", "EditorIcons")); - bypass->add_color_override("icon_color_pressed", bypass_color); - - bus_options->set_icon(get_icon("GuiMiniTabMenu", "EditorIcons")); - - update_bus(); - set_process(true); - } + switch (p_what) { + case NOTIFICATION_READY: { + + for (int i = 0; i < CHANNELS_MAX; i++) { + channel[i].vu_l->set_under_texture(get_icon("BusVuEmpty", "EditorIcons")); + channel[i].vu_l->set_progress_texture(get_icon("BusVuFull", "EditorIcons")); + channel[i].vu_r->set_under_texture(get_icon("BusVuEmpty", "EditorIcons")); + channel[i].vu_r->set_progress_texture(get_icon("BusVuFull", "EditorIcons")); + channel[i].prev_active = true; + } - if (p_what == NOTIFICATION_DRAW) { + disabled_vu = get_icon("BusVuFrozen", "EditorIcons"); - if (has_focus()) { - draw_style_box(get_stylebox("focus", "Button"), Rect2(Vector2(), get_size())); - } else if (is_master) { - draw_style_box(get_stylebox("disabled", "Button"), Rect2(Vector2(), get_size())); - } - } + Color solo_color = Color::html(EditorSettings::get_singleton()->is_dark_theme() ? "#ffe337" : "#ffeb70"); + Color mute_color = Color::html(EditorSettings::get_singleton()->is_dark_theme() ? "#ff2929" : "#ff7070"); + Color bypass_color = Color::html(EditorSettings::get_singleton()->is_dark_theme() ? "#22ccff" : "#70deff"); - if (p_what == NOTIFICATION_PROCESS) { + solo->set_icon(get_icon("AudioBusSolo", "EditorIcons")); + solo->add_color_override("icon_color_pressed", solo_color); + mute->set_icon(get_icon("AudioBusMute", "EditorIcons")); + mute->add_color_override("icon_color_pressed", mute_color); + bypass->set_icon(get_icon("AudioBusBypass", "EditorIcons")); + bypass->add_color_override("icon_color_pressed", bypass_color); - if (cc != AudioServer::get_singleton()->get_bus_channels(get_index())) { - cc = AudioServer::get_singleton()->get_bus_channels(get_index()); - _update_visible_channels(); - } + bus_options->set_icon(get_icon("GuiMiniTabMenu", "EditorIcons")); - for (int i = 0; i < cc; i++) { - float real_peak[2] = { -100, -100 }; - bool activity_found = false; + update_bus(); + set_process(true); + } break; + case NOTIFICATION_DRAW: { - if (AudioServer::get_singleton()->is_bus_channel_active(get_index(), i)) { - activity_found = true; - real_peak[0] = MAX(real_peak[0], AudioServer::get_singleton()->get_bus_peak_volume_left_db(get_index(), i)); - real_peak[1] = MAX(real_peak[1], AudioServer::get_singleton()->get_bus_peak_volume_right_db(get_index(), i)); + if (is_master) { + draw_style_box(get_stylebox("disabled", "Button"), Rect2(Vector2(), get_size())); + } else if (has_focus()) { + draw_style_box(get_stylebox("focus", "Button"), Rect2(Vector2(), get_size())); + } else { + draw_style_box(get_stylebox("panel", "TabContainer"), Rect2(Vector2(), get_size())); } - if (real_peak[0] > channel[i].peak_l) { - channel[i].peak_l = real_peak[0]; - } else { - channel[i].peak_l -= get_process_delta_time() * 60.0; + if (get_index() != 0 && hovering_drop) { + Color accent = get_color("accent_color", "Editor"); + accent.a *= 0.7; + draw_rect(Rect2(Point2(), get_size()), accent, false); } + } break; + case NOTIFICATION_PROCESS: { - if (real_peak[1] > channel[i].peak_r) { - channel[i].peak_r = real_peak[1]; - } else { - channel[i].peak_r -= get_process_delta_time() * 60.0; + if (cc != AudioServer::get_singleton()->get_bus_channels(get_index())) { + cc = AudioServer::get_singleton()->get_bus_channels(get_index()); + _update_visible_channels(); } - channel[i].vu_l->set_value(channel[i].peak_l); - channel[i].vu_r->set_value(channel[i].peak_r); + for (int i = 0; i < cc; i++) { + float real_peak[2] = { -100, -100 }; + bool activity_found = false; - if (activity_found != channel[i].prev_active) { - if (activity_found) { - channel[i].vu_l->set_over_texture(Ref<Texture>()); - channel[i].vu_r->set_over_texture(Ref<Texture>()); + if (AudioServer::get_singleton()->is_bus_channel_active(get_index(), i)) { + activity_found = true; + real_peak[0] = MAX(real_peak[0], AudioServer::get_singleton()->get_bus_peak_volume_left_db(get_index(), i)); + real_peak[1] = MAX(real_peak[1], AudioServer::get_singleton()->get_bus_peak_volume_right_db(get_index(), i)); + } + + if (real_peak[0] > channel[i].peak_l) { + channel[i].peak_l = real_peak[0]; } else { - channel[i].vu_l->set_over_texture(disabled_vu); - channel[i].vu_r->set_over_texture(disabled_vu); + channel[i].peak_l -= get_process_delta_time() * 60.0; } - channel[i].prev_active = activity_found; - } - } - } + if (real_peak[1] > channel[i].peak_r) { + channel[i].peak_r = real_peak[1]; + } else { + channel[i].peak_r -= get_process_delta_time() * 60.0; + } - if (p_what == NOTIFICATION_VISIBILITY_CHANGED) { + channel[i].vu_l->set_value(channel[i].peak_l); + channel[i].vu_r->set_value(channel[i].peak_r); - for (int i = 0; i < CHANNELS_MAX; i++) { - channel[i].peak_l = -100; - channel[i].peak_r = -100; - channel[i].prev_active = true; - } + if (activity_found != channel[i].prev_active) { + if (activity_found) { + channel[i].vu_l->set_over_texture(Ref<Texture>()); + channel[i].vu_r->set_over_texture(Ref<Texture>()); + } else { + channel[i].vu_l->set_over_texture(disabled_vu); + channel[i].vu_r->set_over_texture(disabled_vu); + } - set_process(is_visible_in_tree()); - } + channel[i].prev_active = activity_found; + } + } + } break; + case NOTIFICATION_VISIBILITY_CHANGED: { - if (p_what == NOTIFICATION_THEME_CHANGED) { + for (int i = 0; i < CHANNELS_MAX; i++) { + channel[i].peak_l = -100; + channel[i].peak_r = -100; + channel[i].prev_active = true; + } - for (int i = 0; i < CHANNELS_MAX; i++) { - channel[i].vu_l->set_under_texture(get_icon("BusVuEmpty", "EditorIcons")); - channel[i].vu_l->set_progress_texture(get_icon("BusVuFull", "EditorIcons")); - channel[i].vu_r->set_under_texture(get_icon("BusVuEmpty", "EditorIcons")); - channel[i].vu_r->set_progress_texture(get_icon("BusVuFull", "EditorIcons")); - channel[i].prev_active = true; - } + set_process(is_visible_in_tree()); + } break; + case NOTIFICATION_THEME_CHANGED: { - disabled_vu = get_icon("BusVuFrozen", "EditorIcons"); + for (int i = 0; i < CHANNELS_MAX; i++) { + channel[i].vu_l->set_under_texture(get_icon("BusVuEmpty", "EditorIcons")); + channel[i].vu_l->set_progress_texture(get_icon("BusVuFull", "EditorIcons")); + channel[i].vu_r->set_under_texture(get_icon("BusVuEmpty", "EditorIcons")); + channel[i].vu_r->set_progress_texture(get_icon("BusVuFull", "EditorIcons")); + channel[i].prev_active = true; + } - solo->set_icon(get_icon("AudioBusSolo", "EditorIcons")); - mute->set_icon(get_icon("AudioBusMute", "EditorIcons")); - bypass->set_icon(get_icon("AudioBusBypass", "EditorIcons")); + disabled_vu = get_icon("BusVuFrozen", "EditorIcons"); - bus_options->set_icon(get_icon("GuiMiniTabMenu", "EditorIcons")); + solo->set_icon(get_icon("AudioBusSolo", "EditorIcons")); + mute->set_icon(get_icon("AudioBusMute", "EditorIcons")); + bypass->set_icon(get_icon("AudioBusBypass", "EditorIcons")); + + bus_options->set_icon(get_icon("GuiMiniTabMenu", "EditorIcons")); + } break; + case NOTIFICATION_MOUSE_EXIT: + case NOTIFICATION_DRAG_END: { + + if (hovering_drop) { + hovering_drop = false; + update(); + } + } break; } } @@ -553,6 +567,7 @@ Variant EditorAudioBus::get_drag_data(const Point2 &p_point) { Control *c = memnew(Control); Panel *p = memnew(Panel); c->add_child(p); + p->set_modulate(Color(1, 1, 1, 0.7)); p->add_style_override("panel", get_stylebox("focus", "Button")); p->set_size(get_size()); p->set_position(-p_point); @@ -560,21 +575,29 @@ Variant EditorAudioBus::get_drag_data(const Point2 &p_point) { Dictionary d; d["type"] = "move_audio_bus"; d["index"] = get_index(); - emit_signal("drop_end_request"); + + if (get_index() < AudioServer::get_singleton()->get_bus_count() - 1) { + emit_signal("drop_end_request"); + } + return d; } bool EditorAudioBus::can_drop_data(const Point2 &p_point, const Variant &p_data) const { - if (get_index() == 0) + if (get_index() == 0) { return false; + } + Dictionary d = p_data; - if (d.has("type") && String(d["type"]) == "move_audio_bus") { + if (d.has("type") && String(d["type"]) == "move_audio_bus" && (int)d["index"] != get_index()) { + hovering_drop = true; return true; } return false; } + void EditorAudioBus::drop_data(const Point2 &p_point, const Variant &p_data) { Dictionary d = p_data; @@ -589,7 +612,6 @@ Variant EditorAudioBus::get_drag_data_fw(const Point2 &p_point, Control *p_from) } Variant md = item->get_metadata(0); - if (md.get_type() == Variant::INT) { Dictionary fxd; fxd["type"] = "audio_bus_effect"; @@ -749,6 +771,7 @@ EditorAudioBus::EditorAudioBus(EditorAudioBuses *p_buses, bool p_is_master) { buses = p_buses; updating_bus = false; is_master = p_is_master; + hovering_drop = false; set_tooltip(TTR("Audio Bus, Drag and Drop to rearrange.")); @@ -756,7 +779,6 @@ EditorAudioBus::EditorAudioBus(EditorAudioBuses *p_buses, bool p_is_master) { add_child(vb); set_v_size_flags(SIZE_EXPAND_FILL); - set_custom_minimum_size(Size2(110, 0) * EDSCALE); track_name = memnew(LineEdit); track_name->connect("text_entered", this, "_name_changed"); @@ -800,7 +822,9 @@ EditorAudioBus::EditorAudioBus(EditorAudioBuses *p_buses, bool p_is_master) { child->add_style_override("pressed", sbempty); } - vb->add_child(memnew(HSeparator)); + HSeparator *separator = memnew(HSeparator); + separator->set_mouse_filter(MOUSE_FILTER_PASS); + vb->add_child(separator); HBoxContainer *hb = memnew(HBoxContainer); vb->add_child(hb); @@ -811,20 +835,19 @@ EditorAudioBus::EditorAudioBus(EditorAudioBuses *p_buses, bool p_is_master) { slider->set_clip_contents(false); audio_value_preview_box = memnew(Panel); - { - HBoxContainer *audioprev_hbc = memnew(HBoxContainer); - audioprev_hbc->set_v_size_flags(SIZE_EXPAND_FILL); - audioprev_hbc->set_h_size_flags(SIZE_EXPAND_FILL); - audioprev_hbc->set_mouse_filter(MOUSE_FILTER_PASS); - audio_value_preview_box->add_child(audioprev_hbc); - - audio_value_preview_label = memnew(Label); - audio_value_preview_label->set_v_size_flags(SIZE_EXPAND_FILL); - audio_value_preview_label->set_h_size_flags(SIZE_EXPAND_FILL); - audio_value_preview_label->set_mouse_filter(MOUSE_FILTER_PASS); - - audioprev_hbc->add_child(audio_value_preview_label); - } + HBoxContainer *audioprev_hbc = memnew(HBoxContainer); + audioprev_hbc->set_v_size_flags(SIZE_EXPAND_FILL); + audioprev_hbc->set_h_size_flags(SIZE_EXPAND_FILL); + audioprev_hbc->set_mouse_filter(MOUSE_FILTER_PASS); + audio_value_preview_box->add_child(audioprev_hbc); + + audio_value_preview_label = memnew(Label); + audio_value_preview_label->set_v_size_flags(SIZE_EXPAND_FILL); + audio_value_preview_label->set_h_size_flags(SIZE_EXPAND_FILL); + audio_value_preview_label->set_mouse_filter(MOUSE_FILTER_PASS); + + audioprev_hbc->add_child(audio_value_preview_label); + slider->add_child(audio_value_preview_box); audio_value_preview_box->set_as_toplevel(true); Ref<StyleBoxFlat> panel_style = memnew(StyleBoxFlat); @@ -863,17 +886,18 @@ EditorAudioBus::EditorAudioBus(EditorAudioBuses *p_buses, bool p_is_master) { channel[i].peak_r = 0.0f; } - scale = memnew(EditorAudioMeterNotches); + EditorAudioMeterNotches *scale = memnew(EditorAudioMeterNotches); for (float db = 6.0f; db >= -80.0f; db -= 6.0f) { bool renderNotch = (db >= -6.0f || db == -24.0f || db == -72.0f); scale->add_notch(_scaled_db_to_normalized_volume(db), db, renderNotch); } + scale->set_mouse_filter(MOUSE_FILTER_PASS); hb->add_child(scale); effects = memnew(Tree); effects->set_hide_root(true); - effects->set_custom_minimum_size(Size2(0, 100) * EDSCALE); + effects->set_custom_minimum_size(Size2(0, 80) * EDSCALE); effects->set_hide_folding(true); effects->set_v_size_flags(SIZE_EXPAND_FILL); vb->add_child(effects); @@ -923,6 +947,36 @@ EditorAudioBus::EditorAudioBus(EditorAudioBuses *p_buses, bool p_is_master) { delete_effect_popup->connect("index_pressed", this, "_delete_effect_pressed"); } +void EditorAudioBusDrop::_notification(int p_what) { + + switch (p_what) { + case NOTIFICATION_DRAW: { + draw_style_box(get_stylebox("normal", "Button"), Rect2(Vector2(), get_size())); + + if (hovering_drop) { + Color accent = get_color("accent_color", "Editor"); + accent.a *= 0.7; + draw_rect(Rect2(Point2(), get_size()), accent, false); + } + } break; + case NOTIFICATION_MOUSE_ENTER: { + + if (!hovering_drop) { + hovering_drop = true; + update(); + } + } break; + case NOTIFICATION_MOUSE_EXIT: + case NOTIFICATION_DRAG_END: { + + if (hovering_drop) { + hovering_drop = false; + update(); + } + } break; + } +} + bool EditorAudioBusDrop::can_drop_data(const Point2 &p_point, const Variant &p_data) const { Dictionary d = p_data; @@ -932,10 +986,11 @@ bool EditorAudioBusDrop::can_drop_data(const Point2 &p_point, const Variant &p_d return false; } + void EditorAudioBusDrop::drop_data(const Point2 &p_point, const Variant &p_data) { Dictionary d = p_data; - emit_signal("dropped", d["index"], -1); + emit_signal("dropped", d["index"], AudioServer::get_singleton()->get_bus_count()); } void EditorAudioBusDrop::_bind_methods() { @@ -944,6 +999,8 @@ void EditorAudioBusDrop::_bind_methods() { } EditorAudioBusDrop::EditorAudioBusDrop() { + + hovering_drop = false; } void EditorAudioBuses::_update_buses() { @@ -976,37 +1033,43 @@ EditorAudioBuses *EditorAudioBuses::register_editor() { void EditorAudioBuses::_notification(int p_what) { - if (p_what == NOTIFICATION_READY) { - _update_buses(); - } + switch (p_what) { + case NOTIFICATION_ENTER_TREE: + case NOTIFICATION_THEME_CHANGED: { - if (p_what == NOTIFICATION_DRAG_END) { - if (drop_end) { - drop_end->queue_delete(); - drop_end = NULL; - } - } + bus_scroll->add_style_override("bg", get_stylebox("bg", "Tree")); + } break; + case NOTIFICATION_READY: { - if (p_what == NOTIFICATION_PROCESS) { + _update_buses(); + } break; + case NOTIFICATION_DRAG_END: { - //check if anything was edited - bool edited = AudioServer::get_singleton()->is_edited(); - for (int i = 0; i < AudioServer::get_singleton()->get_bus_count(); i++) { - for (int j = 0; j < AudioServer::get_singleton()->get_bus_effect_count(i); j++) { - Ref<AudioEffect> effect = AudioServer::get_singleton()->get_bus_effect(i, j); - if (effect->is_edited()) { - edited = true; - effect->set_edited(false); + if (drop_end) { + drop_end->queue_delete(); + drop_end = NULL; + } + } break; + case NOTIFICATION_PROCESS: { + + // Check if anything was edited. + bool edited = AudioServer::get_singleton()->is_edited(); + for (int i = 0; i < AudioServer::get_singleton()->get_bus_count(); i++) { + for (int j = 0; j < AudioServer::get_singleton()->get_bus_effect_count(i); j++) { + Ref<AudioEffect> effect = AudioServer::get_singleton()->get_bus_effect(i, j); + if (effect->is_edited()) { + edited = true; + effect->set_edited(false); + } } } - } - - AudioServer::get_singleton()->set_edited(false); - if (edited) { + AudioServer::get_singleton()->set_edited(false); - save_timer->start(); - } + if (edited) { + save_timer->start(); + } + } break; } } @@ -1014,7 +1077,6 @@ void EditorAudioBuses::_add_bus() { UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo(); - //need to simulate new name, so we can undi :( ur->create_action(TTR("Add Audio Bus")); ur->add_do_method(AudioServer::get_singleton(), "set_bus_count", AudioServer::get_singleton()->get_bus_count() + 1); ur->add_undo_method(AudioServer::get_singleton(), "set_bus_count", AudioServer::get_singleton()->get_bus_count()); @@ -1119,21 +1181,12 @@ void EditorAudioBuses::_request_drop_end() { void EditorAudioBuses::_drop_at_index(int p_bus, int p_index) { UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo(); - - //need to simulate new name, so we can undi :( ur->create_action(TTR("Move Audio Bus")); + ur->add_do_method(AudioServer::get_singleton(), "move_bus", p_bus, p_index); - int final_pos; - if (p_index == p_bus) { - final_pos = p_bus; - } else if (p_index == -1) { - final_pos = AudioServer::get_singleton()->get_bus_count() - 1; - } else if (p_index < p_bus) { - final_pos = p_index; - } else { - final_pos = p_index - 1; - } - ur->add_undo_method(AudioServer::get_singleton(), "move_bus", final_pos, p_bus); + int real_bus = p_index > p_bus ? p_bus : p_bus + 1; + int real_index = p_index > p_bus ? p_index - 1 : p_index; + ur->add_undo_method(AudioServer::get_singleton(), "move_bus", real_index, real_bus); ur->add_do_method(this, "_update_buses"); ur->add_undo_method(this, "_update_buses"); @@ -1189,7 +1242,7 @@ void EditorAudioBuses::_load_default_layout() { } edited_path = layout_path; - file->set_text(layout_path.get_file()); + file->set_text(String(TTR("Layout")) + ": " + layout_path.get_file()); AudioServer::get_singleton()->set_bus_layout(state); _update_buses(); EditorNode::get_singleton()->get_undo_redo()->clear_history(); @@ -1206,7 +1259,7 @@ void EditorAudioBuses::_file_dialog_callback(const String &p_string) { } edited_path = p_string; - file->set_text(p_string.get_file()); + file->set_text(String(TTR("Layout")) + ": " + p_string.get_file()); AudioServer::get_singleton()->set_bus_layout(state); _update_buses(); EditorNode::get_singleton()->get_undo_redo()->clear_history(); @@ -1228,7 +1281,7 @@ void EditorAudioBuses::_file_dialog_callback(const String &p_string) { } edited_path = p_string; - file->set_text(p_string.get_file()); + file->set_text(String(TTR("Layout")) + ": " + p_string.get_file()); _update_buses(); EditorNode::get_singleton()->get_undo_redo()->clear_history(); call_deferred("_select_layout"); @@ -1262,19 +1315,20 @@ EditorAudioBuses::EditorAudioBuses() { top_hb = memnew(HBoxContainer); add_child(top_hb); - file = memnew(ToolButton); - file->set_text("default_bus_layout.tres"); + file = memnew(Label); + file->set_text(String(TTR("Layout")) + ": " + "default_bus_layout.tres"); + file->set_clip_text(true); + file->set_h_size_flags(SIZE_EXPAND_FILL); top_hb->add_child(file); - file->connect("pressed", this, "_select_layout"); add = memnew(Button); top_hb->add_child(add); add->set_text(TTR("Add Bus")); add->set_tooltip(TTR("Add a new Audio Bus to this layout.")); - add->connect("pressed", this, "_add_bus"); - top_hb->add_spacer(); + VSeparator *separator = memnew(VSeparator); + top_hb->add_child(separator); load = memnew(Button); load->set_text(TTR("Load")); @@ -1301,7 +1355,6 @@ EditorAudioBuses::EditorAudioBuses() { _new->connect("pressed", this, "_new_layout"); bus_scroll = memnew(ScrollContainer); - bus_scroll->add_style_override("panel", memnew(StyleBoxEmpty)); bus_scroll->set_v_size_flags(SIZE_EXPAND_FILL); bus_scroll->set_enable_h_scroll(true); bus_scroll->set_enable_v_scroll(false); @@ -1377,38 +1430,65 @@ AudioBusesEditorPlugin::AudioBusesEditorPlugin(EditorAudioBuses *p_node) { AudioBusesEditorPlugin::~AudioBusesEditorPlugin() { } -void EditorAudioMeterNotches::add_notch(float normalized_offset, float db_value, bool render_value) { - notches.push_back(AudioNotch(normalized_offset, db_value, render_value)); +void EditorAudioMeterNotches::add_notch(float p_normalized_offset, float p_db_value, bool p_render_value) { + + notches.push_back(AudioNotch(p_normalized_offset, p_db_value, p_render_value)); +} + +Size2 EditorAudioMeterNotches::get_minimum_size() const { + + Ref<Font> font = get_font("font", "Label"); + float font_height = font->get_height(); + + float width = 0; + float height = top_padding + btm_padding; + + for (uint8_t i = 0; i < notches.size(); i++) { + if (notches[i].render_db_value) { + width = MAX(width, font->get_string_size(String::num(Math::abs(notches[i].db_value)) + "dB").x); + height += font_height; + } + } + width += line_length + label_space; + + return Size2(width, height); } void EditorAudioMeterNotches::_bind_methods() { + ClassDB::bind_method("add_notch", &EditorAudioMeterNotches::add_notch); ClassDB::bind_method("_draw_audio_notches", &EditorAudioMeterNotches::_draw_audio_notches); } void EditorAudioMeterNotches::_notification(int p_what) { - if (p_what == NOTIFICATION_DRAW) { - notch_color = EditorSettings::get_singleton()->is_dark_theme() ? Color(1.0f, 1.0f, 1.0f, 0.8f) : Color(0.0f, 0.0f, 0.0f, 0.8f); - _draw_audio_notches(); + + switch (p_what) { + case NOTIFICATION_THEME_CHANGED: { + notch_color = EditorSettings::get_singleton()->is_dark_theme() ? Color(1, 1, 1) : Color(0, 0, 0); + } break; + case NOTIFICATION_DRAW: { + _draw_audio_notches(); + } break; } } void EditorAudioMeterNotches::_draw_audio_notches() { + Ref<Font> font = get_font("font", "Label"); float font_height = font->get_height(); for (uint8_t i = 0; i < notches.size(); i++) { AudioNotch n = notches[i]; - draw_line(Vector2(0.0f, (1.0f - n.relative_position) * (get_size().y - btm_padding - top_padding) + top_padding), + draw_line(Vector2(0, (1.0f - n.relative_position) * (get_size().y - btm_padding - top_padding) + top_padding), Vector2(line_length, (1.0f - n.relative_position) * (get_size().y - btm_padding - top_padding) + top_padding), notch_color, - 1.0f); + 1); if (n.render_db_value) { draw_string(font, Vector2(line_length + label_space, (1.0f - n.relative_position) * (get_size().y - btm_padding - top_padding) + (font_height / 4) + top_padding), - String("{0}dB").format(varray(Math::abs(n.db_value))), + String::num(Math::abs(n.db_value)) + "dB", notch_color); } } @@ -1419,7 +1499,6 @@ EditorAudioMeterNotches::EditorAudioMeterNotches() : label_space(2.0f), btm_padding(9.0f), top_padding(5.0f) { - this->set_v_size_flags(SIZE_EXPAND_FILL); - this->set_h_size_flags(SIZE_EXPAND_FILL); - notch_color = EditorSettings::get_singleton()->is_dark_theme() ? Color(1.0f, 1.0f, 1.0f, 0.8f) : Color(0.0f, 0.0f, 0.0f, 0.8f); + + notch_color = EditorSettings::get_singleton()->is_dark_theme() ? Color(1, 1, 1) : Color(0, 0, 0); } diff --git a/editor/editor_audio_buses.h b/editor/editor_audio_buses.h index 50f2101fd8..20890fd3b5 100644 --- a/editor/editor_audio_buses.h +++ b/editor/editor_audio_buses.h @@ -72,7 +72,6 @@ class EditorAudioBus : public PanelContainer { TextureProgress *vu_r; } channel[CHANNELS_MAX]; - class EditorAudioMeterNotches *scale; OptionButton *send; PopupMenu *effect_options; @@ -90,8 +89,8 @@ class EditorAudioBus : public PanelContainer { Tree *effects; bool updating_bus; - bool is_master; + mutable bool hovering_drop; void _gui_input(const Ref<InputEvent> &p_event); void _bus_popup_pressed(int p_option); @@ -137,15 +136,18 @@ public: EditorAudioBus(EditorAudioBuses *p_buses = NULL, bool p_is_master = false); }; -class EditorAudioBusDrop : public Panel { +class EditorAudioBusDrop : public Control { - GDCLASS(EditorAudioBusDrop, Panel); + GDCLASS(EditorAudioBusDrop, Control); virtual bool can_drop_data(const Point2 &p_point, const Variant &p_data) const; virtual void drop_data(const Point2 &p_point, const Variant &p_data); + mutable bool hovering_drop; + protected: static void _bind_methods(); + void _notification(int p_what); public: EditorAudioBusDrop(); @@ -157,13 +159,14 @@ class EditorAudioBuses : public VBoxContainer { HBoxContainer *top_hb; - Button *add; ScrollContainer *bus_scroll; HBoxContainer *bus_hb; EditorAudioBusDrop *drop_end; - Button *file; + Label *file; + + Button *add; Button *load; Button *save_as; Button *_default; @@ -242,7 +245,8 @@ public: float top_padding; Color notch_color; - void add_notch(float normalized_offset, float db_value, bool render_value = false); + void add_notch(float p_normalized_offset, float p_db_value, bool p_render_value = false); + Size2 get_minimum_size() const; private: static void _bind_methods(); diff --git a/editor/editor_file_dialog.cpp b/editor/editor_file_dialog.cpp index 1a293adb4b..8025fc9795 100644 --- a/editor/editor_file_dialog.cpp +++ b/editor/editor_file_dialog.cpp @@ -63,6 +63,7 @@ void EditorFileDialog::_notification(int p_what) { dir_up->set_icon(get_icon("ArrowUp", "EditorIcons")); refresh->set_icon(get_icon("Reload", "EditorIcons")); favorite->set_icon(get_icon("Favorites", "EditorIcons")); + show_hidden->set_icon(get_icon("GuiVisibilityVisible", "EditorIcons")); fav_up->set_icon(get_icon("MoveUp", "EditorIcons")); fav_down->set_icon(get_icon("MoveDown", "EditorIcons")); @@ -86,9 +87,9 @@ void EditorFileDialog::_notification(int p_what) { } else if (p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) { - bool show_hidden = EditorSettings::get_singleton()->get("filesystem/file_dialog/show_hidden_files"); - if (show_hidden_files != show_hidden) - set_show_hidden_files(show_hidden); + bool is_showing_hidden = EditorSettings::get_singleton()->get("filesystem/file_dialog/show_hidden_files"); + if (show_hidden_files != is_showing_hidden) + set_show_hidden_files(is_showing_hidden); set_display_mode((DisplayMode)EditorSettings::get_singleton()->get("filesystem/file_dialog/display_mode").operator int()); // update icons @@ -140,7 +141,7 @@ void EditorFileDialog::_unhandled_input(const Ref<InputEvent> &p_event) { handled = true; } if (ED_IS_SHORTCUT("file_dialog/toggle_favorite", p_event)) { - _favorite_toggled(favorite->is_pressed()); + _favorite_pressed(); handled = true; } if (ED_IS_SHORTCUT("file_dialog/toggle_mode", p_event)) { @@ -231,6 +232,7 @@ void EditorFileDialog::_file_entered(const String &p_file) { } void EditorFileDialog::_save_confirm_pressed() { + String f = dir_access->get_current_dir().plus_file(file->get_text()); _save_to_recent(); hide(); @@ -717,20 +719,19 @@ void EditorFileDialog::update_file_list() { List<String> files; List<String> dirs; - bool isdir; - bool ishidden; - bool show_hidden = show_hidden_files; + bool is_dir; + bool is_hidden; String item; - while ((item = dir_access->get_next(&isdir)) != "") { + while ((item = dir_access->get_next(&is_dir)) != "") { if (item == "." || item == "..") continue; - ishidden = dir_access->current_is_hidden(); + is_hidden = dir_access->current_is_hidden(); - if (show_hidden || !ishidden) { - if (!isdir) + if (show_hidden_files || !is_hidden) { + if (!is_dir) files.push_back(item); else dirs.push_back(item); @@ -1130,6 +1131,7 @@ void EditorFileDialog::_update_drives() { } void EditorFileDialog::_favorite_selected(int p_idx) { + dir_access->change_dir(favorites->get_item_metadata(p_idx)); file->set_text(""); update_dir(); @@ -1210,7 +1212,7 @@ void EditorFileDialog::_update_favorites() { favorites->add_item(name, folder_icon); } else { - continue; // We don't handle favorite files here + continue; // We don't handle favorite files here. } favorites->set_item_metadata(favorites->get_item_count() - 1, favorited[i]); @@ -1218,11 +1220,12 @@ void EditorFileDialog::_update_favorites() { if (setthis) { favorite->set_pressed(true); favorites->set_current(favorites->get_item_count() - 1); + recent->unselect_all(); } } } -void EditorFileDialog::_favorite_toggled(bool p_toggle) { +void EditorFileDialog::_favorite_pressed() { bool res = access == ACCESS_RESOURCES; String cd = get_current_dir(); @@ -1253,12 +1256,6 @@ void EditorFileDialog::_favorite_toggled(bool p_toggle) { _update_favorites(); } -void EditorFileDialog::_favorite_pressed() { - - favorite->set_pressed(!favorite->is_pressed()); - _favorite_toggled(favorite->is_pressed()); -} - void EditorFileDialog::_recent_selected(int p_idx) { Vector<String> recentd = EditorSettings::get_singleton()->get_recent_dirs(); @@ -1381,7 +1378,6 @@ void EditorFileDialog::_bind_methods() { ClassDB::bind_method(D_METHOD("_go_forward"), &EditorFileDialog::_go_forward); ClassDB::bind_method(D_METHOD("_go_up"), &EditorFileDialog::_go_up); - ClassDB::bind_method(D_METHOD("_favorite_toggled"), &EditorFileDialog::_favorite_toggled); ClassDB::bind_method(D_METHOD("_favorite_pressed"), &EditorFileDialog::_favorite_pressed); ClassDB::bind_method(D_METHOD("_favorite_selected"), &EditorFileDialog::_favorite_selected); ClassDB::bind_method(D_METHOD("_favorite_move_up"), &EditorFileDialog::_favorite_move_up); @@ -1418,6 +1414,7 @@ void EditorFileDialog::_bind_methods() { void EditorFileDialog::set_show_hidden_files(bool p_show) { show_hidden_files = p_show; + show_hidden->set_pressed(p_show); invalidate(); } @@ -1523,17 +1520,23 @@ EditorFileDialog::EditorFileDialog() { pathhb->add_child(refresh); favorite = memnew(ToolButton); - favorite->set_flat(true); favorite->set_toggle_mode(true); favorite->set_tooltip(TTR("(Un)favorite current folder.")); favorite->connect("pressed", this, "_favorite_pressed"); pathhb->add_child(favorite); - Ref<ButtonGroup> view_mode_group; - view_mode_group.instance(); + show_hidden = memnew(ToolButton); + show_hidden->set_toggle_mode(true); + show_hidden->set_pressed(is_showing_hidden_files()); + show_hidden->set_tooltip(TTR("Toggle visibility of hidden files.")); + show_hidden->connect("toggled", this, "set_show_hidden_files"); + pathhb->add_child(show_hidden); pathhb->add_child(memnew(VSeparator)); + Ref<ButtonGroup> view_mode_group; + view_mode_group.instance(); + mode_thumbnails = memnew(ToolButton); mode_thumbnails->connect("pressed", this, "set_display_mode", varray(DISPLAY_THUMBNAILS)); mode_thumbnails->set_toggle_mode(true); @@ -1593,6 +1596,7 @@ EditorFileDialog::EditorFileDialog() { rec_vb->set_custom_minimum_size(Size2(150, 100) * EDSCALE); rec_vb->set_v_size_flags(SIZE_EXPAND_FILL); recent = memnew(ItemList); + recent->set_allow_reselect(true); rec_vb->add_margin_child(TTR("Recent:"), recent, true); recent->connect("item_selected", this, "_recent_selected"); @@ -1609,7 +1613,7 @@ EditorFileDialog::EditorFileDialog() { list_vb->add_child(memnew(Label(TTR("Directories & Files:")))); preview_hb->add_child(list_vb); - // Item (files and folders) list with context menu + // Item (files and folders) list with context menu. item_list = memnew(ItemList); item_list->set_v_size_flags(SIZE_EXPAND_FILL); @@ -1622,7 +1626,7 @@ EditorFileDialog::EditorFileDialog() { item_menu->connect("id_pressed", this, "_item_menu_id_pressed"); add_child(item_menu); - // Other stuff + // Other stuff. preview_vb = memnew(VBoxContainer); preview_hb->add_child(preview_vb); @@ -1641,7 +1645,7 @@ EditorFileDialog::EditorFileDialog() { filter = memnew(OptionButton); filter->set_stretch_ratio(3); filter->set_h_size_flags(SIZE_EXPAND_FILL); - filter->set_clip_text(true); // too many extensions overflow it + filter->set_clip_text(true); // Too many extensions overflow it. filename_hbc->add_child(filter); filename_hbc->set_h_size_flags(SIZE_EXPAND_FILL); item_vb->add_child(filename_hbc); diff --git a/editor/editor_file_dialog.h b/editor/editor_file_dialog.h index 529aaa71de..6578be8563 100644 --- a/editor/editor_file_dialog.h +++ b/editor/editor_file_dialog.h @@ -116,11 +116,13 @@ private: DirAccess *dir_access; ConfirmationDialog *confirm_save; DependencyRemoveDialog *remove_dialog; + ToolButton *mode_thumbnails; ToolButton *mode_list; ToolButton *refresh; ToolButton *favorite; + ToolButton *show_hidden; ToolButton *fav_up; ToolButton *fav_down; @@ -150,7 +152,6 @@ private: void update_filters(); void _update_favorites(); - void _favorite_toggled(bool p_toggle); void _favorite_pressed(); void _favorite_selected(int p_idx); void _favorite_move_up(); diff --git a/editor/editor_fonts.cpp b/editor/editor_fonts.cpp index cddabbc4e4..40ecffbb3b 100644 --- a/editor/editor_fonts.cpp +++ b/editor/editor_fonts.cpp @@ -204,9 +204,8 @@ void editor_register_fonts(Ref<Theme> p_theme) { dfmono->set_antialiased(font_source_antialiased); dfmono->set_hinting(font_source_hinting); dfmono->set_font_ptr(_font_Hack_Regular, _font_Hack_Regular_size); - //dfd->set_force_autohinter(true); //just looks better..i think? - int default_font_size = int(EditorSettings::get_singleton()->get("interface/editor/main_font_size")) * EDSCALE; + int default_font_size = int(EDITOR_GET("interface/editor/main_font_size")) * EDSCALE; // Default font MAKE_DEFAULT_FONT(df, default_font_size); @@ -220,15 +219,14 @@ void editor_register_fonts(Ref<Theme> p_theme) { MAKE_BOLD_FONT(df_title, default_font_size + 2 * EDSCALE); p_theme->set_font("title", "EditorFonts", df_title); - // Doc font - MAKE_BOLD_FONT(df_doc_title, int(EDITOR_DEF("text_editor/help/help_title_font_size", 23)) * EDSCALE); - - MAKE_DEFAULT_FONT(df_doc, int(EDITOR_DEF("text_editor/help/help_font_size", 15)) * EDSCALE); - + // Documentation fonts + MAKE_DEFAULT_FONT(df_doc, int(EDITOR_GET("text_editor/help/help_font_size")) * EDSCALE); + MAKE_BOLD_FONT(df_doc_bold, int(EDITOR_GET("text_editor/help/help_font_size")) * EDSCALE); + MAKE_BOLD_FONT(df_doc_title, int(EDITOR_GET("text_editor/help/help_title_font_size")) * EDSCALE); + MAKE_SOURCE_FONT(df_doc_code, int(EDITOR_GET("text_editor/help/help_source_font_size")) * EDSCALE); p_theme->set_font("doc", "EditorFonts", df_doc); + p_theme->set_font("doc_bold", "EditorFonts", df_doc_bold); p_theme->set_font("doc_title", "EditorFonts", df_doc_title); - - MAKE_SOURCE_FONT(df_doc_code, int(EDITOR_GET("text_editor/help/help_source_font_size")) * EDSCALE); p_theme->set_font("doc_source", "EditorFonts", df_doc_code); // Ruler font @@ -236,13 +234,13 @@ void editor_register_fonts(Ref<Theme> p_theme) { p_theme->set_font("rulers", "EditorFonts", df_rulers); // Code font - MAKE_SOURCE_FONT(df_code, int(EditorSettings::get_singleton()->get("interface/editor/code_font_size")) * EDSCALE); + MAKE_SOURCE_FONT(df_code, int(EDITOR_GET("interface/editor/code_font_size")) * EDSCALE); p_theme->set_font("source", "EditorFonts", df_code); - MAKE_SOURCE_FONT(df_expression, (int(EditorSettings::get_singleton()->get("interface/editor/code_font_size")) - 1) * EDSCALE); + MAKE_SOURCE_FONT(df_expression, (int(EDITOR_GET("interface/editor/code_font_size")) - 1) * EDSCALE); p_theme->set_font("expression", "EditorFonts", df_expression); - MAKE_SOURCE_FONT(df_output_code, int(EDITOR_DEF("run/output/font_size", 13)) * EDSCALE); + MAKE_SOURCE_FONT(df_output_code, int(EDITOR_GET("run/output/font_size")) * EDSCALE); p_theme->set_font("output_source", "EditorFonts", df_output_code); MAKE_SOURCE_FONT(df_text_editor_status_code, default_font_size); diff --git a/editor/editor_help.cpp b/editor/editor_help.cpp index df25b08b4c..26d793cf65 100644 --- a/editor/editor_help.cpp +++ b/editor/editor_help.cpp @@ -325,6 +325,7 @@ void EditorHelp::_update_doc() { DocData::ClassDoc cd = doc->class_list[edited_class]; //make a copy, so we can sort without worrying Ref<Font> doc_font = get_font("doc", "EditorFonts"); + Ref<Font> doc_bold_font = get_font("doc_bold", "EditorFonts"); Ref<Font> doc_title_font = get_font("doc_title", "EditorFonts"); Ref<Font> doc_code_font = get_font("doc_source", "EditorFonts"); String link_color_text = title_color.to_html(false); @@ -1132,6 +1133,7 @@ static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt) { String base_path; Ref<Font> doc_font = p_rt->get_font("doc", "EditorFonts"); + Ref<Font> doc_bold_font = p_rt->get_font("doc_bold", "EditorFonts"); Ref<Font> doc_code_font = p_rt->get_font("doc_source", "EditorFonts"); Color font_color_hl = p_rt->get_color("headline_color", "EditorHelp"); Color link_color = p_rt->get_color("accent_color", "Editor").linear_interpolate(font_color_hl, 0.8); @@ -1219,7 +1221,7 @@ static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt) { } else if (tag == "b") { //use bold font - p_rt->push_font(doc_code_font); + p_rt->push_font(doc_bold_font); pos = brk_end + 1; tag_stack.push_front(tag); } else if (tag == "i") { @@ -1237,13 +1239,13 @@ static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt) { tag_stack.push_front(tag); } else if (tag == "center") { - //use monospace font + //align to center p_rt->push_align(RichTextLabel::ALIGN_CENTER); pos = brk_end + 1; tag_stack.push_front(tag); } else if (tag == "br") { - //use monospace font + //force a line break p_rt->add_newline(); pos = brk_end + 1; } else if (tag == "u") { @@ -1254,14 +1256,13 @@ static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt) { tag_stack.push_front(tag); } else if (tag == "s") { - //use strikethrough (not supported underline instead) - p_rt->push_underline(); + //use strikethrough + p_rt->push_strikethrough(); pos = brk_end + 1; tag_stack.push_front(tag); } else if (tag == "url") { - //use strikethrough (not supported underline instead) int end = bbcode.find("[", brk_end); if (end == -1) end = bbcode.length(); @@ -1278,7 +1279,6 @@ static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt) { tag_stack.push_front("url"); } else if (tag == "img") { - //use strikethrough (not supported underline instead) int end = bbcode.find("[", brk_end); if (end == -1) end = bbcode.length(); diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 5fc7e71cca..79c312b7b1 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -5044,7 +5044,7 @@ void EditorNode::_feature_profile_changed() { main_editor_buttons[EDITOR_3D]->set_visible(!profile->is_feature_disabled(EditorFeatureProfile::FEATURE_3D)); main_editor_buttons[EDITOR_SCRIPT]->set_visible(!profile->is_feature_disabled(EditorFeatureProfile::FEATURE_SCRIPT)); main_editor_buttons[EDITOR_ASSETLIB]->set_visible(!profile->is_feature_disabled(EditorFeatureProfile::FEATURE_ASSET_LIB)); - if (profile->is_feature_disabled(EditorFeatureProfile::FEATURE_3D) || profile->is_feature_disabled(EditorFeatureProfile::FEATURE_ASSET_LIB) || profile->is_feature_disabled(EditorFeatureProfile::FEATURE_ASSET_LIB)) { + if (profile->is_feature_disabled(EditorFeatureProfile::FEATURE_3D) || profile->is_feature_disabled(EditorFeatureProfile::FEATURE_SCRIPT) || profile->is_feature_disabled(EditorFeatureProfile::FEATURE_ASSET_LIB)) { _editor_select(EDITOR_2D); } } else { diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp index 4050899ccc..58e3cc6fc1 100644 --- a/editor/editor_settings.cpp +++ b/editor/editor_settings.cpp @@ -320,19 +320,19 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) { _initial_set("interface/editor/custom_display_scale", 1.0f); hints["interface/editor/custom_display_scale"] = PropertyInfo(Variant::REAL, "interface/editor/custom_display_scale", PROPERTY_HINT_RANGE, "0.5,3,0.01", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED); _initial_set("interface/editor/main_font_size", 14); - hints["interface/editor/main_font_size"] = PropertyInfo(Variant::INT, "interface/editor/main_font_size", PROPERTY_HINT_RANGE, "10,40,1", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED); - _initial_set("interface/editor/code_font_size", 14); - hints["interface/editor/code_font_size"] = PropertyInfo(Variant::INT, "interface/editor/code_font_size", PROPERTY_HINT_RANGE, "8,96,1", PROPERTY_USAGE_DEFAULT); + hints["interface/editor/main_font_size"] = PropertyInfo(Variant::INT, "interface/editor/main_font_size", PROPERTY_HINT_RANGE, "8,48,1", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED); _initial_set("interface/editor/main_font_antialiased", true); - _initial_set("interface/editor/code_font_antialiased", true); _initial_set("interface/editor/main_font_hinting", 2); hints["interface/editor/main_font_hinting"] = PropertyInfo(Variant::INT, "interface/editor/main_font_hinting", PROPERTY_HINT_ENUM, "None,Light,Normal", PROPERTY_USAGE_DEFAULT); - _initial_set("interface/editor/code_font_hinting", 2); - hints["interface/editor/code_font_hinting"] = PropertyInfo(Variant::INT, "interface/editor/code_font_hinting", PROPERTY_HINT_ENUM, "None,Light,Normal", PROPERTY_USAGE_DEFAULT); _initial_set("interface/editor/main_font", ""); hints["interface/editor/main_font"] = PropertyInfo(Variant::STRING, "interface/editor/main_font", PROPERTY_HINT_GLOBAL_FILE, "*.ttf,*.otf", PROPERTY_USAGE_DEFAULT); _initial_set("interface/editor/main_font_bold", ""); hints["interface/editor/main_font_bold"] = PropertyInfo(Variant::STRING, "interface/editor/main_font_bold", PROPERTY_HINT_GLOBAL_FILE, "*.ttf,*.otf", PROPERTY_USAGE_DEFAULT); + _initial_set("interface/editor/code_font_size", 14); + hints["interface/editor/code_font_size"] = PropertyInfo(Variant::INT, "interface/editor/code_font_size", PROPERTY_HINT_RANGE, "8,48,1", PROPERTY_USAGE_DEFAULT); + _initial_set("interface/editor/code_font_antialiased", true); + _initial_set("interface/editor/code_font_hinting", 2); + hints["interface/editor/code_font_hinting"] = PropertyInfo(Variant::INT, "interface/editor/code_font_hinting", PROPERTY_HINT_ENUM, "None,Light,Normal", PROPERTY_USAGE_DEFAULT); _initial_set("interface/editor/code_font", ""); hints["interface/editor/code_font"] = PropertyInfo(Variant::STRING, "interface/editor/code_font", PROPERTY_HINT_GLOBAL_FILE, "*.ttf,*.otf", PROPERTY_USAGE_DEFAULT); _initial_set("interface/editor/dim_editor_on_dialog_popup", true); @@ -491,8 +491,12 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) { // Help _initial_set("text_editor/help/show_help_index", true); - _initial_set("text_editor/help_source_font_size", 14); - hints["text_editor/help/help_source_font_size"] = PropertyInfo(Variant::REAL, "text_editor/help/help_source_font_size", PROPERTY_HINT_RANGE, "10, 50, 1"); + _initial_set("text_editor/help/help_font_size", 15); + hints["text_editor/help/help_font_size"] = PropertyInfo(Variant::INT, "text_editor/help/help_font_size", PROPERTY_HINT_RANGE, "8,48,1"); + _initial_set("text_editor/help/help_source_font_size", 14); + hints["text_editor/help/help_source_font_size"] = PropertyInfo(Variant::INT, "text_editor/help/help_source_font_size", PROPERTY_HINT_RANGE, "8,48,1"); + _initial_set("text_editor/help/help_title_font_size", 23); + hints["text_editor/help/help_title_font_size"] = PropertyInfo(Variant::INT, "text_editor/help/help_title_font_size", PROPERTY_HINT_RANGE, "8,48,1"); /* Editors */ @@ -569,7 +573,7 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) { _initial_set("editors/2d/bone_outline_size", 2); _initial_set("editors/2d/viewport_border_color", Color(0.4, 0.4, 1.0, 0.4)); _initial_set("editors/2d/warped_mouse_panning", true); - _initial_set("editors/2d/simple_spacebar_panning", false); + _initial_set("editors/2d/simple_panning", false); _initial_set("editors/2d/scroll_to_pan", false); _initial_set("editors/2d/pan_speed", 20); @@ -600,7 +604,8 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) { _initial_set("run/auto_save/save_before_running", true); // Output - hints["run/output/font_size"] = PropertyInfo(Variant::INT, "run/output/font_size", PROPERTY_HINT_RANGE, "8,96,1", PROPERTY_USAGE_DEFAULT); + _initial_set("run/output/font_size", 13); + hints["run/output/font_size"] = PropertyInfo(Variant::INT, "run/output/font_size", PROPERTY_HINT_RANGE, "8,48,1"); _initial_set("run/output/always_clear_output_on_play", true); _initial_set("run/output/always_open_output_on_play", true); _initial_set("run/output/always_close_output_on_stop", false); @@ -699,6 +704,10 @@ bool EditorSettings::_save_text_editor_theme(String p_file) { return false; } +bool EditorSettings::_is_default_text_editor_theme(String p_theme_name) { + return p_theme_name == "default" || p_theme_name == "adaptive" || p_theme_name == "custom"; +} + static Dictionary _get_builtin_script_templates() { Dictionary templates; @@ -1291,7 +1300,7 @@ void EditorSettings::list_text_editor_themes() { d->list_dir_begin(); String file = d->get_next(); while (file != String()) { - if (file.get_extension() == "tet" && file.get_basename().to_lower() != "default" && file.get_basename().to_lower() != "adaptive" && file.get_basename().to_lower() != "custom") { + if (file.get_extension() == "tet" && !_is_default_text_editor_theme(file.get_basename().to_lower())) { custom_themes.push_back(file.get_basename()); } file = d->get_next(); @@ -1308,14 +1317,16 @@ void EditorSettings::list_text_editor_themes() { } void EditorSettings::load_text_editor_theme() { - if (get("text_editor/theme/color_theme") == "Default" || get("text_editor/theme/color_theme") == "Adaptive" || get("text_editor/theme/color_theme") == "Custom") { - if (get("text_editor/theme/color_theme") == "Default") { + String p_file = get("text_editor/theme/color_theme"); + + if (_is_default_text_editor_theme(p_file.get_file().to_lower())) { + if (p_file == "Default") { _load_default_text_editor_theme(); } return; // sorry for "Settings changed" console spam } - String theme_path = get_text_editor_themes_dir().plus_file((String)get("text_editor/theme/color_theme") + ".tet"); + String theme_path = get_text_editor_themes_dir().plus_file(p_file + ".tet"); Ref<ConfigFile> cf = memnew(ConfigFile); Error err = cf->load(theme_path); @@ -1367,7 +1378,7 @@ bool EditorSettings::save_text_editor_theme() { String p_file = get("text_editor/theme/color_theme"); - if (p_file.get_file().to_lower() == "default" || p_file.get_file().to_lower() == "adaptive" || p_file.get_file().to_lower() == "custom") { + if (_is_default_text_editor_theme(p_file.get_file().to_lower())) { return false; } String theme_path = get_text_editor_themes_dir().plus_file(p_file + ".tet"); @@ -1379,7 +1390,7 @@ bool EditorSettings::save_text_editor_theme_as(String p_file) { p_file += ".tet"; } - if (p_file.get_file().to_lower() == "default.tet" || p_file.get_file().to_lower() == "adaptive.tet" || p_file.get_file().to_lower() == "custom.tet") { + if (_is_default_text_editor_theme(p_file.get_file().to_lower().trim_suffix(".tet"))) { return false; } if (_save_text_editor_theme(p_file)) { @@ -1397,6 +1408,11 @@ bool EditorSettings::save_text_editor_theme_as(String p_file) { return false; } +bool EditorSettings::is_default_text_editor_theme() { + String p_file = get("text_editor/theme/color_theme"); + return _is_default_text_editor_theme(p_file.get_file().to_lower()); +} + Vector<String> EditorSettings::get_script_templates(const String &p_extension) { Vector<String> templates; diff --git a/editor/editor_settings.h b/editor/editor_settings.h index 43a8cbf739..2ee8dd805b 100644 --- a/editor/editor_settings.h +++ b/editor/editor_settings.h @@ -123,6 +123,7 @@ private: void _load_defaults(Ref<ConfigFile> p_extra_config = NULL); void _load_default_text_editor_theme(); bool _save_text_editor_theme(String p_file); + bool _is_default_text_editor_theme(String p_file); protected: static void _bind_methods(); @@ -187,6 +188,7 @@ public: bool import_text_editor_theme(String p_file); bool save_text_editor_theme(); bool save_text_editor_theme_as(String p_file); + bool is_default_text_editor_theme(); Vector<String> get_script_templates(const String &p_extension); String get_editor_layouts_config() const; diff --git a/editor/icons/icon_project_icon_loading.svg b/editor/icons/icon_project_icon_loading.svg new file mode 100644 index 0000000000..3802b67654 --- /dev/null +++ b/editor/icons/icon_project_icon_loading.svg @@ -0,0 +1 @@ +<svg height="64" viewBox="0 0 64 64" width="64" xmlns="http://www.w3.org/2000/svg"><path d="m8 0c-4.432 0-8 3.568-8 8v48c0 4.432 3.568 8 8 8h48c4.432 0 8-3.568 8-8v-48c0-4.432-3.568-8-8-8z" fill="#e0e0e0" fill-opacity=".188235"/></svg>
\ No newline at end of file diff --git a/editor/import/editor_scene_importer_gltf.cpp b/editor/import/editor_scene_importer_gltf.cpp index daa423e1d9..c97021433b 100644 --- a/editor/import/editor_scene_importer_gltf.cpp +++ b/editor/import/editor_scene_importer_gltf.cpp @@ -2090,22 +2090,23 @@ void EditorSceneImporterGLTF::_import_animation(GLTFState &state, AnimationPlaye animation->add_track(Animation::TYPE_VALUE); animation->track_set_path(track_idx, node_path); - if (track.weight_tracks[i].interpolation <= GLTFAnimation::INTERP_STEP) { - animation->track_set_interpolation_type(track_idx, track.weight_tracks[i].interpolation == GLTFAnimation::INTERP_STEP ? Animation::INTERPOLATION_NEAREST : Animation::INTERPOLATION_NEAREST); + // Only LINEAR and STEP (NEAREST) can be supported out of the box by Godot's Animation, + // the other modes have to be baked. + GLTFAnimation::Interpolation gltf_interp = track.weight_tracks[i].interpolation; + if (gltf_interp == GLTFAnimation::INTERP_LINEAR || gltf_interp == GLTFAnimation::INTERP_STEP) { + animation->track_set_interpolation_type(track_idx, gltf_interp == GLTFAnimation::INTERP_STEP ? Animation::INTERPOLATION_NEAREST : Animation::INTERPOLATION_LINEAR); for (int j = 0; j < track.weight_tracks[i].times.size(); j++) { float t = track.weight_tracks[i].times[j]; float w = track.weight_tracks[i].values[j]; animation->track_insert_key(track_idx, t, w); } } else { - //must bake, apologies. + // CATMULLROMSPLINE or CUBIC_SPLINE have to be baked, apologies. float increment = 1.0 / float(bake_fps); float time = 0.0; - bool last = false; while (true) { - - _interpolate_track<float>(track.weight_tracks[i].times, track.weight_tracks[i].values, time, track.weight_tracks[i].interpolation); + _interpolate_track<float>(track.weight_tracks[i].times, track.weight_tracks[i].values, time, gltf_interp); if (last) { break; } diff --git a/editor/plugins/asset_library_editor_plugin.cpp b/editor/plugins/asset_library_editor_plugin.cpp index a0774ac696..1503258ff5 100644 --- a/editor/plugins/asset_library_editor_plugin.cpp +++ b/editor/plugins/asset_library_editor_plugin.cpp @@ -35,7 +35,7 @@ #include "editor_node.h" #include "editor_settings.h" -void EditorAssetLibraryItem::configure(const String &p_title, int p_asset_id, const String &p_category, int p_category_id, const String &p_author, int p_author_id, int p_rating, const String &p_cost) { +void EditorAssetLibraryItem::configure(const String &p_title, int p_asset_id, const String &p_category, int p_category_id, const String &p_author, int p_author_id, const String &p_cost) { title->set_text(p_title); asset_id = p_asset_id; @@ -44,13 +44,6 @@ void EditorAssetLibraryItem::configure(const String &p_title, int p_asset_id, co author->set_text(p_author); author_id = p_author_id; price->set_text(p_cost); - - for (int i = 0; i < 5; i++) { - if (i < p_rating) - stars[i]->set_texture(get_icon("Favorites", "EditorIcons")); - else - stars[i]->set_texture(get_icon("NonFavorite", "EditorIcons")); - } } void EditorAssetLibraryItem::set_image(int p_type, int p_index, const Ref<Texture> &p_image) { @@ -65,9 +58,10 @@ void EditorAssetLibraryItem::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE) { - icon->set_normal_texture(get_icon("DefaultProjectIcon", "EditorIcons")); + icon->set_normal_texture(get_icon("ProjectIconLoading", "EditorIcons")); category->add_color_override("font_color", Color(0.5, 0.5, 0.5)); author->add_color_override("font_color", Color(0.5, 0.5, 0.5)); + price->add_color_override("font_color", Color(0.5, 0.5, 0.5)); } } @@ -100,17 +94,19 @@ EditorAssetLibraryItem::EditorAssetLibraryItem() { Ref<StyleBoxEmpty> border; border.instance(); - border->set_default_margin(MARGIN_LEFT, 5); - border->set_default_margin(MARGIN_RIGHT, 5); - border->set_default_margin(MARGIN_BOTTOM, 5); - border->set_default_margin(MARGIN_TOP, 5); + border->set_default_margin(MARGIN_LEFT, 5 * EDSCALE); + border->set_default_margin(MARGIN_RIGHT, 5 * EDSCALE); + border->set_default_margin(MARGIN_BOTTOM, 5 * EDSCALE); + border->set_default_margin(MARGIN_TOP, 5 * EDSCALE); add_style_override("panel", border); HBoxContainer *hb = memnew(HBoxContainer); + // Add some spacing to visually separate the icon from the asset details + hb->add_constant_override("separation", 15 * EDSCALE); add_child(hb); icon = memnew(TextureButton); - icon->set_custom_minimum_size(Size2(64, 64)); + icon->set_custom_minimum_size(Size2(64, 64) * EDSCALE); icon->set_default_cursor_shape(CURSOR_POINTING_HAND); icon->connect("pressed", this, "_asset_clicked"); @@ -139,18 +135,11 @@ EditorAssetLibraryItem::EditorAssetLibraryItem() { author->connect("pressed", this, "_author_clicked"); vb->add_child(author); - HBoxContainer *rating_hb = memnew(HBoxContainer); - vb->add_child(rating_hb); - - for (int i = 0; i < 5; i++) { - stars[i] = memnew(TextureRect); - rating_hb->add_child(stars[i]); - } price = memnew(Label); price->set_text(TTR("Free")); vb->add_child(price); - set_custom_minimum_size(Size2(250, 100)); + set_custom_minimum_size(Size2(250, 100) * EDSCALE); set_h_size_flags(SIZE_EXPAND_FILL); set_mouse_filter(MOUSE_FILTER_PASS); @@ -194,7 +183,6 @@ void EditorAssetLibraryItemDescription::set_image(int p_type, int p_index, const break; } } - //item->call("set_image",p_type,p_index,p_image); } break; case EditorAssetLibrary::IMAGE_QUEUE_SCREENSHOT: { @@ -207,7 +195,6 @@ void EditorAssetLibraryItemDescription::set_image(int p_type, int p_index, const break; } } - //item->call("set_image",p_type,p_index,p_image); } break; } } @@ -248,13 +235,13 @@ void EditorAssetLibraryItemDescription::_preview_click(int p_id) { } } -void EditorAssetLibraryItemDescription::configure(const String &p_title, int p_asset_id, const String &p_category, int p_category_id, const String &p_author, int p_author_id, int p_rating, const String &p_cost, int p_version, const String &p_version_string, const String &p_description, const String &p_download_url, const String &p_browse_url, const String &p_sha256_hash) { +void EditorAssetLibraryItemDescription::configure(const String &p_title, int p_asset_id, const String &p_category, int p_category_id, const String &p_author, int p_author_id, const String &p_cost, int p_version, const String &p_version_string, const String &p_description, const String &p_download_url, const String &p_browse_url, const String &p_sha256_hash) { asset_id = p_asset_id; title = p_title; download_url = p_download_url; sha256 = p_sha256_hash; - item->configure(p_title, p_asset_id, p_category, p_category_id, p_author, p_author_id, p_rating, p_cost); + item->configure(p_title, p_asset_id, p_category, p_category_id, p_author, p_author_id, p_cost); description->clear(); description->add_text(TTR("Version:") + " " + p_version_string + "\n"); description->add_text(TTR("Contents:") + " "); @@ -554,7 +541,7 @@ EditorAssetLibraryItemDownload::EditorAssetLibraryItemDownload() { hb2->add_child(retry); hb2->add_child(install); - set_custom_minimum_size(Size2(310, 0)); + set_custom_minimum_size(Size2(310, 0) * EDSCALE); download = memnew(HTTPRequest); add_child(download); @@ -666,7 +653,6 @@ void EditorAssetLibrary::_install_asset() { } const char *EditorAssetLibrary::sort_key[SORT_MAX] = { - "rating", "downloads", "name", "cost", @@ -674,10 +660,9 @@ const char *EditorAssetLibrary::sort_key[SORT_MAX] = { }; const char *EditorAssetLibrary::sort_text[SORT_MAX] = { - "Rating", "Downloads", "Name", - "Cost", + "License", // "cost" stores the SPDX license name in the Godot Asset Library "Updated" }; @@ -988,7 +973,7 @@ HBoxContainer *EditorAssetLibrary::_make_pages(int p_page, int p_page_count, int to = p_page_count; hbc->add_spacer(); - hbc->add_constant_override("separation", 5); + hbc->add_constant_override("separation", 5 * EDSCALE); Button *first = memnew(Button); first->set_text(TTR("First")); @@ -1194,8 +1179,8 @@ void EditorAssetLibrary::_http_request_completed(int p_status, int p_code, const asset_items = memnew(GridContainer); asset_items->set_columns(2); - asset_items->add_constant_override("hseparation", 10); - asset_items->add_constant_override("vseparation", 10); + asset_items->add_constant_override("hseparation", 10 * EDSCALE); + asset_items->add_constant_override("vseparation", 10 * EDSCALE); library_vb->add_child(asset_items); @@ -1212,12 +1197,11 @@ void EditorAssetLibrary::_http_request_completed(int p_status, int p_code, const ERR_CONTINUE(!r.has("author_id")); ERR_CONTINUE(!r.has("category_id")); ERR_FAIL_COND(!category_map.has(r["category_id"])); - ERR_CONTINUE(!r.has("rating")); ERR_CONTINUE(!r.has("cost")); EditorAssetLibraryItem *item = memnew(EditorAssetLibraryItem); asset_items->add_child(item); - item->configure(r["title"], r["asset_id"], category_map[r["category_id"]], r["category_id"], r["author"], r["author_id"], r["rating"], r["cost"]); + item->configure(r["title"], r["asset_id"], category_map[r["category_id"]], r["category_id"], r["author"], r["author_id"], r["cost"]); item->connect("asset_selected", this, "_select_asset"); item->connect("author_selected", this, "_select_author"); item->connect("category_selected", this, "_select_category"); @@ -1238,7 +1222,6 @@ void EditorAssetLibrary::_http_request_completed(int p_status, int p_code, const ERR_FAIL_COND(!r.has("version_string")); ERR_FAIL_COND(!r.has("category_id")); ERR_FAIL_COND(!category_map.has(r["category_id"])); - ERR_FAIL_COND(!r.has("rating")); ERR_FAIL_COND(!r.has("cost")); ERR_FAIL_COND(!r.has("description")); ERR_FAIL_COND(!r.has("download_url")); @@ -1254,7 +1237,7 @@ void EditorAssetLibrary::_http_request_completed(int p_status, int p_code, const description->popup_centered_minsize(); description->connect("confirmed", this, "_install_asset"); - description->configure(r["title"], r["asset_id"], category_map[r["category_id"]], r["category_id"], r["author"], r["author_id"], r["rating"], r["cost"], r["version"], r["version_string"], r["description"], r["download_url"], r["browse_url"], r["download_hash"]); + description->configure(r["title"], r["asset_id"], category_map[r["category_id"]], r["category_id"], r["author"], r["author_id"], r["cost"], r["version"], r["version_string"], r["description"], r["download_url"], r["browse_url"], r["download_hash"]); /*item->connect("asset_selected",this,"_select_asset"); item->connect("author_selected",this,"_select_author"); item->connect("category_selected",this,"_category_selected");*/ @@ -1361,7 +1344,7 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) { HBoxContainer *search_hb = memnew(HBoxContainer); library_main->add_child(search_hb); - library_main->add_constant_override("separation", 10); + library_main->add_constant_override("separation", 10 * EDSCALE); search_hb->add_child(memnew(Label(TTR("Search:") + " "))); filter = memnew(LineEdit); @@ -1463,10 +1446,10 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) { Ref<StyleBoxEmpty> border2; border2.instance(); - border2->set_default_margin(MARGIN_LEFT, 15); - border2->set_default_margin(MARGIN_RIGHT, 35); - border2->set_default_margin(MARGIN_BOTTOM, 15); - border2->set_default_margin(MARGIN_TOP, 15); + border2->set_default_margin(MARGIN_LEFT, 15 * EDSCALE); + border2->set_default_margin(MARGIN_RIGHT, 35 * EDSCALE); + border2->set_default_margin(MARGIN_BOTTOM, 15 * EDSCALE); + border2->set_default_margin(MARGIN_TOP, 15 * EDSCALE); PanelContainer *library_vb_border = memnew(PanelContainer); library_scroll->add_child(library_vb_border); @@ -1478,15 +1461,14 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) { library_vb->set_h_size_flags(SIZE_EXPAND_FILL); library_vb_border->add_child(library_vb); - //margin_panel->set_stop_mouse(false); asset_top_page = memnew(HBoxContainer); library_vb->add_child(asset_top_page); asset_items = memnew(GridContainer); asset_items->set_columns(2); - asset_items->add_constant_override("hseparation", 10); - asset_items->add_constant_override("vseparation", 10); + asset_items->add_constant_override("hseparation", 10 * EDSCALE); + asset_items->add_constant_override("vseparation", 10 * EDSCALE); library_vb->add_child(asset_items); @@ -1500,7 +1482,7 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) { last_queue_id = 0; - library_vb->add_constant_override("separation", 20); + library_vb->add_constant_override("separation", 20 * EDSCALE); load_status = memnew(ProgressBar); load_status->set_min(0); diff --git a/editor/plugins/asset_library_editor_plugin.h b/editor/plugins/asset_library_editor_plugin.h index dd5f3c2077..81288ae831 100644 --- a/editor/plugins/asset_library_editor_plugin.h +++ b/editor/plugins/asset_library_editor_plugin.h @@ -77,7 +77,7 @@ protected: static void _bind_methods(); public: - void configure(const String &p_title, int p_asset_id, const String &p_category, int p_category_id, const String &p_author, int p_author_id, int p_rating, const String &p_cost); + void configure(const String &p_title, int p_asset_id, const String &p_category, int p_category_id, const String &p_author, int p_author_id, const String &p_cost); EditorAssetLibraryItem(); }; @@ -120,7 +120,7 @@ protected: static void _bind_methods(); public: - void configure(const String &p_title, int p_asset_id, const String &p_category, int p_category_id, const String &p_author, int p_author_id, int p_rating, const String &p_cost, int p_version, const String &p_version_string, const String &p_description, const String &p_download_url, const String &p_browse_url, const String &p_sha256_hash); + void configure(const String &p_title, int p_asset_id, const String &p_category, int p_category_id, const String &p_author, int p_author_id, const String &p_cost, int p_version, const String &p_version_string, const String &p_description, const String &p_download_url, const String &p_browse_url, const String &p_sha256_hash); void add_preview(int p_id, bool p_video, const String &p_url); String get_title() { return title; } @@ -216,7 +216,6 @@ class EditorAssetLibrary : public PanelContainer { }; enum SortOrder { - SORT_RATING, SORT_DOWNLOADS, SORT_NAME, SORT_COST, diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index e8ef689ca3..fbf01a9405 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -1081,7 +1081,7 @@ bool CanvasItemEditor::_gui_input_zoom_or_pan(const Ref<InputEvent> &p_event) { if (b->is_pressed() && (b->get_button_index() == BUTTON_MIDDLE || (b->get_button_index() == BUTTON_LEFT && tool == TOOL_PAN) || - (b->get_button_index() == BUTTON_LEFT && !EditorSettings::get_singleton()->get("editors/2d/simple_spacebar_panning") && Input::get_singleton()->is_key_pressed(KEY_SPACE)))) { + (b->get_button_index() == BUTTON_LEFT && !EditorSettings::get_singleton()->get("editors/2d/simple_panning") && pan_pressed))) { // Pan the viewport panning = true; } @@ -1097,7 +1097,9 @@ bool CanvasItemEditor::_gui_input_zoom_or_pan(const Ref<InputEvent> &p_event) { Ref<InputEventKey> k = p_event; if (k.is_valid()) { - if (k->get_scancode() == KEY_SPACE && (EditorSettings::get_singleton()->get("editors/2d/simple_spacebar_panning") || drag_type != DRAG_NONE)) { + bool is_pan_key = pan_view_shortcut.is_valid() && pan_view_shortcut->is_shortcut(p_event); + + if (is_pan_key && (EditorSettings::get_singleton()->get("editors/2d/simple_panning") || drag_type != DRAG_NONE)) { if (!panning) { if (k->is_pressed() && !k->is_echo()) { //Pan the viewport @@ -1110,6 +1112,9 @@ bool CanvasItemEditor::_gui_input_zoom_or_pan(const Ref<InputEvent> &p_event) { } } } + + if (is_pan_key) + pan_pressed = k->is_pressed(); } Ref<InputEventMouseMotion> m = p_event; @@ -2214,7 +2219,7 @@ bool CanvasItemEditor::_gui_input_hover(const Ref<InputEvent> &p_event) { void CanvasItemEditor::_gui_input_viewport(const Ref<InputEvent> &p_event) { bool accepted = false; - if (EditorSettings::get_singleton()->get("editors/2d/simple_spacebar_panning") || !Input::get_singleton()->is_key_pressed(KEY_SPACE)) { + if (EditorSettings::get_singleton()->get("editors/2d/simple_panning") || !pan_pressed) { if ((accepted = _gui_input_rulers_and_guides(p_event))) { //printf("Rulers and guides\n"); } else if ((accepted = editor->get_editor_plugins_over()->forward_gui_input(p_event))) { @@ -4780,6 +4785,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) { dragged_guide_pos = Point2(); dragged_guide_index = -1; panning = false; + pan_pressed = false; bone_last_frame = 0; @@ -5129,6 +5135,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) { multiply_grid_step_shortcut = ED_SHORTCUT("canvas_item_editor/multiply_grid_step", TTR("Multiply grid step by 2"), KEY_KP_MULTIPLY); divide_grid_step_shortcut = ED_SHORTCUT("canvas_item_editor/divide_grid_step", TTR("Divide grid step by 2"), KEY_KP_DIVIDE); + pan_view_shortcut = ED_SHORTCUT("canvas_item_editor/pan_view", TTR("Pan View"), KEY_SPACE); skeleton_menu->get_popup()->set_item_checked(skeleton_menu->get_popup()->get_item_index(SKELETON_SHOW_BONES), true); singleton = this; diff --git a/editor/plugins/canvas_item_editor_plugin.h b/editor/plugins/canvas_item_editor_plugin.h index e098d261c0..ff221eb758 100644 --- a/editor/plugins/canvas_item_editor_plugin.h +++ b/editor/plugins/canvas_item_editor_plugin.h @@ -265,6 +265,7 @@ private: bool key_rot; bool key_scale; bool panning; + bool pan_pressed; MenuOption last_option; @@ -383,6 +384,7 @@ private: Ref<ShortCut> set_pivot_shortcut; Ref<ShortCut> multiply_grid_step_shortcut; Ref<ShortCut> divide_grid_step_shortcut; + Ref<ShortCut> pan_view_shortcut; bool _is_node_locked(const Node *p_node); bool _is_node_movable(const Node *p_node, bool p_popup_warning = false); diff --git a/editor/plugins/editor_preview_plugins.cpp b/editor/plugins/editor_preview_plugins.cpp index 28e57ac48a..285823d95a 100644 --- a/editor/plugins/editor_preview_plugins.cpp +++ b/editor/plugins/editor_preview_plugins.cpp @@ -643,7 +643,7 @@ Ref<Texture> EditorAudioStreamPreviewPlugin::generate(const RES &p_from, const S float max = -1000; float min = 1000; int from = uint64_t(i) * frame_length / w; - int to = uint64_t(i + 1) * frame_length / w; + int to = (uint64_t(i) + 1) * frame_length / w; to = MIN(to, frame_length); from = MIN(from, frame_length - 1); if (to == from) { diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index f45e6a2c9a..7456c5d016 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -1311,23 +1311,29 @@ void ScriptEditor::_theme_option(int p_option) { EditorSettings::get_singleton()->load_text_editor_theme(); } break; case THEME_SAVE: { - if (!EditorSettings::get_singleton()->save_text_editor_theme()) { + if (EditorSettings::get_singleton()->is_default_text_editor_theme()) { + ScriptEditor::_show_save_theme_as_dialog(); + } else if (!EditorSettings::get_singleton()->save_text_editor_theme()) { editor->show_warning(TTR("Error while saving theme"), TTR("Error saving")); } } break; case THEME_SAVE_AS: { - file_dialog->set_mode(EditorFileDialog::MODE_SAVE_FILE); - file_dialog->set_access(EditorFileDialog::ACCESS_FILESYSTEM); - file_dialog_option = THEME_SAVE_AS; - file_dialog->clear_filters(); - file_dialog->add_filter("*.tet"); - file_dialog->set_current_path(EditorSettings::get_singleton()->get_text_editor_themes_dir().plus_file(EditorSettings::get_singleton()->get("text_editor/theme/color_theme"))); - file_dialog->popup_centered_ratio(); - file_dialog->set_title(TTR("Save Theme As...")); + ScriptEditor::_show_save_theme_as_dialog(); } break; } } +void ScriptEditor::_show_save_theme_as_dialog() { + file_dialog->set_mode(EditorFileDialog::MODE_SAVE_FILE); + file_dialog->set_access(EditorFileDialog::ACCESS_FILESYSTEM); + file_dialog_option = THEME_SAVE_AS; + file_dialog->clear_filters(); + file_dialog->add_filter("*.tet"); + file_dialog->set_current_path(EditorSettings::get_singleton()->get_text_editor_themes_dir().plus_file(EditorSettings::get_singleton()->get("text_editor/theme/color_theme"))); + file_dialog->popup_centered_ratio(); + file_dialog->set_title(TTR("Save Theme As...")); +} + void ScriptEditor::_tab_changed(int p_which) { ensure_select_current(); @@ -1976,10 +1982,11 @@ bool ScriptEditor::edit(const RES &p_resource, int p_line, int p_col, bool p_gra String flags = EditorSettings::get_singleton()->get("text_editor/external/exec_flags"); List<String> args; + bool has_file_flag = false; + String script_path = ProjectSettings::get_singleton()->globalize_path(p_resource->get_path()); if (flags.size()) { String project_path = ProjectSettings::get_singleton()->get_resource_path(); - String script_path = ProjectSettings::get_singleton()->globalize_path(p_resource->get_path()); flags = flags.replacen("{line}", itos(p_line > 0 ? p_line : 0)); flags = flags.replacen("{col}", itos(p_col)); @@ -2001,6 +2008,9 @@ bool ScriptEditor::edit(const RES &p_resource, int p_line, int p_col, bool p_gra } else if (flags[i] == '\0' || (!inside_quotes && flags[i] == ' ')) { String arg = flags.substr(from, num_chars); + if (arg.find("{file}") != -1) { + has_file_flag = true; + } // do path replacement here, else there will be issues with spaces and quotes arg = arg.replacen("{project}", project_path); @@ -2015,6 +2025,11 @@ bool ScriptEditor::edit(const RES &p_resource, int p_line, int p_col, bool p_gra } } + // Default to passing script path if no {file} flag is specified. + if (!has_file_flag) { + args.push_back(script_path); + } + Error err = OS::get_singleton()->execute(path, args, false); if (err == OK) return false; @@ -3437,7 +3452,8 @@ ScriptEditorPlugin::ScriptEditorPlugin(EditorNode *p_node) { EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::INT, "text_editor/open_scripts/list_script_names_as", PROPERTY_HINT_ENUM, "Name,Parent Directory And Name,Full Path")); EDITOR_DEF("text_editor/open_scripts/list_script_names_as", 0); EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::STRING, "text_editor/external/exec_path", PROPERTY_HINT_GLOBAL_FILE)); - EDITOR_DEF("text_editor/external/exec_flags", ""); + EDITOR_DEF("text_editor/external/exec_flags", "{file}"); + EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::STRING, "text_editor/external/exec_flags", PROPERTY_HINT_PLACEHOLDER_TEXT, "Call flags with placeholders: {project}, {file}, {col}, {line}.")); ED_SHORTCUT("script_editor/open_recent", TTR("Open Recent"), KEY_MASK_CMD | KEY_MASK_SHIFT | KEY_T); ED_SHORTCUT("script_editor/clear_recent", TTR("Clear Recent Files")); diff --git a/editor/plugins/script_editor_plugin.h b/editor/plugins/script_editor_plugin.h index fae98d6ec8..7cd347e2d0 100644 --- a/editor/plugins/script_editor_plugin.h +++ b/editor/plugins/script_editor_plugin.h @@ -264,6 +264,7 @@ class ScriptEditor : public PanelContainer { void _tab_changed(int p_which); void _menu_option(int p_option); void _theme_option(int p_option); + void _show_save_theme_as_dialog(); Tree *disk_changed_list; ConfirmationDialog *disk_changed; diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp index 79867f40ca..c7a438948d 100644 --- a/editor/plugins/script_text_editor.cpp +++ b/editor/plugins/script_text_editor.cpp @@ -547,7 +547,6 @@ void ScriptTextEditor::_validate_script() { script->set_source_code(text); script->update_exports(); _update_member_keywords(); - //script->reload(); //will update all the variables in property editors } functions.clear(); @@ -558,30 +557,36 @@ void ScriptTextEditor::_validate_script() { } _update_connected_methods(); - code_editor->set_warning_nb(missing_connections.size() + warnings.size()); + int warning_nb = warnings.size(); warnings_panel->clear(); - // add missing connections - Node *base = get_tree()->get_edited_scene_root(); - if (base && missing_connections.size() > 0) { - warnings_panel->push_table(1); - for (List<Connection>::Element *E = missing_connections.front(); E; E = E->next()) { - Connection connection = E->get(); - - String base_path = base->get_name(); - String source_path = base == connection.source ? base_path : base_path + "/" + String(base->get_path_to(Object::cast_to<Node>(connection.source))); - String target_path = base == connection.target ? base_path : base_path + "/" + String(base->get_path_to(Object::cast_to<Node>(connection.target))); + // Add missing connections. + if (GLOBAL_GET("debug/gdscript/warnings/enable").booleanize()) { + Node *base = get_tree()->get_edited_scene_root(); + if (base && missing_connections.size() > 0) { + warnings_panel->push_table(1); + for (List<Connection>::Element *E = missing_connections.front(); E; E = E->next()) { + Connection connection = E->get(); + + String base_path = base->get_name(); + String source_path = base == connection.source ? base_path : base_path + "/" + String(base->get_path_to(Object::cast_to<Node>(connection.source))); + String target_path = base == connection.target ? base_path : base_path + "/" + String(base->get_path_to(Object::cast_to<Node>(connection.target))); + + warnings_panel->push_cell(); + warnings_panel->push_color(warnings_panel->get_color("warning_color", "Editor")); + warnings_panel->add_text(vformat(TTR("Missing connected method '%s' for signal '%s' from node '%s' to node '%s'."), connection.method, connection.signal, source_path, target_path)); + warnings_panel->pop(); // Color. + warnings_panel->pop(); // Cell. + } + warnings_panel->pop(); // Table. - warnings_panel->push_cell(); - warnings_panel->push_color(warnings_panel->get_color("warning_color", "Editor")); - warnings_panel->add_text(vformat(TTR("Missing connected method '%s' for signal '%s' from node '%s' to node '%s'"), connection.method, connection.signal, source_path, target_path)); - warnings_panel->pop(); // Color - warnings_panel->pop(); // Cell + warning_nb += missing_connections.size(); } - warnings_panel->pop(); // Table } - // add script warnings + code_editor->set_warning_nb(warning_nb); + + // Add script warnings. warnings_panel->push_table(3); for (List<ScriptLanguage::Warning>::Element *E = warnings.front(); E; E = E->next()) { ScriptLanguage::Warning w = E->get(); @@ -591,13 +596,13 @@ void ScriptTextEditor::_validate_script() { warnings_panel->push_color(warnings_panel->get_color("warning_color", "Editor")); warnings_panel->add_text(TTR("Line") + " " + itos(w.line)); warnings_panel->add_text(" (" + w.string_code + "):"); - warnings_panel->pop(); // Color - warnings_panel->pop(); // Meta goto - warnings_panel->pop(); // Cell + warnings_panel->pop(); // Color. + warnings_panel->pop(); // Meta goto. + warnings_panel->pop(); // Cell. warnings_panel->push_cell(); warnings_panel->add_text(w.message); - warnings_panel->pop(); // Cell + warnings_panel->pop(); // Cell. Dictionary ignore_meta; ignore_meta["line"] = w.line; @@ -605,11 +610,10 @@ void ScriptTextEditor::_validate_script() { warnings_panel->push_cell(); warnings_panel->push_meta(ignore_meta); warnings_panel->add_text(TTR("(ignore)")); - warnings_panel->pop(); // Meta ignore - warnings_panel->pop(); // Cell - //warnings_panel->add_newline(); + warnings_panel->pop(); // Meta ignore. + warnings_panel->pop(); // Cell. } - warnings_panel->pop(); // Table + warnings_panel->pop(); // Table. line--; bool highlight_safe = EDITOR_DEF("text_editor/highlighting/highlight_type_safe_lines", true); @@ -872,12 +876,36 @@ void ScriptTextEditor::_update_connected_methods() { continue; } - int line = script->get_language()->find_function(connection.method, text_edit->get_text()); - if (line < 0) { - missing_connections.push_back(connection); + // As deleted nodes are still accessible via the undo/redo system, check if they're still on the tree. + Node *source = Object::cast_to<Node>(connection.source); + if (source && !source->is_inside_tree()) { continue; } - text_edit->set_line_info_icon(line - 1, get_parent_control()->get_icon("Slot", "EditorIcons"), connection.method); + + if (!ClassDB::has_method(script->get_instance_base_type(), connection.method)) { + + int line = script->get_language()->find_function(connection.method, text_edit->get_text()); + if (line < 0) { + // There is a chance that the method is inherited from another script. + bool found_inherited_function = false; + Ref<Script> inherited_script = script->get_base_script(); + while (!inherited_script.is_null()) { + line = inherited_script->get_language()->find_function(connection.method, inherited_script->get_source_code()); + if (line != -1) { + found_inherited_function = true; + break; + } + + inherited_script = inherited_script->get_base_script(); + } + + if (!found_inherited_function) { + missing_connections.push_back(connection); + } + } else { + text_edit->set_line_info_icon(line - 1, get_parent_control()->get_icon("Slot", "EditorIcons"), connection.method); + } + } } } } diff --git a/editor/plugins/shader_editor_plugin.cpp b/editor/plugins/shader_editor_plugin.cpp index a795405dfc..f9ca38b919 100644 --- a/editor/plugins/shader_editor_plugin.cpp +++ b/editor/plugins/shader_editor_plugin.cpp @@ -60,6 +60,26 @@ void ShaderTextEditor::set_edited_shader(const Ref<Shader> &p_shader) { _line_col_changed(); } +void ShaderTextEditor::reload_text() { + ERR_FAIL_COND(shader.is_null()); + + TextEdit *te = get_text_edit(); + int column = te->cursor_get_column(); + int row = te->cursor_get_line(); + int h = te->get_h_scroll(); + int v = te->get_v_scroll(); + + te->set_text(shader->get_code()); + te->cursor_set_line(row); + te->cursor_set_column(column); + te->set_h_scroll(h); + te->set_v_scroll(v); + + te->tag_saved_version(); + + update_line_and_column(); +} + void ShaderTextEditor::_load_theme_settings() { get_text_edit()->clear_colors(); @@ -330,9 +350,8 @@ void ShaderEditor::_menu_option(int p_option) { void ShaderEditor::_notification(int p_what) { - if (p_what == NOTIFICATION_VISIBILITY_CHANGED) { - //if (is_visible_in_tree()) - // shader_editor->get_text_edit()->grab_focus(); + if (p_what == MainLoop::NOTIFICATION_WM_FOCUS_IN) { + _check_for_external_edit(); } } @@ -363,12 +382,14 @@ void ShaderEditor::_editor_settings_changed() { void ShaderEditor::_bind_methods() { + ClassDB::bind_method("_reload_shader_from_disk", &ShaderEditor::_reload_shader_from_disk); ClassDB::bind_method("_editor_settings_changed", &ShaderEditor::_editor_settings_changed); ClassDB::bind_method("_text_edit_gui_input", &ShaderEditor::_text_edit_gui_input); ClassDB::bind_method("_menu_option", &ShaderEditor::_menu_option); ClassDB::bind_method("_params_changed", &ShaderEditor::_params_changed); ClassDB::bind_method("apply_shaders", &ShaderEditor::apply_shaders); + ClassDB::bind_method("save_external_data", &ShaderEditor::save_external_data); } void ShaderEditor::ensure_select_current() { @@ -389,6 +410,37 @@ void ShaderEditor::goto_line_selection(int p_line, int p_begin, int p_end) { shader_editor->goto_line_selection(p_line, p_begin, p_end); } +void ShaderEditor::_check_for_external_edit() { + + if (shader.is_null() || !shader.is_valid()) { + return; + } + + // internal shader. + if (shader->get_path() == "" || shader->get_path().find("local://") != -1 || shader->get_path().find("::") != -1) { + return; + } + + bool use_autoreload = bool(EDITOR_DEF("text_editor/files/auto_reload_scripts_on_external_change", false)); + if (shader->get_last_modified_time() != FileAccess::get_modified_time(shader->get_path())) { + if (use_autoreload) { + _reload_shader_from_disk(); + } else { + disk_changed->call_deferred("popup_centered"); + } + } +} + +void ShaderEditor::_reload_shader_from_disk() { + + Ref<Shader> rel_shader = ResourceLoader::load(shader->get_path(), shader->get_class(), true); + ERR_FAIL_COND(!rel_shader.is_valid()); + + shader->set_code(rel_shader->get_code()); + shader->set_last_modified_time(rel_shader->get_last_modified_time()); + shader_editor->reload_text(); +} + void ShaderEditor::edit(const Ref<Shader> &p_shader) { if (p_shader.is_null() || !p_shader->is_text_shader()) @@ -405,16 +457,20 @@ void ShaderEditor::edit(const Ref<Shader> &p_shader) { // see if already has it } -void ShaderEditor::save_external_data() { +void ShaderEditor::save_external_data(const String &p_str) { - if (shader.is_null()) + if (shader.is_null()) { + disk_changed->hide(); return; - apply_shaders(); + } + apply_shaders(); if (shader->get_path() != "" && shader->get_path().find("local://") == -1 && shader->get_path().find("::") == -1) { //external shader, save it ResourceSaver::save(shader->get_path(), shader); } + + disk_changed->hide(); } void ShaderEditor::apply_shaders() { @@ -573,6 +629,23 @@ ShaderEditor::ShaderEditor(EditorNode *p_node) { goto_line_dialog = memnew(GotoLineDialog); add_child(goto_line_dialog); + disk_changed = memnew(ConfirmationDialog); + + VBoxContainer *vbc = memnew(VBoxContainer); + disk_changed->add_child(vbc); + + Label *dl = memnew(Label); + dl->set_text(TTR("This shader has been modified on on disk.\nWhat action should be taken?")); + vbc->add_child(dl); + + disk_changed->connect("confirmed", this, "_reload_shader_from_disk"); + disk_changed->get_ok()->set_text(TTR("Reload")); + + disk_changed->add_button(TTR("Resave"), !OS::get_singleton()->get_swap_ok_cancel(), "resave"); + disk_changed->connect("custom_action", this, "save_external_data"); + + add_child(disk_changed); + _editor_settings_changed(); } diff --git a/editor/plugins/shader_editor_plugin.h b/editor/plugins/shader_editor_plugin.h index 28ac9faaa5..b56c1451ad 100644 --- a/editor/plugins/shader_editor_plugin.h +++ b/editor/plugins/shader_editor_plugin.h @@ -58,6 +58,8 @@ protected: public: virtual void _validate_script(); + void reload_text(); + Ref<Shader> get_edited_shader() const; void set_edited_shader(const Ref<Shader> &p_shader); ShaderTextEditor(); @@ -103,6 +105,7 @@ class ShaderEditor : public PanelContainer { GotoLineDialog *goto_line_dialog; ConfirmationDialog *erase_tab_confirm; + ConfirmationDialog *disk_changed; ShaderTextEditor *shader_editor; @@ -112,6 +115,9 @@ class ShaderEditor : public PanelContainer { void _editor_settings_changed(); + void _check_for_external_edit(); + void _reload_shader_from_disk(); + protected: void _notification(int p_what); static void _bind_methods(); @@ -127,7 +133,7 @@ public: void goto_line_selection(int p_line, int p_begin, int p_end); virtual Size2 get_minimum_size() const { return Size2(0, 200); } - void save_external_data(); + void save_external_data(const String &p_str = ""); ShaderEditor(EditorNode *p_node); }; diff --git a/editor/plugins/tile_map_editor_plugin.cpp b/editor/plugins/tile_map_editor_plugin.cpp index 5e1d818ce9..16f93b8fd3 100644 --- a/editor/plugins/tile_map_editor_plugin.cpp +++ b/editor/plugins/tile_map_editor_plugin.cpp @@ -572,23 +572,25 @@ void TileMapEditor::_pick_tile(const Point2 &p_pos) { if (id == TileMap::INVALID_CELL) return; - if (search_box->get_text().strip_edges() != "") { - + if (search_box->get_text() != "") { search_box->set_text(""); _update_palette(); } - Vector<int> selected; - - selected.push_back(id); - set_selected_tiles(selected); - flip_h = node->is_cell_x_flipped(p_pos.x, p_pos.y); flip_v = node->is_cell_y_flipped(p_pos.x, p_pos.y); transpose = node->is_cell_transposed(p_pos.x, p_pos.y); autotile_coord = node->get_cell_autotile_coord(p_pos.x, p_pos.y); + Vector<int> selected; + selected.push_back(id); + set_selected_tiles(selected); _update_palette(); + + if ((manual_autotile && node->get_tileset()->tile_get_tile_mode(id) == TileSet::AUTO_TILE) || (!priority_atlastile && node->get_tileset()->tile_get_tile_mode(id) == TileSet::ATLAS_TILE)) { + manual_palette->select(manual_palette->find_metadata((Point2)autotile_coord)); + } + CanvasItemEditor::get_singleton()->update_viewport(); } @@ -982,7 +984,7 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) { return true; } else { - // Mousebutton was released + // Mousebutton was released. if (tool != TOOL_NONE) { if (tool == TOOL_PAINTING) { @@ -1046,7 +1048,7 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) { CanvasItemEditor::get_singleton()->update_viewport(); - return true; // We want to keep the Pasting tool + return true; // We want to keep the Pasting tool. } else if (tool == TOOL_SELECTING) { CanvasItemEditor::get_singleton()->update_viewport(); @@ -1070,7 +1072,10 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) { _finish_undo(); - // We want to keep the bucket-tool active + // So the fill preview is cleared right after the click. + CanvasItemEditor::get_singleton()->update_viewport(); + + // We want to keep the bucket-tool active. return true; } @@ -1197,7 +1202,7 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) { if (tool == TOOL_PAINTING) { - // Paint using bresenham line to prevent holes in painting if the user moves fast + // Paint using bresenham line to prevent holes in painting if the user moves fast. Vector<Point2i> points = line(old_over_tile.x, over_tile.x, old_over_tile.y, over_tile.y); Vector<int> ids = get_selected_tiles(); @@ -1218,7 +1223,7 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) { if (tool == TOOL_ERASING) { - // erase using bresenham line to prevent holes in painting if the user moves fast + // Erase using bresenham line to prevent holes in painting if the user moves fast. Vector<Point2i> points = line(old_over_tile.x, over_tile.x, old_over_tile.y, over_tile.y); @@ -1343,13 +1348,13 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) { } if (!mouse_over) { - // Editor shortcuts should not fire if mouse not in viewport + // Editor shortcuts should not fire if mouse not in viewport. return false; } if (ED_IS_SHORTCUT("tile_map_editor/paint_tile", p_event)) { // NOTE: We do not set tool = TOOL_PAINTING as this begins painting - // immediately without pressing the left mouse button first + // immediately without pressing the left mouse button first. tool = TOOL_NONE; CanvasItemEditor::get_singleton()->update_viewport(); @@ -1431,7 +1436,7 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) { CanvasItemEditor::get_singleton()->update_viewport(); return true; } - } else if (k.is_valid()) { // release event + } else if (k.is_valid()) { // Release event. if (tool == TOOL_NONE) { @@ -1447,7 +1452,7 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) { #else if (k->get_scancode() == KEY_CONTROL) { #endif - // go back to that last tool if KEY_CONTROL was released + // Go back to that last tool if KEY_CONTROL was released. tool = last_tool; CanvasItemEditor::get_singleton()->update_viewport(); diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp index 7b521aba13..9a3991bef1 100644 --- a/editor/project_manager.cpp +++ b/editor/project_manager.cpp @@ -294,13 +294,13 @@ private: String sp = _test_path(); if (sp != "") { - // set the project name to the select folder name - if (project_name->get_text() == "") { + // If the project name is empty or default, infer the project name from the selected folder name + if (project_name->get_text() == "" || project_name->get_text() == TTR("New Game Project")) { sp = sp.replace("\\", "/"); int lidx = sp.find_last("/"); if (lidx != -1) { - sp = sp.substr(lidx + 1, sp.length()); + sp = sp.substr(lidx + 1, sp.length()).capitalize(); } if (sp == "" && mode == MODE_IMPORT) sp = TTR("Imported Project"); @@ -961,9 +961,25 @@ void ProjectManager::_notification(int p_what) { set_process_unhandled_input(is_visible_in_tree()); } break; + case NOTIFICATION_WM_QUIT_REQUEST: { + + _dim_window(); + } break; } } +void ProjectManager::_dim_window() { + + // This method must be called before calling `get_tree()->quit()`. + // Otherwise, its effect won't be visible + + // Dim the project manager window while it's quitting to make it clearer that it's busy. + // No transition is applied, as the effect needs to be visible immediately + float c = 1.0f - float(EDITOR_GET("interface/editor/dim_amount")); + Color dim_color = Color(c, c, c); + gui_base->set_modulate(dim_color); +} + void ProjectManager::_panel_draw(Node *p_hb) { HBoxContainer *hb = Object::cast_to<HBoxContainer>(p_hb); @@ -1514,6 +1530,7 @@ void ProjectManager::_open_selected_projects() { ERR_FAIL_COND(err); } + _dim_window(); get_tree()->quit(); } @@ -1780,11 +1797,13 @@ void ProjectManager::_restart_confirm() { Error err = OS::get_singleton()->execute(exec, args, false, &pid); ERR_FAIL_COND(err); + _dim_window(); get_tree()->quit(); } void ProjectManager::_exit_dialog() { + _dim_window(); get_tree()->quit(); } diff --git a/editor/project_manager.h b/editor/project_manager.h index fa878e75a6..a7cc6549f5 100644 --- a/editor/project_manager.h +++ b/editor/project_manager.h @@ -110,6 +110,7 @@ class ProjectManager : public Control { void _install_project(const String &p_zip_path, const String &p_title); + void _dim_window(); void _panel_draw(Node *p_hb); void _panel_input(const Ref<InputEvent> &p_ev, Node *p_hb); void _unhandled_input(const Ref<InputEvent> &p_ev); diff --git a/editor/scene_tree_editor.cpp b/editor/scene_tree_editor.cpp index e1b4320378..d6c8e6b452 100644 --- a/editor/scene_tree_editor.cpp +++ b/editor/scene_tree_editor.cpp @@ -291,8 +291,8 @@ bool SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent) { p_node->connect("script_changed", this, "_node_script_changed", varray(p_node)); if (!p_node->get_script().is_null()) { - - item->add_button(0, get_icon("Script", "EditorIcons"), BUTTON_SCRIPT, false, TTR("Open Script")); + Ref<Script> script = p_node->get_script(); + item->add_button(0, get_icon("Script", "EditorIcons"), BUTTON_SCRIPT, false, TTR("Open Script:") + " " + script->get_path()); } if (p_node->is_class("CanvasItem")) { @@ -399,15 +399,17 @@ bool SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent) { void SceneTreeEditor::_node_visibility_changed(Node *p_node) { - if (p_node != get_scene_node() && !p_node->get_owner()) { + if (!p_node || (p_node != get_scene_node() && !p_node->get_owner())) { return; } - TreeItem *item = p_node ? _find(tree->get_root(), p_node->get_path()) : NULL; - if (!item) { + TreeItem *item = _find(tree->get_root(), p_node->get_path()); + + if (!item) { return; } + int idx = item->get_button_by_id(0, BUTTON_VISIBILITY); ERR_FAIL_COND(idx == -1); diff --git a/editor/script_create_dialog.cpp b/editor/script_create_dialog.cpp index 751ae4fcf7..ffa221edaf 100644 --- a/editor/script_create_dialog.cpp +++ b/editor/script_create_dialog.cpp @@ -100,17 +100,25 @@ void ScriptCreateDialog::set_inheritance_base_type(const String &p_base) { base_type = p_base; } -bool ScriptCreateDialog::_validate(const String &p_string) { +bool ScriptCreateDialog::_validate_parent(const String &p_string) { if (p_string.length() == 0) return false; - if (ScriptServer::get_language(language_menu->get_selected())->can_inherit_from_file() && p_string.is_quoted()) { + if (can_inherit_from_file && p_string.is_quoted()) { String p = p_string.substr(1, p_string.length() - 2); if (_validate_path(p, true) == "") return true; } + return ClassDB::class_exists(p_string) || ScriptServer::is_global_class(p_string); +} + +bool ScriptCreateDialog::_validate_class(const String &p_string) { + + if (p_string.length() == 0) + return false; + for (int i = 0; i < p_string.length(); i++) { if (i == 0) { @@ -118,7 +126,7 @@ bool ScriptCreateDialog::_validate(const String &p_string) { return false; // no start with number plz } - bool valid_char = (p_string[i] >= '0' && p_string[i] <= '9') || (p_string[i] >= 'a' && p_string[i] <= 'z') || (p_string[i] >= 'A' && p_string[i] <= 'Z') || p_string[i] == '_' || p_string[i] == '-'; + bool valid_char = (p_string[i] >= '0' && p_string[i] <= '9') || (p_string[i] >= 'a' && p_string[i] <= 'z') || (p_string[i] >= 'A' && p_string[i] <= 'Z') || p_string[i] == '_'; if (!valid_char) return false; @@ -193,7 +201,7 @@ String ScriptCreateDialog::_validate_path(const String &p_path, bool p_file_must void ScriptCreateDialog::_class_name_changed(const String &p_name) { - if (_validate(class_name->get_text())) { + if (_validate_class(class_name->get_text())) { is_class_name_valid = true; } else { is_class_name_valid = false; @@ -203,7 +211,7 @@ void ScriptCreateDialog::_class_name_changed(const String &p_name) { void ScriptCreateDialog::_parent_name_changed(const String &p_parent) { - if (_validate(parent_name->get_text())) { + if (_validate_parent(parent_name->get_text())) { is_parent_name_valid = true; } else { is_parent_name_valid = false; @@ -298,27 +306,13 @@ void ScriptCreateDialog::_load_exist() { void ScriptCreateDialog::_lang_changed(int l) { - l = language_menu->get_selected(); ScriptLanguage *language = ScriptServer::get_language(l); - if (language->has_named_classes()) { - has_named_classes = true; - } else { - has_named_classes = false; - } - - if (language->supports_builtin_mode()) { - supports_built_in = true; - } else { - supports_built_in = false; + has_named_classes = language->has_named_classes(); + can_inherit_from_file = language->can_inherit_from_file(); + supports_built_in = language->supports_builtin_mode(); + if (!supports_built_in) is_built_in = false; - } - - if (ScriptServer::get_language(l)->can_inherit_from_file()) { - can_inherit_from_file = true; - } else { - can_inherit_from_file = false; - } String selected_ext = "." + language->get_extension(); String path = file_path->get_text(); @@ -430,7 +424,7 @@ void ScriptCreateDialog::_file_selected(const String &p_file) { String p = ProjectSettings::get_singleton()->localize_path(p_file); if (is_browsing_parent) { parent_name->set_text("\"" + p + "\""); - _class_name_changed("\"" + p + "\""); + _parent_name_changed(parent_name->get_text()); } else { file_path->set_text(p); _path_changed(p); @@ -445,7 +439,8 @@ void ScriptCreateDialog::_file_selected(const String &p_file) { void ScriptCreateDialog::_create() { - parent_name->set_text(select_class->get_selected_type()); + parent_name->set_text(select_class->get_selected_type().split(" ")[0]); + _parent_name_changed(parent_name->get_text()); } void ScriptCreateDialog::_browse_class_in_tree() { @@ -542,14 +537,7 @@ void ScriptCreateDialog::_update_dialog() { class_name->set_editable(false); class_name->set_placeholder(TTR("N/A")); class_name->set_placeholder_alpha(1); - } - - /* Can script inherit from a file */ - - if (can_inherit_from_file) { - parent_browse_button->set_disabled(false); - } else { - parent_browse_button->set_disabled(true); + class_name->set_text(""); } /* Is script Built-in */ @@ -572,7 +560,8 @@ void ScriptCreateDialog::_update_dialog() { if (is_built_in) { get_ok()->set_text(TTR("Create")); parent_name->set_editable(true); - parent_browse_button->set_disabled(false); + parent_search_button->set_disabled(false); + parent_browse_button->set_disabled(!can_inherit_from_file); internal->set_visible(_can_be_built_in()); internal_label->set_visible(_can_be_built_in()); _msg_path_valid(true, TTR("Built-in script (into scene file).")); @@ -580,7 +569,8 @@ void ScriptCreateDialog::_update_dialog() { // New Script Created get_ok()->set_text(TTR("Create")); parent_name->set_editable(true); - parent_browse_button->set_disabled(false); + parent_search_button->set_disabled(false); + parent_browse_button->set_disabled(!can_inherit_from_file); internal->set_visible(_can_be_built_in()); internal_label->set_visible(_can_be_built_in()); if (is_path_valid) { @@ -590,6 +580,7 @@ void ScriptCreateDialog::_update_dialog() { // Script Loaded get_ok()->set_text(TTR("Load")); parent_name->set_editable(false); + parent_search_button->set_disabled(true); parent_browse_button->set_disabled(true); internal->set_disabled(!_can_be_built_in()); if (is_path_valid) { @@ -755,7 +746,6 @@ ScriptCreateDialog::ScriptCreateDialog() { internal->set_h_size_flags(0); internal->connect("pressed", this, "_built_in_pressed"); internal_label = memnew(Label(TTR("Built-in Script"))); - internal_label->set_text(TTR("Built-in Script")); internal_label->set_align(Label::ALIGN_RIGHT); gc->add_child(internal_label); gc->add_child(internal); diff --git a/editor/script_create_dialog.h b/editor/script_create_dialog.h index c6dba78f56..61f87f5732 100644 --- a/editor/script_create_dialog.h +++ b/editor/script_create_dialog.h @@ -87,7 +87,8 @@ class ScriptCreateDialog : public ConfirmationDialog { void _path_entered(const String &p_path = String()); void _lang_changed(int l = 0); void _built_in_pressed(); - bool _validate(const String &p_string); + bool _validate_parent(const String &p_string); + bool _validate_class(const String &p_string); String _validate_path(const String &p_path, bool p_file_must_exist); void _class_name_changed(const String &p_name); void _parent_name_changed(const String &p_parent); diff --git a/editor/script_editor_debugger.cpp b/editor/script_editor_debugger.cpp index c3b62810f1..3b086c6316 100644 --- a/editor/script_editor_debugger.cpp +++ b/editor/script_editor_debugger.cpp @@ -727,20 +727,8 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da String tt = vs; switch (Performance::MonitorType((int)perf_items[i]->get_metadata(1))) { case Performance::MONITOR_TYPE_MEMORY: { - // for the time being, going above GBs is a bad sign. - String unit = "B"; - if ((int)v > 1073741824) { - unit = "GB"; - v /= 1073741824.0; - } else if ((int)v > 1048576) { - unit = "MB"; - v /= 1048576.0; - } else if ((int)v > 1024) { - unit = "KB"; - v /= 1024.0; - } - tt += " bytes"; - vs = String::num(v, 2) + " " + unit; + vs = String::humanize_size(v); + tt = vs; } break; case Performance::MONITOR_TYPE_TIME: { tt += " seconds"; |