fixes even more crap (replay stuff mostly)

This commit is contained in:
Kade M 2021-06-20 17:59:39 -07:00
parent 98e96e4348
commit 40601171ab
4 changed files with 81 additions and 26 deletions

39
source/OFLSprite.hx Normal file
View File

@ -0,0 +1,39 @@
import flixel.util.FlxColor;
import openfl.display.Sprite;
import flixel.FlxSprite;
/**
* designed to draw a Open FL Sprite as a FlxSprite (to allow layering and auto sizing for haxe flixel cameras)
* Custom made for Kade Engine
*/
class OFLSprite extends FlxSprite
{
public var flSprite:Sprite;
public function new(x,y,width,height,Sprite:Sprite)
{
super(x,y);
makeGraphic(width,height,FlxColor.TRANSPARENT);
flSprite = Sprite;
pixels.draw(flSprite);
}
private var _frameCount:Int = 0;
override function update(elapsed:Float)
{
if (_frameCount != 2)
{
pixels.draw(flSprite);
_frameCount++;
}
}
public function updateDisplay()
{
pixels.draw(flSprite);
}
}

View File

@ -212,6 +212,7 @@ class PlayState extends MusicBeatState
private var botPlayState:FlxText;
// Replay shit
private var saveNotes:Array<Dynamic> = [];
private var saveJudge:Array<String> = [];
public static var highestCombo:Int = 0;
@ -2563,7 +2564,7 @@ class PlayState extends MusicBeatState
campaignMisses = misses;
if (!loadRep)
rep.SaveReplay(saveNotes);
rep.SaveReplay(saveNotes, saveJudge);
else
{
PlayStateChangeables.botPlay = false;
@ -3223,6 +3224,17 @@ class PlayState extends MusicBeatState
return null;
}
public function findByTimeIndex(time:Float):Int
{
for (i in 0...rep.replay.songNotes.length)
{
//trace('checking ' + Math.round(i[0]) + ' against ' + Math.round(time));
if (rep.replay.songNotes[i][0] == time)
return i;
}
return -1;
}
public var fuckingVolume:Float = 1;
public var useVideo = false;
@ -3322,11 +3334,17 @@ class PlayState extends MusicBeatState
if (daNote != null)
{
if (!loadRep)
{
saveNotes.push([daNote.strumTime,0,direction,166 * Math.floor((PlayState.rep.replay.sf / 60) * 1000) / 166]);
saveJudge.push("miss");
}
}
else
if (!loadRep)
{
saveNotes.push([Conductor.songPosition,0,direction,166 * Math.floor((PlayState.rep.replay.sf / 60) * 1000) / 166]);
saveJudge.push("miss");
}
//var noteDiff:Float = Math.abs(daNote.strumTime - Conductor.songPosition);
//var wife:Float = EtternaFunctions.wife3(noteDiff, FlxG.save.data.etternaMode ? 1 : 1.7);
@ -3468,9 +3486,12 @@ class PlayState extends MusicBeatState
var noteDiff:Float = -(note.strumTime - Conductor.songPosition);
if(loadRep)
{
noteDiff = findByTime(note.strumTime)[3];
note.rating = Ratings.CalculateRating(noteDiff);
note.rating = rep.replay.songJudgements[findByTimeIndex(note.strumTime)];
}
else
note.rating = Ratings.CalculateRating(noteDiff);
if (note.rating == "miss")
return;
@ -3522,6 +3543,7 @@ class PlayState extends MusicBeatState
array[1] = -1;
trace('pushing ' + array[0]);
saveNotes.push(array);
saveJudge.push(note.rating);
}
playerStrums.forEach(function(spr:FlxSprite)

View File

@ -120,19 +120,19 @@ class Ratings
public static function checkRating(ms:Float, ts:Float)
{
var rating = "miss";
if (ms < 166 * ts && ms > 135 * ts)
if (ms <= 166 * ts && ms >= 135 * ts)
rating = "shit";
if (ms > -166 * ts && ms < -135 * ts)
if (ms >= -166 * ts && ms <= -135 * ts)
rating = "shit";
if (ms < 135 * ts && ms > 90 * ts)
if (ms <= 135 * ts && ms >= 90 * ts)
rating = "bad";
if (ms > -135 * ts && ms < -90 * ts)
if (ms >= -135 * ts && ms <= -90 * ts)
rating = "bad";
if (ms < 90 * ts && ms > 45 * ts)
if (ms <= 90 * ts && ms >= 45 * ts)
rating = "good";
if (ms > -90 * ts && ms < -45 * ts)
if (ms >= -90 * ts && ms <= -45 * ts)
rating = "good";
if (ms < 45 * ts && ms > -45 * ts)
if (ms <= 45 * ts && ms >= -45 * ts)
rating = "sick";
return rating;
}

View File

@ -35,7 +35,7 @@ class ResultsScreen extends FlxSubState
public var anotherBackground:FlxSprite;
public var graph:HitGraph;
public var graphSprite:FlxSprite;
public var graphSprite:OFLSprite;
public var comboText:FlxText;
public var contText:FlxText;
@ -97,7 +97,7 @@ class ResultsScreen extends FlxSubState
graph = new HitGraph(FlxG.width - 500,45,495,240);
graph.alpha = 0;
graphSprite = new FlxSprite(FlxG.width - 510,45);
graphSprite = new OFLSprite(FlxG.width - 510,45,460,240,graph);
graphSprite.scrollFactor.set();
graphSprite.alpha = 0;
@ -116,25 +116,25 @@ class ResultsScreen extends FlxSubState
var mean:Float = 0;
for (i in PlayState.rep.replay.songNotes)
for (i in 0...PlayState.rep.replay.songNotes.length)
{
// 0 = time
// 1 = length
// 2 = type
// 3 = diff
var diff = i[3];
var judge = Ratings.CalculateRating(diff, Math.floor((PlayState.rep.replay.sf / 60) * 1000));
var obj = PlayState.rep.replay.songNotes[i];
// judgement
var obj2 = PlayState.rep.replay.songJudgements[i];
var diff = obj[3];
var judge = obj2;
mean += diff;
if (i[1] != -1)
if (obj[1] != -1)
graph.addToHistory(diff, judge);
}
graph.update();
graphSprite.makeGraphic(460,240,FlxColor.TRANSPARENT);
graphSprite.pixels.draw(graph);
mean = HelperFunctions.truncateFloat(mean / PlayState.rep.replay.songNotes.length,2);
settingsText = new FlxText(20,FlxG.height + 50,0,'SF: ${PlayState.rep.replay.sf} | Ratio (SA/GA): ${Math.round(sicks)}:1 ${Math.round(goods)}:1 | Mean: ${mean}ms | Played on ${PlayState.SONG.song} ${CoolUtil.difficultyString()}');
@ -168,12 +168,6 @@ class ResultsScreen extends FlxSubState
if (music.volume < 0.5)
music.volume += 0.01 * elapsed;
// render
if (frames != 2)
{
graphSprite.pixels.draw(graph);
frames++;
}
// keybinds
if (FlxG.keys.justPressed.ENTER)