reorderable wip

This commit is contained in:
Frakist
2023-08-26 18:31:43 +03:00
parent 8badd79d0c
commit dcd2675257
3 changed files with 42 additions and 9 deletions
+7 -1
View File
@@ -456,6 +456,7 @@ class Charter extends UIState {
Framerate.memoryCounter.alpha = 0.4;
Framerate.codenameBuildField.alpha = 0.4;
}
updateDisplaySprites();
}
override function destroy() {
@@ -596,6 +597,7 @@ class Charter extends UIState {
if (FlxG.mouse.pressed) {
selection.loop(function (n:CharterNote) {
n.setPosition(n.id * 40 + (mousePos.x - dragStartPos.x), n.step * 40 + (mousePos.y - dragStartPos.y));
n.dragging = true;
n.cursor = HAND;
}, function (e:CharterEvent) {
e.y = e.step * 40 + (mousePos.y - dragStartPos.y) - 17;
@@ -620,6 +622,7 @@ class Charter extends UIState {
for (s in selection) {
if (!s.draggable) continue;
s.handleDrag(changePoint);
if (s is CharterNote) cast(s, CharterNote).dragging = false;
if (s is UISprite) cast(s, UISprite).cursor = BUTTON;
}
sortNotes();
@@ -954,6 +957,9 @@ class Charter extends UIState {
}
WindowTitle.prefix = undos.unsaved ? "● " : "";
strumLines.sort(function(o, a, b) return FlxSort.byValues(o, a.x - 80, b.x - 80), -1);
for (it=>i in strumLines.members)
if (!i.dragging) i.x = CoolUtil.fpsLerp(i.x, 160 * it, 0.3);
}
public static var startTime:Float = 0;
@@ -993,7 +999,7 @@ class Charter extends UIState {
str.y = strumlineInfoBG.y;
}
strumlineAddButton.x = strumLines.members.length * (40 * 4);
strumlineAddButton.x = strumLines.length * (40 * 4);
strumlineAddButton.y = strumlineInfoBG.y;
}
+12 -6
View File
@@ -22,7 +22,8 @@ class CharterNote extends UISprite implements ICharterSelectable {
public var selected:Bool = false;
public var draggable:Bool = true;
public var dragging:Bool = false;
public var strumLine:CharterStrumline = null;
public function new() {
super();
antialiasing = true;
@@ -52,17 +53,22 @@ class CharterNote extends UISprite implements ICharterSelectable {
public var step:Float;
public var id:Int;
public var realId:Int;
@:isVar public var id(get, set):Int;
public var susLength:Float;
public var type:Int;
function set_id(d:Int) {
strumLine = Charter.instance.strumLines.members[Math.floor(d / 4)];
id = d % 4;
realId = d;
return id;
}
function get_id() return id + 4 * Charter.instance.strumLines.members.indexOf(strumLine);
public function updatePos(step:Float, id:Int, susLength:Float = 0, type:Int = 0) {
this.step = step;
this.id = id;
this.susLength = susLength;
this.type = type;
x = id * 40;
y = step * 40;
sustainSpr.scale.set(10, (40 * susLength));
@@ -116,7 +122,7 @@ class CharterNote extends UISprite implements ICharterSelectable {
var __passed:Bool = false;
public override function update(elapsed:Float) {
super.update(elapsed);
if (!dragging) x = (strumLine != null ? strumLine.button.x : 0) + (id % 4) * 40;
if(sustainSpr.exists)
sustainSpr.follow(this, 15, 20);
@@ -13,6 +13,7 @@ class CharterStrumline extends UISprite {
public var healthIcon:HealthIcon;
public var button:CharterStrumlineButton;
public var dragging:Bool = false;
public var curMenu:UIContextMenu = null;
@@ -37,12 +38,32 @@ class CharterStrumline extends UISprite {
button = new CharterStrumlineButton(this);
members.push(button);
}
var __pastStrumlines:Array<CharterStrumline>;
public override function update(elapsed:Float) {
if (healthIcon != null)
healthIcon.follow(this, ((40 * 4) - healthIcon.width) / 2, 0);
healthIcon.follow(this, ((40 * 4) - healthIcon.width) / 2, 50);
button.follow(this, 0, 95);
super.update(elapsed);
if (FlxG.mouse.overlaps(healthIcon) && FlxG.mouse.justPressed) {
dragging = true;
trace(__pastStrumlines = Charter.instance.strumLines.members.copy());
}
if (dragging) x = FlxG.mouse.x - 80;
if (FlxG.mouse.justReleased && dragging) {
dragging = false;
/*if (FlxG.keys.pressed.ALT) {
for (i in Charter.instance.notesGroup.members) {
trace(i.realId);
}
}*/
for (i in Charter.instance.eventsGroup.members) {
for (j in i.events)
if (j.name == "Camera Movement" && !FlxG.keys.pressed.SHIFT)
j.params[0] = Charter.instance.strumLines.members.indexOf(__pastStrumlines[j.params[0]]);
i.refreshEventIcons();
}
}
}
public function updateInfo() {