Skip to content

Commit

Permalink
we can export now (although its not finished yet)
Browse files Browse the repository at this point in the history
  • Loading branch information
lemz1 committed Nov 2, 2024
1 parent 2abc94d commit 2cd0ae7
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 4 deletions.
36 changes: 35 additions & 1 deletion source/funkin/ui/debug/char/CharCreatorCharacter.hx
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,16 @@ import flixel.graphics.frames.FlxAtlasFrames;
import openfl.display.BitmapData;
import funkin.data.animation.AnimationData;
import funkin.play.character.BaseCharacter.CharacterType;
import funkin.data.character.CharacterData;
import funkin.data.character.CharacterRegistry;
import funkin.ui.debug.char.animate.CharSelectAtlasSprite;
import funkin.play.stage.Bopper;
import flixel.math.FlxPoint;
import flixel.math.FlxPoint.FlxCallbackPoint; // honestly these are kind of awesome
import flixel.FlxSprite;
import haxe.io.Bytes;
import haxe.io.Path;
import funkin.util.SerializerUtil;

// literally just basecharacter but less functionality
// like the removal of note event functions
Expand All @@ -21,7 +25,7 @@ class CharCreatorCharacter extends Bopper
public var characterId(get, never):String;
public var renderType(get, never):String;

public var characterName:String;
public var characterName:String = "Unknown";
public var characterType:CharacterType = BF;

public var holdTimer:Float = 0;
Expand Down Expand Up @@ -246,6 +250,36 @@ class CharCreatorCharacter extends Bopper
return null;
}

/**
* Returns the `CharacterData` in bytes
* @return Bytes
*/
public function toBytes():Bytes
{
return Bytes.ofString(SerializerUtil.toJSON(toCharacterData()));
}

/**
* Returns the information as `CharacterData`
* @return CharacterData
*/
public function toCharacterData():CharacterData
{
return {
version: CharacterRegistry.CHARACTER_DATA_VERSION,
name: characterName,
assetPaths: generatedParams.files.filter((file) -> return file.name.endsWith(".png"))
.map((file) -> Path.normalize(file.name.substr(file.name.indexOf("images") + 7)).replace(".png", "")),
flipX: characterFlipX,
renderType: generatedParams.renderType,
healthIcon:
{
id: characterId
},
animations: animations,
};
}

// getters and setters
// git gut

Expand Down
7 changes: 4 additions & 3 deletions source/funkin/ui/debug/char/CharCreatorState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import funkin.input.Cursor;
import funkin.ui.debug.char.pages.*;
import funkin.util.MouseUtil;
import funkin.util.WindowUtil;
import funkin.util.SerializerUtil;
import flixel.addons.display.FlxGridOverlay;
import flixel.FlxCamera;
import flixel.FlxSprite;
Expand Down Expand Up @@ -161,9 +162,9 @@ class CharCreatorState extends UIState

function exportCharacter():Void
{
funkin.util.FileUtil.saveFile(haxe.io.Bytes.ofString("lol"), [funkin.util.FileUtil.FILE_FILTER_JSON], (path:String) -> {
trace('PATH: $path');
});
var gameplayPage:CharCreatorGameplayPage = cast pages[Gameplay];

funkin.util.FileUtil.saveFile(gameplayPage.currentCharacter.toBytes(), [funkin.util.FileUtil.FILE_FILTER_JSON]);
}
}

Expand Down

0 comments on commit 2cd0ae7

Please sign in to comment.