public void DrawTexts()
        {
            if (m_texts.GetAllocatedCount() <= 0)
            {
                return;
            }

            for (int i = 0; i < m_texts.GetAllocatedCount(); i++)
            {
                MyHudText text = m_texts.GetAllocatedItem(i);

                var font = text.Font;
                text.Position /= MyGuiManager.GetHudSize();
                var normalizedCoord = ConvertHudToNormalizedGuiPosition(ref text.Position);

                Vector2 textSize = MyGuiManager.MeasureString(font, text.GetStringBuilder(), MyGuiSandbox.GetDefaultTextScaleWithLanguage());
                textSize.X *= 0.9f;
                textSize.Y *= 0.7f;
                MyGuiScreenHudBase.DrawFog(ref normalizedCoord, ref textSize);

                MyGuiManager.DrawString(font, text.GetStringBuilder(), normalizedCoord, text.Scale, colorMask: text.Color, drawAlign: MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER);
            }

            m_texts.ClearAllAllocated();
        }
Exemple #2
0
        public void DrawTexts()
        {
            if (m_texts.GetAllocatedCount() <= 0)
            {
                return;
            }

            for (int i = 0; i < m_texts.GetAllocatedCount(); i++)
            {
                MyHudText text = m_texts.GetAllocatedItem(i);
                if (text.GetStringBuilder().Length == 0)
                {
                    continue;
                }

                var font = text.Font;
                text.Position /= MyGuiManager.GetHudSize();
                var normalizedCoord = ConvertHudToNormalizedGuiPosition(ref text.Position);

                Vector2 textSize = MyGuiManager.MeasureString(font, text.GetStringBuilder(), MyGuiSandbox.GetDefaultTextScaleWithLanguage());
                textSize.X *= 0.9f;
                textSize.Y *= 0.7f;
                textSize   *= text.Scale;
                MyGuiScreenHudBase.DrawFog(ref normalizedCoord, ref textSize, text.Color.A / 255f, text.Alignement);

                MyGuiManager.DrawString(font, text.GetStringBuilder(), normalizedCoord, text.Scale, colorMask: text.Color, drawAlign: text.Alignement);
            }

            m_texts.ClearAllAllocated();
        }
Exemple #3
0
        private void DrawFog()
        {
            Vector2 notificationPosition = Position;

            for (int i = 0; i < m_textSizes.Count; i++)
            {
                var textSize = m_textSizes[i];
                MyGuiScreenHudBase.DrawFog(ref notificationPosition, ref textSize);
                notificationPosition.Y += textSize.Y;
            }
        }
        private void DrawBackgroundFog(Vector2 namesTopLeft, Vector2 valuesTopRight, bool topDown)
        {
            float lineOffset;
            int   startIdx, endIdx, step;

            if (topDown)
            {
                lineOffset = LineSpacing;
                startIdx   = 0;
                endIdx     = Count;
                step       = 1;
            }
            else
            {
                lineOffset = -LineSpacing;
                startIdx   = Count - 1;
                endIdx     = -1;
                step       = -1;
            }

            for (int i = startIdx; i != endIdx; i += step)
            {
                var item = m_items[i];
                if (!item.Visible)
                {
                    continue;
                }

                var center = new Vector2((namesTopLeft.X + valuesTopRight.X) * 0.5f,
                                         namesTopLeft.Y + 0.5f * lineOffset);
                var size = new Vector2(Math.Abs(namesTopLeft.X - valuesTopRight.X),
                                       LineSpacing);

                MyGuiScreenHudBase.DrawFog(ref center, ref size);

                namesTopLeft.Y   += lineOffset;
                valuesTopRight.Y += lineOffset;
            }
        }