damaged brain

This commit is contained in:
Frakist
2024-01-31 22:19:07 +02:00
parent e15bcd945d
commit 0eefa8a4b7
3 changed files with 49 additions and 14 deletions
@@ -164,7 +164,7 @@ class StrumLineButton extends UIButton {
public var typeDropDown:UIDropDown;
public var visibleCheckBoxText:UIText;
public var visibleCheckBox:UICheckbox;
public var characterList:UIButtonList<CompressedCharacterButton>;
public var characterList:UIButtonList<CompactCharacterButton>;
public function new(id:Int, char:String, type:Int, visible:Bool) {
super(0, 0, '', function () {}, 510, 150);
numberText = new UIText(5, 5, 0, 'Strumline #$id');
@@ -194,10 +194,10 @@ class StrumLineButton extends UIButton {
typeDropDown = new UIDropDown(typeDropDownText.x, typeDropDownText.y + 24, 165, 32, ["OPPONENT", "PLAYER", "ADDITIONAL"], type);
members.push(typeDropDown);
characterList = new UIButtonList<CompressedCharacterButton>(numberText.x + 265 + 26, numberText.y, 210, 140, "", FlxPoint.get(200, 40), null, 5);
characterList = new UIButtonList<CompactCharacterButton>(numberText.x + 265 + 26, numberText.y, 210, 140, "", FlxPoint.get(200, 40), null, 5);
characterList.frames = Paths.getFrames('editors/ui/inputbox');
characterList.cameraSpacing = 0;
characterList.add(new CompressedCharacterButton(char, [], characterList));
characterList.add(new CompactCharacterButton(char, [], characterList));
members.push(characterList);
}
public override function update(elapsed) {
@@ -215,13 +215,13 @@ class StrumLineButton extends UIButton {
}
}
class CompressedCharacterButton extends UIButton {
class CompactCharacterButton extends UIButton {
public var charIcon:HealthIcon;
public var textBox:UIAutoCompleteTextBox;
public var deleteButton:UIButton;
public var deleteIcon:FlxSprite;
public function new(char:String, charsList:Array<String>, parent:UIButtonList<CompressedCharacterButton>) {
public function new(char:String, charsList:Array<String>, parent:UIButtonList<CompactCharacterButton>) {
super(0, 0, "", null, 200, 40);
autoAlpha = false;
+9
View File
@@ -954,6 +954,7 @@ class Charter extends UIState {
#end
var __crochet:Float;
var __autosaveElapsed:Float;
public override function update(elapsed:Float) {
updateNoteLogic(elapsed);
@@ -1046,6 +1047,14 @@ class Charter extends UIState {
WindowUtils.prefix = undos.unsaved ? "* " : "";
SaveWarning.showWarning = undos.unsaved;
__autosaveElapsed += elapsed;
if (__autosaveElapsed > 5) {
#if sys
saveTo('${Paths.getAssetsRoot()}/songs/${__song.toLowerCase()}');
#end
__autosaveElapsed = 0;
}
}
public static var startTime:Float = 0;
+35 -9
View File
@@ -13,6 +13,7 @@ class UIButtonList<T:UIButton> extends UIWindow {
public var addButton:UIButton;
public var addIcon:FlxSprite;
public var buttonCameras:FlxCamera;
public var cameraSpacing = 30;
public var buttonSpacing:Float = 16;
@@ -31,9 +32,14 @@ class UIButtonList<T:UIButton> extends UIWindow {
if (buttonOffset != null) this.buttonOffset = buttonOffset;
super(x, y, width, height, windowName);
buttonCameras = new FlxCamera(Std.int(x), Std.int(y+cameraSpacing), width, height-cameraSpacing-1);
FlxG.cameras.add(buttonCameras, false);
buttonCameras.bgColor = 0;
addButton = new UIButton(25, 16, "", null, Std.int(this.buttonSize.x));
addButton.autoAlpha = false;
addButton.color = 0xFF00FF00;
addButton.cameras = [buttonCameras];
addIcon = new FlxSprite(addButton.x + addButton.bHeight / 2, addButton.y + (32/2) - 8).loadGraphic(Paths.image('editors/charter/add-button'));
addIcon.antialiasing = false;
@@ -41,7 +47,7 @@ class UIButtonList<T:UIButton> extends UIWindow {
members.push(addButton);
members.push(buttons);
nextscrollY = -this.buttonSpacing;
nextscrollY = buttonCameras.scroll.y = -this.buttonSpacing;
}
public inline function add(button:T) {
@@ -69,22 +75,22 @@ class UIButtonList<T:UIButton> extends UIWindow {
if (curMoving != button) {
button.setPosition(
x + (bWidth/2) - (buttonSize.x/2) + buttonOffset.x,
CoolUtil.fpsLerp(button.y, y + nextscrollY + cameraSpacing + ((buttonSize.y+buttonSpacing) * i) + buttonOffset.y, 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;
}
if (addButton != null)
addButton.setPosition(
x + (bWidth/2) - (buttonSize.x/2) + buttonOffset.x,
CoolUtil.fpsLerp(addButton.y, y + nextscrollY + cameraSpacing + ((buttonSize.y+buttonSpacing) * buttons.members.length) + buttonOffset.y, 0.25));
(bWidth/2) - (buttonSize.x/2) + buttonOffset.x,
CoolUtil.fpsLerp(addButton.y, ((buttonSize.y+buttonSpacing) * buttons.members.length) + buttonOffset.y, 0.25));
if (curMoving != null) {
curMovingInterval += FlxG.mouse.deltaY;
if (Math.abs(curMovingInterval) > addButton.bHeight / 2) {
curMovingInterval = 999;
curMoving.y = CoolUtil.fpsLerp(curMoving.y, FlxG.mouse.screenY - (curMoving.bHeight / 2), 0.3);
curMoving.y = CoolUtil.fpsLerp(curMoving.y, FlxG.mouse.getWorldPosition(buttonCameras).y - (curMoving.bHeight / 2), 0.3);
buttons.sort(function(o, a:T, b:T) return FlxSort.byValues(o, a.y + (a.bHeight / 2), b.y + (a.bHeight / 2)), -1);
}
if (FlxG.mouse.justReleased) {
@@ -101,16 +107,19 @@ class UIButtonList<T:UIButton> extends UIWindow {
super.update(elapsed);
nextscrollY = FlxMath.bound(nextscrollY - (hovered ? -FlxG.mouse.wheel : 0) * 12, -Math.max((addButton.y + 32 + (buttonSpacing*1.5)) - bHeight, -buttonSpacing), buttonSpacing);
nextscrollY = FlxMath.bound(buttonCameras.scroll.y - (hovered ? FlxG.mouse.wheel : 0) * 12, -buttonSpacing, Math.max((addButton.y + 32 + (buttonSpacing*1.5)) - buttonCameras.height, -buttonSpacing));
if (curMoving != null && dragging) {
nextscrollY -= Math.min((bHeight - 100) - FlxG.mouse.screenY, 0) / 8;
nextscrollY += Math.min(FlxG.mouse.screenY - 100, 0) / 8;
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 = nextscrollY;
for (i => button in buttons.members) {
if (button == null) continue;
button.selectable = button.shouldPress = (hovered && !dragging);
button.cameras = [buttonCameras];
if (button.ID != i) {
if (dragCallback != null) dragCallback(cast button, button.ID, i);
button.ID = i; // Ok back to normal :D
@@ -118,5 +127,22 @@ class UIButtonList<T:UIButton> extends UIWindow {
}
addButton.selectable = (hovered && !dragging);
if (__lastDrawCameras[0] != null) {
buttonCameras.height = bHeight - cameraSpacing - 1; // -1 for the little gap at the bottom of the window
buttonCameras.x = __lastDrawCameras[0].x + x - __lastDrawCameras[0].scroll.x;
buttonCameras.y = __lastDrawCameras[0].y + y + cameraSpacing - __lastDrawCameras[0].scroll.y;
buttonCameras.zoom = __lastDrawCameras[0].zoom;
}
}
override function destroy() {
super.destroy();
if(buttonCameras != null) {
if (FlxG.cameras.list.contains(buttonCameras))
FlxG.cameras.remove(buttonCameras);
buttonCameras = null;
}
}
}