adsgfasdg

This commit is contained in:
lunarcleint
2023-08-21 21:00:55 -07:00
parent 008ad05bf1
commit bf475d9bd3
2 changed files with 82 additions and 4 deletions
@@ -0,0 +1,66 @@
package funkin.editors.charter;
import flixel.tweens.misc.VarTween;
import flixel.tweens.FlxTween;
class ChartHoverNote extends UISprite {
public var angleTween:FlxTween;
public var onGrid:Bool = false;
public var id:Int = 0;
public var nextID:Int = 0;
public function new() {
super();
antialiasing = true;
loadGraphic(Paths.image('editors/charter/note'), true, 157, 154);
animation.add("note", [for(i in 0...frames.frames.length) i], 0, true);
animation.play("note");
this.setUnstretchedGraphicSize(40, 40, false);
moves = selectable = false;
colorTransform.color = 0xFFFFFF;
}
public override function update(elapsed:Float) {
super.update(elapsed);
var mousePos = FlxG.mouse.getWorldPosition(__lastDrawCameras[0]);
alpha = FlxMath.lerp(alpha, onGrid ? 0.2 : 0, 1/8);
id = Math.floor(x / 40);
if (onGrid) {
Charter.instance.gridBackdropDummy.cursor = BUTTON;
x = (nextID = Math.floor(mousePos.x / 40)) * 40;
y = (FlxG.keys.pressed.SHIFT ? (mousePos.y / 40) : Math.floor(mousePos.y / 40)) * 40;
if (id != nextID) {
if (angleTween != null) angleTween.cancel();
angle = switch(id % 4) {
case 0: -90;
case 1: 180;
case 2: 0;
case 3: 90;
default: 0; // how is that even possible
};
var destAngle = switch((nextID % 4)) {
case 0: -90;
case 1: 180;
case 2: 0;
case 3: 90;
default: 0; // how is that even possible
};
angleTween = FlxTween.tween(this, {angle: destAngle}, 2/3, {ease: function(t) {
return ((Math.sin(t * Math.PI) * 0.35) * 3 * t * Math.sqrt(1 - t)) + t;
}, onComplete: function (t) {angleTween = null;}});
}
} else if (alpha > 0) {
Charter.instance.gridBackdropDummy.cursor = ARROW;
x = mousePos.x - 20; y = mousePos.y -20;
}
mousePos.put();
}
}
+16 -4
View File
@@ -55,6 +55,7 @@ class Charter extends UIState {
public var topLimit:FlxSprite;
public var bottomLimit:FlxSprite;
public var bottomSeparator:FlxSprite;
public var hoverNote:ChartHoverNote;
public var strumlineInfoBG:FlxSprite;
public var strumlineAddButton:CharterStrumlineExtraButton;
@@ -342,6 +343,9 @@ class Charter extends UIState {
eventsBackdrop.cameras = [charterCamera];
add(eventsBackdrop);
hoverNote = new ChartHoverNote();
hoverNote.cameras = [charterCamera];
add(gridBackdropDummy = new CharterBackdropDummy(gridBackdrop));
sectionSeparator = new FlxBackdrop(null, Y, 0, 0);
sectionSeparator.x = -20;
@@ -421,6 +425,7 @@ class Charter extends UIState {
// adds grid and notes so that they're ALWAYS behind the UI
add(gridBackdrop);
add(hoverNote);
add(sectionSeparator);
add(beatSeparator);
add(addEventSpr);
@@ -549,6 +554,7 @@ class Charter extends UIState {
if (!gridBackdropDummy.hoveredByChild && !FlxG.mouse.pressed)
gridActionType = NONE;
selectionBox.visible = false;
hoverNote.onGrid = false;
switch(gridActionType) {
case BOX:
if (gridBackdropDummy.hoveredByChild) {
@@ -625,19 +631,25 @@ class Charter extends UIState {
case NONE:
if (FlxG.mouse.justPressed)
FlxG.mouse.getWorldPosition(charterCamera, dragStartPos);
FlxG.mouse.getWorldPosition(charterCamera, dragStartPos);
hoverNote.visible = hoveredSprite != null ? hoveredSprite is CharterNote : true;
if (gridBackdropDummy.hovered) {
// AUTO DETECT
if (FlxG.mouse.pressed && (Math.abs(mousePos.x - dragStartPos.x) > 20 || Math.abs(mousePos.y - dragStartPos.y) > 20))
gridActionType = BOX;
var id = Math.floor(mousePos.x / 40);
var mouseOnGrid = id >= 0 && id < 4 * gridBackdrop.strumlinesAmount && mousePos.y >= 0;
hoverNote.onGrid = mouseOnGrid;
if (FlxG.mouse.justReleased) {
if (selection.length > 1) {
selection = []; // clear selection
} else {
// place note
var id = Math.floor(mousePos.x / 40);
if (id >= 0 && id < 4 * gridBackdrop.strumlinesAmount && mousePos.y >= 0) {
if (mouseOnGrid) {
var note = new CharterNote();
note.updatePos(FlxG.keys.pressed.SHIFT ? (mousePos.y / 40) : Math.floor(mousePos.y / 40), id, 0, 0);
notesGroup.add(note);