better strum line screen

This commit is contained in:
lunarcleint
2023-08-04 17:39:33 -07:00
parent f6a30c6185
commit d03146c24d
2 changed files with 23 additions and 15 deletions
@@ -56,16 +56,20 @@ class CharterStrumlineScreen extends UISubstateWindow {
function addLabelOn(ui:UISprite, text:String)
add(new UIText(ui.x, ui.y - 24, 0, text));
charactersList = new UIButtonList<CharacterButton>(15, 43, 250, 330, "", FlxPoint.get(246, 75), null, 0);
var title:UIText;
add(title = new UIText(windowSpr.x + 20, windowSpr.y + 30 + 16, 0, creatingStrumLine ? "Create New Strumline" : "Edit Strumline Properties", 28));
charactersList = new UIButtonList<CharacterButton>(15, title.y + title.height + 36, 250, 259, "", FlxPoint.get(250, 54), null, 0);
charactersList.addButton.callback = () -> charactersList.add(new CharacterButton(0,0,"New Char", charactersList));
charactersList.cameraSpacing = 0;
for (i in strumLine.characters)
charactersList.add(new CharacterButton(0,0,i, charactersList));
charactersList.cameraSpacing = 2;
add(charactersList);
addLabelOn(charactersList, "Characters");
charactersList.frames = Paths.getFrames('editors/ui/inputbox');
typeDropdown = new UIDropDown(charactersList.x + 265, charactersList.y + 20, 200, 32, ["OPPONENT", "PLAYER", "ADDITIONAL"], strumLine.type);
typeDropdown = new UIDropDown(charactersList.x + charactersList.bWidth + 16, charactersList.y, 200, 32, ["OPPONENT", "PLAYER", "ADDITIONAL"], strumLine.type);
add(typeDropdown);
addLabelOn(typeDropdown, "Type");
@@ -159,24 +163,28 @@ class CharacterButton extends UIButton {
public var deleteIcon:FlxSprite;
public function new(x:Float, y:Float, char:String, parent:UIButtonList<CharacterButton>) {
super(x, y, "", null, 250, 54);
charIcon = new HealthIcon(char);
charIcon.scale.set(0.5, 0.5);
charIcon.scale.set(0.3, 0.3);
charIcon.updateHitbox();
super(x, y, "", null, 246, Math.floor(charIcon.height));
charIcon.setPosition(x + 10, bHeight/2 - charIcon.height / 2);
members.push(charIcon);
members.remove(field);
members.push(textBox = new UITextBox(95, bHeight/2 - 16, char, 100));
members.push(textBox = new UITextBox(charIcon.x + charIcon.width + 16, bHeight/2 - (32/2), char, 115));
textBox.antialiasing = true;
textBox.onChange = function(char:String) {
charIcon.loadGraphic(Assets.exists(Paths.image("icons/" + char)) ? Paths.image("icons/" + char) : Paths.image("icons/face"), true, 150, 150);
charIcon.updateHitbox();
}
deleteButton = new UIButton(textBox.x + 105, y, "", function () {
deleteButton = new UIButton(textBox.x + 115 + 16, bHeight/2 - (32/2), "", function () {
parent.remove(this);
}, 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);
+7 -7
View File
@@ -25,13 +25,13 @@ class UIButtonList<T:UIButton> extends UIWindow {
var curMoving:T = null;
var curMovingInterval:Float = 0;
public function new(x:Int, y:Int, width:Int, height:Int, windowName:String, buttonSize:FlxPoint, ?buttonOffset:FlxPoint, ?buttonSpacing:Float) {
public function new(x:Float, y:Float, width:Int, height:Int, windowName:String, buttonSize:FlxPoint, ?buttonOffset:FlxPoint, ?buttonSpacing:Float) {
if (buttonSpacing != null) this.buttonSpacing = buttonSpacing;
this.buttonSize = buttonSize;
if (buttonOffset != null) this.buttonOffset = buttonOffset;
super(x, y, width, height, windowName);
buttonCameras = new FlxCamera(x, y+cameraSpacing, width, height-cameraSpacing);
buttonCameras = new FlxCamera(Std.int(x), Std.int(y+cameraSpacing), width, height-cameraSpacing-1);
FlxG.cameras.add(buttonCameras, false);
buttonCameras.bgColor = 0;
@@ -72,8 +72,8 @@ class UIButtonList<T:UIButton> extends UIWindow {
if (curMoving != button) {
button.setPosition(
(bWidth/2) - (buttonSize.x/2),
CoolUtil.fpsLerp(button.y, (buttonSize.y+buttonSpacing) * i, 0.25));
(bWidth/2) - (buttonSize.x/2) + buttonOffset.x,
CoolUtil.fpsLerp(button.y, ((buttonSize.y+buttonSpacing) * i) + buttonOffset.y, 0.25));
}
if (button.hovered && FlxG.mouse.justPressed) curMoving = button;
}
@@ -104,14 +104,14 @@ class UIButtonList<T:UIButton> extends UIWindow {
super.update(elapsed);
nextscrollY = FlxMath.bound(buttonCameras.scroll.y - (hovered ? FlxG.mouse.wheel : 0) * 12, -buttonSpacing, Math.max((addButton.y + 32 + (buttonSpacing*1.5)) - buttonCameras.height, -buttonSpacing));
nextscrollY = FlxMath.bound(buttonCameras.scroll.y - (hovered ? FlxG.mouse.wheel : 0) * 6, -buttonSpacing, Math.max((addButton.y + 32 + (buttonSpacing*1.5)) - buttonCameras.height, -buttonSpacing));
if (curMoving != null && dragging) {
nextscrollY -= Math.min((bHeight - 100) - FlxG.mouse.getWorldPosition(buttonCameras).y, 0) / 8;
nextscrollY += Math.min(FlxG.mouse.getWorldPosition(buttonCameras).y - 100, 0) / 8;
}
buttonCameras.scroll.y = FlxMath.lerp(buttonCameras.scroll.y, nextscrollY, 1/3);
buttonCameras.scroll.y = nextscrollY;
for (button in buttons) {
if (button != null) button.selectable = button.shouldPress = (hovered && !dragging);
@@ -120,7 +120,7 @@ class UIButtonList<T:UIButton> extends UIWindow {
addButton.selectable = (hovered && !dragging);
if (__lastDrawCameras[0] != null) {
buttonCameras.height = bHeight - cameraSpacing;
buttonCameras.height = bHeight - cameraSpacing - 1; // -1 for the little gap at the bottom of the window
buttonCameras.x = x - __lastDrawCameras[0].scroll.x;
buttonCameras.y = y + cameraSpacing - __lastDrawCameras[0].scroll.y;
buttonCameras.zoom = __lastDrawCameras[0].zoom;