Exemplo n.º 1
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 *= text.Scale;
                MyGuiTextShadows.DrawShadow(ref normalizedCoord, ref textSize, null, text.Color.A / 255f, text.Alignement);
                MyGuiManager.DrawString(font, text.GetStringBuilder(), normalizedCoord, text.Scale, colorMask: text.Color, drawAlign: text.Alignement);
            }

            m_texts.ClearAllAllocated();
        }
Exemplo n.º 2
0
        private void DrawFog()
        {
            Vector2 notificationPosition = Position;

            for (int i = 0; i < m_textSizes.Count; i++)
            {
                var textSize = m_textSizes[i];
                MyGuiTextShadows.DrawShadow(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);

                MyGuiTextShadows.DrawShadow(ref center, ref size);

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