Skip to content

Commit

Permalink
more things
Browse files Browse the repository at this point in the history
Added a function in CoolUtil for grabbing the note count from a song, which is used in the Chart Editor, which now displays your song's note count.
Removed more unnecessary data from notes
Attempted failure at allowing HaxeFlixel to have more than 1000 FPS
Adjusted the FPS text to look like how it did in Base FNF
  • Loading branch information
JordanSantiagoYT committed Oct 8, 2023
1 parent 2022ef3 commit 41c0fb1
Show file tree
Hide file tree
Showing 13 changed files with 5,511 additions and 64 deletions.
9 changes: 9 additions & 0 deletions source/CoolUtil.hx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import flixel.system.FlxSound;
import flixel.util.FlxColor;
import flixel.tweens.FlxTween;
import flixel.math.FlxMath;
import Song.SwagSong;
#if sys
import sys.io.File;
import sys.FileSystem;
Expand Down Expand Up @@ -181,6 +182,14 @@ class CoolUtil
#end
}

public static function getNoteAmount(song:SwagSong):Int {
var total:Int = 0;
for (section in song.notes) {
total += section.sectionNotes.length;
}
return total;
}

/*
* List of formatting for different byte amounts
* in an array formatted like this:
Expand Down
4 changes: 2 additions & 2 deletions source/GameplayChangersSubstate.hx
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@ class GameplayChangersSubstate extends MusicBeatSubstate
if (goption.getValue() != "constant")
{
option.displayFormat = '%vX';
option.maxValue = 30;
option.maxValue = 100;
}
else
{
option.displayFormat = "%v";
option.maxValue = 60;
option.maxValue = 200;
}
optionsArray.push(option);

Expand Down
6 changes: 1 addition & 5 deletions source/Note.hx
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,9 @@ class Note extends FlxSprite
public var tooLate:Bool = false;
public var wasGoodHit:Bool = false;
public var ignoreNote:Bool = false;
public var hitByOpponent:Bool = false;
public var noteWasHit:Bool = false;
public var hitByOpponent:Bool = false; //For Opponent notes
public var prevNote:Note;
public var nextNote:Note;
public var theStrumStuff:StrumNote;

public var spawned:Bool = false;

Expand Down Expand Up @@ -100,8 +98,6 @@ class Note extends FlxSprite

public var hitsoundDisabled:Bool = false;

public static var __pool:FlxPool<Note>;

private function set_multSpeed(value:Float):Float {
resizeByRatio(value / multSpeed);
multSpeed = value;
Expand Down
126 changes: 77 additions & 49 deletions source/PlayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -1967,8 +1967,7 @@ class PlayState extends MusicBeatState
add(EngineWatermark);
}

if (ClientPrefs.showcaseMode && !ClientPrefs.charsAndBG) {
//hitTxt = new FlxText(STRUM_X + (FlxG.width / 2) - 248, 20, 10000, "test", 42);
//hitTxt = new FlxText(STRUM_X + (FlxG.width / 2) - 248, 20, 10000, "", 42);
hitTxt = new FlxText(0, 20, 10000, "test", 42);
hitTxt.setFormat(Paths.font("vcr.ttf"), 42, FlxColor.WHITE, LEFT, FlxTextBorderStyle.OUTLINE, FlxColor.BLACK);
hitTxt.scrollFactor.set();
Expand All @@ -1979,6 +1978,7 @@ class PlayState extends MusicBeatState
//hitTxt.screenCenter(X);
hitTxt.screenCenter(Y);
add(hitTxt);
if (ClientPrefs.showcaseMode && !ClientPrefs.charsAndBG) {
var chromaScreen = new FlxSprite(-5000, -2000).makeGraphic(Std.int(FlxG.width * 2), Std.int(FlxG.height * 2), FlxColor.GREEN);
chromaScreen.scrollFactor.set(0, 0);
chromaScreen.scale.set(3, 3);
Expand Down Expand Up @@ -5038,20 +5038,24 @@ if (ClientPrefs.showNPS) {
var currentTime = Date.now().getTime();
var timeThreshold = ClientPrefs.npsWithSpeed ? 1000 / playbackRate : 1000;

// Remove expired notes from notesHitDateArray and notesHitArray
// Create new arrays to store items you want to keep
var filteredNotesHitDateArray:Array<Date> = [];
var filteredNotesHitArray:Array<Float> = [];
var notesToRemove:Array<Int> = [];
var oppNotesToRemove:Array<Int> = [];

for (i in 0...notesHitDateArray.length) {
var cock:Date = notesHitDateArray[i];
if (cock != null && (cock.getTime() + timeThreshold < currentTime)) {
if (cock == null || (cock.getTime() + timeThreshold >= currentTime)) {
filteredNotesHitDateArray.push(cock);
filteredNotesHitArray.push(notesHitArray[i]);
} else {
notesToRemove.push(i);
}
}

for (i in notesToRemove) {
notesHitDateArray.splice(i, 1);
notesHitArray.splice(i, 1);
}

// Update notesHitDateArray and notesHitArray with the filtered arrays
notesHitDateArray = filteredNotesHitDateArray;
notesHitArray = filteredNotesHitArray;

// Calculate sum of NPS values
var sum:Float = 0.0;
Expand All @@ -5060,24 +5064,33 @@ if (ClientPrefs.showNPS) {
}
nps = sum;

// Similar filtering logic for oppNotesHitDateArray and oppNotesHitArray
var filteredOppNotesHitDateArray:Array<Date> = [];
var filteredOppNotesHitArray:Array<Float> = [];
var oppNotesToRemove:Array<Int> = [];

for (i in 0...oppNotesHitDateArray.length) {
var cock:Date = oppNotesHitDateArray[i];
if (cock != null && (cock.getTime() + timeThreshold < currentTime)) {
if (cock == null || (cock.getTime() + timeThreshold >= currentTime)) {
filteredOppNotesHitDateArray.push(cock);
filteredOppNotesHitArray.push(oppNotesHitArray[i]);
} else {
oppNotesToRemove.push(i);
}
}

for (i in oppNotesToRemove) {
oppNotesHitDateArray.splice(i, 1);
oppNotesHitArray.splice(i, 1);
}
// Update oppNotesHitDateArray and oppNotesHitArray with the filtered arrays
oppNotesHitDateArray = filteredOppNotesHitDateArray;
oppNotesHitArray = filteredOppNotesHitArray;

// Calculate sum of NPS values for the opponent
var oppSum:Float = 0.0;
for (value in oppNotesHitArray) {
oppSum += value;
}
oppNPS = oppSum;

// Update maxNPS and maxOppNPS if needed
if (oppNPS > maxOppNPS) {
maxOppNPS = oppNPS;
}
Expand All @@ -5086,11 +5099,16 @@ if (ClientPrefs.showNPS) {
}
}

if (ClientPrefs.showcaseMode && !ClientPrefs.charsAndBG) hitTxt.text = 'Notes Hit: ' + FlxStringUtil.formatMoney(totalNotesPlayed, false)
if (ClientPrefs.showcaseMode && !ClientPrefs.charsAndBG) {
hitTxt.text = 'Notes Hit: ' + FlxStringUtil.formatMoney(totalNotesPlayed, false) + ' / ' + FlxStringUtil.formatMoney(totalNotes, false)
+ '\nNPS (Max): ' + FlxStringUtil.formatMoney(nps, false) + ' (' + FlxStringUtil.formatMoney(maxNPS, false) + ')'
+ '\nOpponent Notes Hit: ' + FlxStringUtil.formatMoney(enemyHits, false)
+ '\nOpponent NPS (Max): ' + FlxStringUtil.formatMoney(oppNPS, false) + ' (' + FlxStringUtil.formatMoney(maxOppNPS, false) + ')'
+ '\nTotal Note Hits: ' + FlxStringUtil.formatMoney(Math.abs(totalNotesPlayed + enemyHits), false);
+ '\nTotal Note Hits: ' + FlxStringUtil.formatMoney(Math.abs(totalNotesPlayed + enemyHits), false)
+ '\nVideo Speedup: ' + Math.abs(playbackRate / playbackRate / playbackRate) + 'x';
} else if (ClientPrefs.showcaseMode) {
hitTxt.text = 'Video Speedup: ' + Math.abs(playbackRate / playbackRate / playbackRate) + 'x';
}

if (combo > maxCombo)
maxCombo = combo;
Expand Down Expand Up @@ -5564,27 +5582,48 @@ if (ClientPrefs.showNPS) {
}
doDeathCheck();

if (unspawnNotes[0] != null)
{
var time:Float = 0;
if (!ClientPrefs.dynamicSpawnTime)
{
time = spawnTime * ClientPrefs.noteSpawnTime;
}
if (ClientPrefs.dynamicSpawnTime)
{
time = spawnTime / songSpeed;
}
if(unspawnNotes[0].multSpeed < 1) time /= unspawnNotes[0].multSpeed;
time /= (FlxMath.bound(camHUD.zoom, null, 1));

while (unspawnNotes.length > 0 && unspawnNotes[0].strumTime - Conductor.songPosition < time)
{
var dunceNote:Note = unspawnNotes.shift();
notes.insert(0, dunceNote);
dunceNote.spawned=true;
}
}
if (unspawnNotes[0] != null)
{
var currentTime = Conductor.songPosition;
var timeThreshold:Float = 0;

if (!ClientPrefs.dynamicSpawnTime)
{
timeThreshold = spawnTime * ClientPrefs.noteSpawnTime;
}
else
{
timeThreshold = spawnTime / songSpeed;
}

if (unspawnNotes[0].multSpeed < 1)
{
timeThreshold /= unspawnNotes[0].multSpeed;
}

timeThreshold /= (FlxMath.bound(camHUD.zoom, null, 1));

// Create a new array to store items you want to keep
var filteredUnspawnNotes:Array<Note> = [];

// Add notes to 'notes' one by one if they meet the criteria
for (dunceNote in unspawnNotes) {
if (dunceNote.strumTime - currentTime < timeThreshold) {
if (ClientPrefs.showNotes) {
notes.insert(0, dunceNote);
} else {
notes.add(dunceNote);
}
dunceNote.spawned = true;
} else {
// Note is still within the time threshold, keep it
filteredUnspawnNotes.push(dunceNote);
}
}

// Update 'unspawnNotes' with the filtered array
unspawnNotes = filteredUnspawnNotes;
}

if (generatedMusic)
{
Expand Down Expand Up @@ -5906,7 +5945,6 @@ if (ClientPrefs.showNPS) {
{
if (!daNote.isSustainNote) {
totalNotesPlayed += 1 * polyphony;
missCombo = 0;
if (ClientPrefs.showNPS) { //i dont think we should be pushing to 2 arrays at the same time but oh well
notesHitArray.push(1 * polyphony);
notesHitDateArray.push(Date.now());
Expand Down Expand Up @@ -6632,7 +6670,6 @@ if (ClientPrefs.showNPS) {
n.active = true;
n.visible = true;
n.wasGoodHit = false;
n.noteWasHit = false;
n.canBeHit = false;
n.tooLate = false;
n.hitByOpponent = false;
Expand Down Expand Up @@ -6673,7 +6710,6 @@ if (ClientPrefs.showNPS) {
n.active = true;
n.visible = true;
n.wasGoodHit = false;
n.noteWasHit = false;
n.canBeHit = false;
n.tooLate = false;
n.hitByOpponent = false;
Expand Down Expand Up @@ -6713,7 +6749,6 @@ if (ClientPrefs.showNPS) {
n.active = true;
n.visible = true;
n.wasGoodHit = false;
n.noteWasHit = false;
n.canBeHit = false;
n.tooLate = false;
n.hitByOpponent = false;
Expand Down Expand Up @@ -6751,7 +6786,6 @@ if (ClientPrefs.showNPS) {
n.active = true;
n.visible = true;
n.wasGoodHit = false;
n.noteWasHit = false;
n.canBeHit = false;
n.tooLate = false;
n.hitByOpponent = false;
Expand Down Expand Up @@ -6788,7 +6822,6 @@ if (ClientPrefs.showNPS) {
n.active = true;
n.visible = true;
n.wasGoodHit = false;
n.noteWasHit = false;
n.canBeHit = false;
n.tooLate = false;
n.hitByOpponent = false;
Expand Down Expand Up @@ -6824,7 +6857,6 @@ if (ClientPrefs.showNPS) {
n.active = true;
n.visible = true;
n.wasGoodHit = false;
n.noteWasHit = false;
n.canBeHit = false;
n.tooLate = false;
n.hitByOpponent = false;
Expand Down Expand Up @@ -6860,7 +6892,6 @@ if (ClientPrefs.showNPS) {
n.active = true;
n.visible = true;
n.wasGoodHit = false;
n.noteWasHit = false;
n.canBeHit = false;
n.tooLate = false;
n.hitByOpponent = false;
Expand All @@ -6885,7 +6916,6 @@ if (ClientPrefs.showNPS) {
n.active = true;
n.visible = true;
n.wasGoodHit = false;
n.noteWasHit = false;
n.canBeHit = false;
n.tooLate = false;
n.hitByOpponent = false;
Expand All @@ -6911,7 +6941,6 @@ if (ClientPrefs.showNPS) {
n.active = true;
n.visible = true;
n.wasGoodHit = false;
n.noteWasHit = false;
n.tooLate = false;
n.canBeHit = false;
n.hitByOpponent = false;
Expand All @@ -6928,7 +6957,6 @@ if (ClientPrefs.showNPS) {
n.active = false;
n.visible = false;
n.wasGoodHit = true;
n.noteWasHit = true;
n.tooLate = false;
n.canBeHit = false;
n.hitByOpponent = true;
Expand Down
11 changes: 8 additions & 3 deletions source/editors/ChartingState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ class ChartingState extends MusicBeatState

#if desktop
// Updating Discord Rich Presence
DiscordClient.changePresence("Chart Editor", StringTools.replace(_song.song, '-', ' '));
DiscordClient.changePresence("Chart Editor - Charting " + StringTools.replace(_song.song, '-', ' '), '${FlxStringUtil.formatMoney(CoolUtil.getNoteAmount(_song), false)} Notes');
#end

vortex = FlxG.save.data.chart_vortex;
Expand Down Expand Up @@ -1066,7 +1066,7 @@ class ChartingState extends MusicBeatState
changeSection(value);
});

var CopyNextSectionCount:FlxUINumericStepper = new FlxUINumericStepper(jumpSection.x, jumpSection.y + 60, 1, 1, -999, 999, 0);
var CopyNextSectionCount:FlxUINumericStepper = new FlxUINumericStepper(jumpSection.x, jumpSection.y + 60, 1, 1, -16384, 16384, 0);
blockPressWhileTypingOnStepper.push(CopyNextSectionCount);

var copyNextButton:FlxButton = new FlxButton(CopyNextSectionCount.x, CopyNextSectionCount.y + 20, "Copy to the next..", function()
Expand Down Expand Up @@ -2427,7 +2427,8 @@ class ChartingState extends MusicBeatState
"\nSection: " + curSec +
"\n\nBeat: " + Std.string(curDecBeat).substring(0,4) +
"\n\nStep: " + curStep +
"\n\nBeat Snap: " + quantization + "th";
"\n\nBeat Snap: " + quantization + "th" +
"\n\n" + FlxStringUtil.formatMoney(CoolUtil.getNoteAmount(_song), false) + ' Notes';

var playedSound:Array<Bool> = [false, false, false, false]; //Prevents ouchy GF sex sounds
curRenderedNotes.forEachAlive(function(note:Note) {
Expand Down Expand Up @@ -3118,6 +3119,10 @@ class ChartingState extends MusicBeatState
}
}
}
#if desktop
// Updating Discord Rich Presence (for updating Note Count)
DiscordClient.changePresence("Chart Editor - Charting " + StringTools.replace(_song.song, '-', ' '), '${FlxStringUtil.formatMoney(CoolUtil.getNoteAmount(_song), false)} Notes');
#end
}

function setupNoteData(i:Array<Dynamic>, isNextSection:Bool):Note
Expand Down
2 changes: 1 addition & 1 deletion source/editors/EditorPlayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ class EditorPlayState extends MusicBeatState
}
}

if (!daNote.mustPress && daNote.wasGoodHit && !daNote.hitByOpponent && !daNote.ignoreNote)
if (!daNote.mustPress && daNote.strumTime <= Conductor.songPosition)
{
if (PlayState.SONG.needsVoices)
vocals.volume = 1;
Expand Down
Loading

0 comments on commit 41c0fb1

Please sign in to comment.