diff --git a/source/funkin/ui/debug/char/CharCreatorState.hx b/source/funkin/ui/debug/char/CharCreatorState.hx index 7803b5f2e3..8ccb71126c 100644 --- a/source/funkin/ui/debug/char/CharCreatorState.hx +++ b/source/funkin/ui/debug/char/CharCreatorState.hx @@ -100,12 +100,12 @@ class CharCreatorState extends UIState function setupUICallbacks() { menubarOptionGameplay.onChange = function(_) switchToPage(Gameplay); - menubarItemExport.onClick = _ -> exportCharacter(); + menubarItemExport.onClick = _ -> this.exportCharacter(); } function handleShortcuts():Void { - if (FlxG.keys.pressed.CONTROL && FlxG.keys.justPressed.S) exportCharacter(); + if (FlxG.keys.pressed.CONTROL && FlxG.keys.justPressed.S) this.exportCharacter(); } function wizardComplete(params:WizardGenerateParams) @@ -160,27 +160,6 @@ class CharCreatorState extends UIState selectedPage.fillUpBottomBar(bottomBarLeftBox, bottomBarMiddleBox, bottomBarRightBox); selectedPage.fillUpPageSettings(menubarMenuSettings); } - - function exportCharacter():Void - { - var gameplayPage:CharCreatorGameplayPage = cast pages[Gameplay]; - - var zipEntries = []; - zipEntries.push(FileUtil.makeZIPEntry('${gameplayPage.currentCharacter.characterId}.json', gameplayPage.currentCharacter.toJSON())); - - for (file in gameplayPage.currentCharacter.files) - { - // skip if the file is in a character path - if (CharCreatorUtil.isCharacterPath(file.name)) - { - continue; - } - - zipEntries.push(FileUtil.makeZIPEntryFromBytes('images/characters/${Path.withoutDirectory(file.name)}', file.bytes)); - } - - FileUtil.saveFilesAsZIP(zipEntries); - } } enum CharCreatorPage diff --git a/source/funkin/ui/debug/char/handlers/CharCreatorImportExportHandler.hx b/source/funkin/ui/debug/char/handlers/CharCreatorImportExportHandler.hx new file mode 100644 index 0000000000..279be82810 --- /dev/null +++ b/source/funkin/ui/debug/char/handlers/CharCreatorImportExportHandler.hx @@ -0,0 +1,33 @@ +package funkin.ui.debug.char.handlers; + +import haxe.io.Path; +import funkin.ui.debug.char.pages.CharCreatorGameplayPage; +import funkin.ui.debug.char.CharCreatorState; +import funkin.util.FileUtil; + +@:access(funkin.ui.debug.char.CharCreatorState) +class CharCreatorImportExportHandler +{ + public static function importCharacter(state:CharCreatorState):Void {} + + public static function exportCharacter(state:CharCreatorState):Void + { + var gameplayPage:CharCreatorGameplayPage = cast state.pages[Gameplay]; + + var zipEntries = []; + zipEntries.push(FileUtil.makeZIPEntry('${gameplayPage.currentCharacter.characterId}.json', gameplayPage.currentCharacter.toJSON())); + + for (file in gameplayPage.currentCharacter.files) + { + // skip if the file is in a character path + if (CharCreatorUtil.isCharacterPath(file.name)) + { + continue; + } + + zipEntries.push(FileUtil.makeZIPEntryFromBytes('images/characters/${Path.withoutDirectory(file.name)}', file.bytes)); + } + + FileUtil.saveFilesAsZIP(zipEntries); + } +} diff --git a/source/funkin/ui/debug/char/import.hx b/source/funkin/ui/debug/char/import.hx index 1d3ae589a9..93029835a9 100644 --- a/source/funkin/ui/debug/char/import.hx +++ b/source/funkin/ui/debug/char/import.hx @@ -5,4 +5,5 @@ import funkin.ui.debug.char.util.GhostUtil; #if !macro using funkin.ui.debug.char.handlers.CharCreatorStartupWizard; +using funkin.ui.debug.char.handlers.CharCreatorImportExportHandler; #end