Skip to content

Commit

Permalink
implement drag move for player location recording
Browse files Browse the repository at this point in the history
  • Loading branch information
MikiraSora committed Sep 11, 2024
1 parent d4ea7d5 commit a444f30
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 71 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public abstract class BulletPalleteReferencableBatchDrawTargetBase<T> : CommonBa
protected Dictionary<Texture, ConcurrentBag<(Vector2, Vector2, float)>> selectedDrawList = new();
protected List<(Vector2 pos, IBulletPalleteReferencable obj)> drawStrList = new();

private readonly SoflanList nonSoflanList = new(new ISoflan[] { new Soflan() { TGrid = TGrid.Zero, Speed = 1 } });
private readonly SoflanList nonSoflanList = new([new Soflan() { TGrid = TGrid.Zero, Speed = 1 }]);
private readonly IStringDrawing stringDrawing;
private readonly IHighlightBatchTextureDrawing highlightDrawing;
private readonly IBatchTextureDrawing batchTextureDrawing;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1008,92 +1008,101 @@ public async void OnMouseMove(Point pos)
if (IsLocked)
return;

if (!IsDesignMode)
return;

if (isMiddleMouseDown)
if (IsDesignMode)
{
isCanvasDragging = true;
if (isMiddleMouseDown)
{
isCanvasDragging = true;

var diffX = pos.X - mouseCanvasStartPosition.X;
Setting.XOffset = startXOffset + diffX;
var diffX = pos.X - mouseCanvasStartPosition.X;
Setting.XOffset = startXOffset + diffX;

var curY = pos.Y;
var diffY = curY - mouseCanvasStartPosition.Y;
var curY = pos.Y;
var diffY = curY - mouseCanvasStartPosition.Y;

var canvasY = startScrollOffset + diffY;
var audioTime = TGridCalculator.ConvertYToAudioTime_DesignMode(canvasY, this);
//ScrollViewerVerticalOffset = Math.Max(0, Math.Min(TotalDurationHeight, startScrollOffset + diffY));
ScrollTo(audioTime);
var canvasY = startScrollOffset + diffY;
var audioTime = TGridCalculator.ConvertYToAudioTime_DesignMode(canvasY, this);
//ScrollViewerVerticalOffset = Math.Max(0, Math.Min(TotalDurationHeight, startScrollOffset + diffY));
ScrollTo(audioTime);

//Log.LogInfo($"diffY: {diffY:F2} ScrollViewerVerticalOffset: {ScrollViewerVerticalOffset:F2}");
}
//Log.LogInfo($"diffY: {diffY:F2} ScrollViewerVerticalOffset: {ScrollViewerVerticalOffset:F2}");
}

if (isLeftMouseDown)
{
var r = isSelectRangeDragging;
isSelectRangeDragging = true;
var dragCall = new Action<OngekiObjectBase, Point>((vm, pos) =>
if (isLeftMouseDown)
{
var action = InteractiveManager.GetInteractive(vm);
if (r)
action.OnDragMove(vm, pos, this);
else
action.OnDragStart(vm, pos, this);
});
var r = isSelectRangeDragging;
isSelectRangeDragging = true;
var dragCall = new Action<OngekiObjectBase, Point>((vm, pos) =>
{
var action = InteractiveManager.GetInteractive(vm);
if (r)
action.OnDragMove(vm, pos, this);
else
action.OnDragStart(vm, pos, this);
});

var rp = 1 - pos.Y / ViewHeight;
var srp = 1 - mouseSelectRangeStartPosition.Y / ViewHeight;
var offsetY = 0d;
var rp = 1 - pos.Y / ViewHeight;
var srp = 1 - mouseSelectRangeStartPosition.Y / ViewHeight;
var offsetY = 0d;

//const double dragDist = 0.7;
const double trigPrecent = 0.15;
const double autoScrollSpeed = 7;
//const double dragDist = 0.7;
const double trigPrecent = 0.15;
const double autoScrollSpeed = 7;

var offsetYAcc = 0d;
if (rp >= (1 - trigPrecent) && dragOutBound)
offsetYAcc = (rp - (1 - trigPrecent)) / trigPrecent;
else if (rp <= trigPrecent && dragOutBound)
offsetYAcc = rp / trigPrecent - 1;
else if (rp < 1 - trigPrecent && rp > trigPrecent)
dragOutBound = true; //当指针在滑动范围外面,那么就可以进行任何的滑动操作了,避免指针从滑动范围内开始就滚动
offsetY = offsetYAcc * autoScrollSpeed;
var offsetYAcc = 0d;
if (rp >= (1 - trigPrecent) && dragOutBound)
offsetYAcc = (rp - (1 - trigPrecent)) / trigPrecent;
else if (rp <= trigPrecent && dragOutBound)
offsetYAcc = rp / trigPrecent - 1;
else if (rp < 1 - trigPrecent && rp > trigPrecent)
dragOutBound = true; //当指针在滑动范围外面,那么就可以进行任何的滑动操作了,避免指针从滑动范围内开始就滚动
offsetY = offsetYAcc * autoScrollSpeed;

var prev = CurrentPlayTime;
var y = Rect.MinY + Setting.JudgeLineOffsetY + offsetY;
var prev = CurrentPlayTime;
var y = Rect.MinY + Setting.JudgeLineOffsetY + offsetY;

//Log.LogDebug($"pos={pos.X:F2},{pos.Y:F2} offsetYAcc={offsetYAcc:F2} dragOutBound={dragOutBound} y={y:F2}");
//Log.LogDebug($"pos={pos.X:F2},{pos.Y:F2} offsetYAcc={offsetYAcc:F2} dragOutBound={dragOutBound} y={y:F2}");

if (offsetY != 0)
{
var audioTime = TGridCalculator.ConvertYToAudioTime_DesignMode(y, this);
ScrollTo(audioTime);
}
if (offsetY != 0)
{
var audioTime = TGridCalculator.ConvertYToAudioTime_DesignMode(y, this);
ScrollTo(audioTime);
}

//检查判断,确定是拖动已选物品位置,还是说拉框选择区域
if (IsRangeSelecting)
{
//拉框
var p = pos;
p.Y = Math.Min(TotalDurationHeight, Math.Max(0, Rect.MaxY - p.Y + offsetY));
SelectionCurrentCursorPosition = new Vector2((float)p.X, (float)p.Y);
}
else
{
//拖动已选物件
var cp = pos;
cp.Y = ViewHeight - cp.Y + Rect.MinY;
//Log.LogDebug($"SelectObjects: {SelectObjects.Count()}");
SelectObjects.ToArray().ForEach(x => dragCall(x as OngekiObjectBase, cp));
}
//检查判断,确定是拖动已选物品位置,还是说拉框选择区域
if (IsRangeSelecting)
{
//拉框
var p = pos;
p.Y = Math.Min(TotalDurationHeight, Math.Max(0, Rect.MaxY - p.Y + offsetY));
SelectionCurrentCursorPosition = new Vector2((float)p.X, (float)p.Y);
}
else
{
//拖动已选物件
var cp = pos;
cp.Y = ViewHeight - cp.Y + Rect.MinY;
//Log.LogDebug($"SelectObjects: {SelectObjects.Count()}");
SelectObjects.ToArray().ForEach(x => dragCall(x as OngekiObjectBase, cp));
}

//持续性的
if (offsetY != 0)
//持续性的
if (offsetY != 0)
{
var currentid = currentDraggingActionId = MathUtils.Random(int.MaxValue - 1);
await Task.Delay(1000 / 60);
if (currentDraggingActionId == currentid)
OnMouseMove(pos);
}
}
}
else
{
//preview mode
if (isDraggingPlayerLocation)
{
var currentid = currentDraggingActionId = MathUtils.Random(int.MaxValue - 1);
await Task.Delay(1000 / 60);
if (currentDraggingActionId == currentid)
OnMouseMove(pos);
//update current dragging player location
draggingPlayerLocationCurrentX = XGridCalculator.ConvertXToXGrid(pos.X, this);
}
}
}
Expand Down

0 comments on commit a444f30

Please sign in to comment.