diff --git a/art/flashFiles/RECOVER_NOTE_assets.fla b/art/flashFiles/RECOVER_NOTE_assets.fla
deleted file mode 100644
index 96bc1a23..00000000
Binary files a/art/flashFiles/RECOVER_NOTE_assets.fla and /dev/null differ
diff --git a/assets/images/editors/ui/selection.xml b/assets/images/editors/ui/selection.xml
new file mode 100644
index 00000000..8fab7d3d
--- /dev/null
+++ b/assets/images/editors/ui/selection.xml
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/buildnumber.txt b/buildnumber.txt
index bf0b9f89..a08fb8e1 100644
--- a/buildnumber.txt
+++ b/buildnumber.txt
@@ -1 +1 @@
-2678
\ No newline at end of file
+2687
\ No newline at end of file
diff --git a/source/funkin/editors/charter/Charter.hx b/source/funkin/editors/charter/Charter.hx
index 30a02c63..3cbbdbea 100644
--- a/source/funkin/editors/charter/Charter.hx
+++ b/source/funkin/editors/charter/Charter.hx
@@ -1,5 +1,6 @@
package funkin.editors.charter;
+import flixel.math.FlxPoint;
import funkin.editors.charter.CharterBackdrop.CharterBackdropDummy;
import funkin.system.Conductor;
import funkin.chart.*;
@@ -45,6 +46,8 @@ class Charter extends UIState {
public var charterCamera:FlxCamera;
// camera for the ui
public var uiCamera:FlxCamera;
+ // selection box for the ui
+ public var selectionBox:UISliceSprite;
public var selection:Array = [];
@@ -150,10 +153,16 @@ class Charter extends UIState {
gridBackdrop = new CharterBackdrop();
- notesGroup.cameras = gridBackdrop.cameras = [charterCamera];
add(gridBackdropDummy = new CharterBackdropDummy(gridBackdrop));
+ selectionBox = new UISliceSprite(0, 0, 2, 2, 'editors/ui/selection');
+ selectionBox.visible = false;
+ selectionBox.scrollFactor.set(1, 1);
+ selectionBox.incorporeal = true;
+
+ selectionBox.cameras = notesGroup.cameras = gridBackdrop.cameras = [charterCamera];
+
topMenuSpr = new UITopMenu(topMenu);
topMenuSpr.cameras = uiGroup.cameras = [uiCamera];
@@ -162,6 +171,7 @@ class Charter extends UIState {
// adds grid and notes so that they're ALWAYS behind the UI
add(gridBackdrop);
add(notesGroup);
+ add(selectionBox);
// add the ui group
add(uiGroup);
// add the top menu last OUT of the ui group so that it stays on top
@@ -184,11 +194,17 @@ class Charter extends UIState {
}
}
- public override function update(elapsed:Float) {
- // TODO: do optimization like NoteGroup
- notesGroup.forEach(function(n) {
+ /**
+ * NOTE AND CHARTER GRID LOGIC HERE
+ */
+ #if REGION
+ var selectionBoxEnabled:Bool = false;
+ var dragStartPos:FlxPoint = new FlxPoint();
+
+ public function updateNoteLogic(elapsed:Float) {
+ notesGroup.forEach(function(n) {
n.selected = false;
- if (n.hovered) {
+ if (n.hovered && !selectionBoxEnabled) {
if (FlxG.mouse.justReleased) {
if (FlxG.keys.pressed.CONTROL)
selection.push(n);
@@ -205,8 +221,55 @@ class Charter extends UIState {
for(n in selection)
n.selected = true;
- if (gridBackdropDummy.hovered && FlxG.mouse.justReleasedRight)
- openContextMenu(topMenu[2].childs);
+ if (gridBackdropDummy.hovered || (selectionBoxEnabled && gridBackdropDummy.hoveredByChild)) {
+ var mousePos = FlxG.mouse.getWorldPosition(charterCamera);
+ if (FlxG.mouse.justPressed) {
+ selectionBoxEnabled = false;
+ FlxG.mouse.getWorldPosition(charterCamera, dragStartPos);
+ }
+ if (FlxG.mouse.pressed) {
+ if (Math.abs(mousePos.x - dragStartPos.x) > 20 || Math.abs(mousePos.y - dragStartPos.y) > 20) {
+ selectionBoxEnabled = true;
+ }
+ if (selectionBoxEnabled) {
+ selectionBox.x = Math.min(mousePos.x, dragStartPos.x);
+ selectionBox.y = Math.min(mousePos.y, dragStartPos.y);
+ selectionBox.bWidth = Std.int(Math.abs(mousePos.x - dragStartPos.x));
+ selectionBox.bHeight = Std.int(Math.abs(mousePos.y - dragStartPos.y));
+ }
+ }
+ if (FlxG.mouse.justReleased) {
+ if (selectionBoxEnabled) {
+ var minX = Std.int(Math.round(selectionBox.x / 40));
+ var minY = Math.round(selectionBox.y / 40) - 1;
+ var maxX = Std.int(Math.round((selectionBox.x + selectionBox.bWidth) / 40));
+ var maxY = Math.round((selectionBox.y + selectionBox.bHeight) / 40);
+
+ selection = [];
+ notesGroup.forEach(function(n) {
+ if (n.id >= minX && n.id <= maxX && n.step >= minY && n.step <= maxY)
+ selection.push(n);
+ });
+
+ selectionBoxEnabled = false;
+ } else {
+ // place note
+ var note = new CharterNote();
+ note.updatePos(FlxG.keys.pressed.SHIFT ? (mousePos.y / 40) : Std.int(mousePos.y / 40), Std.int(mousePos.x / 40), 0, 0);
+ notesGroup.add(note);
+ selection = [note];
+ }
+ }
+ if (FlxG.mouse.justReleasedRight)
+ openContextMenu(topMenu[2].childs);
+ }
+ selectionBox.visible = selectionBoxEnabled;
+ }
+ #end
+ public override function update(elapsed:Float) {
+ // TODO: do optimization like NoteGroup
+ updateNoteLogic(elapsed);
+
super.update(elapsed);
@@ -215,13 +278,13 @@ class Charter extends UIState {
// TODO: canTypeText in case an ui input element is focused
if (true) {
if (controls.LEFT)
- FlxG.camera.scroll.x -= 100 * elapsed;
+ FlxG.camera.scroll.x -= 250 * elapsed;
if (controls.RIGHT)
- FlxG.camera.scroll.x += 100 * elapsed;
+ FlxG.camera.scroll.x += 250 * elapsed;
if (controls.UP)
- FlxG.camera.scroll.y -= 100 * elapsed;
+ FlxG.camera.scroll.y -= 250 * elapsed;
if (controls.DOWN)
- FlxG.camera.scroll.y += 100 * elapsed;
+ FlxG.camera.scroll.y += 250 * elapsed;
if (FlxG.keys.justPressed.DELETE)
_edit_delete();
diff --git a/source/funkin/editors/charter/CharterBackdrop.hx b/source/funkin/editors/charter/CharterBackdrop.hx
index d4e3df93..ee5326f9 100644
--- a/source/funkin/editors/charter/CharterBackdrop.hx
+++ b/source/funkin/editors/charter/CharterBackdrop.hx
@@ -36,6 +36,7 @@ class CharterBackdropDummy extends UISprite {
super();
this.parent = parent;
cameras = parent.cameras;
+ scrollFactor.set(1, 0);
}
public override function updateButton() {
diff --git a/source/funkin/editors/charter/CharterNote.hx b/source/funkin/editors/charter/CharterNote.hx
index f596b697..d0aaccef 100644
--- a/source/funkin/editors/charter/CharterNote.hx
+++ b/source/funkin/editors/charter/CharterNote.hx
@@ -22,7 +22,18 @@ class CharterNote extends UISprite {
cursor = BUTTON;
}
+
+ public var step:Float;
+ public var id:Int;
+ public var susLength:Float;
+ public var type:Int;
+
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;
@@ -42,6 +53,7 @@ class CharterNote extends UISprite {
public override function update(elapsed:Float) {
super.update(elapsed);
colorTransform.redMultiplier = colorTransform.greenMultiplier = colorTransform.blueMultiplier = selected ? 0.75 : 1;
- colorTransform.redOffset = colorTransform.greenOffset = colorTransform.blueOffset = selected ? 96 : 0;
+ colorTransform.redOffset = colorTransform.greenOffset = selected ? 96 : 0;
+ colorTransform.blueOffset = selected ? 168 : 0;
}
}
\ No newline at end of file
diff --git a/source/funkin/editors/ui/UIContextMenu.hx b/source/funkin/editors/ui/UIContextMenu.hx
index 0ff38131..449d9e40 100644
--- a/source/funkin/editors/ui/UIContextMenu.hx
+++ b/source/funkin/editors/ui/UIContextMenu.hx
@@ -67,6 +67,12 @@ class UIContextMenu extends MusicBeatSubstate {
}
bg.bWidth = maxW + 8;
bg.bHeight = Std.int(lastY - bg.y + 4);
+
+ if (bg.y + bg.bHeight > FlxG.height) {
+ bg.y -= bg.bHeight;
+ for(o in contextMenuOptions)
+ o.y -= bg.bHeight;
+ }
}
public function select(option:UIContextMenuOption) {
@@ -123,7 +129,7 @@ class UIContextMenuOptionSpr extends UISliceSprite {
public override function draw() {
alpha = hovered ? 1 : 0;
- label.follow(this, 20, 0);
+ label.follow(this, 20, 2);
super.draw();
}
diff --git a/source/funkin/editors/ui/UISliceSprite.hx b/source/funkin/editors/ui/UISliceSprite.hx
index ec6afc27..eebdf1e9 100644
--- a/source/funkin/editors/ui/UISliceSprite.hx
+++ b/source/funkin/editors/ui/UISliceSprite.hx
@@ -7,6 +7,8 @@ class UISliceSprite extends UISprite {
public var bHeight:Int = 20;
public var framesOffset:Int = 0;
+ public var incorporeal:Bool = false;
+
public function new(x:Float, y:Float, w:Int, h:Int, path:String) {
super(x, y);
@@ -15,6 +17,7 @@ class UISliceSprite extends UISprite {
}
public override function updateButton() {
+ if (incorporeal) return;
__rect.x = x;
__rect.y = y;
__rect.width = bWidth;
@@ -41,7 +44,7 @@ class UISliceSprite extends UISprite {
var bottom:FlxFrame = frames.frames[framesOffset + 7];
var bottomright:FlxFrame = frames.frames[framesOffset + 8];
- @:privateAccess {
+ @:privateAccess if (visible) {
// TOP LEFT
frame = topleft;
setPosition(x, y);
@@ -49,10 +52,12 @@ class UISliceSprite extends UISprite {
super.drawSuper();
// TOP
- frame = top;
- setPosition(x + topleft.frame.width, y);
- __setSize(bWidth - topleft.frame.width - topright.frame.width, top.frame.height);
- super.drawSuper();
+ if (bWidth > topleft.frame.width + topright.frame.width) {
+ frame = top;
+ setPosition(x + topleft.frame.width, y);
+ __setSize(bWidth - topleft.frame.width - topright.frame.width, top.frame.height);
+ super.drawSuper();
+ }
// TOP RIGHT
frame = topright;
@@ -61,22 +66,26 @@ class UISliceSprite extends UISprite {
super.drawSuper();
// MIDDLE LEFT
- frame = middleleft;
- setPosition(x, y + top.frame.height);
- __setSize(middleleft.frame.width, bHeight - topleft.frame.height - bottomleft.frame.height);
- super.drawSuper();
-
- // MIDDLE
- frame = middle;
- setPosition(x + topleft.frame.width, y + top.frame.height);
- __setSize(bWidth - middleleft.frame.width - middleright.frame.width, bHeight - topleft.frame.height - bottomleft.frame.height);
- super.drawSuper();
+ if (bHeight > top.frame.height + bottom.frame.height) {
+ frame = middleleft;
+ setPosition(x, y + top.frame.height);
+ __setSize(middleleft.frame.width, bHeight - topleft.frame.height - bottomleft.frame.height);
+ super.drawSuper();
+
+ if (bWidth > middleleft.frame.width + middleright.frame.width) {
+ // MIDDLE
+ frame = middle;
+ setPosition(x + topleft.frame.width, y + top.frame.height);
+ __setSize(bWidth - middleleft.frame.width - middleright.frame.width, bHeight - topleft.frame.height - bottomleft.frame.height);
+ super.drawSuper();
+ }
- // MIDDLE RIGHT
- frame = middleright;
- setPosition(x + bWidth - topright.frame.width, y + top.frame.height);
- __setSize(middleright.frame.width, bHeight - topleft.frame.height - bottomleft.frame.height);
- super.drawSuper();
+ // MIDDLE RIGHT
+ frame = middleright;
+ setPosition(x + bWidth - topright.frame.width, y + top.frame.height);
+ __setSize(middleright.frame.width, bHeight - topleft.frame.height - bottomleft.frame.height);
+ super.drawSuper();
+ }
// BOTTOM LEFT
frame = bottomleft;
@@ -84,11 +93,13 @@ class UISliceSprite extends UISprite {
__setSize(bottomleft.frame.width, bottomleft.frame.height);
super.drawSuper();
- // BOTTOM
- frame = bottom;
- setPosition(x + bottomleft.frame.width, y + bHeight - bottom.frame.height);
- __setSize(bWidth - bottomleft.frame.width - bottomright.frame.width, bottom.frame.height);
- super.drawSuper();
+ if (bWidth > bottomleft.frame.width + bottomright.frame.width) {
+ // BOTTOM
+ frame = bottom;
+ setPosition(x + bottomleft.frame.width, y + bHeight - bottom.frame.height);
+ __setSize(bWidth - bottomleft.frame.width - bottomright.frame.width, bottom.frame.height);
+ super.drawSuper();
+ }
// BOTTOM RIGHT
frame = bottomright;
diff --git a/source/funkin/options/TreeMenu.hx b/source/funkin/options/TreeMenu.hx
index 0d8a60b7..ec13e9f1 100644
--- a/source/funkin/options/TreeMenu.hx
+++ b/source/funkin/options/TreeMenu.hx
@@ -1,5 +1,6 @@
package funkin.options;
+import flixel.FlxState;
import funkin.ui.FunkinText;
import flixel.tweens.FlxTween;
import funkin.menus.MainMenuState;
@@ -16,6 +17,8 @@ class TreeMenu extends MusicBeatState {
public var pathDesc:FunkinText;
public var pathBG:FlxSprite;
+ public var lastState:Class = Type.getClass(FlxG.state);
+
public function new() {
super();
}
@@ -76,7 +79,7 @@ class TreeMenu extends MusicBeatState {
}
public function exit() {
- FlxG.switchState(new MainMenuState());
+ FlxG.switchState((lastState != null) ? Type.createInstance(lastState, []) : new MainMenuState());
}
public function onMenuClose(m:OptionsScreen) {