Fix SM replays
This commit is contained in:
@ -1,5 +1,10 @@
|
||||
package;
|
||||
|
||||
import haxe.Exception;
|
||||
#if sys
|
||||
import smTools.SMFile;
|
||||
import sys.FileSystem;
|
||||
import sys.io.File;
|
||||
#end
|
||||
import openfl.geom.Matrix;
|
||||
import openfl.display.BitmapData;
|
||||
import flixel.system.FlxSound;
|
||||
@ -210,6 +215,7 @@ class ResultsScreen extends FlxSubState
|
||||
PlayState.rep = Replay.LoadReplay(PlayState.rep.path);
|
||||
|
||||
PlayState.loadRep = true;
|
||||
PlayState.isSM = PlayState.rep.replay.sm;
|
||||
|
||||
var songFormat = StringTools.replace(PlayState.rep.replay.songName, " ", "-");
|
||||
switch (songFormat) {
|
||||
@ -231,11 +237,43 @@ class ResultsScreen extends FlxSubState
|
||||
Highscore.saveCombo(songHighscore, Ratings.GenerateLetterRank(PlayState.instance.accuracy),PlayState.storyDifficulty);
|
||||
#end
|
||||
|
||||
var poop:String = Highscore.formatSong(songFormat, PlayState.rep.replay.songDiff);
|
||||
#if sys
|
||||
if (PlayState.rep.replay.sm)
|
||||
if (!FileSystem.exists(StringTools.replace(PlayState.rep.replay.chartPath,"converted.json","")))
|
||||
{
|
||||
Application.current.window.alert("The SM file in this replay does not exist!","SM Replays");
|
||||
return;
|
||||
}
|
||||
#end
|
||||
|
||||
var poop = "";
|
||||
|
||||
#if sys
|
||||
if (PlayState.isSM)
|
||||
{
|
||||
poop = File.getContent(PlayState.rep.replay.chartPath);
|
||||
try
|
||||
{
|
||||
PlayState.sm = SMFile.loadFile(PlayState.pathToSm + "/" + StringTools.replace(PlayState.rep.replay.songName," ", "_") + ".sm");
|
||||
}
|
||||
catch(e:Exception)
|
||||
{
|
||||
Application.current.window.alert("Make sure that the SM file is called " + PlayState.pathToSm + "/" + StringTools.replace(PlayState.rep.replay.songName," ", "_") + ".sm!\nAs I couldn't read it.","SM Replays");
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
poop = Highscore.formatSong(songFormat, PlayState.rep.replay.songDiff);
|
||||
#else
|
||||
poop = Highscore.formatSong(PlayState.rep.replay.songName, PlayState.rep.replay.songDiff);
|
||||
#end
|
||||
|
||||
music.fadeOut(0.3);
|
||||
|
||||
PlayState.SONG = Song.loadFromJson(poop, PlayState.rep.replay.songName);
|
||||
if (PlayState.isSM)
|
||||
PlayState.SONG = Song.loadFromJsonRAW(poop);
|
||||
else
|
||||
PlayState.SONG = Song.loadFromJson(poop, PlayState.rep.replay.songName);
|
||||
PlayState.isStoryMode = false;
|
||||
PlayState.storyDifficulty = PlayState.rep.replay.songDiff;
|
||||
LoadingState.loadAndSwitchState(new PlayState());
|
||||
|
Reference in New Issue
Block a user