Skip to content

Commit

Permalink
freeplay frame data/delays export
Browse files Browse the repository at this point in the history
  • Loading branch information
KoloInDaCrib committed Nov 26, 2024
1 parent 4332853 commit 6495373
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 15 deletions.
2 changes: 1 addition & 1 deletion assets
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class FreeplayDJSettingsDialog extends DefaultPageDialog
var data = daPage.data;

var currentChar = PlayerRegistry.instance.fetchEntry(data.importedPlayerData);
if (currentChar != null)
if (currentChar?.getFreeplayDJData() != null)
{
bgTextField1.value = currentChar.getFreeplayDJText(1);
bgTextField2.value = currentChar.getFreeplayDJText(2);
Expand All @@ -47,8 +47,15 @@ class FreeplayDJSettingsDialog extends DefaultPageDialog
loopEndFrame.pos = currentChar.getFreeplayDJData().getFistPumpLoopEndFrame();
introBadStartFrame.pos = currentChar.getFreeplayDJData().getFistPumpIntroBadStartFrame();
introBadEndFrame.pos = currentChar.getFreeplayDJData().getFistPumpIntroBadEndFrame();
loopBadStartFrame.pos = currentChar.getFreeplayDJData()?.getFistPumpLoopBadStartFrame();
loopBadEndFrame.pos = currentChar.getFreeplayDJData()?.getCharSelectTransitionDelay();
loopBadStartFrame.pos = currentChar.getFreeplayDJData().getFistPumpLoopBadStartFrame();
loopBadEndFrame.pos = currentChar.getFreeplayDJData().getCharSelectTransitionDelay();

charSelectTransitionDelay.pos = currentChar.getFreeplayDJData().getCharSelectTransitionDelay();
soundClickFrame.pos = currentChar.getFreeplayDJData().getCartoonSoundClickFrame();
soundCartoonFrame.pos = currentChar.getFreeplayDJData().getCartoonSoundCartoonFrame();
loopBlinkFrame.pos = currentChar.getFreeplayDJData().getCartoonLoopBlinkFrame();
loopFrame.pos = currentChar.getFreeplayDJData().getCartoonLoopFrame();
channelChangeFrame.pos = currentChar.getFreeplayDJData().getCartoonChannelChangeFrame();
}

bgTextField1.onChange = bgTextField2.onChange = bgTextField3.onChange = _ -> daPage.updateScrollingTexts();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package funkin.ui.debug.char.handlers;

import haxe.io.Path;
import funkin.data.character.CharacterRegistry;
import funkin.ui.debug.char.components.dialogs.freeplay.FreeplayDJSettingsDialog;
import funkin.ui.debug.char.pages.CharCreatorGameplayPage;
import funkin.ui.debug.char.pages.CharCreatorSelectPage;
import funkin.ui.debug.char.pages.CharCreatorFreeplayPage;
Expand Down Expand Up @@ -62,12 +63,15 @@ class CharCreatorImportExportHandler
{
// no check needed there's no zip files in assets folder

for (file in FileUtil.readZIPFromBytes(gameplayPage.currentCharacter.files[0].bytes))
if (gameplayPage.currentCharacter.files.length > 0)
{
var zipName = gameplayPage.currentCharacter.files[0].name.replace(".zip", "");
for (file in FileUtil.readZIPFromBytes(gameplayPage.currentCharacter.files[0].bytes))
{
var zipName = gameplayPage.currentCharacter.files[0].name.replace(".zip", "");

zipEntries.push(FileUtil.makeZIPEntryFromBytes('images/characters/${Path.withoutDirectory(zipName)}/${Path.withoutDirectory(file.fileName)}',
file.data));
zipEntries.push(FileUtil.makeZIPEntryFromBytes('images/characters/${Path.withoutDirectory(zipName)}/${Path.withoutDirectory(file.fileName)}',
file.data));
}
}
}

Expand Down Expand Up @@ -113,16 +117,23 @@ class CharCreatorImportExportHandler
// zipEntries.push(FileUtil.makeZIPEntryFromBytes('images/freeplay/icons/${Path.withoutDirectory(file.name)}', file.bytes));
// }

var charSelectZipName = Path.withoutDirectory(selectPage.data.charSelectFile.name.replace(".zip", ""));
for (file in FileUtil.readZIPFromBytes(selectPage.data.charSelectFile.bytes))
if (selectPage.data.charSelectFile != null)
{
zipEntries.push(FileUtil.makeZIPEntryFromBytes('images/charSelect/${charSelectZipName}/${Path.withoutDirectory(file.fileName)}', file.data));
var charSelectZipName = Path.withoutDirectory(selectPage.data.charSelectFile.name.replace(".zip", ""));
for (file in FileUtil.readZIPFromBytes(selectPage.data.charSelectFile.bytes))
{
zipEntries.push(FileUtil.makeZIPEntryFromBytes('images/charSelect/${charSelectZipName}/${Path.withoutDirectory(file.fileName)}', file.data));
}
}

var freeplayDJZipName = Path.withoutDirectory(freeplayPage.data.freeplayFile.name.replace(".zip", ""));
for (file in FileUtil.readZIPFromBytes(freeplayPage.data.freeplayFile.bytes))
var freeplayDJZipName = Path.withoutDirectory(freeplayPage.loadedSprFreeplayPath);
if (freeplayPage.data.freeplayFile != null)
{
zipEntries.push(FileUtil.makeZIPEntryFromBytes('images/freeplay/${freeplayDJZipName}/${Path.withoutDirectory(file.fileName)}', file.data));
freeplayDJZipName = Path.withoutDirectory(freeplayPage.data.freeplayFile.name.replace(".zip", ""));
for (file in FileUtil.readZIPFromBytes(freeplayPage.data.freeplayFile.bytes))
{
zipEntries.push(FileUtil.makeZIPEntryFromBytes('images/freeplay/${freeplayDJZipName}/${Path.withoutDirectory(file.fileName)}', file.data));
}
}

var playerData:PlayerData = new PlayerData();
Expand All @@ -139,6 +150,35 @@ class CharCreatorImportExportHandler
playerData.freeplayDJ.text2 = freeplayPage.bgText2;
playerData.freeplayDJ.text3 = freeplayPage.bgText3;
playerData.freeplayDJ.animations = freeplayPage.djAnims.copy();

var pageDialog:FreeplayDJSettingsDialog = cast freeplayPage.dialogMap[FreeplayDJSettings];

// this code gives me an eyesore
playerData.freeplayDJ.fistPump =
{
introStartFrame: Std.int(pageDialog.introStartFrame.pos),
introEndFrame: Std.int(pageDialog.introEndFrame.pos),
loopStartFrame: Std.int(pageDialog.loopStartFrame.pos),
loopEndFrame: Std.int(pageDialog.loopEndFrame.pos),
introBadStartFrame: Std.int(pageDialog.introBadStartFrame.pos),
introBadEndFrame: Std.int(pageDialog.introBadEndFrame.pos),
loopBadStartFrame: Std.int(pageDialog.loopBadStartFrame.pos),
loopBadEndFrame: Std.int(pageDialog.loopBadEndFrame.pos)
}

playerData.freeplayDJ.charSelect =
{
transitionDelay: pageDialog.charSelectTransitionDelay.pos
}

playerData.freeplayDJ.cartoon =
{
soundClickFrame: Std.int(pageDialog.soundClickFrame.pos),
soundCartoonFrame: Std.int(pageDialog.soundCartoonFrame.pos),
loopBlinkFrame: Std.int(pageDialog.loopBlinkFrame.pos),
loopFrame: Std.int(pageDialog.loopFrame.pos),
channelChangeFrame: Std.int(pageDialog.channelChangeFrame.pos)
}
}

playerData.charSelect = new PlayerCharSelectData(selectPage.position);
Expand Down
6 changes: 5 additions & 1 deletion source/funkin/ui/debug/char/pages/CharCreatorFreeplayPage.hx
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class CharCreatorFreeplayPage extends CharCreatorDefaultPage
var dialogMap:Map<FreeplayDialogType, DefaultPageDialog>;

var data:WizardGenerateParams;
var loadedSprFreeplayPath:String = ""; // failsafe for when we're importing data instead of creating it

public var useStyle:Null<String> = null;
public var customStyleData:FreeplayStyleData =
Expand Down Expand Up @@ -106,7 +107,10 @@ class CharCreatorFreeplayPage extends CharCreatorDefaultPage
if (playuh != null)
{
@:privateAccess
djAnims = playuh.getFreeplayDJData().animations.copy();
{
loadedSprFreeplayPath = playuh.getFreeplayDJData().assetPath;
djAnims = playuh.getFreeplayDJData().animations.copy();
}

playDJAnimation();

Expand Down

0 comments on commit 6495373

Please sign in to comment.