2017-03-31 11:43:42 +08:00
|
|
|
|
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
|
|
|
|
|
|
using OpenTK;
|
|
|
|
|
|
2017-04-18 15:05:58 +08:00
|
|
|
|
namespace osu.Game.Rulesets.Replays
|
2017-03-31 11:43:42 +08:00
|
|
|
|
{
|
|
|
|
|
public class ReplayFrame
|
|
|
|
|
{
|
2017-04-20 14:26:42 +08:00
|
|
|
|
public Vector2 Position => new Vector2(MouseX ?? 0, MouseY ?? 0);
|
2017-03-31 11:43:42 +08:00
|
|
|
|
|
2017-04-20 17:02:09 +08:00
|
|
|
|
public bool IsImportant => MouseX.HasValue && MouseY.HasValue && (MouseLeft || MouseRight);
|
2017-03-31 11:43:42 +08:00
|
|
|
|
|
2017-04-20 14:26:42 +08:00
|
|
|
|
public float? MouseX;
|
|
|
|
|
public float? MouseY;
|
2017-03-31 11:43:42 +08:00
|
|
|
|
|
|
|
|
|
public bool MouseLeft => MouseLeft1 || MouseLeft2;
|
|
|
|
|
public bool MouseRight => MouseRight1 || MouseRight2;
|
|
|
|
|
|
|
|
|
|
public bool MouseLeft1
|
|
|
|
|
{
|
|
|
|
|
get { return (ButtonState & ReplayButtonState.Left1) > 0; }
|
|
|
|
|
set { setButtonState(ReplayButtonState.Left1, value); }
|
|
|
|
|
}
|
|
|
|
|
public bool MouseRight1
|
|
|
|
|
{
|
|
|
|
|
get { return (ButtonState & ReplayButtonState.Right1) > 0; }
|
|
|
|
|
set { setButtonState(ReplayButtonState.Right1, value); }
|
|
|
|
|
}
|
|
|
|
|
public bool MouseLeft2
|
|
|
|
|
{
|
|
|
|
|
get { return (ButtonState & ReplayButtonState.Left2) > 0; }
|
|
|
|
|
set { setButtonState(ReplayButtonState.Left2, value); }
|
|
|
|
|
}
|
|
|
|
|
public bool MouseRight2
|
|
|
|
|
{
|
|
|
|
|
get { return (ButtonState & ReplayButtonState.Right2) > 0; }
|
|
|
|
|
set { setButtonState(ReplayButtonState.Right2, value); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void setButtonState(ReplayButtonState singleButton, bool pressed)
|
|
|
|
|
{
|
|
|
|
|
if (pressed)
|
|
|
|
|
ButtonState |= singleButton;
|
|
|
|
|
else
|
|
|
|
|
ButtonState &= ~singleButton;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public double Time;
|
|
|
|
|
|
|
|
|
|
public ReplayButtonState ButtonState;
|
|
|
|
|
|
|
|
|
|
protected ReplayFrame()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2017-04-20 14:26:42 +08:00
|
|
|
|
public ReplayFrame(double time, float? mouseX, float? mouseY, ReplayButtonState buttonState)
|
2017-03-31 11:43:42 +08:00
|
|
|
|
{
|
2017-04-20 14:26:42 +08:00
|
|
|
|
MouseX = mouseX;
|
|
|
|
|
MouseY = mouseY;
|
2017-03-31 11:43:42 +08:00
|
|
|
|
ButtonState = buttonState;
|
|
|
|
|
Time = time;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string ToString()
|
|
|
|
|
{
|
|
|
|
|
return $"{Time}\t({MouseX},{MouseY})\t{MouseLeft}\t{MouseRight}\t{MouseLeft1}\t{MouseRight1}\t{MouseLeft2}\t{MouseRight2}\t{ButtonState}";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|