feat: updated engine
This commit is contained in:
parent
cbe99774ff
commit
f4cf6b3999
6607 changed files with 910135 additions and 430025 deletions
|
|
@ -30,23 +30,26 @@
|
|||
|
||||
#include "editor_log.h"
|
||||
|
||||
#include "core/io/resource_loader.h"
|
||||
#include "core/object/callable_mp.h"
|
||||
#include "core/object/message_queue.h"
|
||||
#include "core/object/undo_redo.h"
|
||||
#include "core/os/keyboard.h"
|
||||
#include "core/os/os.h"
|
||||
#include "core/version.h"
|
||||
#include "editor/docks/editor_dock.h"
|
||||
#include "editor/docks/inspector_dock.h"
|
||||
#include "editor/editor_node.h"
|
||||
#include "editor/editor_string_names.h"
|
||||
#include "editor/file_system/editor_paths.h"
|
||||
#include "editor/script/script_editor_plugin.h"
|
||||
#include "editor/settings/editor_command_palette.h"
|
||||
#include "editor/settings/editor_settings.h"
|
||||
#include "editor/themes/editor_scale.h"
|
||||
#include "modules/regex/regex.h"
|
||||
#include "scene/gui/box_container.h"
|
||||
#include "scene/gui/separator.h"
|
||||
#include "scene/gui/flow_container.h"
|
||||
#include "scene/main/timer.h"
|
||||
#include "scene/resources/font.h"
|
||||
#include "servers/display/display_server.h"
|
||||
|
||||
void EditorLog::_error_handler(void *p_self, const char *p_func, const char *p_file, int p_line, const char *p_error, const char *p_errorexp, bool p_editor_notify, ErrorHandlerType p_type) {
|
||||
EditorLog *self = static_cast<EditorLog *>(p_self);
|
||||
|
|
@ -106,20 +109,23 @@ void EditorLog::_update_theme() {
|
|||
log->add_theme_font_size_override("mono_font_size", font_size);
|
||||
log->end_bulk_theme_override();
|
||||
|
||||
type_filter_map[MSG_TYPE_STD]->toggle_button->set_button_icon(get_editor_theme_icon(SNAME("Popup")));
|
||||
type_filter_map[MSG_TYPE_ERROR]->toggle_button->set_button_icon(get_editor_theme_icon(SNAME("StatusError")));
|
||||
type_filter_map[MSG_TYPE_WARNING]->toggle_button->set_button_icon(get_editor_theme_icon(SNAME("StatusWarning")));
|
||||
type_filter_map[MSG_TYPE_EDITOR]->toggle_button->set_button_icon(get_editor_theme_icon(SNAME("Edit")));
|
||||
const String wide_text = "MM";
|
||||
|
||||
type_filter_map[MSG_TYPE_STD]->toggle_button->set_theme_type_variation("EditorLogFilterButton");
|
||||
type_filter_map[MSG_TYPE_ERROR]->toggle_button->set_theme_type_variation("EditorLogFilterButton");
|
||||
type_filter_map[MSG_TYPE_WARNING]->toggle_button->set_theme_type_variation("EditorLogFilterButton");
|
||||
type_filter_map[MSG_TYPE_EDITOR]->toggle_button->set_theme_type_variation("EditorLogFilterButton");
|
||||
Button *button = type_filter_map[MSG_TYPE_STD]->toggle_button;
|
||||
button->set_button_icon(get_editor_theme_icon(SNAME("Popup")));
|
||||
button->set_custom_minimum_size(Vector2(button->get_minimum_size_for_text_and_icon(wide_text, button->get_button_icon()).x * EDSCALE, 0));
|
||||
button = type_filter_map[MSG_TYPE_ERROR]->toggle_button;
|
||||
button->set_button_icon(get_editor_theme_icon(SNAME("StatusError")));
|
||||
button->set_custom_minimum_size(Vector2(button->get_minimum_size_for_text_and_icon(wide_text, button->get_button_icon()).x * EDSCALE, 0));
|
||||
button = type_filter_map[MSG_TYPE_WARNING]->toggle_button;
|
||||
button->set_button_icon(get_editor_theme_icon(SNAME("StatusWarning")));
|
||||
button->set_custom_minimum_size(Vector2(button->get_minimum_size_for_text_and_icon(wide_text, button->get_button_icon()).x * EDSCALE, 0));
|
||||
button = type_filter_map[MSG_TYPE_EDITOR]->toggle_button;
|
||||
button->set_button_icon(get_editor_theme_icon(SNAME("Edit")));
|
||||
button->set_custom_minimum_size(Vector2(button->get_minimum_size_for_text_and_icon(wide_text, button->get_button_icon()).x * EDSCALE, 0));
|
||||
|
||||
clear_button->set_button_icon(get_editor_theme_icon(SNAME("Clear")));
|
||||
copy_button->set_button_icon(get_editor_theme_icon(SNAME("ActionCopy")));
|
||||
collapse_button->set_button_icon(get_editor_theme_icon(SNAME("CombineLines")));
|
||||
show_search_button->set_button_icon(get_editor_theme_icon(SNAME("Search")));
|
||||
search_box->set_right_icon(get_editor_theme_icon(SNAME("Search")));
|
||||
|
||||
theme_cache.error_color = get_theme_color(SNAME("error_color"), EditorStringName(Editor));
|
||||
|
|
@ -144,6 +150,13 @@ void EditorLog::_notification(int p_what) {
|
|||
_load_state();
|
||||
} break;
|
||||
|
||||
case NOTIFICATION_EXIT_TREE: {
|
||||
if (!save_state_timer->is_stopped()) {
|
||||
_save_state();
|
||||
save_state_timer->stop();
|
||||
}
|
||||
} break;
|
||||
|
||||
case NOTIFICATION_THEME_CHANGED: {
|
||||
_update_theme();
|
||||
_rebuild_log();
|
||||
|
|
@ -151,6 +164,17 @@ void EditorLog::_notification(int p_what) {
|
|||
}
|
||||
}
|
||||
|
||||
void EditorLog::shortcut_input(const Ref<InputEvent> &p_event) {
|
||||
Ref<InputEventKey> key = p_event;
|
||||
if (key.is_valid() && key->is_pressed() && !key->is_echo()) {
|
||||
if (ED_IS_SHORTCUT("editor/open_search", p_event)) {
|
||||
search_box->grab_focus();
|
||||
search_box->select_all();
|
||||
accept_event();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void EditorLog::_set_collapse(bool p_collapse) {
|
||||
collapse = p_collapse;
|
||||
_start_state_save_timer();
|
||||
|
|
@ -164,40 +188,20 @@ void EditorLog::_start_state_save_timer() {
|
|||
}
|
||||
|
||||
void EditorLog::_save_state() {
|
||||
Ref<ConfigFile> config;
|
||||
config.instantiate();
|
||||
// Load and amend existing config if it exists.
|
||||
config->load(EditorPaths::get_singleton()->get_project_settings_dir().path_join("editor_layout.cfg"));
|
||||
|
||||
const String section = "editor_log";
|
||||
for (const KeyValue<MessageType, LogFilter *> &E : type_filter_map) {
|
||||
config->set_value(section, "log_filter_" + itos(E.key), E.value->is_active());
|
||||
EditorSettings::get_singleton()->set_setting("_editor_log_filter_" + itos(E.key), E.value->is_active());
|
||||
}
|
||||
|
||||
config->set_value(section, "collapse", collapse);
|
||||
config->set_value(section, "show_search", search_box->is_visible());
|
||||
|
||||
config->save(EditorPaths::get_singleton()->get_project_settings_dir().path_join("editor_layout.cfg"));
|
||||
EditorSettings::get_singleton()->set_setting("_editor_log_collapse", collapse);
|
||||
EditorSettings::save();
|
||||
}
|
||||
|
||||
void EditorLog::_load_state() {
|
||||
is_loading_state = true;
|
||||
|
||||
Ref<ConfigFile> config;
|
||||
config.instantiate();
|
||||
config->load(EditorPaths::get_singleton()->get_project_settings_dir().path_join("editor_layout.cfg"));
|
||||
|
||||
// Run the below code even if config->load returns an error, since we want the defaults to be set even if the file does not exist yet.
|
||||
const String section = "editor_log";
|
||||
for (const KeyValue<MessageType, LogFilter *> &E : type_filter_map) {
|
||||
E.value->set_active(config->get_value(section, "log_filter_" + itos(E.key), true));
|
||||
E.value->set_active(EDITOR_DEF("_editor_log_filter_" + itos(E.key), true));
|
||||
}
|
||||
|
||||
collapse = config->get_value(section, "collapse", false);
|
||||
collapse_button->set_pressed(collapse);
|
||||
bool show_search = config->get_value(section, "show_search", true);
|
||||
search_box->set_visible(show_search);
|
||||
show_search_button->set_pressed(show_search);
|
||||
collapse_button->set_pressed(EDITOR_DEF("_editor_log_collapse", false));
|
||||
|
||||
is_loading_state = false;
|
||||
}
|
||||
|
|
@ -221,7 +225,21 @@ void EditorLog::_meta_clicked(const String &p_meta) {
|
|||
if (path.begins_with("./") || path.begins_with(".\\")) {
|
||||
// Relative path. Convert to absolute, using executable path as reference.
|
||||
path = path.trim_prefix("./").trim_prefix(".\\");
|
||||
path = OS::get_singleton()->get_executable_path().get_base_dir().get_base_dir().path_join(path);
|
||||
const String absolute_path = OS::get_singleton()->get_executable_path().get_base_dir().get_base_dir().path_join(path);
|
||||
if (FileAccess::exists(absolute_path)) {
|
||||
path = absolute_path;
|
||||
}
|
||||
}
|
||||
|
||||
if (!FileAccess::exists(path)) {
|
||||
// The file does not exist. Try on GitHub instead.
|
||||
String branch = "master";
|
||||
if (str_compare(GODOT_VERSION_BUILD, "official") == 0) {
|
||||
// In official builds it's safe to use specific commit hash, so the line number is more accurate.
|
||||
branch = GODOT_VERSION_HASH;
|
||||
}
|
||||
OS::get_singleton()->shell_open(vformat("https://github.com/godotengine/godot/blob/%s/%s#L%d", branch, path, line + 1));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!ScriptEditorPlugin::open_in_external_editor(path, line, -1, true)) {
|
||||
|
|
@ -239,18 +257,6 @@ void EditorLog::_clear_request() {
|
|||
_set_dock_tab_icon(Ref<Texture2D>());
|
||||
}
|
||||
|
||||
void EditorLog::_copy_request() {
|
||||
String text = log->get_selected_text();
|
||||
|
||||
if (text.is_empty()) {
|
||||
text = log->get_parsed_text();
|
||||
}
|
||||
|
||||
if (!text.is_empty()) {
|
||||
DisplayServer::get_singleton()->clipboard_set(text);
|
||||
}
|
||||
}
|
||||
|
||||
void EditorLog::clear() {
|
||||
_clear_request();
|
||||
}
|
||||
|
|
@ -413,7 +419,7 @@ void EditorLog::_add_log_line(LogMessage &p_message, bool p_replace_previous) {
|
|||
Ref<Texture2D> icon = theme_cache.error_icon;
|
||||
log->add_image(icon);
|
||||
log->push_bold();
|
||||
log->add_text(" ERROR: ");
|
||||
log->add_text(U" ERROR: ");
|
||||
log->pop(); // bold
|
||||
_set_dock_tab_icon(icon);
|
||||
} break;
|
||||
|
|
@ -422,7 +428,7 @@ void EditorLog::_add_log_line(LogMessage &p_message, bool p_replace_previous) {
|
|||
Ref<Texture2D> icon = theme_cache.warning_icon;
|
||||
log->add_image(icon);
|
||||
log->push_bold();
|
||||
log->add_text(" WARNING: ");
|
||||
log->add_text(U" WARNING: ");
|
||||
log->pop(); // bold
|
||||
_set_dock_tab_icon(icon);
|
||||
} break;
|
||||
|
|
@ -468,14 +474,6 @@ void EditorLog::_set_filter_active(bool p_active, MessageType p_message_type) {
|
|||
_rebuild_log();
|
||||
}
|
||||
|
||||
void EditorLog::_set_search_visible(bool p_visible) {
|
||||
search_box->set_visible(p_visible);
|
||||
if (p_visible) {
|
||||
search_box->grab_focus();
|
||||
}
|
||||
_start_state_save_timer();
|
||||
}
|
||||
|
||||
void EditorLog::_search_changed(const String &p_text) {
|
||||
_rebuild_log();
|
||||
}
|
||||
|
|
@ -492,6 +490,8 @@ EditorLog::EditorLog() {
|
|||
set_dock_shortcut(ED_SHORTCUT_AND_COMMAND("bottom_panels/toggle_output_bottom_panel", TTRC("Toggle Output Dock"), KeyModifierMask::ALT | Key::O));
|
||||
set_default_slot(EditorDock::DOCK_SLOT_BOTTOM);
|
||||
set_available_layouts(EditorDock::DOCK_LAYOUT_HORIZONTAL | EditorDock::DOCK_LAYOUT_FLOATING);
|
||||
set_process_shortcut_input(true);
|
||||
set_shortcut_context(this);
|
||||
|
||||
save_state_timer = memnew(Timer);
|
||||
save_state_timer->set_wait_time(2);
|
||||
|
|
@ -506,7 +506,7 @@ EditorLog::EditorLog() {
|
|||
add_child(hb);
|
||||
|
||||
VBoxContainer *vb_left = memnew(VBoxContainer);
|
||||
vb_left->set_custom_minimum_size(Size2(0, 180) * EDSCALE);
|
||||
vb_left->set_custom_minimum_size(Size2(0, 90 * EDSCALE));
|
||||
vb_left->set_v_size_flags(SIZE_EXPAND_FILL);
|
||||
vb_left->set_h_size_flags(SIZE_EXPAND_FILL);
|
||||
hb->add_child(vb_left);
|
||||
|
|
@ -525,95 +525,62 @@ EditorLog::EditorLog() {
|
|||
log->connect("meta_clicked", callable_mp(this, &EditorLog::_meta_clicked));
|
||||
vb_left->add_child(log);
|
||||
|
||||
// Search box
|
||||
search_box = memnew(LineEdit);
|
||||
search_box->set_h_size_flags(Control::SIZE_EXPAND_FILL);
|
||||
search_box->set_placeholder(TTR("Filter Messages"));
|
||||
search_box->set_accessibility_name(TTRC("Filter Messages"));
|
||||
search_box->set_clear_button_enabled(true);
|
||||
search_box->set_visible(true);
|
||||
search_box->connect(SceneStringName(text_changed), callable_mp(this, &EditorLog::_search_changed));
|
||||
vb_left->add_child(search_box);
|
||||
|
||||
VBoxContainer *vb_right = memnew(VBoxContainer);
|
||||
hb->add_child(vb_right);
|
||||
|
||||
// Tools grid
|
||||
HBoxContainer *hb_tools = memnew(HBoxContainer);
|
||||
hb_tools->set_h_size_flags(SIZE_SHRINK_CENTER);
|
||||
vb_right->add_child(hb_tools);
|
||||
HFlowContainer *bottom_hf = memnew(HFlowContainer);
|
||||
bottom_hf->set_alignment(FlowContainer::ALIGNMENT_END);
|
||||
vb_left->add_child(bottom_hf);
|
||||
|
||||
// Clear.
|
||||
clear_button = memnew(Button);
|
||||
clear_button->set_accessibility_name(TTRC("Clear Log"));
|
||||
clear_button->set_theme_type_variation(SceneStringName(FlatButton));
|
||||
clear_button->set_theme_type_variation("BottomPanelButton");
|
||||
clear_button->set_focus_mode(FOCUS_ACCESSIBILITY);
|
||||
clear_button->set_shortcut(ED_SHORTCUT("editor/clear_output", TTRC("Clear Output"), KeyModifierMask::CMD_OR_CTRL | KeyModifierMask::ALT | Key::K));
|
||||
clear_button->connect(SceneStringName(pressed), callable_mp(this, &EditorLog::_clear_request));
|
||||
hb_tools->add_child(clear_button);
|
||||
|
||||
// Copy.
|
||||
copy_button = memnew(Button);
|
||||
copy_button->set_accessibility_name(TTRC("Copy Selection"));
|
||||
copy_button->set_theme_type_variation(SceneStringName(FlatButton));
|
||||
copy_button->set_focus_mode(FOCUS_ACCESSIBILITY);
|
||||
copy_button->set_shortcut(ED_SHORTCUT("editor/copy_output", TTRC("Copy Selection"), KeyModifierMask::CMD_OR_CTRL | Key::C));
|
||||
copy_button->set_shortcut_context(this);
|
||||
copy_button->connect(SceneStringName(pressed), callable_mp(this, &EditorLog::_copy_request));
|
||||
hb_tools->add_child(copy_button);
|
||||
|
||||
// Separate toggle buttons from normal buttons.
|
||||
vb_right->add_child(memnew(HSeparator));
|
||||
|
||||
// A second hbox to make a 2x2 grid of buttons.
|
||||
HBoxContainer *hb_tools2 = memnew(HBoxContainer);
|
||||
hb_tools2->set_h_size_flags(SIZE_SHRINK_CENTER);
|
||||
vb_right->add_child(hb_tools2);
|
||||
bottom_hf->add_child(clear_button);
|
||||
|
||||
// Collapse.
|
||||
collapse_button = memnew(Button);
|
||||
collapse_button->set_theme_type_variation(SceneStringName(FlatButton));
|
||||
collapse_button->set_theme_type_variation("BottomPanelButton");
|
||||
collapse_button->set_focus_mode(FOCUS_ACCESSIBILITY);
|
||||
collapse_button->set_tooltip_text(TTR("Collapse duplicate messages into one log entry. Shows number of occurrences."));
|
||||
collapse_button->set_toggle_mode(true);
|
||||
collapse_button->set_pressed(false);
|
||||
collapse_button->connect(SceneStringName(toggled), callable_mp(this, &EditorLog::_set_collapse));
|
||||
hb_tools2->add_child(collapse_button);
|
||||
bottom_hf->add_child(collapse_button);
|
||||
|
||||
// Show Search.
|
||||
show_search_button = memnew(Button);
|
||||
show_search_button->set_accessibility_name(TTRC("Show Search"));
|
||||
show_search_button->set_theme_type_variation(SceneStringName(FlatButton));
|
||||
show_search_button->set_focus_mode(FOCUS_ACCESSIBILITY);
|
||||
show_search_button->set_toggle_mode(true);
|
||||
show_search_button->set_pressed(true);
|
||||
show_search_button->set_shortcut(ED_SHORTCUT("editor/open_search", TTRC("Focus Search/Filter Bar"), KeyModifierMask::CMD_OR_CTRL | Key::F));
|
||||
show_search_button->set_shortcut_context(this);
|
||||
show_search_button->connect(SceneStringName(toggled), callable_mp(this, &EditorLog::_set_search_visible));
|
||||
hb_tools2->add_child(show_search_button);
|
||||
// Search box
|
||||
search_box = memnew(LineEdit);
|
||||
search_box->set_custom_minimum_size(Vector2(150 * EDSCALE, 0));
|
||||
search_box->set_h_size_flags(Control::SIZE_EXPAND_FILL);
|
||||
search_box->set_placeholder(TTRC("Filter Messages"));
|
||||
search_box->set_accessibility_name(TTRC("Filter Messages"));
|
||||
search_box->set_clear_button_enabled(true);
|
||||
search_box->connect(SceneStringName(text_changed), callable_mp(this, &EditorLog::_search_changed));
|
||||
bottom_hf->add_child(search_box);
|
||||
|
||||
HBoxContainer *hbox = memnew(HBoxContainer);
|
||||
bottom_hf->add_child(hbox);
|
||||
|
||||
// Message Type Filters.
|
||||
vb_right->add_child(memnew(HSeparator));
|
||||
|
||||
LogFilter *std_filter = memnew(LogFilter(MSG_TYPE_STD));
|
||||
std_filter->initialize_button(TTRC("Standard Messages"), TTRC("Toggle visibility of standard output messages."), callable_mp(this, &EditorLog::_set_filter_active));
|
||||
vb_right->add_child(std_filter->toggle_button);
|
||||
hbox->add_child(std_filter->toggle_button);
|
||||
type_filter_map.insert(MSG_TYPE_STD, std_filter);
|
||||
type_filter_map.insert(MSG_TYPE_STD_RICH, std_filter);
|
||||
|
||||
LogFilter *error_filter = memnew(LogFilter(MSG_TYPE_ERROR));
|
||||
error_filter->initialize_button(TTRC("Errors"), TTRC("Toggle visibility of errors."), callable_mp(this, &EditorLog::_set_filter_active));
|
||||
vb_right->add_child(error_filter->toggle_button);
|
||||
hbox->add_child(error_filter->toggle_button);
|
||||
type_filter_map.insert(MSG_TYPE_ERROR, error_filter);
|
||||
|
||||
LogFilter *warning_filter = memnew(LogFilter(MSG_TYPE_WARNING));
|
||||
warning_filter->initialize_button(TTRC("Warnings"), TTRC("Toggle visibility of warnings."), callable_mp(this, &EditorLog::_set_filter_active));
|
||||
vb_right->add_child(warning_filter->toggle_button);
|
||||
hbox->add_child(warning_filter->toggle_button);
|
||||
type_filter_map.insert(MSG_TYPE_WARNING, warning_filter);
|
||||
|
||||
LogFilter *editor_filter = memnew(LogFilter(MSG_TYPE_EDITOR));
|
||||
editor_filter->initialize_button(TTRC("Editor Messages"), TTRC("Toggle visibility of editor messages."), callable_mp(this, &EditorLog::_set_filter_active));
|
||||
vb_right->add_child(editor_filter->toggle_button);
|
||||
hbox->add_child(editor_filter->toggle_button);
|
||||
type_filter_map.insert(MSG_TYPE_EDITOR, editor_filter);
|
||||
|
||||
add_message(GODOT_VERSION_FULL_NAME " (c) 2007-present Juan Linietsky, Ariel Manzur & Godot Contributors.");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue