feat: modules moved and engine moved to submodule
This commit is contained in:
parent
dfb5e645cd
commit
c33d2130cc
5136 changed files with 225275 additions and 64485 deletions
|
|
@ -184,16 +184,22 @@ void ScriptTextEditor::enable_editor(Control *p_shortcut_context) {
|
|||
void ScriptTextEditor::_load_theme_settings() {
|
||||
CodeEdit *text_edit = code_editor->get_text_editor();
|
||||
|
||||
Color updated_warning_line_color = EDITOR_GET("text_editor/theme/highlighting/warning_color");
|
||||
Color updated_marked_line_color = EDITOR_GET("text_editor/theme/highlighting/mark_color");
|
||||
Color updated_safe_line_number_color = EDITOR_GET("text_editor/theme/highlighting/safe_line_number_color");
|
||||
Color updated_folded_code_region_color = EDITOR_GET("text_editor/theme/highlighting/folded_code_region_color");
|
||||
|
||||
bool safe_line_number_color_updated = updated_safe_line_number_color != safe_line_number_color;
|
||||
bool warning_line_color_updated = updated_warning_line_color != warning_line_color;
|
||||
bool marked_line_color_updated = updated_marked_line_color != marked_line_color;
|
||||
bool safe_line_number_color_updated = updated_safe_line_number_color != safe_line_number_color;
|
||||
bool folded_code_region_color_updated = updated_folded_code_region_color != folded_code_region_color;
|
||||
if (safe_line_number_color_updated || marked_line_color_updated || folded_code_region_color_updated) {
|
||||
if (safe_line_number_color_updated || warning_line_color_updated || marked_line_color_updated || folded_code_region_color_updated) {
|
||||
safe_line_number_color = updated_safe_line_number_color;
|
||||
for (int i = 0; i < text_edit->get_line_count(); i++) {
|
||||
if (warning_line_color_updated && text_edit->get_line_background_color(i) == warning_line_color) {
|
||||
text_edit->set_line_background_color(i, updated_warning_line_color);
|
||||
}
|
||||
|
||||
if (marked_line_color_updated && text_edit->get_line_background_color(i) == marked_line_color) {
|
||||
text_edit->set_line_background_color(i, updated_marked_line_color);
|
||||
}
|
||||
|
|
@ -206,6 +212,7 @@ void ScriptTextEditor::_load_theme_settings() {
|
|||
text_edit->set_line_background_color(i, updated_folded_code_region_color);
|
||||
}
|
||||
}
|
||||
warning_line_color = updated_warning_line_color;
|
||||
marked_line_color = updated_marked_line_color;
|
||||
folded_code_region_color = updated_folded_code_region_color;
|
||||
}
|
||||
|
|
@ -228,8 +235,8 @@ void ScriptTextEditor::_set_theme_for_script() {
|
|||
script->get_language()->get_string_delimiters(&strings);
|
||||
text_edit->clear_string_delimiters();
|
||||
for (const String &string : strings) {
|
||||
String beg = string.get_slice(" ", 0);
|
||||
String end = string.get_slice_count(" ") > 1 ? string.get_slice(" ", 1) : String();
|
||||
String beg = string.get_slicec(' ', 0);
|
||||
String end = string.get_slice_count(" ") > 1 ? string.get_slicec(' ', 1) : String();
|
||||
if (!text_edit->has_string_delimiter(beg)) {
|
||||
text_edit->add_string_delimiter(beg, end, end.is_empty());
|
||||
}
|
||||
|
|
@ -244,8 +251,8 @@ void ScriptTextEditor::_set_theme_for_script() {
|
|||
List<String> comments;
|
||||
script->get_language()->get_comment_delimiters(&comments);
|
||||
for (const String &comment : comments) {
|
||||
String beg = comment.get_slice(" ", 0);
|
||||
String end = comment.get_slice_count(" ") > 1 ? comment.get_slice(" ", 1) : String();
|
||||
String beg = comment.get_slicec(' ', 0);
|
||||
String end = comment.get_slice_count(" ") > 1 ? comment.get_slicec(' ', 1) : String();
|
||||
text_edit->add_comment_delimiter(beg, end, end.is_empty());
|
||||
|
||||
if (!end.is_empty() && !text_edit->has_auto_brace_completion_open_key(beg)) {
|
||||
|
|
@ -256,8 +263,8 @@ void ScriptTextEditor::_set_theme_for_script() {
|
|||
List<String> doc_comments;
|
||||
script->get_language()->get_doc_comment_delimiters(&doc_comments);
|
||||
for (const String &doc_comment : doc_comments) {
|
||||
String beg = doc_comment.get_slice(" ", 0);
|
||||
String end = doc_comment.get_slice_count(" ") > 1 ? doc_comment.get_slice(" ", 1) : String();
|
||||
String beg = doc_comment.get_slicec(' ', 0);
|
||||
String end = doc_comment.get_slice_count(" ") > 1 ? doc_comment.get_slicec(' ', 1) : String();
|
||||
text_edit->add_comment_delimiter(beg, end, end.is_empty());
|
||||
|
||||
if (!end.is_empty() && !text_edit->has_auto_brace_completion_open_key(beg)) {
|
||||
|
|
@ -567,8 +574,8 @@ void ScriptTextEditor::_validate_script() {
|
|||
script_is_valid = true;
|
||||
}
|
||||
_update_connected_methods();
|
||||
_update_warnings();
|
||||
_update_errors();
|
||||
_update_warnings();
|
||||
|
||||
emit_signal(SNAME("name_changed"));
|
||||
emit_signal(SNAME("edited_script_changed"));
|
||||
|
|
@ -637,6 +644,17 @@ void ScriptTextEditor::_update_warnings() {
|
|||
warnings_panel->pop(); // Cell.
|
||||
}
|
||||
warnings_panel->pop(); // Table.
|
||||
if (warning_line_color.a != 0.0) {
|
||||
CodeEdit *te = code_editor->get_text_editor();
|
||||
for (int i = 0; i < te->get_line_count(); i++) {
|
||||
for (const ScriptLanguage::Warning &W : warnings) {
|
||||
if (i >= W.start_line - 1 && i < W.end_line) {
|
||||
te->set_line_background_color(i, warning_line_color);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ScriptTextEditor::_update_errors() {
|
||||
|
|
@ -706,7 +724,7 @@ void ScriptTextEditor::_update_errors() {
|
|||
if (errors.is_empty()) {
|
||||
bool is_folded_code_region = te->is_line_code_region_start(i) && te->is_line_folded(i);
|
||||
te->set_line_background_color(i, is_folded_code_region ? folded_code_region_color : Color(0, 0, 0, 0));
|
||||
} else {
|
||||
} else if (marked_line_color.a != 0) {
|
||||
for (const ScriptLanguage::ScriptError &E : errors) {
|
||||
bool error_line = i == E.line - 1;
|
||||
te->set_line_background_color(i, error_line ? marked_line_color : Color(0, 0, 0, 0));
|
||||
|
|
@ -742,7 +760,7 @@ void ScriptTextEditor::_update_bookmark_list() {
|
|||
bookmarks_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/goto_previous_bookmark"), BOOKMARK_GOTO_PREV);
|
||||
|
||||
PackedInt32Array bookmark_list = code_editor->get_text_editor()->get_bookmarked_lines();
|
||||
if (bookmark_list.size() == 0) {
|
||||
if (bookmark_list.is_empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -897,7 +915,7 @@ void ScriptTextEditor::_update_breakpoint_list() {
|
|||
breakpoints_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/goto_previous_breakpoint"), DEBUG_GOTO_PREV_BREAKPOINT);
|
||||
|
||||
PackedInt32Array breakpoint_list = code_editor->get_text_editor()->get_breakpointed_lines();
|
||||
if (breakpoint_list.size() == 0) {
|
||||
if (breakpoint_list.is_empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -935,7 +953,7 @@ void ScriptTextEditor::_on_caret_moved() {
|
|||
return;
|
||||
}
|
||||
int current_line = code_editor->get_text_editor()->get_caret_line();
|
||||
if (ABS(current_line - previous_line) >= 10) {
|
||||
if (Math::abs(current_line - previous_line) >= 10) {
|
||||
Dictionary nav_state = get_navigation_state();
|
||||
nav_state["row"] = previous_line;
|
||||
nav_state["scroll_position"] = -1;
|
||||
|
|
@ -957,19 +975,7 @@ void ScriptTextEditor::_lookup_symbol(const String &p_symbol, int p_row, int p_c
|
|||
if (ScriptServer::is_global_class(p_symbol)) {
|
||||
EditorNode::get_singleton()->load_resource(ScriptServer::get_global_class_path(p_symbol));
|
||||
} else if (p_symbol.is_resource_file() || p_symbol.begins_with("uid://")) {
|
||||
String symbol = p_symbol;
|
||||
if (symbol.begins_with("uid://")) {
|
||||
symbol = ResourceUID::uid_to_path(symbol);
|
||||
}
|
||||
|
||||
List<String> scene_extensions;
|
||||
ResourceLoader::get_recognized_extensions_for_type("PackedScene", &scene_extensions);
|
||||
|
||||
if (scene_extensions.find(symbol.get_extension())) {
|
||||
EditorNode::get_singleton()->load_scene(symbol);
|
||||
} else {
|
||||
EditorNode::get_singleton()->load_resource(symbol);
|
||||
}
|
||||
EditorNode::get_singleton()->load_scene_or_resource(p_symbol);
|
||||
} else if (lc_error == OK) {
|
||||
_goto_line(p_row);
|
||||
|
||||
|
|
@ -1064,14 +1070,7 @@ void ScriptTextEditor::_lookup_symbol(const String &p_symbol, int p_row, int p_c
|
|||
// Every symbol other than absolute path is relative path so keep this condition at last.
|
||||
String path = _get_absolute_path(p_symbol);
|
||||
if (FileAccess::exists(path)) {
|
||||
List<String> scene_extensions;
|
||||
ResourceLoader::get_recognized_extensions_for_type("PackedScene", &scene_extensions);
|
||||
|
||||
if (scene_extensions.find(path.get_extension())) {
|
||||
EditorNode::get_singleton()->load_scene(path);
|
||||
} else {
|
||||
EditorNode::get_singleton()->load_resource(path);
|
||||
}
|
||||
EditorNode::get_singleton()->load_scene_or_resource(path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1228,8 +1227,8 @@ String ScriptTextEditor::_get_absolute_path(const String &rel_path) {
|
|||
return path.replace("///", "//").simplify_path();
|
||||
}
|
||||
|
||||
void ScriptTextEditor::update_toggle_scripts_button() {
|
||||
code_editor->update_toggle_scripts_button();
|
||||
void ScriptTextEditor::update_toggle_files_button() {
|
||||
code_editor->update_toggle_files_button();
|
||||
}
|
||||
|
||||
void ScriptTextEditor::_update_connected_methods() {
|
||||
|
|
@ -1278,12 +1277,12 @@ void ScriptTextEditor::_update_connected_methods() {
|
|||
int line = -1;
|
||||
|
||||
for (int j = 0; j < functions.size(); j++) {
|
||||
String name = functions[j].get_slice(":", 0);
|
||||
String name = functions[j].get_slicec(':', 0);
|
||||
if (name == method) {
|
||||
Dictionary line_meta;
|
||||
line_meta["type"] = "connection";
|
||||
line_meta["method"] = method;
|
||||
line = functions[j].get_slice(":", 1).to_int() - 1;
|
||||
line = functions[j].get_slicec(':', 1).to_int() - 1;
|
||||
text_edit->set_line_gutter_metadata(line, connection_gutter, line_meta);
|
||||
text_edit->set_line_gutter_icon(line, connection_gutter, get_parent_control()->get_editor_theme_icon(SNAME("Slot")));
|
||||
text_edit->set_line_gutter_clickable(line, connection_gutter, true);
|
||||
|
|
@ -1318,7 +1317,7 @@ void ScriptTextEditor::_update_connected_methods() {
|
|||
// Add override icons to methods.
|
||||
methods_found.clear();
|
||||
for (int i = 0; i < functions.size(); i++) {
|
||||
String raw_name = functions[i].get_slice(":", 0);
|
||||
String raw_name = functions[i].get_slicec(':', 0);
|
||||
StringName name = StringName(raw_name);
|
||||
if (methods_found.has(name)) {
|
||||
continue;
|
||||
|
|
@ -1364,7 +1363,7 @@ void ScriptTextEditor::_update_connected_methods() {
|
|||
}
|
||||
|
||||
if (!found_base_class.is_empty()) {
|
||||
int line = functions[i].get_slice(":", 1).to_int() - 1;
|
||||
int line = functions[i].get_slicec(':', 1).to_int() - 1;
|
||||
|
||||
Dictionary line_meta = text_edit->get_line_gutter_metadata(line, connection_gutter);
|
||||
if (line_meta.is_empty()) {
|
||||
|
|
@ -1697,7 +1696,7 @@ void ScriptTextEditor::_edit_option(int p_op) {
|
|||
} break;
|
||||
case DEBUG_GOTO_NEXT_BREAKPOINT: {
|
||||
PackedInt32Array bpoints = tx->get_breakpointed_lines();
|
||||
if (bpoints.size() <= 0) {
|
||||
if (bpoints.is_empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -1712,7 +1711,7 @@ void ScriptTextEditor::_edit_option(int p_op) {
|
|||
} break;
|
||||
case DEBUG_GOTO_PREV_BREAKPOINT: {
|
||||
PackedInt32Array bpoints = tx->get_breakpointed_lines();
|
||||
if (bpoints.size() <= 0) {
|
||||
if (bpoints.is_empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -1806,8 +1805,8 @@ void ScriptTextEditor::_notification(int p_what) {
|
|||
break;
|
||||
}
|
||||
if (is_visible_in_tree()) {
|
||||
_update_warnings();
|
||||
_update_errors();
|
||||
_update_warnings();
|
||||
}
|
||||
[[fallthrough]];
|
||||
case NOTIFICATION_ENTER_TREE: {
|
||||
|
|
@ -1928,8 +1927,14 @@ static String _quote_drop_data(const String &str) {
|
|||
return escaped.quote(using_single_quotes ? "'" : "\"");
|
||||
}
|
||||
|
||||
static String _get_dropped_resource_line(const Ref<Resource> &p_resource, bool p_create_field) {
|
||||
const String &path = p_resource->get_path();
|
||||
static String _get_dropped_resource_line(const Ref<Resource> &p_resource, bool p_create_field, bool p_allow_uid) {
|
||||
String path = p_resource->get_path();
|
||||
if (p_allow_uid) {
|
||||
ResourceUID::ID id = ResourceLoader::get_resource_uid(path);
|
||||
if (id != ResourceUID::INVALID_ID) {
|
||||
path = ResourceUID::get_singleton()->id_to_text(id);
|
||||
}
|
||||
}
|
||||
const bool is_script = ClassDB::is_parent_class(p_resource->get_class(), "Script");
|
||||
|
||||
if (!p_create_field) {
|
||||
|
|
@ -1938,7 +1943,7 @@ static String _get_dropped_resource_line(const Ref<Resource> &p_resource, bool p
|
|||
|
||||
String variable_name = p_resource->get_name();
|
||||
if (variable_name.is_empty()) {
|
||||
variable_name = path.get_file().get_basename();
|
||||
variable_name = p_resource->get_path().get_file().get_basename();
|
||||
}
|
||||
|
||||
if (is_script) {
|
||||
|
|
@ -1953,7 +1958,7 @@ void ScriptTextEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data
|
|||
Dictionary d = p_data;
|
||||
|
||||
CodeEdit *te = code_editor->get_text_editor();
|
||||
Point2i pos = te->get_line_column_at_pos(p_point);
|
||||
Point2i pos = (p_point == Vector2(Math::INF, Math::INF)) ? Point2i(te->get_caret_line(0), te->get_caret_column(0)) : te->get_line_column_at_pos(p_point);
|
||||
int drop_at_line = pos.y;
|
||||
int drop_at_column = pos.x;
|
||||
int selection_index = te->get_selection_at_line_column(drop_at_line, drop_at_column);
|
||||
|
|
@ -1969,6 +1974,7 @@ void ScriptTextEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data
|
|||
String text_to_drop;
|
||||
|
||||
const bool drop_modifier_pressed = Input::get_singleton()->is_key_pressed(Key::CMD_OR_CTRL);
|
||||
const bool allow_uid = Input::get_singleton()->is_key_pressed(Key::SHIFT) != bool(EDITOR_GET("text_editor/behavior/files/drop_preload_resources_as_uid"));
|
||||
const String &line = te->get_line(drop_at_line);
|
||||
const bool is_empty_line = line_will_be_empty || line.is_empty() || te->get_first_non_whitespace_column(drop_at_line) == line.length();
|
||||
|
||||
|
|
@ -1991,7 +1997,7 @@ void ScriptTextEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data
|
|||
String warning = TTR("Preloading internal resources is not supported.");
|
||||
EditorToaster::get_singleton()->popup_str(warning, EditorToaster::SEVERITY_ERROR);
|
||||
} else {
|
||||
text_to_drop = _get_dropped_resource_line(resource, is_empty_line);
|
||||
text_to_drop = _get_dropped_resource_line(resource, is_empty_line, allow_uid);
|
||||
}
|
||||
} else {
|
||||
text_to_drop = _quote_drop_data(path);
|
||||
|
|
@ -2010,7 +2016,7 @@ void ScriptTextEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data
|
|||
resource.instantiate();
|
||||
resource->set_path_cache(path);
|
||||
}
|
||||
parts.append(_get_dropped_resource_line(resource, is_empty_line));
|
||||
parts.append(_get_dropped_resource_line(resource, is_empty_line, allow_uid));
|
||||
} else {
|
||||
parts.append(_quote_drop_data(path));
|
||||
}
|
||||
|
|
@ -2242,7 +2248,7 @@ void ScriptTextEditor::_text_edit_gui_input(const Ref<InputEvent> &ev) {
|
|||
switch (expression_pattern) {
|
||||
case RGBA_PARAMETER: {
|
||||
color_args = line.substr(begin, end - begin);
|
||||
String stripped = color_args.replace(" ", "").replace("\t", "").replace("(", "").replace(")", "");
|
||||
String stripped = color_args.remove_chars(" \t()");
|
||||
PackedFloat64Array color = stripped.split_floats(",");
|
||||
if (color.size() > 2) {
|
||||
float alpha = color.size() > 3 ? color[3] : 1.0f;
|
||||
|
|
@ -2254,7 +2260,7 @@ void ScriptTextEditor::_text_edit_gui_input(const Ref<InputEvent> &ev) {
|
|||
end = line.length();
|
||||
}
|
||||
color_args = line.substr(begin, end - begin);
|
||||
const String color_name = color_args.replace(" ", "").replace("\t", "").replace(".", "");
|
||||
const String color_name = color_args.remove_chars(" \t.");
|
||||
const int color_index = Color::find_named_color(color_name);
|
||||
if (0 <= color_index) {
|
||||
const Color color_constant = Color::get_named_color(color_index);
|
||||
|
|
@ -2376,7 +2382,7 @@ void ScriptTextEditor::_enable_code_editor() {
|
|||
code_editor->get_text_editor()->connect("gutter_removed", callable_mp(this, &ScriptTextEditor::_update_gutter_indexes));
|
||||
code_editor->get_text_editor()->connect("gutter_clicked", callable_mp(this, &ScriptTextEditor::_gutter_clicked));
|
||||
code_editor->get_text_editor()->connect(SceneStringName(gui_input), callable_mp(this, &ScriptTextEditor::_text_edit_gui_input));
|
||||
code_editor->show_toggle_scripts_button();
|
||||
code_editor->show_toggle_files_button();
|
||||
_update_gutter_indexes();
|
||||
|
||||
editor_box->add_child(warnings_panel);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue