public override void Draw(BaseScreen.Resources screenResources, SmartSpriteBatch spriteBatch, ScreenAbstractor screen, float opacity, FloatRectangle?clip = null, Texture2D bgTexture = null, Vector2?scrollOffset = null)
        {
            float width    = ActualPosition.Width;
            float height   = ActualPosition.Height;
            float barWidth = BarWidth.Value();

            if (barWidth == 0)
            {
                barWidth = 0.001f;
            }


            float availableWidth = width - barWidth;

            float percentage = Value.Value() / MaxValue.Value();

            float sliderHeight = SliderHeight.Value();

            if (sliderHeight == 0)
            {
                sliderHeight = 0.001f;
            }

            float sliderTop = (height / 2f) - (sliderHeight / 2f);

            FloatRectangle sliderRect = new FloatRectangle(0 + ActualPosition.X, sliderTop + ActualPosition.Y, width, sliderHeight);
            FloatRectangle barRect    = new FloatRectangle(availableWidth * percentage + ActualPosition.X, ActualPosition.Y, barWidth, height);

            if (SliderTexture.HasValue())
            {
                using (new SmartSpriteBatchManager(Solids.Instance.SpriteBatch))
                {
                    spriteBatch.Draw(Solids.Instance.AssetLibrary.GetTexture(SliderTexture.Value(), true), screen.Translate(sliderRect).Value.ToRectangle, Color.White);
                }
            }
            else
            {
                spriteBatch.DrawSolidRectangle(screen.Translate(sliderRect).Value, SliderColor.Value().Value *opacity, clip);
            }

            if (BarTexture.HasValue())
            {
                using (new SmartSpriteBatchManager(Solids.Instance.SpriteBatch))
                {
                    spriteBatch.Draw(Solids.Instance.AssetLibrary.GetTexture(BarTexture.Value(), true), screen.Translate(barRect).Value.ToRectangle, Color.White);
                }
            }
            else
            {
                spriteBatch.DrawSolidRectangle(screen.Translate(barRect).Value, BarColor.Value().Value *opacity, clip);
            }
        }
Exemple #2
0
        public override void Draw(BaseScreen.Resources screenResources, SmartSpriteBatch spriteBatch, ScreenAbstractor screen, float opacity, FloatRectangle?clip = null, Texture2D bgTexture = null, Vector2?scrollOffset = null)
        {
            if (clip.HasValue && ParentPosition.HasValue)
            {
                clip = clip.Value.ConstrainTo(ParentPosition.Value);
            }

            clip = screen.Translate(clip);

            var t = Position.Value();

            FloatRectangle tmp = screen.Translate(ActualPosition.AdjustForMargin(Margin)).Value;

            if (clip.HasValue)
            {
                if (tmp.Right < clip.Value.X || tmp.X > clip.Value.Right)
                {
                    return;
                }
            }

            if (BlurAmount.Value() > 0)
            {
                Solids.GaussianBlur.DoBlur(bgTexture, BlurAmount.Value(), (BackgroundColor.Value().Value *opacity) * ((BlurAmount.Value() / Solids.MaxBlur)), tmp.ToRectangle, ScissorRect, clip, NoisePerc.Value());
            }

            if (BackgroundColor.Value().HasValue&& FillTexture.Value() == null)
            {
                spriteBatch.DrawSolidRectangle(tmp, BackgroundColor.Value().Value *opacity, clip);
            }

            if (FillTexture.Value() != null)
            {
                using (new SmartSpriteBatchManager(Solids.Instance.SpriteBatch))
                {
                    spriteBatch.DrawTexturedRectangle(tmp, BackgroundColor.Value().Value *opacity, Solids.Instance.AssetLibrary.GetTexture(FillTexture.Value()), TilingMode.Value, clip);
                }
            }

            if (BrushSize.Value() > 0)
            {
                spriteBatch.DrawBorder(tmp, BorderColor.Value() * opacity, BrushSize.Value(), clip);
            }

            this.ActualSize = new Vector2(Position.Value().Width, Position.Value().Height).PadForMargin(Margin);

            SetChildrenOriginToMyOrigin();
        }