@@ -17,8 +17,10 @@ static func reset_svg() -> void:
1717 if FileAccess .file_exists (file_path ):
1818 State .apply_svg_text (FileAccess .get_file_as_string (file_path ))
1919
20- static func apply_svgs_from_paths (paths : PackedStringArray ) -> void :
21- _start_file_import_process (paths , _apply_svg , PackedStringArray (["svg" ]))
20+ static func apply_svgs_from_paths (paths : PackedStringArray ,
21+ show_incorrect_extension_errors := true ) -> void :
22+ _start_file_import_process (paths , _apply_svg , PackedStringArray (["svg" ]),
23+ show_incorrect_extension_errors )
2224
2325static func compare_svg_to_disk_contents (idx := - 1 ) -> FileState :
2426 var tab := Configs .savedata .get_active_tab () if idx == - 1 else Configs .savedata .get_tab (idx )
@@ -216,16 +218,28 @@ completion_callback: Callable, multi_select := false) -> void:
216218
217219# Preprocessing step where all files with wrong extensions are discarded.
218220static func _start_file_import_process (file_paths : PackedStringArray ,
219- completion_callback : Callable , allowed_extensions : PackedStringArray ) -> void :
221+ completion_callback : Callable , allowed_extensions : PackedStringArray ,
222+ show_incorrect_extension_errors := true ) -> void :
223+ if not show_incorrect_extension_errors :
224+ for i in range (file_paths .size () - 1 , - 1 , - 1 ):
225+ if not file_paths [i ].get_extension () in allowed_extensions :
226+ file_paths .remove_at (i )
227+ if not file_paths .is_empty ():
228+ _file_import_proceed (file_paths , completion_callback )
229+ return
230+
220231 var incorrect_extension_file_paths := PackedStringArray ()
221232 for i in range (file_paths .size () - 1 , - 1 , - 1 ):
222233 if not file_paths [i ].get_extension () in allowed_extensions :
223234 incorrect_extension_file_paths .append (Utils .simplify_file_path (file_paths [i ]))
224235 file_paths .remove_at (i )
225236
237+ if file_paths .is_empty ():
238+ return
239+
226240 var proceed_callback := _file_import_proceed .bind (file_paths , completion_callback )
227241
228- if not incorrect_extension_file_paths .is_empty ():
242+ if show_incorrect_extension_errors and not incorrect_extension_file_paths .is_empty ():
229243 var error_text := TranslationUtils .get_extension_alert_text (allowed_extensions ) + "\n "
230244 var passed_list := PackedStringArray () # Only pass if there are more than two.
231245 if incorrect_extension_file_paths .size () >= 2 :
0 commit comments