Skip to content

Commit

Permalink
freeplay style export
Browse files Browse the repository at this point in the history
  • Loading branch information
KoloInDaCrib committed Nov 18, 2024
1 parent 2be51f8 commit 31ce73f
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,41 +119,74 @@ class FreeplayStyleDialog extends DefaultPageDialog
daPage.arrowRight.animation.play('shine');

daPage.randomCapsule.applyStyle(daStyle);
daPage.useStyle = styleID;
}
else if (optionMakeNew.selected)
{
var dadBitmap = BitmapData.fromBytes(CharCreatorUtil.gimmeTheBytes(fieldBGAsset.text?.length > 0 ? fieldBGAsset.text : Paths.image('freeplay/freeplayBGdad')));
var arrowBitmap = BitmapData.fromBytes(CharCreatorUtil.gimmeTheBytes(fieldArrow.text?.length > 0 ? fieldArrow.text : Paths.image('freeplay/freeplaySelector')));
var capsuleBitmap = BitmapData.fromBytes(CharCreatorUtil.gimmeTheBytes(fieldCapsule.text?.length > 0 ? fieldCapsule.text : Paths.image('freeplay/freeplayCapsule/capsule/freeplayCapsule')));

var arrowXML = CharCreatorUtil.gimmeTheBytes(fieldArrow.text.replace(".png", ".xml"))?.toString() ?? Paths.file("images/freeplay/freeplaySelector.xml");
var capsuleXML = CharCreatorUtil.gimmeTheBytes(fieldCapsule.text.replace(".png",
".xml"))?.toString() ?? Paths.file("images/freeplay/freeplayCapsule/capsule/freeplayCapsule.xml");
var arrowXML = CharCreatorUtil.gimmeTheBytes(fieldArrow.text.replace(".png", ".xml"));
var capsuleXML = CharCreatorUtil.gimmeTheBytes(fieldCapsule.text.replace(".png", ".xml"));

daPage.bgDad.loadGraphic(dadBitmap);

daPage.arrowLeft.frames = daPage.arrowRight.frames = FlxAtlasFrames.fromSparrow(arrowBitmap, arrowXML);
daPage.arrowLeft.frames = daPage.arrowRight.frames = FlxAtlasFrames.fromSparrow(arrowBitmap,
arrowXML?.toString() ?? Paths.file("images/freeplay/freeplaySelector.xml"));

daPage.arrowLeft.animation.addByPrefix('shine', 'arrow pointer loop', 24);
daPage.arrowRight.animation.addByPrefix('shine', 'arrow pointer loop', 24);
daPage.arrowLeft.animation.play('shine');
daPage.arrowRight.animation.play('shine');

// overcomplicating capsule stuff
daPage.randomCapsule.capsule.frames = FlxAtlasFrames.fromSparrow(capsuleBitmap, capsuleXML);
daPage.randomCapsule.capsule.frames = FlxAtlasFrames.fromSparrow(capsuleBitmap,
capsuleXML?.toString() ?? Paths.file("images/freeplay/freeplayCapsule/capsule/freeplayCapsule.xml"));
daPage.randomCapsule.capsule.animation.addByPrefix('selected', 'mp3 capsule w backing0', 24);
daPage.randomCapsule.capsule.animation.addByPrefix('unselected', 'mp3 capsule w backing NOT SELECTED', 24);

var selectColor:Color = selectPicker.selectedItem != null ? cast(selectPicker.selectedItem) : Color.fromString("#00ccff");
var deselectColor:Color = deselectPicker.selectedItem != null ? cast(deselectPicker.selectedItem) : Color.fromString("#00ccff");

@:privateAccess
{
var compColor:Color = selectPicker.selectedItem != null ? cast(selectPicker.selectedItem) : Color.fromString("white");
daPage.randomCapsule.songText.glowColor = FlxColor.fromRGB(compColor.r, compColor.g, compColor.b);
daPage.randomCapsule.songText.glowColor = FlxColor.fromRGB(selectColor.r, selectColor.g, selectColor.b);
daPage.randomCapsule.songText.blurredText.color = daPage.randomCapsule.songText.glowColor;

daPage.randomCapsule.songText.whiteText.textField.filters = [
new openfl.filters.GlowFilter(daPage.randomCapsule.songText.glowColor, 1, 5, 5, 210, openfl.filters.BitmapFilterQuality.MEDIUM),
];
}

daPage.useStyle = null;

daPage.customStyleData.bgAsset = 'freeplay/freeplayBGdad' + (fieldBGAsset.text?.length > 0 ? '_${daPage.data.characterID}' : "");
daPage.customStyleData.selectorAsset = 'freeplay/freeplaySelector' + (fieldArrow.text?.length > 0 ? '_${daPage.data.characterID}' : "");
daPage.customStyleData.capsuleAsset = 'freeplay/freeplayCapsule/capsule/freeplayCapsule'
+ (fieldCapsule.text?.length > 0 ? '_${daPage.data.characterID}' : "");
daPage.customStyleData.capsuleTextColors = [deselectColor.toHex(), selectColor.toHex()];
daPage.customStyleData.startDelay = delayStepper.pos;

daPage.styleFiles = [];
if (daPage.customStyleData.bgAsset != 'freeplay/freeplayBGdad')
{
daPage.styleFiles.push(
{
name: '${daPage.customStyleData.bgAsset}.png',
bytes: dadBitmap.image.encode(PNG)
});
}
if (daPage.customStyleData.selectorAsset != 'freeplay/freeplaySelector')
{
daPage.styleFiles.push({name: '${daPage.customStyleData.selectorAsset}.png', bytes: arrowBitmap.image.encode(PNG)});
daPage.styleFiles.push({name: '${daPage.customStyleData.selectorAsset}.xml', bytes: arrowXML});
}
if (daPage.customStyleData.capsuleAsset != 'freeplay/freeplayCapsule/capsule/freeplayCapsule')
{
daPage.styleFiles.push({name: '${daPage.customStyleData.capsuleAsset}.png', bytes: capsuleBitmap.image.encode(PNG)});
daPage.styleFiles.push({name: '${daPage.customStyleData.capsuleAsset}.xml', bytes: capsuleXML});
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import funkin.ui.debug.char.pages.CharCreatorSelectPage;
import funkin.ui.debug.char.pages.CharCreatorFreeplayPage;
import funkin.ui.debug.char.CharCreatorState;
import funkin.data.freeplay.player.PlayerData;
import funkin.data.freeplay.style.FreeplayStyleData;
import funkin.util.FileUtil;

using StringTools;
Expand Down Expand Up @@ -115,7 +116,7 @@ class CharCreatorImportExportHandler
playerData.name = "Unknown";
playerData.ownedChars = selectPage.ownedCharacters;
playerData.showUnownedChars = false;
playerData.freeplayStyle = "bf";
playerData.freeplayStyle = freeplayPage.useStyle ?? charID;

@:privateAccess
{
Expand All @@ -131,5 +132,14 @@ class CharCreatorImportExportHandler

zipEntries.push(FileUtil.makeZIPEntry('data/players/${charID}.json', playerData.serialize()));
if (selectPage.nametagFile != null) zipEntries.push(FileUtil.makeZIPEntryFromBytes('images/charSelect${charID}Nametag.png', selectPage.nametagFile.bytes));

if (freeplayPage.useStyle == null)
{
zipEntries.push(FileUtil.makeZIPEntry('data/ui/styles/${charID}.json',
new json2object.JsonWriter<FreeplayStyleData>().write(freeplayPage.customStyleData, ' ')));

for (file in freeplayPage.styleFiles)
zipEntries.push(FileUtil.makeZIPEntryFromBytes('images/${file.name}', file.bytes));
}
}
}
16 changes: 16 additions & 0 deletions source/funkin/ui/debug/char/pages/CharCreatorFreeplayPage.hx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import funkin.ui.freeplay.FreeplayState.DifficultySprite;
import funkin.ui.debug.char.components.dialogs.*;
import funkin.graphics.FunkinSprite;
import funkin.ui.freeplay.FreeplayStyle;
import funkin.data.freeplay.style.FreeplayStyleData;
import funkin.data.freeplay.style.FreeplayStyleRegistry;
import funkin.graphics.shaders.AngleMask;
import funkin.graphics.shaders.Grayscale;
Expand Down Expand Up @@ -57,6 +58,19 @@ class CharCreatorFreeplayPage extends CharCreatorDefaultPage

var data:WizardGenerateParams;

public var useStyle:Null<String> = null;
public var customStyleData:FreeplayStyleData =
{
version: FreeplayStyleRegistry.FREEPLAYSTYLE_DATA_VERSION,
bgAsset: 'freeplay/freeplayBGdad',
selectorAsset: 'freeplay/freeplaySelector',
numbersAsset: "digital_numbers",
capsuleAsset: "freeplay/freeplayCapsule/capsule/freeplayCapsule",
capsuleTextColors: ["#00ccff", "#00ccff"],
startDelay: 1.0
}
public var styleFiles:Array<WizardFile> = [];

override public function new(state:CharCreatorState, data:WizardGenerateParams)
{
super(state);
Expand Down Expand Up @@ -224,6 +238,8 @@ class CharCreatorFreeplayPage extends CharCreatorDefaultPage
var currentChar = PlayerRegistry.instance.fetchEntry(data.importedPlayerData);
var stylishSunglasses = FreeplayStyleRegistry.instance.fetchEntry(currentChar?.getFreeplayStyleID() ?? "");

if (stylishSunglasses != null) useStyle = currentChar.getFreeplayStyleID();

bgDad = new FlxSprite(pinkBack.width * 0.74)
.loadGraphic(stylishSunglasses == null ? Paths.image('freeplay/freeplayBGdad') : stylishSunglasses.getBgAssetGraphic());
bgDad.setGraphicSize(0, FlxG.height);
Expand Down

0 comments on commit 31ce73f

Please sign in to comment.