Пример #1
0
        protected override void DrawSelf(SpriteBatch sb)
        {
            base.DrawSelf(sb);
            PreDraw?.Invoke(this, sb);
            var center = GetInnerDimensions().Center();

            sb.Draw(Texture, center, null, Color.White, 0, Texture.Size() * 0.5f, Scale, SpriteEffects.None, 0f);
        }
Пример #2
0
        /// <inheritdoc />
        public void Draw(TimeSpan total, TimeSpan elapsed, bool isRunningSlowly)
        {
            PreDraw?.Invoke(this, new DrawEventArgs(total, elapsed, isRunningSlowly, Campaign.Renderer));

            InternalDraw(total, elapsed, isRunningSlowly);

            PostDraw?.Invoke(this, new DrawEventArgs(total, elapsed, isRunningSlowly, Campaign.Renderer));
        }
Пример #3
0
            /// <summary>
            /// Invokes the Xna PreDraw event.
            /// </summary>
            /// <param name="gameTime"></param>
            public static void InvokePreDraw(GameTime gameTime)
            {
                var args = new XnaDrawEventArgs
                {
                    GameTime = gameTime
                };

                PreDraw.Invoke(args);
            }
Пример #4
0
        /// <inheritdoc />
        public void Draw(TimeSpan total, TimeSpan elapsed, bool isRunningSlowly)
        {
            PreDraw?.Invoke(this, new DrawEventArgs(total, elapsed, isRunningSlowly, UserInterface.Renderer));

            if (Cursor != null)
            {
                UserInterface.Renderer.Draw(Cursor.Texture, lastLocation);
            }

            PostDraw?.Invoke(this, new DrawEventArgs(total, elapsed, isRunningSlowly, UserInterface.Renderer));
        }
Пример #5
0
        /// <inheritdoc />
        public void Draw(TimeSpan total, TimeSpan elapsed, bool isRunningSlowly)
        {
            if (!IsVisible)
            {
                return;
            }

            PreDraw?.Invoke(this, new DrawEventArgs(total, elapsed, isRunningSlowly, UserInterface.Renderer));

            UserInterface.Renderer.Draw(background, destination, Background);
            InternalDraw(total, elapsed, isRunningSlowly);

            PostDraw?.Invoke(this, new DrawEventArgs(total, elapsed, isRunningSlowly, UserInterface.Renderer));
        }
Пример #6
0
        public virtual void Draw(SpriteBatch spriteBatch, float deltaTime)
        {
            PreDraw?.Invoke(spriteBatch, deltaTime);
            var drawRect = DrawRect;

            switch (shape)
            {
            case Shape.Rectangle:
                if (secondaryColor.HasValue)
                {
                    GUI.DrawRectangle(spriteBatch, drawRect, secondaryColor.Value, isFilled, thickness: 2);
                }
                GUI.DrawRectangle(spriteBatch, drawRect, color, isFilled, thickness: IsSelected ? 3 : 1);
                break;

            case Shape.Circle:
                if (secondaryColor.HasValue)
                {
                    ShapeExtensions.DrawCircle(spriteBatch, DrawPos, size / 2, sides, secondaryColor.Value, thickness: 2);
                }
                ShapeExtensions.DrawCircle(spriteBatch, DrawPos, size / 2, sides, color, thickness: IsSelected ? 3 : 1);
                break;

            case Shape.Cross:
                float halfSize = size / 2;
                if (secondaryColor.HasValue)
                {
                    GUI.DrawLine(spriteBatch, DrawPos + Vector2.UnitY * halfSize, DrawPos - Vector2.UnitY * halfSize, secondaryColor.Value, width: 2);
                    GUI.DrawLine(spriteBatch, DrawPos + Vector2.UnitX * halfSize, DrawPos - Vector2.UnitX * halfSize, secondaryColor.Value, width: 2);
                }
                GUI.DrawLine(spriteBatch, DrawPos + Vector2.UnitY * halfSize, DrawPos - Vector2.UnitY * halfSize, color, width: IsSelected ? 3 : 1);
                GUI.DrawLine(spriteBatch, DrawPos + Vector2.UnitX * halfSize, DrawPos - Vector2.UnitX * halfSize, color, width: IsSelected ? 3 : 1);
                break;

            default: throw new NotImplementedException(shape.ToString());
            }
            if (IsSelected)
            {
                if (showTooltip && !string.IsNullOrEmpty(tooltip))
                {
                    var offset = tooltipOffset ?? new Vector2(size, -size / 2);
                    GUI.DrawString(spriteBatch, DrawPos + offset, tooltip, textColor, textBackgroundColor);
                }
            }
            PostDraw?.Invoke(spriteBatch, deltaTime);
        }
Пример #7
0
        /// <inheritdoc />
        public void Draw(TimeSpan total, TimeSpan elapsed, bool isRunningSlowly)
        {
            PreDraw?.Invoke(this, new DrawEventArgs(total, elapsed, isRunningSlowly, Renderer));

            foreach (Dialog dialog in Dialogs)
            {
                dialog.Draw(total, elapsed, isRunningSlowly);
            }

            foreach (Window window in Windows)
            {
                window.Draw(total, elapsed, isRunningSlowly);
            }

            Mouse.Draw(total, elapsed, isRunningSlowly);

            PostDraw?.Invoke(this, new DrawEventArgs(total, elapsed, isRunningSlowly, Renderer));
        }
Пример #8
0
        protected override void DrawSelf(SpriteBatch spriteBatch)
        {
            if (Texture == null)
            {
                return;
            }

            PreDraw?.Invoke();

            CalculatedStyle dimensions = base.GetDimensions();
            Rectangle?      nullable   = null;

            spriteBatch.End();
            spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, PointSample ? SamplerState.PointClamp : SamplerState.AnisotropicClamp, DepthStencilState.None, _overflowRaster, null, Main.UIScaleMatrix);

            if (Pass != null)
            {
                Pass.Apply();
            }
            spriteBatch.Draw(this.Texture, dimensions.ToRectangle(), nullable, Color.White, 0f, Vector2.Zero, SpriteEffects.None, 0f);

            spriteBatch.End();
            spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.AnisotropicClamp, DepthStencilState.None, _overflowRaster, null, Main.UIScaleMatrix);
        }