From 36e9a12db31234bc2bf7f087dd4fff4bdab673e0 Mon Sep 17 00:00:00 2001 From: Super <38338700+superpowers04@users.noreply.github.com> Date: Fri, 23 Aug 2024 23:55:38 -0400 Subject: [PATCH] Finally seperate vocals on vslice charts Some sustain improvements --- source/Alphabet.hx | 20 ++++---- source/Note.hx | 19 ++++---- source/PlayState.hx | 78 +++++++++++++++++------------- source/QuickNameSubState.hx | 37 ++++++++------ source/se/objects/SEJoinedSound.hx | 23 +++++++-- version.downloadMe | 2 +- 6 files changed, 108 insertions(+), 71 deletions(-) diff --git a/source/Alphabet.hx b/source/Alphabet.hx index 04bc02dd..b080cc28 100644 --- a/source/Alphabet.hx +++ b/source/Alphabet.hx @@ -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; @@ -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; @@ -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{ @@ -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; diff --git a/source/Note.hx b/source/Note.hx index 8a0f9c31..6945c801 100644 --- a/source/Note.hx +++ b/source/Note.hx @@ -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; @@ -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)){ @@ -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(); @@ -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); diff --git a/source/PlayState.hx b/source/PlayState.hx index 46533895..11c76b31 100644 --- a/source/PlayState.hx +++ b/source/PlayState.hx @@ -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++; @@ -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(); } @@ -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); @@ -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')); @@ -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; @@ -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--; @@ -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; @@ -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 @@ -2833,7 +2833,7 @@ 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)) { @@ -2841,13 +2841,22 @@ class PlayState extends ScriptMusicBeatState 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; + } } @@ -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'); } @@ -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; @@ -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(); @@ -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){ @@ -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]); @@ -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){ diff --git a/source/QuickNameSubState.hx b/source/QuickNameSubState.hx index 02d1a4c0..b1eb7b96 100644 --- a/source/QuickNameSubState.hx +++ b/source/QuickNameSubState.hx @@ -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; @@ -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); @@ -80,7 +80,7 @@ class QuickNameSubState extends MusicBeatSubstate{ FlxG.state.persistentUpdate = befUpdate; CoolUtil.toggleVolKeys(true); - destroy(); + close(); }); @@ -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; diff --git a/source/se/objects/SEJoinedSound.hx b/source/se/objects/SEJoinedSound.hx index 593fef39..28c64eb9 100644 --- a/source/se/objects/SEJoinedSound.hx +++ b/source/se/objects/SEJoinedSound.hx @@ -21,6 +21,7 @@ import flixel.FlxG; @:keep inline function get_length(){ return sounds.length; } + var syncVolume:Bool = false; var syncTime:Bool = true; var maxTimeDifference:Int=5; @@ -104,14 +105,30 @@ import flixel.FlxG; sounds.remove(sound); return sound; } + function setVolume(index:Int,volume:Float){ + return (sounds[index] is FlxSound ? sounds[index] : sound).volume = volume; + } + + function getVolume(index:Int){ + return (sounds[index] is FlxSound ? sounds[index] : sound).volume; + } // Shadowed Variables/Functions. This shit is dumb tbh - function stop() for(sound in sounds) sound.stop(); + function stop() { + for(sound in sounds) sound.stop(); + sync(); + } // function start() for(sound in sounds) sound.start();s - function play() for(sound in sounds) sound.play(); - function pause() for(sound in sounds) sound.pause(); + function play() { + for(sound in sounds) sound.play(); + sync(); + } + function pause() { + for(sound in sounds) sound.pause(); + sync(); + } var volume(get,set):Float; function get_volume() return sound?.volume; function set_volume(v) {for(sound in sounds) {sound.volume=v;} return v;} diff --git a/version.downloadMe b/version.downloadMe index 3d3e53ec..bf117e9e 100644 --- a/version.downloadMe +++ b/version.downloadMe @@ -1,4 +1,4 @@ -24.08.18.0406; +24.08.23.2304; * Better Psych character support(Still kinda experimental but should be more stable) * Fix some small errors * Fix characters not loading due to using ID instead of folderName