potential hashlink + neko support

This commit is contained in:
Yoshman29
2022-12-26 16:31:39 +01:00
parent c27de7a01d
commit 6d00ab0b5b
13 changed files with 133 additions and 35 deletions
@@ -26,6 +26,8 @@ class CharacterEditor extends WindowContent {
* ANIMATION TAB
*/
public var animsDropDown:DropDown;
public var animNameInput:InputBox;
public var animPrefixInput:InputBox;
public override function create() {
super.create();
@@ -77,15 +79,37 @@ class CharacterEditor extends WindowContent {
var labels:Array<WindowText> = [];
var label:WindowText = null;
labels.push(label = new WindowText(10, 10, 0, "Animations"));
animsDropDown = new DropDown(10, label.y + label.height, [], function(id) {
char.playAnim(animList[id].name, true);
animsDropDown = new DropDown(10, label.y + label.height, 380, [], function(id) {
changeAnim(id);
});
labels.push(label = new WindowText(10, animsDropDown.y + animsDropDown.height + 10, 0, "Animation Name"));
refreshAnims();
animNameInput = new InputBox(10, label.y + label.height, 380, "");
labels.push(label = new WindowText(10, animNameInput.y + animNameInput.height + 10, 0, "Animation Prefix"));
animPrefixInput = new InputBox(10, label.y + label.height, 380, "");
// labels.push(label = new WindowText(10, animNameInput.y + animNameInput.height + 10, 0, "Animation Prefix"));
// animPrefixInput = new InputBox(10, label.y + label.height, 380, "");
for(spr in [animsDropDown])
for(l in labels)
tabView.tabs[0].add(l);
for(spr in [animsDropDown, animNameInput, ])
tabView.tabs[0].add(spr);
refreshAnims();
}
public function changeAnim(id:Int) {
var anim = animList[id];
if (anim == null) return;
char.playAnim(anim.name, true);
animNameInput.text = anim.name;
animPrefixInput.text = anim.name;
}
public function refreshAnims() {
+1 -1
View File
@@ -8,7 +8,7 @@ class DropDown extends Button {
public var onChange:Int->Void;
public var options:Array<String>;
public function new(x:Float, y:Float, options:Array<String>, onChange:Int->Void, curId:Int = 0, ?normalButton:ThemeData, ?hoverButton:ThemeData, ?pressedButton:ThemeData, ?disabledButton:ThemeData) {
public function new(x:Float, y:Float, w:Float, options:Array<String>, onChange:Int->Void, curId:Int = 0, ?normalButton:ThemeData, ?hoverButton:ThemeData, ?pressedButton:ThemeData, ?disabledButton:ThemeData) {
super(x, y, "", onClick, normalButton, hoverButton, pressedButton, disabledButton);
this.options = options;
onSelectionChange(curId);
+27 -4
View File
@@ -9,7 +9,15 @@ import lime.app.Application;
class InputBox extends Button {
public var index:Int = 0;
public function new(x:Float, y:Float, w:Float, t:String, onChange:Void->Void) {
public var text(get, set):String;
private inline function set_text(t:String):String
return label.text = t;
private inline function get_text():String
return label.text;
public var onChange:Void->Void;
public function new(x:Float, y:Float, w:Float, t:String, ?onChange:Void->Void) {
super(x, y, t, function() {
setIndex(label.text.length);
});
@@ -19,26 +27,41 @@ class InputBox extends Button {
Application.current.window.onTextInput.add(onTextInput);
}
private function onKeyDown(event:KeyboardEvent) {
if (!this.hasFocus()) return;
switch(event.keyCode) {
case Keyboard.CONTROL | Keyboard.SHIFT:
// nothing
case Keyboard.ESCAPE:
this.loseFocus();
case Keyboard.LEFT:
changeIndex(-1);
case Keyboard.RIGHT:
changeIndex(1);
case Keyboard.HOME:
setIndex(0);
case Keyboard.END:
setIndex(text.length);
case Keyboard.DELETE:
text = text.substr(0, index) + text.substring(index + 1, text.length);
onTextInput("");
case Keyboard.BACKSPACE:
text = text.substr(0, index - 1) + text.substring(index, text.length);
index--;
onTextInput("");
case Keyboard.ENTER | Keyboard.NUMPAD_ENTER:
onTextInput("\n");
default:
// nothing
}
}
private function onTextInput(input:String) {
if (!this.hasFocus()) return;
text = text.substr(0, index) + input + text.substring(index, text.length);
if (onChange != null)
onChange();
}
public inline function changeIndex(change:Int) {