예제 #1
0
        public override void Draw(SmartSpriteBatch spriteBatch, ScreenAbstractor screen, float opacity, FloatRectangle?clip = null, Texture2D bgTexture = null)
        {
            int y = (int)BaseScreen.AllAssets.Max(t => t.Position.Bottom);
            var x = (int)BaseScreen.AllAssets.Max(t => t.Position.Right);

            if (BaseScreen.RenderTarget == null || BaseScreen.RenderTarget.Width != (int)x || BaseScreen.RenderTarget.Height != (int)y)
            {
                BaseScreen.RenderTarget = new RenderTarget2D(Solids.SpriteBatch.GraphicsDevice, x, y);
            }

            Solids.SpriteBatch.GraphicsDevice.SetRenderTarget(BaseScreen.RenderTarget);
            Solids.SpriteBatch.GraphicsDevice.Clear(Color.Transparent);
            //  Solids.SpriteBatch.ForceBegin(SpriteSortMode.Immediate, BlendState.NonPremultiplied, SamplerState.AnisotropicClamp, DepthStencilState.None, RasterizerState.CullNone, null, null);
            using (new SmartSpriteBatchManager(Solids.SpriteBatch))
            {
                BaseScreen.Draw(new GameTime(), BaseScreen.OpenCloseOpacity, null);
            }

            Solids.SpriteBatch.GraphicsDevice.SetRenderTarget(ParentScreen.RenderTarget);

            //  Solids.SpriteBatch.ForceEnd();

            //previousTexture = screen.RenderTarget;

            base.Draw(spriteBatch, screen, opacity, clip, bgTexture);
        }
예제 #2
0
        public override void Draw(BaseScreen.Resources screenResources, SmartSpriteBatch spriteBatch, ScreenAbstractor screen, float opacity, FloatRectangle?clip = null, Texture2D bgTexture = null, Vector2?scrollOffset = null)
        {
            ctx = 0;
            var    items = Items?.Value();
            string hash  = "";

            hash = items?.GetHashCode().ToString();

            if (previousHash != hash)
            {
                this.Children.Value = new List <DataboundAsset>();
                if (items != null)
                {
                    foreach (VirtualizedDataContext dataContext in items)
                    {
                        var newItem = screenResources.GetTemplate(Template.Value());
                        newItem.VirtualizedDataContext = dataContext;
                        newItem.ParentAsset            = this;

                        this.Children.Value.Add(newItem);
                    }
                }

                this.FixParentChildRelationship();
                this.FixBinds();
                previousHash = hash;
            }


            SetChildrenOriginToMyOrigin();
        }
예제 #3
0
        public override void Draw(BaseScreen.Resources screenResources, SmartSpriteBatch spriteBatch, ScreenAbstractor screen, float opacity, FloatRectangle?clip = null, Texture2D bgTexture = null, Vector2?scrollOffset = null)
        {
            ctx = 0;
            var    items = Items?.Value();
            string hash  = "";

            hash = items?.GetHashCode().ToString();

            if (previousHash != hash)
            {
                if (items != null)
                {
                    this.Children.Value = new List <DataboundAsset>();
                    foreach (VirtualizedDataContext dataContext in items)
                    {
                        var newItem = screenResources.GetTemplate(Template.Value());
                        newItem.VirtualizedDataContext = dataContext;
                        newItem.ParentAsset            = this;

                        this.Children.Value.Add(newItem);
                    }

                    this.FixParentChildRelationship();
                    this.FixBinds();
                }

                previousHash = hash;
            }

            float pos = 0;

            foreach (DataboundAsset item in Children.Value)
            {
                if (item.Margin != null && item.Margin.Value != null)
                {
                    pos = pos + item.Margin.Value.Top;
                }


                float height = item.Position.Value.Height;
                if (item.ActualSize.Y > 0)
                {
                    height = item.ActualSize.Y;
                }

                float lm = 0;
                float bm = 0;

                if (item.Margin != null && item.Margin.Value != null)
                {
                    lm = item.Margin.Value.Left;
                    bm = item.Margin.Value.Bottom;
                }

                item.Position.Value = new FloatRectangle(lm, pos, item.Position.Value.Width, item.Position.Value.Height);

                pos = pos + height + bm;
            }

            this.ActualSize = new Vector2(this.Position.Value.Width, pos - this.Position.ToVector2().Y);

            SetChildrenOriginToMyOrigin();
        }
예제 #4
0
 public virtual void Draw(BaseScreen.Resources screenResources, SmartSpriteBatch spriteBatch, ScreenAbstractor screen, float opacity, FloatRectangle?clip = null, Texture2D bgTexture = null, Vector2?scrollOffset = null)
 {
     throw new NotImplementedException();
 }
예제 #5
0
        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 barHeight = BarHeight.Value();

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


            float availableHeight = height - barHeight;

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

            float sliderWidth = SliderWidth.Value();

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

            float sliderLeft = (width / 2f) - (sliderWidth / 2f);

            FloatRectangle sliderRect = new FloatRectangle(
                sliderLeft + ActualPosition.X,
                ActualPosition.Y,
                sliderWidth,
                height);

            FloatRectangle barRect = new FloatRectangle(
                ActualPosition.X,
                (availableHeight - (availableHeight * percentage)) + ActualPosition.Y,
                width,
                barHeight);

            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);
            }

            if (ActiveColor.HasValue() && this.State.Value == ButtonState.Hover)
            {
                spriteBatch.DrawSolidRectangle(screen.Translate(ActualPosition).Value, ActiveColor.Value().Value *opacity, clip);
            }
        }
예제 #6
0
        public override void Draw(BaseScreen.Resources screenResources, SmartSpriteBatch spriteBatch, ScreenAbstractor screen, float opacity, FloatRectangle?clip = null, Texture2D bgTexture = null, Vector2?scrollOffset = null)
        {
            if (Solids.Instance.InputService.IsPressed(InputService.ShiftKeys.LeftShift1))
            {
                //   return;
            }

            if (Texture2D != null)
            {
                FloatRectangle?pos            = screen.Translate(Position.Value.Move(scrollOffset));
                FloatRectangle?translatedClip = screen.Translate(clip);

                Rectangle?fixedSource = SourceRectangle.Value;

                (Rectangle position, Rectangle? source)thing = TextureHelpers.GetAdjustedDestAndSourceAfterClip(pos, fixedSource, translatedClip);
                using (new SmartSpriteBatchManager(Solids.Instance.SpriteBatch))
                {
                    //spriteBatch.Draw(Texture2D.Value, thing.Item1, thing.Item2, ImageColor.Value * opacity, Rotation.Value, new Vector2(thing.Item1.Width/2f, thing.Item1.Height/2f),SpriteEffects.None,1f);

                    spriteBatch.Draw(Texture2D.Value, pos.Value.ToRectangle, null, ImageColor.Value * opacity);
                }
            }
        }
예제 #7
0
        List <SmartSpriteBatch.Line> TranslateLines(List <SmartSpriteBatch.Line> lines, ScreenAbstractor screen, float opacity, Vector2?scrollOffset = null)
        {
            List <SmartSpriteBatch.Line> result = new List <SmartSpriteBatch.Line>();

            foreach (SmartSpriteBatch.Line line in lines)
            {
                result.Add(new SmartSpriteBatch.Line(screen.Translate(line.Start.Move(scrollOffset)), screen.Translate(line.End.Move(scrollOffset)), line.Color * opacity, line.BrushSize));
            }

            return(result);
        }
예제 #8
0
        public static Vector2 DrawFontAsset(
            SmartSpriteBatch spriteBatch,
            ScreenAbstractor screen,
            float opacity,
            string text,
            Color?fontColor,
            FloatRectangle?position,
            float fontSize,
            float?lineHeight,
            string fontName,
            bool pseudoAntiAlias,
            bool wordWrap,
            FontJustification justification,
            float fontMargin,
            Thickness margin      = null,
            Color?outlineColor    = null,
            FloatRectangle?clip   = null,
            Texture2D bgTexture   = null,
            Vector2?scrollOffset  = null,
            int?caretPos          = null,
            bool multiLine        = false,
            Rectangle?scissorRect = null)
        {
            if (position == null)
            {
                return(Vector2.Zero);
            }

            if (string.IsNullOrWhiteSpace(text))
            {
                return(Vector2.Zero);
            }

            List <string> textValues = new List <string> {
                text
            };

            if (multiLine)
            {
                textValues = text.ToList();
            }

            if (fontSize == 0)
            {
                fontSize = 24;
            }

            float lHeight = fontSize * 1.25f;

            if (lineHeight.HasValue)
            {
                lHeight = lineHeight.Value;
            }

            float      translatedBaseSize = screen.Translate(new Vector2(1f, 1f)).Y;
            float      fontSizeRatio      = (translatedBaseSize / 1080f);
            float      translatedFontSize = fontSizeRatio * fontSize;
            FontFamily fontFamily         = Solids.Instance.Fonts.Fonts[fontName];

            if (fontFamily == null)
            {
                return(Vector2.Zero);
            }

            string currentKey = translatedFontSize.ToString() + fontFamily.ToString();


            BMFont myFont = fontFamily.GetFont((int)translatedFontSize);

            Vector2 sizeOfI = myFont.MeasureString("Igj'#" + FontSystem.MDL2Symbols.Download.AsChar());

            float translatedWidth = screen.Translate(position).Value.Width;

            float wordWrapWidth = translatedWidth;

            if (margin != null)
            {
                wordWrapWidth = wordWrapWidth - screen.Translate(new Vector2(margin.Left + margin.Right, 0)).X;
                position      = new FloatRectangle(position.Value.X, position.Value.Y + margin.Top, position.Value.Width, position.Value.Height);
            }

            Vector2 size = myFont.MeasureString(text);

            float scale = translatedFontSize / sizeOfI.Y;

            if (wordWrap && multiLine)
            {
                List <string> lines = textValues.ToList();

                textValues = new List <string>();

                string reconstructedLine = "";
                foreach (string line in lines)
                {
                    string[] words = line.Split(' ');

                    for (int i = 0; i < words.Length; i++)
                    {
                        string withoutCurrentWord = reconstructedLine;
                        reconstructedLine = reconstructedLine + words[i] + " ";

                        Vector2 wwSize = myFont.MeasureString(reconstructedLine);
                        if (wwSize.X * scale > wordWrapWidth)
                        {
                            textValues.Add(withoutCurrentWord);
                            reconstructedLine = "";
                            i = i - 1;
                        }
                    }
                }

                textValues.Add(reconstructedLine);
            }



            float   ulHeight = lHeight / translatedBaseSize;
            Vector2 calcSize = Vector2.Zero;

            for (int i = 0; i < textValues.Count; i++)
            {
                FloatRectangle positionValue = new FloatRectangle(position.Value.X, position.Value.Y + (ulHeight * i), position.Value.Width, ulHeight);
                FloatRectangle fontPos       = new FloatRectangle(positionValue.X, positionValue.Y + fontMargin, positionValue.Width, positionValue.Height - (fontMargin * 2f));

                string textValue = textValues[i];

                FloatRectangle?tclip = screen.Translate(clip);

                FloatRectangle positionRectangle = new FloatRectangle();

                FloatRectangle translatedPosition = screen.Translate(fontPos).Value;

                if (tclip.HasValue)
                {
                    if (translatedPosition.Right < tclip.Value.X || translatedPosition.X > tclip.Value.Right)
                    {
                        return(Vector2.Zero);
                    }
                }

                if (string.IsNullOrWhiteSpace(fontName))
                {
                    return(Vector2.Zero);
                }

                float width = size.X * scale;

                switch (justification)
                {
                case FontJustification.Left:
                {
                    positionRectangle = new FloatRectangle(translatedPosition.X, translatedPosition.Y, width, translatedPosition.Height);
                    break;
                }

                case FontJustification.Right:
                {
                    positionRectangle = new FloatRectangle(translatedPosition.Right - width, translatedPosition.Y, width, translatedPosition.Height);
                    break;
                }

                case FontJustification.Center:
                {
                    positionRectangle = new FloatRectangle(translatedPosition.X + (translatedPosition.Width / 2f) - (width / 2f), translatedPosition.Y, width, translatedPosition.Height);
                    break;
                }
                }

                if (caretPos != null)
                {
                    using (new SmartSpriteBatchManager(Solids.Instance.SpriteBatch, scissorRect: tclip))
                    {
                        float actualCarotPos = (width / text.Length) * caretPos.Value;

                        float oppax = (DateTime.Now.Millisecond % 250) / 250f;
                        spriteBatch.DrawLine(
                            new Vector2(positionRectangle.X + actualCarotPos, positionRectangle.Y),
                            new Vector2(positionRectangle.X + actualCarotPos, positionRectangle.Bottom),
                            Color.White * oppax, tclip, 1f);
                    }
                }

                Rectangle source = new Rectangle(0, 0, (int)size.X, (int)size.Y);

                tclip = tclip?.Clamp(scissorRect);

                (Rectangle position, Rectangle? source)translator = TextureHelpers.GetAdjustedDestAndSourceAfterClip(positionRectangle, source, tclip);

                Solids.Instance.SpriteBatch.Scissor = tclip.ToRectangle();

                Rectangle tmp = Solids.Instance.Bounds;
                if (tclip.HasValue)
                {
                    tmp = tclip.Clamp(scissorRect).ToRectangle;
                }

                Solids.Instance.SpriteBatch.Scissor = tmp;

                using (new SmartSpriteBatchManager(Solids.Instance.SpriteBatch))
                {
                    if ((pseudoAntiAlias || outlineColor.HasValue))
                    {
                        Color?cl = fontColor * opacity * 0.3f;

                        if (outlineColor.HasValue)
                        {
                            cl = outlineColor.Value * opacity;
                        }

                        for (int y = -1; y <= 1; y = y + 2)
                        {
                            for (int x = -1; x <= 1; x = x + 2)
                            {
                                myFont.DrawText(Solids.Instance.SpriteBatch, translator.position.X + x, translator.position.Y + y, textValue, cl, scale);
                            }
                        }
                    }

                    myFont.DrawText(Solids.Instance.SpriteBatch, translator.position.X, translator.position.Y, textValue, fontColor * opacity, scale);
                    calcSize = new Vector2(position.Value.Width, calcSize.Y + lHeight);
                }

                Solids.Instance.SpriteBatch.Scissor = null;
            }


            float actHeight = screen.Untranslate(calcSize.Y);

            if (margin != null)
            {
                calcSize.Y = calcSize.Y + margin.Bottom;
            }

            return(new Vector2(position.Value.Width, actHeight));
        }
예제 #9
0
        public override void Draw(BaseScreen.Resources screenResources, SmartSpriteBatch spriteBatch, ScreenAbstractor screen, float opacity, FloatRectangle?clip = null, Texture2D bgTexture = null, Vector2?scrollOffset = null)
        {
            using (new SmartSpriteBatchManager(Solids.Instance.SpriteBatch))
            {
                Rectangle tmp = screen.Translate(Position.Value.Move(scrollOffset)).ToRectangle().Clip(screen.Translate(clip));

                int borderSize = (int)(Math.Min(tmp.Width, tmp.Height) * BorderSizePercentage.Value);

                spriteBatch.Draw(Solids.Instance.AssetLibrary.GetTexture("Images\\9grid\\tl.png"), new Rectangle(tmp.X - borderSize, tmp.Y - borderSize, borderSize, borderSize), Color.Value * opacity);
                spriteBatch.Draw(Solids.Instance.AssetLibrary.GetTexture("Images\\9grid\\tr.png"), new Rectangle(tmp.Right, tmp.Y - borderSize, borderSize, borderSize), Color.Value * opacity);
                spriteBatch.Draw(Solids.Instance.AssetLibrary.GetTexture("Images\\9grid\\bl.png"), new Rectangle(tmp.X - borderSize, tmp.Bottom, borderSize, borderSize), Color.Value * opacity);
                spriteBatch.Draw(Solids.Instance.AssetLibrary.GetTexture("Images\\9grid\\br.png"), new Rectangle(tmp.Right, tmp.Bottom, borderSize, borderSize), Color.Value * opacity);
                spriteBatch.Draw(Solids.Instance.AssetLibrary.GetTexture("Images\\9grid\\t.png"), new Rectangle(tmp.X, tmp.Y - borderSize, tmp.Width, borderSize), Color.Value * opacity);
                spriteBatch.Draw(Solids.Instance.AssetLibrary.GetTexture("Images\\9grid\\b.png"), new Rectangle(tmp.X, tmp.Bottom, tmp.Width, borderSize), Color.Value * opacity);
                spriteBatch.Draw(Solids.Instance.AssetLibrary.GetTexture("Images\\9grid\\l.png"), new Rectangle(tmp.X - borderSize, tmp.Y, borderSize, tmp.Height), Color.Value * opacity);
                spriteBatch.Draw(Solids.Instance.AssetLibrary.GetTexture("Images\\9grid\\r.png"), new Rectangle(tmp.Right, tmp.Y, borderSize, tmp.Height), Color.Value * opacity);
            }

            SetChildrenOriginToMyOrigin();
        }
예제 #10
0
        public override void Draw(BaseScreen.Resources screenResources, SmartSpriteBatch spriteBatch, ScreenAbstractor screen, float opacity, FloatRectangle?clip = null, Texture2D bgTexture = null, Vector2?scrollOffset = null)
        {
            string txt = Text.Value();

            if (!string.IsNullOrWhiteSpace(Symbol.Value()))
            {
                MDL2Symbols symbol = (MDL2Symbols)Enum.Parse(typeof(MDL2Symbols), Symbol.Value());
                txt = symbol.AsChar();
            }

            if (FontName.Value != null)
            {
                this.ActualSize = DrawFontAsset(spriteBatch, screen, opacity, txt, FontColor.Value(),
                                                ActualPosition, FontSize.Value(), LineHeight.Value(), FontName.Value(), PseudoAntiAlias.Value(), WordWrap.Value(),
                                                Justification.Value(), FontMargin.Value(), Margin.Value(), OutlineColor.Value(), Clip, bgTexture, scrollOffset, CaretPos.Value(),
                                                MultiLine.Value(), ScissorRect);
            }


            if (Position.Value.Height == 0)
            {
                autoSize = true;
            }

            if (autoSize)
            {
                this.Position.Value = new FloatRectangle(Position.Value.X, Position.Value.Y, Position.Value.Width, ActualSize.Y);
            }
        }
예제 #11
0
        public override void Draw(BaseScreen.Resources screenResources, SmartSpriteBatch spriteBatch, ScreenAbstractor screen, float opacity, FloatRectangle?clip = null, Texture2D bgTexture = null, Vector2?scrollOffset = null)
        {
            if (texture != null)
            {
                if (aspectRatio == 0)
                {
                    aspectRatio = texture.Width / (float)texture.Height;
                }
            }

            if (Texture.HasValue() && (texture == null || loadedTexture != Texture.Value()))
            {
                loadedTexture = Texture.Value();
                texture       = Solids.Instance.AssetLibrary.GetTexture(loadedTexture, true);
            }

            Rectangle rect = screen.Translate(ActualPosition).ToRectangle(); //.Move(scrollOffset)

            if (ScalingMode.Value == ScaleMode.BestFit)
            {
                float newWidth  = rect.Width;
                float newHeight = newWidth / aspectRatio;

                if (newHeight > rect.Height)
                {
                    newHeight = rect.Height;
                    newWidth  = newHeight * aspectRatio;
                }

                float xOffset = (rect.Width - newWidth) / 2f;
                float yOffset = (rect.Height - newHeight) / 2f;

                rect = new Rectangle((int)(rect.X + xOffset), (int)(rect.Y + yOffset), (int)newWidth, (int)newHeight);
            }

            if (ScalingMode.Value == ScaleMode.Fill)
            {
                float newWidth  = rect.Width;
                float newHeight = newWidth / aspectRatio;

                if (newHeight < rect.Height)
                {
                    newHeight = rect.Height;
                    newWidth  = newHeight * aspectRatio;
                }

                float xOffset = (rect.Width - newWidth) / 2f;
                float yOffset = (rect.Height - newHeight) / 2f;

                rect = new Rectangle((int)(rect.X + xOffset), (int)(rect.Y + yOffset), (int)newWidth, (int)newHeight);
            }

            if (ScalingMode.Value == ScaleMode.None)
            {
                rect.Width  = texture.Width;
                rect.Height = texture.Height;
            }

            if (texture != null)
            {
                Color c = Color.White;
                if (Colorize.HasValue())
                {
                    if (Colorize.Value() != null)
                    {
                        c = Colorize.Value().Value;
                    }
                }

                using (new SmartSpriteBatchManager(Solids.Instance.SpriteBatch))
                {
                    if (clip == null)
                    {
                        rect = new Rectangle(rect.X + (int)(rect.Width / 2f), rect.Y + (int)(rect.Height / 2f), rect.Width, rect.Height);
                        spriteBatch.Draw(texture, rect, null, c * opacity, Rotation.Value, new Vector2(texture.Width / 2, texture.Height / 2), SpriteEffects.None, 1f);
                    }
                    else
                    {
                        FloatRectangle?tclip  = screen.Translate(clip);
                        Rectangle      source = new Rectangle(0, 0, texture.Width, texture.Height);
                        (Rectangle position, Rectangle? source)translator = TextureHelpers.GetAdjustedDestAndSourceAfterClip(new FloatRectangle(rect), source, tclip);
                        using (new SmartSpriteBatchManager(Solids.Instance.SpriteBatch))
                        {
                            spriteBatch.Draw(texture, translator.position, translator.source, c * opacity, Rotation.Value, new Vector2(translator.source.Value.Width / 2f, translator.source.Value.Height / 2f), SpriteEffects.None, 1f);
                        }
                    }
                }
            }
        }
예제 #12
0
        public override void Draw(BaseScreen.Resources screenResources, SmartSpriteBatch spriteBatch, ScreenAbstractor screen, float opacity, FloatRectangle?clip = null, Texture2D bgTexture = null, Vector2?scrollOffset = null)
        {
            float pos = 0;

            foreach (DataboundAsset item in Children.Value.Where(x => !x.IsHiddenOrParentHidden()))
            {
                if (item.Margin != null && item.Margin.Value != null)
                {
                    pos = pos + item.Margin.Value.Top;
                }


                float height = item.Position.Value.Height;
                if (item.ActualSize.Y > 0)
                {
                    height = item.ActualSize.Y;
                }

                if (height == 0)
                {
                    Debug.WriteLine("oops");
                }

                float lm = 0;
                float bm = 0;

                if (item.Margin != null && item.Margin.Value != null)
                {
                    lm = item.Margin.Value.Left;
                    bm = item.Margin.Value.Bottom;
                }

                item.Position.Value = new FloatRectangle(lm, pos, item.Position.Value.Width, item.Position.Value.Height);

                pos = pos + height + bm;
            }

            this.ActualSize = new Vector2(this.Position.Value.Width, pos - this.Position.ToVector2().Y);

            SetChildrenOriginToMyOrigin();
        }
예제 #13
0
        public override void Draw(BaseScreen.Resources screenResources, SmartSpriteBatch spriteBatch, ScreenAbstractor screen, float opacity, FloatRectangle?clip = null, Texture2D bgTexture = null, Vector2?scrollOffset = null)
        {
            if (Solids.Instance.InputService.IsPressed(InputService.ShiftKeys.LeftShift1))
            {
                //  return;
            }

            Vector2 sp = new Vector2(StartPositon.X, StartPositon.Y).Move(scrollOffset);
            Vector2 ep = new Vector2(EndPositon.X, EndPositon.Y).Move(scrollOffset);



            if (clip != null && sp.X < clip.Value.X)
            {
                sp.X = clip.Value.X;
            }
            if (clip != null && sp.X > clip.Value.BottomRight.X)
            {
                sp.X = clip.Value.BottomRight.X;
            }
            if (clip != null && ep.X < clip.Value.X)
            {
                ep.X = clip.Value.X;
            }
            if (clip != null && ep.X > clip.Value.BottomRight.X)
            {
                ep.X = clip.Value.BottomRight.X;
            }


            if (clip != null && sp.Y < clip.Value.Y)
            {
                sp.Y = clip.Value.Y;
            }
            if (clip != null && sp.Y > clip.Value.BottomRight.Y)
            {
                sp.Y = clip.Value.BottomRight.Y;
            }
            if (clip != null && ep.Y < clip.Value.Y)
            {
                ep.Y = clip.Value.Y;
            }
            if (clip != null && ep.Y > clip.Value.BottomRight.Y)
            {
                ep.Y = clip.Value.BottomRight.Y;
            }


            Vector2 start = screen.Translate(sp);
            Vector2 end   = screen.Translate(ep);

            FloatRectangle?tclip = screen.Translate(clip);

            if (tclip.HasValue)
            {
                if ((start.X < tclip.Value.X && end.X < tclip.Value.X) || (start.X > tclip.Value.Right && end.X > tclip.Value.Right))
                {
                    return;
                }
            }

            spriteBatch.DrawLine(new Vector2(start.X, start.Y), new Vector2(end.X, end.Y), Color, null, BrushSize);
        }
예제 #14
0
        public override void Draw(BaseScreen.Resources screenResources, SmartSpriteBatch spriteBatch, ScreenAbstractor screen, float opacity, FloatRectangle?clip = null, Texture2D bgTexture = null, Vector2?scrollOffset = null)
        {
            if (!haveLoadedTemplate)
            {
                string template = Template.Value();

                List <DataboundAsset> children = this.Children.Value;

                DataboundAsset templateContent = screenResources.GetTemplate(template);
                templateContent.ParentAsset = this;

                if (templateContent is DataboundContainterAsset containerAsset)
                {
                    //containerAsset.Children.Value = children;

                    List <DataboundAsset> contentAssets = containerAsset.FindChildrenOfType <ContentAsset>();
                    if (contentAssets.Count > 0)
                    {
                        foreach (var contentAsset in contentAssets)
                        {
                            ((DataboundContainterAsset)contentAsset.ParentAsset).Children.Value = children;
                        }
                    }
                }

                this.Children.Value = new List <DataboundAsset> {
                    templateContent
                };
                this.FixParentChildRelationship();

                this.FixBinds();
                haveLoadedTemplate = true;
            }

            SetChildrenOriginToMyOrigin();
            if (ActualSize == Vector2.Zero)
            {
                this.ActualSize = this.Children.Value.First().ActualSize;
            }
        }
예제 #15
0
        public override void Draw(BaseScreen.Resources screenResources, SmartSpriteBatch spriteBatch, ScreenAbstractor screen, float opacity, FloatRectangle?clip = null, Texture2D bgTexture = null, Vector2?scrollOffset = null)
        {
            if (this.Children.Value == null || this.Children.Value.Count == 0)
            {
                return;
            }

            foreach (DataboundAsset databoundAsset in this.Children.Value)
            {
                databoundAsset.IsHidden.Value = true;
            }

            DataboundAsset select = this.Children.Value.First();

            if (this.State.Value == ButtonState.Hover && this.Children.Value.Count > 1)
            {
                select = this.Children.Value[1];
            }
            if (this.State.Value == ButtonState.Pressing && this.Children.Value.Count > 2)
            {
                select = this.Children.Value[2];
            }

            select.IsHidden.Value = false;

            SetChildrenOriginToMyOrigin();

            if (this.ActualSize == Vector2.Zero)
            {
                this.ActualSize = this.Children.Value.First().ActualSize;
            }
        }
예제 #16
0
 public override void Draw(BaseScreen.Resources screenResources, SmartSpriteBatch spriteBatch, ScreenAbstractor screen, float opacity, FloatRectangle?clip = null, Texture2D bgTexture = null, Vector2?scrollOffset = null)
 {
     SetChildrenOriginToMyOrigin();
     this.ActualSize = this.Children.Value.First().ActualSize;
 }
예제 #17
0
        public override void Draw(BaseScreen.Resources screenResources, SmartSpriteBatch spriteBatch, ScreenAbstractor screen, float opacity, FloatRectangle?clip = null, Texture2D bgTexture = null, Vector2?scrollOffset = null)
        {
            //    if (approxPoints == null)

            if (Points == null || Points.Value() == null)
            {
                return;
            }

            SetPoints(Points.Value());

            var drawPoints = approxPoints.Select(screen.Translate).ToArray();

            if (ToColor.HasValue())
            {
                spriteBatch.DrawLine(drawPoints, Color.Value(), ToColor.Value(), null, BrushSize.Value);
            }
            else
            {
                spriteBatch.DrawLine(drawPoints, Color.Value(), null, BrushSize.Value);
            }
        }
예제 #18
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();
        }
예제 #19
0
 public override void Draw(BaseScreen.Resources screenResources, SmartSpriteBatch spriteBatch, ScreenAbstractor screen, float opacity, FloatRectangle?clip = null, Texture2D bgTexture = null, Vector2?scrollOffset = null)
 {
     spriteBatch.DrawLines(TranslateLines(Lines, screen, opacity, scrollOffset), screen.Translate(clip));
 }