Skip to content

Commit

Permalink
fix the crash
Browse files Browse the repository at this point in the history
  • Loading branch information
mcagabe19 committed Dec 14, 2024
1 parent f63cc31 commit 7217c91
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions source/mobile/funkin/backend/system/CopyState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -53,7 +52,7 @@ using StringTools;
class CopyState extends funkin.backend.MusicBeatState
{
private static final textFilesExtensions:Array<String> = ['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<String> = [];
public static var locatedFiles:Array<String> = [];
public static var maxLoopTimes:Int = 0;
Expand All @@ -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));
Expand Down Expand Up @@ -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();
};
}

Expand Down Expand Up @@ -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/'));
Expand All @@ -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)
Expand All @@ -251,6 +251,8 @@ class CopyState extends funkin.backend.MusicBeatState

maxLoopTimes = locatedFiles.length;

trace(maxLoopTimes);

return (maxLoopTimes <= 0);
}
}
Expand Down

0 comments on commit 7217c91

Please sign in to comment.