Ejemplo n.º 1
0
        void QuestDescriptionDrawer(ISpriteBatch sb, Vector2 pos, IQuestDescription item, int index)
        {
            if (item == null)
            {
                return;
            }

            // Write the list index
            var indexStr      = "  " + (index + 1) + ". ";
            var indexStrWidth = Font.MeasureString(indexStr).X;

            sb.DrawString(Font, indexStr, pos, ForeColor);

            // Get the color to use for the title
            var titleColor = ForeColor;

            // Draw the quest's title, prefixing a DONE tag if its ready to turn in
            var title = item.Name;

            if (HasFinishQuestReqs(item.QuestID))
            {
                titleColor = CanTurnInQuestForeColor;
                title      = "[DONE] " + title;
            }
            sb.DrawString(Font, title, pos + new Vector2(indexStrWidth + 10, 0), titleColor);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Draws a string with shading.
        /// </summary>
        /// <param name="spriteBatch"><see cref="ISpriteBatch"/> to use to draw.</param>
        /// <param name="font"><see cref="Font"/> to draw the string with.</param>
        /// <param name="text">The string to draw.</param>
        /// <param name="position">The position of the top-left corner of the string to draw.</param>
        /// <param name="fontColor">The font color.</param>
        /// <param name="borderColor">The shading color.</param>
        public static void DrawStringShaded(this ISpriteBatch spriteBatch, Font font, string text, Vector2 position,
                                            Color fontColor, Color borderColor)
        {
            position = position.Round();

            spriteBatch.DrawString(font, text, position - new Vector2(0, 1), borderColor);
            spriteBatch.DrawString(font, text, position - new Vector2(1, 0), borderColor);
            spriteBatch.DrawString(font, text, position + new Vector2(0, 1), borderColor);
            spriteBatch.DrawString(font, text, position + new Vector2(1, 0), borderColor);

            spriteBatch.DrawString(font, text, position, fontColor);
        }
        void DefaultDrawer(ISpriteBatch sb, Vector2 pos, int v)
        {
            if (Font != _cachedSpacingFont)
            {
                _cachedSpacingFont = Font;
                _cachedSpacing     = (int)Font.MeasureString("W").X;
            }

            // Rank
            sb.DrawString(Font, Items.ElementAt(v).Rank.ToString(), pos, Color.Green);

            // Name
            sb.DrawString(Font, Items.ElementAt(v).Name, pos + new Vector2(_cachedSpacing + 2, 0), ForeColor);
        }
        void DefaultDrawer(ISpriteBatch sb, Vector2 pos, GuildMemberNameRank item, int index)
        {
            if (Font != _cachedSpacingFont)
            {
                _cachedSpacingFont = Font;
                _cachedSpacing     = (int)Font.MeasureString("W").X;
            }

            // Rank
            sb.DrawString(Font, item.Rank.ToString(), pos, Color.Green);

            // Name
            sb.DrawString(Font, item.Name, pos + new Vector2(_cachedSpacing + 2, 0), ForeColor);
        }
Ejemplo n.º 5
0
        public void Render(ISpriteBatch spriteBatch, V2 cameraPosition)
        {
            spriteBatch.Begin();

            for (int i = 0; i < positionedWorldCells.Length; i++)
            {
                if (positionedWorldCells[i] == null)
                {
                    continue;
                }

                for (int j = 0; j < positionedWorldCells[i].Count; j++)
                {
                    var cell = positionedWorldCells[i][j];

                    if (cell.Tile == null)
                    {
                        continue;
                    }

                    spriteBatch.Draw(cell.Tile.Texture,
                                     new Rect(0, 0, TileWidth, TileHeight),
                                     new Rect((int)cell.Position.X, (int)cell.Position.Y, TileWidth, TileHeight),
                                     0f,
                                     baseDepth - ((i * 100) + j) * HeightRowDepthMod);

                    spriteBatch.DrawString(SysCore.SystemFont, cell.Position.X + ", " + cell.Position.Y, new V2(cell.Position.X, cell.Position.Y), new V4(255), 0f, 1f, 1f);
                }
            }

            spriteBatch.End();
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Draws the InfoBox.
        /// </summary>
        /// <param name="sb"><see cref="ISpriteBatch"/> to draw with.</param>
        public void Draw(ISpriteBatch sb)
        {
            ThreadAsserts.IsMainThread();

            // Remove dead items
            while (_items.Count > 0 && _items[0].CreatedTime + _messageLife < TickCount.Now)
            {
                _items.RemoveAt(0);
            }

            // Loop through all items
            var i = 0;

            foreach (var item in _items)
            {
                // Set the position
                var pos = _position;
                pos.Y -= _font.GetLineSpacing() * (i++ + 1);
                pos.X -= item.Width;

                // Set the color
                var lifeLeft = (item.CreatedTime + _messageLife) - TickCount.Now;
                var alpha    = (byte)Math.Min(255, lifeLeft);
                var color    = new Color(item.Color.R, item.Color.G, item.Color.B, alpha);

                // Draw
                sb.DrawString(_font, item.Message, pos, color);
            }
        }
Ejemplo n.º 7
0
        private void DrawName(ISpriteBatch spriteBatch)
        {
            Vector2 measure = Font.MeasureString(Score.Name);
            Vector2 origin  = new Vector2(0, measure.Y * 0.5f);

            spriteBatch.DrawString(Font, Score.Name, NamePosition.WorldPosition, Color.White, WorldRotation, origin, WorldScale, SpriteEffects.None, 0);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Draws the text to display for the <see cref="TextBox"/>.
        /// </summary>
        /// <param name="spriteBatch">The <see cref="ISpriteBatch"/> to draw to.</param>
        /// <param name="offset">The offset to draw the text at.</param>
        protected override void DrawControlText(ISpriteBatch spriteBatch, Vector2 offset)
        {
            var numChars = NumCharsToDraw - LineCharBufferOffset;

            if (numChars > 0)
            {
                spriteBatch.DrawString(Font, new string(MaskChar, numChars), offset, ForeColor);
            }
        }
Ejemplo n.º 9
0
        public virtual void Draw(ISpriteBatch spriteBatch)
        {
            string scoreString = DisplayScore.ToString();

            Vector2 measure = Font.MeasureString(scoreString);
            Vector2 origin = new Vector2(measure.X, measure.Y * 0.5f);

            spriteBatch.DrawString(Font, scoreString, ScorePosition.WorldPosition, Color.White, WorldRotation, origin, WorldScale, SpriteEffects.None, 0);
        }
Ejemplo n.º 10
0
        private void DrawScore(ISpriteBatch spriteBatch)
        {
            string scoreString = Score.Amount.ToString();

            Vector2 measure = Font.MeasureString(scoreString);
            Vector2 origin  = new Vector2(measure.X, measure.Y * 0.5f);

            spriteBatch.DrawString(Font, scoreString, ScorePosition.WorldPosition, Color.White, WorldRotation, origin, WorldScale, SpriteEffects.None, 0);
        }
Ejemplo n.º 11
0
        public void Draw(ISpriteBatch spriteBatch, Vector offset)
        {
            var solidColorBrush = this.brush as SolidColorBrush;

            spriteBatch.DrawString(
                this.spriteFont,
                this.text,
                this.position + offset,
                solidColorBrush != null ? solidColorBrush.Color : Colors.Magenta);
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Draws the text for the control.
        /// </summary>
        /// <param name="spriteBatch"><see cref="ISpriteBatch"/> to draw to.</param>
        /// <param name="position">Position relative to the Control to draw the text.</param>
        protected virtual void DrawText(ISpriteBatch spriteBatch, Vector2 position)
        {
            // Ensure the font is valid
            if (string.IsNullOrEmpty(Text) || Font == null || Font.IsDisposed)
            {
                return;
            }

            // Draw the text
            spriteBatch.DrawString(Font, Text, ScreenPosition + position, ForeColor);
        }
Ejemplo n.º 13
0
        public virtual void Draw(ISpriteBatch spriteBatch)
        {
            Color color = Value > 0 ? Color.LightGreen : Color.Red;

            color *= NumberPosition.Opacity;

            Vector2 measure = Font.MeasureString(ValueString);
            Vector2 origin  = new Vector2(measure.X, measure.Y) * 0.5f;

            spriteBatch.DrawString(Font, ValueString, NumberPosition.WorldPosition, color, NumberPosition.WorldRotation, origin, NumberPosition.WorldScale, SpriteEffects.None, 0);
        }
Ejemplo n.º 14
0
 public override void Draw(ISpriteBatch spriteBatch, GameTime gameTime)
 {
     spriteBatch.DrawString(_font, "Score: " + score, new Vector2(100, 100), Color.Black);
 }
Ejemplo n.º 15
0
        /// <summary>
        /// Draws the <see cref="StyledText"/> to the <paramref name="spriteBatch"/>.
        /// </summary>
        /// <param name="spriteBatch"><see cref="ISpriteBatch"/> to draw the <see cref="StyledText"/> to.</param>
        /// <param name="font"><see cref="Font"/> to use for drawing the characters.</param>
        /// <param name="position">Top-left corner of where to begin drawing the <see cref="StyledText"/>.</param>
        /// <param name="defaultColor">The default color to use for drawing the text. Only used if the
        /// <see cref="Color"/> is equal to <see cref="ColorForDefault"/>.</param>
        public void Draw(ISpriteBatch spriteBatch, Font font, Vector2 position, Color defaultColor)
        {
            var colorToUse = (Color == ColorForDefault ? defaultColor : Color);

            spriteBatch.DrawString(font, Text, position, colorToUse);
        }
Ejemplo n.º 16
0
 /// <summary>
 /// Draws the <see cref="DamageText"/>.
 /// </summary>
 /// <param name="sb"><see cref="ISpriteBatch"/> to draw to.</param>
 /// <param name="font"><see cref="Font"/> to draw with.</param>
 public void Draw(ISpriteBatch sb, Font font)
 {
     sb.DrawString(font, _text, _pos, new Color(255, 255, 255, (byte)_alpha));
 }
Ejemplo n.º 17
0
        public void Render(ISpriteBatch spriteBatch, V2 cameraPosition)
        {
            spriteBatch.Begin();

            for (int i = 0; i < positionedWorldCells.Length; i++)
            {
                if (positionedWorldCells[i] == null)
                    continue;

                for (int j = 0; j < positionedWorldCells[i].Count; j++)
                {
                    var cell = positionedWorldCells[i][j];

                    if (cell.Tile == null)
                        continue;

                    spriteBatch.Draw(cell.Tile.Texture,
                        new Rect(0, 0, TileWidth, TileHeight),
                        new Rect((int)cell.Position.X, (int)cell.Position.Y, TileWidth, TileHeight),
                        0f,
                        baseDepth - ((i * 100) + j) * HeightRowDepthMod);

                    spriteBatch.DrawString(SysCore.SystemFont, cell.Position.X + ", " + cell.Position.Y, new V2(cell.Position.X, cell.Position.Y), new V4(255), 0f, 1f, 1f);

                }
            }

            spriteBatch.End();
        }
Ejemplo n.º 18
0
        private void DrawName(ISpriteBatch spriteBatch)
        {
            Vector2 measure = Font.MeasureString(Score.Name);
            Vector2 origin = new Vector2(0, measure.Y * 0.5f);

            spriteBatch.DrawString(Font, Score.Name, NamePosition.WorldPosition, Color.White, WorldRotation, origin, WorldScale, SpriteEffects.None, 0);
        }
Ejemplo n.º 19
0
        /// <summary>
        /// Draws the text for the control.
        /// </summary>
        /// <param name="spriteBatch"><see cref="ISpriteBatch"/> to draw to.</param>
        /// <param name="position">Position relative to the Control to draw the text.</param>
        protected virtual void DrawText(ISpriteBatch spriteBatch, Vector2 position)
        {
            // Ensure the font is valid
            if (string.IsNullOrEmpty(Text) || Font == null || Font.IsDisposed)
                return;

            // Draw the text
            spriteBatch.DrawString(Font, Text, ScreenPosition + position, ForeColor);
        }
Ejemplo n.º 20
0
        /// <summary>
        /// Draws the InfoBox.
        /// </summary>
        /// <param name="sb"><see cref="ISpriteBatch"/> to draw with.</param>
        public void Draw(ISpriteBatch sb)
        {
            ThreadAsserts.IsMainThread();

            // Remove dead items
            while (_items.Count > 0 && _items[0].CreatedTime + _messageLife < TickCount.Now)
            {
                _items.RemoveAt(0);
            }

            // Loop through all items
            var i = 0;
            foreach (var item in _items)
            {
                // Set the position
                var pos = _position;
                pos.Y -= _font.GetLineSpacing() * (i++ + 1);
                pos.X -= item.Width;

                // Set the color
                var lifeLeft = (item.CreatedTime + _messageLife) - TickCount.Now;
                var alpha = (byte)Math.Min(255, lifeLeft);
                var color = new Color(item.Color.R, item.Color.G, item.Color.B, alpha);

                // Draw
                sb.DrawString(_font, item.Message, pos, color);
                
            }
        }
Ejemplo n.º 21
0
 /// <summary>
 /// Draws the text to display for the <see cref="TextBox"/>.
 /// </summary>
 /// <param name="spriteBatch">The <see cref="ISpriteBatch"/> to draw to.</param>
 /// <param name="offset">The offset to draw the text at.</param>
 protected override void DrawControlText(ISpriteBatch spriteBatch, Vector2 offset)
 {
     var numChars = NumCharsToDraw - LineCharBufferOffset;
     if (numChars > 0)
         spriteBatch.DrawString(Font, new string(MaskChar, numChars), offset, ForeColor);
 }
Ejemplo n.º 22
0
 private void Render(TextSprite toRender)
 {
     _spriteBatch.DrawString(toRender.SpriteFont, toRender.Text, toRender.Position, toRender.Color);
 }
Ejemplo n.º 23
0
        /// <summary>
        /// Draws the <see cref="StyledText"/> to the <paramref name="spriteBatch"/>.
        /// </summary>
        /// <param name="spriteBatch"><see cref="ISpriteBatch"/> to draw the <see cref="StyledText"/> to.</param>
        /// <param name="font"><see cref="Font"/> to use for drawing the characters.</param>
        /// <param name="position">Top-left corner of where to begin drawing the <see cref="StyledText"/>.</param>
        /// <param name="defaultColor">The default color to use for drawing the text. Only used if the
        /// <see cref="Color"/> is equal to <see cref="ColorForDefault"/>.</param>
        public void Draw(ISpriteBatch spriteBatch, Font font, Vector2 position, Color defaultColor)
        {
            var colorToUse = (Color == ColorForDefault ? defaultColor : Color);

            spriteBatch.DrawString(font, Text, position, colorToUse);
        }
Ejemplo n.º 24
0
        protected override void DoRender(
            Moment now,
            GraphicsDevice graphicsDevice, 
            ISpriteBatch spriteBatch,
            TextureContent content,
            HolofunkView view,
            Transform parentTransform, 
            int depth)
        {
            Transform combinedTransform = parentTransform.CombineWith(LocalTransform);

            spriteBatch.Begin();

            Vector2 textSize = content.SpriteFont.MeasureString(m_text);
            Vector2 origin = Vector2.Zero;

            if (Alignment == Alignment.Centered) {
                origin = textSize / 2;
            }
            else if (Alignment == Alignment.TopRight) {
                origin = new Vector2(textSize.X, 0);
            }

            spriteBatch.DrawString(
                content.SpriteFont,
                m_text,
                combinedTransform.Translation,
                Color,
                Rotation,
                origin,
                combinedTransform.Scale.X,
                SpriteEffects.None,
                0);

            spriteBatch.End();
        }
Ejemplo n.º 25
0
 /// <summary>
 /// Draws the <see cref="DamageText"/>.
 /// </summary>
 /// <param name="sb"><see cref="ISpriteBatch"/> to draw to.</param>
 /// <param name="font"><see cref="Font"/> to draw with.</param>
 public void Draw(ISpriteBatch sb, Font font)
 {
     sb.DrawString(font, _text, _pos, new Color(255, 255, 255, (byte)_alpha));
 }
Ejemplo n.º 26
0
 public void Draw(ISpriteBatch batch)
 {
     if (needsUpdate)
         Update();
     batch.DrawString(font, Text, position, Color.Black, 0, Vector2.Zero, scale, SpriteEffects.None, 0);
 }