protected override void BeforeRender(RendererParameters parameters) { parameters.ThrowIfNull("parameters"); base.BeforeRender(parameters); WindowTexture windowWindowTexture = parameters.TextureContent.Windows.InnerBevel1; if (!_windowRectangleSet) { var messageWithBackgroundColor = _state.Message as IMessageWithBackgroundColor; if (messageWithBackgroundColor != null) { BackgroundColor = messageWithBackgroundColor.BackgroundColor.ToXnaColor(); } WindowTexture selectedAnswerWindowTexture = parameters.TextureContent.Windows.Glow1; SpriteFont font = parameters.FontContent.Calibri12Pt; Rectangle destinationRectangle = Constants.GameWindow.DestinationRectangle; float maximumLineWidth = destinationRectangle.Width * TextAdventure.Xna.Constants.MessageRenderer.MaximumLineWidthAsPercentageOfGameWindowDestinationRectangle; float maximumClientHeight = destinationRectangle.Height - (destinationRectangle.Center.Y + TextAdventure.Xna.Constants.MessageRenderer.VerticalOffsetFromGameWindowDestinationRectangleCenter) - (TextAdventure.Xna.Constants.MessageRenderer.VerticalWindowPadding * 2) - (windowWindowTexture.SpriteHeight * 2); _formatter = new MessageFormatter(_state.Message, font, selectedAnswerWindowTexture, maximumLineWidth); if (_formatter.Answers.Any()) { _answerSelectionManager = new MessageAnswerSelectionManager(_formatter.Answers); } int clientWidth = _formatter.MaximumLineWidthAfterFormatting.Round(); int clientHeight = Math.Min(maximumClientHeight, _formatter.TotalHeightAfterFormatting).Round(); if (clientHeight < _formatter.TotalHeightAfterFormatting) { clientWidth += TextAdventure.Xna.Constants.MessageRenderer.ArrowHorizontalPadding + windowWindowTexture.SpriteWidth; } SetWindowRectangleUsingWindowYAndClientSize( WindowHorizontalAlignment.Center, destinationRectangle.Center.Y + TextAdventure.Xna.Constants.Tile.TileHeight * 2, clientWidth, clientHeight, windowWindowTexture.Padding); _windowRectangleSet = true; //_textTexture = new Texture2D(_state.GraphicsDevice, clientWidth, clientHeight); _state.AnswerSelectionManager = _answerSelectionManager; _state.MaximumScrollPosition = _formatter.TotalHeightAfterFormatting - clientHeight; _state.VisibleHeight = clientHeight; } Alpha = _state.Alpha; _transformMatrix = Matrix.CreateTranslation(new Vector3(-Window.WindowRectangle.Center.ToVector2(), 0f)) * Matrix.CreateScale(_state.Scale, _state.Scale, 1f) * Matrix.CreateTranslation(new Vector3(Window.WindowRectangle.Center.ToVector2(), 0f)); }