public TextBlock(Screen screen, Vector2 position, string text) : base(screen) { Text = text; Color = Color.Black; font = screen.Manager.Game.Content.Load<SpriteFont>("Fonts/Hud"); Bound = new Rectangle((int)position.X, (int)position.Y, (int)font.MeasureString(Text).X + 10, 20); }
public BannerSign(VisionContent vContent, IEnumerable<CodeIsland> islands) : base(vContent.LoadEffect("effects/signtexteffect")) { _spriteBatch = new SpriteBatch(Effect.GraphicsDevice); _spriteFont = vContent.Load<SpriteFont>("fonts/BlackCastle"); _tpds = islands.Select(_ => new TextAndPosAndDistance { Text = _.VAssembly.Name, Pos = new Vector3(_.World.M41 + (float) _.GroundExtentX/2, HeightAboveOcean, _.World.M43 + (float) _.GroundExtentZ/2) }).ToList(); foreach (var tpd in _tpds) { var sz = _spriteFont.MeasureString(tpd.Text)/4*TextSize; var extent = new Vector3(sz.X, sz.Y, sz.X); tpd.BoundingBox = new BoundingBox(tpd.Pos - extent, tpd.Pos + extent); } }
//////////////////////////////////////////////////////////////////////////// protected internal void CalcRect(Rectangle prev, SpriteFont font, Margins margins, Point offset, bool first) { int size = (int)Math.Ceiling(font.MeasureString(Text).X) + margins.Horizontal; if (first) offset.X = 0; headerRect = new Rectangle(prev.Right + offset.X, prev.Top, size, prev.Height); }