コード例 #1
0
        /// <summary>
        /// Finds the intersection point with the edge of the gamefield if it intersects.
        /// </summary>
        private Vector2 getVectorBorder(Vector2 point, Vector2 origin)
        {
            Line l = new Line(point, origin);
            Line l2;

            //Gets correct gamefield border
            if (point.X < 0)
            {
                l2 = new Line(Vector2.Zero, new Vector2(0, GameField.DEFAULT_HEIGHT));
            }
            else if (point.X > GameField.DEFAULT_WIDTH)
            {
                l2 = new Line(new Vector2(GameField.DEFAULT_WIDTH, 0), new Vector2(GameField.DEFAULT_WIDTH, GameField.DEFAULT_HEIGHT));
            }
            else if (point.Y < 0)
            {
                l2 = new Line(Vector2.Zero, new Vector2(GameField.DEFAULT_WIDTH, 0));
            }
            else if (point.Y > GameField.DEFAULT_HEIGHT)
            {
                l2 = new Line(new Vector2(0, GameField.DEFAULT_HEIGHT), new Vector2(GameField.DEFAULT_WIDTH, GameField.DEFAULT_HEIGHT));
            }
            else
            {
                return(point);
            }

            //At this point line combinations wont be parallel
            return(OsuMathHelper.IntersectBetween(l, l2));
        }
コード例 #2
0
        private void startBatch(bool allowRecycle = false)
        {
            if (hasBegun && !allowRecycle)
            {
                return;
            }

            endBatch();

            int amountQuads = OsuMathHelper.Clamp(SpriteList.Count, 1, 100);

            if (SpriteBatch == null || SpriteBatch.Size < amountQuads)
            {
                for (int i = 0; i < SpriteBatches.Length; i++)
                {
                    SpriteBatches[i] = new QuadBatch <TexturedVertex2d>(amountQuads * 2, 500);
                }
            }

            if (currentBlend == SpriteBlendMode.Additive)
            {
                OsuGlControl.SetBlend(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.One);
            }
            else
            {
                OsuGlControl.SetBlend(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);
            }

            hasBegun = true;
            Current  = this;
            NativeText.ScaleModifier = Scale;
        }
コード例 #3
0
        public HitCircleFruits(HitObjectManager hom, Vector2 startPosition, int startTime, bool newCombo, HitObjectSoundType soundType, string fruit)
            : base(hom)
        {
            Position     = new Vector2(OsuMathHelper.Clamp(startPosition.X, 0, GameField.DEFAULT_WIDTH), 340);
            BasePosition = Position;
            StartTime    = startTime;
            EndTime      = startTime;
            SoundType    = soundType;

            NewCombo = newCombo;

            if (hom.spriteManager != null)
            {
                SpriteHitCircle1 =
                    new pSprite(TextureManager.Load(@"fruit-" + fruit), Fields.Gamefield, Origins.Centre,
                                Clocks.Audio, Position, SpriteManager.drawOrderBwd(StartTime), false, Color.White);
                SpriteCollection.Add(SpriteHitCircle1);
                DimCollection.Add(SpriteHitCircle1);
                SpriteHitCircle1.TagNumeric = 1;

                SpriteHitCircle2 =
                    new pSprite(TextureManager.Load(@"fruit-" + fruit + "-overlay"), Fields.Gamefield,
                                Origins.Centre, Clocks.Audio, Position,
                                SpriteManager.drawOrderBwd(StartTime - 1), false, Color.White);
                SpriteCollection.Add(SpriteHitCircle2);
                DimCollection.Add(SpriteHitCircle2);

                SpriteHyperDash =
                    new pSprite(TextureManager.Load(@"fruit-" + fruit), Fields.Gamefield,
                                Origins.Centre, Clocks.Audio, Position,
                                SpriteManager.drawOrderBwd(StartTime + 1), false, Color.TransparentBlack);
                SpriteHyperDash.Additive = true;
                SpriteCollection.Add(SpriteHyperDash);
                DimCollection.Add(SpriteHyperDash);

                Transformation fall1 = new Transformation(new Vector2(Position.X, -100), new Vector2(Position.X, 340), StartTime - hitObjectManager.PreEmpt, StartTime);

                fall1.EndVector.Y += (fall1.EndVector.Y - fall1.StartVector.Y) * 0.2f;
                fall1.Time2       += (int)(fall1.Duration * 0.2f);

                float rotation = RNG.NextSingle(-0.2f, 0.2f);

                SpriteCollection.ForEach(s =>
                {
                    s.Transformations.Add(fall1);
                    s.Rotation = rotation;
                });

                if (ModManager.CheckActive(hitObjectManager.ActiveMods, Mods.Hidden))
                {
                    Transformation t = new Transformation(TransformationType.Fade, 1, 0, startTime - (int)(hitObjectManager.PreEmpt * 0.6),
                                                          startTime - (int)(hitObjectManager.PreEmpt * 0.44));
                    SpriteCollection.ForEach(s => s.Transformations.Add(t));
                }
            }
        }
コード例 #4
0
ファイル: pSliderBar.cs プロジェクト: notperry1234567890/osu
        internal pSliderBar(SpriteManager spriteManager, double min, double max, double initial, Vector2 position, int length)
        {
            Min        = min;
            Max        = max;
            Current    = Initial = OsuMathHelper.Clamp(initial, Min, Max);
            Length     = length;
            lineColour = SkinManager.NEW_SKIN_COLOUR_MAIN;

            lineLeft                  = new pSpriteSliderBarLine(GameBase.WhitePixel, position, 0.992f, lineColour, length);
            lineLeft.HandleInput      = true;
            lineLeft.ExactCoordinates = true;
            lineLeft.VectorScale      = new Vector2(length * 1.6f, 1.5f);

            lineRight = new pSprite(GameBase.WhitePixel, position, 0.991f, true, lineColour);
            lineRight.ExactCoordinates = true;
            lineRight.HandleInput      = true;
            lineRight.Alpha            = 0.5f;
            lineRight.VectorScale      = new Vector2(length * 1.6f, 1.5f);

            Seekbar =
                new pSprite(TextureManager.Load(@"circle-empty", SkinSource.Osu), Fields.TopLeft, Origins.Centre,
                            Clocks.Game, seekPosition, 0.99f, true, lineColour, null);
            Seekbar.HandleInput = true;

            Seekbar.OnUpdate += delegate
            {
                float v1         = Seekbar.drawRectangle.X - lineLeft.drawRectangle.X;
                float halfCircle = Seekbar.DrawWidth / 1.6f / 2;

                lineLeft.VectorScale.X  = Math.Max(0, v1 / GameBase.WindowManager.RatioInverse);
                lineRight.VectorScale.X = Math.Max(0, length * 1.6f - (v1 + Seekbar.DrawWidth) / GameBase.WindowManager.RatioInverse);
                lineRight.Position.X    = Seekbar.Position.X + halfCircle;
            };

            SpriteCollection.Add(Seekbar);
            SpriteCollection.Add(lineLeft);
            SpriteCollection.Add(lineRight);

            lineLeft.OnHover     += sprite_OnHover;
            lineLeft.OnHoverLost += sprite_OnHoverLost;

            if (spriteManager != null)
            {
                spriteManager.Add(Seekbar);
                spriteManager.Add(lineLeft);
                spriteManager.Add(lineRight);
            }

            updatePosition();
        }
コード例 #5
0
        internal void SetColours(Stream stream = null, VoidDelegate callback = null)
        {
            GameBase.RunBackgroundThread(delegate
            {
                List <Color> newColours = new List <Color>();

                if (stream != null)
                {
                    try
                    {
                        using (System.Drawing.Bitmap b = (System.Drawing.Bitmap)System.Drawing.Image.FromStream(stream, false, false))
                            for (int i = 0; i < 50; i++)
                            {
                                newColours.Add(OsuMathHelper.CConvert(b.GetPixel(RNG.Next(b.Width), RNG.Next(b.Height))));
                            }
                        return;
                    }
                    catch (ArgumentException)
                    {
                    }
                    finally
                    {
                        stream.Dispose();
                    }
                }

                newColours.Add(new Color(5, 25, 81));
                newColours.Add(new Color(16, 56, 135));
                newColours.Add(new Color(3, 3, 5));
                newColours.Add(new Color(91, 170, 207));
                newColours.Add(new Color(140, 152, 150));

                for (int i = 0; i < 2; i++)
                {
                    byte c = (byte)RNG.Next(224, 256);
                    newColours.Add(new Color(c, c, c));
                }

                GameBase.Scheduler.Add(delegate
                {
                    SetColours(newColours);
                    if (callback != null)
                    {
                        callback();
                    }
                });
            });
        }
コード例 #6
0
        internal override void UpdateFlashlight()
        {
            if (s_Flashlight != null)
            {
                Vector2 destination = new Vector2(
                    Math.Max(0, Math.Min(640, (InputManager.s_Cursor.Position.X - GameBase.WindowManager.NonWidescreenOffsetX) / GameBase.WindowManager.Ratio)) + GameBase.WindowManager.OffsetXScaled,
                    Math.Max(0, Math.Min(480, InputManager.s_Cursor.Position.Y / GameBase.WindowManager.Ratio)));
                if (s_Flashlight != null)
                {
                    s_Flashlight.Position = OsuMathHelper.TweenValues(s_Flashlight.Position, destination,
                                                                      (float)GameBase.ElapsedMilliseconds, 0, 120, EasingTypes.Out);
                }
            }

            base.UpdateFlashlight();
        }
コード例 #7
0
        private void Explode(HitObject h)
        {
            if (ModManager.CheckActive(Mods.Cinema))
            {
                return;
            }

            float explosionOffset = OsuMathHelper.Clamp(((HitCircleFruits)h).CatchOffset.X, -catcherWidthHalf + catchMargin * 3, catcherWidthHalf - catchMargin * 3);

            if (!(h is HitCircleFruitsTick))
            {
                float scale = OsuMathHelper.Clamp(ComboCounter.HitCombo / 200f, 0.35f, 1.125f);

                pSprite exp1 = new pSprite(TextureManager.Load(@"scoreboard-explosion-2", SkinSource.Osu),
                                           Fields.Gamefield, Origins.CentreLeft, Clocks.Game,
                                           h.Position, 0.99f,
                                           false, h.Colour);
                exp1.Additive = true;
                exp1.Rotation = (float)(-Math.PI / 2);
                exp1.FadeOut(300);
                exp1.Transformations.Add(new Transformation(TransformationType.VectorScale, new Vector2(1, 0.9f),
                                                            new Vector2(16 * scale, 1.1f), GameBase.Time, GameBase.Time + 160,
                                                            EasingTypes.Out));
                spriteManagerAdd.Add(exp1);

                exp1.IsVisible       = true;
                exp1.InitialPosition = new Vector2(explosionOffset, 0);
                caughtSprites.Add(exp1);
            }
            pSprite exp2 = new pSprite(TextureManager.Load(@"scoreboard-explosion-1", SkinSource.Osu),
                                       Fields.Gamefield, Origins.CentreLeft, Clocks.Game,
                                       h.Position, 1, false,
                                       h.Colour);

            exp2.Rotation = (float)(-Math.PI / 2);
            spriteManagerAdd.Add(exp2);
            exp2.Additive = true;
            exp2.FadeOut(700);
            exp2.Transformations.Add(new Transformation(TransformationType.VectorScale, new Vector2(0.9f, 1),
                                                        new Vector2(0.9f, 1.3f), GameBase.Time, GameBase.Time + 500,
                                                        EasingTypes.Out));

            exp2.IsVisible       = true;
            exp2.InitialPosition = new Vector2(explosionOffset, 0);
            caughtSprites.Add(exp2);
        }
コード例 #8
0
        protected override void Read()
        {
            BindSection(@"Mania");

            ReadList(@"ColumnLineWidth", ColumnLineWidth, w => w > 0f && w < 2f ? 2f : w);

            ReadValue(@"BarlineHeight", ref BarlineHeight);
            ReadValue(@"SpecialStyle", ref SpecialStyle);

            ReadList(@"ColumnWidth", ColumnWidth, w => OsuMathHelper.Clamp(w, 5, 100));
            ReadList(@"ColumnSpacing", ColumnSpacing);
            for (int i = 0; i < Columns - 1; i++)
            {
                ColumnSpacing[i] = OsuMathHelper.Clamp(ColumnSpacing[i], -ColumnWidth[i + 1], float.MaxValue); // No reason to limit max
            }
            ReadList(@"LightingNWidth", LightingNWidth);
            ReadList(@"LightingLWidth", LightingLWidth);

            ReadValues(imageMap);
            ReadValues(colours);
            ReadValues(flip);
            ReadValues(noteBodyStyle);

            ReadValue(@"WidthForNoteHeightScale", ref WidthForNoteHeightScale);
            ReadValue(@"StageSeparation", ref StageSeparation);
            StageSeparation = Math.Max(StageSeparation, 5);
            ReadValue(@"SeparateScore", ref SeparateScore);
            ReadValue(@"SplitStages", ref SplitStagesFromSkin);
            ReadValue(@"KeysUnderNotes", ref KeysUnderNotes);
            ReadValue(@"ColumnStart", ref ColumnStart);
            ReadValue(@"ColumnRight", ref ColumnRight);
            ReadValue(@"JudgementLine", ref JudgementLine);
            ReadValue(@"HitPosition", ref HitPosition);
            HitPosition = Math.Max(240, Math.Min(HitPosition, 480));
            ReadValue(@"LightPosition", ref LightPosition);
            ReadValue(@"ComboPosition", ref ComboPosition);
            ReadValue(@"ScorePosition", ref ScorePosition);
            ReadValue(@"UpsideDown", ref UpsideDown);
            ReadValue(@"LightFramePerSecond", ref LightFramePerSecond);
            if (LightFramePerSecond <= 0)
            {
                LightFramePerSecond = 24;
            }
        }
コード例 #9
0
        /// <summary>
        /// Set the mania-wide scroll speed.
        /// </summary>
        /// <param name="value">The new scroll speed value.</param>
        /// <param name="owned">Whether the value is owned or unowned.</param>
        /// <param name="type">The type of speed to set. A normal Speed or a RelativeSpeed.</param>
        /// <returns>If the scroll speed was changed.</returns>
        internal static bool SetSpeed(double value, bool owned = false, ManiaSpeedType type = ManiaSpeedType.Speed)
        {
            // unowned sets only happen when the speed is not already owned
            if (!owned && isSpeedOwned)
            {
                return(false);
            }

            Mods mods = InputManager.ReplayMode && InputManager.ReplayScore != null ? InputManager.ReplayScore.EnabledMods : ModManager.ModStatus;

            EffectiveBPM = primaryBPM * (
                ModManager.CheckActive(mods, Mods.DoubleTime) ? 1.5
                : ModManager.CheckActive(mods, Mods.HalfTime) ? 0.75
                : 1.0);

            double oldRelativeSpeed = RelativeSpeed;

            if (type == ManiaSpeedType.RelativeSpeed)
            {
                // set RelativeSpeed and calculate Speed
                RelativeSpeed = value;
                Speed         = OsuMathHelper.Clamp((int)Math.Round(RelativeSpeed * (ConfigManager.sManiaSpeedBPMScale ? 1 : EffectiveBPM / SPEED_FACTOR)), SPEED_MIN, SPEED_MAX);
            }
            else
            {
                // set Speed and calculate RelativeSpeed
                Speed         = OsuMathHelper.Clamp((int)Math.Round(value), SPEED_MIN, SPEED_MAX);
                RelativeSpeed = Speed * (ConfigManager.sManiaSpeedBPMScale ? 1 : SPEED_FACTOR / Math.Max(EffectiveBPM, 1));
            }

            if (owned)
            {
                isSpeedOwned = true;

                ConfigManager.sManiaSpeed.Value = Speed;
                if (BeatmapManager.Current != null && ConfigManager.sUsePerBeatmapManiaSpeed)
                {
                    BeatmapManager.Current.ManiaSpeed = Speed;
                }
            }

            return(RelativeSpeed != oldRelativeSpeed);
        }
コード例 #10
0
        public override void Update()
        {
            background.HandleInput = !Player.Playing || Player.Unpausing;

            const float hide_delay = 1000;

            if (Visible && GameBase.Time - lastVisibleTime > hide_delay)
            {
                Visible = false;
            }

            if (Visible)
            {
                if (background.Alpha > 0.98f)
                {
                    float aimProgress = volume.Value / 100f;
                    if (progress.Progress != aimProgress)
                    {
                        float difference = progress.Progress - aimProgress;
                        if (Math.Abs(difference) < 0.0001)
                        {
                            progress.Progress = aimProgress;
                        }
                        else
                        {
                            progress.Progress = OsuMathHelper.Clamp(aimProgress + difference * (float)Math.Pow(0.99, GameBase.ElapsedMilliseconds), 0, 1);
                        }
                    }

                    percentageDisplay.Text = Math.Round(progress.Progress * 100) + @"%";
                }
            }
            else
            {
                if (percentageDisplay.Alpha == 0)
                {
                    percentageDisplay.Text = string.Empty;
                }
            }

            base.Update();
        }
コード例 #11
0
        protected override void OnShown(EventArgs e)
        {
            editor = Editor.Instance;

            if (editor.Compose.selectedObjects.Count == 1)
            {
                HitObject h = editor.Compose.selectedObjects[0];
                float     x = OsuMathHelper.Clamp(h.BasePosition.X, (float)nud_x.Minimum, (float)nud_x.Maximum);
                float     y = OsuMathHelper.Clamp(h.BasePosition.Y, (float)nud_y.Minimum, (float)nud_y.Maximum);
                nud_y.Value         = (decimal)y;
                nud_x.Value         = (decimal)x;
                cb_relative.Checked = false;
            }
            else
            {
                cb_relative.Checked = true;
                relativePos         = new Vector2();
            }
            base.OnShown(e);
        }
コード例 #12
0
        private void MouseHandler(RawInput data)
        {
            RawMouse m     = data.Mouse;
            float    speed = (float)ConfigManager.sMouseSpeed;

            AbsoluteMovement = (m.Flags & RawMouseFlags.MoveAbsolute) > 0;

            if (AbsoluteMovement)
            {
                if (ConfigManager.sAbsoluteToOsuWindow)
                {
                    const int range = 65536;
                    position.X = ((float)((m.LastX - range / 2) * speed) + range / 2) / range * GameBase.WindowManager.Width;
                    position.Y = ((float)((m.LastY - range / 2) * speed) + range / 2) / range * GameBase.WindowManager.Height;
                }
                else
                {
                    // Absolute coordinates need to be shifted to the osu window's position and scaled to the desktop resolution.
                    position = ToScreenCoords(m) - new Vector2(GameBase.ClientBounds.X, GameBase.ClientBounds.Y);

                    position.X = (position.X - GameBase.WindowManager.Width / 2) * speed + GameBase.WindowManager.Width / 2;
                    position.Y = (position.Y - GameBase.WindowManager.Height / 2) * speed + GameBase.WindowManager.Height / 2;
                }
            }
            else
            {
                position.X += m.LastX * speed;
                position.Y += m.LastY * speed;
            }

            if (InputManager.ShallClampMouseToWindow)
            {
                position.X = OsuMathHelper.Clamp(position.X, 0, GameBase.WindowManager.Width - 1);
                position.Y = OsuMathHelper.Clamp(position.Y, 0, GameBase.WindowManager.Height - 1);
            }

            intermediatePositionsNextFrame.Add(position);

            ++amountMessages;
            latency += GameBase.stopWatch.ElapsedMilliseconds - lastProcessTime;
        }
コード例 #13
0
ファイル: pSliderBar.cs プロジェクト: notperry1234567890/osu
        internal void SetValue(double value, bool silent = false, bool final = false)
        {
            value = OsuMathHelper.Clamp(value, Min, Max);

            if (Current != value)
            {
                Current = value;

                if (!silent)
                {
                    if (OnValueChanged != null)
                    {
                        OnValueChanged(final);
                    }

                    if (IsDragging || final)
                    {
                        AudioEngine.Click(null, @"sliderbar", 1 + progress * 0.2f);
                    }
                }
            }

            updatePosition();
        }
コード例 #14
0
        internal void CalculateStrains(DifficultyHitObjectFruits PreviousHitObject, double TimeRate)
        {
            // Rather simple, but more specialized things are inherently inaccurate due to the big difference playstyles and opinions make.
            // See Taiko feedback thread.
            double TimeElapsed = (double)(BaseHitObject.StartTime - PreviousHitObject.BaseHitObject.StartTime) / TimeRate;
            double Decay       = Math.Pow(DECAY_BASE, TimeElapsed / 1000);

            // Update new position with lazy movement.
            PlayerPositionOffset =
                OsuMathHelper.Clamp(
                    PreviousHitObject.ActualNormalizedPosition,
                    NormalizedPosition - (NORMALIZED_HITOBJECT_RADIUS - playerPositioningError),
                    NormalizedPosition + (NORMALIZED_HITOBJECT_RADIUS - playerPositioningError)) // Obtain new lazy position, but be stricter by allowing for an error of a certain degree of the player.
                - NormalizedPosition;                                                            // Subtract HitObject position to obtain offset

            LastMovement = DistanceTo(PreviousHitObject);
            double Addition = SpacingWeight(LastMovement);

            if (NormalizedPosition < PreviousHitObject.NormalizedPosition)
            {
                LastMovement = -LastMovement;
            }

            HitCircleFruits previousHitCircle = PreviousHitObject.BaseHitObject as HitCircleFruits;

            double additionBonus = 0;
            double sqrtTime      = Math.Sqrt(Math.Max(TimeElapsed, 25));

            // Direction changes give an extra point!
            if (Math.Abs(LastMovement) > 0.1)
            {
                if (Math.Abs(PreviousHitObject.LastMovement) > 0.1 && Math.Sign(LastMovement) != Math.Sign(PreviousHitObject.LastMovement))
                {
                    double bonus = DIRECTION_CHANGE_BONUS / sqrtTime;

                    // Weight bonus by how
                    double bonusFactor = Math.Min(playerPositioningError, Math.Abs(LastMovement)) / playerPositioningError;

                    // We want time to play a role twice here!
                    Addition += bonus * bonusFactor;

                    // Bonus for tougher direction switches and "almost" hyperdashes at this point
                    if (previousHitCircle != null && previousHitCircle.DistanceToHyperDash <= 10)
                    {
                        additionBonus += 0.3 * bonusFactor;
                    }
                }

                // Base bonus for every movement, giving some weight to streams.
                Addition += 7.5 * Math.Min(Math.Abs(LastMovement), NORMALIZED_HITOBJECT_RADIUS * 2) / (NORMALIZED_HITOBJECT_RADIUS * 6) / sqrtTime;
            }

            // Bonus for "almost" hyperdashes at corner points
            if (previousHitCircle != null && previousHitCircle.DistanceToHyperDash <= 10)
            {
                if (!previousHitCircle.HyperDash)
                {
                    additionBonus += 1.0;
                }
                else
                {
                    // After a hyperdash we ARE in the correct position. Always!
                    PlayerPositionOffset = 0;
                }

                Addition *= 1.0 + additionBonus * ((10 - previousHitCircle.DistanceToHyperDash) / 10);
            }

            Addition *= 850.0 / Math.Max(TimeElapsed, 25);

            Strain = PreviousHitObject.Strain * Decay + Addition;
        }
コード例 #15
0
        private void updateCompletion(float percent)
        {
            if (spriteGlow != null)
            {
                if (state < SpinningState.Passed)
                {
                    spriteGlow.InitialColour = new Color(3, 151, 255);
                    Transformation tr = spriteGlow.Transformations.Count > 0 ? spriteGlow.Transformations[0] : null;
                    if (tr != null)
                    {
                        tr.StartFloat = tr.EndFloat = Math.Min(1, percent / 100f);
                    }

                    spriteMiddleTop.Scale = spriteMiddleBottom.Scale = SpriteCircleTop.Scale = spriteCircleBottom.Scale = spriteGlow.Scale = 0.8f + OsuMathHelper.easeOutVal(percent / 100f, 0, 0.2f, 1);
                }
            }
            else
            {
                percent = Math.Min(99, percent);

                int barCount = (int)percent / 10;
                if (SkinManager.Current.SpinnerNoBlink || RNG.NextBool(((int)percent % 10) / 10f))
                {
                    barCount++;
                }

                if (spriteScoreMetre != null)
                {
                    spriteScoreMetre.DrawTop    = (int)(69.2 * (10 - barCount));
                    spriteScoreMetre.DrawHeight = (int)(69.2 * barCount);
                    spriteScoreMetre.Position.Y = (float)(spinnerTopOffset + 43.25 * (10 - barCount));
                }
            }
        }
コード例 #16
0
        internal override void UpdateInput()
        {
            if (!IsInitialized || Player.Paused)
            {
                return;
            }

            int frameCheck = 0;

            if (!InputManager.ReplayMode)
            {
                InputManager.leftButton1  |= KeyboardHandler.IsKeyDown(BindingManager.For(Bindings.FruitsDash));
                InputManager.leftButton1  |= JoystickHandler.IsKeyDown(BindingManager.For(Bindings.FruitsDash));
                InputManager.leftButton1i |= InputManager.leftButton1;
                if (InputManager.leftButton1i)
                {
                    InputManager.leftButton = ButtonState.Pressed;
                }
            }

            Dashing = InputManager.leftButton == ButtonState.Pressed;

            if (Dashing)
            {
                frameCheck += 4;
            }

            float currentMovementSpeed = baseMovementSpeed * specialMovementModifier;

            if (!Dashing)
            {
                currentMovementSpeed /= 2;
            }

            if (InputManager.ReplayMode || Player.Relaxing)
            {
                float newPos = InputManager.ReplayGamefieldCursor.X;

                if (InputManager.NewReplayFrame)
                {
                    LeftPressed  = catcher1.Position.X > newPos;
                    RightPressed = catcher1.Position.X < newPos;
                }

                if (catcher1.Position.X != newPos)
                {
#if DEBUG
                    if (!ModManager.CheckActive(Mods.Autoplay) && (Math.Abs(catcher1.Position.X - newPos) > currentMovementSpeed * GameBase.SIXTY_FRAME_TIME))
                    {
                        NotificationManager.ShowMessageMassive("Impossible movement (" + Math.Abs(catcher1.Position.X - newPos) + " vs " + (currentMovementSpeed * GameBase.SIXTY_FRAME_TIME) + ")", 1000);
                    }
#endif

                    catcher1.FlipHorizontal = catcher1.Position.X > newPos;

                    catcher1.Position.X = newPos;
                }
            }
            else
            {
                if (GameBase.ElapsedMilliseconds > 33)
                {
                    return;
                }

                if (Math.Abs(catcher1.Position.X - checkPosition) > 0.01f)
                {
                    catcher1.Position.X = checkPosition;
                    CurrentScore.InvalidateSubmission();
                }


                if ((RightPressed = KeyboardHandler.IsKeyDown(BindingManager.For(Bindings.FruitsRight)) || JoystickHandler.IsKeyDown(BindingManager.For(Bindings.FruitsRight))))
                {
                    frameCheck             += 1;
                    catcher1.Position.X     = (float)(catcher1.Position.X + currentMovementSpeed * GameBase.ElapsedMilliseconds);
                    catcher1.FlipHorizontal = false;
                }

                if ((LeftPressed = KeyboardHandler.IsKeyDown(BindingManager.For(Bindings.FruitsLeft)) || JoystickHandler.IsKeyDown(BindingManager.For(Bindings.FruitsLeft))))
                {
                    frameCheck             += 2;
                    catcher1.Position.X     = (float)(catcher1.Position.X - currentMovementSpeed * GameBase.ElapsedMilliseconds);
                    catcher1.FlipHorizontal = true;
                }
            }

            checkSpecialWaitingState();

            importantFrame      = frameCheck != importantFrameCheck;
            importantFrameCheck = frameCheck;

            catcher1.Position.X = OsuMathHelper.Clamp(catcher1.Position.X, 0, 512);
            checkPosition       = catcher1.Position.X;
        }
コード例 #17
0
        internal override void CreateAutoplayReplay()
        {
            InputManager.ReplayScore.Replay = new List <bReplayFrame>();
            List <bReplayFrame> replay = InputManager.ReplayScore.Replay;

            replay.Add(new bReplayFrame(-100000, 256, 490, pButtonState.None));

            //replay.Add(new bReplayFrame(hitObjectManager.hitObjects[0].StartTime - 1000, 256, 490, pButtonState.None));

            float movementSpeed = baseMovementSpeed * 0.5f;
            float dashSpeed     = baseMovementSpeed;

            float lastPosition = 256;
            int   lastTime     = 0;

            for (int i = 0; i < hitObjectManager.hitObjectsCount; i++)
            {
                HitObject h = hitObjectManager.hitObjects[i];

                if (h.EndTime < InputManager.ReplayStartTime)
                {
                    h.IsHit = true;
                    continue;
                }

                float positionChange = Math.Abs(lastPosition - h.Position.X);
                int   timeAvailable  = h.StartTime - lastTime;

                //So we can either make it there without a dash or not.
                float speedRequired = positionChange / timeAvailable;

                bool dashRequired = speedRequired > movementSpeed && h.StartTime != 0;
                bool hyperDash    = speedRequired > dashSpeed && h.StartTime != 0;

                if (lastPosition - catcherWidthHalf + catchMargin < h.Position.X &&
                    lastPosition + catcherWidthHalf - catchMargin > h.Position.X)
                {
                    //we are already in the correct range.
                    lastTime = h.EndTime;
                    replay.Add(new bReplayFrame(h.StartTime, lastPosition, 490, pButtonState.None));
                    continue;
                }

                if (h is HitCircleFruitsSpin)
                {
                    //special spinner handling...
                    replay.Add(new bReplayFrame(h.StartTime, h.Position.X, 490, pButtonState.Left1));
                }
                else if (hyperDash)
                {
                    replay.Add(new bReplayFrame(h.StartTime - timeAvailable + 1, lastPosition, 490, pButtonState.Left1));

                    replay.Add(new bReplayFrame(h.StartTime, h.Position.X, 490, pButtonState.None));
                }
                else if (dashRequired)
                {
                    //we do a movement in two parts - the dash part then the normal part...
                    int timeAtNormalSpeed = (int)(positionChange / movementSpeed);

                    int timeWeNeedToSave = timeAtNormalSpeed - timeAvailable;

                    int timeAtDashSpeed = timeWeNeedToSave / 2;
                    timeAtNormalSpeed -= timeAtDashSpeed;

                    float midPosition = OsuMathHelper.Lerp(lastPosition, h.Position.X, (float)timeAtDashSpeed / timeAvailable);

                    //dash movement
                    replay.Add(new bReplayFrame(h.StartTime - timeAvailable + 1, lastPosition, 490, pButtonState.Left1));

                    replay.Add(new bReplayFrame(h.StartTime - timeAvailable + timeAtDashSpeed, midPosition, 490, pButtonState.None));

                    replay.Add(new bReplayFrame(h.StartTime, h.Position.X, 490, pButtonState.None));
                }
                else
                {
                    int timeBefore = (int)(positionChange / movementSpeed);

                    replay.Add(new bReplayFrame(h.StartTime - timeBefore, lastPosition, 490, pButtonState.Right1));
                    replay.Add(new bReplayFrame(h.StartTime, h.Position.X, 490, pButtonState.None));
                }


                lastTime     = h.EndTime;
                lastPosition = h.Position.X;

                /*replay.Add(new bReplayFrame(h.StartTime, h.Position.X, 490, pButtonState.Right1));
                 * if (i < hitObjectManager.hitObjectsCount - 1 && i != 0 && hitObjectManager.hitObjects[i + 1].StartTime - h.StartTime > 2000)
                 *  replay.Add(new bReplayFrame(hitObjectManager.hitObjects[i + 1].StartTime - 1000, h.Position.X, 490,pButtonState.None));    */
            }


            Player.currentScore.Replay     = InputManager.ReplayScore.Replay;
            Player.currentScore.PlayerName = "salad!";
        }
コード例 #18
0
        private void ChangePolygon()
        {
            lastValidCount = nudCount.Value;

            editor.Compose.AddPolygon((int)nudCount.Value, (int)nudRepeat.Value, OsuMathHelper.ToRadians(trAngle.Value), (double)trDS.Value / 10.0);
        }
コード例 #19
0
ファイル: NativeText.cs プロジェクト: notperry1234567890/osu
        internal static pTexture CreateText(string text, float size, Vector2 restrictBounds, Color color, ShadowType shadow, bool bold, bool italic, bool underline, TextAlignment alignment, bool forceAa, out Vector2 measured, out RectangleF[] characterRegions, Color background, Color border, int borderWidth, bool measureOnly, bool getCharacterRegions, FontFace fontFace, Vector4 cornerBounds, Vector2 padding, pTexture lastTexture = null, int startIndex = 0, int length = -1)
        {
            characterRegions = null;
            if (text == null)
            {
                measured = Vector2.Zero;
                return(null);
            }

            if (ConfigManager.dDisableTextRendering)
            {
                measured = new Vector2(text.Length * size, size);
                return(null);
            }

#if DEBUG
            if (!text.Contains(@"NativeText"))
            {
                int  limit_per_second = osu.GameModes.Play.Player.Playing ? 5 : 58;
                bool newSecond        = GameBase.Time / 1000 != currentSecond;

                drawCount++;
                if (drawCount == limit_per_second)
                {
                    Debug.Print(@"NativeText: High number of text refreshes per second.");
                }

                if (newSecond)
                {
                    currentSecond = GameBase.Time / 1000;
                    drawCount     = 0;
                }
            }
#endif

            //This lock ensures we are only using the shared GDI+ object (FromHwnd) in one place at a time.
            lock (createTextLock)
            {
                try
                {
                    using (System.Drawing.Graphics graphics = System.Drawing.Graphics.FromHwnd(IntPtr.Zero))
                        using (StringFormat sf = new StringFormat())
                        {
                            if (dpiRatio == 0)
                            {
                                dpiRatio = 96 / graphics.DpiX;
                            }

                            size *= dpiRatio;

                            GameBase.PerformanceMonitor.ReportCount(CounterType.NativeText);

                            graphics.TextRenderingHint = TextRenderingHint.AntiAlias;

                            SizeF measuredSize;

                            string face = GetFontFace(fontFace);

                            if (face.StartsWith(@"Aller"))
                            {
                                //if we are using the default osu! font, allow specific language overrides based on simple detection.
                                string fontFaceOverride = getLanguageSpeicificFont(text);
                                if (fontFaceOverride != null)
                                {
                                    face = fontFaceOverride;
                                }
                            }

                            if (startIndex != 0 || length > 0)
                            {
                                text = text.Substring(startIndex, length);
                            }
                            else if (length == -1)
                            {
                                length = text.Length;
                            }


                            if (size < 20 && face.EndsWith(@" Light"))
                            {
                                face = face.Replace(@" Light", string.Empty);
                            }

                            FontStyle fs = FontStyle.Regular;
                            if (bold)
                            {
                                if (face.EndsWith(@" Light"))
                                {
                                    face = face.Replace(@" Light", string.Empty);
                                }
                                fs |= FontStyle.Bold;
                            }

                            if (italic)
                            {
                                fs |= FontStyle.Italic;
                            }

                            if (underline)
                            {
                                fs |= FontStyle.Underline;
                            }

                            switch (alignment)
                            {
                            case TextAlignment.Left:
                            case TextAlignment.LeftFixed:
                                sf.Alignment = StringAlignment.Near;
                                break;

                            case TextAlignment.Centre:
                                sf.Alignment = StringAlignment.Center;
                                break;

                            case TextAlignment.Right:
                                sf.Alignment = StringAlignment.Far;
                                break;
                            }

                            if (!OsuMain.IsWine && face.StartsWith(@"Aller"))
                            {
                                for (char c = '0'; c <= '9'; c++)
                                {
                                    text = text.Replace(c, (char)(c + (0xf83c - '0')));
                                }
                            }

                            Font f = GetFont(face, size * ScaleModifier, fs);
                            if (ScaleModifier != 1)
                            {
                                restrictBounds *= ScaleModifier;
                            }

                            try
                            {
                                if (text.Length == 0)
                                {
                                    text = " ";
                                }
                                measuredSize = restrictBounds != Vector2.Zero
                                                ? graphics.MeasureString(text, f, new SizeF(restrictBounds.X, restrictBounds.Y), sf)
                                                : graphics.MeasureString(text, f);
                            }
                            catch (InvalidOperationException)
                            {
                                measured = Vector2.Zero;
                                return(null);
                            }

                            int width  = (int)(measuredSize.Width + 1);
                            int height = (int)(measuredSize.Height + 1);

                            if (restrictBounds.Y != 0)
                            {
                                height = (int)restrictBounds.Y;
                            }

                            if (restrictBounds.X != 0 && (alignment != TextAlignment.Left || background.A > 0))
                            {
                                width = (int)restrictBounds.X;
                            }

                            if (padding != Vector2.Zero && restrictBounds == Vector2.Zero)
                            {
                                width  += (int)(padding.X * 2);
                                height += (int)(padding.Y * 2);
                            }

                            measured = new Vector2(width, height);
                            float offset = Math.Max(0.5f, Math.Min(1f, (size * ScaleModifier) / 14));

                            if (getCharacterRegions)
                            {
                                characterRegions = new RectangleF[text.Length];

                                // SetMeasurableCharacterRanges only accepts a maximum of 32 intervals to be queried, so we as the library user are
                                // forced to split the string into 32 character long chunks and perform MeasureCharacterRanges on each.
                                int numIntervals = (text.Length / 32) + 1;
                                for (int i = 0; i < numIntervals; ++i)
                                {
                                    int offsetIndex = i * 32;
                                    int end         = Math.Min(text.Length - offsetIndex, 32);

                                    CharacterRange[] characterRanges = new CharacterRange[end];
                                    for (int j = 0; j < end; ++j)
                                    {
                                        characterRanges[j] = new CharacterRange(j + offsetIndex, 1);
                                    }

                                    sf.SetMeasurableCharacterRanges(characterRanges);
                                    Region[] regions = graphics.MeasureCharacterRanges(
                                        text,
                                        f,
                                        new RectangleF(
                                            padding.X,
                                            padding.Y,
                                            restrictBounds.X == 0 ? Single.PositiveInfinity : restrictBounds.X,
                                            restrictBounds.Y == 0 ? Single.PositiveInfinity : restrictBounds.Y),
                                        sf);

                                    for (int j = 0; j < end; ++j)
                                    {
                                        Region region = regions[j] as Region;
                                        characterRegions[j + offsetIndex] = region.GetBounds(graphics);
                                    }
                                }
                            }

                            if (measureOnly)
                            {
                                int startSpace = 0;
                                int endSpace   = 0;

                                int i = 0;
                                while (i < text.Length && text[i++] == ' ')
                                {
                                    startSpace++;
                                }
                                int j = text.Length - 1;
                                while (j >= i && text[j--] == ' ')
                                {
                                    endSpace++;
                                }
                                if (startSpace == text.Length)
                                {
                                    endSpace += startSpace;
                                }

                                measured = new Vector2(width + (endSpace * 5.145f * size / 12), height);
                                return(null);
                            }

                            using (Bitmap b = new Bitmap(width, height, PixelFormat.Format32bppArgb))
                                using (System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(b))
                                {
                                    //Quality settings
                                    g.TextRenderingHint = graphics.TextRenderingHint;
                                    g.SmoothingMode     = SmoothingMode.HighQuality;
                                    g.InterpolationMode = InterpolationMode.HighQualityBicubic;

                                    if (background.A > 0)
                                    {
                                        if (cornerBounds != Vector4.Zero)
                                        {
                                            fillRoundedRectangle(g, new Rectangle(0, 0, width, height), new SolidBrush(OsuMathHelper.CConvert(background)), cornerBounds);

                                            if (borderWidth > 0)
                                            {
                                                drawRoundedRectangle(g,
                                                                     new Rectangle(0, 0, width - (int)Math.Ceiling(borderWidth / 2f), height - (int)Math.Ceiling(borderWidth / 2f)),
                                                                     new Pen(OsuMathHelper.CConvert(border), borderWidth),
                                                                     cornerBounds);
                                            }
                                        }
                                        else
                                        {
                                            g.Clear(OsuMathHelper.CConvert(background));
                                            if (borderWidth > 0)
                                            {
                                                g.DrawRectangle(new Pen(OsuMathHelper.CConvert(border), borderWidth),
                                                                new Rectangle(borderWidth / 2, borderWidth / 2, width - borderWidth, height - borderWidth));
                                            }
                                        }
                                    }
                                    else
                                    {
                                        g.Clear(System.Drawing.Color.FromArgb(1, color.R, color.G, color.B));
                                    }


                                    using (Brush brush = new SolidBrush(OsuMathHelper.CConvert(color)))
                                    {
                                        if (restrictBounds != Vector2.Zero)
                                        {
                                            restrictBounds.X -= padding.X * 2;
                                            restrictBounds.Y -= padding.Y * 2;

                                            switch (shadow)
                                            {
                                            case ShadowType.Normal:
                                                g.DrawString(text, f, shadowBrush, new RectangleF(padding.X - offset, offset + padding.Y, restrictBounds.X, restrictBounds.Y), sf);
                                                g.DrawString(text, f, shadowBrush, new RectangleF(padding.X + offset, offset + padding.Y, restrictBounds.X, restrictBounds.Y), sf);
                                                break;

                                            case ShadowType.Border:
                                                Brush borderBrush = greyBrush;
                                                if (background.A == 0 && borderWidth == 1 && border.A > 0)
                                                {
                                                    borderBrush = new SolidBrush(OsuMathHelper.CConvert(border));
                                                }

                                                g.DrawString(text, f, borderBrush, new RectangleF(padding.X + offset, padding.Y + offset, restrictBounds.X, restrictBounds.Y), sf);
                                                g.DrawString(text, f, borderBrush, new RectangleF(padding.X + offset, padding.Y - offset, restrictBounds.X, restrictBounds.Y), sf);
                                                g.DrawString(text, f, borderBrush, new RectangleF(padding.X - offset, padding.Y + offset, restrictBounds.X, restrictBounds.Y), sf);
                                                g.DrawString(text, f, borderBrush, new RectangleF(padding.X - offset, padding.Y - offset, restrictBounds.X, restrictBounds.Y), sf);
                                                break;
                                            }

                                            g.DrawString(text, f, brush, new RectangleF(padding.X, padding.Y, restrictBounds.X, restrictBounds.Y), sf);
                                        }
                                        else
                                        {
                                            switch (shadow)
                                            {
                                            case ShadowType.Normal:
                                                g.DrawString(text, f, shadowBrush, padding.X - offset, padding.Y + offset);
                                                g.DrawString(text, f, shadowBrush, padding.X + offset, padding.Y + offset);
                                                break;

                                            case ShadowType.Border:
                                                Brush borderBrush = greyBrush;
                                                if (background.A == 0 && borderWidth == 1 && border.A > 0)
                                                {
                                                    borderBrush = new SolidBrush(OsuMathHelper.CConvert(border));
                                                }

                                                g.DrawString(text, f, borderBrush, padding.X + offset, padding.Y + offset);
                                                g.DrawString(text, f, borderBrush, padding.X - offset, padding.Y + offset);
                                                g.DrawString(text, f, borderBrush, padding.X + offset, padding.Y - offset);
                                                g.DrawString(text, f, borderBrush, padding.X - offset, padding.Y - offset);
                                                break;
                                            }

                                            g.DrawString(text, f, brush, padding.X, padding.Y);
                                        }
                                    }

                                    //if (lastTexture == null || lastTexture.isDisposed)
                                    {
                                        lastTexture            = pTexture.FromBitmap(b);
                                        lastTexture.Disposable = true;
                                    }

                                    /*else
                                     * {
                                     *  lastTexture.Width = b.Width;
                                     *  lastTexture.Height = b.Height;
                                     *  lastTexture.SetData(b);
                                     * }*/

                                    return(lastTexture);
                                }
                        }
                }
                catch (Exception e)
                {
                    measured = Vector2.Zero;
                    return(null);
                }
            }
        }
コード例 #20
0
 private double validateValue(TrackBar t, double value)
 {
     return(OsuMathHelper.Clamp(value, t.Minimum, t.Maximum));
 }
コード例 #21
0
ファイル: ProgressBar.cs プロジェクト: notperry1234567890/osu
 internal virtual void SetProgress(float progress)
 {
     progressBarForeground.VectorScale = new Vector2(OsuMathHelper.Clamp(progress, 0, 1) * length, height);
 }
コード例 #22
0
        private void SongSetup_Load(object sender, EventArgs e)
        {
            combos = new[] { combo1, combo2, combo3, combo4,
                             combo5, combo6, combo7, combo8 };

            List <String> files = (BeatmapManager.Current.InOszContainer) ?
                                  new List <string>(BeatmapManager.Current.Package.MapFiles) : null;

            //Restrict anything that can alter the filename of the difficulty when we are in the editor with a overridden difficulty
            //unless we are using the save as dialog.
            bool fRestrict = files != null && !newDifficulty &&
                             files.Exists((f) => f.EndsWith(Path.GetFileName(BeatmapManager.Current.Filename)));

            version.Enabled = !fRestrict;

            title.Text          = !string.IsNullOrEmpty(BeatmapManager.Current.TitleUnicode) ? BeatmapManager.Current.TitleUnicode : BeatmapManager.Current.Title;
            titleRomanised.Text = string.IsNullOrEmpty(BeatmapManager.Current.Title) ? GeneralHelper.AsciiOnly(BeatmapManager.Current.TitleUnicode) : BeatmapManager.Current.Title;

            artist.Text          = !string.IsNullOrEmpty(BeatmapManager.Current.ArtistUnicode) ? BeatmapManager.Current.ArtistUnicode : BeatmapManager.Current.Artist;
            artistRomanised.Text = string.IsNullOrEmpty(BeatmapManager.Current.Artist) ? GeneralHelper.AsciiOnly(BeatmapManager.Current.ArtistUnicode) : BeatmapManager.Current.Artist;

            creator.Text = (BeatmapManager.Current.Creator.Length > 0
                                ? BeatmapManager.Current.Creator
                                : ConfigManager.sUsername.Value);
            source.Text = BeatmapManager.Current.Source;
            if (creator.Text == ConfigManager.sUsername || fRestrict)
            {
                creator.Enabled = false;
            }
            version.Text = BeatmapManager.Current.Version;

            coopmode.Checked = BeatmapManager.Current.PlayMode == PlayModes.OsuMania && BeatmapManager.Current.DifficultyCircleSize >= 10;

            // extend the trackbar a little to avoid resetting .osuhaxed values
            setDifficulty(hpDrainRate, BeatmapManager.Current.DifficultyHpDrainRate, DRAIN_MIN, DRAIN_MAX, 10.0);

            if (allowedModes.SelectedIndex == 3)
            {
                setDifficulty(circleSize, BeatmapManager.Current.DifficultyCircleSize / (coopmode.Checked ? 2 : 1), CS_MIN_MANIA, CS_MAX_MANIA, 1.0); // Mania doesn't support any decimal circle size
            }
            else
            {
                setDifficulty(circleSize, BeatmapManager.Current.DifficultyCircleSize, CS_MIN, CS_MAX, 10.0);
            }

            setDifficulty(approachRate, BeatmapManager.Current.DifficultyApproachRate, AR_MIN, AR_MAX, 10.0);
            setDifficulty(overallDifficulty, BeatmapManager.Current.DifficultyOverall, OD_MIN, OD_MAX, 10.0);

            // in the case where there's only one sampleset, this works.
            // when there isn't, the control is hidden anyway.
            listSampleset.SelectedItem = AudioEngine.CurrentSampleSet.ToString();
            tags.Text               = BeatmapManager.Current.Tags;
            source.Text             = BeatmapManager.Current.Source;
            sampleCustom.Checked    = AudioEngine.CustomSamples == CustomSampleSet.Custom1;
            checkEpilepsy.Checked   = BeatmapManager.Current.EpilepsyWarning;
            udCountdownOffset.Value = BeatmapManager.Current.CountdownOffset;

            stackLeniency.Value = (int)Math.Max(2, Math.Round(BeatmapManager.Current.StackLeniency * 10));

            allowedModes.SelectedIndex = (int)BeatmapManager.Current.PlayMode;
            originMode = BeatmapManager.Current.PlayMode;

            volume1.Value = BeatmapManager.Current.SampleVolume;

            if (BeatmapManager.Current.AudioPresent)
            {
                checkSamplesMatchPlaybackRate.Checked = BeatmapManager.Current.SamplesMatchPlaybackRate;
            }
            else
            {
                checkSamplesMatchPlaybackRate.Checked = true;
                checkSamplesMatchPlaybackRate.Enabled = false;
            }

            checkCountdown.Checked     = BeatmapManager.Current.Countdown != Countdown.Disabled;
            checkLetterbox.Checked     = BeatmapManager.Current.LetterboxInBreaks;
            checkWidescreen.Checked    = BeatmapManager.Current.WidescreenStoryboard || newDifficulty;
            checkStoryOverFire.Checked = !BeatmapManager.Current.StoryFireInFront;

            if (BeatmapManager.Current.Countdown == Countdown.Disabled)
            {
                countdownNormal.Checked = true;
            }
            else
            {
                countdownDouble.Checked = BeatmapManager.Current.Countdown == Countdown.DoubleSpeed;
                countdownHalf.Checked   = BeatmapManager.Current.Countdown == Countdown.HalfSpeed;
                countdownNormal.Checked = BeatmapManager.Current.Countdown == Countdown.Normal;
            }

            SkinManager.InitializeSkinList();
            foreach (string s in SkinManager.Skins)
            {
                skinPreference.Items.Add(s);
            }

            if (!string.IsNullOrEmpty(BeatmapManager.Current.SkinPreference))
            {
                skinPreference.Text = BeatmapManager.Current.SkinPreference;
            }
            else
            {
                skinPreference.SelectedIndex = 0;
            }



            panelCountdownRate.Enabled = checkCountdown.Checked;

            if (AudioEngine.ControlPoints.Count > 0)
            {
                SampleSet       def    = AudioEngine.ControlPoints[0].SampleSet;
                CustomSampleSet cus    = AudioEngine.ControlPoints[0].CustomSamples;
                int             volume = AudioEngine.ControlPoints[0].Volume;


                foreach (ControlPoint p in AudioEngine.ControlPoints)
                {
                    if (p.SampleSet != def || p.CustomSamples != cus || p.CustomSamples >= CustomSampleSet.Custom2)
                    {
                        hideSampleSettings.Visible = true;
                        resetSampleSettings        = false;
                    }
                    if (p.Volume != volume)
                    {
                        hideSampleVolume.Visible = true;
                        resetVolumeSettings      = false;
                    }
                }

                volume1.Value = volume;
            }

            List <System.Drawing.Color> colours = new List <System.Drawing.Color>(4);

            for (int x = 0; x < SkinManager.MAX_COLOUR_COUNT; x++)
            {
                System.Drawing.Color c = OsuMathHelper.CConvert(SkinManager.LoadColour("Combo" + (x + 1).ToString()));
                if (x < 2 || c.A > 0)
                {
                    colours.Add(c);
                }
            }

            while (colours.Count < 2)
            {
                colours.Add(System.Drawing.Color.FromArgb(240, 240, 240));
            }

            colours.Add(colours[0]);
            colours.RemoveAt(0);

            int y;

            for (y = 0; y < colours.Count; y++)
            {
                combos[y].SwatchColor = colours[y];
                combos[y].Visible     = true;
                combos[y].Visible2    = true;
            }

            for (; y < 8; y++)
            {
                combos[y].Visible  = false;
                combos[y].Visible2 = false;
            }

            backgroundColour.SwatchColor = OsuMathHelper.CConvert(EventManager.backgroundColour);

            updateCheckedColours();
            customColour.Checked    = BeatmapManager.Current.CustomColours;
            cb_maniaSpecial.Checked = BeatmapManager.Current.SpecialStyle;

            if (newDifficulty || fRestrict)
            {
                version.Text = string.Empty;
                version.Select();

                artist.Enabled = false;
                title.Enabled  = false;
            }
            else
            {
                artist.Select();
            }

            changesMade = false;
        }
コード例 #23
0
 internal static GridSizes ClampSize(GridSizes value)
 {
     return((GridSizes)OsuMathHelper.Clamp((int)value, (int)GridSizes.Tiny, (int)GridSizes.Large));
 }
コード例 #24
0
        internal void Update()
        {
            float targetAlpha        = backgroundIsReady && showStoryboard ? 1 : 0;
            float maskingTargetAlpha = WidescreenStoryboard ? 0 : targetAlpha;

            if (GameBase.Mode == OsuModes.Edit)
            {
                spriteManagerFG.Alpha      = spriteManagerBG.Alpha = targetAlpha;
                spriteManagerMasking.Alpha = maskingTargetAlpha;
            }
            else
            {
                if (spriteManagerFG.Alpha != targetAlpha)
                {
                    spriteManagerBG.Alpha = spriteManagerFG.Alpha = OsuMathHelper.Clamp(spriteManagerFG.Alpha + ((targetAlpha < spriteManagerFG.Alpha ? -0.07f : 0.07f) * (float)GameBase.FrameRatio), 0, 1);
                }

                if (spriteManagerMasking.Alpha != maskingTargetAlpha)
                {
                    spriteManagerMasking.Alpha = OsuMathHelper.Clamp(spriteManagerMasking.Alpha + ((maskingTargetAlpha < spriteManagerMasking.Alpha ? -0.07f : 0.07f) * (float)GameBase.FrameRatio), 0, 1);
                }
            }

            bool breakMode = false;

            if (hitObjectManager.hitObjectsCount > 0)
            {
                if (beforeGameplay && AudioEngine.Time > hitObjectManager.EarliestHitObject.HittableStartTime - hitObjectManager.PreEmpt)
                {
                    beforeGameplay = false;
                }
                else if (!afterGameplay && AudioEngine.Time > hitObjectManager.LatestHitObject.HittableEndTime + hitObjectManager.HitWindow50)
                {
                    afterGameplay = true;
                }
            }
            else
            {
                beforeGameplay = true;
                afterGameplay  = false;
            }

            if (GameBase.Mode == OsuModes.Play && (beforeGameplay || afterGameplay))
            {
                breakMode = true;
            }

            for (int i = 0; i < eventBreaks.Count; i++)
            {
                EventBreak e = eventBreaks[i];

                if (AudioEngine.Time < e.StartTime || AudioEngine.Time > e.EndTime)
                {
                    continue;
                }

                breakMode    = true;
                BreakCurrent = e;

                break;
            }

            if (GameBase.Mode == OsuModes.Play && Player.Passing != passingCurrent)
            {
                passingCurrent = Player.Passing;

                if (passingCurrent)
                {
                    InvokeOnPassing();
                }
                else
                {
                    InvokeOnFailing();
                }

                //Sprites
                for (int i = 0; i < storyLayerSprites[(int)StoryLayer.Fail].Count; i++)
                {
                    Event e = storyLayerSprites[(int)StoryLayer.Fail][i];

                    e.Sprite.Bypass = passingCurrent;
                }

                //Samples
                for (int i = 0; i < storyLayerSamples[(int)StoryLayer.Fail].Count; i++)
                {
                    EventSample e = (EventSample)storyLayerSamples[(int)StoryLayer.Fail][i];

                    if (passingCurrent)
                    {
                        AudioEngine.SampleEvents.Remove(e.SampleCache);
                    }
                    else
                    {
                        AudioEngine.SampleEvents.Add(e.SampleCache);
                    }
                }

                if (!firstRun)
                {
                    //Sprites
                    for (int i = 0; i < storyLayerSprites[(int)StoryLayer.Pass].Count; i++)
                    {
                        Event e = storyLayerSprites[(int)StoryLayer.Pass][i];
                        e.Sprite.Bypass = !passingCurrent;
                    }

                    //Samples
                    for (int i = 0; i < storyLayerSamples[(int)StoryLayer.Pass].Count; i++)
                    {
                        EventSample e = (EventSample)storyLayerSamples[(int)StoryLayer.Pass][i];

                        if (passingCurrent)
                        {
                            AudioEngine.SampleEvents.Add(e.SampleCache);
                        }
                        else
                        {
                            AudioEngine.SampleEvents.Remove(e.SampleCache);
                        }
                    }
                }
                firstRun = false;
            }

            if (GameBase.Mode == OsuModes.Play && Player.Loaded && breakMode != BreakMode && !InputManager.ReplayMode)
            {
                //toggles go here. are only run on switching mode.
                if (!breakMode)
                {
                    NotificationManager.ClearMessageMassive();
                    //Clear any displaying messages when gameplay starts.
                }
            }

            BreakMode = breakMode;

            if (!breakMode)
            {
                BreakCurrent = null;
            }

            UpdateVideo();

            UpdateDimming();

            if (GameBase.SixtyFramesPerSecondFrame && showStoryboard)
            {
                LoadDynamic(false, true);
            }
        }
コード例 #25
0
        private void InitializeTester()
        {
            if (!PREDEFINED_TEST)
            {
                return;
            }

            if (BeatmapManager.Beatmaps.Count > 0)
            {
                if (USE_LAST_PLAYED_BEATMAP)
                {
                    List <Beatmap> temp = new List <Beatmap>(BeatmapManager.Beatmaps);
                    temp.Sort((a, b) => { return(a.DateLastPlayed.CompareTo(b.DateLastPlayed)); });
                    BeatmapManager.Current = temp[temp.Count - 1];
                }
                else //Choose a random beatmap
                {
                    BeatmapManager.Current = BeatmapManager.Beatmaps[RNG.Next(0, BeatmapManager.Beatmaps.Count)];
                }
            }

            if (MULTIPLAYER_MATCH)
            {
                if (BeatmapManager.Current == null)
                {
                    NotificationManager.ShowMessage("Couldn't start in specified test mode because no beatmaps were available.");
                    return;
                }

                BanchoClient.Start();

                Mode = OsuModes.MatchSetup;

                const int player_count = 8;

                while (!BanchoClient.Connected || !BanchoClient.InitializationComplete)
                {
                    Scheduler.Update();
                }

                PresenceCache.QueryAll();

                while (User.Id <= 0 || BanchoClient.Users.Count < player_count)
                {
                    Scheduler.Update();
                }

                List <User> users = BanchoClient.Users.FindAll(u => u.InitialLoadComplete && u.Id != User.Id);
                users.Insert(0, User); //we are the first user.

                MatchSetup.Match = new ClientSideMatch(new bMatch(MatchTypes.Standard,
                                                                  MatchScoringTypes.Score,
                                                                  MatchTeamTypes.TeamVs,
                                                                  PlayModes.Osu,
                                                                  @"My test game",
                                                                  string.Empty,
                                                                  player_count,
                                                                  BeatmapManager.Current.SortTitle,
                                                                  BeatmapManager.Current.BeatmapChecksum,
                                                                  BeatmapManager.Current.BeatmapId,
                                                                  MODS_TO_USE,
                                                                  2,
                                                                  MultiSpecialModes.FreeMod
                                                                  ));

                for (int i = 0; i < player_count; i++)
                {
                    MatchSetup.Match.slotId[i]    = users[i].Id;
                    MatchSetup.Match.UserSlots[i] = users[i];

                    MatchSetup.Match.slotStatus[i] = SlotStatus.Playing;
                    switch (MatchSetup.Match.matchTeamType)
                    {
                    case MatchTeamTypes.TagTeamVs:
                    case MatchTeamTypes.TeamVs:
                        MatchSetup.Match.slotTeam[i] = i % 2 == 0 ? SlotTeams.Blue : SlotTeams.Red;
                        break;
                    }
                }

                bScoreFrame[] frames = new bScoreFrame[player_count];
                for (int i = 0; i < player_count; i++)
                {
                    frames[i] = new bScoreFrame {
                        id = (byte)i, pass = true, currentHp = 200
                    }
                }
                ;

                RunBackgroundThread(delegate
                {
                    Thread.Sleep(5000);

                    for (int i = 0; i < player_count; i++)
                    {
                        PlayerVs.MatchPlayerSkipped(i);
                        Thread.Sleep(100);
                    }

                    Thread.Sleep(2000);

                    Player.QueueSkip();
                    Player.Instance?.DoSkip();

                    PlayerVs.AllPlayersLoaded    = true;
                    PlayerVs.AllPlayersCompleted = true;

                    while (true)
                    {
                        byte player = (byte)RNG.Next(0, player_count);

                        switch (RNG.Next(0, 30))
                        {
                        default:
                            frames[player].count300 += 1;
                            frames[player].currentCombo++;
                            frames[player].currentHp += 3;
                            break;

                        case 1:
                        case 2:
                        case 3:
                            frames[player].count100 += 1;
                            frames[player].currentCombo++;
                            frames[player].currentHp += 2;
                            break;

                        case 4:
                        case 5:
                            frames[player].count50   += 1;
                            frames[player].currentHp += 1;
                            frames[player].currentCombo++;
                            break;

                        case 6:
                            frames[player].countMiss   += 1;
                            frames[player].currentHp   -= 50;
                            frames[player].currentCombo = 0;
                            break;
                        }

                        frames[player].currentHp = OsuMathHelper.Clamp(frames[player].currentHp, 0, 200);

                        if (frames[player].currentHp == 0)
                        {
                            frames[player].pass = false;
                        }
                        else if (frames[player].currentHp > 100)
                        {
                            frames[player].pass = true;
                        }

                        frames[player].totalScore += frames[player].currentCombo * 300;
                        frames[player].maxCombo    = Math.Max(frames[player].maxCombo, frames[player].currentCombo);


                        PlayerVs.MatchScoreUpdate(frames[player]);

                        Thread.Sleep(50);
                    }
                });
            }

            switch (INITIAL_MODE)
            {
            case OsuModes.Play:
                if (BeatmapManager.Current == null)
                {
                    NotificationManager.ShowMessage("Couldn't start in specified test mode because no beatmaps were available.");
                    return;
                }

                ModManager.ModStatus = MODS_TO_USE;

                if (AUTOMATIC_SKIP)
                {
                    GameBase.RunBackgroundThread(delegate
                    {
                        while (true)
                        {
                            if (Player.Instance != null && Player.Instance.Status != PlayerStatus.Busy)
                            {
                                Scheduler.Add(delegate { Player.Instance?.DoSkip(); });
                                if (Player.HasSkipped)
                                {
                                    break;
                                }
                            }

                            Thread.Sleep(200);
                        }
                    });
                }

                if (AUTOPLAY)
                {
                    ModManager.ModStatus |= Mods.Autoplay;
                }

                break;
            }

            QueuedMode  = INITIAL_MODE;
            Player.Mode = INITIAL_PLAY_MODE;
        }
    }
コード例 #26
0
        internal void SetScrollPosition(Vector2 scrollPosition, float clamp = 0)
        {
            ScrollPosition = new Vector2(ScrollDraggerOnLeft && ScrollDragger && ScrollDraggerPadding ? -8 : 0, OsuMathHelper.Clamp(scrollPosition.Y, ClampingStartHeight, Math.Max(ClampingStartHeight, ContentDimensions.Y - ContentDisplayHeight)) * clamp + scrollPosition.Y * (1 - clamp));

            if (float.IsNaN(ScrollPosition.X))
            {
                ScrollPosition.X = 0;
            }
            if (float.IsNaN(ScrollPosition.Y))
            {
                ScrollPosition.Y = ClampingStartHeight;
            }

            ContentSpriteManager.ViewOffset           = ScrollPosition;
            ContentSpriteManagerBackground.ViewOffset = ScrollPosition;

            Children.ForEach(s => s.ScrollOffset = ScrollPosition);

            UpdateDragger();
        }
コード例 #27
0
        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!";
        }