Merge pull request #57720 from akien-mga/prefer-cast-to-get_class-string-compare
This commit is contained in:
commit
f32c715fbc
|
@ -683,7 +683,7 @@ EditorDebuggerNode::CameraOverride EditorDebuggerNode::get_camera_override() {
|
|||
void EditorDebuggerNode::add_debugger_plugin(const Ref<Script> &p_script) {
|
||||
ERR_FAIL_COND_MSG(debugger_plugins.has(p_script), "Debugger plugin already exists.");
|
||||
ERR_FAIL_COND_MSG(p_script.is_null(), "Debugger plugin script is null");
|
||||
ERR_FAIL_COND_MSG(String(p_script->get_instance_base_type()) == "", "Debugger plugin script has error.");
|
||||
ERR_FAIL_COND_MSG(p_script->get_instance_base_type() == StringName(), "Debugger plugin script has error.");
|
||||
ERR_FAIL_COND_MSG(String(p_script->get_instance_base_type()) != "EditorDebuggerPlugin", "Base type of debugger plugin is not 'EditorDebuggerPlugin'.");
|
||||
ERR_FAIL_COND_MSG(!p_script->is_tool(), "Debugger plugin script is not in tool mode.");
|
||||
debugger_plugins.insert(p_script);
|
||||
|
|
|
@ -362,21 +362,21 @@ Node *EditorAutoloadSettings::_create_autoload(const String &p_path) {
|
|||
RES res = ResourceLoader::load(p_path);
|
||||
ERR_FAIL_COND_V_MSG(res.is_null(), nullptr, "Can't autoload: " + p_path + ".");
|
||||
Node *n = nullptr;
|
||||
if (res->is_class("PackedScene")) {
|
||||
Ref<PackedScene> ps = res;
|
||||
n = ps->instantiate();
|
||||
} else if (res->is_class("Script")) {
|
||||
Ref<Script> s = res;
|
||||
StringName ibt = s->get_instance_base_type();
|
||||
Ref<PackedScene> scn = res;
|
||||
Ref<Script> script = res;
|
||||
if (scn.is_valid()) {
|
||||
n = scn->instantiate();
|
||||
} else if (script.is_valid()) {
|
||||
StringName ibt = script->get_instance_base_type();
|
||||
bool valid_type = ClassDB::is_parent_class(ibt, "Node");
|
||||
ERR_FAIL_COND_V_MSG(!valid_type, nullptr, "Script does not inherit a Node: " + p_path + ".");
|
||||
|
||||
Object *obj = ClassDB::instantiate(ibt);
|
||||
|
||||
ERR_FAIL_COND_V_MSG(obj == nullptr, nullptr, "Cannot instance script for AutoLoad, expected 'Node' inheritance, got: " + String(ibt) + ".");
|
||||
ERR_FAIL_COND_V_MSG(!obj, nullptr, "Cannot instance script for AutoLoad, expected 'Node' inheritance, got: " + String(ibt) + ".");
|
||||
|
||||
n = Object::cast_to<Node>(obj);
|
||||
n->set_script(s);
|
||||
n->set_script(script);
|
||||
}
|
||||
|
||||
ERR_FAIL_COND_V_MSG(!n, nullptr, "Path in AutoLoad not a node or script: " + p_path + ".");
|
||||
|
|
|
@ -610,11 +610,6 @@ TreeItem *EditorHelpSearch::Runner::_create_member_item(TreeItem *p_parent, cons
|
|||
text = p_text;
|
||||
} else {
|
||||
icon = ui_service->get_theme_icon(p_icon, SNAME("EditorIcons"));
|
||||
/*// In flat mode, show the class icon.
|
||||
if (ui_service->has_icon(p_class_name, "EditorIcons"))
|
||||
icon = ui_service->get_icon(p_class_name, "EditorIcons");
|
||||
else if (ClassDB::is_parent_class(p_class_name, "Object"))
|
||||
icon = ui_service->get_icon("Object", "EditorIcons");*/
|
||||
text = p_class_name + "." + p_text;
|
||||
}
|
||||
|
||||
|
|
|
@ -2425,7 +2425,7 @@ void EditorInspector::update_tree() {
|
|||
if (!ClassDB::class_exists(type) && !ScriptServer::is_global_class(type) && p.hint_string.length() && FileAccess::exists(p.hint_string)) {
|
||||
// If we have a category inside a script, search for the first script with a valid icon.
|
||||
Ref<Script> script = ResourceLoader::load(p.hint_string, "Script");
|
||||
String base_type;
|
||||
StringName base_type;
|
||||
if (script.is_valid()) {
|
||||
base_type = script->get_instance_base_type();
|
||||
}
|
||||
|
|
|
@ -745,7 +745,6 @@ void EditorNode::_notification(int p_what) {
|
|||
|
||||
bottom_panel_raise->set_icon(gui_base->get_theme_icon(SNAME("ExpandBottomDock"), SNAME("EditorIcons")));
|
||||
|
||||
// clear_button->set_icon(gui_base->get_icon("Close", "EditorIcons")); don't have access to that node. needs to become a class property
|
||||
if (gui_base->is_layout_rtl()) {
|
||||
dock_tab_move_left->set_icon(theme->get_icon(SNAME("Forward"), SNAME("EditorIcons")));
|
||||
dock_tab_move_right->set_icon(theme->get_icon(SNAME("Back"), SNAME("EditorIcons")));
|
||||
|
@ -2280,7 +2279,7 @@ void EditorNode::_edit_current(bool p_skip_foreign) {
|
|||
if (main_plugin) {
|
||||
// special case if use of external editor is true
|
||||
Resource *current_res = Object::cast_to<Resource>(current_obj);
|
||||
if (main_plugin->get_name() == "Script" && current_obj->get_class_name() != StringName("VisualScript") && current_res && !current_res->is_built_in() && (bool(EditorSettings::get_singleton()->get("text_editor/external/use_external_editor")) || overrides_external_editor(current_obj))) {
|
||||
if (main_plugin->get_name() == "Script" && current_obj->is_class("VisualScript") && current_res && !current_res->is_built_in() && (bool(EditorSettings::get_singleton()->get("text_editor/external/use_external_editor")) || overrides_external_editor(current_obj))) {
|
||||
if (!changing_scene) {
|
||||
main_plugin->edit(current_obj);
|
||||
}
|
||||
|
@ -3293,8 +3292,8 @@ void EditorNode::set_addon_plugin_enabled(const String &p_addon, bool p_enabled,
|
|||
return;
|
||||
}
|
||||
|
||||
// Errors in the script cause the base_type to be an empty string.
|
||||
if (String(script->get_instance_base_type()) == "") {
|
||||
// Errors in the script cause the base_type to be an empty StringName.
|
||||
if (script->get_instance_base_type() == StringName()) {
|
||||
show_warning(vformat(TTR("Unable to load addon script from path: '%s'. This might be due to a code error in that script.\nDisabling the addon at '%s' to prevent further errors."), script_path, p_addon));
|
||||
_remove_plugin_from_enabled(p_addon);
|
||||
return;
|
||||
|
@ -3937,7 +3936,7 @@ StringName EditorNode::get_object_custom_type_name(const Object *p_object) const
|
|||
ERR_FAIL_COND_V(!p_object, StringName());
|
||||
|
||||
Ref<Script> script = p_object->get_script();
|
||||
if (script.is_null() && p_object->is_class("Script")) {
|
||||
if (script.is_null() && Object::cast_to<Script>(p_object)) {
|
||||
script = p_object;
|
||||
}
|
||||
|
||||
|
@ -4148,13 +4147,12 @@ Ref<Texture2D> EditorNode::_file_dialog_get_icon(const String &p_path) {
|
|||
|
||||
void EditorNode::_build_icon_type_cache() {
|
||||
List<StringName> tl;
|
||||
StringName ei = "EditorIcons";
|
||||
theme_base->get_theme()->get_icon_list(ei, &tl);
|
||||
theme_base->get_theme()->get_icon_list(SNAME("EditorIcons"), &tl);
|
||||
for (const StringName &E : tl) {
|
||||
if (!ClassDB::class_exists(E)) {
|
||||
continue;
|
||||
}
|
||||
icon_type_cache[E] = theme_base->get_theme()->get_icon(E, ei);
|
||||
icon_type_cache[E] = theme_base->get_theme()->get_icon(E, SNAME("EditorIcons"));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -77,16 +77,16 @@ void EditorResourcePicker::_update_resource_preview(const String &p_path, const
|
|||
return;
|
||||
}
|
||||
|
||||
String type = edited_resource->get_class_name();
|
||||
if (ClassDB::is_parent_class(type, "Script")) {
|
||||
assign_button->set_text(edited_resource->get_path().get_file());
|
||||
Ref<Script> script = edited_resource;
|
||||
if (script.is_valid()) {
|
||||
assign_button->set_text(script->get_path().get_file());
|
||||
return;
|
||||
}
|
||||
|
||||
if (p_preview.is_valid()) {
|
||||
preview_rect->set_offset(SIDE_LEFT, assign_button->get_icon()->get_width() + assign_button->get_theme_stylebox(SNAME("normal"))->get_default_margin(SIDE_LEFT) + get_theme_constant(SNAME("hseparation"), SNAME("Button")));
|
||||
|
||||
if (type == "GradientTexture1D") {
|
||||
if (Ref<GradientTexture1D>(edited_resource).is_valid()) {
|
||||
preview_rect->set_stretch_mode(TextureRect::STRETCH_SCALE);
|
||||
assign_button->set_custom_minimum_size(Size2(1, 1));
|
||||
} else {
|
||||
|
@ -642,7 +642,7 @@ void EditorResourcePicker::drop_data_fw(const Point2 &p_point, const Variant &p_
|
|||
for (Set<String>::Element *E = allowed_types.front(); E; E = E->next()) {
|
||||
String at = E->get().strip_edges();
|
||||
|
||||
if (at == "BaseMaterial3D" && ClassDB::is_parent_class(dropped_resource->get_class(), "Texture2D")) {
|
||||
if (at == "BaseMaterial3D" && Ref<Texture2D>(dropped_resource).is_valid()) {
|
||||
// Use existing resource if possible and only replace its data.
|
||||
Ref<StandardMaterial3D> mat = edited_resource;
|
||||
if (!mat.is_valid()) {
|
||||
|
@ -653,7 +653,7 @@ void EditorResourcePicker::drop_data_fw(const Point2 &p_point, const Variant &p_
|
|||
break;
|
||||
}
|
||||
|
||||
if (at == "ShaderMaterial" && ClassDB::is_parent_class(dropped_resource->get_class(), "Shader")) {
|
||||
if (at == "ShaderMaterial" && Ref<Shader>(dropped_resource).is_valid()) {
|
||||
Ref<ShaderMaterial> mat = edited_resource;
|
||||
if (!mat.is_valid()) {
|
||||
mat.instantiate();
|
||||
|
@ -663,7 +663,7 @@ void EditorResourcePicker::drop_data_fw(const Point2 &p_point, const Variant &p_
|
|||
break;
|
||||
}
|
||||
|
||||
if (at == "Font" && ClassDB::is_parent_class(dropped_resource->get_class(), "FontData")) {
|
||||
if (at == "Font" && Ref<FontData>(dropped_resource).is_valid()) {
|
||||
Ref<Font> font = edited_resource;
|
||||
if (!font.is_valid()) {
|
||||
font.instantiate();
|
||||
|
@ -673,7 +673,7 @@ void EditorResourcePicker::drop_data_fw(const Point2 &p_point, const Variant &p_
|
|||
break;
|
||||
}
|
||||
|
||||
if (at == "Texture2D" && ClassDB::is_parent_class(dropped_resource->get_class(), "Image")) {
|
||||
if (at == "Texture2D" && Ref<Image>(dropped_resource).is_valid()) {
|
||||
Ref<ImageTexture> texture = edited_resource;
|
||||
if (!texture.is_valid()) {
|
||||
texture.instantiate();
|
||||
|
|
|
@ -338,30 +338,28 @@ void FileSystemDock::_notification(int p_what) {
|
|||
EditorFileSystem::get_singleton()->connect("filesystem_changed", callable_mp(this, &FileSystemDock::_fs_changed));
|
||||
EditorResourcePreview::get_singleton()->connect("preview_invalidated", callable_mp(this, &FileSystemDock::_preview_invalidated));
|
||||
|
||||
String ei = "EditorIcons";
|
||||
|
||||
button_reload->set_icon(get_theme_icon(SNAME("Reload"), ei));
|
||||
button_toggle_display_mode->set_icon(get_theme_icon(SNAME("Panels2"), ei));
|
||||
button_reload->set_icon(get_theme_icon(SNAME("Reload"), SNAME("EditorIcons")));
|
||||
button_toggle_display_mode->set_icon(get_theme_icon(SNAME("Panels2"), SNAME("EditorIcons")));
|
||||
button_file_list_display_mode->connect("pressed", callable_mp(this, &FileSystemDock::_toggle_file_display));
|
||||
|
||||
files->connect("item_activated", callable_mp(this, &FileSystemDock::_file_list_activate_file));
|
||||
button_hist_next->connect("pressed", callable_mp(this, &FileSystemDock::_fw_history));
|
||||
button_hist_prev->connect("pressed", callable_mp(this, &FileSystemDock::_bw_history));
|
||||
|
||||
tree_search_box->set_right_icon(get_theme_icon(SNAME("Search"), ei));
|
||||
tree_search_box->set_right_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons")));
|
||||
tree_search_box->set_clear_button_enabled(true);
|
||||
tree_button_sort->set_icon(get_theme_icon(SNAME("Sort"), ei));
|
||||
tree_button_sort->set_icon(get_theme_icon(SNAME("Sort"), SNAME("EditorIcons")));
|
||||
|
||||
file_list_search_box->set_right_icon(get_theme_icon(SNAME("Search"), ei));
|
||||
file_list_search_box->set_right_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons")));
|
||||
file_list_search_box->set_clear_button_enabled(true);
|
||||
file_list_button_sort->set_icon(get_theme_icon(SNAME("Sort"), ei));
|
||||
file_list_button_sort->set_icon(get_theme_icon(SNAME("Sort"), SNAME("EditorIcons")));
|
||||
|
||||
if (is_layout_rtl()) {
|
||||
button_hist_next->set_icon(get_theme_icon(SNAME("Back"), ei));
|
||||
button_hist_prev->set_icon(get_theme_icon(SNAME("Forward"), ei));
|
||||
button_hist_next->set_icon(get_theme_icon(SNAME("Back"), SNAME("EditorIcons")));
|
||||
button_hist_prev->set_icon(get_theme_icon(SNAME("Forward"), SNAME("EditorIcons")));
|
||||
} else {
|
||||
button_hist_next->set_icon(get_theme_icon(SNAME("Forward"), ei));
|
||||
button_hist_prev->set_icon(get_theme_icon(SNAME("Back"), ei));
|
||||
button_hist_next->set_icon(get_theme_icon(SNAME("Forward"), SNAME("EditorIcons")));
|
||||
button_hist_prev->set_icon(get_theme_icon(SNAME("Back"), SNAME("EditorIcons")));
|
||||
}
|
||||
file_list_popup->connect("id_pressed", callable_mp(this, &FileSystemDock::_file_list_rmb_option));
|
||||
tree_popup->connect("id_pressed", callable_mp(this, &FileSystemDock::_tree_rmb_option));
|
||||
|
@ -412,15 +410,14 @@ void FileSystemDock::_notification(int p_what) {
|
|||
|
||||
case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
|
||||
// Update icons.
|
||||
String ei = "EditorIcons";
|
||||
button_reload->set_icon(get_theme_icon(SNAME("Reload"), ei));
|
||||
button_toggle_display_mode->set_icon(get_theme_icon(SNAME("Panels2"), ei));
|
||||
button_reload->set_icon(get_theme_icon(SNAME("Reload"), SNAME("EditorIcons")));
|
||||
button_toggle_display_mode->set_icon(get_theme_icon(SNAME("Panels2"), SNAME("EditorIcons")));
|
||||
if (is_layout_rtl()) {
|
||||
button_hist_next->set_icon(get_theme_icon(SNAME("Back"), ei));
|
||||
button_hist_prev->set_icon(get_theme_icon(SNAME("Forward"), ei));
|
||||
button_hist_next->set_icon(get_theme_icon(SNAME("Back"), SNAME("EditorIcons")));
|
||||
button_hist_prev->set_icon(get_theme_icon(SNAME("Forward"), SNAME("EditorIcons")));
|
||||
} else {
|
||||
button_hist_next->set_icon(get_theme_icon(SNAME("Forward"), ei));
|
||||
button_hist_prev->set_icon(get_theme_icon(SNAME("Back"), ei));
|
||||
button_hist_next->set_icon(get_theme_icon(SNAME("Forward"), SNAME("EditorIcons")));
|
||||
button_hist_prev->set_icon(get_theme_icon(SNAME("Back"), SNAME("EditorIcons")));
|
||||
}
|
||||
if (file_list_display_mode == FILE_LIST_DISPLAY_LIST) {
|
||||
button_file_list_display_mode->set_icon(get_theme_icon(SNAME("FileThumbnail"), SNAME("EditorIcons")));
|
||||
|
@ -428,13 +425,13 @@ void FileSystemDock::_notification(int p_what) {
|
|||
button_file_list_display_mode->set_icon(get_theme_icon(SNAME("FileList"), SNAME("EditorIcons")));
|
||||
}
|
||||
|
||||
tree_search_box->set_right_icon(get_theme_icon(SNAME("Search"), ei));
|
||||
tree_search_box->set_right_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons")));
|
||||
tree_search_box->set_clear_button_enabled(true);
|
||||
tree_button_sort->set_icon(get_theme_icon(SNAME("Sort"), ei));
|
||||
tree_button_sort->set_icon(get_theme_icon(SNAME("Sort"), SNAME("EditorIcons")));
|
||||
|
||||
file_list_search_box->set_right_icon(get_theme_icon(SNAME("Search"), ei));
|
||||
file_list_search_box->set_right_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons")));
|
||||
file_list_search_box->set_clear_button_enabled(true);
|
||||
file_list_button_sort->set_icon(get_theme_icon(SNAME("Sort"), ei));
|
||||
file_list_button_sort->set_icon(get_theme_icon(SNAME("Sort"), SNAME("EditorIcons")));
|
||||
|
||||
// Update always show folders.
|
||||
bool new_always_show_folders = bool(EditorSettings::get_singleton()->get("docks/filesystem/always_show_folders"));
|
||||
|
@ -718,7 +715,6 @@ void FileSystemDock::_update_file_list(bool p_keep_selection) {
|
|||
String directory = path;
|
||||
String file = "";
|
||||
|
||||
String ei = "EditorIcons";
|
||||
int thumbnail_size = EditorSettings::get_singleton()->get("docks/filesystem/thumbnail_size");
|
||||
thumbnail_size *= EDSCALE;
|
||||
Ref<Texture2D> folder_thumbnail;
|
||||
|
@ -736,13 +732,13 @@ void FileSystemDock::_update_file_list(bool p_keep_selection) {
|
|||
files->set_fixed_icon_size(Size2(thumbnail_size, thumbnail_size));
|
||||
|
||||
if (thumbnail_size < 64) {
|
||||
folder_thumbnail = get_theme_icon(SNAME("FolderMediumThumb"), ei);
|
||||
file_thumbnail = get_theme_icon(SNAME("FileMediumThumb"), ei);
|
||||
file_thumbnail_broken = get_theme_icon(SNAME("FileDeadMediumThumb"), ei);
|
||||
folder_thumbnail = get_theme_icon(SNAME("FolderMediumThumb"), SNAME("EditorIcons"));
|
||||
file_thumbnail = get_theme_icon(SNAME("FileMediumThumb"), SNAME("EditorIcons"));
|
||||
file_thumbnail_broken = get_theme_icon(SNAME("FileDeadMediumThumb"), SNAME("EditorIcons"));
|
||||
} else {
|
||||
folder_thumbnail = get_theme_icon(SNAME("FolderBigThumb"), ei);
|
||||
file_thumbnail = get_theme_icon(SNAME("FileBigThumb"), ei);
|
||||
file_thumbnail_broken = get_theme_icon(SNAME("FileDeadBigThumb"), ei);
|
||||
folder_thumbnail = get_theme_icon(SNAME("FolderBigThumb"), SNAME("EditorIcons"));
|
||||
file_thumbnail = get_theme_icon(SNAME("FileBigThumb"), SNAME("EditorIcons"));
|
||||
file_thumbnail_broken = get_theme_icon(SNAME("FileDeadBigThumb"), SNAME("EditorIcons"));
|
||||
}
|
||||
} else {
|
||||
// No thumbnails.
|
||||
|
@ -871,7 +867,6 @@ void FileSystemDock::_update_file_list(bool p_keep_selection) {
|
|||
|
||||
// Fills the ItemList control node from the FileInfos.
|
||||
String main_scene = ProjectSettings::get_singleton()->get("application/run/main_scene");
|
||||
String oi = "Object";
|
||||
for (FileInfo &E : file_list) {
|
||||
FileInfo *finfo = &(E);
|
||||
String fname = finfo->name;
|
||||
|
@ -885,10 +880,10 @@ void FileSystemDock::_update_file_list(bool p_keep_selection) {
|
|||
|
||||
// Select the icons.
|
||||
if (!finfo->import_broken) {
|
||||
type_icon = (has_theme_icon(ftype, ei)) ? get_theme_icon(ftype, ei) : get_theme_icon(oi, ei);
|
||||
type_icon = (has_theme_icon(ftype, SNAME("EditorIcons"))) ? get_theme_icon(ftype, SNAME("EditorIcons")) : get_theme_icon(SNAME("Object"), SNAME("EditorIcons"));
|
||||
big_icon = file_thumbnail;
|
||||
} else {
|
||||
type_icon = get_theme_icon(SNAME("ImportFail"), ei);
|
||||
type_icon = get_theme_icon(SNAME("ImportFail"), SNAME("EditorIcons"));
|
||||
big_icon = file_thumbnail_broken;
|
||||
tooltip += "\n" + TTR("Status: Import of file failed. Please fix file and reimport manually.");
|
||||
}
|
||||
|
|
|
@ -300,7 +300,7 @@ void AnimationNodeBlendTreeEditor::_add_node(int p_idx) {
|
|||
base_name = add_options[p_idx].name;
|
||||
} else {
|
||||
ERR_FAIL_COND(add_options[p_idx].script.is_null());
|
||||
String base_type = add_options[p_idx].script->get_instance_base_type();
|
||||
StringName base_type = add_options[p_idx].script->get_instance_base_type();
|
||||
AnimationNode *an = Object::cast_to<AnimationNode>(ClassDB::instantiate(base_type));
|
||||
ERR_FAIL_COND(!an);
|
||||
anode = Ref<AnimationNode>(an);
|
||||
|
|
|
@ -5804,7 +5804,7 @@ void CanvasItemEditorViewport::_create_nodes(Node *parent, Node *child, String &
|
|||
}
|
||||
|
||||
// make visible for certain node type
|
||||
if (ClassDB::is_parent_class(child->get_class(), "Control")) {
|
||||
if (Object::cast_to<Control>(child)) {
|
||||
Size2 texture_size = texture->get_size();
|
||||
editor_data->get_undo_redo().add_do_property(child, "rect_size", texture_size);
|
||||
} else if (Object::cast_to<Polygon2D>(child)) {
|
||||
|
@ -5935,29 +5935,32 @@ bool CanvasItemEditorViewport::can_drop_data(const Point2 &p_point, const Varian
|
|||
if (String(d["type"]) == "files") {
|
||||
Vector<String> files = d["files"];
|
||||
bool can_instantiate = false;
|
||||
for (int i = 0; i < files.size(); i++) { // check if dragged files contain resource or scene can be created at least once
|
||||
RES res = ResourceLoader::load(files[i]);
|
||||
if (res.is_null()) {
|
||||
continue;
|
||||
}
|
||||
String type = res->get_class();
|
||||
if (type == "PackedScene") {
|
||||
Ref<PackedScene> sdata = Ref<PackedScene>(Object::cast_to<PackedScene>(*res));
|
||||
Node *instantiated_scene = sdata->instantiate(PackedScene::GEN_EDIT_STATE_INSTANCE);
|
||||
if (!instantiated_scene) {
|
||||
|
||||
List<String> scene_extensions;
|
||||
ResourceLoader::get_recognized_extensions_for_type("PackedScene", &scene_extensions);
|
||||
List<String> texture_extensions;
|
||||
ResourceLoader::get_recognized_extensions_for_type("Texture2D", &texture_extensions);
|
||||
|
||||
for (int i = 0; i < files.size(); i++) {
|
||||
// Check if dragged files with texture or scene extension can be created at least once.
|
||||
if (texture_extensions.find(files[i].get_extension()) || scene_extensions.find(files[i].get_extension())) {
|
||||
RES res = ResourceLoader::load(files[i]);
|
||||
if (res.is_null()) {
|
||||
continue;
|
||||
}
|
||||
memdelete(instantiated_scene);
|
||||
} else if (ClassDB::is_parent_class(type, "Texture2D")) {
|
||||
Ref<Texture2D> texture = Ref<Texture2D>(Object::cast_to<Texture2D>(*res));
|
||||
if (!texture.is_valid()) {
|
||||
Ref<PackedScene> scn = res;
|
||||
if (scn.is_valid()) {
|
||||
Node *instantiated_scene = scn->instantiate(PackedScene::GEN_EDIT_STATE_INSTANCE);
|
||||
if (!instantiated_scene) {
|
||||
continue;
|
||||
}
|
||||
memdelete(instantiated_scene);
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
continue;
|
||||
can_instantiate = true;
|
||||
break;
|
||||
}
|
||||
can_instantiate = true;
|
||||
break;
|
||||
}
|
||||
if (can_instantiate) {
|
||||
if (!preview_node->get_parent()) { // create preview only once
|
||||
|
|
|
@ -188,7 +188,7 @@ bool EditorImagePreviewPlugin::generate_small_preview_automatically() const {
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
/////////////////////////////////////////////////
|
||||
|
||||
bool EditorBitmapPreviewPlugin::handles(const String &p_type) const {
|
||||
return ClassDB::is_parent_class(p_type, "BitMap");
|
||||
}
|
||||
|
@ -308,7 +308,7 @@ void EditorMaterialPreviewPlugin::_preview_done() {
|
|||
}
|
||||
|
||||
bool EditorMaterialPreviewPlugin::handles(const String &p_type) const {
|
||||
return ClassDB::is_parent_class(p_type, "Material"); //any material
|
||||
return ClassDB::is_parent_class(p_type, "Material"); // Any material.
|
||||
}
|
||||
|
||||
bool EditorMaterialPreviewPlugin::generate_small_preview_automatically() const {
|
||||
|
@ -699,7 +699,7 @@ void EditorMeshPreviewPlugin::_preview_done() {
|
|||
}
|
||||
|
||||
bool EditorMeshPreviewPlugin::handles(const String &p_type) const {
|
||||
return ClassDB::is_parent_class(p_type, "Mesh"); //any Mesh
|
||||
return ClassDB::is_parent_class(p_type, "Mesh"); // Any mesh.
|
||||
}
|
||||
|
||||
Ref<Texture2D> EditorMeshPreviewPlugin::generate(const RES &p_from, const Size2 &p_size) const {
|
||||
|
|
|
@ -3978,7 +3978,7 @@ AABB Node3DEditorViewport::_calculate_spatial_bounds(const Node3D *p_parent, boo
|
|||
if (child) {
|
||||
AABB child_bounds = _calculate_spatial_bounds(child, false);
|
||||
|
||||
if (bounds.size == Vector3() && p_parent->get_class_name() == StringName("Node3D")) {
|
||||
if (bounds.size == Vector3() && Object::cast_to<Node3D>(p_parent)) {
|
||||
bounds = child_bounds;
|
||||
} else {
|
||||
bounds.merge_with(child_bounds);
|
||||
|
@ -3986,7 +3986,7 @@ AABB Node3DEditorViewport::_calculate_spatial_bounds(const Node3D *p_parent, boo
|
|||
}
|
||||
}
|
||||
|
||||
if (bounds.size == Vector3() && p_parent->get_class_name() != StringName("Node3D")) {
|
||||
if (bounds.size == Vector3() && !Object::cast_to<Node3D>(p_parent)) {
|
||||
bounds = AABB(Vector3(-0.2, -0.2, -0.2), Vector3(0.4, 0.4, 0.4));
|
||||
}
|
||||
|
||||
|
@ -4213,25 +4213,19 @@ bool Node3DEditorViewport::can_drop_data_fw(const Point2 &p_point, const Variant
|
|||
ResourceLoader::get_recognized_extensions_for_type("Mesh", &mesh_extensions);
|
||||
|
||||
for (int i = 0; i < files.size(); i++) {
|
||||
// Check if dragged files with mesh or scene extension can be created at least once.
|
||||
if (mesh_extensions.find(files[i].get_extension()) || scene_extensions.find(files[i].get_extension())) {
|
||||
RES res = ResourceLoader::load(files[i]);
|
||||
if (res.is_null()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
String type = res->get_class();
|
||||
if (type == "PackedScene") {
|
||||
Ref<PackedScene> sdata = ResourceLoader::load(files[i]);
|
||||
Node *instantiated_scene = sdata->instantiate(PackedScene::GEN_EDIT_STATE_INSTANCE);
|
||||
Ref<PackedScene> scn = res;
|
||||
if (scn.is_valid()) {
|
||||
Node *instantiated_scene = scn->instantiate(PackedScene::GEN_EDIT_STATE_INSTANCE);
|
||||
if (!instantiated_scene) {
|
||||
continue;
|
||||
}
|
||||
memdelete(instantiated_scene);
|
||||
} else if (ClassDB::is_parent_class(type, "Mesh")) {
|
||||
Ref<Mesh> mesh = ResourceLoader::load(files[i]);
|
||||
if (!mesh.is_valid()) {
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -132,10 +132,7 @@ PackedSceneEditorTranslationParserPlugin::PackedSceneEditorTranslationParserPlug
|
|||
lookup_properties.insert("script");
|
||||
|
||||
// Exception list (to prevent false positives).
|
||||
exception_list.insert("LineEdit", Vector<StringName>());
|
||||
exception_list["LineEdit"].append("text");
|
||||
exception_list.insert("TextEdit", Vector<StringName>());
|
||||
exception_list["TextEdit"].append("text");
|
||||
exception_list.insert("CodeEdit", Vector<StringName>());
|
||||
exception_list["CodeEdit"].append("text");
|
||||
exception_list.insert("LineEdit", { "text" });
|
||||
exception_list.insert("TextEdit", { "text" });
|
||||
exception_list.insert("CodeEdit", { "text" });
|
||||
}
|
||||
|
|
|
@ -37,9 +37,9 @@ class PackedSceneEditorTranslationParserPlugin : public EditorTranslationParserP
|
|||
GDCLASS(PackedSceneEditorTranslationParserPlugin, EditorTranslationParserPlugin);
|
||||
|
||||
// Scene Node's properties that contain translation strings.
|
||||
Set<StringName> lookup_properties;
|
||||
Set<String> lookup_properties;
|
||||
// Properties from specific Nodes that should be ignored.
|
||||
Map<StringName, Vector<StringName>> exception_list;
|
||||
Map<String, Vector<String>> exception_list;
|
||||
|
||||
public:
|
||||
virtual Error parse_file(const String &p_path, Vector<String> *r_ids, Vector<Vector<String>> *r_ids_ctx_plural) override;
|
||||
|
|
|
@ -2265,7 +2265,7 @@ bool ScriptEditor::edit(const RES &p_resource, int p_line, int p_col, bool p_gra
|
|||
if (use_external_editor &&
|
||||
(EditorDebuggerNode::get_singleton()->get_dump_stack_script() != p_resource || EditorDebuggerNode::get_singleton()->get_debug_with_external_editor()) &&
|
||||
p_resource->get_path().is_resource_file() &&
|
||||
p_resource->get_class_name() != StringName("VisualScript")) {
|
||||
!Ref<VisualScript>(p_resource).is_valid()) {
|
||||
String path = EditorSettings::get_singleton()->get("text_editor/external/exec_path");
|
||||
String flags = EditorSettings::get_singleton()->get("text_editor/external/exec_flags");
|
||||
|
||||
|
@ -2364,7 +2364,7 @@ bool ScriptEditor::edit(const RES &p_resource, int p_line, int p_col, bool p_gra
|
|||
|
||||
se->set_edited_resource(p_resource);
|
||||
|
||||
if (p_resource->get_class_name() != StringName("VisualScript")) {
|
||||
if (!Ref<VisualScript>(p_resource).is_valid()) {
|
||||
bool highlighter_set = false;
|
||||
for (int i = 0; i < syntax_highlighters.size(); i++) {
|
||||
Ref<EditorSyntaxHighlighter> highlighter = syntax_highlighters[i]->_create();
|
||||
|
|
|
@ -1373,7 +1373,7 @@ void ScriptTextEditor::reload(bool p_soft) {
|
|||
return;
|
||||
}
|
||||
scr->set_source_code(te->get_text());
|
||||
bool soft = p_soft || scr->get_instance_base_type() == "EditorPlugin"; //always soft-reload editor plugins
|
||||
bool soft = p_soft || scr->get_instance_base_type() == "EditorPlugin"; // Always soft-reload editor plugins.
|
||||
|
||||
scr->get_language()->reload_tool_script(scr, soft);
|
||||
}
|
||||
|
|
|
@ -2584,7 +2584,7 @@ void VisualShaderEditor::_add_node(int p_idx, const Vector<Variant> &p_ops, Stri
|
|||
vsnode = Ref<VisualShaderNode>(vsn);
|
||||
} else {
|
||||
ERR_FAIL_COND(add_options[p_idx].script.is_null());
|
||||
String base_type = add_options[p_idx].script->get_instance_base_type();
|
||||
StringName base_type = add_options[p_idx].script->get_instance_base_type();
|
||||
VisualShaderNode *vsn = Object::cast_to<VisualShaderNode>(ClassDB::instantiate(base_type));
|
||||
ERR_FAIL_COND(!vsn);
|
||||
vsnode = Ref<VisualShaderNode>(vsn);
|
||||
|
|
|
@ -1275,8 +1275,6 @@ ProjectExportDialog::ProjectExportDialog() {
|
|||
|
||||
set_hide_on_ok(false);
|
||||
|
||||
editor_icons = "EditorIcons";
|
||||
|
||||
default_filename = EditorSettings::get_singleton()->get_project_metadata("export_options", "default_filename", "");
|
||||
// If no default set, use project name
|
||||
if (default_filename.is_empty()) {
|
||||
|
|
|
@ -85,8 +85,6 @@ private:
|
|||
Label *include_label;
|
||||
MarginContainer *include_margin;
|
||||
|
||||
StringName editor_icons;
|
||||
|
||||
Button *export_button;
|
||||
Button *export_all_button;
|
||||
AcceptDialog *export_all_dialog;
|
||||
|
|
|
@ -2250,9 +2250,8 @@ bool Main::start() {
|
|||
}
|
||||
}
|
||||
|
||||
if (main_loop->is_class("SceneTree")) {
|
||||
SceneTree *sml = Object::cast_to<SceneTree>(main_loop);
|
||||
|
||||
SceneTree *sml = Object::cast_to<SceneTree>(main_loop);
|
||||
if (sml) {
|
||||
#ifdef DEBUG_ENABLED
|
||||
if (debug_collisions) {
|
||||
sml->set_debug_collisions_hint(true);
|
||||
|
@ -2294,20 +2293,18 @@ bool Main::start() {
|
|||
RES res = ResourceLoader::load(info.path);
|
||||
ERR_CONTINUE_MSG(res.is_null(), "Can't autoload: " + info.path);
|
||||
Node *n = nullptr;
|
||||
if (res->is_class("PackedScene")) {
|
||||
Ref<PackedScene> ps = res;
|
||||
n = ps->instantiate();
|
||||
} else if (res->is_class("Script")) {
|
||||
Ref<Script> script_res = res;
|
||||
Ref<PackedScene> scn = res;
|
||||
Ref<Script> script_res = res;
|
||||
if (scn.is_valid()) {
|
||||
n = scn->instantiate();
|
||||
} else if (script_res.is_valid()) {
|
||||
StringName ibt = script_res->get_instance_base_type();
|
||||
bool valid_type = ClassDB::is_parent_class(ibt, "Node");
|
||||
ERR_CONTINUE_MSG(!valid_type, "Script does not inherit a Node: " + info.path);
|
||||
|
||||
Object *obj = ClassDB::instantiate(ibt);
|
||||
|
||||
ERR_CONTINUE_MSG(obj == nullptr,
|
||||
"Cannot instance script for autoload, expected 'Node' inheritance, got: " +
|
||||
String(ibt));
|
||||
ERR_CONTINUE_MSG(!obj, "Cannot instance script for autoload, expected 'Node' inheritance, got: " + String(ibt) + ".");
|
||||
|
||||
n = Object::cast_to<Node>(obj);
|
||||
n->set_script(script_res);
|
||||
|
|
|
@ -766,7 +766,7 @@ Variant NativeScriptInstance::call(const StringName &p_method, const Variant **p
|
|||
void NativeScriptInstance::notification(int p_notification) {
|
||||
#ifdef DEBUG_ENABLED
|
||||
if (p_notification == MainLoop::NOTIFICATION_CRASH) {
|
||||
if (current_method_call != StringName("")) {
|
||||
if (current_method_call != StringName()) {
|
||||
ERR_PRINT("NativeScriptInstance detected crash on method: " + current_method_call);
|
||||
current_method_call = "";
|
||||
}
|
||||
|
|
|
@ -93,7 +93,7 @@ Variant PluginScript::_new(const Variant **p_args, int p_argcount, Callable::Cal
|
|||
REF ref;
|
||||
Object *owner = nullptr;
|
||||
|
||||
if (get_instance_base_type() == "") {
|
||||
if (get_instance_base_type() == StringName()) {
|
||||
owner = memnew(RefCounted);
|
||||
} else {
|
||||
owner = ClassDB::instantiate(get_instance_base_type());
|
||||
|
|
|
@ -196,7 +196,7 @@ Error GDScriptAnalyzer::check_class_member_name_conflict(const GDScriptParser::C
|
|||
}
|
||||
|
||||
if (current_data_type && current_data_type->kind == GDScriptParser::DataType::Kind::NATIVE) {
|
||||
if (current_data_type->native_type != StringName("")) {
|
||||
if (current_data_type->native_type != StringName()) {
|
||||
return check_native_member_name_conflict(
|
||||
p_member_name,
|
||||
p_member_node,
|
||||
|
@ -250,7 +250,7 @@ Error GDScriptAnalyzer::resolve_inheritance(GDScriptParser::ClassNode *p_class,
|
|||
if (!p_class->extends_used) {
|
||||
result.type_source = GDScriptParser::DataType::ANNOTATED_INFERRED;
|
||||
result.kind = GDScriptParser::DataType::NATIVE;
|
||||
result.native_type = "RefCounted";
|
||||
result.native_type = SNAME("RefCounted");
|
||||
} else {
|
||||
result.type_source = GDScriptParser::DataType::ANNOTATED_EXPLICIT;
|
||||
|
||||
|
@ -438,7 +438,7 @@ GDScriptParser::DataType GDScriptAnalyzer::resolve_datatype(GDScriptParser::Type
|
|||
|
||||
StringName first = p_type->type_chain[0]->name;
|
||||
|
||||
if (first == "Variant") {
|
||||
if (first == SNAME("Variant")) {
|
||||
result.kind = GDScriptParser::DataType::VARIANT;
|
||||
if (p_type->type_chain.size() > 1) {
|
||||
push_error(R"("Variant" type don't contain nested types.)", p_type->type_chain[1]);
|
||||
|
@ -447,9 +447,9 @@ GDScriptParser::DataType GDScriptAnalyzer::resolve_datatype(GDScriptParser::Type
|
|||
return result;
|
||||
}
|
||||
|
||||
if (first == "Object") {
|
||||
if (first == SNAME("Object")) {
|
||||
result.kind = GDScriptParser::DataType::NATIVE;
|
||||
result.native_type = "Object";
|
||||
result.native_type = SNAME("Object");
|
||||
if (p_type->type_chain.size() > 1) {
|
||||
push_error(R"("Object" type don't contain nested types.)", p_type->type_chain[1]);
|
||||
return GDScriptParser::DataType();
|
||||
|
@ -2552,7 +2552,7 @@ void GDScriptAnalyzer::reduce_get_node(GDScriptParser::GetNodeNode *p_get_node)
|
|||
GDScriptParser::DataType result;
|
||||
result.type_source = GDScriptParser::DataType::ANNOTATED_EXPLICIT;
|
||||
result.kind = GDScriptParser::DataType::NATIVE;
|
||||
result.native_type = "Node";
|
||||
result.native_type = SNAME("Node");
|
||||
result.builtin_type = Variant::OBJECT;
|
||||
|
||||
if (!ClassDB::is_parent_class(parser->current_class->base_type.native_type, result.native_type)) {
|
||||
|
@ -3524,7 +3524,7 @@ GDScriptParser::DataType GDScriptAnalyzer::type_from_property(const PropertyInfo
|
|||
result.builtin_type = p_property.type;
|
||||
if (p_property.type == Variant::OBJECT) {
|
||||
result.kind = GDScriptParser::DataType::NATIVE;
|
||||
result.native_type = p_property.class_name == StringName() ? "Object" : p_property.class_name;
|
||||
result.native_type = p_property.class_name == StringName() ? SNAME("Object") : p_property.class_name;
|
||||
} else {
|
||||
result.kind = GDScriptParser::DataType::BUILTIN;
|
||||
result.builtin_type = p_property.type;
|
||||
|
|
|
@ -652,7 +652,7 @@ static void _get_directory_contents(EditorFileSystemDirectory *p_dir, Map<String
|
|||
}
|
||||
|
||||
static void _find_annotation_arguments(const GDScriptParser::AnnotationNode *p_annotation, int p_argument, const String p_quote_style, Map<String, ScriptCodeCompletionOption> &r_result) {
|
||||
if (p_annotation->name == "@export_range") {
|
||||
if (p_annotation->name == SNAME("@export_range")) {
|
||||
if (p_argument == 3 || p_argument == 4) {
|
||||
// Slider hint.
|
||||
ScriptCodeCompletionOption slider1("or_greater", ScriptCodeCompletionOption::KIND_PLAIN_TEXT);
|
||||
|
@ -662,7 +662,7 @@ static void _find_annotation_arguments(const GDScriptParser::AnnotationNode *p_a
|
|||
slider2.insert_text = slider2.display.quote(p_quote_style);
|
||||
r_result.insert(slider2.display, slider2);
|
||||
}
|
||||
} else if (p_annotation->name == "@export_exp_easing") {
|
||||
} else if (p_annotation->name == SNAME("@export_exp_easing")) {
|
||||
if (p_argument == 0 || p_argument == 1) {
|
||||
// Easing hint.
|
||||
ScriptCodeCompletionOption hint1("attenuation", ScriptCodeCompletionOption::KIND_PLAIN_TEXT);
|
||||
|
@ -672,7 +672,7 @@ static void _find_annotation_arguments(const GDScriptParser::AnnotationNode *p_a
|
|||
hint2.insert_text = hint2.display.quote(p_quote_style);
|
||||
r_result.insert(hint2.display, hint2);
|
||||
}
|
||||
} else if (p_annotation->name == "@export_node_path") {
|
||||
} else if (p_annotation->name == SNAME("@export_node_path")) {
|
||||
ScriptCodeCompletionOption node("Node", ScriptCodeCompletionOption::KIND_CLASS);
|
||||
r_result.insert(node.display, node);
|
||||
List<StringName> node_types;
|
||||
|
@ -684,7 +684,7 @@ static void _find_annotation_arguments(const GDScriptParser::AnnotationNode *p_a
|
|||
ScriptCodeCompletionOption option(E, ScriptCodeCompletionOption::KIND_CLASS);
|
||||
r_result.insert(option.display, option);
|
||||
}
|
||||
} else if (p_annotation->name == "@warning_ignore") {
|
||||
} else if (p_annotation->name == SNAME("@warning_ignore")) {
|
||||
for (int warning_code = 0; warning_code < GDScriptWarning::WARNING_MAX; warning_code++) {
|
||||
ScriptCodeCompletionOption warning(GDScriptWarning::get_name_from_code((GDScriptWarning::Code)warning_code).to_lower(), ScriptCodeCompletionOption::KIND_PLAIN_TEXT);
|
||||
r_result.insert(warning.display, warning);
|
||||
|
@ -1384,7 +1384,7 @@ static bool _guess_expression_type(GDScriptParser::CompletionContext &p_context,
|
|||
|
||||
Object *baseptr = base.value;
|
||||
|
||||
if (all_is_const && String(call->function_name) == "get_node" && ClassDB::is_parent_class(native_type.native_type, "Node") && args.size()) {
|
||||
if (all_is_const && call->function_name == SNAME("get_node") && ClassDB::is_parent_class(native_type.native_type, SNAME("Node")) && args.size()) {
|
||||
String arg1 = args[0];
|
||||
if (arg1.begins_with("/root/")) {
|
||||
String which = arg1.get_slice("/", 2);
|
||||
|
@ -2085,7 +2085,7 @@ static bool _guess_method_return_type_from_base(GDScriptParser::CompletionContex
|
|||
GDScriptParser::DataType base_type = p_base.type;
|
||||
bool is_static = base_type.is_meta_type;
|
||||
|
||||
if (is_static && p_method == "new") {
|
||||
if (is_static && p_method == SNAME("new")) {
|
||||
r_type.type = base_type;
|
||||
r_type.type.is_meta_type = false;
|
||||
r_type.type.is_constant = false;
|
||||
|
@ -2274,7 +2274,7 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c
|
|||
r_arghint = _make_arguments_hint(info, p_argidx);
|
||||
}
|
||||
|
||||
if (p_argidx == 0 && ClassDB::is_parent_class(class_name, "Node") && (p_method == "get_node" || p_method == "has_node")) {
|
||||
if (p_argidx == 0 && ClassDB::is_parent_class(class_name, SNAME("Node")) && (p_method == SNAME("get_node") || p_method == SNAME("has_node"))) {
|
||||
// Get autoloads
|
||||
List<PropertyInfo> props;
|
||||
ProjectSettings::get_singleton()->get_property_list(&props);
|
||||
|
@ -2291,7 +2291,7 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c
|
|||
}
|
||||
}
|
||||
|
||||
if (p_argidx == 0 && method_args > 0 && ClassDB::is_parent_class(class_name, "InputEvent") && p_method.operator String().contains("action")) {
|
||||
if (p_argidx == 0 && method_args > 0 && ClassDB::is_parent_class(class_name, SNAME("InputEvent")) && p_method.operator String().contains("action")) {
|
||||
// Get input actions
|
||||
List<PropertyInfo> props;
|
||||
ProjectSettings::get_singleton()->get_property_list(&props);
|
||||
|
|
|
@ -519,7 +519,7 @@ void GDScriptParser::parse_program() {
|
|||
// Check for @tool annotation.
|
||||
AnnotationNode *annotation = parse_annotation(AnnotationInfo::SCRIPT | AnnotationInfo::CLASS_LEVEL);
|
||||
if (annotation != nullptr) {
|
||||
if (annotation->name == "@tool") {
|
||||
if (annotation->name == SNAME("@tool")) {
|
||||
// TODO: don't allow @tool anywhere else. (Should all script annotations be the first thing?).
|
||||
_is_tool = true;
|
||||
if (previous.type != GDScriptTokenizer::Token::NEWLINE) {
|
||||
|
@ -573,7 +573,7 @@ void GDScriptParser::parse_program() {
|
|||
// Check for @icon annotation.
|
||||
AnnotationNode *annotation = parse_annotation(AnnotationInfo::SCRIPT | AnnotationInfo::CLASS_LEVEL);
|
||||
if (annotation != nullptr) {
|
||||
if (annotation->name == "@icon") {
|
||||
if (annotation->name == SNAME("@icon")) {
|
||||
if (previous.type != GDScriptTokenizer::Token::NEWLINE) {
|
||||
push_error(R"(Expected newline after "@icon" annotation.)");
|
||||
}
|
||||
|
@ -3503,7 +3503,7 @@ bool GDScriptParser::export_annotations(const AnnotationNode *p_annotation, Node
|
|||
// This is called after the analyzer is done finding the type, so this should be set here.
|
||||
DataType export_type = variable->get_datatype();
|
||||
|
||||
if (p_annotation->name == "@export") {
|
||||
if (p_annotation->name == SNAME("@export")) {
|
||||
if (variable->datatype_specifier == nullptr && variable->initializer == nullptr) {
|
||||
push_error(R"(Cannot use simple "@export" annotation with variable without type or initializer, since type can't be inferred.)", p_annotation);
|
||||
return false;
|
||||
|
@ -3528,7 +3528,7 @@ bool GDScriptParser::export_annotations(const AnnotationNode *p_annotation, Node
|
|||
variable->export_info.hint_string = Variant::get_type_name(export_type.builtin_type);
|
||||
break;
|
||||
case GDScriptParser::DataType::NATIVE:
|
||||
if (ClassDB::is_parent_class(export_type.native_type, "Resource")) {
|
||||
if (ClassDB::is_parent_class(export_type.native_type, SNAME("Resource"))) {
|
||||
variable->export_info.type = Variant::OBJECT;
|
||||
variable->export_info.hint = PROPERTY_HINT_RESOURCE_TYPE;
|
||||
variable->export_info.hint_string = export_type.native_type;
|
||||
|
|
|
@ -73,23 +73,21 @@ void init_autoloads() {
|
|||
RES res = ResourceLoader::load(info.path);
|
||||
ERR_CONTINUE_MSG(res.is_null(), "Can't autoload: " + info.path);
|
||||
Node *n = nullptr;
|
||||
if (res->is_class("PackedScene")) {
|
||||
Ref<PackedScene> ps = res;
|
||||
n = ps->instantiate();
|
||||
} else if (res->is_class("Script")) {
|
||||
Ref<Script> script_res = res;
|
||||
StringName ibt = script_res->get_instance_base_type();
|
||||
Ref<PackedScene> scn = res;
|
||||
Ref<Script> script = res;
|
||||
if (scn.is_valid()) {
|
||||
n = scn->instantiate();
|
||||
} else if (script.is_valid()) {
|
||||
StringName ibt = script->get_instance_base_type();
|
||||
bool valid_type = ClassDB::is_parent_class(ibt, "Node");
|
||||
ERR_CONTINUE_MSG(!valid_type, "Script does not inherit a Node: " + info.path);
|
||||
|
||||
Object *obj = ClassDB::instantiate(ibt);
|
||||
|
||||
ERR_CONTINUE_MSG(obj == nullptr,
|
||||
"Cannot instance script for autoload, expected 'Node' inheritance, got: " +
|
||||
String(ibt));
|
||||
ERR_CONTINUE_MSG(!obj, "Cannot instance script for autoload, expected 'Node' inheritance, got: " + String(ibt) + ".");
|
||||
|
||||
n = Object::cast_to<Node>(obj);
|
||||
n->set_script(script_res);
|
||||
n->set_script(script);
|
||||
}
|
||||
|
||||
ERR_CONTINUE_MSG(!n, "Path in autoload not a node or script: " + info.path);
|
||||
|
|
|
@ -653,7 +653,6 @@ void VisualScriptEditor::_update_graph(int p_only_id) {
|
|||
|
||||
List<int> ids;
|
||||
script->get_node_list(&ids);
|
||||
StringName editor_icons = "EditorIcons";
|
||||
|
||||
for (int &E : ids) {
|
||||
if (p_only_id >= 0 && p_only_id != E) {
|
||||
|
|
|
@ -1164,9 +1164,6 @@ void VisualScript::_bind_methods() {
|
|||
ClassDB::bind_method(D_METHOD("remove_custom_signal", "name"), &VisualScript::remove_custom_signal);
|
||||
ClassDB::bind_method(D_METHOD("rename_custom_signal", "name", "new_name"), &VisualScript::rename_custom_signal);
|
||||
|
||||
//ClassDB::bind_method(D_METHOD("set_variable_info","name","info"),&VScript::set_variable_info);
|
||||
//ClassDB::bind_method(D_METHOD("get_variable_info","name"),&VScript::set_variable_info);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_instance_base_type", "type"), &VisualScript::set_instance_base_type);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("_set_data", "data"), &VisualScript::_set_data);
|
||||
|
|
|
@ -2495,7 +2495,7 @@ static Node *_find_script_node(Node *p_edited_scene, Node *p_current_node, const
|
|||
VisualScriptSceneNode::TypeGuess VisualScriptSceneNode::guess_output_type(TypeGuess *p_inputs, int p_output) const {
|
||||
VisualScriptSceneNode::TypeGuess tg;
|
||||
tg.type = Variant::OBJECT;
|
||||
tg.gdclass = "Node";
|
||||
tg.gdclass = SNAME("Node");
|
||||
|
||||
#ifdef TOOLS_ENABLED
|
||||
Ref<Script> script = get_visual_script();
|
||||
|
@ -2649,7 +2649,7 @@ VisualScriptNodeInstance *VisualScriptSceneTree::instantiate(VisualScriptInstanc
|
|||
VisualScriptSceneTree::TypeGuess VisualScriptSceneTree::guess_output_type(TypeGuess *p_inputs, int p_output) const {
|
||||
TypeGuess tg;
|
||||
tg.type = Variant::OBJECT;
|
||||
tg.gdclass = "SceneTree";
|
||||
tg.gdclass = SNAME("SceneTree");
|
||||
return tg;
|
||||
}
|
||||
|
||||
|
@ -2766,11 +2766,11 @@ PropertyInfo VisualScriptSelf::get_input_value_port_info(int p_idx) const {
|
|||
}
|
||||
|
||||
PropertyInfo VisualScriptSelf::get_output_value_port_info(int p_idx) const {
|
||||
String type_name;
|
||||
StringName type_name;
|
||||
if (get_visual_script().is_valid()) {
|
||||
type_name = get_visual_script()->get_instance_base_type();
|
||||
} else {
|
||||
type_name = "instance";
|
||||
type_name = SNAME("instance");
|
||||
}
|
||||
|
||||
return PropertyInfo(Variant::OBJECT, type_name);
|
||||
|
@ -2801,7 +2801,7 @@ VisualScriptNodeInstance *VisualScriptSelf::instantiate(VisualScriptInstance *p_
|
|||
VisualScriptSelf::TypeGuess VisualScriptSelf::guess_output_type(TypeGuess *p_inputs, int p_output) const {
|
||||
VisualScriptSceneNode::TypeGuess tg;
|
||||
tg.type = Variant::OBJECT;
|
||||
tg.gdclass = "Object";
|
||||
tg.gdclass = SNAME("Object");
|
||||
|
||||
Ref<Script> script = get_visual_script();
|
||||
if (!script.is_valid()) {
|
||||
|
|
|
@ -1951,7 +1951,7 @@ Error ResourceFormatSaverTextInstance::save(const String &p_path, const RES &p_r
|
|||
}
|
||||
|
||||
Error ResourceFormatSaverText::save(const String &p_path, const RES &p_resource, uint32_t p_flags) {
|
||||
if (p_path.ends_with(".sct") && p_resource->get_class() != "PackedScene") {
|
||||
if (p_path.ends_with(".tscn") && !Ref<PackedScene>(p_resource).is_valid()) {
|
||||
return ERR_FILE_UNRECOGNIZED;
|
||||
}
|
||||
|
||||
|
@ -1960,14 +1960,14 @@ Error ResourceFormatSaverText::save(const String &p_path, const RES &p_resource,
|
|||
}
|
||||
|
||||
bool ResourceFormatSaverText::recognize(const RES &p_resource) const {
|
||||
return true; // all recognized!
|
||||
return true; // All resources recognized!
|
||||
}
|
||||
|
||||
void ResourceFormatSaverText::get_recognized_extensions(const RES &p_resource, List<String> *p_extensions) const {
|
||||
if (p_resource->get_class() == "PackedScene") {
|
||||
p_extensions->push_back("tscn"); //text scene
|
||||
if (Ref<PackedScene>(p_resource).is_valid()) {
|
||||
p_extensions->push_back("tscn"); // Text scene.
|
||||
} else {
|
||||
p_extensions->push_back("tres"); //text resource
|
||||
p_extensions->push_back("tres"); // Text resource.
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue