Skip to content

Commit

Permalink
suffering
Browse files Browse the repository at this point in the history
attempted to optimize chart loading a bit
fixed a startupstate crash
exiting the week editor in any way now plays the correct menu music
added a secret helping function for the "Copy to the next.." and "Copy from the last to the next.." buttons: pressing CTRL will swap sectionify all notes
  • Loading branch information
JordanSantiagoYT committed Oct 15, 2024
1 parent 6762b35 commit c424d25
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 83 deletions.
7 changes: 2 additions & 5 deletions source/Note.hx
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,15 @@ typedef PreloadedChartNote = {
isSustainEnd:Bool,
sustainLength:Float,
sustainScale:Float,
parent:PreloadedChartNote,
parentST:Float,
hitHealth:Float,
missHealth:Float,
hitCausesMiss:Null<Bool>,
wasHit:Bool,
multSpeed:Float,
noteDensity:Float,
wasSpawned:Bool,
ignoreNote:Bool,
lowPriority:Bool,
wasMissed:Bool
}

typedef NoteSplashData = {
Expand Down Expand Up @@ -598,10 +596,9 @@ class Note extends FlxSprite
doOppStuff = chartNoteData.oppNote;
gfNote = chartNoteData.gfNote;
isSustainNote = chartNoteData.isSustainNote;
sustainLength = chartNoteData.sustainLength;
sustainScale = chartNoteData.sustainScale;
lowPriority = chartNoteData.lowPriority;
if (isSustainNote) parentST = chartNoteData.parent.strumTime;
if (isSustainNote) parentST = chartNoteData.parentST;

hitHealth = chartNoteData.hitHealth;
missHealth = chartNoteData.missHealth;
Expand Down
107 changes: 47 additions & 60 deletions source/PlayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -2894,6 +2894,8 @@ class PlayState extends MusicBeatState
}
var currentBPMLol:Float = Conductor.bpm;
var currentMultiplier:Float = 1;
var gottaHitNote:Bool = false;
var swagNote:PreloadedChartNote;
for (section in noteData) {
if (section.changeBPM) currentBPMLol = section.bpm;

Expand All @@ -2906,22 +2908,19 @@ class PlayState extends MusicBeatState
firstNoteData = Std.int(songNotes[1] % 4);
assignedFirstData = true;
}
if (!randomMode && !flip && !stairs && !waves) {
daNoteData = Std.int(songNotes[1] % 4);
}
if (oneK) {
daNoteData = firstNoteData;
}
if (randomMode) {
daNoteData = FlxG.random.int(0, 3);
}
if (flip) {
daNoteData = Std.int(Math.abs((songNotes[1] % 4) - 3));
}
if (!randomMode && !flip && !stairs && !waves) daNoteData = Std.int(songNotes[1] % 4);

if (oneK) daNoteData = firstNoteData;

if (randomMode) daNoteData = FlxG.random.int(0, 3);

if (flip) daNoteData = Std.int(Math.abs((songNotes[1] % 4) - 3));

if (stairs && !waves) {
daNoteData = stair % 4;
stair++;
}

if (waves) {
switch (stair % 6) {
case 0 | 1 | 2 | 3:
Expand All @@ -2933,7 +2932,8 @@ class PlayState extends MusicBeatState
}
stair++;
}
final gottaHitNote:Bool = ((songNotes[1] < 4 && !opponentChart)

gottaHitNote = ((songNotes[1] < 4 && !opponentChart)
|| (songNotes[1] > 3 && opponentChart) ? section.mustHitSection : !section.mustHitSection);

if ((bothSides || gottaHitNote) && songNotes[3] != 'Hurt Note') {
Expand Down Expand Up @@ -2966,7 +2966,7 @@ class PlayState extends MusicBeatState
multiChangeEvents[1].shift();
}

final swagNote:PreloadedChartNote = cast {
swagNote = cast {
strumTime: daStrumTime,
noteData: daNoteData,
mustPress: bothSides || gottaHitNote,
Expand All @@ -2976,19 +2976,14 @@ class PlayState extends MusicBeatState
noteskin: (gottaHitNote ? bfNoteskin : dadNoteskin),
gfNote: songNotes[3] == 'GF Sing' || (section.gfSection && songNotes[1] < 4),
noAnimation: songNotes[3] == 'No Animation',
isSustainNote: false,
isSustainEnd: false,
noMissAnimation: songNotes[3] == 'No Animation',
sustainLength: songNotes[2],
sustainScale: 0,
parent: null,
hitHealth: 0.023,
missHealth: songNotes[3] != 'Hurt Note' ? 0.0475 : 0.3,
wasHit: false,
hitCausesMiss: songNotes[3] == 'Hurt Note',
multSpeed: 1,
noteDensity: currentMultiplier,
wasSpawned: false,
wasMissed: false,
ignoreNote: songNotes[3] == 'Hurt Note' && gottaHitNote
};
if (swagNote.noteskin.length > 0 && !Paths.noteSkinFramesMap.exists(swagNote.noteskin)) inline Paths.initNote(4, swagNote.noteskin);
Expand All @@ -3002,6 +2997,35 @@ class PlayState extends MusicBeatState
}

inline unspawnNotes.push(swagNote);

if (jackingtime > 0) {
for (i in 0...Std.int(jackingtime)) {
final jackNote:PreloadedChartNote = cast {
strumTime: swagNote.strumTime + (15000 / SONG.bpm) * (i + 1),
noteData: swagNote.noteData,
mustPress: swagNote.mustPress,
oppNote: swagNote.oppNote,
noteType: swagNote.noteType,
animSuffix: (songNotes[3] == 'Alt Animation' || section.altAnim ? '-alt' : ''),
noteskin: (gottaHitNote ? bfNoteskin : dadNoteskin),
gfNote: swagNote.gfNote,
isSustainNote: false,
isSustainEnd: false,
sustainScale: 0,
parentST: 0,
hitHealth: swagNote.hitHealth,
missHealth: swagNote.missHealth,
wasHit: false,
multSpeed: 1,
noteDensity: currentMultiplier,
hitCausesMiss: swagNote.hitCausesMiss,
ignoreNote: swagNote.ignoreNote
};
inline unspawnNotes.push(jackNote);
}
}

if (swagNote.sustainLength < 1) continue;

var ratio:Float = Conductor.bpm / currentBPMLol;

Expand All @@ -3020,54 +3044,18 @@ class PlayState extends MusicBeatState
gfNote: songNotes[3] == 'GF Sing' || (section.gfSection && songNotes[1] < 4),
noAnimation: songNotes[3] == 'No Animation',
isSustainNote: true,
isSustainEnd: susNote == floorSus,
sustainLength: 0,
isSustainEnd: susNote == floorSus,
sustainScale: 1 / ratio,
parent: swagNote,
parentST: swagNote.strumTime,
hitHealth: 0.023,
missHealth: songNotes[3] != 'Hurt Note' ? 0.0475 : 0.1,
wasHit: false,
multSpeed: 1,
noteDensity: currentMultiplier,
hitCausesMiss: songNotes[3] == 'Hurt Note',
wasSpawned: false,
canBeHit:false,
wasMissed: false,
ignoreNote: songNotes[3] == 'Hurt Note' && swagNote.mustPress
};
inline unspawnNotes.push(sustainNote);
//Sys.sleep(0.0001);
}
}

if (jackingtime > 0) {
for (i in 0...Std.int(jackingtime)) {
final jackNote:PreloadedChartNote = cast {
strumTime: swagNote.strumTime + (15000 / SONG.bpm) * (i + 1),
noteData: swagNote.noteData,
mustPress: swagNote.mustPress,
oppNote: swagNote.oppNote,
noteType: swagNote.noteType,
animSuffix: (songNotes[3] == 'Alt Animation' || section.altAnim ? '-alt' : ''),
noteskin: (gottaHitNote ? bfNoteskin : dadNoteskin),
gfNote: swagNote.gfNote,
isSustainNote: false,
isSustainEnd: false,
sustainLength: swagNote.sustainLength,
sustainScale: 0,
parent: null,
hitHealth: swagNote.hitHealth,
missHealth: swagNote.missHealth,
wasHit: false,
multSpeed: 1,
noteDensity: currentMultiplier,
hitCausesMiss: swagNote.hitCausesMiss,
wasSpawned: false,
canBeHit:false,
wasMissed: false,
ignoreNote: swagNote.ignoreNote
};
inline unspawnNotes.push(jackNote);
}
}
} else {
Expand Down Expand Up @@ -4103,8 +4091,7 @@ class PlayState extends MusicBeatState
var noteIndex:Int = 0;
while (unspawnNotes.length > 0 && unspawnNotes[noteIndex] != null)
{
if (ClientPrefs.showNotes) unspawnNotes[noteIndex].wasSpawned = false;
else unspawnNotes[noteIndex].wasHit = false;
unspawnNotes[noteIndex].wasHit = false;
noteIndex++;
}
}
Expand Down
4 changes: 4 additions & 0 deletions source/StartupState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ class StartupState extends MusicBeatState
vidSprite.playVideo(Paths.video('bambiStartup'), false, false);
vidSprite.finishCallback = function()
{
try { vidSprite.finishVideo(); }
catch (e) {}
FlxG.switchState(TitleState.new);
};
#else
Expand All @@ -92,6 +94,8 @@ class StartupState extends MusicBeatState
vidSprite.playVideo(Paths.video('broCopiedDenpa'), false, false);
vidSprite.finishCallback = function()
{
try { vidSprite.finishVideo(); }
catch (e) {}
FlxG.switchState(TitleState.new);
};
#else
Expand Down
20 changes: 11 additions & 9 deletions source/editors/ChartingState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -1274,6 +1274,7 @@ class ChartingState extends MusicBeatState

copyMultiSectButton = new FlxButton(CopyFutureSectionCount.x, CopyLastSectionCount.y + 40, "Copy from the last " + Std.int(CopyFutureSectionCount.value) + " to the next " + Std.int(CopyFutureSectionCount.value) + " sections, " + Std.int(CopyLoopCount.value) + " times", function()
{
var swapNotes:Bool = FlxG.keys.pressed.CONTROL;
var daSec = FlxMath.maxInt(curSec, Std.int(CopyLastSectionCount.value));
var value1:Int = Std.int(CopyLastSectionCount.value);
var value2:Int = Std.int(CopyFutureSectionCount.value) * Std.int(CopyLoopCount.value);
Expand All @@ -1293,7 +1294,7 @@ class ChartingState extends MusicBeatState
{
var strum = note[0] + Conductor.stepCrochet * (getSectionBeats(daSec - value1) * 4 * value1);


if (swapNotes) note[1] = (note[1] + 4) % 8;
var copiedNote:Array<Dynamic> = [strum, note[1], note[2], note[3]];
inline _song.notes[daSec].sectionNotes.push(copiedNote);
}
Expand All @@ -1320,6 +1321,7 @@ class ChartingState extends MusicBeatState

var copyNextButton:FlxButton = new FlxButton(CopyNextSectionCount.x, CopyNextSectionCount.y + 20, "Copy to the next..", function()
{
var swapNotes:Bool = FlxG.keys.pressed.CONTROL;
var value:Int = Std.int(CopyNextSectionCount.value);
if(value == 0) {
return;
Expand All @@ -1331,15 +1333,15 @@ class ChartingState extends MusicBeatState
saveUndo(_song); //I don't even know why.

for(i in 0...value) {
changeSection(curSec+1);
for (note in _song.notes[curSec-1].sectionNotes)
{
var strum = note[0] + Conductor.stepCrochet * (getSectionBeats(curSec-1) * 4);

changeSection(curSec+1);
for (note in _song.notes[curSec-1].sectionNotes)
{
var strum = note[0] + Conductor.stepCrochet * (getSectionBeats(curSec-1) * 4);

var copiedNote:Array<Dynamic> = [strum, note[1], note[2], note[3]];
_song.notes[curSec].sectionNotes.push(copiedNote);
}
if (swapNotes) note[1] = (note[1] + 4) % 8;
var copiedNote:Array<Dynamic> = [strum, note[1], note[2], note[3]];
_song.notes[curSec].sectionNotes.push(copiedNote);
}
}
updateGrid(false);
});
Expand Down
9 changes: 1 addition & 8 deletions source/editors/EditorPlayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,6 @@ class EditorPlayState extends MusicBeatState

final gottaHitNote:Bool = (songNotes[1] < 4 ? section.mustHitSection : !section.mustHitSection);

var oldNote:PreloadedChartNote = unspawnNotes[unspawnNotes.length - 1];

final swagNote:PreloadedChartNote = cast {
strumTime: daStrumTime,
noteData: daNoteData,
Expand All @@ -244,8 +242,6 @@ class EditorPlayState extends MusicBeatState
isSustainEnd: false,
sustainLength: songNotes[2],
sustainScale: 0,
parent: null,
prevNote: oldNote,
hitHealth: 0.023,
missHealth: 0.0475,
wasHit: false,
Expand All @@ -264,8 +260,6 @@ class EditorPlayState extends MusicBeatState
final floorSus:Int = Math.floor(swagNote.sustainLength / Conductor.stepCrochet);
if (floorSus > 0) {
for (susNote in 0...floorSus + 1) {
oldNote = unspawnNotes[Std.int(unspawnNotes.length - 1)];

final sustainNote:PreloadedChartNote = cast {
strumTime: daStrumTime + (Conductor.stepCrochet * susNote),
noteData: daNoteData,
Expand All @@ -279,8 +273,7 @@ class EditorPlayState extends MusicBeatState
isSustainEnd: susNote == floorSus,
sustainLength: 0,
sustainScale: 1 / ratio,
parent: swagNote,
prevNote: oldNote,
parentST: swagNote.strumTime,
hitHealth: 0.023,
missHealth: 0.0475,
wasHit: false,
Expand Down
2 changes: 1 addition & 1 deletion source/editors/WeekEditorState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -840,7 +840,7 @@ class WeekEditorFreeplayState extends MusicBeatState
FlxG.sound.volumeUpKeys = TitleState.volumeUpKeys;
if(FlxG.keys.justPressed.ESCAPE) {
FlxG.switchState(editors.MasterEditorMenu.new);
FlxG.sound.playMusic(Paths.music('freakyMenu'));
FlxG.sound.playMusic(Paths.music('freakyMenu-' + ClientPrefs.daMenuMusic));
if (music != null && music.music != null) music.destroy();
}

Expand Down

0 comments on commit c424d25

Please sign in to comment.