2021-03-27 15:53:32 +01:00
extends Node
2021-05-18 06:56:35 +02:00
### Contains info about disabled classes and allows to take info about allowed methods
2021-04-04 12:52:42 +02:00
2021-05-18 06:56:35 +02:00
# Globablly disabled functions for all classes
2022-01-06 08:36:36 +01:00
var function_exceptions : Array = [
# They exists without assigment like Class.method, because they may be a parent of other objects and children also should have disabled child.method, its children also etc. which is too much to do
###
### Godot 4.0
###
" set_mesh " , # 55266
" set_use_all_surfaces " , # 55266
" set_visibility_range_begin_margin " , #54655
" set_visibility_range_begin " , #54655
" map_pattern " , #54103
" _broadcast " , #53873
" get_indexed " , #53840
" make_polygons_from_outlines " , #53808
" set_clip_children " , #53667
" set_base " , #53723
" set_polygon " , #53722
" add_bone " , #53646
" set_bone_children " , #53646
" global_pose_z_forward_to_bone_forward " , #53646
" lightmap_unwrap " , # 52929
" get_property_list " , #53604
" set_projector " , #53604
" commit " , #53191
" commit_to_arrays " , #53191
" popup_centered_ratio " , #53566
" set_stream " , #52853
" shaped_text_draw_outline " , #53562
" set_input_as_handled " , #53560
" add_node " , #53558
" set_language " , #53218
" set_texture " , #46828
" _activate " , #45984
" compress_from_channels " , # Image
" open_midi_inputs " , #52821
" load_threaded_request " , #46762
" bake_navigation_mesh " , # TODO too hard to find for now
" set_is_setup " , # Just don't use, in SkeletonModification crashes
" _update_shape " , # TODO, probably crashes exported build
" get_custom_monitor " , # TODO crashes only in exported build
###
### Input crashes, still are some problems TODO
###
" _gui_input " ,
2021-05-18 06:56:35 +02:00
" _input " ,
2022-01-06 08:36:36 +01:00
" _unhandled_input " ,
2021-05-18 06:56:35 +02:00
" _unhandled_key_input " ,
2022-01-06 08:36:36 +01:00
" _vp_input " ,
" _vp_unhandled_input " ,
###
### Reported crashes
###
" lightmap_unwrap " , # 52929
" replace_by " , #53775
" bake " , #53774
" create_debug_tangents " , #53182
" create_from_mesh " , #53181
" remove_line " , # 49571 - Memory leak
" connect_to_signal " , # 53622
" set_extra_cull_margin " , # 53623
" _thread_done " , #53621
" set_physics_enabled " , #53620
" _iter_init " , #53554
" set_block_signals " , #53553
" make_atlas " , #51154
" set_basic_type " , #53456
" set_custom_viewport " , #53445
" _draw_soft_mesh " , #53437
" light_unwrap " , #52929
" create_action " , #50769
" _editor_settings_changed " , # 45979
" set_script " , #46120
" set_icon " , #46189
" set_editor_hint " , #46252 - Fixed only for master(due compatibility)
" set_probe_data " , #46570
" add_vertex " , #47066
" create_shape_owner " , #47135
" shape_owner_get_owner " , #47135
" get_bind_bone " , #47358
" get_bind_name " , #47358
" get_bind_pose " , #47358
" decompress " , #50787
" convert " , # 46479
" save_png_to_buffer " , # 50787
###
### Not worth to check, cause a lot of crashes but it is very unlikelly that users will use them
###
2021-03-27 15:53:32 +01:00
" propagate_notification " ,
" notification " ,
2022-01-06 08:36:36 +01:00
###
### Error spam when using it TODO
###
" get_recognized_extensions_for_type " , # Spam
" load " , # Spam - _ResourceLoader
2021-03-27 15:53:32 +01:00
" add_sphere " ,
2022-01-06 08:36:36 +01:00
" _update_inputs " ,
2021-03-27 15:53:32 +01:00
" update_bitmask_region " ,
2021-04-04 12:52:42 +02:00
" set_enabled_inputs " ,
2022-01-06 08:36:36 +01:00
###
### Slow Function
###
" set_pre_process_time " ,
" create_convex_collision " ,
" create_multiple_convex_collisions " ,
" load_webp_from_buffer " ,
2021-03-27 15:53:32 +01:00
" _update_sky " ,
2022-01-06 08:36:36 +01:00
" interpolate_baked " ,
" get_baked_length " ,
" get_baked_points " ,
" get_closest_offset " ,
" get_closest_point " , # Only Curve, but looks that a lot of other classes uses this
" get_baked_up_vectors " ,
" interpolate_baked_up_vector " ,
" tessellate " ,
" get_baked_tilts " ,
" set_enabled_inputs " ,
" grow_mask " ,
" force_update_transform " ,
" is_enabler_enabled " ,
" set_enabler " ,
" get_aabb " ,
" set_aabb " ,
" is_on_screen " ,
" set_rings " ,
" set_amount " ,
###
### Do not save files and create files and folders, this probably can be enabled in CI
###
2021-03-27 15:53:32 +01:00
" pck_start " ,
" save " ,
" save_png " ,
" save_to_wav " ,
" save_to_file " ,
" make_dir " ,
" make_dir_recursive " ,
" save_encrypted " ,
" save_encrypted_pass " ,
" save_exr " ,
" dump_resources_to_file " ,
" dump_memory_to_file " ,
2022-01-06 08:36:36 +01:00
###
### This also allow to save files
###
2021-03-27 15:53:32 +01:00
" open " ,
" open_encrypted " ,
" open_encrypted_with_pass " ,
" open_compressed " ,
2022-01-06 08:36:36 +01:00
###
### Do not warp mouse, because I'm unable to do anything
###
2021-03-27 15:53:32 +01:00
" warp_mouse " ,
" warp_mouse_position " ,
2022-01-06 08:36:36 +01:00
###
### OS
###
2021-03-27 15:53:32 +01:00
" kill " ,
" shell_open " ,
" execute " ,
2022-01-06 08:36:36 +01:00
" alert " , # Stupid alert window opens
###
### Godot freeze or run very cslow
###
" poll " ,
2021-03-27 15:53:32 +01:00
" delay_usec " ,
" delay_msec " ,
" wait_to_finish " ,
" accept_stream " ,
" connect_to_stream " ,
" discover " ,
" wait " ,
" debug_bake " ,
" bake " ,
2022-01-06 08:36:36 +01:00
" set_gizmo " , # Stupid function, needs as parameter an object which can't be instanced # TODO, create issue to hide it
###
### Spams Output and aren't very useful
###
2021-03-27 15:53:32 +01:00
" print_tree " ,
" print_stray_nodes " ,
" print_tree_pretty " ,
" print_all_textures_by_size " ,
" print_all_resources " ,
" print_resources_in_use " ,
2022-01-06 08:36:36 +01:00
###
### Can call other functions and broke everything
###
2021-03-27 15:53:32 +01:00
" _call_function " ,
" call " ,
" call_deferred " ,
" callv " ,
" call_func " ,
2022-01-06 08:36:36 +01:00
###
### Too dangerous, because add, mix and remove randomly nodes and objects
###
2021-03-27 15:53:32 +01:00
" replace_by " ,
" create_instance " ,
" set_owner " ,
" set_root_node " ,
2022-01-06 08:36:36 +01:00
" instantiate " ,
2021-03-27 15:53:32 +01:00
" init_ref " ,
" reference " ,
" unreference " ,
" new " ,
" duplicate " ,
" queue_free " ,
" free " ,
" remove_and_skip " ,
" remove_child " ,
" move_child " ,
" raise " ,
" add_child " ,
2021-04-04 12:52:42 +02:00
" add_sibling " ,
2022-01-06 08:36:36 +01:00
#####
##### Goost
##### TODO: these take too long to execute, does not make sense to limit number of iterations ether.
##### TODO - remove this and put it into setting file
#####
" smooth_polyline_approx " ,
" smooth_polygon_approx " ,
2021-03-27 15:53:32 +01:00
]
2021-04-04 12:52:42 +02:00
2022-01-06 08:36:36 +01:00
# Globally disabled classes which causes bugs or are very hard to use properly
var disabled_classes : Array = [
" GLTFDocument " , # TODO memory leak
###
### Crashes, Freezes
###
" ProjectSettings " , # Don't mess with project settings, because they can broke entire your workflow
" EditorSettings " , # Also don't mess with editor settings
" GDScript " , # Broke script
" SceneTree " ,
" JNISingleton " , # Freeze - who use it?
" Engine " , # Crashes only in Godot 4 but not really usable
###
### JavaClass is only functions that returns Null when using JavaClass.new().get_class
###
2021-05-18 06:56:35 +02:00
" JavaClass " ,
2022-01-06 08:36:36 +01:00
###
### Android
###
" JavaClassWrapper " , # Looks that JavaClassWrapper.new() crashes android
###
### Exported build - some checks are disabled in exported build due to too big performance impact
###
2021-03-27 15:53:32 +01:00
" Image " ,
2022-01-06 08:36:36 +01:00
# TODOGODOT4 - update here exluded list from Godot4
###
### Godot 4.0
###
" OS " ,
" Thread " ,
" Semaphore " ,
" Mutex " ,
" GodotSharp " ,
# Class which is non instantable, and have non instantable childrens, but
# is used as argument
" Node3DGizmo " ,
2021-04-15 19:13:17 +02:00
# Creating them is really slow in Godot 4.0
" ColorPicker " ,
" FileDialog " ,
" ColorPickerButton " ,
" PhysicalSkyMaterial " ,
" ProceduralSkyMaterial "
2021-03-27 15:53:32 +01:00
]
2022-01-06 08:36:36 +01:00
2021-04-04 12:52:42 +02:00
# Checks if function can be executed
2022-01-06 08:36:36 +01:00
# Looks at its arguments and checks if are recognized and supported
func check_if_is_allowed ( method_data : Dictionary ) - > bool :
2021-05-18 06:56:35 +02:00
# Function is virtual or vararg, so we just skip it
2022-01-06 08:36:36 +01:00
if method_data [ " flags " ] == method_data [ " flags " ] | METHOD_FLAG_VIRTUAL :
2021-04-04 12:52:42 +02:00
return false
2022-01-06 08:36:36 +01:00
if method_data [ " flags " ] == method_data [ " flags " ] | 128 : # VARARG TODO, Godot issue, add missing flag binding
2021-04-21 16:41:27 +02:00
return false
2022-01-06 08:36:36 +01:00
for arg in method_data [ " args " ] :
var name_of_class : String = arg [ " class_name " ]
2021-04-04 12:52:42 +02:00
if name_of_class . is_empty ( ) :
continue
if name_of_class in disabled_classes :
return false
2022-01-06 08:36:36 +01:00
if ! ClassDB . class_exists ( name_of_class ) :
2021-04-04 12:52:42 +02:00
return false
2022-01-06 08:36:36 +01:00
if ! ClassDB . is_parent_class ( name_of_class , " Node " ) && ! ClassDB . is_parent_class ( name_of_class , " RefCounted " ) :
return false
2021-05-18 06:56:35 +02:00
if name_of_class . find ( " Editor " ) != - 1 || name_of_class . find ( " SkinReference " ) != - 1 :
2021-04-04 12:52:42 +02:00
return false
2022-01-06 08:36:36 +01:00
2021-05-18 06:56:35 +02:00
# In case of adding new type, this prevents from crashing due not recognizing this type
# In case of removing/rename type, just comment e.g. TYPE_ARRAY and all occurencies on e.g. switch statement with it
2022-01-06 08:36:36 +01:00
var t : int = arg [ " type " ]
if ! (
t == TYPE_NIL
|| t == TYPE_CALLABLE
|| t == TYPE_MAX
|| t == TYPE_AABB
|| t == TYPE_ARRAY
|| t == TYPE_BASIS
|| t == TYPE_BOOL
|| t == TYPE_COLOR
|| t == TYPE_COLOR_ARRAY
|| t == TYPE_DICTIONARY
|| t == TYPE_INT
|| t == TYPE_INT32_ARRAY
|| t == TYPE_INT64_ARRAY
|| t == TYPE_NODE_PATH
|| t == TYPE_OBJECT
|| t == TYPE_PLANE
|| t == TYPE_QUATERNION
|| t == TYPE_RAW_ARRAY
|| t == TYPE_FLOAT
|| t == TYPE_FLOAT32_ARRAY
|| t == TYPE_FLOAT64_ARRAY
|| t == TYPE_RECT2
|| t == TYPE_RECT2I
|| t == TYPE_RID
|| t == TYPE_STRING
|| t == TYPE_STRING_NAME
|| t == TYPE_STRING_ARRAY
|| t == TYPE_TRANSFORM3D
|| t == TYPE_TRANSFORM2D
|| t == TYPE_VECTOR2
|| t == TYPE_VECTOR2I
|| t == TYPE_VECTOR2_ARRAY
|| t == TYPE_VECTOR3
|| t == TYPE_VECTOR3I
|| t == TYPE_VECTOR3_ARRAY
) :
print ( " ----------------------------------------------------------- TODO - MISSING TYPE, ADD SUPPORT IT " ) # Add assert here to get info which type is missing
2021-04-04 12:52:42 +02:00
return false
2022-01-06 08:36:36 +01:00
2021-04-04 12:52:42 +02:00
return true
2022-01-06 08:36:36 +01:00
# Removes disabled methods from classes
func remove_disabled_methods ( method_list : Array , exceptions : Array ) - > Array :
var new_list : Array = [ ] # Workaround for GH 50139 renaming remove to remove_at
2021-07-06 17:59:07 +02:00
for method_index in range ( method_list . size ( ) ) :
2021-05-18 06:56:35 +02:00
var index : int = - 1
2021-07-06 17:59:07 +02:00
for exception in exceptions :
2021-05-18 06:56:35 +02:00
if method_list [ method_index ] . get ( " name " ) == exception :
index = method_index
break
2021-07-06 17:59:07 +02:00
if index == - 1 :
new_list . append ( method_list [ method_index ] )
2022-01-06 08:36:36 +01:00
2021-07-06 17:59:07 +02:00
method_list = new_list
return new_list
2021-06-04 21:44:10 +02:00
2021-05-18 06:56:35 +02:00
# Return all available classes which can be used
2022-01-06 08:36:36 +01:00
func get_list_of_available_classes ( must_be_instantable : bool = true ) - > Array :
var full_class_list : Array = Array ( ClassDB . get_class_list ( ) )
var classes : Array = [ ]
2021-03-27 15:53:32 +01:00
full_class_list . sort ( )
var c = 0
for name_of_class in full_class_list :
if name_of_class in disabled_classes :
continue
2021-04-04 12:52:42 +02:00
#This is only for RegressionTestProject, because it needs for now clear visual info what is going on screen, but some nodes broke view
2022-01-06 08:36:36 +01:00
if ! ClassDB . is_parent_class ( name_of_class , " Node " ) && ! ClassDB . is_parent_class ( name_of_class , " RefCounted " ) :
2021-03-27 15:53:32 +01:00
continue
2022-01-06 08:36:36 +01:00
# Don't test Servers objects like TranslationServer
if name_of_class . find ( " Server " ) != - 1 :
2021-03-27 15:53:32 +01:00
continue
2022-01-06 08:36:36 +01:00
# Don't test Editor nodes
if name_of_class . find ( " Editor " ) != - 1 :
continue
2021-06-22 07:00:48 +02:00
if ! must_be_instantable || ClassDB . can_instantiate ( name_of_class ) :
2021-03-27 15:53:32 +01:00
classes . push_back ( name_of_class )
2022-01-06 08:36:36 +01:00
c += 1
2021-03-27 15:53:32 +01:00
print ( str ( c ) + " choosen classes from all " + str ( full_class_list . size ( ) ) + " classes. " )
return classes