private void UpdateTimelineSelection() { float diff = Camera.main.ScreenToWorldPoint(Input.mousePosition).x - dragSelectTimeline.position.x; float timelineScaleMulti = Timeline.scale / 20f; dragSelectTimeline.localScale = new Vector3(diff * timelineScaleMulti, 1.1f, 1); Vector2 topLeft = dragSelectTimeline.transform.TransformPoint(0, 0, 0); Vector2 size = dragSelectTimeline.transform.TransformVector(1, 1, 1); Vector2 center = new Vector2(topLeft.x + size.x / 2, topLeft.y - size.y / 2); float minX = Math.Min(center.x - size.x / 2, center.x + size.x / 2); float maxX = Math.Max(center.x - size.x / 2, center.x + size.x / 2); float minY = Math.Min(center.y - size.y / 2, center.y + size.y / 2); float maxY = Math.Max(center.y - size.y / 2, center.y + size.y / 2); Rect selectionRect = Rect.MinMaxRect(minX, minY, maxX, maxY); float offscreenOffset = timelineNotes.parent.position.x; QNT_Timestamp start = Timeline.time + Relative_QNT.FromBeatTime((minX - offscreenOffset - 1.0f) * timelineScaleMulti); QNT_Timestamp end = Timeline.time + Relative_QNT.FromBeatTime((maxX - offscreenOffset + 1.0f) * timelineScaleMulti); if (start > end) { QNT_Timestamp temp = start; start = end; end = temp; } List <Target> newSelectedTargets = new List <Target>(); foreach (Target target in new NoteEnumerator(start, end)) { if (target.IsTimelineInsideRect(selectionRect)) { newSelectedTargets.Add(target); } } var deselectedTargets = dragTimelineSelectedTargets.Except(newSelectedTargets); foreach (Target t in deselectedTargets) { t.MakeTimelineDeselectTarget(); } var selectedTargets = newSelectedTargets.Except(dragTimelineSelectedTargets); foreach (Target t in selectedTargets) { t.MakeTimelineSelectTarget(); } dragTimelineSelectedTargets = newSelectedTargets; }
private void UpdateDragTimelineTargetAction() { foreach (TargetTimelineMoveIntent intent in timelineTargetMoveIntents) { Relative_QNT offsetFromDragPoint = intent.startTick - startTimelineMoveTime; var mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition); mousePos.x /= Timeline.scaleTransform; mousePos.x -= timelineNotes.parent.position.x; QNT_Timestamp newTime = SnapToBeat(mousePos.x); newTime += offsetFromDragPoint; intent.target.time = newTime; intent.intendedTick = newTime; } }
//Gets the cue status based on a target. public static Cue ToCue(Target target, Relative_QNT offset) { int pitch = 0; Vector2 tempPos = new Vector2(); int x = 0, y = 0; float offsetX = 0, offsetY = 0; Vector2 pitch98 = new Vector2(NotePosCalc.xSize * -2f, -NotePosCalc.ySize); Vector2 pitch99 = new Vector2(NotePosCalc.xSize * 2f, -NotePosCalc.ySize); Vector2 pitch100 = new Vector2(NotePosCalc.xSize * -2f, NotePosCalc.ySize); Vector2 pitch101 = new Vector2(NotePosCalc.xSize * 2f, NotePosCalc.ySize); //If it's a melee note. if (target.data.behavior == TargetBehavior.Melee || target.data.behavior == TargetBehavior.Mine) { pitch = 98; if (target.data.x > 0) { pitch += 1; } if (target.data.y > 0) { pitch += 2; } switch (pitch) { case 98: offsetX = pitch98.x - target.data.position.x; offsetY = pitch98.y - target.data.position.y; break; case 99: offsetX = pitch99.x - target.data.position.x; offsetY = pitch99.y - target.data.position.y; break; case 100: offsetX = pitch100.x - target.data.position.x; offsetY = pitch100.y - target.data.position.y; break; case 101: offsetX = pitch101.x - target.data.position.x; offsetY = pitch101.y - target.data.position.y; break; } offsetX = -offsetX / NotePosCalc.xSize / 4; offsetY = -offsetY / NotePosCalc.ySize / 4; } else { //We have to divide by the new positions between the grid. tempPos.x = (target.data.x + xStart) / xSize; tempPos.y = (target.data.y + yStart) / ySize; x = Mathf.Clamp(Mathf.RoundToInt(tempPos.x), 0, 11); y = Mathf.Clamp(Mathf.RoundToInt(tempPos.y), 0, 6); pitch = x + 12 * y; offsetX = (tempPos.x - x); offsetY = (tempPos.y - y); } Cue cue = new Cue() { tick = (int)(target.data.time + offset).tick, tickLength = (int)target.data.beatLength.tick, pitch = pitch, velocity = target.data.velocity, gridOffset = new Cue.GridOffset { x = (float)Math.Round(offsetX, 2), y = (float)Math.Round(offsetY, 2) }, handType = target.data.handType, behavior = target.data.behavior, }; if (NRSettings.config.useAutoZOffsetWith360) { cue.zOffset = GetZOffsetForX(target.data.x); } return(cue); }
private QNT_Timestamp SnapToBeat(float posX) { QNT_Timestamp time = Timeline.time + Relative_QNT.FromBeatTime(posX); return(timeline.GetClosestBeatSnapped(time + Constants.DurationFromBeatSnap((uint)timeline.beatSnap) / 2, (uint)timeline.beatSnap)); }