コード例 #1
0
        protected void SetWindowRectangleUsingWindowXAndWindowSize(WindowVerticalAlignment alignment, int windowX, int windowWidth, int windowHeight, Padding padding)
        {
            Rectangle windowDestinationRectangle = Constants.GameWindow.DestinationRectangle;
            Point windowCenterPoint = windowDestinationRectangle.Center;
            Rectangle windowRectangle;

            switch (alignment)
            {
                case WindowVerticalAlignment.Top:
                    windowRectangle = new Rectangle(windowX, 0, windowWidth, windowHeight);
                    break;
                case WindowVerticalAlignment.Center:
                    windowRectangle = new Rectangle(windowX, windowCenterPoint.Y - (windowHeight / 2), windowWidth, windowHeight);
                    break;
                case WindowVerticalAlignment.Bottom:
                    windowRectangle = new Rectangle(windowX, windowDestinationRectangle.Bottom - windowHeight, windowWidth, windowHeight);
                    break;
                default:
                    throw new ArgumentOutOfRangeException("alignment");
            }

            Window = new BorderedWindow(windowRectangle, padding);
        }
コード例 #2
0
        protected void SetWindowRectangleUsingWindowYAndWindowSize(WindowHorizontalAlignment alignment, int windowY, int windowWidth, int windowHeight, Padding padding)
        {
            Rectangle windowDestinationRectangle = Constants.GameWindow.DestinationRectangle;
            Point windowCenterPoint = windowDestinationRectangle.Center;
            Rectangle windowRectangle;

            switch (alignment)
            {
                case WindowHorizontalAlignment.Left:
                    windowRectangle = new Rectangle(0, windowY, windowWidth, windowHeight);
                    break;
                case WindowHorizontalAlignment.Center:
                    windowRectangle = new Rectangle(windowCenterPoint.X - (windowWidth / 2), windowY, windowWidth, windowHeight);
                    break;
                case WindowHorizontalAlignment.Right:
                    windowRectangle = new Rectangle(windowDestinationRectangle.Right - windowWidth, windowY, windowWidth, windowHeight);
                    break;
                default:
                    throw new ArgumentOutOfRangeException("alignment");
            }

            Window = new BorderedWindow(windowRectangle, padding);
        }
コード例 #3
0
 protected void SetWindowRectangleUsingClientLocationAndClientSize(int clientX, int clientY, int clientWidth, int clientHeight, Padding padding)
 {
     Window = new BorderedWindow(new Rectangle(clientX - padding.Left, clientY - padding.Top, clientWidth + padding.X, clientHeight + padding.Y), padding);
 }
コード例 #4
0
 protected void SetWindowRectangleUsingWindowLocationAndClientSize(int windowX, int windowY, int clientWidth, int clientHeight, Padding padding)
 {
     Window = new BorderedWindow(new Rectangle(windowX, windowY, clientWidth + padding.X, clientHeight + padding.Y), padding);
 }
コード例 #5
0
 public BorderedWindowRenderer()
 {
     BorderColor = Color.Transparent;
     Window = new BorderedWindow(Rectangle.Empty, Padding.None);
 }
コード例 #6
0
        protected void SetWindowRectangle(WindowAlignment alignment, int windowWidth, int windowHeight, Padding padding)
        {
            Rectangle windowDestinationRectangle = Constants.GameWindow.DestinationRectangle;
            Point windowCenterPoint = windowDestinationRectangle.Center;
            Rectangle rectangle;

            switch (alignment)
            {
                case WindowAlignment.TopLeft:
                    rectangle = new Rectangle(0, 0, windowWidth, windowHeight);
                    break;
                case WindowAlignment.TopCenter:
                    rectangle = new Rectangle(windowCenterPoint.X - (windowWidth / 2), 0, windowWidth, windowHeight);
                    break;
                case WindowAlignment.TopRight:
                    rectangle = new Rectangle(windowDestinationRectangle.Right - windowWidth, 0, windowWidth, windowHeight);
                    break;
                case WindowAlignment.RightCenter:
                    rectangle = new Rectangle(windowDestinationRectangle.Right - windowWidth, windowCenterPoint.Y - (windowHeight / 2), windowWidth, windowHeight);
                    break;
                case WindowAlignment.BottomRight:
                    rectangle = new Rectangle(windowDestinationRectangle.Right - windowWidth, windowDestinationRectangle.Bottom - windowHeight, windowWidth, windowHeight);
                    break;
                case WindowAlignment.BottomCenter:
                    rectangle = new Rectangle(windowCenterPoint.X - (windowWidth / 2), windowDestinationRectangle.Bottom - windowHeight, windowWidth, windowHeight);
                    break;
                case WindowAlignment.BottomLeft:
                    rectangle = new Rectangle(0, windowDestinationRectangle.Bottom - windowHeight, windowWidth, windowHeight);
                    break;
                case WindowAlignment.LeftCenter:
                    rectangle = new Rectangle(0, windowCenterPoint.Y - (windowHeight / 2), windowWidth, windowHeight);
                    break;
                case WindowAlignment.Center:
                    rectangle = new Rectangle(windowCenterPoint.X - (windowWidth / 2), windowCenterPoint.Y - (windowHeight / 2), windowWidth, windowHeight);
                    break;
                default:
                    throw new ArgumentOutOfRangeException("alignment");
            }

            Window = new BorderedWindow(rectangle, padding);
        }
コード例 #7
0
 protected void SetWindowRectangle(int x, int y, int width, int height, Padding padding)
 {
     Window = new BorderedWindow(new Rectangle(x, y, width, height), padding);
 }
コード例 #8
0
 protected void SetWindowRectangle(Rectangle windowRectangle, Padding padding)
 {
     Window = new BorderedWindow(windowRectangle, padding);
 }
コード例 #9
0
        private void RenderAnswers(
            RendererParameters parameters,
            WindowTexture selectedAnswerWindowTexture,
            SpriteFont font,
            Matrix transformMatrix,
            IEnumerable<MessageTextAnswer> answers,
            Color shadowColor,
            Vector2 position)
        {
            answers = answers.ToArray();

            int answerCount = answers.Count();
            int totalAnswerPadding = ((answerCount - 1) * TextAdventure.Xna.Constants.MessageRenderer.AnswerHorizontalPadding);
            float lineWidth = answers.Sum(arg => arg.Size.X + (selectedAnswerWindowTexture.SpriteWidth * 2) + (TextAdventure.Xna.Constants.MessageRenderer.AnswerHorizontalTextPadding * 2)) + totalAnswerPadding;
            float lineHeight = answers.Max(arg => arg.Size.Y);

            position.X += (Window.AbsoluteClientRectangle.Width - lineWidth) / 2;

            foreach (MessageTextAnswer answer in answers)
            {
                var window = new BorderedWindow(
                    new Rectangle(
                        position.X.Round(),
                        position.Y.Round(),
                        (answer.Size.X + (selectedAnswerWindowTexture.SpriteWidth * 2) + (TextAdventure.Xna.Constants.MessageRenderer.AnswerHorizontalTextPadding * 2)).Round(),
                        (lineHeight + (selectedAnswerWindowTexture.SpriteHeight * 2)).Round()),
                    selectedAnswerWindowTexture.Padding);

                if (answer.Answer == _answerSelectionManager.SelectedAnswer)
                {
                    _messageAnswerRenderer.Update(
                        window.WindowRectangle,
                        selectedAnswerWindowTexture.Padding,
                        answer.SelectedAnswerBackgroundColor.ToXnaColor(),
                        Alpha,
                        Window.AbsoluteClientRectangle,
                        transformMatrix);
                    _messageAnswerRenderer.Render(parameters);
                }

                var textPosition = new Vector2(
                    window.AbsoluteClientRectangle.X + ((window.AbsoluteClientRectangle.Width - answer.Size.X) / 2),
                    window.AbsoluteClientRectangle.Y + ((window.AbsoluteClientRectangle.Height - lineHeight) / 2));
                Color textColor = answer.Answer == _answerSelectionManager.SelectedAnswer ? answer.SelectedAnswerForegroundColor.ToXnaColor() : answer.UnselectedAnswerForegroundColor.ToXnaColor();

                parameters.SpriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.None, new ScissoringRasterizerState(), null, transformMatrix);

                parameters.SpriteBatch.DrawStringWithShadow(
                    font,
                    answer.Text,
                    textPosition.Round(),
                    textColor * Alpha,
                    shadowColor,
                    Vector2.One);

                parameters.SpriteBatch.End();

                position.X += window.WindowRectangle.Width + TextAdventure.Xna.Constants.MessageRenderer.AnswerHorizontalPadding;
            }
        }