formatting
This commit is contained in:
parent
c226c62d52
commit
c628766fc0
102
source/Replay.hx
102
source/Replay.hx
@ -13,79 +13,79 @@ import openfl.utils.Dictionary;
|
|||||||
|
|
||||||
typedef ReplayJSON =
|
typedef ReplayJSON =
|
||||||
{
|
{
|
||||||
public var replayGameVer:String;
|
public var replayGameVer:String;
|
||||||
public var timestamp:Date;
|
public var timestamp:Date;
|
||||||
public var songName:String;
|
public var songName:String;
|
||||||
public var songDiff:Int;
|
public var songDiff:Int;
|
||||||
public var songNotes:Array<Float>;
|
public var songNotes:Array<Float>;
|
||||||
public var noteSpeed:Float;
|
public var noteSpeed:Float;
|
||||||
public var isDownscroll:Bool;
|
public var isDownscroll:Bool;
|
||||||
}
|
}
|
||||||
|
|
||||||
class Replay
|
class Replay
|
||||||
{
|
{
|
||||||
public static var version:String = "1.1"; // replay file version
|
public static var version:String = "1.1"; // replay file version
|
||||||
|
|
||||||
public var path:String = "";
|
public var path:String = "";
|
||||||
public var replay:ReplayJSON;
|
public var replay:ReplayJSON;
|
||||||
public function new(path:String)
|
public function new(path:String)
|
||||||
{
|
{
|
||||||
this.path = path;
|
this.path = path;
|
||||||
replay = {
|
replay = {
|
||||||
songName: "No Song Found",
|
songName: "No Song Found",
|
||||||
songDiff: 1,
|
songDiff: 1,
|
||||||
noteSpeed: 1.5,
|
noteSpeed: 1.5,
|
||||||
isDownscroll: false,
|
isDownscroll: false,
|
||||||
songNotes: [],
|
songNotes: [],
|
||||||
replayGameVer: version,
|
replayGameVer: version,
|
||||||
timestamp: Date.now()
|
timestamp: Date.now()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function LoadReplay(path:String):Replay
|
public static function LoadReplay(path:String):Replay
|
||||||
{
|
{
|
||||||
var rep:Replay = new Replay(path);
|
var rep:Replay = new Replay(path);
|
||||||
|
|
||||||
rep.LoadFromJSON();
|
rep.LoadFromJSON();
|
||||||
|
|
||||||
trace('basic replay data:\nSong Name: ' + rep.replay.songName + '\nSong Diff: ' + rep.replay.songDiff + '\nNotes Length: ' + rep.replay.songNotes.length);
|
trace('basic replay data:\nSong Name: ' + rep.replay.songName + '\nSong Diff: ' + rep.replay.songDiff + '\nNotes Length: ' + rep.replay.songNotes.length);
|
||||||
|
|
||||||
return rep;
|
return rep;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function SaveReplay(notearray:Array<Float>)
|
public function SaveReplay(notearray:Array<Float>)
|
||||||
{
|
{
|
||||||
var json = {
|
var json = {
|
||||||
"songName": PlayState.SONG.song,
|
"songName": PlayState.SONG.song,
|
||||||
"songDiff": PlayState.storyDifficulty,
|
"songDiff": PlayState.storyDifficulty,
|
||||||
"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,
|
||||||
"timestamp": Date.now(),
|
"timestamp": Date.now(),
|
||||||
"replayGameVer": version
|
"replayGameVer": version
|
||||||
};
|
};
|
||||||
|
|
||||||
var data:String = Json.stringify(json);
|
var data:String = Json.stringify(json);
|
||||||
|
|
||||||
#if sys
|
#if sys
|
||||||
File.saveContent("assets/replays/replay-" + PlayState.SONG.song + "-time" + Date.now().getTime() + ".kadeReplay", data);
|
File.saveContent("assets/replays/replay-" + PlayState.SONG.song + "-time" + Date.now().getTime() + ".kadeReplay", data);
|
||||||
#end
|
#end
|
||||||
}
|
}
|
||||||
|
|
||||||
public function LoadFromJSON()
|
public function LoadFromJSON()
|
||||||
{
|
{
|
||||||
#if sys
|
if sys
|
||||||
trace('loading ' + Sys.getCwd() + 'assets/replays/' + path + ' replay...');
|
trace('loading ' + Sys.getCwd() + 'assets/replays/' + path + ' replay...');
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var repl:ReplayJSON = cast Json.parse(File.getContent(Sys.getCwd() + "assets/replays/" + path));
|
var repl:ReplayJSON = cast Json.parse(File.getContent(Sys.getCwd() + "assets/replays/" + path));
|
||||||
replay = repl;
|
replay = repl;
|
||||||
}
|
}
|
||||||
catch(e)
|
catch(e)
|
||||||
{
|
{
|
||||||
trace('failed!\n' + e.message);
|
trace('failed!\n' + e.message);
|
||||||
}
|
}
|
||||||
#end
|
#end
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user