woah (character editor)
This commit is contained in:
@@ -0,0 +1,82 @@
|
||||
package funkin.editors.character;
|
||||
|
||||
import flixel.util.FlxColor;
|
||||
import flixel.math.FlxPoint;
|
||||
|
||||
class CharacterAnimButtons extends UIButton {
|
||||
public var anim:String = "";
|
||||
|
||||
public var editButton:UIButton;
|
||||
public var editIcon:FlxSprite;
|
||||
|
||||
public var ghostButton:UIButton;
|
||||
public var ghostIcon:FlxSprite;
|
||||
|
||||
public var deleteButton:UIButton;
|
||||
public var deleteIcon:FlxSprite;
|
||||
|
||||
public function new(x:Float,y:Float,anim:String, offset:FlxPoint) {
|
||||
this.anim = anim;
|
||||
super(x,y, '$anim (${offset.x}, ${offset.y})', function () {
|
||||
CharacterEditor.instance.playAnimation(this.anim);
|
||||
}, 282);
|
||||
|
||||
ghostButton = new UIButton(x+282+17, y, "", function () {
|
||||
CharacterEditor.instance.ghostAnim(this.anim);
|
||||
}, 32);
|
||||
members.push(ghostButton);
|
||||
|
||||
ghostIcon = new FlxSprite(ghostButton.x + 8, ghostButton.y + 8).loadGraphic(Paths.image('editors/character/ghost-button'), true, 16, 16);
|
||||
ghostIcon.animation.add("alive", [0]);
|
||||
ghostIcon.animation.add("dead", [1]);
|
||||
ghostIcon.animation.play("dead"); ghostIcon.alpha = 0.5;
|
||||
ghostIcon.antialiasing = false;
|
||||
ghostIcon.updateHitbox();
|
||||
members.push(ghostIcon);
|
||||
|
||||
editButton = new UIButton(ghostButton.x+32+17, y, "", function () {
|
||||
CharacterEditor.instance.editAnimWithUI(this.anim);
|
||||
}, 32);
|
||||
editButton.color = FlxColor.YELLOW;
|
||||
members.push(editButton);
|
||||
|
||||
editIcon = new FlxSprite(editButton.x + 8, editButton.y + 8).loadGraphic(Paths.image('editors/character/edit-button'));
|
||||
editIcon.antialiasing = false;
|
||||
members.push(editIcon);
|
||||
|
||||
deleteButton = new UIButton(editButton.x+32+17, y, "", function () {
|
||||
CharacterEditor.instance.deleteAnim(this.anim);
|
||||
}, 32);
|
||||
deleteButton.color = FlxColor.RED;
|
||||
members.push(deleteButton);
|
||||
|
||||
deleteIcon = new FlxSprite(deleteButton.x + (15/2), deleteButton.y + 8).loadGraphic(Paths.image('editors/character/delete-button'));
|
||||
deleteIcon.antialiasing = false;
|
||||
members.push(deleteIcon);
|
||||
}
|
||||
|
||||
public override function update(elapsed:Float) {
|
||||
editButton.selectable = ghostButton.selectable = deleteButton.selectable = selectable;
|
||||
hovered = !deleteButton.hovered;
|
||||
updatePos();
|
||||
super.update(elapsed);
|
||||
}
|
||||
|
||||
public function updateInfo(anim:String, offset:FlxPoint, ghost:Bool) {
|
||||
this.anim = anim;
|
||||
|
||||
field.text = '$anim (${offset.x}, ${offset.y})';
|
||||
ghostIcon.animation.play(ghost ? "alive" : "dead");
|
||||
ghostIcon.alpha = ghost ? 1 : 0.5;
|
||||
}
|
||||
|
||||
public inline function updatePos() {
|
||||
// buttons
|
||||
deleteButton.x = (editButton.x = (ghostButton.x = (x+282+17))+32+17)+32+17;
|
||||
deleteButton.y = editButton.y = ghostButton.y = y;
|
||||
// icons
|
||||
ghostIcon.x = ghostButton.x + 8; ghostIcon.y = ghostButton.y + 8;
|
||||
editIcon.x = editButton.x + 8; editIcon.y = editButton.y + 8;
|
||||
deleteIcon.x = deleteButton.x + (15/2); deleteIcon.y = deleteButton.y + 8;
|
||||
}
|
||||
}
|
||||
@@ -278,13 +278,13 @@ class CharacterEditor extends UIState {
|
||||
}
|
||||
|
||||
|
||||
if (FlxG.mouse.justPressedMiddle) {
|
||||
if (FlxG.mouse.justPressed) {
|
||||
FlxG.mouse.getScreenPosition(charCamera, camDrag);
|
||||
camDrag *= camDragSpeed;
|
||||
camDrag += charCamera.scroll;
|
||||
}
|
||||
|
||||
if (FlxG.mouse.pressedMiddle) {
|
||||
if (FlxG.mouse.pressed) {
|
||||
var pos = FlxG.mouse.getScreenPosition(charCamera);
|
||||
pos *= camDragSpeed;
|
||||
nextScroll.set((camDrag.x - pos.x), (camDrag.y - pos.y));
|
||||
@@ -628,82 +628,7 @@ class CharacterEditor extends UIState {
|
||||
}
|
||||
#end
|
||||
}
|
||||
class CharacterAnimButtons extends UIButton {
|
||||
public var anim:String = "";
|
||||
|
||||
public var editButton:UIButton;
|
||||
public var editIcon:FlxSprite;
|
||||
|
||||
public var ghostButton:UIButton;
|
||||
public var ghostIcon:FlxSprite;
|
||||
|
||||
public var deleteButton:UIButton;
|
||||
public var deleteIcon:FlxSprite;
|
||||
|
||||
public function new(x:Float,y:Float,anim:String, offset:FlxPoint) {
|
||||
this.anim = anim;
|
||||
super(x,y, '$anim (${offset.x}, ${offset.y})', function () {
|
||||
CharacterEditor.instance.playAnimation(this.anim);
|
||||
}, 282);
|
||||
|
||||
ghostButton = new UIButton(x+282+17, y, "", function () {
|
||||
CharacterEditor.instance.ghostAnim(this.anim);
|
||||
}, 32);
|
||||
members.push(ghostButton);
|
||||
|
||||
ghostIcon = new FlxSprite(ghostButton.x + 8, ghostButton.y + 8).loadGraphic(Paths.image('editors/character/ghost-button'), true, 16, 16);
|
||||
ghostIcon.animation.add("alive", [0]);
|
||||
ghostIcon.animation.add("dead", [1]);
|
||||
ghostIcon.animation.play("dead"); ghostIcon.alpha = 0.5;
|
||||
ghostIcon.antialiasing = false;
|
||||
ghostIcon.updateHitbox();
|
||||
members.push(ghostIcon);
|
||||
|
||||
editButton = new UIButton(ghostButton.x+32+17, y, "", function () {
|
||||
CharacterEditor.instance.editAnimWithUI(this.anim);
|
||||
}, 32);
|
||||
members.push(editButton);
|
||||
|
||||
editIcon = new FlxSprite(editButton.x + 8, editButton.y + 8).loadGraphic(Paths.image('editors/character/edit-button'));
|
||||
editIcon.antialiasing = false;
|
||||
members.push(editIcon);
|
||||
|
||||
deleteButton = new UIButton(editButton.x+32+17, y, "", function () {
|
||||
CharacterEditor.instance.deleteAnim(this.anim);
|
||||
}, 32);
|
||||
deleteButton.color = 0xFFFF0000;
|
||||
members.push(deleteButton);
|
||||
|
||||
deleteIcon = new FlxSprite(deleteButton.x + (15/2), deleteButton.y + 8).loadGraphic(Paths.image('editors/character/delete-button'));
|
||||
deleteIcon.antialiasing = false;
|
||||
members.push(deleteIcon);
|
||||
}
|
||||
|
||||
public override function update(elapsed:Float) {
|
||||
editButton.selectable = ghostButton.selectable = deleteButton.selectable = selectable;
|
||||
hovered = !deleteButton.hovered;
|
||||
updatePos();
|
||||
super.update(elapsed);
|
||||
}
|
||||
|
||||
public function updateInfo(anim:String, offset:FlxPoint, ghost:Bool) {
|
||||
this.anim = anim;
|
||||
|
||||
field.text = '$anim (${offset.x}, ${offset.y})';
|
||||
ghostIcon.animation.play(ghost ? "alive" : "dead");
|
||||
ghostIcon.alpha = ghost ? 1 : 0.5;
|
||||
}
|
||||
|
||||
public inline function updatePos() {
|
||||
// buttons
|
||||
deleteButton.x = (editButton.x = (ghostButton.x = (x+282+17))+32+17)+32+17;
|
||||
deleteButton.y = editButton.y = ghostButton.y = y;
|
||||
// icons
|
||||
ghostIcon.x = ghostButton.x + 8; ghostIcon.y = ghostButton.y + 8;
|
||||
editIcon.x = editButton.x + 8; editIcon.y = editButton.y + 8;
|
||||
deleteIcon.x = deleteButton.x + (15/2); deleteIcon.y = deleteButton.y + 8;
|
||||
}
|
||||
}
|
||||
enum CharacterChange {
|
||||
CEditInfo(oldInfo:Xml, newInfo:Xml);
|
||||
CCreateAnim(animID:Int, animData:AnimData);
|
||||
|
||||
@@ -58,7 +58,7 @@ class UIButtonList extends UIWindow {
|
||||
var i:UIButton = cast(i, UIButton);
|
||||
i.selectable = true;
|
||||
}
|
||||
button.y = CoolUtil.fpsLerp(button.y, -scrollY + ((buttons.members[i-1] != null ? buttons.members[i-1].bHeight : 0) + _buttonYOffset) * i, 0.1);
|
||||
button.y = CoolUtil.fpsLerp(button.y, -scrollY + ((buttons.members[i-1] != null ? buttons.members[i-1].bHeight : 0) + _buttonYOffset) * i, 0.25);
|
||||
button.shouldPress = true;
|
||||
}
|
||||
if (button != addButton && button.hovered && FlxG.mouse.justPressed) _curMoving = button;
|
||||
@@ -68,7 +68,7 @@ class UIButtonList extends UIWindow {
|
||||
if (Math.abs(_curMovingInterval) > addButton.bHeight / 2) {
|
||||
_curMovingInterval = 999;
|
||||
_curMoving.shouldPress = false;
|
||||
_curMoving.y = CoolUtil.fpsLerp(_curMoving.y, FlxG.mouse.getScreenPosition(buttonCameras).y - (_curMoving.bHeight / 2), 0.2);
|
||||
_curMoving.y = CoolUtil.fpsLerp(_curMoving.y, FlxG.mouse.getScreenPosition(buttonCameras).y - (_curMoving.bHeight / 2), 0.3);
|
||||
buttons.sort(function(o,a,b) return flixel.util.FlxSort.byValues(o, a == addButton ? 999 : a.y + (a.bHeight / 2), b == addButton ? 999 : b.y + (a.bHeight / 2)), -1);
|
||||
}
|
||||
if (FlxG.mouse.justReleased) {
|
||||
|
||||
Reference in New Issue
Block a user