AUTOCOMPLETE FOR ANIMS!!!

This commit is contained in:
lunarcleint
2025-03-04 19:52:58 -07:00
parent d0a7f91106
commit 0970a63dd1
5 changed files with 21 additions and 10 deletions
+7
View File
@@ -1184,6 +1184,13 @@ final class CoolUtil
return animsList;
}
public static function getAnimsListFromSprite(spr:FunkinSprite):Array<String> {
if (spr.animateAtlas != null) {
return [for (symbol => timeline in spr.animateAtlas.anim.symbolDictionary) symbol];
} else
return getAnimsListFromFrames(spr.frames);
}
// TODO: check this for bugs
// Code from https://github.com/elnabo/equals/blob/master/src/equals/Equal.hx, (MIT License), but updated to work with haxe 4
public static function deepEqual<T> (a:T, b:T) : Bool {
@@ -25,7 +25,7 @@ class CharacterAnimButton extends UIButton {
public var animationDisplayBG:UISliceSprite;
public var nameTextBox:UITextBox;
public var animTextBox:UITextBox;
public var animTextBox:UIAutoCompleteTextBox;
public var positionXStepper:UINumericStepper;
public var positionYStepper:UINumericStepper;
public var fpsStepper:UINumericStepper;
@@ -78,7 +78,7 @@ class CharacterAnimButton extends UIButton {
foldableButtons.push(nameTextBox);
addLabelOn(nameTextBox, "Name", 12);
animTextBox = new UITextBox(nameTextBox.x + 100, nameTextBox.y, animData.anim, 156, 22, false, true);
animTextBox = new UIAutoCompleteTextBox(nameTextBox.x + 100, nameTextBox.y, animData.anim, 156, 22, false, true);
animTextBox.onChange = (newAnim:String) -> {this.changeAnim(newAnim);};
members.push(animTextBox);
foldableButtons.push(animTextBox);
@@ -41,6 +41,8 @@ class CharacterAnimsWindow extends UIButtonList<CharacterAnimButton> {
for (anim in character.getAnimOrder())
addAnimation(character.animDatas.get(anim));
addButton.callback = generateAnimation;
setAnimAutoComplete(CoolUtil.getAnimsListFromSprite(character));
}
public var ghosts:Array<String> = [];
@@ -113,6 +115,11 @@ class CharacterAnimsWindow extends UIButtonList<CharacterAnimButton> {
}
}
public inline function setAnimAutoComplete(anims:Array<String>) {
for (button in buttons)
button.animTextBox.suggestItems = anims;
}
public function findValid():Null<String> {
for (button in buttons) if (button.valid) return button.anim;
return null;
@@ -188,6 +188,7 @@ class CharacterPropertiesWindow extends UISliceSprite {
for (anim in animsWindow.buttons) anim.checkValid(); // Re-add all animations
CharacterEditor.instance.playAnimation(animsWindow.findValid().getDefault(animsWindow.buttons.members[0].anim));
animsWindow.setAnimAutoComplete(CoolUtil.getAnimsListFromSprite(character));
}
public function changeFlipX(newFlipX:Bool) @:privateAccess {
@@ -9,10 +9,10 @@ class UIAutoCompleteTextBox extends UITextBox {
public var suggestItems(default, set):Array<String> = [];
var suggestIndex = 0;
public function new(x:Float, y:Float, text:String = "", width:Int = 320, height:Int = 32, multiline:Bool = false) {
super(x, y, text, width, height, multiline);
public function new(x:Float, y:Float, text:String = "", width:Int = 320, height:Int = 32, multiline:Bool = false, small:Bool = false) {
super(x, y, text, width, height, multiline, small);
suggestionText = new UIText(0, 0, width, "");
suggestionText = new UIText(0, 0, width, "", small ? 12 : 15);
suggestionText.color = 0xFF888888;
suggestionText.visible = false;
members.insert(members.indexOf(label), suggestionText);
@@ -20,11 +20,7 @@ class UIAutoCompleteTextBox extends UITextBox {
public override function update(elapsed:Float) {
super.update(elapsed);
var selected = selectable && focused;
suggestionText.exists = selected;
suggestionText.exists = selectable && focused;
suggestionText.follow(label, 0, 0);
}