From 853820c56b2f31d5775b587afe639e991f096aaf Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Mon, 30 May 2022 23:59:12 -0400 Subject: [PATCH 01/25] animation timing fixes --- source/funkin/play/character/BaseCharacter.hx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/source/funkin/play/character/BaseCharacter.hx b/source/funkin/play/character/BaseCharacter.hx index 3f038e294..22b95bc06 100644 --- a/source/funkin/play/character/BaseCharacter.hx +++ b/source/funkin/play/character/BaseCharacter.hx @@ -207,7 +207,7 @@ class BaseCharacter extends Bopper super.onUpdate(event); // Reset hold timer for each note pressed. - if (justPressedNote()) + if (justPressedNote() && this.characterType == BF) { holdTimer = 0; } @@ -233,12 +233,16 @@ class BaseCharacter extends Bopper { holdTimer += event.elapsed; var singTimeMs:Float = singTimeCrochet * (Conductor.crochet * 0.001); // x beats, to ms. + + if (getCurrentAnimation().endsWith("miss")) + singTimeMs *= 2; // makes it feel more awkward when you miss + // Without this check here, the player character would only play the `sing` animation // for one beat, as opposed to holding it as long as the player is holding the button. var shouldStopSinging:Bool = (this.characterType == BF) ? !isHoldingNote() : true; FlxG.watch.addQuick('singTimeMs-${characterId}', singTimeMs); - if (holdTimer > singTimeMs && shouldStopSinging && !getCurrentAnimation().endsWith("miss")) + if (holdTimer > singTimeMs && shouldStopSinging) { trace(getCurrentAnimation()); // trace('holdTimer reached ${holdTimer}sec (> ${singTimeMs}), stopping sing animation'); @@ -358,17 +362,17 @@ class BaseCharacter extends Bopper { super.onNoteHit(event); - holdTimer = 0; - if (event.note.mustPress && characterType == BF) { // If the note is from the same strumline, play the sing animation. this.playSingAnimation(event.note.data.dir, false, event.note.data.altNote); + holdTimer = 0; } else if (!event.note.mustPress && characterType == DAD) { // If the note is from the same strumline, play the sing animation. this.playSingAnimation(event.note.data.dir, false, event.note.data.altNote); + holdTimer = 0; } } From 3f84a5514f4523b17ed8a46ebec28a5cb044e13d Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Thu, 9 Jun 2022 02:27:20 -0400 Subject: [PATCH 02/25] POV i learning how macros work --- source/funkin/util/Constants.hx | 3 ++- source/funkin/util/macro/GitCommit.hx | 26 ++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/source/funkin/util/Constants.hx b/source/funkin/util/Constants.hx index a93578c20..c8df8f3d2 100644 --- a/source/funkin/util/Constants.hx +++ b/source/funkin/util/Constants.hx @@ -22,10 +22,11 @@ class Constants #if debug public static final GIT_HASH = funkin.util.macro.GitCommit.getGitCommitHash(); + public static final GIT_BRANCH = funkin.util.macro.GitCommit.getGitBranch(); static function get_VERSION():String { - return 'v${Application.current.meta.get('version')} (${GIT_HASH})' + VERSION_SUFFIX; + return 'v${Application.current.meta.get('version')} (${GIT_BRANCH} : ${GIT_HASH})' + VERSION_SUFFIX; } #else static function get_VERSION():String diff --git a/source/funkin/util/macro/GitCommit.hx b/source/funkin/util/macro/GitCommit.hx index 14c68639a..35700e2f2 100644 --- a/source/funkin/util/macro/GitCommit.hx +++ b/source/funkin/util/macro/GitCommit.hx @@ -31,5 +31,31 @@ class GitCommit return macro $v{commitHashSplice}; #end } + + public static macro function getGitBranch():haxe.macro.Expr.ExprOf + { + #if !display + // Get the current line number. + var pos = haxe.macro.Context.currentPos(); + var branchProcess = new sys.io.Process('git', ['rev-parse', '--abbrev-ref', 'HEAD']); + + if (branchProcess.exitCode() != 0) + { + var message = branchProcess.stderr.readAll().toString(); + haxe.macro.Context.info('[WARN] Could not determine current git commit; is this a proper Git repository?', pos); + } + + var branchName:String = branchProcess.stdout.readLine(); + trace('Current Working Branch: ${branchName}'); + + // Generates a string expression + return macro $v{branchName}; + #else + // `#if display` is used for code completion. In this case returning an + // empty string is good enough; We don't want to call git on every hint. + var branchName:String = ""; + return macro $v{branchName}; + #end + } } #end From b5d85c3fd622629af112dd21992ace0074335f41 Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Tue, 5 Jul 2022 14:24:02 -0400 Subject: [PATCH 03/25] latency stuff in progress maybe? --- source/funkin/InitState.hx | 6 ++---- source/funkin/LatencyState.hx | 24 +++++++++++++++++++++--- source/funkin/MusicBeatSubstate.hx | 2 +- 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/source/funkin/InitState.hx b/source/funkin/InitState.hx index bfde8c327..07dcd2afb 100644 --- a/source/funkin/InitState.hx +++ b/source/funkin/InitState.hx @@ -179,11 +179,9 @@ class InitState extends FlxTransitionableState #elseif FIGHT FlxG.switchState(new PicoFight()); #elseif ANIMDEBUG -<<<<<<< HEAD FlxG.switchState(new funkin.ui.animDebugShit.DebugBoundingState()); -======= - FlxG.switchState(new DebugBoundingState()); ->>>>>>> origin/feature/scripted-modules + #elseif LATENCY + FlxG.switchState(new LatencyState()); #elseif NETTEST FlxG.switchState(new netTest.NetTest()); #else diff --git a/source/funkin/LatencyState.hx b/source/funkin/LatencyState.hx index 0239bea53..b7e559beb 100644 --- a/source/funkin/LatencyState.hx +++ b/source/funkin/LatencyState.hx @@ -1,16 +1,18 @@ package funkin; import flixel.FlxSprite; -import flixel.FlxState; +import flixel.FlxSubState; import flixel.group.FlxGroup.FlxTypedGroup; import flixel.text.FlxText; -class LatencyState extends FlxState +class LatencyState extends MusicBeatSubstate { var offsetText:FlxText; var noteGrp:FlxTypedGroup; var strumLine:FlxSprite; + var block:FlxSprite; + override function create() { FlxG.sound.playMusic(Paths.sound('soundTest')); @@ -18,6 +20,9 @@ class LatencyState extends FlxState noteGrp = new FlxTypedGroup(); add(noteGrp); + block = new FlxSprite().makeGraphic(100, 100); + add(block); + for (i in 0...32) { var note:Note = new Note(Conductor.crochet * i, 1); @@ -36,6 +41,13 @@ class LatencyState extends FlxState super.create(); } + override function beatHit() + { + block.visible = !block.visible; + + super.beatHit(); + } + override function update(elapsed:Float) { offsetText.text = "Offset: " + Conductor.offset + "ms"; @@ -65,7 +77,13 @@ class LatencyState extends FlxState daNote.x = strumLine.x + 30; if (daNote.y < strumLine.y) - daNote.kill(); + daNote.alpha = 0.5; + + if (daNote.y < 0 - daNote.height) + { + daNote.alpha = 1; + // daNote.data.strumTime += Conductor.crochet * 8; + } }); super.update(elapsed); diff --git a/source/funkin/MusicBeatSubstate.hx b/source/funkin/MusicBeatSubstate.hx index db20bce34..001f8d420 100644 --- a/source/funkin/MusicBeatSubstate.hx +++ b/source/funkin/MusicBeatSubstate.hx @@ -45,7 +45,7 @@ class MusicBeatSubstate extends FlxSubState } for (i in 0...Conductor.bpmChangeMap.length) { - if (Conductor.songPosition > Conductor.bpmChangeMap[i].songTime) + if (Conductor.songPosition - Conductor.offset > Conductor.bpmChangeMap[i].songTime) lastChange = Conductor.bpmChangeMap[i]; } From 9cf2598951aa5f509c1d5a6de93e33744f3bd28e Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Tue, 5 Jul 2022 14:34:08 -0400 Subject: [PATCH 04/25] spectogram placeholder --- source/funkin/LatencyState.hx | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/source/funkin/LatencyState.hx b/source/funkin/LatencyState.hx index b7e559beb..c5a91c9c7 100644 --- a/source/funkin/LatencyState.hx +++ b/source/funkin/LatencyState.hx @@ -4,6 +4,8 @@ import flixel.FlxSprite; import flixel.FlxSubState; import flixel.group.FlxGroup.FlxTypedGroup; import flixel.text.FlxText; +import flixel.util.FlxColor; +import funkin.audiovis.PolygonSpectogram; class LatencyState extends MusicBeatSubstate { @@ -20,6 +22,14 @@ class LatencyState extends MusicBeatSubstate noteGrp = new FlxTypedGroup(); add(noteGrp); + var musSpec:PolygonSpectogram = new PolygonSpectogram(FlxG.sound.music, FlxColor.RED, FlxG.height, Math.floor(FlxG.height / 2)); + musSpec.x += 170; + musSpec.scrollFactor.set(); + musSpec.waveAmplitude = 50; + musSpec.realtimeVisLenght = 0.6; + // musSpec.visType = FREQUENCIES; + add(musSpec); + block = new FlxSprite().makeGraphic(100, 100); add(block); From 53d703cfcdca91a41299246554081eb0aa9bb299 Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Tue, 5 Jul 2022 14:36:01 -0400 Subject: [PATCH 05/25] spectogram tweakin hehe --- source/funkin/LatencyState.hx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/funkin/LatencyState.hx b/source/funkin/LatencyState.hx index c5a91c9c7..9a9df4768 100644 --- a/source/funkin/LatencyState.hx +++ b/source/funkin/LatencyState.hx @@ -25,8 +25,8 @@ class LatencyState extends MusicBeatSubstate var musSpec:PolygonSpectogram = new PolygonSpectogram(FlxG.sound.music, FlxColor.RED, FlxG.height, Math.floor(FlxG.height / 2)); musSpec.x += 170; musSpec.scrollFactor.set(); - musSpec.waveAmplitude = 50; - musSpec.realtimeVisLenght = 0.6; + musSpec.waveAmplitude = 100; + musSpec.realtimeVisLenght = 0.45; // musSpec.visType = FREQUENCIES; add(musSpec); From 9712af9f62cb60ff0cf6f4d5ec1142aaae82df5c Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Wed, 6 Jul 2022 11:51:44 -0400 Subject: [PATCH 06/25] daily builds instead of push'd (12:30PM EST / 5:30UTC) --- .github/workflows/build-shit.yml | 55 ++++++++++++++++++++++---------- 1 file changed, 39 insertions(+), 16 deletions(-) diff --git a/.github/workflows/build-shit.yml b/.github/workflows/build-shit.yml index abbacc7d3..16c6e4aa7 100644 --- a/.github/workflows/build-shit.yml +++ b/.github/workflows/build-shit.yml @@ -1,21 +1,41 @@ name: build-upload -on: [push, workflow_dispatch] +on: + schedule: + - cron: '30 17 * * *' jobs: + check_date: + runs-on: ubuntu-latest + name: Check latest commit + outputs: + should_run: ${{ steps.should_run.outputs.should_run }} + steps: + - uses: actions/checkout@v2 + - name: print latest_commit + run: echo ${{ github.sha }} + - id: should_run + continue-on-error: true + name: check latest commit is less than a day + if: ${{ github.event_name == 'schedule' }} + run: test -z $(git rev-list --after="24 hours" ${{ github.sha }}) && echo "::set-output name=should_run::false" create-nightly-html5: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: ./.github/actions/setup-haxeshit - - name: Build game? - run: | - haxelib run lime build html5 -debug - ls - - uses: ./.github/actions/upload-itch - with: - butler-key: ${{ secrets.BUTLER_API_KEY}} - build-dir: export/debug/html5/bin - target: html5 + needs: check_date + if: ${{ needs.check_date.outputs.should_run != 'false'}} + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: ./.github/actions/setup-haxeshit + - name: Build game? + run: | + haxelib run lime build html5 -debug + ls + - uses: ./.github/actions/upload-itch + with: + butler-key: ${{ secrets.BUTLER_API_KEY}} + build-dir: export/debug/html5/bin + target: html5 create-nightly-win: + needs: check_date + if: ${{ needs.check_date.outputs.should_run != 'false'}} runs-on: windows-latest steps: - uses: actions/checkout@v3 @@ -30,6 +50,8 @@ jobs: build-dir: export/debug/windows/bin target: win create-nightly-mac: + needs: check_date + if: ${{ needs.check_date.outputs.should_run != 'false'}} runs-on: macos-latest steps: - uses: actions/checkout@v3 @@ -44,6 +66,8 @@ jobs: build-dir: export/debug/macos/bin target: mac create-nightly-linux: + needs: check_date + if: ${{ needs.check_date.outputs.should_run != 'false'}} runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -59,5 +83,4 @@ jobs: with: butler-key: ${{ secrets.BUTLER_API_KEY}} build-dir: export/debug/linux/bin - target: linux - + target: linux \ No newline at end of file From f797f6a7b1f795eb667cff8af80db343e2973b27 Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Wed, 6 Jul 2022 15:27:45 -0400 Subject: [PATCH 07/25] music debug stuff in progress --- source/funkin/Conductor.hx | 2 + source/funkin/LatencyState.hx | 86 +++++++++++++++++++++++------- source/funkin/MusicBeatSubstate.hx | 4 +- 3 files changed, 72 insertions(+), 20 deletions(-) diff --git a/source/funkin/Conductor.hx b/source/funkin/Conductor.hx index 331dd46f7..0337a479e 100644 --- a/source/funkin/Conductor.hx +++ b/source/funkin/Conductor.hx @@ -42,6 +42,8 @@ class Conductor public static var songPosition:Float; public static var lastSongPos:Float; + public static var visualOffset:Float = 0; + public static var audioOffset:Float = 0; public static var offset:Float = 0; public static var bpmChangeMap:Array = []; diff --git a/source/funkin/LatencyState.hx b/source/funkin/LatencyState.hx index 9a9df4768..33855321e 100644 --- a/source/funkin/LatencyState.hx +++ b/source/funkin/LatencyState.hx @@ -3,6 +3,8 @@ package funkin; import flixel.FlxSprite; import flixel.FlxSubState; import flixel.group.FlxGroup.FlxTypedGroup; +import flixel.group.FlxGroup; +import flixel.math.FlxMath; import flixel.text.FlxText; import flixel.util.FlxColor; import funkin.audiovis.PolygonSpectogram; @@ -13,25 +15,52 @@ class LatencyState extends MusicBeatSubstate var noteGrp:FlxTypedGroup; var strumLine:FlxSprite; - var block:FlxSprite; + var blocks:FlxGroup; + + var songPosVis:FlxSprite; + + var beatTrail:FlxSprite; override function create() { FlxG.sound.playMusic(Paths.sound('soundTest')); + Conductor.bpm = 120; noteGrp = new FlxTypedGroup(); add(noteGrp); - var musSpec:PolygonSpectogram = new PolygonSpectogram(FlxG.sound.music, FlxColor.RED, FlxG.height, Math.floor(FlxG.height / 2)); - musSpec.x += 170; - musSpec.scrollFactor.set(); - musSpec.waveAmplitude = 100; - musSpec.realtimeVisLenght = 0.45; - // musSpec.visType = FREQUENCIES; - add(musSpec); + // var musSpec:PolygonSpectogram = new PolygonSpectogram(FlxG.sound.music, FlxColor.RED, FlxG.height, Math.floor(FlxG.height / 2)); + // musSpec.x += 170; + // musSpec.scrollFactor.set(); + // musSpec.waveAmplitude = 100; + // musSpec.realtimeVisLenght = 0.45; + // // musSpec.visType = FREQUENCIES; + // add(musSpec); - block = new FlxSprite().makeGraphic(100, 100); - add(block); + for (beat in 0...Math.floor(FlxG.sound.music.length / Conductor.crochet)) + { + var beatTick:FlxSprite = new FlxSprite(songPosToX(beat * Conductor.crochet), FlxG.height - 15); + beatTick.makeGraphic(2, 15); + beatTick.alpha = 0.3; + add(beatTick); + } + + songPosVis = new FlxSprite(0, FlxG.height - 20).makeGraphic(2, 20, FlxColor.RED); + add(songPosVis); + + beatTrail = new FlxSprite(0, songPosVis.y).makeGraphic(2, 20, FlxColor.PURPLE); + beatTrail.alpha = 0.7; + add(beatTrail); + + blocks = new FlxGroup(); + add(blocks); + + for (i in 0...8) + { + var block = new FlxSprite(2, 50 * i).makeGraphic(48, 48); + block.visible = false; + blocks.add(block); + } for (i in 0...32) { @@ -46,33 +75,49 @@ class LatencyState extends MusicBeatSubstate strumLine = new FlxSprite(FlxG.width / 2, 100).makeGraphic(FlxG.width, 5); add(strumLine); - Conductor.bpm = 120; - super.create(); } override function beatHit() { - block.visible = !block.visible; + beatTrail.x = songPosVis.x; + + if (curBeat % 8 == 0) + blocks.forEach(blok -> + { + blok.visible = false; + }); + + blocks.members[curBeat % 8].visible = true; + // block.visible = !block.visible; super.beatHit(); } override function update(elapsed:Float) { - offsetText.text = "Offset: " + Conductor.offset + "ms"; + songPosVis.x = songPosToX(Conductor.songPosition); + + offsetText.text = "Offset: " + Conductor.visualOffset + "ms"; + offsetText.text += "\ncurStep: " + curStep; + offsetText.text += "\ncurBeat: " + curBeat; Conductor.songPosition = FlxG.sound.music.time - Conductor.offset; - var multiply:Float = 1; + var multiply:Float = 10; if (FlxG.keys.pressed.SHIFT) - multiply = 10; + multiply = 1; if (FlxG.keys.justPressed.RIGHT) - Conductor.offset += 1 * multiply; + { + Conductor.visualOffset += 1 * multiply; + } + if (FlxG.keys.justPressed.LEFT) - Conductor.offset -= 1 * multiply; + { + Conductor.visualOffset -= 1 * multiply; + } if (FlxG.keys.justPressed.SPACE) { @@ -98,4 +143,9 @@ class LatencyState extends MusicBeatSubstate super.update(elapsed); } + + function songPosToX(pos:Float):Float + { + return FlxMath.remapToRange(pos, 0, FlxG.sound.music.length, 0, FlxG.width); + } } diff --git a/source/funkin/MusicBeatSubstate.hx b/source/funkin/MusicBeatSubstate.hx index 001f8d420..1f8090725 100644 --- a/source/funkin/MusicBeatSubstate.hx +++ b/source/funkin/MusicBeatSubstate.hx @@ -45,11 +45,11 @@ class MusicBeatSubstate extends FlxSubState } for (i in 0...Conductor.bpmChangeMap.length) { - if (Conductor.songPosition - Conductor.offset > Conductor.bpmChangeMap[i].songTime) + if (Conductor.songPosition > Conductor.bpmChangeMap[i].songTime) lastChange = Conductor.bpmChangeMap[i]; } - curStep = lastChange.stepTime + Math.floor((Conductor.songPosition - lastChange.songTime) / Conductor.stepCrochet); + curStep = lastChange.stepTime + Math.floor(((Conductor.songPosition - Conductor.visualOffset) - lastChange.songTime) / Conductor.stepCrochet); } public function stepHit():Void From 1c1974bae5e41a3aa04ff608b75e873725ebc16f Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Wed, 6 Jul 2022 18:45:27 -0400 Subject: [PATCH 08/25] better beat visualizations --- source/funkin/LatencyState.hx | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/source/funkin/LatencyState.hx b/source/funkin/LatencyState.hx index 33855321e..9760e4b2d 100644 --- a/source/funkin/LatencyState.hx +++ b/source/funkin/LatencyState.hx @@ -18,6 +18,7 @@ class LatencyState extends MusicBeatSubstate var blocks:FlxGroup; var songPosVis:FlxSprite; + var songVisFollow:FlxSprite; var beatTrail:FlxSprite; @@ -45,6 +46,9 @@ class LatencyState extends MusicBeatSubstate add(beatTick); } + songVisFollow = new FlxSprite(0, FlxG.height - 20).makeGraphic(2, 20, FlxColor.YELLOW); + add(songVisFollow); + songPosVis = new FlxSprite(0, FlxG.height - 20).makeGraphic(2, 20, FlxColor.RED); add(songPosVis); @@ -96,14 +100,26 @@ class LatencyState extends MusicBeatSubstate override function update(elapsed:Float) { + if (FlxG.keys.justPressed.SPACE) + { + if (FlxG.sound.music.playing) + FlxG.sound.music.pause(); + else + FlxG.sound.music.resume(); + } + + if (FlxG.keys.pressed.D) + FlxG.sound.music.time += 1000 * FlxG.elapsed; + + Conductor.songPosition = FlxG.sound.music.time - Conductor.offset; + songPosVis.x = songPosToX(Conductor.songPosition); + songVisFollow.x = songPosToX(Conductor.songPosition - Conductor.visualOffset); offsetText.text = "Offset: " + Conductor.visualOffset + "ms"; offsetText.text += "\ncurStep: " + curStep; offsetText.text += "\ncurBeat: " + curBeat; - Conductor.songPosition = FlxG.sound.music.time - Conductor.offset; - var multiply:Float = 10; if (FlxG.keys.pressed.SHIFT) @@ -119,12 +135,12 @@ class LatencyState extends MusicBeatSubstate Conductor.visualOffset -= 1 * multiply; } - if (FlxG.keys.justPressed.SPACE) - { - FlxG.sound.music.stop(); + /* if (FlxG.keys.justPressed.SPACE) + { + FlxG.sound.music.stop(); - FlxG.resetState(); - } + FlxG.resetState(); + }*/ noteGrp.forEach(function(daNote:Note) { From 5e630dc214c463ff76db101a8287f91af1023b5f Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Wed, 6 Jul 2022 20:37:35 -0400 Subject: [PATCH 09/25] latency debugging stuff in progress --- source/funkin/LatencyState.hx | 80 ++++++++++++++++++++++++------ source/funkin/MusicBeatSubstate.hx | 2 +- 2 files changed, 67 insertions(+), 15 deletions(-) diff --git a/source/funkin/LatencyState.hx b/source/funkin/LatencyState.hx index 9760e4b2d..b127fb8c6 100644 --- a/source/funkin/LatencyState.hx +++ b/source/funkin/LatencyState.hx @@ -8,6 +8,7 @@ import flixel.math.FlxMath; import flixel.text.FlxText; import flixel.util.FlxColor; import funkin.audiovis.PolygonSpectogram; +import openfl.events.KeyboardEvent; class LatencyState extends MusicBeatSubstate { @@ -18,18 +19,29 @@ class LatencyState extends MusicBeatSubstate var blocks:FlxGroup; var songPosVis:FlxSprite; - var songVisFollow:FlxSprite; + var songVisFollowVideo:FlxSprite; + var songVisFollowAudio:FlxSprite; var beatTrail:FlxSprite; + var diffGrp:FlxTypedGroup; override function create() { + FlxG.stage.addEventListener(KeyboardEvent.KEY_DOWN, key -> + { + trace("EVENT PRESS: " + FlxG.sound.music.time + " " + Sys.time()); + // trace("EVENT LISTENER: " + key); + }); + FlxG.sound.playMusic(Paths.sound('soundTest')); - Conductor.bpm = 120; + Conductor.bpm = 60; noteGrp = new FlxTypedGroup(); add(noteGrp); + diffGrp = new FlxTypedGroup(); + add(diffGrp); + // var musSpec:PolygonSpectogram = new PolygonSpectogram(FlxG.sound.music, FlxColor.RED, FlxG.height, Math.floor(FlxG.height / 2)); // musSpec.x += 170; // musSpec.scrollFactor.set(); @@ -44,10 +56,17 @@ class LatencyState extends MusicBeatSubstate beatTick.makeGraphic(2, 15); beatTick.alpha = 0.3; add(beatTick); + + var offsetTxt:FlxText = new FlxText(songPosToX(beat * Conductor.crochet), FlxG.height - 26, 0, "swag"); + offsetTxt.alpha = 0.5; + diffGrp.add(offsetTxt); } - songVisFollow = new FlxSprite(0, FlxG.height - 20).makeGraphic(2, 20, FlxColor.YELLOW); - add(songVisFollow); + songVisFollowAudio = new FlxSprite(0, FlxG.height - 20).makeGraphic(2, 20, FlxColor.YELLOW); + add(songVisFollowAudio); + + songVisFollowVideo = new FlxSprite(0, FlxG.height - 20).makeGraphic(2, 20, FlxColor.BLUE); + add(songVisFollowVideo); songPosVis = new FlxSprite(0, FlxG.height - 20).makeGraphic(2, 20, FlxColor.RED); add(songPosVis); @@ -84,8 +103,6 @@ class LatencyState extends MusicBeatSubstate override function beatHit() { - beatTrail.x = songPosVis.x; - if (curBeat % 8 == 0) blocks.forEach(blok -> { @@ -100,6 +117,24 @@ class LatencyState extends MusicBeatSubstate override function update(elapsed:Float) { + if (FlxG.keys.justPressed.S) + { + trace("UPDATE PRESS: " + FlxG.sound.music.time + " " + Sys.time()); + } + + if (FlxG.keys.justPressed.X) + { + var closestBeat:Int = Math.round(Conductor.songPosition / Conductor.crochet); + var getDiff:Float = Conductor.songPosition - (closestBeat * Conductor.crochet); + getDiff -= Conductor.visualOffset; + + trace("\tDISTANCE TO CLOSEST BEAT: " + getDiff + "ms"); + trace("\tCLOSEST BEAT: " + closestBeat); + beatTrail.x = songPosVis.x; + if (closestBeat < FlxG.sound.music.length / Conductor.crochet) + diffGrp.members[closestBeat].text = getDiff + "ms"; + } + if (FlxG.keys.justPressed.SPACE) { if (FlxG.sound.music.playing) @@ -114,9 +149,11 @@ class LatencyState extends MusicBeatSubstate Conductor.songPosition = FlxG.sound.music.time - Conductor.offset; songPosVis.x = songPosToX(Conductor.songPosition); - songVisFollow.x = songPosToX(Conductor.songPosition - Conductor.visualOffset); + songVisFollowAudio.x = songPosToX(Conductor.songPosition - Conductor.audioOffset); + songVisFollowVideo.x = songPosToX(Conductor.songPosition - Conductor.visualOffset); - offsetText.text = "Offset: " + Conductor.visualOffset + "ms"; + offsetText.text = "AUDIO Offset: " + Conductor.audioOffset + "ms"; + offsetText.text += "\nVIDOE Offset: " + Conductor.visualOffset + "ms"; offsetText.text += "\ncurStep: " + curStep; offsetText.text += "\ncurBeat: " + curBeat; @@ -125,14 +162,29 @@ class LatencyState extends MusicBeatSubstate if (FlxG.keys.pressed.SHIFT) multiply = 1; - if (FlxG.keys.justPressed.RIGHT) + if (FlxG.keys.pressed.CONTROL) { - Conductor.visualOffset += 1 * multiply; - } + if (FlxG.keys.justPressed.RIGHT) + { + Conductor.audioOffset += 1 * multiply; + } - if (FlxG.keys.justPressed.LEFT) + if (FlxG.keys.justPressed.LEFT) + { + Conductor.audioOffset -= 1 * multiply; + } + } + else { - Conductor.visualOffset -= 1 * multiply; + if (FlxG.keys.justPressed.RIGHT) + { + Conductor.visualOffset += 1 * multiply; + } + + if (FlxG.keys.justPressed.LEFT) + { + Conductor.visualOffset -= 1 * multiply; + } } /* if (FlxG.keys.justPressed.SPACE) @@ -144,7 +196,7 @@ class LatencyState extends MusicBeatSubstate noteGrp.forEach(function(daNote:Note) { - daNote.y = (strumLine.y - (Conductor.songPosition - daNote.data.strumTime) * 0.45); + daNote.y = (strumLine.y - ((Conductor.songPosition - Conductor.audioOffset) - daNote.data.strumTime) * 0.45); daNote.x = strumLine.x + 30; if (daNote.y < strumLine.y) diff --git a/source/funkin/MusicBeatSubstate.hx b/source/funkin/MusicBeatSubstate.hx index 1f8090725..790d8ee90 100644 --- a/source/funkin/MusicBeatSubstate.hx +++ b/source/funkin/MusicBeatSubstate.hx @@ -49,7 +49,7 @@ class MusicBeatSubstate extends FlxSubState lastChange = Conductor.bpmChangeMap[i]; } - curStep = lastChange.stepTime + Math.floor(((Conductor.songPosition - Conductor.visualOffset) - lastChange.songTime) / Conductor.stepCrochet); + curStep = lastChange.stepTime + Math.floor(((Conductor.songPosition - Conductor.audioOffset) - lastChange.songTime) / Conductor.stepCrochet); } public function stepHit():Void From c3995ef5574d84244c723725d0af9a84970838c4 Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Wed, 6 Jul 2022 20:54:07 -0400 Subject: [PATCH 10/25] different timestamping --- source/funkin/LatencyState.hx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/source/funkin/LatencyState.hx b/source/funkin/LatencyState.hx index b127fb8c6..bb6f52869 100644 --- a/source/funkin/LatencyState.hx +++ b/source/funkin/LatencyState.hx @@ -8,6 +8,7 @@ import flixel.math.FlxMath; import flixel.text.FlxText; import flixel.util.FlxColor; import funkin.audiovis.PolygonSpectogram; +import haxe.Timer; import openfl.events.KeyboardEvent; class LatencyState extends MusicBeatSubstate @@ -29,7 +30,7 @@ class LatencyState extends MusicBeatSubstate { FlxG.stage.addEventListener(KeyboardEvent.KEY_DOWN, key -> { - trace("EVENT PRESS: " + FlxG.sound.music.time + " " + Sys.time()); + trace("EVENT PRESS: " + FlxG.sound.music.time + " " + Timer.stamp()); // trace("EVENT LISTENER: " + key); }); @@ -119,7 +120,7 @@ class LatencyState extends MusicBeatSubstate { if (FlxG.keys.justPressed.S) { - trace("UPDATE PRESS: " + FlxG.sound.music.time + " " + Sys.time()); + trace("UPDATE PRESS: " + FlxG.sound.music.time + " " + Timer.stamp()); } if (FlxG.keys.justPressed.X) From 4d3766b65b01889251771c6d5bf172337b2a495f Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Wed, 6 Jul 2022 20:58:13 -0400 Subject: [PATCH 11/25] better traces hehe --- source/funkin/LatencyState.hx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/funkin/LatencyState.hx b/source/funkin/LatencyState.hx index bb6f52869..6de472584 100644 --- a/source/funkin/LatencyState.hx +++ b/source/funkin/LatencyState.hx @@ -30,7 +30,7 @@ class LatencyState extends MusicBeatSubstate { FlxG.stage.addEventListener(KeyboardEvent.KEY_DOWN, key -> { - trace("EVENT PRESS: " + FlxG.sound.music.time + " " + Timer.stamp()); + trace("\tEVENT PRESS: \t" + FlxG.sound.music.time + " " + Timer.stamp()); // trace("EVENT LISTENER: " + key); }); @@ -120,7 +120,7 @@ class LatencyState extends MusicBeatSubstate { if (FlxG.keys.justPressed.S) { - trace("UPDATE PRESS: " + FlxG.sound.music.time + " " + Timer.stamp()); + trace("\tUPDATE PRESS: \t" + FlxG.sound.music.time + " " + Timer.stamp()); } if (FlxG.keys.justPressed.X) From 05858a4f6c1132dcf0c071f418109f686636517b Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Mon, 11 Jul 2022 15:04:41 -0400 Subject: [PATCH 12/25] crash fix when pressing before loop --- source/funkin/LatencyState.hx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/funkin/LatencyState.hx b/source/funkin/LatencyState.hx index 6de472584..79885d1bd 100644 --- a/source/funkin/LatencyState.hx +++ b/source/funkin/LatencyState.hx @@ -125,7 +125,7 @@ class LatencyState extends MusicBeatSubstate if (FlxG.keys.justPressed.X) { - var closestBeat:Int = Math.round(Conductor.songPosition / Conductor.crochet); + var closestBeat:Int = Math.round(Conductor.songPosition / Conductor.crochet) % diffGrp.members.length; var getDiff:Float = Conductor.songPosition - (closestBeat * Conductor.crochet); getDiff -= Conductor.visualOffset; From 5778e979d989547492c900d783b6aa4cebfd290f Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Mon, 11 Jul 2022 15:14:59 -0400 Subject: [PATCH 13/25] lil fix for end number hehe --- source/funkin/LatencyState.hx | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/source/funkin/LatencyState.hx b/source/funkin/LatencyState.hx index 79885d1bd..713601057 100644 --- a/source/funkin/LatencyState.hx +++ b/source/funkin/LatencyState.hx @@ -25,6 +25,7 @@ class LatencyState extends MusicBeatSubstate var beatTrail:FlxSprite; var diffGrp:FlxTypedGroup; + var offsetsPerBeat:Array = []; override function create() { @@ -61,6 +62,8 @@ class LatencyState extends MusicBeatSubstate var offsetTxt:FlxText = new FlxText(songPosToX(beat * Conductor.crochet), FlxG.height - 26, 0, "swag"); offsetTxt.alpha = 0.5; diffGrp.add(offsetTxt); + + offsetsPerBeat.push(0); } songVisFollowAudio = new FlxSprite(0, FlxG.height - 20).makeGraphic(2, 20, FlxColor.YELLOW); @@ -129,11 +132,16 @@ class LatencyState extends MusicBeatSubstate var getDiff:Float = Conductor.songPosition - (closestBeat * Conductor.crochet); getDiff -= Conductor.visualOffset; + // lil fix for end of song + if (closestBeat == 0 && getDiff >= Conductor.crochet * 2) + getDiff -= FlxG.sound.music.length; + trace("\tDISTANCE TO CLOSEST BEAT: " + getDiff + "ms"); trace("\tCLOSEST BEAT: " + closestBeat); beatTrail.x = songPosVis.x; - if (closestBeat < FlxG.sound.music.length / Conductor.crochet) - diffGrp.members[closestBeat].text = getDiff + "ms"; + + diffGrp.members[closestBeat].text = getDiff + "ms"; + offsetsPerBeat[closestBeat] = Std.int(getDiff); } if (FlxG.keys.justPressed.SPACE) @@ -158,6 +166,15 @@ class LatencyState extends MusicBeatSubstate offsetText.text += "\ncurStep: " + curStep; offsetText.text += "\ncurBeat: " + curBeat; + var avgOffsetInput:Float = 0; + + for (offsetThing in offsetsPerBeat) + avgOffsetInput += offsetThing; + + avgOffsetInput /= offsetsPerBeat.length; + + offsetText.text += "\naverage input offset needed: " + avgOffsetInput; + var multiply:Float = 10; if (FlxG.keys.pressed.SHIFT) From f3e0b0ec5ba115894653c685b61bcccdd00dfba5 Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Tue, 12 Jul 2022 19:02:38 -0400 Subject: [PATCH 14/25] input accuracy testing --- source/funkin/LatencyState.hx | 113 ++++++++++++++++---- source/funkin/ui/CoolStatsGraph.hx | 162 +++++++++++++++++++++++++++++ 2 files changed, 255 insertions(+), 20 deletions(-) create mode 100644 source/funkin/ui/CoolStatsGraph.hx diff --git a/source/funkin/LatencyState.hx b/source/funkin/LatencyState.hx index 713601057..41adfa94e 100644 --- a/source/funkin/LatencyState.hx +++ b/source/funkin/LatencyState.hx @@ -5,9 +5,12 @@ import flixel.FlxSubState; import flixel.group.FlxGroup.FlxTypedGroup; import flixel.group.FlxGroup; import flixel.math.FlxMath; +import flixel.system.FlxSound; +import flixel.system.debug.stats.StatsGraph; import flixel.text.FlxText; import flixel.util.FlxColor; import funkin.audiovis.PolygonSpectogram; +import funkin.ui.CoolStatsGraph; import haxe.Timer; import openfl.events.KeyboardEvent; @@ -26,16 +29,47 @@ class LatencyState extends MusicBeatSubstate var beatTrail:FlxSprite; var diffGrp:FlxTypedGroup; var offsetsPerBeat:Array = []; + var swagSong:HomemadeMusic; + + var funnyStatsGraph:CoolStatsGraph; + var realStats:CoolStatsGraph; override function create() { + swagSong = new HomemadeMusic(); + swagSong.loadEmbedded(Paths.sound('soundTest'), true); + + FlxG.sound.music = swagSong; + FlxG.sound.music.play(); + + funnyStatsGraph = new CoolStatsGraph(0, Std.int(FlxG.height / 2), FlxG.width, Std.int(FlxG.height / 2), FlxColor.PINK, "time"); + FlxG.addChildBelowMouse(funnyStatsGraph); + + realStats = new CoolStatsGraph(0, Std.int(FlxG.height / 2), FlxG.width, Std.int(FlxG.height / 2), FlxColor.YELLOW, "REAL"); + FlxG.addChildBelowMouse(realStats); + FlxG.stage.addEventListener(KeyboardEvent.KEY_DOWN, key -> { + trace(key.charCode); + + if (key.charCode == 120) + generateBeatStuff(); + trace("\tEVENT PRESS: \t" + FlxG.sound.music.time + " " + Timer.stamp()); + // trace(FlxG.sound.music.prevTimestamp); + trace(FlxG.sound.music.time); + trace("\tFR FR PRESS: \t" + swagSong.getTimeWithDiff()); + + // trace("\tREDDIT: \t" + swagSong.frfrTime + " " + Timer.stamp()); + @:privateAccess + trace("\tREDDIT: \t" + FlxG.sound.music._channel.position + " " + Timer.stamp()); // trace("EVENT LISTENER: " + key); }); - FlxG.sound.playMusic(Paths.sound('soundTest')); + // FlxG.sound.playMusic(Paths.sound('soundTest')); + + // funnyStatsGraph.hi + Conductor.bpm = 60; noteGrp = new FlxTypedGroup(); @@ -121,29 +155,19 @@ class LatencyState extends MusicBeatSubstate override function update(elapsed:Float) { + /* trace("1: " + swagSong.frfrTime); + @:privateAccess + trace(FlxG.sound.music._channel.position); + */ + + funnyStatsGraph.update(FlxG.sound.music.time % 500); + realStats.update(swagSong.getTimeWithDiff() % 500); + if (FlxG.keys.justPressed.S) { trace("\tUPDATE PRESS: \t" + FlxG.sound.music.time + " " + Timer.stamp()); } - if (FlxG.keys.justPressed.X) - { - var closestBeat:Int = Math.round(Conductor.songPosition / Conductor.crochet) % diffGrp.members.length; - var getDiff:Float = Conductor.songPosition - (closestBeat * Conductor.crochet); - getDiff -= Conductor.visualOffset; - - // lil fix for end of song - if (closestBeat == 0 && getDiff >= Conductor.crochet * 2) - getDiff -= FlxG.sound.music.length; - - trace("\tDISTANCE TO CLOSEST BEAT: " + getDiff + "ms"); - trace("\tCLOSEST BEAT: " + closestBeat); - beatTrail.x = songPosVis.x; - - diffGrp.members[closestBeat].text = getDiff + "ms"; - offsetsPerBeat[closestBeat] = Std.int(getDiff); - } - if (FlxG.keys.justPressed.SPACE) { if (FlxG.sound.music.playing) @@ -155,7 +179,8 @@ class LatencyState extends MusicBeatSubstate if (FlxG.keys.pressed.D) FlxG.sound.music.time += 1000 * FlxG.elapsed; - Conductor.songPosition = FlxG.sound.music.time - Conductor.offset; + Conductor.songPosition = swagSong.getTimeWithDiff() - Conductor.offset; + // Conductor.songPosition += (Timer.stamp() * 1000) - FlxG.sound.music.prevTimestamp; songPosVis.x = songPosToX(Conductor.songPosition); songVisFollowAudio.x = songPosToX(Conductor.songPosition - Conductor.audioOffset); @@ -230,8 +255,56 @@ class LatencyState extends MusicBeatSubstate super.update(elapsed); } + function generateBeatStuff() + { + Conductor.songPosition = swagSong.getTimeWithDiff(); + + var closestBeat:Int = Math.round(Conductor.songPosition / Conductor.crochet) % diffGrp.members.length; + var getDiff:Float = Conductor.songPosition - (closestBeat * Conductor.crochet); + getDiff -= Conductor.visualOffset; + + // lil fix for end of song + if (closestBeat == 0 && getDiff >= Conductor.crochet * 2) + getDiff -= FlxG.sound.music.length; + + trace("\tDISTANCE TO CLOSEST BEAT: " + getDiff + "ms"); + trace("\tCLOSEST BEAT: " + closestBeat); + beatTrail.x = songPosVis.x; + + diffGrp.members[closestBeat].text = getDiff + "ms"; + offsetsPerBeat[closestBeat] = Std.int(getDiff); + } + function songPosToX(pos:Float):Float { return FlxMath.remapToRange(pos, 0, FlxG.sound.music.length, 0, FlxG.width); } } + +class HomemadeMusic extends FlxSound +{ + public var prevTimestamp:Int = 0; + public var timeWithDiff:Float = 0; + + public function new() + { + super(); + } + + var prevTime:Float = 0; + + override function update(elapsed:Float) + { + super.update(elapsed); + if (prevTime != time) + { + prevTime = time; + prevTimestamp = Std.int(Timer.stamp() * 1000); + } + } + + public function getTimeWithDiff():Float + { + return time + (Std.int(Timer.stamp() * 1000) - prevTimestamp); + } +} diff --git a/source/funkin/ui/CoolStatsGraph.hx b/source/funkin/ui/CoolStatsGraph.hx new file mode 100644 index 000000000..5857a29b5 --- /dev/null +++ b/source/funkin/ui/CoolStatsGraph.hx @@ -0,0 +1,162 @@ +package funkin.ui; + +import flash.display.Graphics; +import flash.display.Shape; +import flash.display.Sprite; +import flash.text.TextField; +import flash.text.TextFormatAlign; +import flixel.math.FlxMath; +import flixel.system.debug.DebuggerUtil; +import flixel.system.debug.stats.Stats; +import flixel.util.FlxColor; +import flixel.util.FlxDestroyUtil; + +/** + * This is a helper function for the stats window to draw a graph with given values. + * SHAMELESSLY STOLEN FROM FLIXEL + * https://github.com/HaxeFlixel/flixel/blob/master/flixel/system/debug/stats/StatsGraph.hx + */ +#if FLX_DEBUG +class CoolStatsGraph extends Sprite +{ + static inline var AXIS_COLOR:FlxColor = 0xffffff; + static inline var AXIS_ALPHA:Float = 0.5; + static inline var HISTORY_MAX:Int = 500; + + public var minLabel:TextField; + public var curLabel:TextField; + public var maxLabel:TextField; + public var avgLabel:TextField; + + public var minValue:Float = FlxMath.MAX_VALUE_FLOAT; + public var maxValue:Float = FlxMath.MIN_VALUE_FLOAT; + + public var graphColor:FlxColor; + + public var history:Array = []; + + var _axis:Shape; + var _width:Int; + var _height:Int; + var _unit:String; + var _labelWidth:Int; + var _label:String; + + public function new(X:Int, Y:Int, Width:Int, Height:Int, GraphColor:FlxColor, Unit:String, LabelWidth:Int = 45, ?Label:String) + { + super(); + x = X; + y = Y; + _width = Width - LabelWidth; + _height = Height; + graphColor = GraphColor; + _unit = Unit; + _labelWidth = LabelWidth; + _label = (Label == null) ? "" : Label; + + _axis = new Shape(); + _axis.x = _labelWidth + 10; + + maxLabel = DebuggerUtil.createTextField(0, 0, Stats.LABEL_COLOR, Stats.TEXT_SIZE); + curLabel = DebuggerUtil.createTextField(0, (_height / 2) - (Stats.TEXT_SIZE / 2), graphColor, Stats.TEXT_SIZE); + minLabel = DebuggerUtil.createTextField(0, _height - Stats.TEXT_SIZE, Stats.LABEL_COLOR, Stats.TEXT_SIZE); + + avgLabel = DebuggerUtil.createTextField(_labelWidth + 20, (_height / 2) - (Stats.TEXT_SIZE / 2) - 10, Stats.LABEL_COLOR, Stats.TEXT_SIZE); + avgLabel.width = _width; + avgLabel.defaultTextFormat.align = TextFormatAlign.CENTER; + avgLabel.alpha = 0.5; + + addChild(_axis); + addChild(maxLabel); + addChild(curLabel); + addChild(minLabel); + addChild(avgLabel); + + drawAxes(); + } + + /** + * Redraws the axes of the graph. + */ + function drawAxes():Void + { + var gfx = _axis.graphics; + gfx.clear(); + gfx.lineStyle(1, AXIS_COLOR, AXIS_ALPHA); + + // y-Axis + gfx.moveTo(0, 0); + gfx.lineTo(0, _height); + + // x-Axis + gfx.moveTo(0, _height); + gfx.lineTo(_width, _height); + } + + /** + * Redraws the graph based on the values stored in the history. + */ + function drawGraph():Void + { + var gfx:Graphics = graphics; + gfx.clear(); + gfx.lineStyle(1, graphColor, 1); + + var inc:Float = _width / (HISTORY_MAX - 1); + var range:Float = Math.max(maxValue - minValue, maxValue * 0.1); + var graphX = _axis.x + 1; + + for (i in 0...history.length) + { + var value = (history[i] - minValue) / range; + + var pointY = (-value * _height - 1) + _height; + if (i == 0) + gfx.moveTo(graphX, _axis.y + pointY); + gfx.lineTo(graphX + (i * inc), pointY); + } + } + + public function update(Value:Float):Void + { + history.unshift(Value); + if (history.length > HISTORY_MAX) + history.pop(); + + // Update range + maxValue = Math.max(maxValue, Value); + minValue = Math.min(minValue, Value); + + minLabel.text = formatValue(minValue); + curLabel.text = formatValue(Value); + maxLabel.text = formatValue(maxValue); + + avgLabel.text = _label + "\nAvg: " + formatValue(average()); + + drawGraph(); + } + + function formatValue(value:Float):String + { + return FlxMath.roundDecimal(value, Stats.DECIMALS) + " " + _unit; + } + + public function average():Float + { + var sum:Float = 0; + for (value in history) + sum += value; + return sum / history.length; + } + + public function destroy():Void + { + _axis = FlxDestroyUtil.removeChild(this, _axis); + minLabel = FlxDestroyUtil.removeChild(this, minLabel); + curLabel = FlxDestroyUtil.removeChild(this, curLabel); + maxLabel = FlxDestroyUtil.removeChild(this, maxLabel); + avgLabel = FlxDestroyUtil.removeChild(this, avgLabel); + history = null; + } +} +#end From a731ccf0ade172cc7a4933f19037808f090c7016 Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Tue, 19 Jul 2022 14:19:03 -0400 Subject: [PATCH 15/25] dipshit latency stuff WIP still --- source/funkin/LatencyState.hx | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/source/funkin/LatencyState.hx b/source/funkin/LatencyState.hx index 41adfa94e..3f2778762 100644 --- a/source/funkin/LatencyState.hx +++ b/source/funkin/LatencyState.hx @@ -20,7 +20,7 @@ class LatencyState extends MusicBeatSubstate var noteGrp:FlxTypedGroup; var strumLine:FlxSprite; - var blocks:FlxGroup; + var blocks:FlxTypedGroup; var songPosVis:FlxSprite; var songVisFollowVideo:FlxSprite; @@ -113,13 +113,13 @@ class LatencyState extends MusicBeatSubstate beatTrail.alpha = 0.7; add(beatTrail); - blocks = new FlxGroup(); + blocks = new FlxTypedGroup(); add(blocks); for (i in 0...8) { var block = new FlxSprite(2, 50 * i).makeGraphic(48, 48); - block.visible = false; + block.alpha = 0; blocks.add(block); } @@ -139,15 +139,25 @@ class LatencyState extends MusicBeatSubstate super.create(); } + override function stepHit() + { + if (curStep % 4 == 2) + { + blocks.members[((curBeat % 8) + 1) % 8].alpha = 0.5; + } + + super.stepHit(); + } + override function beatHit() { if (curBeat % 8 == 0) blocks.forEach(blok -> { - blok.visible = false; + blok.alpha = 0; }); - blocks.members[curBeat % 8].visible = true; + blocks.members[curBeat % 8].alpha = 1; // block.visible = !block.visible; super.beatHit(); From 3be4530fa5144fb13622b4bfbb9bf0e25e25d6a7 Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Mon, 22 Aug 2022 20:18:54 -0400 Subject: [PATCH 16/25] code in place for story week --- source/funkin/StoryMenuState.hx | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/source/funkin/StoryMenuState.hx b/source/funkin/StoryMenuState.hx index 868e62d40..346a0de83 100644 --- a/source/funkin/StoryMenuState.hx +++ b/source/funkin/StoryMenuState.hx @@ -13,8 +13,8 @@ import flixel.text.FlxText; import flixel.tweens.FlxTween; import flixel.util.FlxColor; import flixel.util.FlxTimer; -import lime.net.curl.CURLCode; import funkin.play.PlayState; +import lime.net.curl.CURLCode; using StringTools; @@ -30,13 +30,14 @@ class StoryMenuState extends MusicBeatState ['Satin-Panties', "High", "Milf"], ['Cocoa', 'Eggnog', 'Winter-Horrorland'], ['Senpai', 'Roses', 'Thorns'], - ['Ugh', 'Guns', 'Stress'] + ['Ugh', 'Guns', 'Stress'], + ['Darnell', "lit-up", "2hot"] ]; var curDifficulty:Int = 1; // TODO: This info is just hardcoded right now. // We should probably make it so that weeks must be completed in order to unlock the next week. - public static var weekUnlocked:Array = [true, true, true, true, true, true, true, true]; + public static var weekUnlocked:Array = [true, true, true, true, true, true, true, true, true]; var weekCharacters:Array = [ ['dad', 'bf', 'gf'], @@ -47,6 +48,7 @@ class StoryMenuState extends MusicBeatState ['parents-christmas', 'bf', 'gf'], ['senpai', 'bf', 'gf'], ['tankman', 'bf', 'gf'], + ['pico', 'pico', 'pico'] ]; var weekNames:Array = [ @@ -57,7 +59,8 @@ class StoryMenuState extends MusicBeatState "MOMMY MUST MURDER", "RED SNOW", "hating simulator ft. moawling", - "TANKMAN" + "TANKMAN", + "DARNELL AND NENE" ]; var txtWeekTitle:FlxText; From 8f4855852ed5e1ac692aad3833b73b3de9a68855 Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Wed, 24 Aug 2022 05:44:22 -0400 Subject: [PATCH 17/25] BASE PROTOTYPE WORKING W/ HaxeUI --- Project.xml | 7 +- hmm.json | 151 ++++++------- source/Main.hx | 1 + source/funkin/play/PlayState.hx | 2 + .../ui/stageBuildShit/StageOffsetSubstate.hx | 203 ++++++++++++------ source/module.xml | 14 ++ 6 files changed, 244 insertions(+), 134 deletions(-) create mode 100644 source/module.xml diff --git a/Project.xml b/Project.xml index 81f017853..ff22ddad9 100644 --- a/Project.xml +++ b/Project.xml @@ -122,6 +122,8 @@ + + @@ -196,6 +198,9 @@ + + + @@ -246,7 +251,7 @@ - +
diff --git a/hmm.json b/hmm.json index 984f54166..b32de6cc8 100644 --- a/hmm.json +++ b/hmm.json @@ -1,74 +1,81 @@ { - "dependencies": [ - { - "name": "discord_rpc", - "type": "git", - "dir": null, - "ref": "2d83fa8", - "url": "https://github.com/Aidan63/linc_discord-rpc" - }, - { - "name": "firetongue", - "type": "git", - "dir": null, - "ref": "c5666c8", - "url": "https://github.com/larsiusprime/firetongue" - }, - { - "name": "flixel", - "type": "git", - "dir": null, - "ref": "93a049d6", - "url": "https://github.com/haxeflixel/flixel" - }, - { - "name": "flixel-addons", - "type": "haxelib", - "version": "2.11.0" - }, - { - "name": "flixel-ui", - "type": "haxelib", - "version": "2.4.0" - }, - { - "name": "hscript", - "type": "git", - "dir": null, - "ref": "a1b7f74", - "url": "https://github.com/mastereric/hscript" - }, - { - "name": "hxcpp", - "type": "haxelib", - "version": "4.2.1" - }, - { - "name": "hxcpp-debug-server", - "type": "haxelib", - "version": "1.2.4" - }, - { - "name": "lime", - "type": "haxelib", - "version": "7.9.0" - }, - { - "name": "openfl", - "type": "haxelib", - "version": "9.1.0" - }, - { - "name": "polymod", - "type": "git", - "dir": null, - "ref": "c858b48", - "url": "https://github.com/larsiusprime/polymod" - }, - { - "name": "thx.semver", - "type": "haxelib", - "version": "0.2.2" - } - ] + "dependencies": [{ + "name": "discord_rpc", + "type": "git", + "dir": null, + "ref": "2d83fa8", + "url": "https://github.com/Aidan63/linc_discord-rpc" + }, + { + "name": "firetongue", + "type": "git", + "dir": null, + "ref": "c5666c8", + "url": "https://github.com/larsiusprime/firetongue" + }, + { + "name": "flixel", + "type": "git", + "dir": null, + "ref": "93a049d6", + "url": "https://github.com/haxeflixel/flixel" + }, + { + "name": "flixel-addons", + "type": "haxelib", + "version": "2.11.0" + }, + { + "name": "flixel-ui", + "type": "haxelib", + "version": "2.4.0" + }, + { + "name": "haxeui-core", + "type": "haxelib", + "version": null + }, + { + "name": "haxeui-flixel", + "type": "haxelib", + "version": null + }, + { + "name": "hscript", + "type": "haxelib", + "version": "2.5.0" + }, + { + "name": "hxcpp", + "type": "haxelib", + "version": "4.2.1" + }, + { + "name": "hxcpp-debug-server", + "type": "haxelib", + "version": "1.2.4" + }, + { + "name": "lime", + "type": "haxelib", + "version": "7.9.0" + }, + { + "name": "openfl", + "type": "haxelib", + "version": "9.1.0" + }, + { + "name": "polymod", + "type": "git", + "dir": null, + "ref": "c858b48", + "url": "https://github.com/larsiusprime/polymod" + }, + { + "name": "thx.semver", + "type": "haxelib", + "version": "0.2.2" + } + ] } \ No newline at end of file diff --git a/source/Main.hx b/source/Main.hx index 191ebef53..8416dec43 100644 --- a/source/Main.hx +++ b/source/Main.hx @@ -87,6 +87,7 @@ class Main extends Sprite initialState = TitleState; #end + haxe.ui.Toolkit.init(); addChild(new FlxGame(gameWidth, gameHeight, initialState, zoom, framerate, framerate, skipSplash, startFullscreen)); #if debug diff --git a/source/funkin/play/PlayState.hx b/source/funkin/play/PlayState.hx index 1b4e652ec..5b097b826 100644 --- a/source/funkin/play/PlayState.hx +++ b/source/funkin/play/PlayState.hx @@ -963,6 +963,8 @@ class PlayState extends MusicBeatState implements IHook if (FlxG.keys.justPressed.U) { + // hack for HaxeUI generation, doesn't work unless persistentUpdate is false at state creation!! + persistentUpdate = false; openSubState(new StageOffsetSubstate()); } diff --git a/source/funkin/ui/stageBuildShit/StageOffsetSubstate.hx b/source/funkin/ui/stageBuildShit/StageOffsetSubstate.hx index 1196e8cf1..7c04e6652 100644 --- a/source/funkin/ui/stageBuildShit/StageOffsetSubstate.hx +++ b/source/funkin/ui/stageBuildShit/StageOffsetSubstate.hx @@ -1,103 +1,184 @@ package funkin.ui.stageBuildShit; +import flixel.FlxSprite; +import flixel.input.mouse.FlxMouseEventManager; import flixel.math.FlxPoint; import flixel.ui.FlxButton; import funkin.play.PlayState; import funkin.play.character.BaseCharacter; import funkin.play.stage.StageData; import haxe.Json; +import haxe.ui.ComponentBuilder; +import haxe.ui.RuntimeComponentBuilder; +import haxe.ui.Toolkit; +import haxe.ui.components.Button; +import haxe.ui.containers.HBox; +import haxe.ui.containers.VBox; +import haxe.ui.core.Component; import openfl.Assets; +import openfl.events.Event; +import openfl.events.IOErrorEvent; +import openfl.net.FileReference; class StageOffsetSubstate extends MusicBeatSubstate { - public function new() + override function create() { - super(); + super.create(); + FlxG.mouse.visible = true; PlayState.instance.pauseMusic(); FlxG.camera.target = null; - var btn:FlxButton = new FlxButton(200, 10, "SAVE COMPILE", function() + var str = Paths.xml('ui/stage-editor-view'); + var uiStuff:Component = RuntimeComponentBuilder.fromAsset(str); + + uiStuff.findComponent("lol").onClick = saveCharacterCompile; + uiStuff.findComponent('saveAs').onClick = saveStageFileRef; + + add(uiStuff); + + PlayState.instance.persistentUpdate = true; + uiStuff.cameras = [PlayState.instance.camHUD]; + // btn.cameras = [PlayState.instance.camHUD]; + + for (thing in PlayState.instance.currentStage) { - var stageLol:StageData = StageDataParser.parseStageData(PlayState.instance.currentStageId); + FlxMouseEventManager.add(thing, spr -> + { + char = cast thing; + trace("JUST PRESSED!"); + sprOld.x = thing.x; + sprOld.y = thing.y; - var bfPos = PlayState.instance.currentStage.getBoyfriend().feetPosition; - stageLol.characters.bf.position[0] = Std.int(bfPos.x); - stageLol.characters.bf.position[1] = Std.int(bfPos.y); - - var dadPos = PlayState.instance.currentStage.getDad().feetPosition; - - stageLol.characters.dad.position[0] = Std.int(dadPos.x); - stageLol.characters.dad.position[1] = Std.int(dadPos.y); - - var GF_FEET_SNIIIIIIIIIIIIIFFFF = PlayState.instance.currentStage.getGirlfriend().feetPosition; - stageLol.characters.gf.position[0] = Std.int(GF_FEET_SNIIIIIIIIIIIIIFFFF.x); - stageLol.characters.gf.position[1] = Std.int(GF_FEET_SNIIIIIIIIIIIIIFFFF.y); - - var outputJson = CoolUtil.jsonStringify(stageLol); - - #if sys - // save "local" to the current export. - sys.io.File.saveContent('./assets/data/stages/' + PlayState.instance.currentStageId + '.json', outputJson); - - // save to the dev version - sys.io.File.saveContent('../../../../assets/preload/data/stages/' + PlayState.instance.currentStageId + '.json', outputJson); - #end - // trace(dipshitJson); - - // put character position data to a file of some sort - }); - btn.scrollFactor.set(); - add(btn); - btn.cameras = [PlayState.instance.camHUD]; + mosPosOld.x = FlxG.mouse.x; + mosPosOld.y = FlxG.mouse.y; + }, null, spr -> + { + // ID tag is to see if currently overlapping hold basically!, a bit more reliable than checking transparency! + // used for bug where you can click, and if you click on NO sprite, it snaps the thing to position! unintended! + spr.ID = 1; + spr.alpha = 0.5; + }, spr -> + { + spr.ID = 0; + spr.alpha = 1; + }); + } } var mosPosOld:FlxPoint = new FlxPoint(); var sprOld:FlxPoint = new FlxPoint(); - var char:BaseCharacter = null; + var char:FlxSprite = null; + var overlappingChar:Bool = false; override function update(elapsed:Float) { super.update(elapsed); + if (char != null && char.ID == 1 && FlxG.mouse.pressed) + { + char.x = sprOld.x - (mosPosOld.x - FlxG.mouse.x); + char.y = sprOld.y - (mosPosOld.y - FlxG.mouse.y); + } + CoolUtil.mouseCamDrag(); if (FlxG.keys.pressed.CONTROL) CoolUtil.mouseWheelZoom(); - if (FlxG.mouse.pressed) - { - if (FlxG.mouse.justPressed) - { - for (thing in PlayState.instance.currentStage) - { - if (FlxG.mouse.overlaps(thing) && Std.isOfType(thing, BaseCharacter)) - char = cast thing; - } - - if (char != null) - { - sprOld.x = char.x; - sprOld.y = char.y; - } - - mosPosOld.x = FlxG.mouse.x; - mosPosOld.y = FlxG.mouse.y; - } - - if (char != null) - { - char.x = sprOld.x - (mosPosOld.x - FlxG.mouse.x); - char.y = sprOld.y - (mosPosOld.y - FlxG.mouse.y); - } - } - if (FlxG.keys.justPressed.Y) { + for (thing in PlayState.instance.currentStage) + { + FlxMouseEventManager.remove(thing); + thing.alpha = 1; + } + PlayState.instance.resetCamera(); FlxG.mouse.visible = false; close(); } } + + var _file:FileReference; + + private function saveStageFileRef(_):Void + { + var jsonStr = prepStageStuff(); + + _file = new FileReference(); + _file.addEventListener(Event.COMPLETE, onSaveComplete); + _file.addEventListener(Event.CANCEL, onSaveCancel); + _file.addEventListener(IOErrorEvent.IO_ERROR, onSaveError); + _file.save(jsonStr, PlayState.instance.currentStageId + ".json"); + } + + function onSaveComplete(_) + { + fileRemoveListens(); + FlxG.log.notice("Successfully saved!"); + } + + function onSaveCancel(_) + { + fileRemoveListens(); + } + + function onSaveError(_) + { + fileRemoveListens(); + FlxG.log.error("Problem saving Stage file!"); + } + + function fileRemoveListens() + { + _file.removeEventListener(Event.COMPLETE, onSaveComplete); + _file.removeEventListener(Event.CANCEL, onSaveCancel); + _file.removeEventListener(IOErrorEvent.IO_ERROR, onSaveError); + _file = null; + } + + private function saveCharacterCompile(_):Void + { + var outputJson:String = prepStageStuff(); + + #if sys + // save "local" to the current export. + sys.io.File.saveContent('./assets/data/stages/' + PlayState.instance.currentStageId + '.json', outputJson); + + // save to the dev version + sys.io.File.saveContent('../../../../assets/preload/data/stages/' + PlayState.instance.currentStageId + '.json', outputJson); + #end + } + + private function prepStageStuff():String + { + var stageLol:StageData = StageDataParser.parseStageData(PlayState.instance.currentStageId); + + for (prop in stageLol.props) + { + @:privateAccess + var posStuff = PlayState.instance.currentStage.namedProps.get(prop.name); + + prop.position[0] = posStuff.x; + prop.position[1] = posStuff.y; + } + + var bfPos = PlayState.instance.currentStage.getBoyfriend().feetPosition; + stageLol.characters.bf.position[0] = Std.int(bfPos.x); + stageLol.characters.bf.position[1] = Std.int(bfPos.y); + + var dadPos = PlayState.instance.currentStage.getDad().feetPosition; + + stageLol.characters.dad.position[0] = Std.int(dadPos.x); + stageLol.characters.dad.position[1] = Std.int(dadPos.y); + + var GF_FEET_SNIIIIIIIIIIIIIFFFF = PlayState.instance.currentStage.getGirlfriend().feetPosition; + stageLol.characters.gf.position[0] = Std.int(GF_FEET_SNIIIIIIIIIIIIIFFFF.x); + stageLol.characters.gf.position[1] = Std.int(GF_FEET_SNIIIIIIIIIIIIIFFFF.y); + + return CoolUtil.jsonStringify(stageLol); + } } diff --git a/source/module.xml b/source/module.xml new file mode 100644 index 000000000..b08aabd98 --- /dev/null +++ b/source/module.xml @@ -0,0 +1,14 @@ + + + + + + + + + + \ No newline at end of file From 831626a156cca3fb4f1c8ef6ada846690497b580 Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Thu, 25 Aug 2022 01:35:47 -0400 Subject: [PATCH 18/25] stuff for storymenu --- source/funkin/MenuCharacter.hx | 11 +- source/funkin/MenuItem.hx | 19 +++- source/funkin/StoryMenuState.hx | 172 ++++++++++++++++++++------------ 3 files changed, 136 insertions(+), 66 deletions(-) diff --git a/source/funkin/MenuCharacter.hx b/source/funkin/MenuCharacter.hx index 14cc4e05f..fd678d2de 100644 --- a/source/funkin/MenuCharacter.hx +++ b/source/funkin/MenuCharacter.hx @@ -13,9 +13,16 @@ class MenuCharacter extends FlxSprite this.character = character; - var tex = Paths.getSparrowAtlas('campaign_menu_UI_characters'); + var suffix:String = character; + + if (character != "darnell" && character != "nene") + suffix = "characters"; + + var tex = Paths.getSparrowAtlas('campaign_menu_UI_' + suffix); frames = tex; + trace(character); + animation.addByPrefix('bf', "BF idle dance white", 24); animation.addByPrefix('bfConfirm', 'BF HEY!!', 24, false); animation.addByPrefix('gf', "GF Dancing Beat WHITE", 24); @@ -26,6 +33,8 @@ class MenuCharacter extends FlxSprite animation.addByPrefix('parents-christmas', "Parent Christmas Idle", 24); animation.addByPrefix('senpai', "SENPAI idle Black Lines", 24); animation.addByPrefix('tankman', "Tankman Menu BLACK", 24); + animation.addByPrefix('darnell', "Darnell Black Lines To Scale", 24); + animation.addByPrefix('nene', "Nene Black Lines To Scale", 24); // Parent Christmas Idle animation.play(character); diff --git a/source/funkin/MenuItem.hx b/source/funkin/MenuItem.hx index de03c5b69..43c927b37 100644 --- a/source/funkin/MenuItem.hx +++ b/source/funkin/MenuItem.hx @@ -12,10 +12,19 @@ class MenuItem extends FlxSpriteGroup public var week:FlxSprite; public var flashingInt:Int = 0; - public function new(x:Float, y:Float, weekNum:Int = 0) + public function new(x:Float, y:Float, weekNum:Int = 0, weekType:WeekType) { super(x, y); - week = new FlxSprite().loadGraphic(Paths.image('storymenu/week' + weekNum)); + + var weekStr:String = switch (weekType) + { + case WEEK: + "week"; + case WEEKEND: + "weekend"; + } + + week = new FlxSprite().loadGraphic(Paths.image('storymenu/' + weekStr + weekNum)); add(week); } @@ -46,3 +55,9 @@ class MenuItem extends FlxSpriteGroup week.color = FlxColor.WHITE; } } + +enum abstract WeekType(String) to String +{ + var WEEK; + var WEEKEND; +} diff --git a/source/funkin/StoryMenuState.hx b/source/funkin/StoryMenuState.hx index 346a0de83..cb461b5b5 100644 --- a/source/funkin/StoryMenuState.hx +++ b/source/funkin/StoryMenuState.hx @@ -1,8 +1,5 @@ package funkin; -#if discord_rpc -import Discord.DiscordClient; -#end import flixel.FlxSprite; import flixel.addons.transition.FlxTransitionableState; import flixel.graphics.frames.FlxAtlasFrames; @@ -13,11 +10,17 @@ import flixel.text.FlxText; import flixel.tweens.FlxTween; import flixel.util.FlxColor; import flixel.util.FlxTimer; +import funkin.MenuItem.WeekType; import funkin.play.PlayState; import lime.net.curl.CURLCode; +import openfl.Assets; using StringTools; +#if discord_rpc +import Discord.DiscordClient; +#end + class StoryMenuState extends MusicBeatState { var scoreText:FlxText; @@ -48,7 +51,7 @@ class StoryMenuState extends MusicBeatState ['parents-christmas', 'bf', 'gf'], ['senpai', 'bf', 'gf'], ['tankman', 'bf', 'gf'], - ['pico', 'pico', 'pico'] + ['darnell', 'pico', 'nene'] ]; var weekNames:Array = [ @@ -60,9 +63,12 @@ class StoryMenuState extends MusicBeatState "RED SNOW", "hating simulator ft. moawling", "TANKMAN", - "DARNELL AND NENE" + "Due Debts" ]; + var weekType:Array = [WEEK, WEEK, WEEK, WEEK, WEEK, WEEK, WEEK, WEEK, WEEKEND]; + var weekTypeInc:Map = new Map(); + var txtWeekTitle:FlxText; var curWeek:Int = 0; @@ -70,14 +76,17 @@ class StoryMenuState extends MusicBeatState var txtTracklist:FlxText; var grpWeekText:FlxTypedGroup; - var grpWeekCharacters:FlxTypedGroup; + var grpWeekCharacters:Array>; + // var grpWeekCharacters:FlxTypedGroup; var grpLocks:FlxTypedGroup; var difficultySelectors:FlxGroup; var sprDifficulty:FlxSprite; var leftArrow:FlxSprite; var rightArrow:FlxSprite; + var yellowBG:FlxSprite; // not actually, yellow, lol! + var targetColor:Int = 0xFFF9CF51; override function create() { @@ -106,7 +115,10 @@ class StoryMenuState extends MusicBeatState rankText.screenCenter(X); var ui_tex = Paths.getSparrowAtlas('campaign_menu_UI_assets'); - var yellowBG:FlxSprite = new FlxSprite(0, 56).makeGraphic(FlxG.width, 400, 0xFFF9CF51); + yellowBG = new FlxSprite(0, 56).makeGraphic(FlxG.width, 400, FlxColor.WHITE); + yellowBG.color = 0xFFF9CF51; + // 0xFF413CAE blue + // 0xFFF9CF51 yello grpWeekText = new FlxTypedGroup(); add(grpWeekText); @@ -114,7 +126,8 @@ class StoryMenuState extends MusicBeatState var blackBarThingie:FlxSprite = new FlxSprite().makeGraphic(FlxG.width, 56, FlxColor.BLACK); add(blackBarThingie); - grpWeekCharacters = new FlxTypedGroup(); + // grpWeekCharacters = new FlxTypedGroup(); + grpWeekCharacters = []; grpLocks = new FlxTypedGroup(); add(grpLocks); @@ -126,11 +139,19 @@ class StoryMenuState extends MusicBeatState for (i in 0...weekData.length) { - var weekThing:MenuItem = new MenuItem(0, yellowBG.y + yellowBG.height + 10, i); + if (!weekTypeInc.exists(weekType[i])) + weekTypeInc[weekType[i]] = 1; + + if (i == 0 && weekType[i] == WEEK) + weekTypeInc[weekType[i]] = 0; // set week to 0 by default? + + var weekThing:MenuItem = new MenuItem(0, yellowBG.y + yellowBG.height + 10, weekTypeInc[weekType[i]], weekType[i]); weekThing.y += ((weekThing.height + 20) * i); weekThing.targetY = i; grpWeekText.add(weekThing); + weekTypeInc[weekType[i]] += 1; + weekThing.screenCenter(X); weekThing.antialiasing = true; // weekThing.updateHitbox(); @@ -148,32 +169,64 @@ class StoryMenuState extends MusicBeatState } } - for (char in 0...3) - { - var weekCharacterThing:MenuCharacter = new MenuCharacter((FlxG.width * 0.25) * (1 + char) - 150, weekCharacters[curWeek][char]); - weekCharacterThing.y += 70; - weekCharacterThing.antialiasing = true; - switch (weekCharacterThing.character) - { - case 'dad': - weekCharacterThing.setGraphicSize(Std.int(weekCharacterThing.width * 0.5)); - weekCharacterThing.updateHitbox(); + var sizeChart:Map> = new Map(); - case 'bf': - weekCharacterThing.setGraphicSize(Std.int(weekCharacterThing.width * 0.9)); - weekCharacterThing.updateHitbox(); - weekCharacterThing.x -= 80; - case 'gf': - weekCharacterThing.setGraphicSize(Std.int(weekCharacterThing.width * 0.5)); - weekCharacterThing.updateHitbox(); - case 'pico': - weekCharacterThing.flipX = true; - case 'parents-christmas': - weekCharacterThing.setGraphicSize(Std.int(weekCharacterThing.width * 0.9)); - weekCharacterThing.updateHitbox(); + var sizeTxt:Array = Assets.getText(Paths.file("data/storychardata.txt")).split("\n"); + + for (item in sizeTxt) + { + var items:Array = item.split(" "); + + var stuf:Array = []; + var name:String = items.shift(); + + for (num in items) + stuf.push(Std.parseFloat(num)); + + sizeChart.set(name, stuf); + } + + for (index => week in weekCharacters) + { + grpWeekCharacters.push(new FlxTypedGroup()); + + for (char in 0...week.length) + { + var weekCharacterThing:MenuCharacter = new MenuCharacter((FlxG.width * 0.25) * (1 + char) - 150, weekCharacters[index][char]); + weekCharacterThing.y += 70; + weekCharacterThing.antialiasing = true; + + var size:Float = 0.9; + + switch (char) + { + case 0 | 2: + size = 0.5; + if (char == 0 && weekCharacterThing.character == "pico") + weekCharacterThing.flipX = true; + case 1: + size = 0.9; + weekCharacterThing.x -= 80; + } + + if (sizeChart.exists(weekCharacterThing.character)) + { + var nums:Array = sizeChart[weekCharacterThing.character]; + size = nums[char]; + + // IDK, this might be busted ass null shit? + weekCharacterThing.x += nums[3]; + weekCharacterThing.y += nums[4]; + } + + weekCharacterThing.setGraphicSize(Std.int(weekCharacterThing.width * size)); + weekCharacterThing.updateHitbox(); + + grpWeekCharacters[index].add(weekCharacterThing); + trace("ADD CHARACTER"); } - grpWeekCharacters.add(weekCharacterThing); + trace(grpWeekCharacters[index].toString()); } difficultySelectors = new FlxGroup(); @@ -204,7 +257,13 @@ class StoryMenuState extends MusicBeatState difficultySelectors.add(rightArrow); add(yellowBG); - add(grpWeekCharacters); + for (grp in grpWeekCharacters) + { + add(grp); + // trace("ADDED GRP"); + } + + // add(grpWeekCharacters); txtTracklist = new FlxText(FlxG.width * 0.05, yellowBG.x + yellowBG.height + 100, 0, "Tracks", 32); txtTracklist.alignment = CENTER; @@ -223,6 +282,9 @@ class StoryMenuState extends MusicBeatState override function update(elapsed:Float) { // scoreText.setFormat('VCR OSD Mono', 32); + + yellowBG.color = FlxColor.interpolate(yellowBG.color, targetColor, 0.06); + lerpScore = CoolUtil.coolLerp(lerpScore, intendedScore, 0.5); scoreText.text = "WEEK SCORE:" + Math.round(lerpScore); @@ -298,7 +360,7 @@ class StoryMenuState extends MusicBeatState FlxG.sound.play(Paths.sound('confirmMenu')); grpWeekText.members[curWeek].startFlashing(); - grpWeekCharacters.members[1].animation.play('bfConfirm'); + grpWeekCharacters[curWeek].members[1].animation.play('bfConfirm'); stopspamming = true; } @@ -394,38 +456,22 @@ class StoryMenuState extends MusicBeatState function updateText() { - grpWeekCharacters.members[0].animation.play(weekCharacters[curWeek][0]); - grpWeekCharacters.members[1].animation.play(weekCharacters[curWeek][1]); - grpWeekCharacters.members[2].animation.play(weekCharacters[curWeek][2]); - txtTracklist.text = "Tracks\n"; - - switch (grpWeekCharacters.members[0].animation.curAnim.name) + switch (weekType[curWeek]) { - case 'parents-christmas': - grpWeekCharacters.members[0].offset.set(200, 200); - grpWeekCharacters.members[0].setGraphicSize(Std.int(grpWeekCharacters.members[0].width * 0.99)); - - case 'senpai': - grpWeekCharacters.members[0].offset.set(130, 0); - grpWeekCharacters.members[0].setGraphicSize(Std.int(grpWeekCharacters.members[0].width * 1.4)); - - case 'mom': - grpWeekCharacters.members[0].offset.set(100, 200); - grpWeekCharacters.members[0].setGraphicSize(Std.int(grpWeekCharacters.members[0].width * 1)); - - case 'dad': - grpWeekCharacters.members[0].offset.set(120, 200); - grpWeekCharacters.members[0].setGraphicSize(Std.int(grpWeekCharacters.members[0].width * 1)); - case 'tankman': - grpWeekCharacters.members[0].offset.set(60, -20); - grpWeekCharacters.members[0].setGraphicSize(Std.int(grpWeekCharacters.members[0].width * 1)); - - default: - grpWeekCharacters.members[0].offset.set(100, 100); - grpWeekCharacters.members[0].setGraphicSize(Std.int(grpWeekCharacters.members[0].width * 1)); - // grpWeekCharacters.members[0].updateHitbox(); + case WEEK: + targetColor = 0xFFF9CF51; + case WEEKEND: + targetColor = 0xFF413CAE; } + for (ind => grp in grpWeekCharacters) + grp.visible = ind == curWeek; + + // grpWeekCharacters.members[0].animation.play(weekCharacters[curWeek][0]); + // grpWeekCharacters.members[1].animation.play(weekCharacters[curWeek][1]); + // grpWeekCharacters.members[2].animation.play(weekCharacters[curWeek][2]); + txtTracklist.text = "Tracks\n"; + var trackNames:Array = weekData[curWeek]; for (i in trackNames) { From 59aae9c3d933744ead5d72a8b00f31230a334ed4 Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Thu, 25 Aug 2022 01:40:39 -0400 Subject: [PATCH 19/25] =?UTF-8?q?storymenu=20stuff=20for=20now=20?= =?UTF-8?q?=F0=9F=A4=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/funkin/StoryMenuState.hx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/source/funkin/StoryMenuState.hx b/source/funkin/StoryMenuState.hx index cb461b5b5..d3023b4a3 100644 --- a/source/funkin/StoryMenuState.hx +++ b/source/funkin/StoryMenuState.hx @@ -215,8 +215,11 @@ class StoryMenuState extends MusicBeatState size = nums[char]; // IDK, this might be busted ass null shit? - weekCharacterThing.x += nums[3]; - weekCharacterThing.y += nums[4]; + if (char != 1) + { + weekCharacterThing.x += nums[3]; + weekCharacterThing.y += nums[4]; + } } weekCharacterThing.setGraphicSize(Std.int(weekCharacterThing.width * size)); @@ -467,9 +470,6 @@ class StoryMenuState extends MusicBeatState for (ind => grp in grpWeekCharacters) grp.visible = ind == curWeek; - // grpWeekCharacters.members[0].animation.play(weekCharacters[curWeek][0]); - // grpWeekCharacters.members[1].animation.play(weekCharacters[curWeek][1]); - // grpWeekCharacters.members[2].animation.play(weekCharacters[curWeek][2]); txtTracklist.text = "Tracks\n"; var trackNames:Array = weekData[curWeek]; From aaf1376b53f28bdf228b8a03e5ba5043c3cf1df8 Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Thu, 25 Aug 2022 05:18:09 -0400 Subject: [PATCH 20/25] stage editor Y key fix (and streets repositioning) --- source/funkin/ui/stageBuildShit/StageOffsetSubstate.hx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/source/funkin/ui/stageBuildShit/StageOffsetSubstate.hx b/source/funkin/ui/stageBuildShit/StageOffsetSubstate.hx index 7c04e6652..6c43d42c6 100644 --- a/source/funkin/ui/stageBuildShit/StageOffsetSubstate.hx +++ b/source/funkin/ui/stageBuildShit/StageOffsetSubstate.hx @@ -22,6 +22,8 @@ import openfl.net.FileReference; class StageOffsetSubstate extends MusicBeatSubstate { + var uiStuff:Component; + override function create() { super.create(); @@ -31,7 +33,7 @@ class StageOffsetSubstate extends MusicBeatSubstate FlxG.camera.target = null; var str = Paths.xml('ui/stage-editor-view'); - var uiStuff:Component = RuntimeComponentBuilder.fromAsset(str); + uiStuff = RuntimeComponentBuilder.fromAsset(str); uiStuff.findComponent("lol").onClick = saveCharacterCompile; uiStuff.findComponent('saveAs').onClick = saveStageFileRef; @@ -96,6 +98,11 @@ class StageOffsetSubstate extends MusicBeatSubstate thing.alpha = 1; } + if (uiStuff != null) + remove(uiStuff); + + uiStuff = null; + PlayState.instance.resetCamera(); FlxG.mouse.visible = false; close(); From eaab159c73ed5c911cf9d4b973f8575ad7c5b6af Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Thu, 25 Aug 2022 20:15:50 -0400 Subject: [PATCH 21/25] lit-up on street stage --- source/funkin/play/PlayState.hx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/funkin/play/PlayState.hx b/source/funkin/play/PlayState.hx index 5b097b826..a2e1ee9ff 100644 --- a/source/funkin/play/PlayState.hx +++ b/source/funkin/play/PlayState.hx @@ -478,7 +478,7 @@ class PlayState extends MusicBeatState implements IHook currentStageId = 'pyro'; case 'senpai' | 'roses': currentStageId = 'school'; - case "darnell": + case "darnell" | "lit-up" | "2hot": currentStageId = 'phillyStreets'; case 'thorns': currentStageId = 'schoolEvil'; From 07fb4039dc3097fdbc7a039cc701354e7658904e Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Fri, 26 Aug 2022 16:46:48 -0400 Subject: [PATCH 22/25] dipshit FFT fixing in progress... --- source/funkin/audiovis/SpectogramSprite.hx | 33 ++++++---------------- 1 file changed, 8 insertions(+), 25 deletions(-) diff --git a/source/funkin/audiovis/SpectogramSprite.hx b/source/funkin/audiovis/SpectogramSprite.hx index b3cb6ff62..fb05b6972 100644 --- a/source/funkin/audiovis/SpectogramSprite.hx +++ b/source/funkin/audiovis/SpectogramSprite.hx @@ -1,8 +1,5 @@ package funkin.audiovis; -import funkin.audiovis.PolygonSpectogram.VISTYPE; -import funkin.audiovis.VisShit.CurAudioInfo; -import funkin.audiovis.dsp.FFT; import flixel.FlxSprite; import flixel.group.FlxGroup; import flixel.group.FlxSpriteGroup.FlxTypedSpriteGroup; @@ -11,6 +8,11 @@ import flixel.math.FlxPoint; import flixel.math.FlxVector; import flixel.system.FlxSound; import flixel.util.FlxColor; +import funkin.audiovis.PolygonSpectogram.VISTYPE; +import funkin.audiovis.VisShit.CurAudioInfo; +import funkin.audiovis.dsp.FFT; +import haxe.Timer; +import lime.system.ThreadPool; import lime.utils.Int16Array; using Lambda; @@ -167,39 +169,20 @@ class SpectogramSprite extends FlxTypedSpriteGroup else remappedShit = Std.int(FlxMath.remapToRange(Conductor.songPosition, 0, vis.snd.length, 0, numSamples)); - var i = remappedShit; - var prevLine:FlxPoint = new FlxPoint(); - - var swagheight:Int = 200; - var fftSamples:Array = []; - - // var array:Array = cast audioData.subarray(remappedShit, remappedShit + lengthOfShit); - - if (FlxG.keys.justPressed.M) - { - trace('POOP LOL'); - var funnyAud = audioData.subarray(remappedShit, remappedShit + lengthOfShit); - - for (poop in funnyAud) - { - // trace("actual audio: " + poop); - trace("win: " + poop); - } - - // trace(audioData.subarray(remappedShit, remappedShit + lengthOfShit).buffer); - } + var i = remappedShit; for (sample in remappedShit...remappedShit + (Std.int((44100 * (1 / 144))))) { var curAud:CurAudioInfo = VisShit.getCurAud(audioData, i); i += 2; - // var remappedSample:Float = FlxMath.remapToRange(sample, remappedShit, remappedShit + lengthOfShit, 0, lengthOfShit - 1); fftSamples.push(curAud.balanced); } var freqShit = vis.funnyFFT(fftSamples); + var prevLine:FlxPoint = new FlxPoint(); + var swagheight:Int = 200; for (i in 0...group.members.length) { From 36e6d6bd915a03d5b3057d6ee6ab46f32502e203 Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Fri, 26 Aug 2022 16:46:58 -0400 Subject: [PATCH 23/25] fft... --- source/funkin/audiovis/ABot.hx | 12 ++++++++++++ source/funkin/audiovis/VisShit.hx | 8 +++++--- 2 files changed, 17 insertions(+), 3 deletions(-) create mode 100644 source/funkin/audiovis/ABot.hx diff --git a/source/funkin/audiovis/ABot.hx b/source/funkin/audiovis/ABot.hx new file mode 100644 index 000000000..51df8bb40 --- /dev/null +++ b/source/funkin/audiovis/ABot.hx @@ -0,0 +1,12 @@ +package funkin.audiovis; + +import flixel.FlxSprite; +import flixel.group.FlxSpriteGroup.FlxTypedSpriteGroup; + +class ABot extends FlxTypedSpriteGroup +{ + public function new() + { + super(); + } +} diff --git a/source/funkin/audiovis/VisShit.hx b/source/funkin/audiovis/VisShit.hx index 232d060a5..f15a3c37a 100644 --- a/source/funkin/audiovis/VisShit.hx +++ b/source/funkin/audiovis/VisShit.hx @@ -1,8 +1,10 @@ package funkin.audiovis; -import funkin.audiovis.dsp.FFT; import flixel.math.FlxMath; import flixel.system.FlxSound; +import funkin.audiovis.dsp.FFT; +import haxe.Timer; +import lime.system.ThreadPool; import lime.utils.Int16Array; using Lambda; @@ -51,8 +53,8 @@ class VisShit final maxFreq = 4000.01; final melodicBandPass = function(k:Int, s:Float) { - // final freq = indexToFreq(k); - // final filter = freq > minFreq - binSize && freq < maxFreq + binSize ? 1 : 0; + final freq = indexToFreq(k); + final filter = freq > minFreq - binSize && freq < maxFreq + binSize ? 1 : 0; return s; }; From e15815afa8ea8ad60855fd5d153604b1ee70ffc0 Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Thu, 8 Sep 2022 04:03:50 -0400 Subject: [PATCH 24/25] initial haxeui for character offset editor --- .../ui/animDebugShit/DebugBoundingState.hx | 59 ++++++++++++++++--- 1 file changed, 51 insertions(+), 8 deletions(-) diff --git a/source/funkin/ui/animDebugShit/DebugBoundingState.hx b/source/funkin/ui/animDebugShit/DebugBoundingState.hx index 19012a500..f92e38d67 100644 --- a/source/funkin/ui/animDebugShit/DebugBoundingState.hx +++ b/source/funkin/ui/animDebugShit/DebugBoundingState.hx @@ -1,13 +1,11 @@ package funkin.ui.animDebugShit; -import funkin.play.character.CharacterData.CharacterDataParser; -import funkin.play.character.SparrowCharacter; -import flixel.addons.display.FlxGridOverlay; -import flixel.addons.ui.FlxInputText; -import flixel.addons.ui.FlxUIDropDownMenu; import flixel.FlxCamera; import flixel.FlxSprite; import flixel.FlxState; +import flixel.addons.display.FlxGridOverlay; +import flixel.addons.ui.FlxInputText; +import flixel.addons.ui.FlxUIDropDownMenu; import flixel.graphics.frames.FlxAtlasFrames; import flixel.graphics.frames.FlxFrame; import flixel.group.FlxGroup; @@ -18,6 +16,13 @@ import flixel.util.FlxColor; import flixel.util.FlxSpriteUtil; import flixel.util.FlxTimer; import funkin.play.character.BaseCharacter; +import funkin.play.character.CharacterData.CharacterDataParser; +import funkin.play.character.SparrowCharacter; +import haxe.ui.RuntimeComponentBuilder; +import haxe.ui.components.DropDown; +import haxe.ui.core.Component; +import haxe.ui.events.ItemEvent; +import haxe.ui.events.UIEvent; import lime.utils.Assets as LimeAssets; import openfl.Assets; import openfl.events.Event; @@ -63,10 +68,37 @@ class DebugBoundingState extends FlxState var onionSkinChar:FlxSprite; var txtOffsetShit:FlxText; + var uiStuff:Component; + override function create() { Paths.setCurrentLevel('week1'); + var str = Paths.xml('ui/offset-editor-view'); + uiStuff = RuntimeComponentBuilder.fromAsset(str); + + // uiStuff.findComponent("btnViewSpriteSheet").onClick = _ -> curView = SPRITESHEET; + var dropdown:DropDown = cast uiStuff.findComponent("swapper"); + dropdown.onChange = function(e:UIEvent) + { + trace(e.type); + curView = cast e.data.curView; + trace(e.data); + // trace(e.data); + }; + // lv. + // lv.onChange = function(e:UIEvent) + // { + // trace(e.type); + // // trace(e.data.curView); + // // var item:haxe.ui.core.ItemRenderer = cast e.target; + // trace(e.target); + // // if (e.type == "change") + // // { + // // curView = cast e.data; + // // } + // }; + hudCam = new FlxCamera(); hudCam.bgColor.alpha = 0; @@ -86,6 +118,10 @@ class DebugBoundingState extends FlxState // charInput.cameras = [hudCam]; // charInput.scrollFactor.set(); + uiStuff.cameras = [hudCam]; + + add(uiStuff); + super.create(); } @@ -290,9 +326,16 @@ class DebugBoundingState extends FlxState override function update(elapsed:Float) { if (FlxG.keys.justPressed.ONE) + { + var lv:DropDown = cast uiStuff.findComponent("swapper"); + lv.selectedIndex = 0; curView = SPRITESHEET; + } + if (FlxG.keys.justReleased.TWO) { + var lv:DropDown = cast uiStuff.findComponent("swapper"); + lv.selectedIndex = 1; curView = OFFSETSHIT; if (swagChar != null) { @@ -528,8 +571,8 @@ class DebugBoundingState extends FlxState } } -enum ANIMDEBUGVIEW +enum abstract ANIMDEBUGVIEW(String) { - SPRITESHEET; - OFFSETSHIT; + var SPRITESHEET; + var OFFSETSHIT; } From 43b952b321b0a47b98ea1e00d92aa3ac2e5b9b0a Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Thu, 8 Sep 2022 16:39:31 -0400 Subject: [PATCH 25/25] char input haxeUI stuff --- .../ui/animDebugShit/DebugBoundingState.hx | 32 +++++++------------ 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/source/funkin/ui/animDebugShit/DebugBoundingState.hx b/source/funkin/ui/animDebugShit/DebugBoundingState.hx index f92e38d67..cf28d23da 100644 --- a/source/funkin/ui/animDebugShit/DebugBoundingState.hx +++ b/source/funkin/ui/animDebugShit/DebugBoundingState.hx @@ -56,8 +56,6 @@ class DebugBoundingState extends FlxState var hudCam:FlxCamera; - var charInput:FlxUIDropDownMenu; - var curView:ANIMDEBUGVIEW = SPRITESHEET; var spriteSheetView:FlxGroup; @@ -113,11 +111,6 @@ class DebugBoundingState extends FlxState initSpritesheetView(); initOffsetView(); - // charInput = new FlxInputText(300, 10, 150, "bf", 16); - // charInput.focusCam = hudCam; - // charInput.cameras = [hudCam]; - // charInput.scrollFactor.set(); - uiStuff.cameras = [hudCam]; add(uiStuff); @@ -258,15 +251,16 @@ class DebugBoundingState extends FlxState var characters:Array = CoolUtil.coolTextFile(Paths.txt('characterList')); - // charInput isnt only exclusive to offsetView shit now - charInput = new FlxUIDropDownMenu(500, 20, FlxUIDropDownMenu.makeStrIdLabelArray(characters, true), function(str:String) + var charDropdown:DropDown = cast uiStuff.findComponent('characterDropdown'); + for (char in characters) { - loadAnimShit(characters[Std.parseInt(str)]); - // trace(); - }); - // charInput. - charInput.cameras = [hudCam]; - add(charInput); + charDropdown.dataSource.add({text: char}); + } + + charDropdown.onChange = function(e:UIEvent) + { + loadAnimShit(e.data.text); + }; } public var mouseOffset:FlxPoint = FlxPoint.get(0, 0); @@ -361,11 +355,6 @@ class DebugBoundingState extends FlxState if (FlxG.keys.justPressed.H) hudCam.visible = !hudCam.visible; - /* if (charInput.hasFocus && FlxG.keys.justPressed.ENTER) - { - loadAnimShit(); - }*/ - CoolUtil.mouseCamDrag(); CoolUtil.mouseWheelZoom(); @@ -480,6 +469,9 @@ class DebugBoundingState extends FlxState var swagChar:BaseCharacter; + /* + Called when animation dropdown is changed! + */ function loadAnimShit(char:String) { if (swagChar != null)