From a4b59d14bf34270bf04520320eabf3f11b5f2d29 Mon Sep 17 00:00:00 2001 From: Kolo <67389779+JustKolosaki@users.noreply.github.com> Date: Wed, 18 Sep 2024 13:40:02 +0200 Subject: [PATCH 1/6] applySongRank fix fixes the bug with the percent being overriden when the song has the same letter rank but lower percent (eg. E Rank with 99% being overriden by E Rank with 93%) --- source/funkin/save/Save.hx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/source/funkin/save/Save.hx b/source/funkin/save/Save.hx index 2bbda15c0..74af9994e 100644 --- a/source/funkin/save/Save.hx +++ b/source/funkin/save/Save.hx @@ -598,11 +598,15 @@ class Save return; } + //percent also accounts for different ranks + var oldPerc = (previousScoreData.tallies.sick + previousScoreData.tallies.good) / previousScoreData.tallies.totalNotes; + var newPerc = (newScoreData.tallies.sick + newScoreData.tallies.good) / newScoreData.tallies.totalNotes; + // Set the high score and the high rank separately. var newScore:SaveScoreData = { - score: (previousScoreData.score > newScoreData.score) ? previousScoreData.score : newScoreData.score, - tallies: (previousRank > newRank) ? previousScoreData.tallies : newScoreData.tallies + score: Std.int(Math.max(previousScoreData.score, newScoreData.score)), + tallies: (oldPerc > newPerc ? previousScoreData.tallies : newScoreData.tallies) }; song.set(difficultyId, newScore); From 50a5304ad48b210cba62e8bc756b417b3c69cc96 Mon Sep 17 00:00:00 2001 From: Kolo <67389779+JustKolosaki@users.noreply.github.com> Date: Wed, 18 Sep 2024 17:30:23 +0200 Subject: [PATCH 2/6] Update PlayerData.hx --- source/funkin/data/freeplay/player/PlayerData.hx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/source/funkin/data/freeplay/player/PlayerData.hx b/source/funkin/data/freeplay/player/PlayerData.hx index de293c24e..a5bf086f6 100644 --- a/source/funkin/data/freeplay/player/PlayerData.hx +++ b/source/funkin/data/freeplay/player/PlayerData.hx @@ -264,6 +264,12 @@ class PlayerCharSelectData */ @:optional public var position:Null; + + /** + * The GF name to assign for this character. + */ + @:optional + public var assignedGF:Null; } typedef PlayerResultsData = From 3bb981adb03371e1be5034d7997dc5135a7d8f04 Mon Sep 17 00:00:00 2001 From: Kolo <67389779+JustKolosaki@users.noreply.github.com> Date: Wed, 18 Sep 2024 17:32:37 +0200 Subject: [PATCH 3/6] Update CharSelectGF.hx --- source/funkin/ui/charSelect/CharSelectGF.hx | 37 ++++++++++++--------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/source/funkin/ui/charSelect/CharSelectGF.hx b/source/funkin/ui/charSelect/CharSelectGF.hx index e8eeded40..79cfb585c 100644 --- a/source/funkin/ui/charSelect/CharSelectGF.hx +++ b/source/funkin/ui/charSelect/CharSelectGF.hx @@ -11,6 +11,7 @@ import funkin.modding.IScriptedClass.IBPMSyncedScriptedClass; import flixel.math.FlxMath; import funkin.modding.events.ScriptEvent; import funkin.vis.dsp.SpectralAnalyzer; +import funkin.data.freeplay.player.PlayerRegistry; class CharSelectGF extends FlxAtlasSprite implements IBPMSyncedScriptedClass { @@ -27,7 +28,7 @@ class CharSelectGF extends FlxAtlasSprite implements IBPMSyncedScriptedClass var analyzer:SpectralAnalyzer; - var curGF:GFChar = GF; + var curGF:String = "gf"; public function new() { @@ -97,7 +98,7 @@ class CharSelectGF extends FlxAtlasSprite implements IBPMSyncedScriptedClass function drawFFT() { - if (curGF == NENE) + if (curGF == "nene") { var levels = analyzer.getLevels(); var frame = anim.curSymbol.timeline.get("VIZ_bars").get(anim.curFrame); @@ -172,16 +173,21 @@ class CharSelectGF extends FlxAtlasSprite implements IBPMSyncedScriptedClass */ public function switchGF(bf:String):Void { - var prevGF:GFChar = curGF; - switch (bf) - { - case "pico": - curGF = NENE; - case "bf": - curGF = GF; - default: - curGF = GF; - } + var prevGF = curGF; + + var bfObj = PlayerRegistry.instance.fetchEntry(bf); + curGF = bfObj?.getCharSelectData()?.assignedGF ?? "gf"; + + /*var prevGF:GFChar = curGF; + switch (bf) + { + case "pico": + curGF = NENE; + case "bf": + curGF = GF; + default: + curGF = GF; + }*/ // We don't need to update any anims if we didn't change GF if (prevGF != curGF) @@ -213,9 +219,8 @@ enum FadeStatus FADE_OUT; FADE_IN; } - -enum abstract GFChar(String) from String to String -{ +/*enum abstract GFChar(String) from String to String + { var GF = "gf"; var NENE = "nene"; -} +}*/ From 99657da1f984ff5842d714b2cde398cca6785e06 Mon Sep 17 00:00:00 2001 From: Kolo <67389779+JustKolosaki@users.noreply.github.com> Date: Wed, 18 Sep 2024 17:46:13 +0200 Subject: [PATCH 4/6] accidentally also put the save changes oops --- source/funkin/save/Save.hx | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/source/funkin/save/Save.hx b/source/funkin/save/Save.hx index 74af9994e..2bbda15c0 100644 --- a/source/funkin/save/Save.hx +++ b/source/funkin/save/Save.hx @@ -598,15 +598,11 @@ class Save return; } - //percent also accounts for different ranks - var oldPerc = (previousScoreData.tallies.sick + previousScoreData.tallies.good) / previousScoreData.tallies.totalNotes; - var newPerc = (newScoreData.tallies.sick + newScoreData.tallies.good) / newScoreData.tallies.totalNotes; - // Set the high score and the high rank separately. var newScore:SaveScoreData = { - score: Std.int(Math.max(previousScoreData.score, newScoreData.score)), - tallies: (oldPerc > newPerc ? previousScoreData.tallies : newScoreData.tallies) + score: (previousScoreData.score > newScoreData.score) ? previousScoreData.score : newScoreData.score, + tallies: (previousRank > newRank) ? previousScoreData.tallies : newScoreData.tallies }; song.set(difficultyId, newScore); From 9f0bc2bd521f274f8ad9d214966538d95894277a Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Thu, 19 Sep 2024 04:16:40 -0400 Subject: [PATCH 5/6] Refactor char select GF data handling. --- assets | 2 +- .../funkin/data/freeplay/player/PlayerData.hx | 15 +++++- source/funkin/ui/charSelect/CharSelectGF.hx | 46 +++++++++---------- .../ui/charSelect/CharSelectSubState.hx | 1 - 4 files changed, 36 insertions(+), 28 deletions(-) diff --git a/assets b/assets index bc7009b42..4f7e8bb5c 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit bc7009b4242691faa5c4552f7ca8a2f28e8cb1d2 +Subproject commit 4f7e8bb5cd2e9eb8f68d88c060e9cbe5bccc9e2f diff --git a/source/funkin/data/freeplay/player/PlayerData.hx b/source/funkin/data/freeplay/player/PlayerData.hx index a5bf086f6..9110854c8 100644 --- a/source/funkin/data/freeplay/player/PlayerData.hx +++ b/source/funkin/data/freeplay/player/PlayerData.hx @@ -269,7 +269,20 @@ class PlayerCharSelectData * The GF name to assign for this character. */ @:optional - public var assignedGF:Null; + public var gf:PlayerCharSelectGFData; +} + +typedef PlayerCharSelectGFData = +{ + @:optional + public var assetPath:String; + + @:optional + public var animInfoPath:String; + + @:optional + @:default(false) + public var visualizer:Bool; } typedef PlayerResultsData = diff --git a/source/funkin/ui/charSelect/CharSelectGF.hx b/source/funkin/ui/charSelect/CharSelectGF.hx index 79cfb585c..89fc6deb0 100644 --- a/source/funkin/ui/charSelect/CharSelectGF.hx +++ b/source/funkin/ui/charSelect/CharSelectGF.hx @@ -28,7 +28,8 @@ class CharSelectGF extends FlxAtlasSprite implements IBPMSyncedScriptedClass var analyzer:SpectralAnalyzer; - var curGF:String = "gf"; + var currentGFPath:Null; + var enableVisualizer:Bool = false; public function new() { @@ -98,7 +99,7 @@ class CharSelectGF extends FlxAtlasSprite implements IBPMSyncedScriptedClass function drawFFT() { - if (curGF == "nene") + if (enableVisualizer) { var levels = analyzer.getLevels(); var frame = anim.curSymbol.timeline.get("VIZ_bars").get(anim.curFrame); @@ -173,33 +174,33 @@ class CharSelectGF extends FlxAtlasSprite implements IBPMSyncedScriptedClass */ public function switchGF(bf:String):Void { - var prevGF = curGF; + var previousGFPath = currentGFPath; var bfObj = PlayerRegistry.instance.fetchEntry(bf); - curGF = bfObj?.getCharSelectData()?.assignedGF ?? "gf"; - - /*var prevGF:GFChar = curGF; - switch (bf) - { - case "pico": - curGF = NENE; - case "bf": - curGF = GF; - default: - curGF = GF; - }*/ + var gfData = bfObj?.getCharSelectData()?.gf; + currentGFPath = gfData?.assetPath != null ? Paths.animateAtlas(gfData?.assetPath) : null; // We don't need to update any anims if we didn't change GF - if (prevGF != curGF) + trace('currentGFPath(${currentGFPath})'); + if (currentGFPath == null) { - loadAtlas(Paths.animateAtlas("charSelect/" + curGF + "Chill")); + this.visible = false; + return; + } + else if (previousGFPath != currentGFPath) + { + this.visible = true; + loadAtlas(currentGFPath); - animInInfo = FramesJSFLParser.parse(Paths.file("images/charSelect/" + curGF + "AnimInfo/" + curGF + "In.txt")); - animOutInfo = FramesJSFLParser.parse(Paths.file("images/charSelect/" + curGF + "AnimInfo/" + curGF + "Out.txt")); + enableVisualizer = gfData?.visualizer ?? false; + + var animInfoPath = Paths.file('images/${gfData?.animInfoPath}'); + + animInInfo = FramesJSFLParser.parse(animInfoPath + '/In.txt'); + animOutInfo = FramesJSFLParser.parse(animInfoPath + '/Out.txt'); } playAnimation("idle", true, false, false); - // addFrameCallback(getNextFrameLabel("idle"), () -> playAnimation("idle", true, false, false)); updateHitbox(); } @@ -219,8 +220,3 @@ enum FadeStatus FADE_OUT; FADE_IN; } -/*enum abstract GFChar(String) from String to String - { - var GF = "gf"; - var NENE = "nene"; -}*/ diff --git a/source/funkin/ui/charSelect/CharSelectSubState.hx b/source/funkin/ui/charSelect/CharSelectSubState.hx index 3109dc8f1..e7a87ade6 100644 --- a/source/funkin/ui/charSelect/CharSelectSubState.hx +++ b/source/funkin/ui/charSelect/CharSelectSubState.hx @@ -786,7 +786,6 @@ class CharSelectSubState extends MusicBeatSubState && availableChars.exists(getCurrentSelected()) && Save.instance.charactersSeen.contains(availableChars[getCurrentSelected()])) { - gfChill.visible = true; curChar = availableChars.get(getCurrentSelected()); if (!pressedSelect && controls.ACCEPT) From 78cde16af29f4f4ef5ef2cc3563592aeb1769528 Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Fri, 20 Sep 2024 18:10:47 -0400 Subject: [PATCH 6/6] assets submod --- assets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets b/assets index 4f7e8bb5c..2a0bc4f66 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit 4f7e8bb5cd2e9eb8f68d88c060e9cbe5bccc9e2f +Subproject commit 2a0bc4f66d79a6f590e7ed2c04884d8c1fa8c45e