internal ReplayFrame(int time, Vector2 position, pButtonState mouse) { this.position = position; left = ((mouse & pButtonState.Left) > 0 ? ButtonState.Pressed : ButtonState.Released); right = ((mouse & pButtonState.Right) > 0 ? ButtonState.Pressed : ButtonState.Released); this.time = time; }
public static pButtonState pMouseCreate(bool l, bool l2, bool r, bool r2, bool s = false) { pButtonState p = pButtonState.None; if (l) { p |= pButtonState.Left1; } if (l2) { p |= pButtonState.Left2; } if (r) { p |= pButtonState.Right1; } if (r2) { p |= pButtonState.Right2; } if (s) { p |= pButtonState.Smoke; } return(p); }
public bReplayFrame(int time, float posX, float posY, pButtonState buttonState) { mouseX = posX; mouseY = posY; this.buttonState = buttonState; SetButtonStates(buttonState); this.time = time; }
public ReplayFrame(int time, float mousePosX, float posY, pButtonState mouseButtonState) { MousePosX = mousePosX; MousePosY = posY; MouseButtonState = mouseButtonState; method_0(mouseButtonState); this.Time = time; }
// Token: 0x06000E1A RID: 3610 // RVA: 0x0000EA65 File Offset: 0x0000CC65 public Class14(int int_1, float float_2, float float_3, pButtonState pButtonState_1) { this.float_0 = float_2; this.float_1 = float_3; this.pButtonState_0 = pButtonState_1; this.method_0(pButtonState_1); this.int_0 = int_1; }
private void SetButtonStates(pButtonState buttonState) { mouseLeft |= (buttonState & (pButtonState.Left1 | pButtonState.Left2)) > 0; mouseLeft1 |= (buttonState & pButtonState.Left1) > 0; mouseLeft2 |= (buttonState & pButtonState.Left2) > 0; mouseRight |= (buttonState & (pButtonState.Right1 | pButtonState.Right2)) > 0; mouseRight1 |= (buttonState & pButtonState.Right1) > 0; mouseRight2 |= (buttonState & pButtonState.Right2) > 0; }
public void SetButtonStates(pButtonState buttonState) { this.buttonState = buttonState; mouseLeft = (buttonState & (pButtonState.Left1 | pButtonState.Left2)) > 0; mouseLeft1 = (buttonState & pButtonState.Left1) > 0; mouseLeft2 = (buttonState & pButtonState.Left2) > 0; mouseRight = (buttonState & (pButtonState.Right1 | pButtonState.Right2)) > 0; mouseRight1 = (buttonState & pButtonState.Right1) > 0; mouseRight2 = (buttonState & pButtonState.Right2) > 0; }
public void method_0(pButtonState pButtonState_1) { MouseButtonState = pButtonState_1; bool_0 = ((pButtonState_1 & (pButtonState.Left1 | pButtonState.Left2)) > pButtonState.None); bool_2 = ((pButtonState_1 & pButtonState.Left1) > pButtonState.None); bool_4 = ((pButtonState_1 & pButtonState.Left2) > pButtonState.None); bool_1 = ((pButtonState_1 & (pButtonState.Right1 | pButtonState.Right2)) > pButtonState.None); bool_3 = ((pButtonState_1 & pButtonState.Right1) > pButtonState.None); bool_5 = ((pButtonState_1 & pButtonState.Right2) > pButtonState.None); }
// Token: 0x06000E1B RID: 3611 // RVA: 0x0004DCC0 File Offset: 0x0004BEC0 public void method_0(pButtonState pButtonState_1) { this.pButtonState_0 = pButtonState_1; this.bool_0 = ((pButtonState_1 & (pButtonState.Left1 | pButtonState.Left2)) > pButtonState.None); this.bool_2 = ((pButtonState_1 & pButtonState.Left1) > pButtonState.None); this.bool_4 = ((pButtonState_1 & pButtonState.Left2) > pButtonState.None); this.bool_1 = ((pButtonState_1 & (pButtonState.Right1 | pButtonState.Right2)) > pButtonState.None); this.bool_3 = ((pButtonState_1 & pButtonState.Right1) > pButtonState.None); this.bool_5 = ((pButtonState_1 & pButtonState.Right2) > pButtonState.None); }
// Token: 0x06000E1C RID: 3612 // RVA: 0x0004DD20 File Offset: 0x0004BF20 public Class14(Class32 class32_0) { this.pButtonState_0 = (pButtonState)class32_0.ReadByte(); this.method_0(this.pButtonState_0); byte b = class32_0.ReadByte(); if (b > 0) { this.method_0(pButtonState.Right1); } this.float_0 = class32_0.ReadSingle(); this.float_1 = class32_0.ReadSingle(); this.int_0 = class32_0.ReadInt32(); }
public ReplayFrame(SerializationReader reader) { MouseButtonState = (pButtonState)reader.ReadByte(); method_0(MouseButtonState); var b = reader.ReadByte(); if (b > 0) { method_0(pButtonState.Right1); } MousePosX = reader.ReadSingle(); MousePosY = reader.ReadSingle(); Time = reader.ReadInt32(); }
public bReplayFrame(SerializationReader sr) { buttonState = (pButtonState)sr.ReadByte(); SetButtonStates(buttonState); byte bt = sr.ReadByte(); if (bt > 0)//Handle Pre-Taiko compatible replays. { SetButtonStates(pButtonState.Right1); } mouseX = sr.ReadSingle(); mouseY = sr.ReadSingle(); time = sr.ReadInt32(); }
internal void ReadReplayData(string replayData) { if (replayData.Length > 0) { string[] replaylines = replayData.Split(','); bReplayFrame lastF; if (Replay.Count > 0) { lastF = Replay[Replay.Count - 1]; } else { lastF = new bReplayFrame(0, 0, 0, pButtonState.None); } foreach (string replayline in replaylines) { if (replayline.Length == 0) { continue; } string[] data = replayline.Split('|'); if (data.Length < 4) { continue; } if (data[0] == @"-12345") { Seed = int.Parse(data[3]); continue; } pButtonState buttons = (pButtonState)Enum.Parse(typeof(pButtonState), data[3]); bReplayFrame newF = new bReplayFrame(int.Parse(data[0]) + lastF.time, float.Parse(data[1], GameBase.nfi), float.Parse(data[2], GameBase.nfi), buttons); Replay.Add(newF); lastF = newF; } } }
internal static void UpdateFrame() { if (GameBase.MenuActive) { return; } MouseHandler.UpdateWindowsMouse(); if (doubleClickTime > 0) { doubleClickTime = (int)Math.Max(0, doubleClickTime - GameBase.ElapsedMilliseconds); } //Initialises the current input/processing loop frame. In the case of 2x replays, up to two frames may be processed in a single game tick. int loopFrame = 0; if (ConfigManager.sMouseSpeed != 1 && GameBase.Mode != Modes.Edit) { //Handle mouse velocity setting. MouseState newState = Mouse.GetState(); if (Game.IsActive && newState.X >= 0 && newState.X < GameBase.WindowWidth && newState.Y >= 0 && newState.Y < GameBase.WindowHeight) { #if newmouse Vector2 newMouseVelocityFloat = new Vector2((float)(mouseVelocityFloat.X + (newState.X - mouseVelocityFloat.X) * ConfigManager.sMouseSpeed), (float)(mouseVelocityFloat.Y + (newState.Y - mouseVelocityFloat.Y) * ConfigManager.sMouseSpeed)); if (mouseVelocityPoint.X != newState.X || mouseVelocityPoint.Y != newState.Y) { mouseVelocityFloat = newMouseVelocityFloat; mouseVelocityPoint = new Point((int)Math.Round(mouseVelocityFloat.X), (int)Math.Round(mouseVelocityFloat.Y)); if (GameBase.WindowRectangle.Contains(mouseVelocityPoint)) { Mouse.SetPosition(mouseVelocityPoint.X, mouseVelocityPoint.Y); } } #else Mouse.SetPosition((int)Math.Round(mouse.X + (newState.X - mouse.X) * ConfigManager.sMouseSpeed), (int)Math.Round(mouse.Y + (newState.Y - mouse.Y) * ConfigManager.sMouseSpeed)); #endif /*MouseHandler.MousePoint.X += (int)((newState.X - mouse.X) * MouseHandler.mouseSpeed); * MouseHandler.MousePoint.Y += (int)((newState.Y - mouse.Y) * MouseHandler.mouseSpeed); * * if (!Player.Playing && !GameBase.graphics.IsFullScreen && ( MouseHandler.MousePoint.X < 0 || MouseHandler.MousePoint.X >= GameBase.WindowWidth || MouseHandler.MousePoint.Y < 0 || MouseHandler.MousePoint.Y >= GameBase.WindowHeight)) * Mouse.SetPosition(MouseHandler.MousePoint.X, MouseHandler.MousePoint.Y); * * mouse = newState;*/ mouse = Mouse.GetState(); MouseHandler.MousePosition.X = mouse.X; MouseHandler.MousePosition.Y = mouse.Y; MouseHandler.MousePoint.X = mouse.X; MouseHandler.MousePoint.Y = mouse.Y; } else { mouse = newState; MouseHandler.MousePosition.X = mouse.X; MouseHandler.MousePosition.Y = mouse.Y; MouseHandler.MousePoint.X = mouse.X; MouseHandler.MousePoint.Y = mouse.Y; } } else { mouse = Mouse.GetState(); MouseHandler.MousePosition.X = mouse.X; MouseHandler.MousePosition.Y = mouse.Y; MouseHandler.MousePoint.X = mouse.X; MouseHandler.MousePoint.Y = mouse.Y; } if (!Player.Playing || !ConfigManager.sMouseDisableButtons) { MouseHandler.mouseLeft = mouse.LeftButton; if (TabletHandler.pendingTabletUpdate) { //Make sure we accept a tablet click even when it is release in under 16ms. MouseHandler.mouseLeft = ButtonState.Pressed; TabletHandler.pendingTabletUpdate = false; } else if (TabletHandler.tabletLeft == ButtonState.Pressed) { MouseHandler.mouseLeft = TabletHandler.tabletLeft; } MouseHandler.mouseRight = mouse.RightButton; MouseHandler.mouseMiddle = mouse.MiddleButton; MouseHandler.mouseBack = mouse.XButton1; if (Game.IsActive && GameBase.Mode != Modes.Edit && GameBase.Mode != Modes.Menu) { if (MouseHandler.mouseBack == ButtonState.Pressed && MouseHandler.mouseBackLast != MouseHandler.mouseBack) { KeyboardHandler.DoKeyPressed(Keys.Escape); } MouseHandler.mouseBackLast = MouseHandler.mouseBack; } } else { MouseHandler.mouseLeft = ButtonState.Released; MouseHandler.mouseRight = ButtonState.Released; } bool runningSlow = false; do { AudioEngine.Update(); lock (StreamingManager.LockReplayScore) { if (ReplayMode && ReplayScore != null && ReplayScore.replay != null) { int count = ReplayScore.replay.Count; if (GameBase.Mode == Modes.Play && Player.currentScore != null && count > 0 && ReplayFrame < count - 2 && (ReplayToEnd || !ReplayStreaming || ReplayScore.replay[count - 1].time - AudioEngine.Time > 1000)) { Buffering = false; /* if (ReplayStreaming && !Player.IsFailed && Player.Paused) * Buffering = false; * else * {*/ if (ReplayFrame < count - 2 && (ReplayScore.replay[ReplayFrame + 1].time <= AudioEngine.Time)) // && (Math.Abs(ReplayScore.replay[ReplayFrame + 1].time - AudioEngine.Time) < 10 || AudioEngine.Time - ReplayScore.replay[ReplayFrame + 1].time > 0)) { ReplayFrame++; ReplayOk = true; } else { ReplayOk = false; } runningSlow = AudioEngine.Time - ReplayScore.replay[ReplayFrame].time > 16 && ReplayOk; //skip unnecessary frames if (runningSlow) { while (ReplayFrame < count - 2 && !ReplayScore.replay[ReplayFrame].mouseLeft && !ReplayScore.replay[ReplayFrame].mouseRight && ReplayScore.replay[ReplayFrame + 1].time <= AudioEngine.Time && ReplayScore.replay[ReplayFrame].mouseLeft == leftButtonLastBool && ReplayScore.replay[ReplayFrame].mouseRight == rightButtonLastBool && ReplayScore.replay[ReplayFrame].buttonState == lastButtonState && !Player.IsSpinning) { Console.WriteLine("replay frame {0} skipped!!!!", ReplayFrame); ReplayFrame++; } } Vector2 pos; if (MouseButtonInstantRelease) { leftButton1i = false; leftButton2i = false; rightButton1i = false; rightButton2i = false; leftButton = ButtonState.Released; rightButton = ButtonState.Released; } if (ReplayOk && (ReplayScore.replay[ReplayFrame].mouseLeft || ReplayScore.replay[ReplayFrame].mouseRight || ReplayScore.replay[ReplayFrame].buttonState != lastButtonState || Player.IsSpinning)) { AudioEngine.Time = ReplayScore.replay[ReplayFrame].time; leftButton1i = (!MouseButtonInstantRelease || !leftButton1) && ReplayScore.replay[ReplayFrame].mouseLeft1; leftButton1 = ReplayScore.replay[ReplayFrame].mouseLeft1; leftButton2i = (!MouseButtonInstantRelease || !leftButton2) && ReplayScore.replay[ReplayFrame].mouseLeft2; leftButton2 = ReplayScore.replay[ReplayFrame].mouseLeft2; rightButton1i = (!MouseButtonInstantRelease || !rightButton1) && ReplayScore.replay[ReplayFrame].mouseRight1; rightButton1 = ReplayScore.replay[ReplayFrame].mouseRight1; rightButton2i = (!MouseButtonInstantRelease || !rightButton2) && ReplayScore.replay[ReplayFrame].mouseRight2; rightButton2 = ReplayScore.replay[ReplayFrame].mouseRight2; leftButton = leftButton1i || leftButton2i ? ButtonState.Pressed : ButtonState.Released; rightButton = rightButton1i || rightButton2i ? ButtonState.Pressed : ButtonState.Released; pos = GameBase.GamefieldToDisplay( new Vector2(ReplayScore.replay[ReplayFrame].mouseX, ReplayScore.replay[ReplayFrame].mouseY)); // *WindowWidth / ReplayScore.resolution; lastButtonState = ReplayScore.replay[ReplayFrame].buttonState; } else if (ReplayScore.replay[ReplayFrame].time == ReplayScore.replay[ReplayFrame + 1].time) { pos = GameBase.GamefieldToDisplay( new Vector2(ReplayScore.replay[ReplayFrame].mouseX, ReplayScore.replay[ReplayFrame].mouseY)); } else if (ReplayScore.replay[ReplayFrame].time >= AudioEngine.Time) { int p1 = Math.Max(0, ReplayFrame - 1); int p2 = ReplayFrame; pos = Vector2.Lerp( GameBase.GamefieldToDisplay( new Vector2(ReplayScore.replay[p1].mouseX, ReplayScore.replay[p1].mouseY)), GameBase.GamefieldToDisplay( new Vector2(ReplayScore.replay[p2].mouseX, ReplayScore.replay[p2].mouseY)), Math.Max(0, ( 1 - (float)(ReplayScore.replay[p2].time - AudioEngine.Time) / (ReplayScore.replay[p2].time - ReplayScore.replay[p1].time)))); if (!MouseButtonInstantRelease) { leftButton = ReplayScore.replay[p2].mouseLeft ? ButtonState.Pressed : ButtonState.Released; rightButton = ReplayScore.replay[p2].mouseRight ? ButtonState.Pressed : ButtonState.Released; } } else { int p1 = ReplayFrame; int p2 = Math.Min(count - 1, ReplayFrame + 1); pos = Vector2.Lerp( GameBase.GamefieldToDisplay( new Vector2(ReplayScore.replay[p1].mouseX, ReplayScore.replay[p1].mouseY)), GameBase.GamefieldToDisplay( new Vector2(ReplayScore.replay[p2].mouseX, ReplayScore.replay[p2].mouseY)), Math.Max(0, 1 - ((float)(ReplayScore.replay[p2].time - AudioEngine.Time) / (ReplayScore.replay[p2].time - ReplayScore.replay[p1].time)))); if (!MouseButtonInstantRelease) { leftButton = ReplayScore.replay[p1].mouseLeft ? ButtonState.Pressed : ButtonState.Released; rightButton = ReplayScore.replay[p1].mouseRight ? ButtonState.Pressed : ButtonState.Released; } } CursorPosition = pos; CursorPoint = new Point((int)CursorPosition.X, (int)CursorPosition.Y); Player.Playing = false; } else if (ReplayStreaming) { Player.Playing = false; if (ReplayToEnd) { if (Player.Paused && !Player.Failed) { Buffering = false; } if (Player.ReplayBufferText != null && Player.Failed) { Player.ReplayBufferText.Text = "User Failed"; } } else /*if (HitObjectManager.hitObjects != null && * AudioEngine.Time >= HitObjectManager.hitObjects[0].StartTime - HitObjectManager.PreEmpt)*/ { Buffering = true; float percent; if (count == 0) { percent = 0; } else { percent = MathHelper.Clamp( (float)(ReplayScore.replay[count - 1].time - AudioEngine.Time) / 10, 0, 100); } if (Player.ReplayBufferText != null) { if (Player.Failed) { Player.ReplayBufferText.Text = "Failed"; } else { Player.ReplayBufferText.Text = string.Format("Buffering {0:0.0}%...", percent); } } } } } } if (!ReplayMode) { //todo: move this to the outer loop? Player.Playing = GameBase.Mode == Modes.Play && AudioEngine.Time >= Player.skipBoundary && !Player.Failed && !Player.Paused && !EventManager.BreakMode && Game.IsActive && !Player.currentScore.pass; if (Player.Playing && !GameBase.graphics.IsFullScreen) { if (Cursor.Clip == cursorOriginalBounds) { Cursor.Clip = GameBase.Form.RectangleToScreen(GameBase.Form.ClientRectangle); } } else if (Cursor.Clip != cursorOriginalBounds) { Cursor.Clip = cursorOriginalBounds; } CursorPosition = MouseHandler.MousePosition; CursorPoint = MouseHandler.MousePoint; leftButton = MouseHandler.mouseLeft; leftButton1i = leftButton == ButtonState.Pressed && !leftButtonLastBool; leftButton1 = leftButton == ButtonState.Pressed; leftButton2i = leftButton == ButtonState.Pressed && !leftButtonLastBool; leftButton2 = leftButton == ButtonState.Pressed; rightButton = MouseHandler.mouseRight; rightButton1i = rightButton == ButtonState.Pressed && !rightButtonLastBool; rightButton1 = rightButton == ButtonState.Pressed; rightButton2i = rightButton == ButtonState.Pressed && !rightButtonLastBool; rightButton2 = rightButton == ButtonState.Pressed; } //Update mouse cursor position, except in editor mode where we use the windows cursor. if (!GameBase.MenuVisible) { if (spriteCursor.IsVisible && GameBase.SixtyFramesPerSecondFrame) { pSprite trail = new pSprite(SkinManager.Load("cursortrail"), FieldTypes.WindowScaleOnly, (SkinManager.Current.CursorCentre ? OriginTypes.Centre : OriginTypes.TopLeft), ClockTypes.Game, CursorPosition, spriteCursor.Depth - 0.001F, false, Color.White); trail.FadeOut(150); trail.CurrentScale = spriteCursor.CurrentScale; if (SkinManager.Current.CursorTrailRotate) { trail.CurrentRotation = spriteCursor.CurrentRotation; } GameBase.spriteManagerOverlay.Add(trail); } spriteCursor.CurrentPosition = CursorPosition; } //Only do actions on the input if the window is active. if (Game.IsActive || ReplayMode) { //Mouse wheel MouseHandler.MouseWheelHandled = false; if (mouse.ScrollWheelValue != scrollWheel) { /*if (ChatEngine.IsVisible) * { * if (mouse.ScrollWheelValue > scrollWheel) * ChatEngine.MouseHandler_OnMouseWheelUp(null, null); * else * ChatEngine.MouseHandler_OnMouseWheelDown(null, null); * } * else * {*/ if (mouse.ScrollWheelValue > scrollWheel) { MouseHandler.DoMouseWheelUp(); } else { MouseHandler.DoMouseWheelDown(); } /*}*/ scrollWheel = mouse.ScrollWheelValue; } try { keyboard = Keyboard.GetState(); } catch (InvalidOperationException) { } if (!ReplayMode) { MouseViaKeyboardControls(); } Keys[] newKeys = (Keys[])keyboard.GetPressedKeys().Clone(); if (pressedKeys != null && !keyboard.IsKeyDown(Keys.Scroll)) { KeyboardHandler.ControlPressed = (keyboard.IsKeyDown(Keys.LeftControl) || keyboard.IsKeyDown(Keys.RightControl)); KeyboardHandler.AltPressed = (keyboard.IsKeyDown(Keys.LeftAlt) || keyboard.IsKeyDown(Keys.RightAlt)); KeyboardHandler.ShiftPressed = (keyboard.IsKeyDown(Keys.LeftShift) || keyboard.IsKeyDown(Keys.RightShift)); for (int i = 0; i < newKeys.Length; i++) { Keys k = newKeys[i]; bool bFound = false; for (int j = 0; j < pressedKeys.Length; j++) { if (k == pressedKeys[j]) { bFound = true; break; } } if (!bFound && GameBase.FadeState != FadeStates.FadeOut) { repeatTickCurrent = -100; BanchoClient.Activity(); GameBase.KeyboardHandler_OnKeyPressed(null, k); if (ChatEngine.IsVisible) { string ks = k.ToString(); if (ks.Length == 2 && ks[0] == 'F' && ks[1] >= '0' && ks[1] <= '9') { KeyboardHandler.DoKeyPressed(k); } else { ChatEngine.GameBase_OnKeyRepeat(null, k, true); } } else if (GameBase.ActiveDialog != null) { GameBase.ActiveDialog.HandleKey(k); } else if (!thisBlockKey) { KeyboardHandler.DoKeyPressed(k); } } } } pressedKeys = newKeys; repeatTickCurrent += GameBase.ElapsedMilliseconds; if (repeatTickCurrent >= repeatTickRate) { repeatTickCurrent -= repeatTickRate; if (pressedKeys != null && !keyboard.IsKeyDown(Keys.Scroll)) { foreach (Keys k in newKeys) { bool bFound = false; foreach (Keys k2 in pressedKeys) { if (k == k2) { bFound = true; break; } } if (ChatEngine.IsVisible) { ChatEngine.GameBase_OnKeyRepeat(null, k, false); } else if (GameBase.ActiveDialog == null && bFound && GameBase.FadeState == FadeStates.Idle && !thisBlockKey) { KeyboardHandler.DoOnKeyRepeat(k); } } } if (leftButton == ButtonState.Pressed && MouseHandler.MouseDown && GameBase.FadeState != FadeStates.FadeOut) { MouseHandler.DoOnClickRepeat(); } } MouseHandler.actualClickRegistered = (MouseHandler.mouseLeft == ButtonState.Pressed && mouseLeftActualPrev != ButtonState.Pressed) || (MouseHandler.mouseRight == ButtonState.Pressed && mouseRightActualPrev != ButtonState.Pressed); if (leftButtonLast != leftButton || rightButtonLast != rightButton) { MouseHandler.LastButton2 = MouseHandler.LastButton; MouseHandler.LastButton = MouseHandler.MouseDownButton; MouseHandler.MouseDownButton = MouseButtons.None; if (leftButton == ButtonState.Pressed) { MouseHandler.MouseDownButton |= MouseButtons.Left; } if (rightButton == ButtonState.Pressed) { MouseHandler.MouseDownButton |= MouseButtons.Right; } } //We don't have a replay click, so lets check for physical mouse clicks. //In the case that there is a replay and actual click the same frame, doOnClick will be called only once (above). if (MouseHandler.actualClickRegistered && ReplayMode && GameBase.FadeState != FadeStates.FadeOut) { bool old = MouseHandler.gamePressedRegistered; MouseHandler.gamePressedRegistered = false; MouseHandler.DoOnClick(); MouseHandler.gamePressedRegistered = old; } leftCond = leftButton == ButtonState.Pressed && leftButtonLast != leftButton; rightCond = rightButton == ButtonState.Pressed && rightButtonLast != rightButton; middleCond = MouseHandler.mouseMiddle == ButtonState.Pressed && mouseMiddlePrev != MouseHandler.mouseMiddle; MouseHandler.gameClickRegistered = false; if (leftCond || rightCond || middleCond) { if (!middleCond) { if (SkinManager.Current.CursorExpand) { spriteCursor.Transformations.RemoveAll( delegate(Transformation tr) { return(tr.Type != TransformationType.Rotation); }); Transformation t = new Transformation(TransformationType.Scale, 1, 1.3F, GameBase.Time, GameBase.Time + 100); t.Easing = EasingTypes.In; spriteCursor.Transformations.Add(t); } MouseHandler.clickPosition = new Vector2(mouse.X, mouse.Y); MouseHandler.gamePressedRegistered = true; MouseHandler.gameClickRegistered = true; if (doubleClickTime > 0 && GameBase.FadeState != FadeStates.FadeOut) { MouseHandler.DoOnDoubleClick(); } } if (GameBase.FadeState != FadeStates.FadeOut) { MouseHandler.DoOnClick(); repeatTickCurrent = 0; doubleClickTime = 250; } } else if (leftButton == ButtonState.Released && rightButton == ButtonState.Released && MouseHandler.gamePressedRegistered) { if (SkinManager.Current.CursorExpand) { spriteCursor.Transformations.RemoveAll( delegate(Transformation tr) { return(tr.Type != TransformationType.Rotation); }); Transformation t = new Transformation(TransformationType.Scale, spriteCursor.CurrentScale, 1, GameBase.Time, GameBase.Time + 100); t.Easing = EasingTypes.In; spriteCursor.Transformations.Add(t); } MouseHandler.gamePressedRegistered = false; MouseHandler.DoOnClickUp(); } if (MouseHandler.mouseLeft == ButtonState.Pressed && GameBase.FadeState != FadeStates.FadeOut) { MouseHandler.MouseDown = true; if (mouse.X != MouseHandler.clickPosition.X || mouse.Y != MouseHandler.clickPosition.Y) { MouseHandler.DoOnDrag(); } } else { MouseHandler.MouseDown = false; if (IsDragging) { MouseHandler.DoOnEndDrag(); } } } else { leftButton = ButtonState.Released; rightButton = ButtonState.Released; } GameBase.Instance.UpdateChildren(); leftButtonLast = leftButton; rightButtonLast = rightButton; leftButtonLastBool = leftButton == ButtonState.Pressed; rightButtonLastBool = rightButton == ButtonState.Pressed; mouseLeftActualPrev = MouseHandler.mouseLeft; mouseRightActualPrev = MouseHandler.mouseRight; mouseMiddlePrev = MouseHandler.mouseMiddle; keyboardLast = keyboard; thisBlockKey = false; } while (ReplayMode && ((ReplayModeFF && loopFrame++ < 1) || (runningSlow && loopFrame++ < 4))); }
internal override void CreateAutoplayReplay() { int buttonIndex = 0; bool delayedMovements = ModManager.CheckActive(Mods.Relax2); EasingTypes preferredEasing = delayedMovements ? EasingTypes.InOutCubic : EasingTypes.Out; InputManager.ReplayScore.Replay = new List <bReplayFrame>(); List <bReplayFrame> replay = InputManager.ReplayScore.Replay; AddFrameToReplay(replay, new bReplayFrame(-100000, 256, 500, pButtonState.None)); AddFrameToReplay(replay, new bReplayFrame(hitObjectManager.hitObjects[0].StartTime - 1500, 256, 500, pButtonState.None)); AddFrameToReplay(replay, new bReplayFrame(hitObjectManager.hitObjects[0].StartTime - 1000, 256, 192, pButtonState.None)); // We are using ApplyModsToRate and not ApplyModsToTime to counteract the speed up / slow down from HalfTime / DoubleTime so that we remain at a constant framerate of 60 fps. float frameDelay = (float)HitObjectManager.ApplyModsToRate(1000.0 / 60.0); Vector2 spinnerCentre = new Vector2(256, 192); const float spinnerRadius = 50; // Already superhuman, but still somewhat realistic int reactionTime = (int)HitObjectManager.ApplyModsToRate(100); for (int i = 0; i < hitObjectManager.hitObjectsCount; i++) { HitObject h = hitObjectManager.hitObjects[i]; if (h.EndTime < InputManager.ReplayStartTime) { h.IsHit = true; continue; } int endDelay = h is SpinnerOsu ? 1 : 0; if (delayedMovements && i > 0) { HitObject last = hitObjectManager.hitObjects[i - 1]; //Make the cursor stay at a hitObject as long as possible (mainly for autopilot). if (h.StartTime - HitObjectManager.HITTABLE_RANGE > last.EndTime + hitObjectManager.HitWindow50 + 50) { if (!(last is Spinner) && h.StartTime - last.EndTime < 1000) { AddFrameToReplay(replay, new bReplayFrame(last.EndTime + hitObjectManager.HitWindow50, last.EndPosition.X, last.EndPosition.Y, pButtonState.None)); } if (!(h is Spinner)) { AddFrameToReplay(replay, new bReplayFrame(h.StartTime - HitObjectManager.HITTABLE_RANGE, h.Position.X, h.Position.Y, pButtonState.None)); } } else if (h.StartTime - hitObjectManager.HitWindow50 > last.EndTime + hitObjectManager.HitWindow50 + 50) { if (!(last is Spinner) && h.StartTime - last.EndTime < 1000) { AddFrameToReplay(replay, new bReplayFrame(last.EndTime + hitObjectManager.HitWindow50, last.EndPosition.X, last.EndPosition.Y, pButtonState.None)); } if (!(h is Spinner)) { AddFrameToReplay(replay, new bReplayFrame(h.StartTime - hitObjectManager.HitWindow50, h.Position.X, h.Position.Y, pButtonState.None)); } } else if (h.StartTime - hitObjectManager.HitWindow100 > last.EndTime + hitObjectManager.HitWindow100 + 50) { if (!(last is Spinner) && h.StartTime - last.EndTime < 1000) { AddFrameToReplay(replay, new bReplayFrame(last.EndTime + hitObjectManager.HitWindow100, last.EndPosition.X, last.EndPosition.Y, pButtonState.None)); } if (!(h is Spinner)) { AddFrameToReplay(replay, new bReplayFrame(h.StartTime - hitObjectManager.HitWindow100, h.Position.X, h.Position.Y, pButtonState.None)); } } } Vector2 targetPosition = h.Position; EasingTypes easing = preferredEasing; float spinnerDirection = -1; if (h is Spinner) { targetPosition.X = replay[replay.Count - 1].mouseX; targetPosition.Y = replay[replay.Count - 1].mouseY; Vector2 difference = spinnerCentre - targetPosition; float differenceLength = difference.Length(); float newLength = (float)Math.Sqrt(differenceLength * differenceLength - spinnerRadius * spinnerRadius); if (differenceLength > spinnerRadius) { float angle = (float)Math.Asin(spinnerRadius / differenceLength); if (angle > 0) { spinnerDirection = -1; } else { spinnerDirection = 1; } difference.X = difference.X * (float)Math.Cos(angle) - difference.Y * (float)Math.Sin(angle); difference.Y = difference.X * (float)Math.Sin(angle) + difference.Y * (float)Math.Cos(angle); difference.Normalize(); difference *= newLength; targetPosition += difference; easing = EasingTypes.In; } else if (difference.Length() > 0) { targetPosition = spinnerCentre - difference * (spinnerRadius / difference.Length()); } else { targetPosition = spinnerCentre + new Vector2(0, -spinnerRadius); } } // Do some nice easing for cursor movements if (replay.Count > 0) { bReplayFrame lastFrame = replay[replay.Count - 1]; // Wait until Auto could "see and react" to the next note. int waitTime = h.StartTime - (int)Math.Max(0.0, hitObjectManager.PreEmpt - reactionTime); if (waitTime > lastFrame.time) { lastFrame = new bReplayFrame(waitTime, lastFrame.mouseX, lastFrame.mouseY, lastFrame.buttonState); AddFrameToReplay(replay, lastFrame); } Vector2 lastPosition = new Vector2(lastFrame.mouseX, lastFrame.mouseY); HitObjectManagerOsu hom = hitObjectManager as HitObjectManagerOsu; double timeDifference = HitObjectManager.ApplyModsToTime(h.StartTime - lastFrame.time, ModManager.ModStatus); // Only "snap" to hitcircles if they are far enough apart. As the time between hitcircles gets shorter the snapping threshold goes up. if (hom != null && timeDifference > 0 && // Sanity checks ((lastPosition - targetPosition).Length() > hom.HitObjectRadius * (1.5 + 100.0 / timeDifference) || // Either the distance is big enough timeDifference >= 266)) // ... or the beats are slow enough to tap anyway. { // Perform eased movement for (float time = lastFrame.time + frameDelay; time < h.StartTime; time += frameDelay) { Vector2 currentPosition = OsuMathHelper.TweenValues(lastPosition, targetPosition, time, lastFrame.time, h.StartTime, easing); AddFrameToReplay(replay, new bReplayFrame((int)time, currentPosition.X, currentPosition.Y, lastFrame.buttonState)); } buttonIndex = 0; } else { buttonIndex++; } } pButtonState button = buttonIndex % 2 == 0 ? pButtonState.Left1 : pButtonState.Right1; pButtonState previousButton = pButtonState.None; bReplayFrame newFrame = new bReplayFrame(h.StartTime, targetPosition.X, targetPosition.Y, button); bReplayFrame endFrame = new bReplayFrame(h.EndTime + endDelay, h.EndPosition.X, h.EndPosition.Y, pButtonState.None); // Decrement because we want the previous frame, not the next one int index = FindInsertionIndex(replay, newFrame) - 1; // Do we have a previous frame? No need to check for < replay.Count since we decremented! if (index >= 0) { bReplayFrame previousFrame = replay[index]; previousButton = previousFrame.buttonState; // If a button is already held, then we simply alternate if (previousButton != pButtonState.None) { Debug.Assert(previousButton != (pButtonState.Left1 | pButtonState.Right1)); // Force alternation if we have the same button. Otherwise we can just keep the naturally to us assigned button. if (previousButton == button) { button = (pButtonState.Left1 | pButtonState.Right1) & ~button; newFrame.SetButtonStates(button); } // We always follow the most recent slider / spinner, so remove any other frames that occur while it exists. int endIndex = FindInsertionIndex(replay, endFrame); if (index < replay.Count - 1) { replay.RemoveRange(index + 1, Math.Max(0, endIndex - (index + 1))); } // After alternating we need to keep holding the other button in the future rather than the previous one. for (int j = index + 1; j < replay.Count; ++j) { // Don't affect frames which stop pressing a button! if (j < replay.Count - 1 || replay[j].buttonState == previousButton) { replay[j].SetButtonStates(button); } } } } AddFrameToReplay(replay, newFrame); // We add intermediate frames for spinning / following a slider here. if (h is SpinnerOsu) { Vector2 difference = targetPosition - spinnerCentre; float radius = difference.Length(); float angle = radius == 0 ? 0 : (float)Math.Atan2(difference.Y, difference.X); float t; for (float j = h.StartTime + frameDelay; j < h.EndTime; j += frameDelay) { t = (float)HitObjectManager.ApplyModsToTime(j - h.StartTime) * spinnerDirection; Vector2 pos = spinnerCentre + CirclePosition(t / 20 + angle, spinnerRadius); AddFrameToReplay(replay, new bReplayFrame((int)j, pos.X, pos.Y, button)); } t = (float)HitObjectManager.ApplyModsToTime(h.EndTime - h.StartTime) * spinnerDirection; Vector2 endPosition = spinnerCentre + CirclePosition(t / 20 + angle, spinnerRadius); AddFrameToReplay(replay, new bReplayFrame(h.EndTime, endPosition.X, endPosition.Y, button)); endFrame.mouseX = endPosition.X; endFrame.mouseY = endPosition.Y; } else if (h is SliderOsu) { SliderOsu s = h as SliderOsu; int lastTime = 0; foreach ( Transformation t in s.sliderFollower.Transformations.FindAll( tr => tr.Type == TransformationType.Movement)) { if (lastTime != 0 && t.Time1 - lastTime < frameDelay) { continue; } AddFrameToReplay(replay, new bReplayFrame(t.Time1, t.StartVector.X, t.StartVector.Y, button)); lastTime = t.Time1; } AddFrameToReplay(replay, new bReplayFrame(h.EndTime, h.EndPosition.X, h.EndPosition.Y, button)); } // We only want to let go of our button if we are at the end of the current replay. Otherwise something is still going on after us so we need to keep the button pressed! if (replay[replay.Count - 1].time <= endFrame.time) { AddFrameToReplay(replay, endFrame); } } Player.currentScore.Replay = InputManager.ReplayScore.Replay; Player.currentScore.PlayerName = "osu!"; }