Fix SM replays
This commit is contained in:
parent
6c1372a5fb
commit
7512c87425
@ -1,5 +1,12 @@
|
|||||||
package;
|
package;
|
||||||
|
|
||||||
|
import haxe.Exception;
|
||||||
|
import lime.app.Application;
|
||||||
|
|
||||||
|
#if sys
|
||||||
|
import smTools.SMFile;
|
||||||
|
import sys.FileSystem;
|
||||||
|
#end
|
||||||
import Controls.KeyboardScheme;
|
import Controls.KeyboardScheme;
|
||||||
import Controls.Control;
|
import Controls.Control;
|
||||||
import flash.text.TextField;
|
import flash.text.TextField;
|
||||||
@ -164,9 +171,55 @@ class LoadReplayState extends MusicBeatState
|
|||||||
case 'philly-nice': songFormat = 'Philly';
|
case 'philly-nice': songFormat = 'Philly';
|
||||||
}
|
}
|
||||||
|
|
||||||
var poop:String = Highscore.formatSong(songFormat, PlayState.rep.replay.songDiff);
|
var poop = "";
|
||||||
|
|
||||||
PlayState.SONG = Song.loadFromJson(poop, PlayState.rep.replay.songName);
|
#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
|
||||||
|
|
||||||
|
PlayState.isSM = PlayState.rep.replay.sm;
|
||||||
|
#if sys
|
||||||
|
if (PlayState.isSM)
|
||||||
|
PlayState.pathToSm = StringTools.replace(PlayState.rep.replay.chartPath,"converted.json","");
|
||||||
|
#end
|
||||||
|
|
||||||
|
#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(songFormat, PlayState.rep.replay.songDiff);
|
||||||
|
#end
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (PlayState.isSM)
|
||||||
|
PlayState.SONG = Song.loadFromJsonRAW(poop);
|
||||||
|
else
|
||||||
|
PlayState.SONG = Song.loadFromJson(poop, PlayState.rep.replay.songName);
|
||||||
|
}
|
||||||
|
catch(e:Exception)
|
||||||
|
{
|
||||||
|
Application.current.window.alert("Failed to load the song! Does the JSON exist?","Replays");
|
||||||
|
return;
|
||||||
|
}
|
||||||
PlayState.isStoryMode = false;
|
PlayState.isStoryMode = false;
|
||||||
PlayState.storyDifficulty = PlayState.rep.replay.songDiff;
|
PlayState.storyDifficulty = PlayState.rep.replay.songDiff;
|
||||||
PlayState.storyWeek = getWeekNumbFromSong(PlayState.rep.replay.songName);
|
PlayState.storyWeek = getWeekNumbFromSong(PlayState.rep.replay.songName);
|
||||||
|
@ -84,6 +84,10 @@ class Note extends FlxSprite
|
|||||||
{
|
{
|
||||||
this.strumTime = strumTime;
|
this.strumTime = strumTime;
|
||||||
rStrumTime = strumTime - (FlxG.save.data.offset + PlayState.songOffset);
|
rStrumTime = strumTime - (FlxG.save.data.offset + PlayState.songOffset);
|
||||||
|
#if sys
|
||||||
|
if (PlayState.isSM)
|
||||||
|
rStrumTime = rStrumTime - Std.parseFloat(PlayState.sm.header.OFFSET);
|
||||||
|
#end
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -45,8 +45,10 @@ typedef ReplayJSON =
|
|||||||
public var songNotes:Array<Dynamic>;
|
public var songNotes:Array<Dynamic>;
|
||||||
public var songJudgements:Array<String>;
|
public var songJudgements:Array<String>;
|
||||||
public var noteSpeed:Float;
|
public var noteSpeed:Float;
|
||||||
|
public var chartPath:String;
|
||||||
public var isDownscroll:Bool;
|
public var isDownscroll:Bool;
|
||||||
public var sf:Int;
|
public var sf:Int;
|
||||||
|
public var sm:Bool;
|
||||||
public var ana:Analysis;
|
public var ana:Analysis;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,6 +68,8 @@ class Replay
|
|||||||
isDownscroll: false,
|
isDownscroll: false,
|
||||||
songNotes: [],
|
songNotes: [],
|
||||||
replayGameVer: version,
|
replayGameVer: version,
|
||||||
|
chartPath: "",
|
||||||
|
sm: false,
|
||||||
timestamp: Date.now(),
|
timestamp: Date.now(),
|
||||||
sf: Conductor.safeFrames,
|
sf: Conductor.safeFrames,
|
||||||
ana: new Analysis(),
|
ana: new Analysis(),
|
||||||
@ -86,20 +90,28 @@ class Replay
|
|||||||
|
|
||||||
public function SaveReplay(notearray:Array<Dynamic>, judge:Array<String>, ana:Analysis)
|
public function SaveReplay(notearray:Array<Dynamic>, judge:Array<String>, ana:Analysis)
|
||||||
{
|
{
|
||||||
|
#if sys
|
||||||
|
var chartPath = PlayState.isSM ? PlayState.pathToSm + "/converted.json" : "";
|
||||||
|
#else
|
||||||
|
var chartPath = "";
|
||||||
|
#end
|
||||||
|
|
||||||
var json = {
|
var json = {
|
||||||
"songName": PlayState.SONG.song,
|
"songName": PlayState.SONG.song,
|
||||||
"songDiff": PlayState.storyDifficulty,
|
"songDiff": PlayState.storyDifficulty,
|
||||||
|
"chartPath": chartPath,
|
||||||
|
"sm": PlayState.isSM,
|
||||||
|
"timestamp": Date.now(),
|
||||||
|
"replayGameVer": version,
|
||||||
|
"sf": Conductor.safeFrames,
|
||||||
"noteSpeed": (FlxG.save.data.scrollSpeed > 1 ? FlxG.save.data.scrollSpeed : PlayState.SONG.speed),
|
"noteSpeed": (FlxG.save.data.scrollSpeed > 1 ? FlxG.save.data.scrollSpeed : PlayState.SONG.speed),
|
||||||
"isDownscroll": FlxG.save.data.downscroll,
|
"isDownscroll": FlxG.save.data.downscroll,
|
||||||
"songNotes": notearray,
|
"songNotes": notearray,
|
||||||
"songJudgements": judge,
|
"songJudgements": judge,
|
||||||
"timestamp": Date.now(),
|
|
||||||
"replayGameVer": version,
|
|
||||||
"sf": Conductor.safeFrames,
|
|
||||||
"ana": ana
|
"ana": ana
|
||||||
};
|
};
|
||||||
|
|
||||||
var data:String = Json.stringify(json);
|
var data:String = Json.stringify(json, null, "");
|
||||||
|
|
||||||
var time = Date.now().getTime();
|
var time = Date.now().getTime();
|
||||||
|
|
||||||
|
@ -1,5 +1,10 @@
|
|||||||
package;
|
package;
|
||||||
|
import haxe.Exception;
|
||||||
|
#if sys
|
||||||
|
import smTools.SMFile;
|
||||||
|
import sys.FileSystem;
|
||||||
|
import sys.io.File;
|
||||||
|
#end
|
||||||
import openfl.geom.Matrix;
|
import openfl.geom.Matrix;
|
||||||
import openfl.display.BitmapData;
|
import openfl.display.BitmapData;
|
||||||
import flixel.system.FlxSound;
|
import flixel.system.FlxSound;
|
||||||
@ -210,6 +215,7 @@ class ResultsScreen extends FlxSubState
|
|||||||
PlayState.rep = Replay.LoadReplay(PlayState.rep.path);
|
PlayState.rep = Replay.LoadReplay(PlayState.rep.path);
|
||||||
|
|
||||||
PlayState.loadRep = true;
|
PlayState.loadRep = true;
|
||||||
|
PlayState.isSM = PlayState.rep.replay.sm;
|
||||||
|
|
||||||
var songFormat = StringTools.replace(PlayState.rep.replay.songName, " ", "-");
|
var songFormat = StringTools.replace(PlayState.rep.replay.songName, " ", "-");
|
||||||
switch (songFormat) {
|
switch (songFormat) {
|
||||||
@ -231,11 +237,43 @@ class ResultsScreen extends FlxSubState
|
|||||||
Highscore.saveCombo(songHighscore, Ratings.GenerateLetterRank(PlayState.instance.accuracy),PlayState.storyDifficulty);
|
Highscore.saveCombo(songHighscore, Ratings.GenerateLetterRank(PlayState.instance.accuracy),PlayState.storyDifficulty);
|
||||||
#end
|
#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);
|
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.isStoryMode = false;
|
||||||
PlayState.storyDifficulty = PlayState.rep.replay.songDiff;
|
PlayState.storyDifficulty = PlayState.rep.replay.songDiff;
|
||||||
LoadingState.loadAndSwitchState(new PlayState());
|
LoadingState.loadAndSwitchState(new PlayState());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user