Exemple #1
0
 internal override void Draw(SpriteBatch batch, Camera2D cam = null)
 {
     base.Draw(batch, cam);
     if (!visible) return;
     // Draw overlay
     if (DataHandler.isValid(overlay))
     {
         RectangleF rect = LocalBoundingBox.Inflate(-Width * border, -Height * border);
         if (cam == null)
             batch.Draw(DataHandler.getTexture(overlay.RefKey)/*Texture2D from file*/, cam == null ? rect.ToRectangle() : cam.Transform(rect).ToRectangle()/*on-screen box*/, DataHandler.getTextureSource(overlay)/*Rectange on the sheet*/, Color.White/*white=no tint*/);
         else if (cam.isInsideView(rect))
         {
             RectangleF nocrop;
             RectangleF cropped = cam.TransformWithCropping(rect, out nocrop);
             RectangleF source = DataHandler.getTextureSource(overlay);
             source = source.Mask(nocrop, cropped);
             batch.Draw(DataHandler.getTexture(overlay.RefKey)/*Texture2D from file*/, cropped.Offset(parent.GlobalPosition).ToRectangle()/*on-screen box*/, source.ToRectangle()/*Rectange on the sheet*/, Color.White/*white=no tint*/);
         }
     }
     // Siblings
     foreach (UIVisibleObject obj in siblings.Where(t => t is UIVisibleObject)) obj.Draw(batch, cam);
     // Children
     foreach (UIVisibleObject obj in children.Where(t => t is UIVisibleObject)) obj.Draw(batch, cam);
     // Draw text
     if (text != "" && text != "\0")
     {
         Vector2 tsize = font.MeasureString(text);
         if (cam == null || cam.isInsideView(LocalCenter))
             batch.DrawString(font, text, GlobalCenter - tsize / 2 - cam.ActualView.Location, color);
     }
 }
Exemple #2
0
        internal override void Draw(SpriteBatch batch, Camera2D cam = null)
        {
            if (!visible)
            {
                return;
            }

            if (cells.Count > 0)
            {
                foreach (UIVisibleObject b in cells)
                {
                    b.Draw(batch, this.cam);                                    //TODO: Implement camera inside camera scenario (Camera.Parent)
                }
            }
            else
            {
                string  s    = "Nothing to show.";
                Vector2 size = DataHandler.Fonts[0].MeasureString(s);
                batch.DrawString(DataHandler.Fonts[0], s, new Vector2(maxwidth / 2, maxheight / 2) - size / 2 + GlobalPosition, Color.White);
            }
        }
        internal override void Draw(SpriteBatch batch, Camera2D cam = null)
        {
            if (!visible)
            {
                return;
            }
            // background
            UpdateBackground();
            if (rect != null)
            {
                batch.Draw(rect, BoundingBox.ToRectangle(), Color.White);
            }
            //
            string t = Padding + GetTextToDraw();

            Vector2 tsize = font.MeasureString(t);

            if (!Selected)
            {
                while (tsize.X > Size.X && t != "")
                {
                    t     = t.Substring(0, t.Length - 1);
                    tsize = font.MeasureString(t);
                }
            }
            else
            {
                while (tsize.X > size.X && t.Length > 1)
                {
                    t     = t.Substring(1, t.Length - 1);
                    tsize = font.MeasureString(t);
                }
            }
            batch.DrawString(font, t, cam == null ? this.GlobalCenter - tsize / 2 : cam.Transform(this.GlobalCenter - tsize / 2), text == "" ? Color.Gray : color);
            base.Draw(batch, cam);
        }
        internal override void Draw(SpriteBatch batch, Camera2D cam = null)
        {
            if (!visible) return;
            // background
            UpdateBackground();
            if (rect != null)
                batch.Draw(rect, BoundingBox.ToRectangle(), Color.White);
            //
            string t = Padding + GetTextToDraw();

            Vector2 tsize = font.MeasureString(t);
            if (!Selected)
                while (tsize.X > Size.X && t != "")
                {
                    t = t.Substring(0, t.Length - 1);
                    tsize = font.MeasureString(t);
                }
            else
                while (tsize.X > size.X && t.Length > 1)
                {
                    t = t.Substring(1, t.Length - 1);
                    tsize = font.MeasureString(t);
                }
            batch.DrawString(font, t, cam == null ? this.GlobalCenter - tsize / 2 : cam.Transform(this.GlobalCenter - tsize / 2), text == "" ? Color.Gray : color);
            base.Draw(batch, cam);
        }
 // You don't need a camera, draw ontop of the stage
 internal virtual void Draw(SpriteBatch batch, Camera2D cam = null)
 {
     if (!visible || sprite == null)
         return;
     if (cam == null)
         batch.Draw(DataHandler.getTexture(sprite[state].RefKey)/*Texture2D from file*/, BoundingBox.ToRectangle()/*on-screen box*/, DataHandler.getTextureSource(sprite[state])/*Rectange on the sheet*/, Color.White/*white=no tint*/);
     else
     {
         if (cam.isInsideView(LocalBoundingBox))
         {
             RectangleF nocrop;
             RectangleF cropped = cam.TransformWithCropping(LocalBoundingBox, out nocrop);
             RectangleF source = DataHandler.getTextureSource(sprite[state]);
             // rect is an intersection of nocrop, thus contained by it
             source = source.Mask(nocrop, cropped);
             batch.Draw(DataHandler.getTexture(sprite[state].RefKey)/*Texture2D from file*/,
                 cropped.Offset(parent.GlobalPosition).ToRectangle()/*on-screen box*/,
                 source.ToRectangle()/*Rectange on the sheet*/,
                 Color.White/*white=no tint*/);
         }
     }
 }
Exemple #6
0
 internal override void Draw(SpriteBatch batch, Camera2D cam = null)
 {
     batch.Draw(background, BoundingBox.ToRectangle(), Color.White);
     batch.Draw(fill, BoundingBox.ScaleWidth(progress).ToRectangle(), Color.White);
     base.Draw(batch, cam);
 }
Exemple #7
0
 internal override void Draw(SpriteBatch batch, Camera2D cam = null)
 {
     if (!visible)
         return;
     foreach (var obj in children) obj.Draw(batch);
 }
Exemple #8
0
        internal override void Draw(SpriteBatch batch, Camera2D cam = null)
        {
            if (!visible) return;

            if (cells.Count > 0)
                foreach (UIVisibleObject b in cells) b.Draw(batch, this.cam);   //TODO: Implement camera inside camera scenario (Camera.Parent)
            else
            {
                string s = "Nothing to show.";
                Vector2 size = DataHandler.Fonts[0].MeasureString(s);
                batch.DrawString(DataHandler.Fonts[0], s, new Vector2(maxwidth / 2, maxheight / 2) - size / 2 + GlobalPosition, Color.White);
            }
        }
Exemple #9
0
 internal void TrimGridToVisible()
 {
     maxwidth = Math.Min(Screen.ViewWidth, Width); maxheight = Math.Min(Screen.ViewHeight, Height);
     cam = new Camera2D(0, 0, maxwidth, maxheight, TotalWidth, TotalHeight);
     cam.FitToScreen = false;
 }
Exemple #10
0
 internal void Setup()
 {
     int i = 0;
     float x = 0, y = 0;
     foreach (UIVisibleObject cell in cells)
     {
         cell.Size = new Vector2(unitwidth, unitheight);
         cell.Position = new Vector2(x, y);
         cell.CentralizeSiblings();
         i++;
         if (i == cellsperrowcol)
         {
             i = 0;
             x = mode == Orientation.Portrait ? x + unitwidth : 0;
             y = mode == Orientation.Portrait ? 0 : y + unitheight;
         }
         else
         {
             x += mode == Orientation.Portrait ? 0 : unitwidth;
             y += mode == Orientation.Portrait ? unitheight : 0;
         }
     }
     cam = new Camera2D(0, 0, maxwidth, maxheight, TotalWidth, TotalHeight);
     cam.FitToScreen = false;
 }
Exemple #11
0
 internal override void Draw(SpriteBatch batch, Camera2D cam = null)
 {
     batch.Draw(background, BoundingBox.ToRectangle(), Color.White);
     batch.Draw(fill, BoundingBox.ScaleWidth(progress).ToRectangle(), Color.White);
     base.Draw(batch, cam);
 }
Exemple #12
0
 internal void TrimGridToVisible()
 {
     maxwidth        = Math.Min(Screen.ViewWidth, Width); maxheight = Math.Min(Screen.ViewHeight, Height);
     cam             = new Camera2D(0, 0, maxwidth, maxheight, TotalWidth, TotalHeight);
     cam.FitToScreen = false;
 }