Refactor char select GF data handling.

This commit is contained in:
EliteMasterEric 2024-09-19 04:16:40 -04:00
parent 99657da1f9
commit 9f0bc2bd52
4 changed files with 36 additions and 28 deletions

2
assets

@ -1 +1 @@
Subproject commit bc7009b4242691faa5c4552f7ca8a2f28e8cb1d2
Subproject commit 4f7e8bb5cd2e9eb8f68d88c060e9cbe5bccc9e2f

View file

@ -269,7 +269,20 @@ class PlayerCharSelectData
* The GF name to assign for this character.
*/
@:optional
public var assignedGF:Null<String>;
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 =

View file

@ -28,7 +28,8 @@ class CharSelectGF extends FlxAtlasSprite implements IBPMSyncedScriptedClass
var analyzer:SpectralAnalyzer;
var curGF:String = "gf";
var currentGFPath:Null<String>;
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";
}*/

View file

@ -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)