示例#1
0
 public NotesRenderer(Sprite noteSprite, ITextRenderer textRenderer, int statusBarHeight)
 {
     this.noteSprite      = noteSprite;
     this.textRenderer    = textRenderer;
     this.statusBarHeight = statusBarHeight;
     lineHeight           = textRenderer.RenderText("M", new SDL.SDL_Color()).Height + 5;
 }
示例#2
0
文件: Scene.cs 项目: ejrich/Pretend
        private void RenderText(TextComponent textComponent, IEntity entity)
        {
            if (string.IsNullOrWhiteSpace(textComponent.Text) || string.IsNullOrWhiteSpace(textComponent.Font) || textComponent.Size == 0)
            {
                return;
            }

            var textObject = new RenderableTextObject
            {
                Text        = textComponent.Text,
                FontPath    = textComponent.Font,
                Size        = textComponent.Size,
                Alignment   = textComponent.Alignment,
                Position    = textComponent.RelativePosition,
                Orientation = textComponent.Orientation,
                Color       = textComponent.Color
            };

            var position = entity.GetComponent <PositionComponent>();

            if (position != null)
            {
                textObject.Position += position.Position;
            }

            _textRenderer.RenderText(textObject);
        }
示例#3
0
        public void Render(IScreen screen, Scene scene)
        {
            if (scene.Player.CurrentMonologue == null || scene.Player.CurrentMonologue.IsOver)
            {
                return;
            }

            var lines = scene.Player.CurrentMonologue.CurrentText
                        .Split(new[] { "\n", "\r" }, StringSplitOptions.RemoveEmptyEntries)
                        .Select(l => textRenderer.RenderText(l, new SDL.SDL_Color {
                r = 255, g = 255, b = 255
            }))
                        .ToArray();

            var startY = screen.Height - statusBarHeight - lines.Sum(k => lineHeight);
            var minY   = startY;
            var maxY   = startY + lines.Sum(k => lineHeight);
            var minX   = lines.Min(line => screen.Width / 2 - line.Width / 2);
            var maxX   = lines.Max(line => screen.Width / 2 + line.Width / 2);

            for (var y = minY; y < maxY; y++)
            {
                for (var x = minX; x < maxX; x++)
                {
                    screen.Draw(y, x, 0, 0, 0);
                }
            }

            foreach (var(line, i) in lines.Select((l, i) => (l, i)))
            {
                screen.DrawSprite(line, startY + lineHeight * i, screen.Width / 2 - line.Width / 2);
            }
        }
示例#4
0
        private void DrawArrowsCount(IScreen screen, Scene scene, ITextRenderer textRenderer)
        {
            var arrowsCountY          = screen.Height - statusBarHeight + 30;
            var arrowsCountX          = 1000;
            var currentAmountOfArrows = scene.Player.CurrentAmountOfArrows;
            var maxAmountOfArrows     = scene.Player.MaxAmountOfArrows;

            textRenderer.RenderText($"{currentAmountOfArrows} / {maxAmountOfArrows}", new SDL.SDL_Color(), screen, arrowsCountY,
                                    arrowsCountX);
        }
示例#5
0
 public TextViewerVM(IDataSource data)
 {
     rootNode            = data.SelectedNode;
     CurrentLength       = defaultLength.ToString(CultureInfo.InvariantCulture);
     SaveCommand         = new RelayCommand(saveFile);
     PrintCommand        = new RelayCommand(print);
     ApplyCommand        = new RelayCommand(applyNewLength);
     TextBoxWidth        = Tools.MeasureString(master, Settings.Default.FontSize, false);
     CertutilViewChecked = true;
     renderer.RenderText(currentLength);
 }
示例#6
0
        public void Render(IScreen screen, Scene scene)
        {
            if (scene.Player.State != Player.PlayerState.TextReading)
            {
                return;
            }

            var visiblePartHeight = screen.Height - statusBarHeight;
            var height            = visiblePartHeight;
            var width             = (int)(height / noteSprite.AspectRatio);
            var startY            = (visiblePartHeight - height) / 2;
            var startX            = (screen.Width - width) / 2;
            var sampleYStep       = 1.0f / height;
            var sampleXStep       = 1.0f / width;
            var endY    = startY + height;
            var endX    = startX + width;
            var sampleY = 0.0f;

            for (var y = startY; y < endY; y++)
            {
                var sampleX = 0.0f;
                for (var x = startX; x < endX; x++)
                {
                    var pixel = noteSprite.GetSample(sampleY, sampleX);
                    if (!pixel.IsTransparentColor())
                    {
                        screen.Draw(y, x, pixel);
                    }
                    sampleX += sampleXStep;
                }

                sampleY += sampleYStep;
            }

            var noteStartY = (int)(startY + screen.Height / 10);
            var noteStartX = (int)(startX * 1.2f);
            var currentY   = noteStartY;
            var black      = new SDL.SDL_Color()
            {
                a = 0, b = 0, g = 0, r = 0
            };

            foreach (var line in scene.Player.LastNoteText
                     .Split(new[] { "\n", "\r" }, StringSplitOptions.RemoveEmptyEntries))
            {
                textRenderer.RenderText(line, black, screen, currentY, noteStartX);
                currentY += lineHeight;
            }
        }
示例#7
0
        private void RenderLog(IScreen screen, Scene scene)
        {
            var currentY = 0;

            foreach (var msg in scene.EventsLogger.GetMessages())
            {
                var textSprite = logTextRenderer.RenderText(msg,
                                                            new SDL.SDL_Color {
                    a = 0, b = 255, g = 255, r = 255
                });

                screen.DrawSprite(textSprite, currentY, 0);

                currentY += textSprite.Height;
            }
        }
示例#8
0
        public void RenderText_WhenFieldsNotProvided_Returns()
        {
            _target.RenderText(new RenderableTextObject());

            _mockRenderer.Verify(_ => _.Submit(It.IsAny <Renderable2DObject>()), Times.Never);
        }
示例#9
0
 public MonologueRenderer(ITextRenderer textRenderer, int statusBarHeight)
 {
     this.textRenderer    = textRenderer;
     this.statusBarHeight = statusBarHeight;
     lineHeight           = textRenderer.RenderText("M", new SDL.SDL_Color()).Height + 5;
 }