accuracy ratings

This commit is contained in:
YoshiCrafter29
2022-11-08 09:48:26 +01:00
parent d78a57204d
commit f3e4aacef4
6 changed files with 79 additions and 7 deletions
-1
View File
@@ -74,7 +74,6 @@
<!-- _______________________________ Libraries ______________________________ -->
<haxelib name="hxCodec"/>
<haxelib name="Flixel-TextureAtlas"/>
<haxelib name="flixel-yc29" rename="flixel" />
<haxedev set='webgl' />
+5
View File
@@ -0,0 +1,5 @@
function create() {
startVideo(Paths.video("garfield"), function() {
close();
});
}
+1 -1
View File
@@ -1 +1 @@
1228
1234
-4
View File
@@ -42,10 +42,6 @@ class VideoCutscene extends Cutscene {
public override function update(elapsed:Float) {
super.update(elapsed);
// video.se
// video.setUnstretchedGraphicSize(FlxG.width, FlxG.height, false);
// trace(video);
// trace(video.getScreenBounds(null, cutsceneCamera));
}
public override function destroy() {
FlxG.cameras.remove(camera, true);
+55 -1
View File
@@ -60,6 +60,7 @@ import funkin.scripting.events.*;
using StringTools;
@:access(flixel.text.FlxText.FlxTextFormatRange)
class PlayState extends MusicBeatState
{
public static var instance:PlayState = null;
@@ -157,6 +158,16 @@ class PlayState extends MusicBeatState
public var inCutscene:Bool = false;
public var comboRatings:Array<ComboRating> = [
new ComboRating(0, "[F]", 0xFFFF4444),
new ComboRating(0.1, "[E]", 0xFFFF8844),
new ComboRating(0.2, "[D]", 0xFFFFAA44),
new ComboRating(0.4, "[C]", 0xFFFFFF44),
new ComboRating(0.6, "[B]", 0xFFAAFF44),
new ComboRating(0.8, "[A]", 0xFF88FF44),
new ComboRating(0.9, "[S]", 0xFF44FFFF),
];
#if desktop
// Discord RPC variables
public var difficultyText:String = "";
@@ -166,6 +177,22 @@ class PlayState extends MusicBeatState
public var detailsPausedText:String = "";
#end
public var curRating:ComboRating;
public function updateRating() {
var rating = null;
var acc = get_accuracy();
for(e in comboRatings) {
if (e.percent <= acc && (rating == null || rating.percent < e.percent))
rating = e;
}
var event = scripts.event("onRatingUpdate", new RatingUpdateEvent(rating, curRating));
if (!event.cancelled)
curRating = event.rating;
}
override public function create()
{
instance = this;
@@ -331,6 +358,7 @@ class PlayState extends MusicBeatState
scoreTxt = new FunkinText(healthBarBG.x + 50, healthBarBG.y + 30, Std.int(healthBarBG.width - 100), "Score:0", 16);
missesTxt = new FunkinText(healthBarBG.x + 50, healthBarBG.y + 30, Std.int(healthBarBG.width - 100), "Misses:0", 16);
accuracyTxt = new FunkinText(healthBarBG.x + 50, healthBarBG.y + 30, Std.int(healthBarBG.width - 100), "Accuracy:-%", 16);
accuracyTxt.addFormat(accFormat, 0, 1);
for(text in [scoreTxt, missesTxt, accuracyTxt]) {
text.scrollFactor.set();
@@ -817,6 +845,7 @@ class PlayState extends MusicBeatState
}
var __vocalOffsetViolation:Float = 0;
public var accFormat:FlxTextFormat = new FlxTextFormat(0xFF888888, false, false, 0);
override public function update(elapsed:Float)
{
#if !debug
@@ -829,7 +858,18 @@ class PlayState extends MusicBeatState
scoreTxt.text = 'Score:$songScore';
missesTxt.text = '${comboBreaks ? "Combo Breaks" : "Misses"}:$misses';
var acc = accuracy;
accuracyTxt.text = 'Accuracy:${acc < 0 ? "N/A" : '${FlxMath.roundDecimal(acc * 100, 2)}%'}';
var rating:ComboRating = curRating == null ? new ComboRating(0, "[N/A]", 0xFF888888) : curRating;
@:privateAccess accFormat.format.color = rating.color;
accuracyTxt.text = 'Accuracy:${acc < 0 ? "N/A" : '${FlxMath.roundDecimal(acc * 100, 2)}%'} ${rating.rating}';
@:privateAccess
var format = accuracyTxt._formatRanges[0];
format.range.start = accuracyTxt.text.length - rating.rating.length;
format.range.end = accuracyTxt.text.length;
// accuracyTxt.addFormat(accFormat, accuracyTxt.text.length - rating.rating.length, accuracyTxt.text.length);
if (FlxG.keys.justPressed.ENTER && startedCountdown && canPause)
pauseGame();
@@ -1303,6 +1343,8 @@ class PlayState extends MusicBeatState
if (event.accuracy != null) {
accuracyPressedNotes++;
totalAccuracyAmount += accuracy;
updateRating();
}
if (event.countAsCombo) combo++;
@@ -1449,4 +1491,16 @@ class PlayState extends MusicBeatState
}
public var curLight:Int = 0;
}
class ComboRating {
public var percent:Float;
public var rating:String;
public var color:FlxColor;
public function new(percent:Float, rating:String, color:FlxColor) {
this.percent = percent;
this.rating = rating;
this.color = color;
}
}
@@ -0,0 +1,18 @@
package funkin.scripting.events;
class RatingUpdateEvent extends CancellableEvent {
/**
New combo
**/
public var rating:ComboRating;
/**
Old combo (may be null)
**/
public var oldRating:ComboRating;
public function new(rating:ComboRating, oldRating:ComboRating) {
super();
this.rating = rating;
this.oldRating = oldRating;
}
}