示例#1
0
            public void Draw()
            {
                ClearTexts();
                int visibleCount = Math.Min(m_notifications.Count, MyNotificationConstants.MAX_DISPLAYED_NOTIFICATIONS_COUNT);

                for (int i = 0; i < visibleCount; i++)
                {
                    MyNotification actualNotification   = m_notifications[i];
                    StringBuilder  messageStringBuilder = m_textsPool.Allocate();
                    Debug.Assert(actualNotification != null);
                    Debug.Assert(messageStringBuilder != null);

                    bool hasConfirmation = actualNotification.HasDefaultDisappearMessage();

                    messageStringBuilder.Append(actualNotification.GetText());

                    if (hasConfirmation)
                    {
                        messageStringBuilder.AppendLine();
                        messageStringBuilder.ConcatFormat(m_defaultNotificationDisapearMessage, MyGuiManager.GetInput().GetGameControlTextEnum(MyGameControlEnums.NOTIFICATION_CONFIRMATION));
                    }

                    // draw background:
                    Vector2 textSize = MyGuiManager.GetNormalizedSize(m_usedFont, messageStringBuilder, actualNotification.GetScale());

                    m_textSizes.Add(textSize);
                    m_texts.Add(messageStringBuilder);
                }

                MyGuiManager.BeginSpriteBatch();
                var offset = new Vector2(VideoMode.MyVideoModeManager.IsTripleHead() ? -1 : 0, 0);


                // Draw fog
                Vector2 notificationPosition = Position;

                for (int i = 0; i < visibleCount; i++)
                {
                    Vector2 fogFadeSize = m_textSizes[i] * new Vector2(1.6f, 8.0f);

                    MyGuiManager.DrawSpriteBatch(MyGuiManager.GetFogSmallTexture(), notificationPosition + offset, fogFadeSize,
                                                 m_fogColor,
                                                 MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, MyVideoModeManager.IsTripleHead());

                    notificationPosition.Y += m_textSizes[i].Y;
                }

                // Draw texts
                notificationPosition = Position;
                for (int i = 0; i < visibleCount; i++)
                {
                    MyNotification actualNotification = m_notifications[i];

                    MyGuiManager.DrawString(actualNotification.GetFont(), m_texts[i], notificationPosition + offset,
                                            actualNotification.GetScale(), Color.White,
                                            MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, MyVideoModeManager.IsTripleHead());
                    notificationPosition.Y += m_textSizes[i].Y;
                }
                MyGuiManager.EndSpriteBatch();
            }