Пример #1
0
        public TextEntityView(IEntity entity, IFontScaler fontScaler, SpriteBatch spriteBatch, FontBank fontBank)
            : base(entity)
        {
            _fontScaler  = fontScaler ?? throw new ArgumentNullException();
            _spriteBatch = spriteBatch ?? throw new ArgumentNullException();
            _fontBank    = fontBank ?? throw new ArgumentNullException();

            _textEntity = this.GetEntityAs <ITextEntity>();
            _font       = _fontBank.GetFont(_textEntity.FontName, _textEntity.FontSize);

            _cachedFont = _font;
        }
Пример #2
0
        protected override void LoadContent()
        {
            _spriteBatch = new SpriteBatch(GraphicsDevice);

            FontBank fontBank = new FontBank();

            fontBank.Load(this.Content, "Fonts");

            IFontScaler fontScaler = new SimpleFontScaler(fontBank);

            var textEntity = new TextEntity()
            {
                Colour    = Color.Cyan,
                Text      = "This is a test.",
                Bounds    = new RectangleF(100, 100, 100, 25),
                FontName  = "Calibri",
                FontSize  = 20,
                Behaviour = TextEntityBehaviour.AutoScale,
            };

            var textEntityView = new TextEntityView(
                textEntity,
                fontScaler,
                _spriteBatch,
                fontBank
                );

            var textEntityEditorView = new EditorView(
                textEntityView,
                _spriteBatch
                );

            _views.Add(textEntityEditorView);
            _controllers.Add(new EditorViewController(textEntityEditorView));
            _controllers.Add(new TextEntityViewController(textEntityView, _graphics.GraphicsDevice, _spriteBatch));
        }