From 64953739de3308f8b694aa1d04e7c9aeb4d4ecd0 Mon Sep 17 00:00:00 2001 From: Kolo <67389779+JustKolosaki@users.noreply.github.com> Date: Tue, 26 Nov 2024 20:33:31 +0100 Subject: [PATCH] freeplay frame data/delays export --- assets | 2 +- .../freeplay/FreeplayDJSettingsDialog.hx | 13 +++- .../CharCreatorImportExportHandler.hx | 60 +++++++++++++++---- .../char/pages/CharCreatorFreeplayPage.hx | 6 +- 4 files changed, 66 insertions(+), 15 deletions(-) diff --git a/assets b/assets index 1b62d26482..cc7ef64f59 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit 1b62d264829904b6d37198854617504d23164193 +Subproject commit cc7ef64f594bd280f72f5b74f2c56b32e77e9c7f diff --git a/source/funkin/ui/debug/char/components/dialogs/freeplay/FreeplayDJSettingsDialog.hx b/source/funkin/ui/debug/char/components/dialogs/freeplay/FreeplayDJSettingsDialog.hx index 8826fd672c..4232398f85 100644 --- a/source/funkin/ui/debug/char/components/dialogs/freeplay/FreeplayDJSettingsDialog.hx +++ b/source/funkin/ui/debug/char/components/dialogs/freeplay/FreeplayDJSettingsDialog.hx @@ -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); @@ -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(); diff --git a/source/funkin/ui/debug/char/handlers/CharCreatorImportExportHandler.hx b/source/funkin/ui/debug/char/handlers/CharCreatorImportExportHandler.hx index a9d9169965..eb3a29769a 100644 --- a/source/funkin/ui/debug/char/handlers/CharCreatorImportExportHandler.hx +++ b/source/funkin/ui/debug/char/handlers/CharCreatorImportExportHandler.hx @@ -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; @@ -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)); + } } } @@ -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(); @@ -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); diff --git a/source/funkin/ui/debug/char/pages/CharCreatorFreeplayPage.hx b/source/funkin/ui/debug/char/pages/CharCreatorFreeplayPage.hx index 987b545fea..14c133efb4 100644 --- a/source/funkin/ui/debug/char/pages/CharCreatorFreeplayPage.hx +++ b/source/funkin/ui/debug/char/pages/CharCreatorFreeplayPage.hx @@ -62,6 +62,7 @@ class CharCreatorFreeplayPage extends CharCreatorDefaultPage var dialogMap:Map; var data:WizardGenerateParams; + var loadedSprFreeplayPath:String = ""; // failsafe for when we're importing data instead of creating it public var useStyle:Null = null; public var customStyleData:FreeplayStyleData = @@ -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();