Example #1
0
        public CheckBox(CheckBoxProps checkBoxProps) : base(checkBoxProps)
        {
            TextParagraph      = UiManager.DefaultParagraph(checkBoxProps.Text, Anchor.Auto);
            TextParagraph.Size = new Vector2(0, 10);
            TextParagraph.SetOffset(new Vector2(25, 0));
            TextParagraph.p_HiddenInternalEntity = true;
            AddChild(TextParagraph, true);

            PromiscuousClicksMode = true;

            CHECKBOX_SIZE = checkBoxProps.CheckBoxSize != Vector2.Zero ? checkBoxProps.CheckBoxSize : new Vector2(16, 16);
            Checked       = checkBoxProps.IsChecked;
        }
        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);
            }
        }
Example #3
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);
            }
        }
Example #4
0
        public TextInput(TextInputProps textInputProps) : base(textInputProps)
        {
            p_UseMultiLine = textInputProps.UseMultiLine;

            p_Padding = new Vector2(20, 20);

            if (textInputProps.UseMultiLine && textInputProps.Size.Y == -1)
            {
                p_size.Y *= 4;
            }

            LimitBySize = !p_UseMultiLine;

            TextParagraph = UiManager.DefaultParagraph(string.Empty, p_UseMultiLine ? Anchor.TopLeft : Anchor.CenterLeft);
            TextParagraph.p_HiddenInternalEntity = true;
            AddChild(TextParagraph, true);

            PlaceHolderParagraph = UiManager.DefaultParagraph(string.Empty, p_UseMultiLine ? Anchor.TopLeft : Anchor.CenterLeft);
            PlaceHolderParagraph.p_HiddenInternalEntity = true;
            AddChild(PlaceHolderParagraph, true);

            if (p_UseMultiLine)
            {
                p_scrollBar = new VerticalScrollBar(new SliderProps {
                    Min = 0, Max = 0, EntityAnchor = Anchor.CenterRight, LocalPosition = new Vector2(-8, 0), Size = new Vector2(10, 0)
                });
                p_scrollBar.Value   = 0;
                p_scrollBar.Visible = false;
                p_scrollBar.p_HiddenInternalEntity = true;
                AddChild(p_scrollBar, false);
            }

            TextParagraph.WarpsWords        = p_UseMultiLine;
            PlaceHolderParagraph.WarpsWords = p_UseMultiLine;

            MultiColorParagraph colorTextParagraph = TextParagraph as MultiColorParagraph;

            if (colorTextParagraph != null)
            {
                colorTextParagraph.EnableColorInstructions = false;
            }
        }
Example #5
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;
        }
Example #6
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);
            }
        }
Example #7
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);
        }