diff --git a/assets/languages/en/Editors.xml b/assets/languages/en/Editors.xml index ae4c27e1..a7727e6d 100644 --- a/assets/languages/en/Editors.xml +++ b/assets/languages/en/Editors.xml @@ -433,6 +433,8 @@ Position (X, Y) FPS Indices (Frames) + Looping? + Label diff --git a/source/funkin/editors/character/CharacterAnimButton.hx b/source/funkin/editors/character/CharacterAnimButton.hx index 6d522cb6..a3d19c85 100644 --- a/source/funkin/editors/character/CharacterAnimButton.hx +++ b/source/funkin/editors/character/CharacterAnimButton.hx @@ -21,6 +21,7 @@ class CharacterAnimButton extends UIButton { public var animationDisplayBG:UISliceSprite; public var nameTextBox:UITextBox; public var animTextBox:UIAutoCompleteTextBox; + public var animLabelCheckbox:UICheckbox; public var positionXStepper:UINumericStepper; public var positionYStepper:UINumericStepper; public var fpsStepper:UINumericStepper; @@ -111,13 +112,20 @@ class CharacterAnimButton extends UIButton { foldableButtons.push(fpsStepper); addLabelOn(fpsStepper, translate("fps"), 12); - loopedCheckbox = new UICheckbox(fpsStepper.x + 82 - 32 + 26, fpsStepper.y, "Looping?", animData.loop, 0, true); + loopedCheckbox = new UICheckbox(fpsStepper.x + 82 - 32 + 26, fpsStepper.y, translate("looping"), animData.loop, 0, true); loopedCheckbox.onChecked = (newLooping:Bool) -> {this.changeLooping(newLooping);}; members.push(loopedCheckbox); foldableButtons.push(loopedCheckbox); loopedCheckbox.x += 8; loopedCheckbox.y += 6; + if (parent.character.isAnimate) { + animLabelCheckbox = new UICheckbox(loopedCheckbox.x, animTextBox.y + 26, translate("label"), animData.label, 0, true); + animLabelCheckbox.onChecked = (newLabel:Bool) -> {this.changeLabel(newLabel);}; + members.push(animLabelCheckbox); + foldableButtons.push(animLabelCheckbox); + } + indicesTextBox = new UITextBox(nameTextBox.x, nameTextBox.y, CoolUtil.formatNumberRange(animData.indices.getDefault([]), ", "), 278, 22, false, true); indicesTextBox.onChange = (text:String) -> { this.changeIndicies(CoolUtil.parseNumberRange(text)); @@ -199,6 +207,7 @@ class CharacterAnimButton extends UIButton { fpsStepper.follow(this, 282, 118); loopedCheckbox.follow(this, 336, 122); + animLabelCheckbox?.follow(this, 336, 98); indicesTextBox.follow(this, 158, 164); @@ -343,6 +352,19 @@ class CharacterAnimButton extends UIButton { if (addToUndo) CharacterEditor.undos.addToUndo(CAnimEditLooping(ID, newLooping)); } + public function changeLabel(newLabel:Bool, addToUndo:Bool = true) @:privateAccess { + var animData:AnimData = parent.character.animDatas[anim]; + + animData.label = newLabel; + + if (animLabelCheckbox != null) + animLabelCheckbox.checked = newLabel; + + __refreshAnimation(); + + if (addToUndo) CharacterEditor.undos.addToUndo(CAnimEditLabel(ID, newLabel)); + } + public function changeIndicies(indicies:Array, addToUndo:Bool = true) @:privateAccess { var animData:AnimData = parent.character.animDatas[anim]; var oldIndices:Array = animData.indices.copy(); diff --git a/source/funkin/editors/character/CharacterEditor.hx b/source/funkin/editors/character/CharacterEditor.hx index b040d9bd..61ab5281 100644 --- a/source/funkin/editors/character/CharacterEditor.hx +++ b/source/funkin/editors/character/CharacterEditor.hx @@ -554,6 +554,9 @@ class CharacterEditor extends UIState { case CAnimEditLooping(animID, newLooping): var button:CharacterAnimButton = characterAnimsWindow.buttons.members[animID]; button.changeLooping(!newLooping, false); + case CAnimEditLabel(animID, newLabel): + var button:CharacterAnimButton = characterAnimsWindow.buttons.members[animID]; + button.changeLabel(!newLabel, false); case CAnimEditIndices(animID, oldIndicies, newIndicies): var button:CharacterAnimButton = characterAnimsWindow.buttons.members[animID]; button.changeIndicies(oldIndicies, false); @@ -625,6 +628,9 @@ class CharacterEditor extends UIState { case CAnimEditLooping(animID, newLooping): var button:CharacterAnimButton = characterAnimsWindow.buttons.members[animID]; button.changeLooping(newLooping, false); + case CAnimEditLabel(animID, newLabel): + var button:CharacterAnimButton = characterAnimsWindow.buttons.members[animID]; + button.changeLabel(newLabel, false); case CAnimEditIndices(animID, oldIndicies, newIndicies): var button:CharacterAnimButton = characterAnimsWindow.buttons.members[animID]; button.changeIndicies(newIndicies, false); @@ -936,6 +942,7 @@ enum CharacterEditorChange { CAnimEditFPS(animID:Int, oldFPS:Float, newFPS:Float); CAnimEditLooping(animID:Int, newLooping:Bool); CAnimEditIndices(animID:Int, oldIndicies:Array, newIndicies:Array); + CAnimEditLabel(animID:Int, newLabel:Bool); CCharClearOffsets(oldOffsets:Map); } \ No newline at end of file diff --git a/source/funkin/game/Character.hx b/source/funkin/game/Character.hx index eeb12aec..c2d37971 100644 --- a/source/funkin/game/Character.hx +++ b/source/funkin/game/Character.hx @@ -439,7 +439,7 @@ class Character extends FunkinSprite implements IBeatReceiver implements IOffset "color", "gameOverChar", "holdTime" ]; public static var characterAnimProperties:Array = [ - "name", "anim", "x", "y", "fps", "loop", "indices" + "name", "anim", "label", "x", "y", "fps", "loop", "indices" ]; public inline function buildXML(?animsOrder:Array):Xml { @@ -491,6 +491,9 @@ class Character extends FunkinSprite implements IBeatReceiver implements IOffset if (anim.indices.length > 0) animXml.set("indices", CoolUtil.formatNumberRange(anim.indices)); + if (anim.label) + animXml.set("label", "true"); + xml.addChild(animXml); }