Exemplo n.º 1
0
        override public void DrawEntity(SpriteBatch spriteBatch, bool?BaseDraw = null)
        {
            if (UiManager.GetActiveUserInterface().ActiveEntity != this)
            {
                CalcAutoMaxValue();
            }

            Texture2D texture     = ContentLoader.GetTextureByName("tan_pressed");
            Texture2D markTexture = ContentLoader.GetTextureByName("tan_pressed");

            float FrameHeight = 0.14f;

            UiManager.GetActiveUserInterface().drawUtils.Draw(spriteBatch, texture, p_DrawArea, texture.Bounds, Color.White);

            Vector2 frameSizeTexture = new Vector2(texture.Width, texture.Height * FrameHeight);
            Vector2 frameSizeRender  = frameSizeTexture;
            float   ScaleYfac        = p_DrawArea.Width / frameSizeRender.X;

            int markWidth = p_DrawArea.Width;

            _markHeight = (int)(((float)markTexture.Height / (float)markTexture.Width) * (float)markWidth);

            _frameActualHeight = FrameHeight * texture.Height * ScaleYfac;

            float     markY    = p_DrawArea.Y + _frameActualHeight + _markHeight * 0.5f + (p_DrawArea.Height - _frameActualHeight * 2 - _markHeight) * (GetValueAsPercent());
            Rectangle markDest = new Rectangle(p_DrawArea.X, (int)Math.Round(markY) - _markHeight / 2, markWidth, _markHeight);

            UiManager.GetActiveUserInterface().drawUtils.Draw(spriteBatch, markTexture, markDest, markTexture.Bounds, Color.DarkGray);

            base.DrawEntity(spriteBatch, true);
        }
Exemplo n.º 2
0
        override public void DrawEntity(SpriteBatch spriteBatch, bool?BaseDraw = null)
        {
            if (BaseDraw == null)
            {
                Texture2D texture     = ContentLoader.GetTextureByName("tan_pressed");
                Texture2D markTexture = ContentLoader.GetTextureByName("tan_pressed");

                float frameWidth = 0.03f;

                UiManager.GetActiveUserInterface().drawUtils.Draw(spriteBatch, texture, p_DrawArea, texture.Bounds, Color.White);

                Vector2 frameSizeTexture = new Vector2(texture.Width * frameWidth, texture.Height);
                Vector2 frameSizeRender  = frameSizeTexture;
                float   ScaleXfac        = p_DrawArea.Height / frameSizeRender.Y;

                int markHeight = p_DrawArea.Height;
                p_MarkWidth = (int)(((float)markTexture.Width / (float)markTexture.Height) * (float)markHeight);

                p_FrameActualWidth = frameWidth * texture.Width * ScaleXfac;

                float     markX    = p_DrawArea.X + p_FrameActualWidth + p_MarkWidth * 0.5f + (p_DrawArea.Width - p_FrameActualWidth * 2 - p_MarkWidth) * GetValueAsPercent();
                Rectangle markDest = new Rectangle((int)System.Math.Round(markX) - p_MarkWidth / 2, p_DrawArea.Y, p_MarkWidth, markHeight);

                UiManager.GetActiveUserInterface().drawUtils.Draw(spriteBatch, markTexture, markDest, markTexture.Bounds, Color.White);

                base.DrawEntity(spriteBatch);
            }
            else
            {
                base.DrawEntity(spriteBatch);
            }
        }
Exemplo n.º 3
0
        protected override void AfterDrawChildren(SpriteBatch spriteBatch)
        {
            if (p_OverFlowMode == PanelOverflowBehavior.Overflow)
            {
                return;
            }

            p_InternalDrawArea = p_OriginalDrawArea;
            p_destinationRectVerision++;

            if (p_RenderTarget2D != null)
            {
                UiManager.GetActiveUserInterface().drawUtils.PopRenderTargets();

                UiManager.GetActiveUserInterface().drawUtils.StartDraw(spriteBatch, false);
                spriteBatch.Draw(p_RenderTarget2D, GetRenderTargetRect(), Color.White);
                UiManager.GetActiveUserInterface().drawUtils.EndDraw(spriteBatch);

                if (p_ScrollBar != null)
                {
                    p_InternalDrawArea.Y     -= p_ScrollBar.Value;
                    p_InternalDrawArea.Width -= p_ScrollBar.GetActualDestinationRectangle().Width;
                    p_ScrollBar.UpdateDestinationRects();

                    p_InternalDrawArea = p_OriginalDrawArea;
                }
            }
        }
Exemplo n.º 4
0
        public virtual void StartDraw(SpriteBatch spriteBatch, bool isDisabled)
        {
            spriteBatch.Begin(SpriteSortMode.Deferred, UiManager.GetActiveUserInterface().BlendState, UiManager.GetActiveUserInterface().SamplerState,
                              DepthStencilState.None, RasterizerState.CullCounterClockwise);

            UpdateRenderTarget(spriteBatch);
        }
Exemplo n.º 5
0
        public override Rectangle CalculateDestinationRectangle()
        {
            int width  = UiManager.GetActiveUserInterface().ScreenWidth;
            int height = UiManager.GetActiveUserInterface().ScreenHeight;

            return(new Rectangle(0, 0, width, height));
        }
Exemplo n.º 6
0
        public override void WriteLine(string value)
        {
            base.WriteLine(value);

            Paragraph paragraph = UiManager.DefaultParagraph(value, Anchor.AutoInLine, Microsoft.Xna.Framework.Color.Black, null, new Microsoft.Xna.Framework.Vector2(0, 20), null);

            UiManager.GetActiveUserInterface().ConsoleWindow.AddChild(paragraph);
        }
Exemplo n.º 7
0
        public void AfterDrawDebugs(SpriteBatch spriteBatch)
        {
            UiManager.GetActiveUserInterface().drawUtils.PopRenderTargets();

            UiManager.GetActiveUserInterface().drawUtils.StartDraw(spriteBatch, false);
            spriteBatch.Draw(RenderTarget2D, DrawRectangle, Color.White);
            UiManager.GetActiveUserInterface().drawUtils.EndDraw(spriteBatch);
        }
Exemplo n.º 8
0
        public void PushRenderTarget(RenderTarget2D target)
        {
            if (!UiManager.GetActiveUserInterface().UseRenderTarget)
            {
            }

            p_RenderTargets.Push(target);
        }
Exemplo n.º 9
0
        protected override void BeforeDrawChildren(SpriteBatch spriteBatch)
        {
            if (p_OverFlowMode == PanelOverflowBehavior.Overflow)
            {
                return;
            }

            Rectangle RenderTargetRect = GetRenderTargetRect();

            if (p_RenderTarget2D == null || p_RenderTarget2D.Width != RenderTargetRect.Width || p_RenderTarget2D.Height != p_RenderTarget2D.Height)
            {
                p_RenderTarget2D = new RenderTarget2D(spriteBatch.GraphicsDevice,
                                                      RenderTargetRect.Width, RenderTargetRect.Height, false,
                                                      spriteBatch.GraphicsDevice.PresentationParameters.BackBufferFormat,
                                                      spriteBatch.GraphicsDevice.PresentationParameters.DepthStencilFormat, 0,
                                                      RenderTargetUsage.PreserveContents);
            }

            spriteBatch.GraphicsDevice.SetRenderTarget(p_RenderTarget2D);
            spriteBatch.GraphicsDevice.Clear(Color.Transparent);

            UiManager.GetActiveUserInterface().drawUtils.PushRenderTarget(p_RenderTarget2D);

            //foreach (Entity e in Children)
            //{
            //    if (!e.p_DrawArea.Intersects(p_InternalDrawArea))
            //    {
            //        e.Visible = false;
            //    }
            //}

            p_OriginalDrawArea   = p_InternalDrawArea;
            p_InternalDrawArea.X = 0;
            p_InternalDrawArea.Y = 0;



            if (p_OverFlowMode == PanelOverflowBehavior.VerticalScroll)
            {
                p_InternalDrawArea.Y -= p_ScrollBar.Value;

                p_ScrollBar.SetAnchor(Anchor.CenterLeft);
                p_ScrollBar.SetOffset(new Vector2(p_InternalDrawArea.Width + 5, -p_InternalDrawArea.Y) / GlobalScale);

                if (p_ScrollBar.Parent != null)
                {
                    p_ScrollBar.BringToFront();
                }
                else
                {
                    AddChild(p_ScrollBar);
                }
            }


            ClearRectUpdateFlag(true);
        }
Exemplo n.º 10
0
 override protected void DoAfterUpdate()
 {
     if (p_IsInteractable &&
         (UiManager.GetActiveUserInterface().ActiveEntity == this ||
          UiManager.GetActiveUserInterface().ActiveEntity == Parent ||
          (UiManager.GetActiveUserInterface().ActiveEntity != null && UiManager.GetActiveUserInterface().ActiveEntity.IsDeepChildOf(Parent))))
     {
         if (InputUtils.MouseWheelChange != 0)
         {
             Value = p_Value - InputUtils.MouseWheelChange * GetStepSize();
         }
     }
 }
Exemplo n.º 11
0
        public override void DrawEntity(SpriteBatch spriteBatch, bool?BaseDraw = null)
        {
            if (p_ColorInstructions.Count > 0)
            {
                int     iTextIndex       = 0;
                Color   color            = OverlayColor;
                Vector2 oCharacterSize   = GetCharacterActualSize();
                Vector2 oCurrentPosition = new Vector2(p_Position.X - oCharacterSize.X, p_Position.Y);
                foreach (char c in p_ProcessedText)
                {
                    ColorInstruction colorInstruction;
                    if (p_ColorInstructions.TryGetValue(iTextIndex, out colorInstruction))
                    {
                        if (colorInstruction.UseFillColor)
                        {
                            color = Color.Black;
                        }
                        else
                        {
                            color = colorInstruction.color;
                        }
                    }

                    if (c == '\n')
                    {
                        oCurrentPosition.X  = p_Position.X - oCharacterSize.X;
                        oCurrentPosition.Y += p_CurrentFont.LineSpacing * p_ActualScale;
                    }
                    else
                    {
                        iTextIndex++;
                        oCurrentPosition.X += oCharacterSize.X;
                    }

                    Color fillColor = UiManager.GetActiveUserInterface().drawUtils.FixColorOpacity(color);

                    spriteBatch.DrawString(p_CurrentFont, c.ToString(), oCurrentPosition, fillColor, 0, p_FontOrigin, p_ActualScale, SpriteEffects.None, 0.5f);

                    base.DrawEntity(spriteBatch, true);
                }
            }
            else
            {
                base.DrawEntity(spriteBatch);
            }
        }
Exemplo n.º 12
0
        protected virtual void UpdateRenderTarget(SpriteBatch spriteBatch)
        {
            RenderTarget2D newRenderTarget = null;

            if (p_RenderTargets.Count > 0)
            {
                newRenderTarget = p_RenderTargets.Peek();
            }
            else
            {
                newRenderTarget = UiManager.GetActiveUserInterface().RenderTarget;
            }

            if (p_LastRenderTarget != newRenderTarget)
            {
                p_LastRenderTarget = newRenderTarget;
                spriteBatch.GraphicsDevice.SetRenderTarget(p_LastRenderTarget);
            }
        }
Exemplo n.º 13
0
        public void BeforeDrawDebugs(SpriteBatch spriteBatch)
        {
            int ScreenWidth  = UiManager.GetActiveUserInterface().ScreenWidth;
            int ScreenHeight = UiManager.GetActiveUserInterface().ScreenHeight;

            DrawRectangle = new Rectangle(0, 0, ScreenWidth, ScreenHeight);

            DisposeRenderTarget();

            RenderTarget2D = new RenderTarget2D(spriteBatch.GraphicsDevice, ScreenWidth, ScreenHeight);

            spriteBatch.GraphicsDevice.SetRenderTarget(RenderTarget2D);
            spriteBatch.GraphicsDevice.Clear(Color.Transparent);

            UiManager.GetActiveUserInterface().drawUtils.PushRenderTarget(RenderTarget2D);

            OrginRect       = DrawRectangle;
            DrawRectangle.X = 0;
            DrawRectangle.Y = 0;
        }
Exemplo n.º 14
0
        public override void DrawEntity(SpriteBatch spriteBatch, bool?BaseDraw = null)
        {
            if (BaseDraw == null)
            {
                if (HighlightColor.A > 0 || State == EntityState.MouseHover)
                {
                    Color backColor = UiManager.GetActiveUserInterface().drawUtils.FixColorOpacity(HighlightColor);
                    var   rect      = HighlightColorUseBoxSize ? p_DrawArea : p_ActualDrawRect;

                    if (HighlightColorUseBoxSize)
                    {
                        rect.Height = (int)(rect.Height / GlobalScale / LocalScale);
                    }

                    var Padding = new Point((int)(HighlightColorPadding.X * GlobalScale * LocalScale), (int)(HighlightColorPadding.Y * GlobalScale * LocalScale));
                    rect.Location -= Padding;
                    rect.Size     += Padding + Padding;

                    Texture2D New = ContentLoader.GetTextureByName("WhiteTexture");

                    spriteBatch.Draw(New, rect, HighlightColor);
                }

                Color fillColor = OverlayColor;

                Vector2 fontOrigin = new Vector2((int)p_FontOrigin.X, (int)p_FontOrigin.Y);

                spriteBatch.DrawString(p_CurrentFont, p_ProcessedText, p_Position, fillColor, 0, fontOrigin, p_ActualScale, SpriteEffects.None, 0.5f);

                base.DrawEntity(spriteBatch);
            }
            else if (BaseDraw == true)
            {
                base.DrawEntity(spriteBatch);
            }
        }