From 6631f66c2a9d54dc80d57df60376c84ce1252d08 Mon Sep 17 00:00:00 2001 From: reduz Date: Sat, 17 Jul 2021 18:22:52 -0300 Subject: Optimize StringName usage * Added a new macro SNAME() that constructs and caches a local stringname. * Subsequent usages use the cached version. * Since these use a global static variable, a second refcounter of static usages need to be kept for cleanup time. * Replaced all theme usages by this new macro. * Replace all signal emission usages by this new macro. * Replace all call_deferred usages by this new macro. This is part of ongoing work to optimize GUI and the editor. --- modules/csg/csg_shape.cpp | 2 +- modules/enet/enet_multiplayer_peer.cpp | 16 +- .../gdnative/gdnative_library_editor_plugin.cpp | 24 +-- modules/gdscript/editor/gdscript_highlighter.cpp | 2 +- modules/gdscript/gdscript_function.cpp | 4 +- .../language_server/gdscript_text_document.cpp | 4 +- modules/gridmap/grid_map.cpp | 2 +- modules/gridmap/grid_map_editor_plugin.cpp | 8 +- modules/mono/editor/editor_internal_calls.cpp | 2 +- modules/navigation/godot_navigation_server.cpp | 2 +- .../navigation/navigation_mesh_editor_plugin.cpp | 4 +- modules/opensimplex/noise_texture.cpp | 4 +- modules/visual_script/visual_script.cpp | 4 +- modules/visual_script/visual_script_editor.cpp | 198 ++++++++++----------- modules/visual_script/visual_script_nodes.cpp | 2 +- .../visual_script_property_selector.cpp | 66 +++---- modules/webrtc/webrtc_multiplayer_peer.cpp | 12 +- modules/webrtc/webrtc_peer_connection_js.cpp | 6 +- modules/websocket/websocket_client.cpp | 14 +- modules/websocket/websocket_multiplayer_peer.cpp | 8 +- modules/websocket/websocket_server.cpp | 12 +- modules/webxr/webxr_interface_js.cpp | 12 +- 22 files changed, 204 insertions(+), 204 deletions(-) (limited to 'modules') diff --git a/modules/csg/csg_shape.cpp b/modules/csg/csg_shape.cpp index fd8b213293..53424f2cfd 100644 --- a/modules/csg/csg_shape.cpp +++ b/modules/csg/csg_shape.cpp @@ -140,7 +140,7 @@ void CSGShape3D::_make_dirty() { if (parent) { parent->_make_dirty(); } else if (!dirty) { - call_deferred("_update_shape"); + call_deferred(SNAME("_update_shape")); } dirty = true; diff --git a/modules/enet/enet_multiplayer_peer.cpp b/modules/enet/enet_multiplayer_peer.cpp index a9726426ad..b4ca93f4d9 100644 --- a/modules/enet/enet_multiplayer_peer.cpp +++ b/modules/enet/enet_multiplayer_peer.cpp @@ -249,7 +249,7 @@ void ENetMultiplayerPeer::poll() { connection_status = CONNECTION_CONNECTED; // If connecting, this means it connected to something! - emit_signal("peer_connected", *new_id); + emit_signal(SNAME("peer_connected"), *new_id); if (server) { // Do not notify other peers when server_relay is disabled. @@ -274,7 +274,7 @@ void ENetMultiplayerPeer::poll() { enet_peer_send(E->get(), SYSCH_CONFIG, packet); } } else { - emit_signal("connection_succeeded"); + emit_signal(SNAME("connection_succeeded")); } } break; @@ -285,7 +285,7 @@ void ENetMultiplayerPeer::poll() { if (!id) { if (!server) { - emit_signal("connection_failed"); + emit_signal(SNAME("connection_failed")); } // Never fully connected. break; @@ -293,7 +293,7 @@ void ENetMultiplayerPeer::poll() { if (!server) { // Client just disconnected from server. - emit_signal("server_disconnected"); + emit_signal(SNAME("server_disconnected")); close_connection(); return; } else if (server_relay) { @@ -310,7 +310,7 @@ void ENetMultiplayerPeer::poll() { } } - emit_signal("peer_disconnected", *id); + emit_signal(SNAME("peer_disconnected"), *id); peer_map.erase(*id); memdelete(id); } break; @@ -328,12 +328,12 @@ void ENetMultiplayerPeer::poll() { switch (msg) { case SYSMSG_ADD_PEER: { peer_map[id] = nullptr; - emit_signal("peer_connected", id); + emit_signal(SNAME("peer_connected"), id); } break; case SYSMSG_REMOVE_PEER: { peer_map.erase(id); - emit_signal("peer_disconnected", id); + emit_signal(SNAME("peer_disconnected"), id); } break; } @@ -491,7 +491,7 @@ void ENetMultiplayerPeer::disconnect_peer(int p_peer, bool now) { memdelete(id); } - emit_signal("peer_disconnected", p_peer); + emit_signal(SNAME("peer_disconnected"), p_peer); peer_map.erase(p_peer); } else { enet_peer_disconnect_later(peer_map[p_peer], 0); diff --git a/modules/gdnative/gdnative_library_editor_plugin.cpp b/modules/gdnative/gdnative_library_editor_plugin.cpp index bdbf151393..f965bcd014 100644 --- a/modules/gdnative/gdnative_library_editor_plugin.cpp +++ b/modules/gdnative/gdnative_library_editor_plugin.cpp @@ -74,9 +74,9 @@ void GDNativeLibraryEditor::_update_tree() { platform->set_text(0, E->get().name); platform->set_metadata(0, E->get().library_extension); - platform->set_custom_bg_color(0, get_theme_color("prop_category", "Editor")); - platform->set_custom_bg_color(1, get_theme_color("prop_category", "Editor")); - platform->set_custom_bg_color(2, get_theme_color("prop_category", "Editor")); + platform->set_custom_bg_color(0, get_theme_color(SNAME("prop_category"), SNAME("Editor"))); + platform->set_custom_bg_color(1, get_theme_color(SNAME("prop_category"), SNAME("Editor"))); + platform->set_custom_bg_color(2, get_theme_color(SNAME("prop_category"), SNAME("Editor"))); platform->set_selectable(0, false); platform->set_expand_right(0, true); @@ -87,31 +87,31 @@ void GDNativeLibraryEditor::_update_tree() { bit->set_text(0, it->get()); bit->set_metadata(0, target); bit->set_selectable(0, false); - bit->set_custom_bg_color(0, get_theme_color("prop_subsection", "Editor")); + bit->set_custom_bg_color(0, get_theme_color(SNAME("prop_subsection"), SNAME("Editor"))); - bit->add_button(1, get_theme_icon("Folder", "EditorIcons"), BUTTON_SELECT_LIBRARY, false, TTR("Select the dynamic library for this entry")); + bit->add_button(1, get_theme_icon(SNAME("Folder"), SNAME("EditorIcons")), BUTTON_SELECT_LIBRARY, false, TTR("Select the dynamic library for this entry")); String file = entry_configs[target].library; if (!file.is_empty()) { - bit->add_button(1, get_theme_icon("Clear", "EditorIcons"), BUTTON_CLEAR_LIBRARY, false, TTR("Clear")); + bit->add_button(1, get_theme_icon(SNAME("Clear"), SNAME("EditorIcons")), BUTTON_CLEAR_LIBRARY, false, TTR("Clear")); } bit->set_text(1, file); - bit->add_button(2, get_theme_icon("Folder", "EditorIcons"), BUTTON_SELECT_DEPENDENCES, false, TTR("Select dependencies of the library for this entry")); + bit->add_button(2, get_theme_icon(SNAME("Folder"), SNAME("EditorIcons")), BUTTON_SELECT_DEPENDENCES, false, TTR("Select dependencies of the library for this entry")); Array files = entry_configs[target].dependencies; if (files.size()) { - bit->add_button(2, get_theme_icon("Clear", "EditorIcons"), BUTTON_CLEAR_DEPENDENCES, false, TTR("Clear")); + bit->add_button(2, get_theme_icon(SNAME("Clear"), SNAME("EditorIcons")), BUTTON_CLEAR_DEPENDENCES, false, TTR("Clear")); } bit->set_text(2, Variant(files)); - bit->add_button(3, get_theme_icon("MoveUp", "EditorIcons"), BUTTON_MOVE_UP, false, TTR("Move Up")); - bit->add_button(3, get_theme_icon("MoveDown", "EditorIcons"), BUTTON_MOVE_DOWN, false, TTR("Move Down")); - bit->add_button(3, get_theme_icon("Remove", "EditorIcons"), BUTTON_ERASE_ENTRY, false, TTR("Remove current entry")); + bit->add_button(3, get_theme_icon(SNAME("MoveUp"), SNAME("EditorIcons")), BUTTON_MOVE_UP, false, TTR("Move Up")); + bit->add_button(3, get_theme_icon(SNAME("MoveDown"), SNAME("EditorIcons")), BUTTON_MOVE_DOWN, false, TTR("Move Down")); + bit->add_button(3, get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), BUTTON_ERASE_ENTRY, false, TTR("Remove current entry")); } TreeItem *new_arch = tree->create_item(platform); new_arch->set_text(0, TTR("Double click to create a new entry")); new_arch->set_text_align(0, TreeItem::ALIGN_CENTER); - new_arch->set_custom_color(0, get_theme_color("accent_color", "Editor")); + new_arch->set_custom_color(0, get_theme_color(SNAME("accent_color"), SNAME("Editor"))); new_arch->set_expand_right(0, true); new_arch->set_metadata(1, E->key()); diff --git a/modules/gdscript/editor/gdscript_highlighter.cpp b/modules/gdscript/editor/gdscript_highlighter.cpp index 79ec9eb65f..9a4c22f49f 100644 --- a/modules/gdscript/editor/gdscript_highlighter.cpp +++ b/modules/gdscript/editor/gdscript_highlighter.cpp @@ -448,7 +448,7 @@ void GDScriptSyntaxHighlighter::_update_cache() { color_regions.clear(); color_region_cache.clear(); - font_color = text_edit->get_theme_color("font_color"); + font_color = text_edit->get_theme_color(SNAME("font_color")); symbol_color = EDITOR_GET("text_editor/highlighting/symbol_color"); function_color = EDITOR_GET("text_editor/highlighting/function_color"); number_color = EDITOR_GET("text_editor/highlighting/number_color"); diff --git a/modules/gdscript/gdscript_function.cpp b/modules/gdscript/gdscript_function.cpp index 78399114a5..f300d5a2c9 100644 --- a/modules/gdscript/gdscript_function.cpp +++ b/modules/gdscript/gdscript_function.cpp @@ -262,9 +262,9 @@ Variant GDScriptFunctionState::resume(const Variant &p_arg) { if (completed) { if (first_state.is_valid()) { - first_state->emit_signal("completed", ret); + first_state->emit_signal(SNAME("completed"), ret); } else { - emit_signal("completed", ret); + emit_signal(SNAME("completed"), ret); } #ifdef DEBUG_ENABLED diff --git a/modules/gdscript/language_server/gdscript_text_document.cpp b/modules/gdscript/language_server/gdscript_text_document.cpp index 59d2e6c8fa..55aff618aa 100644 --- a/modules/gdscript/language_server/gdscript_text_document.cpp +++ b/modules/gdscript/language_server/gdscript_text_document.cpp @@ -373,7 +373,7 @@ Variant GDScriptTextDocument::declaration(const Dictionary &p_params) { id = "class_global:" + symbol->native_class + ":" + symbol->name; break; } - call_deferred("show_native_symbol_in_editor", id); + call_deferred(SNAME("show_native_symbol_in_editor"), id); } else { notify_client_show_symbol(symbol); } @@ -410,7 +410,7 @@ void GDScriptTextDocument::sync_script_content(const String &p_path, const Strin } void GDScriptTextDocument::show_native_symbol_in_editor(const String &p_symbol_id) { - ScriptEditor::get_singleton()->call_deferred("_help_class_goto", p_symbol_id); + ScriptEditor::get_singleton()->call_deferred(SNAME("_help_class_goto"), p_symbol_id); DisplayServer::get_singleton()->window_move_to_foreground(); } diff --git a/modules/gridmap/grid_map.cpp b/modules/gridmap/grid_map.cpp index e9134b32d9..0cd41133f1 100644 --- a/modules/gridmap/grid_map.cpp +++ b/modules/gridmap/grid_map.cpp @@ -221,7 +221,7 @@ void GridMap::set_cell_size(const Vector3 &p_size) { ERR_FAIL_COND(p_size.x < 0.001 || p_size.y < 0.001 || p_size.z < 0.001); cell_size = p_size; _recreate_octant_data(); - emit_signal("cell_size_changed", cell_size); + emit_signal(SNAME("cell_size_changed"), cell_size); } Vector3 GridMap::get_cell_size() const { diff --git a/modules/gridmap/grid_map_editor_plugin.cpp b/modules/gridmap/grid_map_editor_plugin.cpp index d894425ce8..046f8c0adb 100644 --- a/modules/gridmap/grid_map_editor_plugin.cpp +++ b/modules/gridmap/grid_map_editor_plugin.cpp @@ -1077,8 +1077,8 @@ void GridMapEditor::_notification(int p_what) { } break; case NOTIFICATION_THEME_CHANGED: { - options->set_icon(get_theme_icon("GridMap", "EditorIcons")); - search_box->set_right_icon(get_theme_icon("Search", "EditorIcons")); + options->set_icon(get_theme_icon(SNAME("GridMap"), SNAME("EditorIcons"))); + search_box->set_right_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); } break; case NOTIFICATION_APPLICATION_FOCUS_OUT: { @@ -1239,7 +1239,7 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) { mode_thumbnail->set_flat(true); mode_thumbnail->set_toggle_mode(true); mode_thumbnail->set_pressed(true); - mode_thumbnail->set_icon(p_editor->get_gui_base()->get_theme_icon("FileThumbnail", "EditorIcons")); + mode_thumbnail->set_icon(p_editor->get_gui_base()->get_theme_icon(SNAME("FileThumbnail"), SNAME("EditorIcons"))); hb->add_child(mode_thumbnail); mode_thumbnail->connect("pressed", callable_mp(this, &GridMapEditor::_set_display_mode), varray(DISPLAY_THUMBNAIL)); @@ -1247,7 +1247,7 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) { mode_list->set_flat(true); mode_list->set_toggle_mode(true); mode_list->set_pressed(false); - mode_list->set_icon(p_editor->get_gui_base()->get_theme_icon("FileList", "EditorIcons")); + mode_list->set_icon(p_editor->get_gui_base()->get_theme_icon(SNAME("FileList"), SNAME("EditorIcons"))); hb->add_child(mode_list); mode_list->connect("pressed", callable_mp(this, &GridMapEditor::_set_display_mode), varray(DISPLAY_LIST)); diff --git a/modules/mono/editor/editor_internal_calls.cpp b/modules/mono/editor/editor_internal_calls.cpp index 21efd58938..8164f459ca 100644 --- a/modules/mono/editor/editor_internal_calls.cpp +++ b/modules/mono/editor/editor_internal_calls.cpp @@ -241,7 +241,7 @@ MonoBoolean godot_icall_Internal_IsAssembliesReloadingNeeded() { void godot_icall_Internal_ReloadAssemblies(MonoBoolean p_soft_reload) { #ifdef GD_MONO_HOT_RELOAD - _GodotSharp::get_singleton()->call_deferred("_reload_assemblies", (bool)p_soft_reload); + _GodotSharp::get_singleton()->call_deferred(SNAME("_reload_assemblies"), (bool)p_soft_reload); #endif } diff --git a/modules/navigation/godot_navigation_server.cpp b/modules/navigation/godot_navigation_server.cpp index df003cfe6f..fd965674d6 100644 --- a/modules/navigation/godot_navigation_server.cpp +++ b/modules/navigation/godot_navigation_server.cpp @@ -536,7 +536,7 @@ void GodotNavigationServer::process(real_t p_delta_time) { // Emit a signal if a map changed. const uint32_t new_map_update_id = active_maps[i]->get_map_update_id(); if (new_map_update_id != active_maps_update_id[i]) { - emit_signal("map_changed", active_maps[i]->get_self()); + emit_signal(SNAME("map_changed"), active_maps[i]->get_self()); active_maps_update_id[i] = new_map_update_id; } } diff --git a/modules/navigation/navigation_mesh_editor_plugin.cpp b/modules/navigation/navigation_mesh_editor_plugin.cpp index aa9248d2a1..8f4203e260 100644 --- a/modules/navigation/navigation_mesh_editor_plugin.cpp +++ b/modules/navigation/navigation_mesh_editor_plugin.cpp @@ -47,8 +47,8 @@ void NavigationMeshEditor::_node_removed(Node *p_node) { void NavigationMeshEditor::_notification(int p_option) { if (p_option == NOTIFICATION_ENTER_TREE) { - button_bake->set_icon(get_theme_icon("Bake", "EditorIcons")); - button_reset->set_icon(get_theme_icon("Reload", "EditorIcons")); + button_bake->set_icon(get_theme_icon(SNAME("Bake"), SNAME("EditorIcons"))); + button_reset->set_icon(get_theme_icon(SNAME("Reload"), SNAME("EditorIcons"))); } } diff --git a/modules/opensimplex/noise_texture.cpp b/modules/opensimplex/noise_texture.cpp index 66c52ffbf9..9db3f3d5fd 100644 --- a/modules/opensimplex/noise_texture.cpp +++ b/modules/opensimplex/noise_texture.cpp @@ -109,7 +109,7 @@ void NoiseTexture::_thread_done(const Ref &p_image) { void NoiseTexture::_thread_function(void *p_ud) { NoiseTexture *tex = (NoiseTexture *)p_ud; - tex->call_deferred("_thread_done", tex->_generate_texture()); + tex->call_deferred(SNAME("_thread_done"), tex->_generate_texture()); } void NoiseTexture::_queue_update() { @@ -118,7 +118,7 @@ void NoiseTexture::_queue_update() { } update_queued = true; - call_deferred("_update_texture"); + call_deferred(SNAME("_update_texture")); } Ref NoiseTexture::_generate_texture() { diff --git a/modules/visual_script/visual_script.cpp b/modules/visual_script/visual_script.cpp index c4b3f9ba44..0de39512ae 100644 --- a/modules/visual_script/visual_script.cpp +++ b/modules/visual_script/visual_script.cpp @@ -46,7 +46,7 @@ bool VisualScriptNode::is_breakpoint() const { } void VisualScriptNode::ports_changed_notify() { - emit_signal("ports_changed"); + emit_signal(SNAME("ports_changed")); } void VisualScriptNode::set_default_input_value(int p_port, const Variant &p_value) { @@ -264,7 +264,7 @@ void VisualScript::_node_ports_changed(int p_id) { #ifdef TOOLS_ENABLED set_edited(true); // Something changed, let's set as edited. - emit_signal("node_ports_changed", p_id); + emit_signal(SNAME("node_ports_changed"), p_id); #endif } diff --git a/modules/visual_script/visual_script_editor.cpp b/modules/visual_script/visual_script_editor.cpp index 8712bfa06b..a0a75642ee 100644 --- a/modules/visual_script/visual_script_editor.cpp +++ b/modules/visual_script/visual_script_editor.cpp @@ -62,7 +62,7 @@ protected: void _sig_changed() { notify_property_list_changed(); - emit_signal("changed"); + emit_signal(SNAME("changed")); } bool _set(const StringName &p_name, const Variant &p_value) { @@ -196,10 +196,10 @@ protected: void _var_changed() { notify_property_list_changed(); - emit_signal("changed"); + emit_signal(SNAME("changed")); } void _var_value_changed() { - emit_signal("changed"); + emit_signal(SNAME("changed")); } bool _set(const StringName &p_name, const Variant &p_value) { @@ -611,41 +611,41 @@ void VisualScriptEditor::_update_graph(int p_only_id) { select_func_text->hide(); Ref type_icons[Variant::VARIANT_MAX] = { - Control::get_theme_icon("Variant", "EditorIcons"), - Control::get_theme_icon("bool", "EditorIcons"), - Control::get_theme_icon("int", "EditorIcons"), - Control::get_theme_icon("float", "EditorIcons"), - Control::get_theme_icon("String", "EditorIcons"), - Control::get_theme_icon("Vector2", "EditorIcons"), - Control::get_theme_icon("Vector2i", "EditorIcons"), - Control::get_theme_icon("Rect2", "EditorIcons"), - Control::get_theme_icon("Rect2i", "EditorIcons"), - Control::get_theme_icon("Vector3", "EditorIcons"), - Control::get_theme_icon("Vector3i", "EditorIcons"), - Control::get_theme_icon("Transform2D", "EditorIcons"), - Control::get_theme_icon("Plane", "EditorIcons"), - Control::get_theme_icon("Quaternion", "EditorIcons"), - Control::get_theme_icon("AABB", "EditorIcons"), - Control::get_theme_icon("Basis", "EditorIcons"), - Control::get_theme_icon("Transform3D", "EditorIcons"), - Control::get_theme_icon("Color", "EditorIcons"), - Control::get_theme_icon("NodePath", "EditorIcons"), - Control::get_theme_icon("RID", "EditorIcons"), - Control::get_theme_icon("MiniObject", "EditorIcons"), - Control::get_theme_icon("Callable", "EditorIcons"), - Control::get_theme_icon("Signal", "EditorIcons"), - Control::get_theme_icon("Dictionary", "EditorIcons"), - Control::get_theme_icon("Array", "EditorIcons"), - Control::get_theme_icon("PackedByteArray", "EditorIcons"), - Control::get_theme_icon("PackedInt32Array", "EditorIcons"), - Control::get_theme_icon("PackedFloat32Array", "EditorIcons"), - Control::get_theme_icon("PackedStringArray", "EditorIcons"), - Control::get_theme_icon("PackedVector2Array", "EditorIcons"), - Control::get_theme_icon("PackedVector3Array", "EditorIcons"), - Control::get_theme_icon("PackedColorArray", "EditorIcons") + Control::get_theme_icon(SNAME("Variant"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("bool"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("int"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("float"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("String"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("Vector2"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("Vector2i"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("Rect2"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("Rect2i"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("Vector3"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("Vector3i"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("Transform2D"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("Plane"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("Quaternion"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("AABB"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("Basis"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("Transform3D"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("Color"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("NodePath"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("RID"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("MiniObject"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("Callable"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("Signal"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("Dictionary"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("Array"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("PackedByteArray"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("PackedInt32Array"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("PackedFloat32Array"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("PackedStringArray"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("PackedVector2Array"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("PackedVector3Array"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("PackedColorArray"), SNAME("EditorIcons")) }; - Ref seq_port = Control::get_theme_icon("VisualShaderPort", "EditorIcons"); + Ref seq_port = Control::get_theme_icon(SNAME("VisualShaderPort"), SNAME("EditorIcons")); List node_ids; script->get_node_list(&node_ids); @@ -711,7 +711,7 @@ void VisualScriptEditor::_update_graph(int p_only_id) { LineEdit *line_edit = memnew(LineEdit); line_edit->set_text(node->get_text()); line_edit->set_expand_to_text_length_enabled(true); - line_edit->add_theme_font_override("font", get_theme_font("source", "EditorFonts")); + line_edit->add_theme_font_override("font", get_theme_font(SNAME("source"), SNAME("EditorFonts"))); gnode->add_child(line_edit); line_edit->connect("text_changed", callable_mp(this, &VisualScriptEditor::_expression_text_changed), varray(E->get())); } else { @@ -735,7 +735,7 @@ void VisualScriptEditor::_update_graph(int p_only_id) { if (node_styles.has(node->get_category())) { Ref sbf = node_styles[node->get_category()]; if (gnode->is_comment()) { - sbf = EditorNode::get_singleton()->get_theme_base()->get_theme()->get_stylebox("comment", "GraphNode"); + sbf = EditorNode::get_singleton()->get_theme_base()->get_theme()->get_stylebox(SNAME("comment"), SNAME("GraphNode")); } Color c = sbf->get_border_color(); @@ -748,7 +748,7 @@ void VisualScriptEditor::_update_graph(int p_only_id) { gnode->add_theme_style_override("frame", sbf); } - const Color mono_color = get_theme_color("mono_color", "Editor"); + const Color mono_color = get_theme_color(SNAME("mono_color"), SNAME("Editor")); int slot_idx = 0; @@ -850,7 +850,7 @@ void VisualScriptEditor::_update_graph(int p_only_id) { } Button *rmbtn = memnew(Button); - rmbtn->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("Remove", "EditorIcons")); + rmbtn->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Remove"), SNAME("EditorIcons"))); hbc->add_child(rmbtn); rmbtn->connect("pressed", callable_mp(this, &VisualScriptEditor::_remove_input_port), varray(E->get(), i), CONNECT_DEFERRED); } else { @@ -906,7 +906,7 @@ void VisualScriptEditor::_update_graph(int p_only_id) { if (right_ok) { if (is_vslist) { Button *rmbtn = memnew(Button); - rmbtn->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("Remove", "EditorIcons")); + rmbtn->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Remove"), SNAME("EditorIcons"))); hbc->add_child(rmbtn); rmbtn->connect("pressed", callable_mp(this, &VisualScriptEditor::_remove_output_port), varray(E->get(), i), CONNECT_DEFERRED); @@ -950,7 +950,7 @@ void VisualScriptEditor::_update_graph(int p_only_id) { gnode->add_child(vbc); - bool dark_theme = get_theme_constant("dark_theme", "Editor"); + bool dark_theme = get_theme_constant(SNAME("dark_theme"), SNAME("Editor")); if (i < mixed_seq_ports) { gnode->set_slot(slot_idx, left_ok, left_type, _color_from_type(left_type, dark_theme), true, TYPE_SEQUENCE, mono_color, Ref(), seq_port); } else { @@ -973,7 +973,7 @@ void VisualScriptEditor::_update_graph(int p_only_id) { graph->set_minimap_opacity(graph_minimap_opacity); // Use default_func instead of default_func for now I think that should be good stop gap solution to ensure not breaking anything. - graph->call_deferred("set_scroll_ofs", script->get_scroll() * EDSCALE); + graph->call_deferred(SNAME("set_scroll_ofs"), script->get_scroll() * EDSCALE); updating_graph = false; } @@ -1037,9 +1037,9 @@ void VisualScriptEditor::_update_members() { TreeItem *functions = members->create_item(root); functions->set_selectable(0, false); functions->set_text(0, TTR("Functions:")); - functions->add_button(0, Control::get_theme_icon("Override", "EditorIcons"), 1, false, TTR("Override an existing built-in function.")); - functions->add_button(0, Control::get_theme_icon("Add", "EditorIcons"), 0, false, TTR("Create a new function.")); - functions->set_custom_color(0, Control::get_theme_color("mono_color", "Editor")); + functions->add_button(0, Control::get_theme_icon(SNAME("Override"), SNAME("EditorIcons")), 1, false, TTR("Override an existing built-in function.")); + functions->add_button(0, Control::get_theme_icon(SNAME("Add"), SNAME("EditorIcons")), 0, false, TTR("Create a new function.")); + functions->set_custom_color(0, Control::get_theme_color(SNAME("mono_color"), SNAME("Editor"))); List func_names; script->get_function_list(&func_names); @@ -1049,7 +1049,7 @@ void VisualScriptEditor::_update_members() { ti->set_text(0, E->get()); ti->set_selectable(0, true); ti->set_metadata(0, E->get()); - ti->add_button(0, Control::get_theme_icon("Edit", "EditorIcons"), 0); + ti->add_button(0, Control::get_theme_icon(SNAME("Edit"), SNAME("EditorIcons")), 0); if (selected == E->get()) { ti->select(0); } @@ -1058,42 +1058,42 @@ void VisualScriptEditor::_update_members() { TreeItem *variables = members->create_item(root); variables->set_selectable(0, false); variables->set_text(0, TTR("Variables:")); - variables->add_button(0, Control::get_theme_icon("Add", "EditorIcons"), -1, false, TTR("Create a new variable.")); - variables->set_custom_color(0, Control::get_theme_color("mono_color", "Editor")); + variables->add_button(0, Control::get_theme_icon(SNAME("Add"), SNAME("EditorIcons")), -1, false, TTR("Create a new variable.")); + variables->set_custom_color(0, Control::get_theme_color(SNAME("mono_color"), SNAME("Editor"))); Ref type_icons[Variant::VARIANT_MAX] = { - Control::get_theme_icon("Variant", "EditorIcons"), - Control::get_theme_icon("bool", "EditorIcons"), - Control::get_theme_icon("int", "EditorIcons"), - Control::get_theme_icon("float", "EditorIcons"), - Control::get_theme_icon("String", "EditorIcons"), - Control::get_theme_icon("Vector2", "EditorIcons"), - Control::get_theme_icon("Vector2i", "EditorIcons"), - Control::get_theme_icon("Rect2", "EditorIcons"), - Control::get_theme_icon("Rect2i", "EditorIcons"), - Control::get_theme_icon("Vector3", "EditorIcons"), - Control::get_theme_icon("Vector3i", "EditorIcons"), - Control::get_theme_icon("Transform2D", "EditorIcons"), - Control::get_theme_icon("Plane", "EditorIcons"), - Control::get_theme_icon("Quaternion", "EditorIcons"), - Control::get_theme_icon("AABB", "EditorIcons"), - Control::get_theme_icon("Basis", "EditorIcons"), - Control::get_theme_icon("Transform3D", "EditorIcons"), - Control::get_theme_icon("Color", "EditorIcons"), - Control::get_theme_icon("NodePath", "EditorIcons"), - Control::get_theme_icon("RID", "EditorIcons"), - Control::get_theme_icon("MiniObject", "EditorIcons"), - Control::get_theme_icon("Callable", "EditorIcons"), - Control::get_theme_icon("Signal", "EditorIcons"), - Control::get_theme_icon("Dictionary", "EditorIcons"), - Control::get_theme_icon("Array", "EditorIcons"), - Control::get_theme_icon("PackedByteArray", "EditorIcons"), - Control::get_theme_icon("PackedInt32Array", "EditorIcons"), - Control::get_theme_icon("PackedFloat32Array", "EditorIcons"), - Control::get_theme_icon("PackedStringArray", "EditorIcons"), - Control::get_theme_icon("PackedVector2Array", "EditorIcons"), - Control::get_theme_icon("PackedVector3Array", "EditorIcons"), - Control::get_theme_icon("PackedColorArray", "EditorIcons") + Control::get_theme_icon(SNAME("Variant"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("bool"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("int"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("float"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("String"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("Vector2"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("Vector2i"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("Rect2"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("Rect2i"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("Vector3"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("Vector3i"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("Transform2D"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("Plane"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("Quaternion"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("AABB"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("Basis"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("Transform3D"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("Color"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("NodePath"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("RID"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("MiniObject"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("Callable"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("Signal"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("Dictionary"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("Array"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("PackedByteArray"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("PackedInt32Array"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("PackedFloat32Array"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("PackedStringArray"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("PackedVector2Array"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("PackedVector3Array"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("PackedColorArray"), SNAME("EditorIcons")) }; List var_names; @@ -1117,8 +1117,8 @@ void VisualScriptEditor::_update_members() { TreeItem *_signals = members->create_item(root); _signals->set_selectable(0, false); _signals->set_text(0, TTR("Signals:")); - _signals->add_button(0, Control::get_theme_icon("Add", "EditorIcons"), -1, false, TTR("Create a new signal.")); - _signals->set_custom_color(0, Control::get_theme_color("mono_color", "Editor")); + _signals->add_button(0, Control::get_theme_icon(SNAME("Add"), SNAME("EditorIcons")), -1, false, TTR("Create a new signal.")); + _signals->set_custom_color(0, Control::get_theme_color(SNAME("mono_color"), SNAME("Editor"))); List signal_names; script->get_custom_signal_list(&signal_names); @@ -1135,12 +1135,12 @@ void VisualScriptEditor::_update_members() { String base_type = script->get_instance_base_type(); String icon_type = base_type; - if (!Control::has_theme_icon(base_type, "EditorIcons")) { + if (!Control::has_theme_icon(base_type, SNAME("EditorIcons"))) { icon_type = "Object"; } base_type_select->set_text(base_type); - base_type_select->set_icon(Control::get_theme_icon(icon_type, "EditorIcons")); + base_type_select->set_icon(Control::get_theme_icon(icon_type, SNAME("EditorIcons"))); updating_members = false; } @@ -1366,7 +1366,7 @@ void VisualScriptEditor::_add_func_input() { hbox->add_child(type_box); Button *delete_button = memnew(Button); - delete_button->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("Remove", "EditorIcons")); + delete_button->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Remove"), SNAME("EditorIcons"))); delete_button->set_tooltip(vformat(TTR("Delete input port"))); hbox->add_child(delete_button); @@ -2401,7 +2401,7 @@ void VisualScriptEditor::_draw_color_over_button(Object *obj, Color p_color) { return; } - Ref normal = get_theme_stylebox("normal", "Button"); + Ref normal = get_theme_stylebox(SNAME("normal"), SNAME("Button")); button->draw_rect(Rect2(normal->get_offset(), button->get_size() - normal->get_minimum_size()), p_color); } @@ -2447,7 +2447,7 @@ void VisualScriptEditor::set_edited_resource(const RES &p_res) { script->connect("node_ports_changed", callable_mp(this, &VisualScriptEditor::_node_ports_changed)); _update_graph(); - call_deferred("_update_members"); + call_deferred(SNAME("_update_members")); } void VisualScriptEditor::enable_editor() { @@ -2481,7 +2481,7 @@ String VisualScriptEditor::get_name() { } Ref VisualScriptEditor::get_theme_icon() { - return Control::get_theme_icon("VisualScript", "EditorIcons"); + return Control::get_theme_icon(SNAME("VisualScript"), SNAME("EditorIcons")); } bool VisualScriptEditor::is_unsaved() { @@ -2556,7 +2556,7 @@ void VisualScriptEditor::goto_line(int p_line, bool p_with_error) { _update_graph(); _update_members(); - call_deferred("call_deferred", "_center_on_node", E->get(), p_line); //editor might be just created and size might not exist yet + call_deferred(SNAME("call_deferred"), "_center_on_node", E->get(), p_line); //editor might be just created and size might not exist yet return; } } @@ -3547,9 +3547,9 @@ void VisualScriptEditor::_notification(int p_what) { return; } - edit_variable_edit->add_theme_style_override("bg", get_theme_stylebox("bg", "Tree")); - edit_signal_edit->add_theme_style_override("bg", get_theme_stylebox("bg", "Tree")); - func_input_scroll->add_theme_style_override("bg", get_theme_stylebox("bg", "Tree")); + edit_variable_edit->add_theme_style_override("bg", get_theme_stylebox(SNAME("bg"), SNAME("Tree"))); + edit_signal_edit->add_theme_style_override("bg", get_theme_stylebox(SNAME("bg"), SNAME("Tree"))); + func_input_scroll->add_theme_style_override("bg", get_theme_stylebox(SNAME("bg"), SNAME("Tree"))); Ref tm = EditorNode::get_singleton()->get_theme_base()->get_theme(); @@ -3572,7 +3572,7 @@ void VisualScriptEditor::_notification(int p_what) { } for (Map::Element *E = node_colors.front(); E; E = E->next()) { - const Ref sb = tm->get_stylebox("frame", "GraphNode"); + const Ref sb = tm->get_stylebox(SNAME("frame"), SNAME("GraphNode")); if (!sb.is_null()) { Ref frame_style = sb->duplicate(); @@ -4052,9 +4052,9 @@ void VisualScriptEditor::_member_rmb_selected(const Vector2 &p_pos) { TreeItem *root = members->get_root(); - Ref del_icon = Control::get_theme_icon("Remove", "EditorIcons"); + Ref del_icon = Control::get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")); - Ref edit_icon = Control::get_theme_icon("Edit", "EditorIcons"); + Ref edit_icon = Control::get_theme_icon(SNAME("Edit"), SNAME("EditorIcons")); if (ti->get_parent() == root->get_first_child()) { member_type = MEMBER_FUNCTION; @@ -4223,7 +4223,7 @@ VisualScriptEditor::VisualScriptEditor() { members_section = memnew(VBoxContainer); // Add but wait until done setting up this. - ScriptEditor::get_singleton()->get_left_list_split()->call_deferred("add_child", members_section); + ScriptEditor::get_singleton()->get_left_list_split()->call_deferred(SNAME("add_child"), members_section); members_section->set_v_size_flags(SIZE_EXPAND_FILL); CheckButton *tool_script_check = memnew(CheckButton); @@ -4489,14 +4489,14 @@ void _VisualScriptEditor::add_custom_node(const String &p_name, const String &p_ String node_name = "custom/" + p_category + "/" + p_name; custom_nodes.insert(node_name, p_script); VisualScriptLanguage::singleton->add_register_func(node_name, &_VisualScriptEditor::create_node_custom); - emit_signal("custom_nodes_updated"); + emit_signal(SNAME("custom_nodes_updated")); } void _VisualScriptEditor::remove_custom_node(const String &p_name, const String &p_category) { String node_name = "custom/" + p_category + "/" + p_name; custom_nodes.erase(node_name); VisualScriptLanguage::singleton->remove_register_func(node_name); - emit_signal("custom_nodes_updated"); + emit_signal(SNAME("custom_nodes_updated")); } void _VisualScriptEditor::_bind_methods() { diff --git a/modules/visual_script/visual_script_nodes.cpp b/modules/visual_script/visual_script_nodes.cpp index b93c710652..990c6d19fb 100644 --- a/modules/visual_script/visual_script_nodes.cpp +++ b/modules/visual_script/visual_script_nodes.cpp @@ -2987,7 +2987,7 @@ VisualScriptNodeInstance *VisualScriptCustomNode::instantiate(VisualScriptInstan } void VisualScriptCustomNode::_script_changed() { - call_deferred("ports_changed_notify"); + call_deferred(SNAME("ports_changed_notify")); } void VisualScriptCustomNode::_bind_methods() { diff --git a/modules/visual_script/visual_script_property_selector.cpp b/modules/visual_script/visual_script_property_selector.cpp index 79addc5828..005f54e595 100644 --- a/modules/visual_script/visual_script_property_selector.cpp +++ b/modules/visual_script/visual_script_property_selector.cpp @@ -98,35 +98,35 @@ void VisualScriptPropertySelector::_update_search() { List props; TreeItem *category = nullptr; Ref type_icons[Variant::VARIANT_MAX] = { - vbc->get_theme_icon("Variant", "EditorIcons"), - vbc->get_theme_icon("bool", "EditorIcons"), - vbc->get_theme_icon("int", "EditorIcons"), - vbc->get_theme_icon("float", "EditorIcons"), - vbc->get_theme_icon("String", "EditorIcons"), - vbc->get_theme_icon("Vector2", "EditorIcons"), - vbc->get_theme_icon("Rect2", "EditorIcons"), - vbc->get_theme_icon("Vector3", "EditorIcons"), - vbc->get_theme_icon("Transform2D", "EditorIcons"), - vbc->get_theme_icon("Plane", "EditorIcons"), - vbc->get_theme_icon("Quaternion", "EditorIcons"), - vbc->get_theme_icon("AABB", "EditorIcons"), - vbc->get_theme_icon("Basis", "EditorIcons"), - vbc->get_theme_icon("Transform3D", "EditorIcons"), - vbc->get_theme_icon("Color", "EditorIcons"), - vbc->get_theme_icon("Path", "EditorIcons"), - vbc->get_theme_icon("RID", "EditorIcons"), - vbc->get_theme_icon("Object", "EditorIcons"), - vbc->get_theme_icon("Dictionary", "EditorIcons"), - vbc->get_theme_icon("Array", "EditorIcons"), - vbc->get_theme_icon("PackedByteArray", "EditorIcons"), - vbc->get_theme_icon("PackedInt32Array", "EditorIcons"), - vbc->get_theme_icon("PackedFloat32Array", "EditorIcons"), - vbc->get_theme_icon("PackedInt64Array", "EditorIcons"), - vbc->get_theme_icon("PackedFloat64Array", "EditorIcons"), - vbc->get_theme_icon("PackedStringArray", "EditorIcons"), - vbc->get_theme_icon("PackedVector2Array", "EditorIcons"), - vbc->get_theme_icon("PackedVector3Array", "EditorIcons"), - vbc->get_theme_icon("PackedColorArray", "EditorIcons") + vbc->get_theme_icon(SNAME("Variant"), SNAME("EditorIcons")), + vbc->get_theme_icon(SNAME("bool"), SNAME("EditorIcons")), + vbc->get_theme_icon(SNAME("int"), SNAME("EditorIcons")), + vbc->get_theme_icon(SNAME("float"), SNAME("EditorIcons")), + vbc->get_theme_icon(SNAME("String"), SNAME("EditorIcons")), + vbc->get_theme_icon(SNAME("Vector2"), SNAME("EditorIcons")), + vbc->get_theme_icon(SNAME("Rect2"), SNAME("EditorIcons")), + vbc->get_theme_icon(SNAME("Vector3"), SNAME("EditorIcons")), + vbc->get_theme_icon(SNAME("Transform2D"), SNAME("EditorIcons")), + vbc->get_theme_icon(SNAME("Plane"), SNAME("EditorIcons")), + vbc->get_theme_icon(SNAME("Quaternion"), SNAME("EditorIcons")), + vbc->get_theme_icon(SNAME("AABB"), SNAME("EditorIcons")), + vbc->get_theme_icon(SNAME("Basis"), SNAME("EditorIcons")), + vbc->get_theme_icon(SNAME("Transform3D"), SNAME("EditorIcons")), + vbc->get_theme_icon(SNAME("Color"), SNAME("EditorIcons")), + vbc->get_theme_icon(SNAME("Path"), SNAME("EditorIcons")), + vbc->get_theme_icon(SNAME("RID"), SNAME("EditorIcons")), + vbc->get_theme_icon(SNAME("Object"), SNAME("EditorIcons")), + vbc->get_theme_icon(SNAME("Dictionary"), SNAME("EditorIcons")), + vbc->get_theme_icon(SNAME("Array"), SNAME("EditorIcons")), + vbc->get_theme_icon(SNAME("PackedByteArray"), SNAME("EditorIcons")), + vbc->get_theme_icon(SNAME("PackedInt32Array"), SNAME("EditorIcons")), + vbc->get_theme_icon(SNAME("PackedFloat32Array"), SNAME("EditorIcons")), + vbc->get_theme_icon(SNAME("PackedInt64Array"), SNAME("EditorIcons")), + vbc->get_theme_icon(SNAME("PackedFloat64Array"), SNAME("EditorIcons")), + vbc->get_theme_icon(SNAME("PackedStringArray"), SNAME("EditorIcons")), + vbc->get_theme_icon(SNAME("PackedVector2Array"), SNAME("EditorIcons")), + vbc->get_theme_icon(SNAME("PackedVector3Array"), SNAME("EditorIcons")), + vbc->get_theme_icon(SNAME("PackedColorArray"), SNAME("EditorIcons")) }; { String b = String(E->get()); @@ -253,7 +253,7 @@ void VisualScriptPropertySelector::_update_search() { TreeItem *item = search_options->create_item(category ? category : root); item->set_text(0, desc); - item->set_icon(0, vbc->get_theme_icon("MemberMethod", "EditorIcons")); + item->set_icon(0, vbc->get_theme_icon(SNAME("MemberMethod"), SNAME("EditorIcons"))); item->set_metadata(0, name); item->set_selectable(0, true); @@ -317,7 +317,7 @@ void VisualScriptPropertySelector::create_visualscript_item(const String &name, if (search_input == String() || text.findn(search_input) != -1) { TreeItem *item = search_options->create_item(root); item->set_text(0, text); - item->set_icon(0, vbc->get_theme_icon("VisualScript", "EditorIcons")); + item->set_icon(0, vbc->get_theme_icon(SNAME("VisualScript"), SNAME("EditorIcons"))); item->set_metadata(0, name); item->set_metadata(1, "action"); item->set_selectable(0, true); @@ -401,7 +401,7 @@ void VisualScriptPropertySelector::get_visual_node_names(const String &root_filt } item->set_text(0, type_name + String("").join(desc)); - item->set_icon(0, vbc->get_theme_icon("VisualScript", "EditorIcons")); + item->set_icon(0, vbc->get_theme_icon(SNAME("VisualScript"), SNAME("EditorIcons"))); item->set_selectable(0, true); item->set_metadata(0, E->get()); item->set_selectable(0, true); @@ -417,7 +417,7 @@ void VisualScriptPropertySelector::_confirmed() { if (!ti) { return; } - emit_signal("selected", ti->get_metadata(0), ti->get_metadata(1), ti->get_metadata(2)); + emit_signal(SNAME("selected"), ti->get_metadata(0), ti->get_metadata(1), ti->get_metadata(2)); set_visible(false); } diff --git a/modules/webrtc/webrtc_multiplayer_peer.cpp b/modules/webrtc/webrtc_multiplayer_peer.cpp index ac75f9e860..51101e3124 100644 --- a/modules/webrtc/webrtc_multiplayer_peer.cpp +++ b/modules/webrtc/webrtc_multiplayer_peer.cpp @@ -123,19 +123,19 @@ void WebRTCMultiplayerPeer::poll() { // Already connected to server: simply notify new peer. // NOTE: Mesh is always connected. if (connection_status == CONNECTION_CONNECTED) { - emit_signal("peer_connected", E->get()); + emit_signal(SNAME("peer_connected"), E->get()); } // Server emulation mode suppresses peer_conencted until server connects. if (server_compat && E->get() == TARGET_PEER_SERVER) { // Server connected. connection_status = CONNECTION_CONNECTED; - emit_signal("peer_connected", TARGET_PEER_SERVER); - emit_signal("connection_succeeded"); + emit_signal(SNAME("peer_connected"), TARGET_PEER_SERVER); + emit_signal(SNAME("connection_succeeded")); // Notify of all previously connected peers for (Map>::Element *F = peer_map.front(); F; F = F->next()) { if (F->key() != 1 && F->get()->connected) { - emit_signal("peer_connected", F->key()); + emit_signal(SNAME("peer_connected"), F->key()); } } break; // Because we already notified of all newly added peers. @@ -283,9 +283,9 @@ void WebRTCMultiplayerPeer::remove_peer(int p_peer_id) { peer_map.erase(p_peer_id); if (peer->connected) { peer->connected = false; - emit_signal("peer_disconnected", p_peer_id); + emit_signal(SNAME("peer_disconnected"), p_peer_id); if (server_compat && p_peer_id == TARGET_PEER_SERVER) { - emit_signal("server_disconnected"); + emit_signal(SNAME("server_disconnected")); connection_status = CONNECTION_DISCONNECTED; } } diff --git a/modules/webrtc/webrtc_peer_connection_js.cpp b/modules/webrtc/webrtc_peer_connection_js.cpp index 2b63e76358..ed3459d5f8 100644 --- a/modules/webrtc/webrtc_peer_connection_js.cpp +++ b/modules/webrtc/webrtc_peer_connection_js.cpp @@ -38,12 +38,12 @@ void WebRTCPeerConnectionJS::_on_ice_candidate(void *p_obj, const char *p_mid_name, int p_mline_idx, const char *p_candidate) { WebRTCPeerConnectionJS *peer = static_cast(p_obj); - peer->emit_signal("ice_candidate_created", String(p_mid_name), p_mline_idx, String(p_candidate)); + peer->emit_signal(SNAME("ice_candidate_created"), String(p_mid_name), p_mline_idx, String(p_candidate)); } void WebRTCPeerConnectionJS::_on_session_created(void *p_obj, const char *p_type, const char *p_session) { WebRTCPeerConnectionJS *peer = static_cast(p_obj); - peer->emit_signal("session_description_created", String(p_type), String(p_session)); + peer->emit_signal(SNAME("session_description_created"), String(p_type), String(p_session)); } void WebRTCPeerConnectionJS::_on_connection_state_changed(void *p_obj, int p_state) { @@ -57,7 +57,7 @@ void WebRTCPeerConnectionJS::_on_error(void *p_obj) { void WebRTCPeerConnectionJS::_on_data_channel(void *p_obj, int p_id) { WebRTCPeerConnectionJS *peer = static_cast(p_obj); - peer->emit_signal("data_channel_received", Ref(new WebRTCDataChannelJS(p_id))); + peer->emit_signal(SNAME("data_channel_received"), Ref(new WebRTCDataChannelJS(p_id))); } void WebRTCPeerConnectionJS::close() { diff --git a/modules/websocket/websocket_client.cpp b/modules/websocket/websocket_client.cpp index af1dc8ff54..f7a8944745 100644 --- a/modules/websocket/websocket_client.cpp +++ b/modules/websocket/websocket_client.cpp @@ -86,7 +86,7 @@ void WebSocketClient::_on_peer_packet() { if (_is_multiplayer) { _process_multiplayer(get_peer(1), 1); } else { - emit_signal("data_received"); + emit_signal(SNAME("data_received")); } } @@ -94,27 +94,27 @@ void WebSocketClient::_on_connect(String p_protocol) { if (_is_multiplayer) { // need to wait for ID confirmation... } else { - emit_signal("connection_established", p_protocol); + emit_signal(SNAME("connection_established"), p_protocol); } } void WebSocketClient::_on_close_request(int p_code, String p_reason) { - emit_signal("server_close_request", p_code, p_reason); + emit_signal(SNAME("server_close_request"), p_code, p_reason); } void WebSocketClient::_on_disconnect(bool p_was_clean) { if (_is_multiplayer) { - emit_signal("connection_failed"); + emit_signal(SNAME("connection_failed")); } else { - emit_signal("connection_closed", p_was_clean); + emit_signal(SNAME("connection_closed"), p_was_clean); } } void WebSocketClient::_on_error() { if (_is_multiplayer) { - emit_signal("connection_failed"); + emit_signal(SNAME("connection_failed")); } else { - emit_signal("connection_error"); + emit_signal(SNAME("connection_error")); } } diff --git a/modules/websocket/websocket_multiplayer_peer.cpp b/modules/websocket/websocket_multiplayer_peer.cpp index 1beeb67b91..ddd8e190df 100644 --- a/modules/websocket/websocket_multiplayer_peer.cpp +++ b/modules/websocket/websocket_multiplayer_peer.cpp @@ -215,7 +215,7 @@ void WebSocketMultiplayerPeer::_store_pkt(int32_t p_source, int32_t p_dest, cons packet.destination = p_dest; memcpy(packet.data, &p_data[PROTO_SIZE], p_data_size); _incoming_packets.push_back(packet); - emit_signal("peer_packet", p_source); + emit_signal(SNAME("peer_packet"), p_source); } Error WebSocketMultiplayerPeer::_server_relay(int32_t p_from, int32_t p_to, const uint8_t *p_buffer, uint32_t p_buffer_size) { @@ -306,15 +306,15 @@ void WebSocketMultiplayerPeer::_process_multiplayer(Ref p_peer, u switch (type) { case SYS_ADD: // Add peer _peer_map[id] = Ref(); - emit_signal("peer_connected", id); + emit_signal(SNAME("peer_connected"), id); if (id == 1) { // We just connected to the server - emit_signal("connection_succeeded"); + emit_signal(SNAME("connection_succeeded")); } break; case SYS_DEL: // Remove peer _peer_map.erase(id); - emit_signal("peer_disconnected", id); + emit_signal(SNAME("peer_disconnected"), id); break; case SYS_ID: // Hello, server assigned ID _peer_id = id; diff --git a/modules/websocket/websocket_server.cpp b/modules/websocket/websocket_server.cpp index 79ca9e4667..fb838109f3 100644 --- a/modules/websocket/websocket_server.cpp +++ b/modules/websocket/websocket_server.cpp @@ -137,7 +137,7 @@ void WebSocketServer::_on_peer_packet(int32_t p_peer_id) { if (_is_multiplayer) { _process_multiplayer(get_peer(p_peer_id), p_peer_id); } else { - emit_signal("data_received", p_peer_id); + emit_signal(SNAME("data_received"), p_peer_id); } } @@ -145,9 +145,9 @@ void WebSocketServer::_on_connect(int32_t p_peer_id, String p_protocol, String p if (_is_multiplayer) { // Send add to clients _send_add(p_peer_id); - emit_signal("peer_connected", p_peer_id); + emit_signal(SNAME("peer_connected"), p_peer_id); } else { - emit_signal("client_connected", p_peer_id, p_protocol, p_resource_name); + emit_signal(SNAME("client_connected"), p_peer_id, p_protocol, p_resource_name); } } @@ -155,12 +155,12 @@ void WebSocketServer::_on_disconnect(int32_t p_peer_id, bool p_was_clean) { if (_is_multiplayer) { // Send delete to clients _send_del(p_peer_id); - emit_signal("peer_disconnected", p_peer_id); + emit_signal(SNAME("peer_disconnected"), p_peer_id); } else { - emit_signal("client_disconnected", p_peer_id, p_was_clean); + emit_signal(SNAME("client_disconnected"), p_peer_id, p_was_clean); } } void WebSocketServer::_on_close_request(int32_t p_peer_id, int p_code, String p_reason) { - emit_signal("client_close_request", p_peer_id, p_code, p_reason); + emit_signal(SNAME("client_close_request"), p_peer_id, p_code, p_reason); } diff --git a/modules/webxr/webxr_interface_js.cpp b/modules/webxr/webxr_interface_js.cpp index 01cc05aa0b..6957dea8c4 100644 --- a/modules/webxr/webxr_interface_js.cpp +++ b/modules/webxr/webxr_interface_js.cpp @@ -45,7 +45,7 @@ void _emwebxr_on_session_supported(char *p_session_mode, int p_supported) { ERR_FAIL_COND(interface.is_null()); String session_mode = String(p_session_mode); - interface->emit_signal("session_supported", session_mode, p_supported ? true : false); + interface->emit_signal(SNAME("session_supported"), session_mode, p_supported ? true : false); } void _emwebxr_on_session_started(char *p_reference_space_type) { @@ -57,7 +57,7 @@ void _emwebxr_on_session_started(char *p_reference_space_type) { String reference_space_type = String(p_reference_space_type); ((WebXRInterfaceJS *)interface.ptr())->_set_reference_space_type(reference_space_type); - interface->emit_signal("session_started"); + interface->emit_signal(SNAME("session_started")); } void _emwebxr_on_session_ended() { @@ -68,7 +68,7 @@ void _emwebxr_on_session_ended() { ERR_FAIL_COND(interface.is_null()); interface->uninitialize(); - interface->emit_signal("session_ended"); + interface->emit_signal(SNAME("session_ended")); } void _emwebxr_on_session_failed(char *p_message) { @@ -81,7 +81,7 @@ void _emwebxr_on_session_failed(char *p_message) { interface->uninitialize(); String message = String(p_message); - interface->emit_signal("session_failed", message); + interface->emit_signal(SNAME("session_failed"), message); } void _emwebxr_on_controller_changed() { @@ -102,7 +102,7 @@ extern "C" EMSCRIPTEN_KEEPALIVE void _emwebxr_on_input_event(char *p_signal_name ERR_FAIL_COND(interface.is_null()); StringName signal_name = StringName(p_signal_name); - interface->emit_signal(signal_name, p_input_source + 1); + interface->emit_signal(SNAME(signal_name), p_input_source + 1); } extern "C" EMSCRIPTEN_KEEPALIVE void _emwebxr_on_simple_event(char *p_signal_name) { @@ -113,7 +113,7 @@ extern "C" EMSCRIPTEN_KEEPALIVE void _emwebxr_on_simple_event(char *p_signal_nam ERR_FAIL_COND(interface.is_null()); StringName signal_name = StringName(p_signal_name); - interface->emit_signal(signal_name); + interface->emit_signal(SNAME(signal_name)); } void WebXRInterfaceJS::is_session_supported(const String &p_session_mode) { -- cgit v1.2.3