Skip to content

Commit

Permalink
yay finished multisparrow i think
Browse files Browse the repository at this point in the history
  • Loading branch information
lemz1 committed Oct 31, 2024
1 parent b20e2c8 commit 4defc11
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 23 deletions.
33 changes: 13 additions & 20 deletions source/funkin/ui/debug/char/CharCreatorCharacter.hx
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,19 @@ class CharCreatorCharacter extends Bopper
switch (generatedParams.renderType)
{
case "sparrow" | "multisparrow":
if (generatedParams.files.length != 2) return; // img and data

var img = BitmapData.fromBytes(generatedParams.files[0].bytes);
var data = generatedParams.files[1].bytes.toString();
this.frames = FlxAtlasFrames.fromSparrow(img, data);
if (generatedParams.files.length < 2) return; // img and data

var combinedFrames = null;
for (i in 0...Math.floor(generatedParams.files.length / 2))
{
var img = BitmapData.fromBytes(generatedParams.files[i * 2].bytes);
var data = generatedParams.files[i * 2 + 1].bytes.toString();
var sparrow = FlxAtlasFrames.fromSparrow(img, data);
if (combinedFrames == null) combinedFrames = sparrow;
else
combinedFrames.addAtlas(sparrow);
}
this.frames = combinedFrames;

case "packer":
if (generatedParams.files.length != 2) return; // img and data
Expand Down Expand Up @@ -113,26 +121,11 @@ class CharCreatorCharacter extends Bopper
}
}

var multiSparrowFrames:Map<String, FlxAtlasFrames> = [];

public function addAnimation(name:String, prefix:String, offsets:Array<Float>, indices:Array<Int>, animPath:String = "", frameRate:Int = 24,
looped:Bool = false, flipX:Bool = false, flipY:Bool = false)
{
if (getAnimationData(name) != null) return true; // i mean i guess???

if (renderType == "multisparrow" && !multiSparrowFrames.exists(animPath))
{
var daFrames:FlxAtlasFrames = Paths.getSparrowAtlas(animPath);
if (daFrames == null) return false;

multiSparrowFrames.set(animPath, daFrames);

for (frame in daFrames.frames)
{
this.frames.pushFrame(frame);
}
}

if (renderType != "atlas")
{
if (indices.length > 0) animation.addByIndices(name, prefix, indices, "", frameRate, looped, flipX, flipY);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class AddAnimDialog extends DefaultPageDialog
charAnimFrames.disabled = charAnimPath.disabled = charAnimFlipX.disabled = charAnimFlipY.disabled = charAnimFramerate.disabled = (char.renderType == "atlas");
charAnimFrames.tooltip = charAnimPath.tooltip = charAnimFlipX.tooltip = charAnimFlipY.tooltip = charAnimFramerate.tooltip = (char.renderType == "atlas" ? "Unavailable for Atlas Characters." : null);

if (char.renderType != "multisparrow")
if (char.renderType != "atlas")
{
charAnimFrameList.dataSource = new ArrayDataSource();
for (fname in char.frames.frames)
Expand Down Expand Up @@ -78,7 +78,7 @@ class AddAnimDialog extends DefaultPageDialog
if (!animAdded) return;

char.setAnimationOffsets(charAnimName.text, charAnimOffsetX.pos, charAnimOffsetY.pos);
char.playAnimation(charAnimName.text, true, true);
char.playAnimation(charAnimName.text);

updateDropdown();
charAnimDropdown.selectedIndex = charAnimDropdown.dataSource.size - 1;
Expand Down
4 changes: 3 additions & 1 deletion source/funkin/ui/debug/char/pages/CharCreatorGameplayPage.hx
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ class CharCreatorGameplayPage extends CharCreatorDefaultPage
var id = drop.selectedIndex + 1;
if (id >= drop.dataSource.size) id = 0;
drop.selectedIndex = id;
currentCharacter.playAnimation(currentCharacter.animations[drop.selectedIndex].name);
}

labelAnimName.onRightClick = function(_) {
Expand All @@ -165,6 +166,7 @@ class CharCreatorGameplayPage extends CharCreatorDefaultPage
var id = drop.selectedIndex - 1;
if (id < 0) id = drop.dataSource.size - 1;
drop.selectedIndex = id;
currentCharacter.playAnimation(currentCharacter.animations[drop.selectedIndex].name);
}

labelAnimOffsetX.onClick = _ -> changeCharAnimOffset(5);
Expand Down Expand Up @@ -203,7 +205,7 @@ class CharCreatorGameplayPage extends CharCreatorDefaultPage

currentCharacter.animations[drop.selectedIndex].offsets = newOffsets;
currentCharacter.setAnimationOffsets(currentCharacter.animations[drop.selectedIndex].name, newOffsets[0], newOffsets[1]); // todo: probs merge there two lol
currentCharacter.playAnimation(currentCharacter.animations[drop.selectedIndex].name, true, true);
currentCharacter.playAnimation(currentCharacter.animations[drop.selectedIndex].name);

// GhostUtil.copyFromCharacter(ghostCharacter, currentCharacter); very costly for memory! we're just gonna update the offsets
ghostCharacter.animations[drop.selectedIndex].offsets = newOffsets;
Expand Down

0 comments on commit 4defc11

Please sign in to comment.