From 642d71c031fdb4f4020e2f0f58085a47ba9b2234 Mon Sep 17 00:00:00 2001 From: lunarcleint <88809950+lunarcleint@users.noreply.github.com> Date: Fri, 4 Aug 2023 22:18:58 -0700 Subject: [PATCH] it works but not really --- source/funkin/editors/character/CharacterEditor.hx | 9 ++++++++- source/funkin/game/Character.hx | 13 ++++++++++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/source/funkin/editors/character/CharacterEditor.hx b/source/funkin/editors/character/CharacterEditor.hx index 42dad73b..ffddc28c 100644 --- a/source/funkin/editors/character/CharacterEditor.hx +++ b/source/funkin/editors/character/CharacterEditor.hx @@ -327,6 +327,8 @@ class CharacterEditor extends UIState { } function _file_save(_) { + if (characterAnimsWindow.dragging) return; + #if sys sys.io.File.saveContent( Assets.getPath(Paths.xml('characters/${character.curCharacter}')), @@ -338,13 +340,18 @@ class CharacterEditor extends UIState { } function _file_saveas(_) { + if (characterAnimsWindow.dragging) return; + openSubState(new SaveSubstate(buildCharacter(), { defaultSaveFile: '${character.curCharacter}.xml' })); } function buildCharacter():String { - var charXML:Xml = character.buildXML(); + var charXML:Xml = character.buildXML([ + for (button in characterAnimsWindow.buttons.members) + button.anim + ]); // clean if (charXML.exists("gameOverChar") && character.gameOverCharacter == "bf-dead") charXML.remove("gameOverChar"); diff --git a/source/funkin/game/Character.hx b/source/funkin/game/Character.hx index 0b302f60..6ef436d6 100644 --- a/source/funkin/game/Character.hx +++ b/source/funkin/game/Character.hx @@ -397,7 +397,7 @@ class Character extends FunkinSprite implements IBeatReceiver implements IOffset dance(); } - public function buildXML():Xml { + public function buildXML(?animsOrder:Array):Xml { var xml = Xml.createElement("character"); xml.set("isPlayer", playerOffsets == true ? "true" : "false"); xml.set("isGF", isGF == true ? "true" : "false"); @@ -408,14 +408,21 @@ class Character extends FunkinSprite implements IBeatReceiver implements IOffset xml.set("camy", Std.string(cameraOffset.y)); xml.set("holdTime", Std.string(holdTime)); xml.set("flipX", Std.string(flipX)); - xml.set("icon", icon); + xml.set("icon", getIcon()); if (iconColor != null) xml.set("color", iconColor.toHexString(false).replace("0x", "#")); xml.set("scale", Std.string(scale.x)); xml.set("antialiasing", antialiasing == true ? "true" : "false"); xml.set("sprite", sprite); - for (anim in animDatas) + var anims:Array = []; + if (animsOrder != null) { + for (name in animsOrder) + if (animDatas.exists(name)) anims.push(animDatas.get(name)); + } else + anims = [for (anim in animDatas) anim]; + + for (anim in anims) { var animXml:Xml = Xml.createElement('anim'); animXml.set("name", anim.name);