Skip to content

Commit

Permalink
Finally seperate vocals on vslice charts
Browse files Browse the repository at this point in the history
Some sustain improvements
  • Loading branch information
superpowers04 committed Aug 24, 2024
1 parent bded101 commit 36e9a12
Show file tree
Hide file tree
Showing 6 changed files with 108 additions and 71 deletions.
20 changes: 10 additions & 10 deletions source/Alphabet.hx
Original file line number Diff line number Diff line change
Expand Up @@ -331,14 +331,14 @@ class AlphaCharacter extends FlxSprite {
// txt.destroy();
// trace('Cached Alpha Characters');
}
public static function cacheText(char:String = "",?bold:Bool = false,?txt:FlxText = null){
public static function cacheText(char:String = "",?bold:Bool = false,?txt:FlxText = null):FlxSprite{
if(char == "") return null;
var kill = false;
if(txt == null) {
txt = new FlxText(-10000,0,"",48);
kill = true;
}
if(char == "") return;
var charID = char + '${if(bold) '-bold' else ''}';
var charID = char + (bold ? "-bold" : "");
txt.text = char;
if(bold){
txt.color = 0xFFFFFF;
Expand All @@ -353,12 +353,13 @@ class AlphaCharacter extends FlxSprite {
// };
// _char.graphic.dump();
// _char.graphic.persist = true;
textCache[charID] = new FlxSprite();
textCache[charID].frames = txt.frames;
textCache[charID].graphic = txt.graphic;
textCache[charID].graphic.persist = true;
var spr = textCache[charID] = new FlxSprite();
spr.frames = txt.frames;
spr.graphic = txt.graphic;
spr.graphic.persist = true;

if(kill) txt.destroy();
return spr;
}

public var row:Int = 0;
Expand Down Expand Up @@ -411,7 +412,7 @@ class AlphaCharacter extends FlxSprite {
createSymbol(letter);
}else{
addAnim(letter,letter);
if(addAnim(letter,letter + " " + letterCase)){
if(addAnim(letter,'$letter $letterCase')){
animation.play(letter);
updateHitbox();
}else{
Expand All @@ -429,9 +430,8 @@ class AlphaCharacter extends FlxSprite {
}
@:keep inline public function useFLXTEXT(letter:String,bold:Bool = false) {

var cacheID = letter + '${if(bold) '-bold' else ''}';
var cacheID = letter + (bold ? '-bold' : '');
var txt = textCache[cacheID] ?? cacheText(letter,bold);
// txt = textCache[cacheID];
if(txt != null){
graphic = txt.graphic;
frames = txt.frames;
Expand Down
19 changes: 10 additions & 9 deletions source/Note.hx
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ class Note extends FlxSprite
// prevNote.setGraphicSize();
}
}else{
animation.play(if(noteJSON == null) noteName + "Scroll" else "scroll");
animation.play(noteJSON == null ? noteName + "Scroll" : "scroll");
}
}else{
noteID = -40;
Expand Down Expand Up @@ -483,10 +483,8 @@ class Note extends FlxSprite
visible = showNote;
var dad = PlayState.opponentCharacter;
if (mustPress) {
if (shouldntBeHit) {
updateCanHit();
}else{

updateCanHit();
if (!shouldntBeHit) {
updateCanHit();

if (!wasGoodHit && strumTime < Conductor.songPosition - (Conductor.safeZoneOffset * Conductor.timeScale)){
Expand All @@ -495,15 +493,18 @@ class Note extends FlxSprite
skipNote = true;
if (!shouldntBeHit) {
PlayState.instance.health += PlayState.SONG.noteMetadata.tooLateHealth;
PlayState.instance.vocals.volume = 0;
PlayState.instance.vocals.setVolume(0,0);
PlayState.instance.noteMiss(noteData, this);
}
// color.saturation = 0;
// FlxTween.tween(this,{alpha:0},0.2,{onComplete:(_)->{
// PlayState.instance.notes.remove(this, true);
PlayState.instance.notes.remove(this, true);

destroy();
// destroy();
// }});
}
// }
}
}else if (aiShouldPress && (dad == null || !dad.isStunned) && PlayState.dadShow && !PlayState.p2canplay && strumTime <= Conductor.songPosition) {
dadNotePress();
Expand All @@ -521,9 +522,9 @@ class Note extends FlxSprite
if (dad.useVoices){
dad.voiceSounds[noteData].play(1);
dad.voiceSounds[noteData].time = 0;
PlayState.instance.vocals.volume = 0;
PlayState.instance.vocals.setVolume(1,0);
}else if (PlayState.instance.vocals != null){
PlayState.instance.vocals.volume = SESave.data.voicesVol;
PlayState.instance.vocals.setVolume(1,SESave.data.voicesVol);
}
if(kill){
PlayState.instance.notes.remove(this);
Expand Down
78 changes: 45 additions & 33 deletions source/PlayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -2004,6 +2004,7 @@ class PlayState extends ScriptMusicBeatState
Conductor.songPosition = FlxG.sound.music.time;
FlxG.sound.music.play();
vocals.syncedSound = FlxG.sound.music;
if(!vocals.playing) vocals.play();
vocals.sync();
// FlxG.sound.music
resyncCount++;
Expand Down Expand Up @@ -2232,7 +2233,7 @@ class PlayState extends ScriptMusicBeatState
var daNote = notes.members[0];
if (daNote.skipNote || daNote.mustPress || !daNote.wasGoodHit) break;
daNote.active = false;
vocals.volume = 0;
vocals.setVolume(1,0);
notes.members.shift();
daNote.kill();
}
Expand Down Expand Up @@ -2291,10 +2292,10 @@ class PlayState extends ScriptMusicBeatState
SEProfiler.qStart('Add Notes');
while(unspawnNotes[0] != null && unspawnNotes[0].strumTime - Conductor.songPosition < 3500){
var dunceNote:Note = unspawnNotes.shift();
callInterp('noteSpawn',[dunceNote]);
if(dunceNote.strumTime - Conductor.songPosition < -100){ // Fucking don't load notes that are 100 ms before the current time
dunceNote.destroy();
}else{ // we add note lmao
callInterp('noteSpawn',[dunceNote]);
notes.add(dunceNote);
var strumNote = (if (dunceNote.parentSprite != null) dunceNote.parentSprite else if (dunceNote.mustPress) playerStrums.members[Math.floor(Math.abs(dunceNote.noteData))] else strumLineNotes.members[Math.floor(Math.abs(dunceNote.noteData))] );
updateNotePosition(dunceNote,strumNote);
Expand Down Expand Up @@ -2429,8 +2430,7 @@ class PlayState extends ScriptMusicBeatState
if(!shouldEndSong){shouldEndSong = true;return;}

canPause = false;
FlxG.sound.music.volume = 0;
vocals.volume = 0;
FlxG.sound.music.volume = vocals.volume = 0;

if (offsetTesting){
FlxG.sound.playMusic(Paths.music('freakyMenu'));
Expand Down Expand Up @@ -2504,7 +2504,7 @@ class PlayState extends ScriptMusicBeatState
var daRating = daNote.rating;
if(daRating == "miss") return noteMiss(daNote.noteData,null,null,true);
var noteDiff:Float = Math.abs(Conductor.songPosition - daNote.strumTime);
vocals.volume = SESave.data.voicesVol;
vocals.setVolume(0,SESave.data.voicesVol);

var placement:String = Std.string(combo);
var camHUD = camHUD;
Expand Down Expand Up @@ -2781,6 +2781,7 @@ class PlayState extends ScriptMusicBeatState
var strumNote:FlxSprite;
var i = notes.members.length - 1;
var daNote:Note;
final swagWidth = (Note.swagWidth * 0.5);
while (i > -1){
daNote = notes.members[i];
i--;
Expand All @@ -2789,7 +2790,6 @@ class PlayState extends ScriptMusicBeatState
if (daNote.tooLate){
daNote.active = false;
daNote.visible = false;
notes.members.splice(i,1);
daNote.kill();
notes.remove(daNote, true);
continue;
Expand All @@ -2809,22 +2809,22 @@ class PlayState extends ScriptMusicBeatState
daNote.y = strumNote.y + daNote.distanceToSprite;
if(daNote.isSustainNote){
// daNote.isSustainNoteEnd &&
// if(daNote.isSustainNoteEnd && daNote.prevNote != null)
// daNote.y = daNote.prevNote.y - (daNote.frameHeight * daNote.scale.y);
// else
daNote.y += Note.swagWidth * 0.5;
if(daNote.isSustainNoteEnd && daNote.prevNote != null)
daNote.y = daNote.prevNote.y - (daNote.frameHeight * daNote.scale.y);
else
daNote.y += swagWidth;

// Only clip sustain notes when properly hit
if(daNote.clipSustain && (daNote.isPressed || !daNote.mustPress) && (daNote.mustPress || _dadShow && daNote.aiShouldPress) && FlxG.overlap(daNote,strumNote)){
// Clip to strumline
var swagRect = new FlxRect(0, 0, daNote.frameWidth, daNote.frameHeight);
swagRect.height = (strumNote.y + (Note.swagWidth / 2) - daNote.y) / daNote.scale.y;
swagRect.y = daNote.frameHeight - swagRect.height;
swagRect.height = (strumNote.y + swagWidth - daNote.y) / daNote.scale.y;
swagRect.y = (daNote.height / daNote.scale.y) - swagRect.height;
if(daNote.mustPress && swagRect.height < 0 ) {goodNoteHit(daNote);continue;}

daNote.clipRect = swagRect;
daNote.susHit(if(daNote.mustPress)0 else 1,daNote);
callInterp("susHit" + (if(daNote.mustPress) "" else "Dad"),[daNote]);
daNote.susHit((daNote.mustPress) ? 0 : 1,daNote);
callInterp((daNote.mustPress) ? "susHit" : "susHitDad",[daNote]);
}
}
}else{ // upscroll
Expand All @@ -2833,21 +2833,30 @@ class PlayState extends ScriptMusicBeatState
// if(daNote.isSustainNoteEnd && daNote.parentNote != null){
// daNote.y = daNote.prevNote.y + Math.ceil(daNote.frameHeight * daNote.scale.y);
// }else
daNote.y -= Note.swagWidth * 0.5;
daNote.y -= swagWidth;
// (!daNote.mustPress || daNote.wasGoodHit || daNote.prevNote.wasGoodHit && !daNote.canBeHit) &&
if(daNote.clipSustain && (daNote.isPressed || !daNote.mustPress) && (daNote.mustPress || _dadShow && daNote.aiShouldPress) && FlxG.overlap(daNote,strumNote))
{
// Clip to strumline
var swagRect = daNote.clipRect ?? new FlxRect(0, 0, 0, 0);
swagRect.height = daNote.height / daNote.scale.y;
swagRect.width = daNote.width / daNote.scale.x;
swagRect.y = (strumNote.y + (Note.swagWidth / 2) - daNote.y) / daNote.scale.y;
swagRect.y = (strumNote.y + swagWidth - daNote.y) / daNote.scale.y;
if(daNote.parentNote != null && daNote.childNotes[0] != null){
swagRect.height = Math.abs(daNote.y - daNote.childNotes[0].y);

}
swagRect.height -= swagRect.y;
if(daNote.mustPress && swagRect.height < 0 ) {goodNoteHit(daNote);continue;}

daNote.clipRect = swagRect;
daNote.susHit((daNote.mustPress) ? 0 : 1,daNote);
callInterp((daNote.mustPress) ? "susHit" : "susHitDad",[daNote]);
}else if(daNote.parentNote != null && daNote.childNotes[0] != null){
var swagRect = daNote.clipRect ?? new FlxRect(0, 0, 0, 0);
swagRect.height = Math.abs(daNote.y - daNote.childNotes[0].y);
daNote.clipRect = swagRect;

}
}

Expand All @@ -2858,17 +2867,17 @@ class PlayState extends ScriptMusicBeatState

updateNotePosition(daNote,strumNote);

if(daNote.mustPress && daNote.tooLate){
if (!daNote.shouldntBeHit) {
if(handleHealth) health += SONG.noteMetadata.tooLateHealth;
vocals.volume = 0;
noteMiss(daNote.noteData, daNote);
}
// if(daNote.mustPress && daNote.tooLate){
// if (!daNote.shouldntBeHit) {
// if(handleHealth) health += SONG.noteMetadata.tooLateHealth;
// vocals.setVolume(0,0);
// noteMiss(daNote.noteData, daNote);
// }

daNote.visible = false;
notes.remove(daNote);
daNote.destroy();
}
// daNote.visible = false;
// notes.remove(daNote);
// daNote.destroy();
// }
}
SEProfiler.qStamp('note updating');
}
Expand Down Expand Up @@ -3028,7 +3037,7 @@ class PlayState extends ScriptMusicBeatState
if (!pressArray[daNote.noteData] || !daNote.updateCanHit(Conductor.songPosition + ((Sys.time() * 1000) - lastMusicUpdate)) || daNote.tooLate || daNote.wasGoodHit) continue;
var coolNote = possibleNotes[daNote.noteData];
if (coolNote != null){
if((Math.abs(daNote.strumTime - coolNote.strumTime) < 7 * Conductor.timeScale)){
if((Math.abs(daNote.strumTime - coolNote.strumTime) < 7)){
notes.remove(daNote);
daNote.destroy();
continue;
Expand Down Expand Up @@ -3320,8 +3329,8 @@ class PlayState extends ScriptMusicBeatState
if (playerCharacter.useVoices){
playerCharacter.voiceSounds[note.noteData].play(1);
playerCharacter.voiceSounds[note.noteData].time = 0;
vocals.volume = 0;
}else vocals.volume = SESave.data.voicesVol;
vocals.setVolume(0,0);
}else vocals.setVolume(0,SESave.data.voicesVol);
notes.remove(note, true);
note.kill();
note.destroy();
Expand All @@ -3338,8 +3347,7 @@ class PlayState extends ScriptMusicBeatState



public function noteMiss(direction:Int = 1, daNote:Note,?forced:Bool = false,?calcStats:Bool = true):Void
{
public function noteMiss(direction:Int = 1, daNote:Note,?forced:Bool = false,?calcStats:Bool = true):Void {
noteMissdyn(direction,daNote,forced,calcStats);
}
public function playMissSound(char,direction){
Expand Down Expand Up @@ -3387,7 +3395,11 @@ class PlayState extends ScriptMusicBeatState
if (SESave.data.accuracyMod == 1 && calcStats) totalNotesHit -= 1;

if(calcStats) songScore -= 10;
if (daNote != null && daNote.shouldntBeHit) {songScore += SONG.noteMetadata.badnoteScore; if(handleHealth) health += SONG.noteMetadata.badnoteHealth;} // Having it insta kill, not a good idea
// Having it insta kill, not a good idea
if (daNote != null && daNote.shouldntBeHit) {
songScore += SONG.noteMetadata.badnoteScore;
if(handleHealth) health += SONG.noteMetadata.badnoteHealth;
}
if(daNote == null){
callInterp("miss",[player,direction,calcStats]);
player.callInterp('miss',[direction,calcStats]);
Expand Down Expand Up @@ -3634,7 +3646,7 @@ class PlayState extends ScriptMusicBeatState
if(boyfriend != null && player != bf && opponent != bf && boyfriend.currentAnimationPriority != 10){
boyfriend.dance(true,curBeat % 2 == 0,true);
}
if(dad != null && opponent != dad && opponent != dad && dad.currentAnimationPriority != 10){
if(dad != null && opponent != dad && player != dad && dad.currentAnimationPriority != 10){
dad.dance(true,curBeat % 2 == 0,true);
}
if(player != null && player.currentAnimationPriority != 10){
Expand Down
37 changes: 22 additions & 15 deletions source/QuickNameSubState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,20 @@ class QuickNameSubState extends MusicBeatSubstate{
FlxG.mouse.visible = true;

super();
buttonPress = function(){
var str:String = check(textBox.text);
if(str != ""){
shownText.text = str;
shownText.color = FlxColor.RED;
shownText.screenCenter(X);

return;
}
CoolUtil.toggleVolKeys(true);
args.insert(0,textBox.text);
Reflect.callMethod(null,funky,args);
destroy();
}
var box = new FlxSprite(20,20).loadGraphic(FlxGraphic.fromRectangle(1240,680,0xdd000000));
box.color = 0xdddddd;
// box.alpha = 0.2;
Expand All @@ -58,20 +71,7 @@ class QuickNameSubState extends MusicBeatSubstate{

// shownText.width = FlxG.width * 0.45;
add(shownText);
funniButton = new FlxButton(0,0,"Continue",function(){
var str:String = check(textBox.text);
if(str != ""){
shownText.text = str;
shownText.color = FlxColor.RED;
shownText.screenCenter(X);

return;
}
CoolUtil.toggleVolKeys(true);
args.insert(0,textBox.text);
Reflect.callMethod(null,funky,args);
destroy();
});
funniButton = new FlxButton(0,0,"Continue",buttonPress);
funniButton.x = textBox.x + textBox.width - (funniButton.width + 2);
funniButton.y = textBox.y + textBox.height + 5;
add(funniButton);
Expand All @@ -80,7 +80,7 @@ class QuickNameSubState extends MusicBeatSubstate{

FlxG.state.persistentUpdate = befUpdate;
CoolUtil.toggleVolKeys(true);
destroy();
close();

});

Expand All @@ -89,12 +89,19 @@ class QuickNameSubState extends MusicBeatSubstate{
add(cancelButton);
}
}
dynamic function buttonPress(){}
override function update(e){
super.update(e);
if(FlxG.keys.justPressed.ESCAPE){
FlxG.mouse.visible = oldMVis;
FlxG.state.persistentUpdate = befUpdate;
CoolUtil.toggleVolKeys(true);
// destroy();
close();
}
if(FlxG.keys.justPressed.ENTER){
buttonPress();
}
}
var _grab:BitmapData;

Expand Down
Loading

0 comments on commit 36e9a12

Please sign in to comment.