@@ -11,7 +11,7 @@ const DownloadAndExtract = MaaacksGameTemplatePlugin.DownloadAndExtract
1111const RELATIVE_PATH_TO_CONFIGURE_SCENE = "scenes/menus/options_menu/input/input_icon_mapper.tscn"
1212const REIMPORT_CHECK_DELAY : float = 0.5
1313const OPEN_SCENE_DELAY : float = 0.5
14- const REGEX_PREFIX = """\\ [node name="InputIconMapper" type="Node "\\ ] [\\ s\\ S]*"""
14+ const MATCH_REGEX = """( \\ [node name="InputIconMapper" instance=ExtResource \\ ("[0-9a-z_]+ "\\ ) \\ ]) [\\ s\\ S]*"""
1515
1616const FILLED_WHITE_CONFIGURATION = """
1717replace_strings = {
@@ -223,31 +223,35 @@ func _delete_extras() -> void:
223223 EditorInterface .get_resource_filesystem ().scan ()
224224
225225func _configure_icons () -> void :
226- var input_options_menu_path := copy_dir_path + RELATIVE_PATH_TO_CONFIGURE_SCENE
227- var input_options_menu := FileAccess .get_file_as_string (input_options_menu_path )
226+ var input_mapper_path := copy_dir_path + RELATIVE_PATH_TO_CONFIGURE_SCENE
227+ var icon_mapper_string := FileAccess .get_file_as_string (input_mapper_path )
228+ var replacing_string := "$1\n "
228229 match (_configuration_index % 4 ):
229230 0 :
230- input_options_menu += FILLED_COLOR_CONFIGURATION
231+ replacing_string += FILLED_COLOR_CONFIGURATION
231232 1 :
232- input_options_menu += FILLED_WHITE_CONFIGURATION
233+ replacing_string += FILLED_WHITE_CONFIGURATION
233234 2 :
234- input_options_menu += OUTLINED_COLOR_CONFIGURATION
235+ replacing_string += OUTLINED_COLOR_CONFIGURATION
235236 3 :
236- input_options_menu += OUTLINED_WHITE_CONFIGURATION
237+ replacing_string += OUTLINED_WHITE_CONFIGURATION
237238 match (_configuration_index / 4 ):
238239 0 :
239- input_options_menu = input_options_menu .replace ("Default" , "Vector" ).replace (".png" , ".svg" )
240+ replacing_string = replacing_string .replace ("Default" , "Vector" ).replace (".png" , ".svg" )
240241 1 :
241242 pass
242243 2 :
243- input_options_menu = input_options_menu .replace ("Default" , "Double" )
244- var file_rewrite := FileAccess .open (input_options_menu_path , FileAccess .WRITE )
245- file_rewrite .store_string (input_options_menu )
244+ replacing_string = replacing_string .replace ("Default" , "Double" )
245+ var regex = RegEx .new ()
246+ regex .compile (MATCH_REGEX )
247+ icon_mapper_string = regex .sub (icon_mapper_string , replacing_string )
248+ var file_rewrite := FileAccess .open (input_mapper_path , FileAccess .WRITE )
249+ file_rewrite .store_string (icon_mapper_string )
246250 file_rewrite .close ()
247- if input_options_menu_path in EditorInterface .get_open_scenes ():
248- EditorInterface .reload_scene_from_path (input_options_menu_path )
251+ if input_mapper_path in EditorInterface .get_open_scenes ():
252+ EditorInterface .reload_scene_from_path (input_mapper_path )
249253 else :
250- EditorInterface .open_scene_from_path (input_options_menu_path )
254+ EditorInterface .open_scene_from_path (input_mapper_path )
251255 await get_tree ().create_timer (OPEN_SCENE_DELAY ).timeout
252256 EditorInterface .save_scene ()
253257 await get_tree ().create_timer (REIMPORT_CHECK_DELAY ).timeout
0 commit comments