From 93780db180eb1439bab18d805e37d59f428d00f1 Mon Sep 17 00:00:00 2001 From: NeeEoo Date: Fri, 13 Jan 2023 01:23:08 +0100 Subject: [PATCH] Live Reload for Mac + Various Fixes --- buildnumber.txt | 2 +- .../funkin/desktop/editors/CharacterEditor.hx | 1 + source/funkin/editors/ChartingState.hx | 68 ---- source/funkin/game/Character.hx | 2 +- source/funkin/game/GameOverSubstate.hx | 3 +- source/funkin/game/Note.hx | 11 + source/funkin/game/PlayState.hx | 351 +++++++++--------- source/funkin/menus/MainMenuState.hx | 4 +- source/funkin/menus/PauseSubState.hx | 4 +- source/funkin/multitasking/StateWindow.hx | 2 +- source/funkin/scripting/Script.hx | 10 +- source/funkin/system/AudioSwitchFix.hx | 20 +- source/funkin/system/FlxAnimate.hx | 129 +++---- source/funkin/system/Main.hx | 50 ++- source/funkin/system/Section.hx | 22 +- 15 files changed, 312 insertions(+), 367 deletions(-) diff --git a/buildnumber.txt b/buildnumber.txt index f969929f..5ee5d632 100644 --- a/buildnumber.txt +++ b/buildnumber.txt @@ -1 +1 @@ -2032 \ No newline at end of file +2034 \ No newline at end of file diff --git a/source/funkin/desktop/editors/CharacterEditor.hx b/source/funkin/desktop/editors/CharacterEditor.hx index cd4cebea..c986eb4a 100644 --- a/source/funkin/desktop/editors/CharacterEditor.hx +++ b/source/funkin/desktop/editors/CharacterEditor.hx @@ -83,6 +83,7 @@ class CharacterEditor extends WindowContent { camFollow = new FlxObject(0, 0, 2, 2); camFollow.setPosition(charMidpoint.x, charMidpoint.y); add(camFollow); + charMidpoint.put(); windowCamera.follow(camFollow, LOCKON, 999); // loading animations from character diff --git a/source/funkin/editors/ChartingState.hx b/source/funkin/editors/ChartingState.hx index 6f0f9924..b9b1c3fe 100644 --- a/source/funkin/editors/ChartingState.hx +++ b/source/funkin/editors/ChartingState.hx @@ -58,11 +58,6 @@ class ChartingState extends MusicBeatState var bpmTxt:FlxText; var strumLine:FlxSprite; - var curSong:String = 'Dadbattle'; - var amountSteps:Int = 0; - var bullshitUI:FlxGroup; - - var highlight:FlxSprite; var GRID_SIZE:Int = 40; @@ -181,7 +176,6 @@ class ChartingState extends MusicBeatState add(curRenderedNotes); add(curRenderedSustains); - super.create(); } @@ -379,25 +373,6 @@ class ChartingState extends MusicBeatState }; } - function generateUI():Void - { - while (bullshitUI.members.length > 0) - { - bullshitUI.remove(bullshitUI.members[0], true); - } - - // general shit - var title:FlxText = new FlxText(UI_box.x + 20, UI_box.y + 20, 0); - bullshitUI.add(title); - /* - var loopCheck = new FlxUICheckBox(UI_box.x + 10, UI_box.y + 50, null, null, "Loops", 100, ['loop check']); - loopCheck.checked = curNoteSelected.doesLoop; - tooltips.add(loopCheck, {title: 'Section looping', body: "Whether or not it's a simon says style section", style: tooltipType}); - bullshitUI.add(loopCheck); - - */ - } - override function getEvent(id:String, sender:Dynamic, data:Dynamic, ?params:Array) { if (id == FlxUICheckBox.CLICK_EVENT) @@ -870,7 +845,6 @@ class ChartingState extends MusicBeatState changeBPM: false, mustHitSection: true, sectionNotes: [], - typeOfSection: 0, altAnim: false }; @@ -960,48 +934,6 @@ class ChartingState extends MusicBeatState return FlxMath.remapToRange(strumTime, 0, 16 * Conductor.stepCrochet, gridBG.y, gridBG.y + gridBG.height); } - /* - function calculateSectionLengths(?sec:SwagSection):Int - { - var daLength:Int = 0; - - for (i in _song.notes) - { - var swagLength = i.lengthInSteps; - - if (i.typeOfSection == Section.COPYCAT) - swagLength * 2; - - daLength += swagLength; - - if (sec != null && sec == i) - { - trace('swag loop??'); - break; - } - } - - return daLength; - }*/ - private var daSpacing:Float = 0.3; - - function loadLevel():Void - { - trace(_song.notes); - } - - function getNotes():Array - { - var noteData:Array = []; - - for (i in _song.notes) - { - noteData.push(i.sectionNotes); - } - - return noteData; - } - function loadJson(song:String):Void { PlayState.SONG = Song.loadFromJson(PlayState.storyPlaylist[0].toLowerCase(), PlayState.difficulty); diff --git a/source/funkin/game/Character.hx b/source/funkin/game/Character.hx index 2a939815..0d3bf134 100644 --- a/source/funkin/game/Character.hx +++ b/source/funkin/game/Character.hx @@ -68,9 +68,9 @@ class Character extends FunkinSprite implements IBeatReceiver implements IOffset midpoint.x + (isPlayer ? -100 : 150) + globalOffset.x + cameraOffset.x, midpoint.y - 100 + globalOffset.y + cameraOffset.y); script.call("onGetCamPos", [event]); + midpoint.put(); // this event cannot be cancelled return new FlxPoint(event.x, event.y); - } public function playSingAnim(direction:Int, suffix:String = "", Context:PlayAnimContext = SING, Reversed:Bool = false, Frame:Int = 0) { diff --git a/source/funkin/game/GameOverSubstate.hx b/source/funkin/game/GameOverSubstate.hx index 2300772f..61610826 100644 --- a/source/funkin/game/GameOverSubstate.hx +++ b/source/funkin/game/GameOverSubstate.hx @@ -54,8 +54,7 @@ class GameOverSubstate extends MusicBeatSubstate lossSFX = FlxG.sound.play(Paths.sound(lossSFXName)); Conductor.changeBPM(100); - - + DiscordUtil.changePresence('Game Over', PlayState.SONG.song + " (" + PlayState.difficulty + ")"); } diff --git a/source/funkin/game/Note.hx b/source/funkin/game/Note.hx index b0112cbb..5336849d 100644 --- a/source/funkin/game/Note.hx +++ b/source/funkin/game/Note.hx @@ -242,4 +242,15 @@ class Note extends FlxSprite public function setClipRect(rect:FlxRect) { this.clipRect = rect; } + + @:noCompletion + override function set_clipRect(rect:FlxRect):FlxRect + { + clipRect = rect; + + if (frames != null) + frame = frames.frames[animation.frameIndex]; + + return rect; + } } diff --git a/source/funkin/game/PlayState.hx b/source/funkin/game/PlayState.hx index fd4217b4..2a611a2e 100644 --- a/source/funkin/game/PlayState.hx +++ b/source/funkin/game/PlayState.hx @@ -288,7 +288,7 @@ class PlayState extends MusicBeatState * Camera for the game (stages, characters) */ public var camGame:FlxCamera; - + /** * The player's current score. */ @@ -507,7 +507,7 @@ class PlayState extends MusicBeatState // String for when the game is paused detailsPausedText = "Paused - " + detailsText; - + // Updating Discord Rich Presence. dad = new Character(100, 100, SONG.player2); @@ -525,7 +525,9 @@ class PlayState extends MusicBeatState } } - var camPos:FlxPoint = new FlxPoint(dad.getGraphicMidpoint().x, dad.getGraphicMidpoint().y); + var dadMidpoint = dad.getGraphicMidpoint(); + var camPos:FlxPoint = new FlxPoint(dadMidpoint.x, dadMidpoint.y); + dadMidpoint.put(); comboGroup = new FlxSpriteGroup(FlxG.width * 0.55, (FlxG.height * 0.5) - 60); @@ -536,7 +538,7 @@ class PlayState extends MusicBeatState if (SONG.stage == null || SONG.stage.trim() == "") SONG.stage = "stage"; add(stage = new Stage(SONG.stage)); - + switch(SONG.song) { // case "": // ADD YOUR HARDCODED SCRIPTS HERE! @@ -576,7 +578,7 @@ class PlayState extends MusicBeatState if (dad != null) add(dad); if (boyfriend != null) add(boyfriend); - + strumLine = new FlxObject(0, 50, FlxG.width, 10); @@ -743,7 +745,7 @@ class PlayState extends MusicBeatState */ public function countdown(swagCounter:Int) { var event:CountdownEvent = scripts.event("onCountdown", EventManager.get(CountdownEvent).recycle( - swagCounter, + swagCounter, 1, introSounds[swagCounter], introSprites[swagCounter], @@ -769,6 +771,7 @@ class PlayState extends MusicBeatState onComplete: function(twn:FlxTween) { sprite.destroy(); + remove(sprite, true); } }); } @@ -823,8 +826,6 @@ class PlayState extends MusicBeatState if (songData.noteTypes == null) songData.noteTypes = []; var noteData:Array = songData.notes; - var playerCounter:Int = 0; - var daBeats:Int = 0; // Not exactly representative of 'daBeats' lol, just how much it has looped var stepCrochet = Conductor.stepCrochet; for (section in noteData) @@ -845,7 +846,7 @@ class PlayState extends MusicBeatState var gottaHitNote:Bool = daNoteData >= 4 ? !section.mustHitSection : section.mustHitSection; if (songNotes.length > 2) { - if (songNotes[3] is Int) + if (songNotes[3] is Int) daNoteType = addNoteType(songData.noteTypes[Std.int(songNotes[3])-1], songNotes[3] == 0); else if (songNotes[3] is String) daNoteType = addNoteType(songNotes[3]); @@ -864,7 +865,7 @@ class PlayState extends MusicBeatState swagNote.scrollFactor.set(0, 0); swagNote.stepLength = stepCrochet; notes.add(swagNote); - + // calculate sustain length and fix var susLength:Float = swagNote.sustainLength / stepCrochet; if (susLength > 0.75) susLength++; @@ -880,7 +881,6 @@ class PlayState extends MusicBeatState splashHandler.getSplashGroup(swagNote.splash); } - daBeats += 1; } notes.sortNotes(); } @@ -962,10 +962,10 @@ class PlayState extends MusicBeatState babyArrow.animation.addByPrefix('blue', 'arrowDOWN'); babyArrow.animation.addByPrefix('purple', 'arrowLEFT'); babyArrow.animation.addByPrefix('red', 'arrowRIGHT'); - + babyArrow.antialiasing = true; babyArrow.setGraphicSize(Std.int(babyArrow.width * 0.7)); - + switch (babyArrow.ID % 4) { case 0: @@ -1064,7 +1064,7 @@ class PlayState extends MusicBeatState { scripts.call("onFocus"); - + if (__wasAutoPause) { updateDiscordPresence(); if (__songPlaying) { @@ -1075,7 +1075,7 @@ class PlayState extends MusicBeatState super.onFocus(); } - + override public function onFocusLost():Void { scripts.call("onFocusLost"); @@ -1085,7 +1085,7 @@ class PlayState extends MusicBeatState inst.pause(); vocals.pause(); } - + super.onFocusLost(); } @@ -1122,7 +1122,7 @@ class PlayState extends MusicBeatState } else openSubState(new PauseSubState(boyfriend.getScreenPosition().x, boyfriend.getScreenPosition().y)); - + updateDiscordPresence(); } @@ -1134,12 +1134,12 @@ class PlayState extends MusicBeatState scoreTxt.text = 'Score:$songScore'; missesTxt.text = '${comboBreaks ? "Combo Breaks" : "Misses"}:$misses'; var acc = accuracy; - + var rating:ComboRating = curRating == null ? new ComboRating(0, "[N/A]", 0xFF888888) : curRating; @:privateAccess accFormat.format.color = rating.color; accuracyTxt.text = 'Accuracy:${acc < 0 ? "-%" : '${FlxMath.roundDecimal(acc * 100, 2)}%'} - ${rating.rating}'; - + @:privateAccess var format = accuracyTxt._formatRanges[0]; format.range.start = accuracyTxt.text.length - rating.rating.length; @@ -1262,7 +1262,7 @@ class PlayState extends MusicBeatState if (FlxG.keys.justPressed.ONE) endSong(); #end - + scripts.call("postUpdate", [elapsed]); } @@ -1276,7 +1276,7 @@ class PlayState extends MusicBeatState break; //ing bad } } - + var event = PlayState.instance.scripts.event("onNoteUpdate", __updateNote_event.recycle(daNote, FlxG.elapsed, __updateNote_strum)); if (!event.cancelled) { if (event.__updateHitWindow) { @@ -1291,7 +1291,7 @@ class PlayState extends MusicBeatState else daNote.canBeHit = false; } - + if (event.__autoCPUHit && !daNote.mustPress && !daNote.wasGoodHit && daNote.strumTime < Conductor.songPosition) goodNoteHit(daNote); if (daNote.wasGoodHit && daNote.isSustainNote && daNote.strumTime + (daNote.stepLength) < Conductor.songPosition) { @@ -1304,7 +1304,7 @@ class PlayState extends MusicBeatState return; } - + if (event.strum == null) return; if (event.__reposNote) event.strum.updateNotePosition(daNote); @@ -1312,7 +1312,7 @@ class PlayState extends MusicBeatState PlayState.instance.scripts.event("onNotePostUpdate", event); } - + } function gameOver(?character:String, ?gameOverSong:String, ?lossSFX:String, ?retrySFX:String) { @@ -1320,7 +1320,7 @@ class PlayState extends MusicBeatState gameOverSong = gameOverSong.getDefault(this.gameOverSong); lossSFX = lossSFX.getDefault(this.lossSFX); retrySFX = retrySFX.getDefault(this.retrySFX); - + boyfriend.stunned = true; persistentUpdate = false; @@ -1423,7 +1423,7 @@ class PlayState extends MusicBeatState __justPressed = CoolUtil.getDefault(event.justPressed, []); __justReleased = CoolUtil.getDefault(event.justReleased, []); - + if (__pressed.contains(true)) { __funcsToExec.push(function(note:Note) { if (__pressed[note.strumID] && note.isSustainNote && note.canBeHit && note.mustPress && !note.wasGoodHit) { @@ -1464,7 +1464,7 @@ class PlayState extends MusicBeatState var event:NoteHitEvent = scripts.event("onPlayerMiss", EventManager.get(NoteHitEvent).recycle(true, false, false, note, [boyfriend], true, note.noteType, "", "", "", note.strumID, -10, 0, -0.04, "shit")); if (event.cancelled) return; - + health += event.healthGain; if (gf != null && combo > 5 && gf.animOffsets.exists('sad')) { @@ -1503,155 +1503,154 @@ class PlayState extends MusicBeatState function goodNoteHit(note:Note):Void { - if (!note.wasGoodHit) + if(note.wasGoodHit) return; + + note.wasGoodHit = true; + + /** + * CALCULATES RATING + */ + var noteDiff = Math.abs(Conductor.songPosition - note.strumTime); + var daRating:String = "sick"; + var score:Int = 300; + var accuracy:Float = 1; + + if (noteDiff > hitWindow * 0.9) { - note.wasGoodHit = true; - - /** - * CALCULATES RATING - */ - var noteDiff = Math.abs(Conductor.songPosition - note.strumTime); - var daRating:String = "sick"; - var score:Int = 300; - var accuracy:Float = 1; - - if (noteDiff > hitWindow * 0.9) - { - daRating = 'shit'; - score = 50; - accuracy = 0.25; - } - else if (noteDiff > hitWindow * 0.75) - { - daRating = 'bad'; - score = 100; - accuracy = 0.45; - } - else if (noteDiff > hitWindow * 0.2) - { - daRating = 'good'; - score = 200; - accuracy = 0.75; - } - - var event:NoteHitEvent; - if (note.mustPress) - // event = scripts.event("onPlayerHit", EventManager.get(NoteHitEvent).recycle(note, [boyfriend], true, note.noteType, note.strumID, note.noteData > 0 ? 0.023 : 0.004, score, note.animSuffix, daRating, note.isSustainNote ? null : accuracy, "game/score/", '')); - event = scripts.event("onPlayerHit", EventManager.get(NoteHitEvent).recycle(false, !note.isSustainNote, !note.isSustainNote, note, [boyfriend], true, note.noteType, "", "game/score/", "", note.strumID, score, note.isSustainNote ? null : accuracy, note.noteData > 0 ? 0.023 : 0.004, daRating, daRating == "sick")); - else - event = scripts.event("onDadHit", EventManager.get(NoteHitEvent).recycle(false, false, false, note, [dad], false, note.noteType, "", "game/score/", "", note.strumID, 0, null, 0, daRating, false)); - - if (!event.cancelled) { - if (event.accuracy != null) { - accuracyPressedNotes++; - totalAccuracyAmount += event.accuracy; - - updateRating(); - } - if (event.countAsCombo) combo++; - - if (event.showRating || (event.showRating == null && event.player && !note.isSustainNote)) - { - var rating:FlxSprite = comboGroup.recycle(FlxSprite); - rating.resetSprite(-40, -60); - comboGroup.remove(rating, true); - - songScore += score; - - rating.loadAnimatedGraphic(Paths.image('${event.ratingPrefix}$daRating${event.ratingSuffix}')); - rating.acceleration.y = 550; - rating.velocity.y -= FlxG.random.int(140, 175); - rating.velocity.x -= FlxG.random.int(0, 10); - - var comboSpr:FlxSprite = comboGroup.recycle(FlxSprite).loadAnimatedGraphic(Paths.image('${event.ratingPrefix}combo${event.ratingSuffix}')); - comboSpr.resetSprite(0, 0); - comboGroup.remove(comboSpr, true); - comboSpr.acceleration.y = 600; - comboSpr.velocity.y -= 150; - comboSpr.velocity.x += FlxG.random.int(1, 10); - - - rating.scale.set(event.ratingScale, event.ratingScale); - rating.antialiasing = event.ratingAntialiasing; - comboSpr.scale.set(event.ratingScale, event.ratingScale); - comboSpr.antialiasing = event.ratingAntialiasing; - - comboSpr.updateHitbox(); - rating.updateHitbox(); - - var separatedScore:String = Std.string(combo).addZeros(3); - - - if (combo == 0 || combo >= 10) { - comboGroup.add(comboSpr); - for (i in 0...separatedScore.length) - { - var numScore:FlxSprite = comboGroup.recycle(FlxSprite).loadAnimatedGraphic(Paths.image('${event.ratingPrefix}num${separatedScore.charAt(i)}${event.ratingSuffix}')); - numScore.resetSprite((43 * i) - 90, 80); - comboGroup.remove(numScore, true); - numScore.antialiasing = event.numAntialiasing; - numScore.scale.set(event.numScale, event.numScale); - numScore.updateHitbox(); - - numScore.acceleration.y = FlxG.random.int(200, 300); - numScore.velocity.y -= FlxG.random.int(140, 160); - numScore.velocity.x = FlxG.random.float(-5, 5); - - comboGroup.add(numScore); - - FlxTween.tween(numScore, {alpha: 0}, 0.2, { - onComplete: function(tween:FlxTween) - { - numScore.exists = false; - }, - startDelay: Conductor.crochet * 0.002 - }); - } - } - comboGroup.add(rating); - - FlxTween.tween(rating, {alpha: 0}, 0.2, { - startDelay: Conductor.crochet * 0.001 - }); - - FlxTween.tween(comboSpr, {alpha: 0}, 0.2, { - onComplete: function(tween:FlxTween) - { - rating.exists = false; - comboSpr.exists = false; - }, - startDelay: Conductor.crochet * 0.001 - }); - - ratingNum += 1; - } - - health += event.healthGain; - - if (!event.animCancelled) - for(char in event.characters) - if (char != null) - char.playSingAnim(event.direction, event.animSuffix); - - (event.player ? playerStrums : cpuStrums).forEach(function(str:Strum) { - if (str.ID == Math.abs(note.strumID)) { - if (!event.strumGlowCancelled) str.press(note.strumTime); - if (event.showSplash) splashHandler.showSplash(note.splash, str); - } - }); - } - - if (event.unmuteVocals) vocals.volume = 1; - if (event.enableCamZooming) camZooming = true; - if (event.autoHitLastSustain) { - if (note.nextSustain != null && note.nextSustain.nextSustain == null) { - // its a tail!! - note.wasGoodHit = true; - } - } - - if (event.deleteNote && !note.isSustainNote) deleteNote(note); + daRating = 'shit'; + score = 50; + accuracy = 0.25; } + else if (noteDiff > hitWindow * 0.75) + { + daRating = 'bad'; + score = 100; + accuracy = 0.45; + } + else if (noteDiff > hitWindow * 0.2) + { + daRating = 'good'; + score = 200; + accuracy = 0.75; + } + + var event:NoteHitEvent; + if (note.mustPress) + // event = scripts.event("onPlayerHit", EventManager.get(NoteHitEvent).recycle(note, [boyfriend], true, note.noteType, note.strumID, note.noteData > 0 ? 0.023 : 0.004, score, note.animSuffix, daRating, note.isSustainNote ? null : accuracy, "game/score/", '')); + event = scripts.event("onPlayerHit", EventManager.get(NoteHitEvent).recycle(false, !note.isSustainNote, !note.isSustainNote, note, [boyfriend], true, note.noteType, "", "game/score/", "", note.strumID, score, note.isSustainNote ? null : accuracy, note.noteData > 0 ? 0.023 : 0.004, daRating, daRating == "sick")); + else + event = scripts.event("onDadHit", EventManager.get(NoteHitEvent).recycle(false, false, false, note, [dad], false, note.noteType, "", "game/score/", "", note.strumID, 0, null, 0, daRating, false)); + + if (!event.cancelled) { + if (event.accuracy != null) { + accuracyPressedNotes++; + totalAccuracyAmount += event.accuracy; + + updateRating(); + } + if (event.countAsCombo) combo++; + + if (event.showRating || (event.showRating == null && event.player && !note.isSustainNote)) + { + var rating:FlxSprite = comboGroup.recycle(FlxSprite); + rating.resetSprite(-40, -60); + comboGroup.remove(rating, true); + + songScore += score; + + rating.loadAnimatedGraphic(Paths.image('${event.ratingPrefix}$daRating${event.ratingSuffix}')); + rating.acceleration.y = 550; + rating.velocity.y -= FlxG.random.int(140, 175); + rating.velocity.x -= FlxG.random.int(0, 10); + + var comboSpr:FlxSprite = comboGroup.recycle(FlxSprite).loadAnimatedGraphic(Paths.image('${event.ratingPrefix}combo${event.ratingSuffix}')); + comboSpr.resetSprite(0, 0); + comboGroup.remove(comboSpr, true); + comboSpr.acceleration.y = 600; + comboSpr.velocity.y -= 150; + comboSpr.velocity.x += FlxG.random.int(1, 10); + + + rating.scale.set(event.ratingScale, event.ratingScale); + rating.antialiasing = event.ratingAntialiasing; + comboSpr.scale.set(event.ratingScale, event.ratingScale); + comboSpr.antialiasing = event.ratingAntialiasing; + + comboSpr.updateHitbox(); + rating.updateHitbox(); + + var separatedScore:String = Std.string(combo).addZeros(3); + + + if (combo == 0 || combo >= 10) { + comboGroup.add(comboSpr); + for (i in 0...separatedScore.length) + { + var numScore:FlxSprite = comboGroup.recycle(FlxSprite).loadAnimatedGraphic(Paths.image('${event.ratingPrefix}num${separatedScore.charAt(i)}${event.ratingSuffix}')); + numScore.resetSprite((43 * i) - 90, 80); + comboGroup.remove(numScore, true); + numScore.antialiasing = event.numAntialiasing; + numScore.scale.set(event.numScale, event.numScale); + numScore.updateHitbox(); + + numScore.acceleration.y = FlxG.random.int(200, 300); + numScore.velocity.y -= FlxG.random.int(140, 160); + numScore.velocity.x = FlxG.random.float(-5, 5); + + comboGroup.add(numScore); + + FlxTween.tween(numScore, {alpha: 0}, 0.2, { + onComplete: function(tween:FlxTween) + { + numScore.exists = false; + }, + startDelay: Conductor.crochet * 0.002 + }); + } + } + comboGroup.add(rating); + + FlxTween.tween(rating, {alpha: 0}, 0.2, { + startDelay: Conductor.crochet * 0.001 + }); + + FlxTween.tween(comboSpr, {alpha: 0}, 0.2, { + onComplete: function(tween:FlxTween) + { + rating.exists = false; + comboSpr.exists = false; + }, + startDelay: Conductor.crochet * 0.001 + }); + + ratingNum += 1; + } + + health += event.healthGain; + + if (!event.animCancelled) + for(char in event.characters) + if (char != null) + char.playSingAnim(event.direction, event.animSuffix); + + (event.player ? playerStrums : cpuStrums).forEach(function(str:Strum) { + if (str.ID == Math.abs(note.strumID)) { + if (!event.strumGlowCancelled) str.press(note.strumTime); + if (event.showSplash) splashHandler.showSplash(note.splash, str); + } + }); + } + + if (event.unmuteVocals) vocals.volume = 1; + if (event.enableCamZooming) camZooming = true; + if (event.autoHitLastSustain) { + if (note.nextSustain != null && note.nextSustain.nextSustain == null) { + // its a tail!! + note.wasGoodHit = true; + } + } + + if (event.deleteNote && !note.isSustainNote) deleteNote(note); } public function deleteNote(note:Note) { @@ -1673,7 +1672,7 @@ class PlayState extends MusicBeatState override function beatHit(curBeat:Int) { super.beatHit(curBeat); - + if (camZoomingInterval < 1) camZoomingInterval = 1; if (Options.camZoomOnBeat && camZooming && FlxG.camera.zoom < maxCamZoom && curBeat % camZoomingInterval == 0) { @@ -1689,7 +1688,7 @@ class PlayState extends MusicBeatState if (gf != null && curBeat % gfSpeed == 0) gf.tryDance(); - + scripts.call("beatHit", [curBeat]); } } diff --git a/source/funkin/menus/MainMenuState.hx b/source/funkin/menus/MainMenuState.hx index aca87a4c..da930d40 100644 --- a/source/funkin/menus/MainMenuState.hx +++ b/source/funkin/menus/MainMenuState.hx @@ -201,7 +201,9 @@ class MainMenuState extends MusicBeatState if (spr.ID == curSelected) { spr.animation.play('selected'); - camFollow.setPosition(spr.getGraphicMidpoint().x, spr.getGraphicMidpoint().y); + var mid = spr.getGraphicMidpoint(); + camFollow.setPosition(mid.x, mid.y); + mid.put(); } spr.updateHitbox(); diff --git a/source/funkin/menus/PauseSubState.hx b/source/funkin/menus/PauseSubState.hx index c8c3e129..7e7ba820 100644 --- a/source/funkin/menus/PauseSubState.hx +++ b/source/funkin/menus/PauseSubState.hx @@ -58,7 +58,9 @@ class PauseSubState extends MusicBeatSubstate if (__cancelDefault = event.cancelled) return; - var bg:FlxSprite = new FlxSprite().makeGraphic(FlxG.width, FlxG.height, FlxColor.BLACK); + var bg:FlxSprite = new FlxSprite().makeGraphic(1, 1, FlxColor.BLACK); + bg.scale.set(FlxG.width, FlxG.height); + bg.updateHitbox(); bg.alpha = 0; bg.scrollFactor.set(); add(bg); diff --git a/source/funkin/multitasking/StateWindow.hx b/source/funkin/multitasking/StateWindow.hx index a4d199e5..82b49fc6 100644 --- a/source/funkin/multitasking/StateWindow.hx +++ b/source/funkin/multitasking/StateWindow.hx @@ -54,7 +54,7 @@ class StateWindow extends Sprite { } - var oldSize = FlxPoint.get(FlxG.width, FlxG.height); + var oldSize = new FlxPoint(FlxG.width, FlxG.height); var oldCamList:Array; var oldCamDefaults:Array; var oldCam:FlxCamera; diff --git a/source/funkin/scripting/Script.hx b/source/funkin/scripting/Script.hx index ee5491ac..9a39a702 100644 --- a/source/funkin/scripting/Script.hx +++ b/source/funkin/scripting/Script.hx @@ -24,12 +24,12 @@ class Script extends FlxBasic implements IFlxDestroyable { "Math" => Math, "StringTools" => StringTools, "Json" => haxe.Json, - + // OpenFL & Lime related stuff "Assets" => openfl.utils.Assets, "Application" => lime.app.Application, "window" => lime.app.Application.current.window, - + // Flixel related stuff "FlxG" => flixel.FlxG, "FlxSprite" => flixel.FlxSprite, @@ -49,7 +49,8 @@ class Script extends FlxBasic implements IFlxDestroyable { "FlxTimer" => flixel.util.FlxTimer, "FlxPoint" => CoolUtil.getMacroAbstractClass("flixel.math.FlxPoint"), "FlxAxes" => CoolUtil.getMacroAbstractClass("flixel.util.FlxAxes"), - + "FlxColor" => CoolUtil.getMacroAbstractClass("flixel.util.FlxColor"), + // Engine related stuff "engine" => { build: funkin.macros.BuildCounterMacro.getBuildNumber(), @@ -97,10 +98,13 @@ class Script extends FlxBasic implements IFlxDestroyable { "hl" => #if hl true #else false #end, "neko" => #if neko true #else false #end, "linux" => #if linux true #else false #end, + "mac" => #if mac true #else false #end, "macos" => #if macos true #else false #end, "android" => #if android true #else false #end, "web" => #if web true #else false #end, "debug" => #if debug true #else false #end, + "release" => #if release true #else false #end, + "final" => #if final true #else false #end, "MOD_SUPPORT" => #if MOD_SUPPORT true #else false #end, "GLOBAL_SCRIPT" => #if GLOBAL_SCRIPT true #else false #end, "SOFTCODED_STATES" => #if SOFTCODED_STATES true #else false #end, diff --git a/source/funkin/system/AudioSwitchFix.hx b/source/funkin/system/AudioSwitchFix.hx index f08e1564..7e64a7f7 100644 --- a/source/funkin/system/AudioSwitchFix.hx +++ b/source/funkin/system/AudioSwitchFix.hx @@ -8,7 +8,7 @@ import flixel.FlxG; /** * if youre stealing this keep this comment at least please lol - * + * * hi gray itsa me yoshicrafter29 i fixed it hehe */ @:dox(hide) @@ -30,9 +30,9 @@ class AudioSwitchFix { } if (FlxG.sound.music != null) FlxG.sound.music.stop(); - - AudioManager.shutdown(); - AudioManager.init(); + + AudioManager.shutdown(); + AudioManager.init(); // #if !lime_doc_gen // if (AudioManager.context.type == OPENAL) // { @@ -45,7 +45,7 @@ class AudioSwitchFix { // } // #end Main.changeID++; - + for(e in playingList) { e.sound.play(e.time); } @@ -55,12 +55,12 @@ class AudioSwitchFix { #end } - public static function init() { - #if windows + public static function init() { + #if windows WindowsAPI.registerAudio(); - FlxG.signals.preStateCreate.add(onStateSwitch); - #end - } + FlxG.signals.preStateCreate.add(onStateSwitch); + #end + } } typedef PlayingSound = { diff --git a/source/funkin/system/FlxAnimate.hx b/source/funkin/system/FlxAnimate.hx index c89b79cf..99ee5353 100644 --- a/source/funkin/system/FlxAnimate.hx +++ b/source/funkin/system/FlxAnimate.hx @@ -9,73 +9,74 @@ import flixel.graphics.frames.FlxFrame; import flixel.math.FlxPoint; import flixel.FlxG; import flixel.FlxCamera; +import flixel.FlxBasic; class FlxAnimate extends flxanimate.FlxAnimate { - override function drawLimb(limb:FlxFrame, _matrix:FlxMatrix, ?colorTransform:ColorTransform) - { - if (alpha == 0 || colorTransform != null && (colorTransform.alphaMultiplier == 0 || colorTransform.alphaOffset == -255) || limb == null || limb.type == EMPTY) - return; - var matrix = new FlxMatrix(); - matrix.concat(_matrix); - for (camera in cameras) - { - if (!camera.visible || !camera.exists || !limbOnScreen(limb, _matrix, camera)) - return; - - getScreenPosition(_point, camera).subtractPoint(offset); - matrix.translate(-origin.x, -origin.y); - if (limb.name != "pivot") { - if (rotOffsetAngle != null && rotOffsetAngle != angle) - { - var angleOff = (-angle + rotOffsetAngle) * FlxAngle.TO_RAD; - matrix.rotate(-angleOff); - if (useOffsetAsRotOffset) - matrix.translate(-offset.x, -offset.y); - else - matrix.translate(-rotOffset.x, -rotOffset.y); - matrix.rotate(angleOff); - } - else - { - if (useOffsetAsRotOffset) - matrix.translate(-offset.x, -offset.y); - else - matrix.translate(-rotOffset.x, -rotOffset.y); - } - matrix.scale(scale.x, scale.y); - - if (bakedRotationAngle <= 0) - { - updateTrig(); - - if (angle != 0) - matrix.rotateWithTrig(_cosAngle, _sinAngle); - } - } - else - matrix.a = matrix.d = 0.7 / camera.zoom; - _point.addPoint(origin); - if (isPixelPerfectRender(camera)) - { - _point.floor(); - } - - matrix.translate(_point.x, _point.y); - camera.drawPixels(limb, null, matrix, colorTransform, blend, antialiasing); - #if FLX_DEBUG - FlxBasic.visibleCount++; - #end - } - - #if FLX_DEBUG - if (FlxG.debugger.drawDebug) - drawDebug(); - #end - } - - override function limbOnScreen(limb:FlxFrame, m:FlxMatrix, ?Camera:FlxCamera) + override function drawLimb(limb:FlxFrame, _matrix:FlxMatrix, ?colorTransform:ColorTransform) { - // TODO: ACTUAL OPTIMISATION + if (alpha == 0 || colorTransform != null && (colorTransform.alphaMultiplier == 0 || colorTransform.alphaOffset == -255) || limb == null || limb.type == EMPTY) + return; + var matrix = new FlxMatrix(); + matrix.concat(_matrix); + for (camera in cameras) + { + if (!camera.visible || !camera.exists || !limbOnScreen(limb, _matrix, camera)) + return; + + getScreenPosition(_point, camera).subtractPoint(offset); + matrix.translate(-origin.x, -origin.y); + if (limb.name != "pivot") { + if (rotOffsetAngle != null && rotOffsetAngle != angle) + { + var angleOff = (-angle + rotOffsetAngle) * FlxAngle.TO_RAD; + matrix.rotate(-angleOff); + if (useOffsetAsRotOffset) + matrix.translate(-offset.x, -offset.y); + else + matrix.translate(-rotOffset.x, -rotOffset.y); + matrix.rotate(angleOff); + } + else + { + if (useOffsetAsRotOffset) + matrix.translate(-offset.x, -offset.y); + else + matrix.translate(-rotOffset.x, -rotOffset.y); + } + matrix.scale(scale.x, scale.y); + + if (bakedRotationAngle <= 0) + { + updateTrig(); + + if (angle != 0) + matrix.rotateWithTrig(_cosAngle, _sinAngle); + } + } + else + matrix.a = matrix.d = 0.7 / camera.zoom; + _point.addPoint(origin); + if (isPixelPerfectRender(camera)) + { + _point.floor(); + } + + matrix.translate(_point.x, _point.y); + camera.drawPixels(limb, null, matrix, colorTransform, blend, antialiasing); + #if FLX_DEBUG + FlxBasic.visibleCount++; + #end + } + + #if FLX_DEBUG + if (FlxG.debugger.drawDebug) + drawDebug(); + #end + } + + override function limbOnScreen(limb:FlxFrame, m:FlxMatrix, ?Camera:FlxCamera) + { + // TODO: ACTUAL OPTIMISATION return true; } } \ No newline at end of file diff --git a/source/funkin/system/Main.hx b/source/funkin/system/Main.hx index c9752906..7da031bd 100644 --- a/source/funkin/system/Main.hx +++ b/source/funkin/system/Main.hx @@ -38,7 +38,7 @@ import funkin.mods.ModsFolder; class Main extends Sprite { public static var instance:Main; - + var gameWidth:Int = 1280; // Width of the game in pixels (might be less / more in actual pixels depending on your zoom). var gameHeight:Int = 720; // Height of the game in pixels (might be less / more in actual pixels depending on your zoom). var zoom:Float = -1; // If -1, zoom is automatically calculated to fit the window dimensions. @@ -102,7 +102,7 @@ class Main extends Sprite loadGameSettings(); // FlxG.switchState(new TitleState()); FlxG.switchState(new funkin.menus.BetaWarningState()); - + #if !mobile addChild(new FramerateField(10, 3, 0xFFFFFF)); #end @@ -110,10 +110,10 @@ class Main extends Sprite @:dox(hide) public static var audioDisconnected:Bool = false; - + public static var changeID:Int = 0; - + private static var __threadCycle:Int = 0; public static function execAsync(func:Void->Void) { #if ALLOW_MULTITHREADING @@ -152,18 +152,32 @@ class Main extends Sprite #if GLOBAL_SCRIPT funkin.scripting.GlobalScript.init(); #end - + #if sys if (Sys.args().contains("-livereload")) { + var pathBack = #if windows + "../../../../" + #elseif mac + "../../../../../../../" + #else + "" + #end; + #if USE_SOURCE_ASSETS + #if windows trace("Used lime test windows. Switching into source assets."); - Paths.assetsTree.addLibrary(ModsFolder.loadLibraryFromFolder('assets', './../../../../assets/', true)); + #elseif mac + trace("Used lime test mac. Switching into source assets."); + #elseif linux + trace("Used lime test linux. Switching into source assets."); + #end + Paths.assetsTree.addLibrary(ModsFolder.loadLibraryFromFolder('assets', './${pathBack}assets/', true)); Paths.assetsTree.sourceLibsAmount++; #end - var buildNum:Int = Std.parseInt(File.getContent("./../../../../buildnumber.txt")); + var buildNum:Int = Std.parseInt(File.getContent('./${pathBack}buildnumber.txt')); buildNum++; - File.saveContent("./../../../../buildnumber.txt", Std.string(buildNum)); + File.saveContent('./${pathBack}buildnumber.txt', Std.string(buildNum)); } else { #if USE_ADAPTED_ASSETS Paths.assetsTree.addLibrary(ModsFolder.loadLibraryFromFolder('assets', './assets/', true)); @@ -218,20 +232,20 @@ class Main extends Sprite {asset: diamond, width: 32, height: 32}, new FlxRect(-200, -200, FlxG.width * 1.4, FlxG.height * 1.4)); } - private static function onStateSwitch(newState:FlxState) { - // manual asset clearing since base openfl one doesnt clear lime one - // doesnt clear bitmaps since flixel fork does it auto - - var cache = cast(Assets.cache, AssetCache); - for (key=>font in cache.font) - cache.removeFont(key); - for (key=>sound in cache.sound) - cache.removeSound(key); + private static function onStateSwitch(newState:FlxState) { + // manual asset clearing since base openfl one doesnt clear lime one + // doesnt clear bitmaps since flixel fork does it auto + + var cache = cast(Assets.cache, AssetCache); + for (key=>font in cache.font) + cache.removeFont(key); + for (key=>sound in cache.sound) + cache.removeSound(key); Paths.assetsTree.clearCache(); #if cpp cpp.vm.Gc.run(true); #end - } + } } diff --git a/source/funkin/system/Section.hx b/source/funkin/system/Section.hx index b57400c5..73f0ba93 100644 --- a/source/funkin/system/Section.hx +++ b/source/funkin/system/Section.hx @@ -4,29 +4,9 @@ typedef SwagSection = { var sectionNotes:Array; var lengthInSteps:Int; - var typeOfSection:Int; var mustHitSection:Bool; var bpm:Float; var changeBPM:Bool; var altAnim:Bool; @:optional var camTarget:Null; -} - -class Section -{ - public var sectionNotes:Array = []; - - public var lengthInSteps:Int = 16; - public var typeOfSection:Int = 0; - public var mustHitSection:Bool = true; - - /** - * Copies the first section into the second section! - */ - public static var COPYCAT:Int = 0; - - public function new(lengthInSteps:Int = 16) - { - this.lengthInSteps = lengthInSteps; - } -} +} \ No newline at end of file