Exemple #1
0
        public CircularProgressBar(bool alwaysDraw = true)
            : base(alwaysDraw)
        {
            vertexBuffer = new QuadVertexBuffer <UncolouredVertex2d>(1, BufferUsageHint.StaticDraw);

            // Some sane defaults
            // Todo: We probably want these as global colours somewhere for the rest of osu!next to use?
            RingForegroundColour = Color.White;
            RingBackgroundColour = new Color(54, 72, 78, 255);
            GlowColour           = new Color(17, 136, 170, 255);
        }
Exemple #2
0
        public override bool Draw()
        {
            if (bypass)
            {
                return(false);
            }

            SpriteManager.Current.SetBlending(Additive);

            pTexture texture = Texture;

            if (texture == null || texture.IsDisposed)
            {
                return(true);
            }

            Vector2 d = new Vector2(drawRectangle.X + drawOriginScaled.X, drawRectangle.Y + drawOriginScaled.Y);

            if (vertexBuffer == null)
            {
                vertexBuffer = new QuadVertexBuffer <ParticleVertex2d>(amountParticles, BufferUsageHint.StaticDraw);

                RectangleF texCoordsRect = new RectangleF(0, 0,
                                                          (float)texture.Width / TextureGl.GetPotDimension(texture.Width),
                                                          (float)texture.Height / TextureGl.GetPotDimension(texture.Height));

                for (int i = 0; i < amountParticles; ++i)
                {
                    int vertexIndex = i * 4;

                    int     time      = RNG.Next(500, 1200);
                    double  angle     = RNG.NextDouble(Math.PI * 2.0);
                    Vector2 direction = drawScaleVector * new Vector2((float)Math.Cos(angle), (float)Math.Sin(angle)) * (float)RNG.NextDouble(radius);

                    if (time > maxTime)
                    {
                        maxTime = time;
                    }

                    vertexBuffer.Vertices[vertexIndex + 0].Position        = d + new Vector2(-drawRectangle.Width / 2, -drawRectangle.Height / 2);
                    vertexBuffer.Vertices[vertexIndex + 0].TexturePosition = new Vector2(0, 0);
                    vertexBuffer.Vertices[vertexIndex + 0].Colour          = Color.White;
                    vertexBuffer.Vertices[vertexIndex + 0].Time            = time;
                    vertexBuffer.Vertices[vertexIndex + 0].Direction       = direction;

                    vertexBuffer.Vertices[vertexIndex + 1].Position        = d + new Vector2(-drawRectangle.Width / 2, drawRectangle.Height / 2);
                    vertexBuffer.Vertices[vertexIndex + 1].TexturePosition = new Vector2(0, texCoordsRect.Height);
                    vertexBuffer.Vertices[vertexIndex + 1].Colour          = Color.White;
                    vertexBuffer.Vertices[vertexIndex + 1].Time            = time;
                    vertexBuffer.Vertices[vertexIndex + 1].Direction       = direction;

                    vertexBuffer.Vertices[vertexIndex + 2].Position        = d + new Vector2(drawRectangle.Width / 2, drawRectangle.Height / 2);
                    vertexBuffer.Vertices[vertexIndex + 2].TexturePosition = new Vector2(texCoordsRect.Width, texCoordsRect.Height);
                    vertexBuffer.Vertices[vertexIndex + 2].Colour          = Color.White;
                    vertexBuffer.Vertices[vertexIndex + 2].Time            = time;
                    vertexBuffer.Vertices[vertexIndex + 2].Direction       = direction;

                    vertexBuffer.Vertices[vertexIndex + 3].Position        = d + new Vector2(drawRectangle.Width / 2, -drawRectangle.Height / 2);
                    vertexBuffer.Vertices[vertexIndex + 3].TexturePosition = new Vector2(texCoordsRect.Width, 0);
                    vertexBuffer.Vertices[vertexIndex + 3].Colour          = Color.White;
                    vertexBuffer.Vertices[vertexIndex + 3].Time            = time;
                    vertexBuffer.Vertices[vertexIndex + 3].Direction       = direction;
                }

                vertexBuffer.Update();
            }

            if (texture.TextureGl != null && texture.TextureGl.Bind())
            {
                OsuGlControl.ParticleShader.Properties[@"g_Gravity"]   = gravity;
                OsuGlControl.ParticleShader.Properties[@"g_FadeClock"] = (float)(getClockTime() - startTime);
                OsuGlControl.ParticleShader.Begin();
                vertexBuffer.Draw();
                OsuGlControl.ParticleShader.End();
            }

            return(true);
        }