Use get_slicec instead of get_slice for single character splitters

This commit is contained in:
A Thousand Ships 2024-11-16 17:16:07 +01:00
parent b5bdb88062
commit 466590d0ec
No known key found for this signature in database
GPG key ID: DEFC5A5B1306947D
58 changed files with 210 additions and 210 deletions

View file

@ -503,7 +503,7 @@ void AnimationPlayerEditor::_animation_rename() {
// Remove library prefix if present.
if (selected_name.contains_char('/')) {
selected_name = selected_name.get_slice("/", 1);
selected_name = selected_name.get_slicec('/', 1);
}
name_dialog->set_title(TTR("Rename Animation"));
@ -536,7 +536,7 @@ void AnimationPlayerEditor::_animation_remove_confirmed() {
// For names of form lib_name/anim_name, remove library name prefix.
if (current.contains_char('/')) {
current = current.get_slice("/", 1);
current = current.get_slicec('/', 1);
}
EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
undo_redo->create_action(TTR("Remove Animation"));
@ -625,8 +625,8 @@ void AnimationPlayerEditor::_animation_name_edited() {
// Extract library prefix if present.
String new_library_prefix = "";
if (current.contains_char('/')) {
new_library_prefix = current.get_slice("/", 0) + "/";
current = current.get_slice("/", 1);
new_library_prefix = current.get_slicec('/', 0) + "/";
current = current.get_slicec('/', 1);
}
undo_redo->create_action(TTR("Rename Animation"));
@ -1340,7 +1340,7 @@ void AnimationPlayerEditor::_animation_duplicate() {
if (new_name.contains_char('/')) {
// Discard library prefix.
new_name = new_name.get_slice("/", 1);
new_name = new_name.get_slicec('/', 1);
}
_update_name_dialog_library_dropdown();

View file

@ -158,7 +158,7 @@ void EditorPropertyFontMetaOverride::_notification(int p_what) {
void EditorPropertyFontMetaOverride::_property_changed(const String &p_property, const Variant &p_value, const String &p_name, bool p_changing) {
if (p_property.begins_with("keys")) {
Dictionary dict = object->get_dict();
String key = p_property.get_slice("/", 1);
String key = p_property.get_slicec('/', 1);
dict[key] = (bool)p_value;
emit_changed(get_edited_property(), dict, "", true);
@ -378,7 +378,7 @@ EditorPropertyFontMetaOverride::EditorPropertyFontMetaOverride(bool p_script) {
void EditorPropertyOTVariation::_property_changed(const String &p_property, const Variant &p_value, const String &p_name, bool p_changing) {
if (p_property.begins_with("keys")) {
Dictionary dict = object->get_dict();
int key = p_property.get_slice("/", 1).to_int();
int key = p_property.get_slicec('/', 1).to_int();
dict[key] = (int)p_value;
emit_changed(get_edited_property(), dict, "", true);
@ -561,7 +561,7 @@ void EditorPropertyOTFeatures::_notification(int p_what) {
void EditorPropertyOTFeatures::_property_changed(const String &p_property, const Variant &p_value, const String &p_name, bool p_changing) {
if (p_property.begins_with("keys")) {
Dictionary dict = object->get_dict();
int key = p_property.get_slice("/", 1).to_int();
int key = p_property.get_slicec('/', 1).to_int();
dict[key] = (int)p_value;
emit_changed(get_edited_property(), dict, "", true);

View file

@ -239,7 +239,7 @@ void MeshLibraryEditor::_menu_cbk(int p_option) {
case MENU_OPTION_REMOVE_ITEM: {
String p = InspectorDock::get_inspector_singleton()->get_selected_path();
if (p.begins_with("item") && p.get_slice_count("/") >= 2) {
to_erase = p.get_slice("/", 1).to_int();
to_erase = p.get_slicec('/', 1).to_int();
cd_remove->set_text(vformat(TTR("Remove item %d?"), to_erase));
cd_remove->popup_centered(Size2(300, 60));
}

View file

@ -156,7 +156,7 @@ Error PackedSceneEditorTranslationParserPlugin::parse_file(const String &p_path,
// Extract FileDialog's filters property with values in format "*.png ; PNG Images","*.gd ; GDScript Files".
Vector<String> str_values = property_value;
for (int k = 0; k < str_values.size(); k++) {
String desc = str_values[k].get_slice(";", 1).strip_edges();
String desc = str_values[k].get_slicec(';', 1).strip_edges();
if (!desc.is_empty()) {
r_translations->push_back({ desc });
}

View file

@ -202,8 +202,8 @@ void EditorStandardSyntaxHighlighter::_update_cache() {
List<String> comments;
scr_lang->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();
highlighter->add_color_region(beg, end, comment_color, end.is_empty());
}
@ -212,8 +212,8 @@ void EditorStandardSyntaxHighlighter::_update_cache() {
List<String> doc_comments;
scr_lang->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();
highlighter->add_color_region(beg, end, doc_comment_color, end.is_empty());
}
@ -222,8 +222,8 @@ void EditorStandardSyntaxHighlighter::_update_cache() {
List<String> strings;
scr_lang->get_string_delimiters(&strings);
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();
highlighter->add_color_region(beg, end, string_color, end.is_empty());
}
}
@ -443,7 +443,7 @@ void ScriptEditorQuickOpen::_confirmed() {
if (!ti) {
return;
}
int line = ti->get_text(0).get_slice(":", 1).to_int();
int line = ti->get_text(0).get_slicec(':', 1).to_int();
emit_signal(SNAME("goto_line"), line - 1);
hide();
@ -2111,10 +2111,10 @@ void ScriptEditor::_update_members_overview() {
for (int i = 0; i < functions.size(); i++) {
String filter = filter_methods->get_text();
String name = functions[i].get_slice(":", 0);
String name = functions[i].get_slicec(':', 0);
if (filter.is_empty() || filter.is_subsequence_ofn(name)) {
members_overview->add_item(name);
members_overview->set_item_metadata(-1, functions[i].get_slice(":", 1).to_int() - 1);
members_overview->set_item_metadata(-1, functions[i].get_slicec(':', 1).to_int() - 1);
}
}
@ -3681,7 +3681,7 @@ void ScriptEditor::_help_class_open(const String &p_class) {
}
void ScriptEditor::_help_class_goto(const String &p_desc) {
String cname = p_desc.get_slice(":", 1);
String cname = p_desc.get_slicec(':', 1);
if (_help_tab_goto(cname, p_desc)) {
return;
@ -3988,7 +3988,7 @@ void ScriptEditor::_on_find_in_files_result_selected(const String &fpath, int li
// Found the end of the script.
scr_id = line.get_slice(scr_header, 1);
scr_id = scr_id.get_slice("\"", 0);
scr_id = scr_id.get_slicec('"', 0);
scr_start_line = l + 1;
int scr_line_count = 0;

View file

@ -228,8 +228,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 +244,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 +256,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)) {
@ -1278,12 +1278,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 +1318,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 +1364,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()) {