From 7217c91e576b098424e0c3ba47a8aaa00f0df207 Mon Sep 17 00:00:00 2001 From: Lily Date: Sat, 14 Dec 2024 23:41:37 +0300 Subject: [PATCH] fix the crash --- .../mobile/funkin/backend/system/CopyState.hx | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/source/mobile/funkin/backend/system/CopyState.hx b/source/mobile/funkin/backend/system/CopyState.hx index b3927073f..e114d8965 100644 --- a/source/mobile/funkin/backend/system/CopyState.hx +++ b/source/mobile/funkin/backend/system/CopyState.hx @@ -35,7 +35,6 @@ import haxe.io.Path; import mobile.funkin.backend.utils.MobileUtil; import funkin.backend.assets.Paths; import funkin.backend.utils.NativeAPI; -import funkin.backend.system.MainState; import flixel.ui.FlxBar; import flixel.ui.FlxBar.FlxBarFillDirection; @@ -53,7 +52,7 @@ using StringTools; class CopyState extends funkin.backend.MusicBeatState { private static final textFilesExtensions:Array = ['ini', 'txt', 'xml', 'hxs', 'hx', 'lua', 'json', 'frag', 'vert']; - public static final IGNORE_FOLDER_FILE_NAME:String = "ignore.txt"; + public static final IGNORE_FOLDER_FILE_NAME:String = "CopyState-Ignore.txt"; private static var directoriesToIgnore:Array = []; public static var locatedFiles:Array = []; public static var maxLoopTimes:Int = 0; @@ -76,12 +75,12 @@ class CopyState extends funkin.backend.MusicBeatState checkExistingFiles(); if (maxLoopTimes <= 0) { - FlxG.switchState(new MainState()); + FlxG.resetGame(); return; } NativeAPI.showMessageBox("Notice", "Seems like you have some missing files that are necessary to run the game\nPress OK to begin the copy process"); - + shouldCopy = true; add(new FlxSprite(0, 0).makeGraphic(FlxG.width, FlxG.height, 0xffcaff4d)); @@ -126,8 +125,9 @@ class CopyState extends funkin.backend.MusicBeatState File.saveContent('logs/' + Date.now().toString().replace(' ', '-').replace(':', "'") + '-CopyState' + '.txt', failedFilesStack.join('\n')); } canUpdate = false; - FlxG.sound.play(Paths.sound('menu/confirm')).onComplete = () -> { - FlxG.switchState(new MainState()); + FlxG.sound.play(Paths.sound('menu/confirm')).onComplete = () -> + { + FlxG.resetGame(); }; } @@ -219,7 +219,7 @@ class CopyState extends funkin.backend.MusicBeatState public static function checkExistingFiles():Bool { - locatedFiles = OpenFLAssets.list(); + locatedFiles = Paths.assetsTree.list(null); // removes unwanted assets var assets = locatedFiles.filter(folder -> folder.startsWith('assets/')); @@ -234,7 +234,7 @@ class CopyState extends funkin.backend.MusicBeatState if (filesToRemove.contains(file)) continue; - if(file.endsWith(IGNORE_FOLDER_FILE_NAME) && !directoriesToIgnore.contains(Path.directory(file))) + if (file.endsWith(IGNORE_FOLDER_FILE_NAME) && !directoriesToIgnore.contains(Path.directory(file))) directoriesToIgnore.push(Path.directory(file)); if (directoriesToIgnore.length > 0) @@ -251,6 +251,8 @@ class CopyState extends funkin.backend.MusicBeatState maxLoopTimes = locatedFiles.length; + trace(maxLoopTimes); + return (maxLoopTimes <= 0); } }