Example #1
0
 public MyRichLabelText()
 {
     m_text  = new StringBuilder(512);
     m_font  = null;
     m_scale = 0;
     m_color = Vector4.Zero;
 }
 public MyNotification(String notificationText, MyGuiScreenGamePlayType LifeArea, float scale,
                       MyGuiFont font,
                       MyGuiDrawAlignEnum textAlign, int disapearTimeMs, MyEntity owner = null, bool showConfirmMessage = false,
                       object[] textFormatArguments = null)
     : this(0, notificationText, LifeArea, scale, font, textAlign, disapearTimeMs, owner, showConfirmMessage, textFormatArguments)
 {
 }
        public MyGuiControlMultilineText(
            IMyGuiControlsParent parent, Vector2 position,
            Vector2 size, Vector4? backgroundColor,
            MyGuiFont font, float textScale, MyGuiDrawAlignEnum textAlign, StringBuilder contents, bool drawBorders = true, bool drawScrollbar = true)
            : base(parent, position, size, backgroundColor, null)
        {
            m_font = font;
            m_textScale = textScale;
            m_textAlign = textAlign;
            m_drawBorders = drawBorders;
            m_drawScrollbar = drawScrollbar;
            TextColor = new Color(MyGuiConstants.LABEL_TEXT_COLOR);

            m_scrollbar = new MyVScrollbar(this);
            m_scrollbar.TopBorder = m_scrollbar.RightBorder = m_scrollbar.BottomBorder = false;
            m_scrollbar.LeftBorder = drawBorders;
            m_scrollbarSize = new Vector2(0.0334f, MyGuiConstants.COMBOBOX_VSCROLLBAR_SIZE.Y);
            m_scrollbarSize = MyGuiConstants.COMBOBOX_VSCROLLBAR_SIZE;
            float minLineHeight = MyGuiManager.MeasureString(m_font,
                                                      MyTextsWrapper.Get(MyTextsWrapperEnum.ServerShutdownNotificationCaption),
                                                      m_parent.GetPositionAbsolute() + m_position, m_textScale,
                                                      m_textAlign).Size.Y;
            m_label = new MyRichLabel(size.X, minLineHeight);
            if (contents != null && contents.Length > 0)
            {
                SetText(contents);
            }
        }                
Example #4
0
 public MyRichLabelText()
 {
     m_text = new StringBuilder(512);
     m_font = null;
     m_scale = 0;
     m_color = Vector4.Zero;
 }
Example #5
0
        public MyGuiControlMultilineText(
            IMyGuiControlsParent parent, Vector2 position,
            Vector2 size, Vector4?backgroundColor,
            MyGuiFont font, float textScale, MyGuiDrawAlignEnum textAlign, StringBuilder contents, bool drawBorders = true, bool drawScrollbar = true)
            : base(parent, position, size, backgroundColor, null)
        {
            m_font          = font;
            m_textScale     = textScale;
            m_textAlign     = textAlign;
            m_drawBorders   = drawBorders;
            m_drawScrollbar = drawScrollbar;
            TextColor       = new Color(MyGuiConstants.LABEL_TEXT_COLOR);

            m_scrollbar            = new MyVScrollbar(this);
            m_scrollbar.TopBorder  = m_scrollbar.RightBorder = m_scrollbar.BottomBorder = false;
            m_scrollbar.LeftBorder = drawBorders;
            m_scrollbarSize        = new Vector2(0.0334f, MyGuiConstants.COMBOBOX_VSCROLLBAR_SIZE.Y);
            m_scrollbarSize        = MyGuiConstants.COMBOBOX_VSCROLLBAR_SIZE;
            float minLineHeight = MyGuiManager.MeasureString(m_font,
                                                             MyTextsWrapper.Get(MyTextsWrapperEnum.ServerShutdownNotificationCaption),
                                                             m_parent.GetPositionAbsolute() + m_position, m_textScale,
                                                             m_textAlign).Size.Y;

            m_label = new MyRichLabel(size.X, minLineHeight);
            if (contents != null && contents.Length > 0)
            {
                SetText(contents);
            }
        }
            private MyNotification(int notificationTextId, string notificationString, MyGuiScreenGamePlayType LifeArea, float scale,
                                  MyGuiFont font,
                                  MyGuiDrawAlignEnum textAlign, int disapearTimeMs, MyEntity owner, bool showConfirmMessage = false,
                                  object[] textFormatArguments = null)
            {
                Owner = owner;
                m_originalText = notificationString;
                m_notificationText = notificationString;
                m_notificationTextID = (int)notificationTextId;
                m_isTextDirty = false;

                // always false:
                m_isDisappeared = false;

                m_actualScale = scale;                
                m_actualFont = font;
                m_actualTextAlign = textAlign;

                m_textFormatArguments = textFormatArguments;

                // timing:
                m_disappearTimeMs = disapearTimeMs;
                m_aliveTime = 0;

                // life space;
                m_lifeSpace = LifeArea;

                // show standart message?
                m_showConfirmMessage = showConfirmMessage;
            }
Example #7
0
 public MyRichLabelText(StringBuilder text, MyGuiFont font, float scale, Vector4 color)
 {
     m_text = text;
     m_font = font;
     m_scale = scale;
     m_color = color;
     RecalculateSize();
 }
Example #8
0
 public void Init(string text, MyGuiFont font, float scale, Vector4 color)
 {
     m_text.Append(text);
     m_font = font;
     m_scale = scale;
     m_color = color;
     RecalculateSize();
 }
Example #9
0
 public void Init(string text, MyGuiFont font, float scale, Vector4 color)
 {
     m_text.Append(text);
     m_font  = font;
     m_scale = scale;
     m_color = color;
     RecalculateSize();
 }
Example #10
0
 public MyRichLabelText(StringBuilder text, MyGuiFont font, float scale, Vector4 color)
 {
     m_text  = text;
     m_font  = font;
     m_scale = scale;
     m_color = color;
     RecalculateSize();
 }
Example #11
0
 public MyColoredText(StringBuilder text, Color normalColor, Color highlightColor, MyGuiFont font, float textScale, Vector2 offset)
 {
     Text = text;
     NormalColor = normalColor;
     HighlightColor = highlightColor;
     Font = font;
     Scale = textScale;
     Offset = offset;
 }
Example #12
0
 public MyColoredText(StringBuilder text, Color normalColor, Color highlightColor, MyGuiFont font, float textScale, Vector2 offset)
 {
     Text           = text;
     NormalColor    = normalColor;
     HighlightColor = highlightColor;
     Font           = font;
     Scale          = textScale;
     Offset         = offset;
 }
Example #13
0
        public MyGuiControlLabel(IMyGuiControlsParent parent, Vector2 position, Vector2?size, MyTextsWrapperEnum textEnum, Vector4 textColor, float textScale, MyGuiDrawAlignEnum textAlign, MyGuiFont font)
            : base(parent, position, size, null, null, false)
        {
            m_type = MyGuiControlLabelType.DEFINED_BY_TEXT_WRAPPER_ENUM;

            m_textEnum = textEnum;
            Font       = font;
            Init(textColor, textScale, textAlign);
        }
        public MyGuiControlLabel(IMyGuiControlsParent parent, Vector2 position, Vector2? size, MyTextsWrapperEnum textEnum, Vector4 textColor, float textScale, MyGuiDrawAlignEnum textAlign, MyGuiFont font)
            : base(parent, position, size, null, null, false)
        {
            m_type = MyGuiControlLabelType.DEFINED_BY_TEXT_WRAPPER_ENUM;

            m_textEnum = textEnum;
            Font = font;
            Init(textColor, textScale, textAlign);
        }
 public MyMessageBoxConfiguration(MyTexture2D texture, Vector4 textColor, Vector4 backgroundColor, Vector4 buttonColor, Vector4 rotatingWheelColor, Vector4 interferenceVideoColor, MyGuiFont font, MyTexture2D buttonTexture ) 
 {
     Texture = texture;
     TextColor = textColor;
     BackgroundColor = backgroundColor;
     ButtonColor = buttonColor;
     RotatingWheelColor = rotatingWheelColor;
     InterferenceVideoColor = interferenceVideoColor;
     Font = font;
     ButtonTexture = buttonTexture;
 }
Example #16
0
        //  IMPORTANT: This class isn't initialized by constructor, but by Start() because it's supposed to be used in memory pool
        public void Start(MyGuiFont font, Vector2 position, Color color, float scale, MyGuiDrawAlignEnum alignement)
        {
            Font = font;
            Position = position;            
            Color = color;
            Scale = scale;
            Alignement = alignement;

            //  Clear current text
            MyMwcUtils.ClearStringBuilder(m_text);
        }
Example #17
0
        public void Append(string text, MyGuiFont font, float scale, Vector4 color)
        {
            string[] paragraphs = text.Split(m_lineSeparators, StringSplitOptions.None);

            for (int i = 0; i < paragraphs.Length; i++)
            {
                AppendParagraph(paragraphs[i], font, scale, color);
                if (i < paragraphs.Length - 1)
                {
                    AppendLine();
                }
            }
        }
Example #18
0
        public MyGuiControlLabel(IMyGuiControlsParent parent, Vector2 position, Vector2?size, StringBuilder text, Vector4 textColor, float textScale, MyGuiDrawAlignEnum textAlign, MyGuiFont font)
            : base(parent, position, size, null, null, false)
        {
            m_type = MyGuiControlLabelType.DEFINED_BY_STRING_BUILDER;
            Font   = font;
            if (text != null)
            {
                //  Create COPY of the text (Don't just point to one string builder!!! This was my original mistake!)
                m_textDefinition = new StringBuilder(text.ToString());
                m_textDraw       = new StringBuilder(text.ToString());
            }

            Init(textColor, textScale, textAlign);
        }
Example #19
0
 public void AppendText(StringBuilder text, MyGuiFont font, float scale, Vector4 color)
 {
     m_label.Append(text, font, scale, color);
     RecalculateScrollBar();
 }
Example #20
0
        //  Draws string (string builder) at specified position
        //  normalizedPosition -> X and Y are within interval <0..1>
        //  scale -> scale for original texture, it's not in pixel/texels, but multiply of original size. E.g. 1 means unchanged size, 2 means double size. Scale is uniform, preserves aspect ratio.
        //  RETURN: Method returns rectangle where was string drawn in normalized coordinates
        public static MyRectangle2D DrawStringCentered(MyGuiFont font, StringBuilder sb, Vector2 normalizedCoord, float scale, Color color, MyGuiDrawAlignEnum drawAlign)
        {
            Vector2 screenCoord = GetScreenCoordinateFromNormalizedCoordinate(normalizedCoord);

            //  Fix the scale for screen resolution
            float fixedScale = scale * m_safeScreenScale;

            //  IMPORTANT: We don't draw shadows under text here because shadows are already contained in font texture!

            int lineCount = 0;
            foreach (var line in sb.Split('\n'))
            {
                line.TrimTrailingWhitespace();
                var lineSizeInPixelsScaled = font.MeasureString(line, fixedScale);
                var lineCoord = GetAlignedCoordinate(screenCoord + new Vector2(0, lineCount * font.LineHeight * fixedScale), lineSizeInPixelsScaled, drawAlign);
                font.DrawString(lineCoord, color, line, fixedScale);
                lineCount++;
            }

            //  IMPORTANT: MeasureString is weird method, because for example it returns height 56 pixels, but DrawString actualy draws 33 pixels tall characters
            //  And SpriteFont.LineSpacing gives me 53 pixels... so am quite sure MeasureString returns height of line and not of characters, but then why is it less than LineSpacing???
            Vector2 sizeInPixelsScaled = font.MeasureString(sb, fixedScale);
            screenCoord = GetAlignedCoordinate(screenCoord, sizeInPixelsScaled, drawAlign);
            return new MyRectangle2D(GetNormalizedCoordinateFromScreenCoordinate(screenCoord), GetNormalizedSizeFromScreenSize(sizeInPixelsScaled));
        }
 public MyNotification(MyTextsWrapperEnum notificationText, MyGuiFont font, MyEntity owner = null)
     : this(notificationText, GetCurrentScreen(), 1.0f, font, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, DONT_DISAPEAR, owner)
 {
 }
 public MyNotification(string notificationText, MyGuiFont font, MyEntity owner = null, bool showConfirmMessage = false)
     : this(notificationText, GetCurrentScreen(), 1.0f, font, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, DONT_DISAPEAR, owner)
 {
     m_showConfirmMessage = showConfirmMessage;
 }
Example #23
0
 public void Append(StringBuilder text, MyGuiFont font, float scale, Vector4 color)
 {
     Append(text.ToString(), font, scale, color);
 }
Example #24
0
        public void Append(string text, MyGuiFont font, float scale, Vector4 color)
        {
            string[] paragraphs = text.Split(m_lineSeparators, StringSplitOptions.None);

            for (int i = 0; i < paragraphs.Length; i++)
            {
                AppendParagraph(paragraphs[i], font, scale, color);
                if (i < paragraphs.Length - 1)
                {
                    AppendLine();
                }
            }
        }
Example #25
0
 /// <summary>
 /// Creates new instance with text's color
 /// </summary>
 /// <param name="text">Warning text</param>
 /// <param name="textFont">Text's font</param>
 public MyHudTextWarning(StringBuilder text, MyGuiFont textFont)
 {
     Text = text;
     TextFont = textFont;
 }
 public MyNotification(string notificationText, MyGuiFont font, int disapearTimeMs, MyEntity owner = null, object[] textFormatArguments = null)
     : this(notificationText, GetCurrentScreen(), 1.0f, font, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, disapearTimeMs, owner, false, textFormatArguments)
 {
 }
        protected void AddLabel(StringBuilder text, Vector4 color, float scale, List<MyGuiControlBase> controlGroup = null, MyGuiFont font = null)
        {
            MyGuiControlLabel label = new MyGuiControlLabel(this, m_currentPosition, null, text, color, MyGuiConstants.LABEL_TEXT_SCALE * MyGuiConstants.DEBUG_LABEL_TEXT_SCALE * scale * m_scale,
                                                            MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER, font);
            float labelWidth = label.GetTextSize().Size.X + 0.02f;
            m_maxWidth = Math.Max(m_maxWidth, labelWidth);
            Controls.Add(label);

            m_currentPosition.Y += 0.04f * m_scale;

            if (controlGroup != null)
                controlGroup.Add(label);
        }
Example #28
0
        //  Draws string (string builder) at specified position
        //  normalizedPosition -> X and Y are within interval <0..1>
        //  scale -> scale for original texture, it's not in pixel/texels, but multiply of original size. E.g. 1 means unchanged size, 2 means double size. Scale is uniform, preserves aspect ratio.
        //  RETURN: Method returns rectangle where was string drawn in normalized coordinates
        public static MyRectangle2D DrawString(MyGuiFont font, StringBuilder sb, Vector2 normalizedCoord, float scale, Color color, MyGuiDrawAlignEnum drawAlign, bool fullscreen = false)
        {
            Vector2 screenCoord = GetScreenCoordinateFromNormalizedCoordinate(normalizedCoord, fullscreen);

            //  Fix the scale for screen resolution
            float fixedScale = scale * m_safeScreenScale;

            //  IMPORTANT: MeasureString is weird method, because for example it returns height 56 pixels, but DrawString actualy draws 33 pixels tall characters
            //  And SpriteFont.LineSpacing gives me 53 pixels... so am quite sure MeasureString returns height of line and not of characters, but then why is it less than LineSpacing???
            Vector2 sizeInPixelsScaled = font.MeasureString(sb, fixedScale);

            screenCoord = GetAlignedCoordinate(screenCoord, sizeInPixelsScaled, drawAlign);

            //  IMPORTANT: We don't draw shadows under text here because shadows are already contained in font texture!

            //MinerWars.AppCode.App.MyMinerGame.GraphicsDeviceManager.GraphicsDevice.

            //font.DrawString(screenCoord, /*color*/ Color.White, sb, fixedScale);
            font.DrawString(screenCoord, color, sb, fixedScale);

            return new MyRectangle2D(GetNormalizedCoordinateFromScreenCoordinate(screenCoord), GetNormalizedSizeFromScreenSize(sizeInPixelsScaled));
        }
 public void AppendText(StringBuilder text, MyGuiFont font, float scale, Vector4 color)
 {
     m_label.Append(text, font, scale, color);
     RecalculateScrollBar();
 }
Example #30
0
 /// <summary>
 /// Creates new instance with text's font
 /// </summary>
 /// <param name="text">Warning text</param>
 /// <param name="textFont">Text's font</param>
 public MyHudTextWarning(MyTextsWrapperEnum text, MyGuiFont textFont)
     : this(MyTextsWrapper.Get(text), textFont)
 {            
 }
Example #31
0
        private void AppendParagraph(string paragraph, MyGuiFont font, float scale, Vector4 color)
        {
            m_helperSb.Clear();
            m_helperSb.Append(paragraph);
            float textWidth = MyGuiManager.GetNormalizedSize(font, m_helperSb, scale).X;
            // first we try append all paragraph to current line
            if (textWidth < m_currentLineRestFreeSpace)
            {
                RealocateRichTexts();
                m_richTextsPool[++m_richTextsOffset].Init(m_helperSb.ToString(), font, scale, color);
                AppendPart(m_richTextsPool[m_richTextsOffset]);
            }
            // if there is not enough free space in current line for whole paragraph
            else
            {
                RealocateRichTexts();
                m_richTextsPool[++m_richTextsOffset].Init("", font, scale, color);
                string[] words = paragraph.Split(m_wordSeparator);
                int currentWordIndex = 0;
                while (currentWordIndex < words.Length)
                {
                    if (words[currentWordIndex].Trim().Length == 0)
                    {
                        currentWordIndex++;
                        continue;
                    }

                    m_helperSb.Clear();
                    if (m_richTextsPool[m_richTextsOffset].Text.Length > 0)
                    {
                        m_helperSb.Append(m_wordSeparator);
                    }
                    m_helperSb.Append(words[currentWordIndex]);

                    textWidth = MyGuiManager.GetNormalizedSize(font, m_helperSb, scale).X;

                    if (textWidth <= m_currentLineRestFreeSpace - m_richTextsPool[m_richTextsOffset].GetSize().X)
                    {
                        m_richTextsPool[m_richTextsOffset].Append(m_helperSb.ToString());
                        currentWordIndex++;
                    }
                    else
                    {
                        // if this word is wider than line and it will be only one word at line, then we append it to current line
                        if ((m_currentLine == null || m_currentLine.IsEmpty()) && m_richTextsPool[m_richTextsOffset].Text.Length == 0)
                        {
                            m_richTextsPool[m_richTextsOffset].Append(m_helperSb.ToString());
                            currentWordIndex++;
                        }

                        AppendPart(m_richTextsPool[m_richTextsOffset]);
                        RealocateRichTexts();
                        m_richTextsPool[++m_richTextsOffset].Init("", font, scale, color);
                        if (currentWordIndex < words.Length)
                        {
                            AppendLine();
                        }
                    }
                }

                if (m_richTextsPool[m_richTextsOffset].Text.Length > 0)
                {
                    AppendPart(m_richTextsPool[m_richTextsOffset]);
                }
            }
        }
Example #32
0
 public MyHudSetting(MyGuiFont font, MyHudTexturesEnum textureDirectionIndicator, MyHudTexturesEnum textureTarget, MyHudTexturesEnum textureUnpowered, Color color, float textureTargetRotationSpeed = 0f, float textureTargetScale = 1f) 
 {
     Font = font;
     TextureDirectionIndicator = textureDirectionIndicator;
     TextureTarget = textureTarget;
     this.Color = color;
     TextureTargetRotationSpeed = textureTargetRotationSpeed;
     TextureTargetScale = textureTargetScale;
     TextureUnpowered = textureUnpowered;
 }
Example #33
0
 public void Append(StringBuilder text, MyGuiFont font, float scale, Vector4 color)
 {
     Append(text.ToString(), font, scale, color);
 }
Example #34
0
 public MyColoredText(StringBuilder text, Color color, MyGuiFont font, float textScale)
     : this(text, color, MyGuiConstants.COLORED_TEXT_DEFAULT_HIGHLIGHT_COLOR, font, textScale, Vector2.Zero)
 {
 }
        void AddIcon(Vector3 pos, float radius, MyTransparentMaterialEnum texture, Color color, string textDown, string textUp, float textSize, bool highlight, Vector3 offset, MyGuiFont font = null, float? importance = null)
        {
            if (font == null)
                font = MyGuiManager.GetFontMinerWarsWhite();

            float scaledRadius = MySolarSystemUtils.CalculateDistanceUnscalingTo(pos, radius, MySolarSystemMapNavigationMark.SCALE_DISTANCE_FROM);

            float textScale = 1 / MySolarSystemUtils.CalculateDistanceUnscalingFrom(pos, 1 / 0.7f, MySolarSystemMapNavigationMark.SCALE_DISTANCE_FROM);// 1;// radius / scaledRadius / 2;

            Vector4 iconColor = Vector4.One;
            if (highlight)
            {
                iconColor *= 1.5f;
            }

            textSize = 1.35f;
            var position = pos + offset * scaledRadius + Vector3.Up / 2 * scaledRadius;
            MyTransparentGeometry.AddBillboardOriented(texture, iconColor, position, m_currentCamera.Up, m_currentCamera.Left, scaledRadius, 0200 + (int)importance);

            if (textUp != null)
            {
                AddText(position, textUp, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_TOP, textSize * textScale, color, font, new Vector2(0, -90) * textScale);
            }

            if (textDown != null)
            {
                AddText(position, textDown, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_TOP, textSize * textScale, color, font, new Vector2(0, -60) * textScale);
            }
        }
Example #36
0
        private void AppendParagraph(string paragraph, MyGuiFont font, float scale, Vector4 color)
        {
            m_helperSb.Clear();
            m_helperSb.Append(paragraph);
            float textWidth = MyGuiManager.GetNormalizedSize(font, m_helperSb, scale).X;

            // first we try append all paragraph to current line
            if (textWidth < m_currentLineRestFreeSpace)
            {
                RealocateRichTexts();
                m_richTextsPool[++m_richTextsOffset].Init(m_helperSb.ToString(), font, scale, color);
                AppendPart(m_richTextsPool[m_richTextsOffset]);
            }
            // if there is not enough free space in current line for whole paragraph
            else
            {
                RealocateRichTexts();
                m_richTextsPool[++m_richTextsOffset].Init("", font, scale, color);
                string[] words            = paragraph.Split(m_wordSeparator);
                int      currentWordIndex = 0;
                while (currentWordIndex < words.Length)
                {
                    if (words[currentWordIndex].Trim().Length == 0)
                    {
                        currentWordIndex++;
                        continue;
                    }

                    m_helperSb.Clear();
                    if (m_richTextsPool[m_richTextsOffset].Text.Length > 0)
                    {
                        m_helperSb.Append(m_wordSeparator);
                    }
                    m_helperSb.Append(words[currentWordIndex]);

                    textWidth = MyGuiManager.GetNormalizedSize(font, m_helperSb, scale).X;

                    if (textWidth <= m_currentLineRestFreeSpace - m_richTextsPool[m_richTextsOffset].GetSize().X)
                    {
                        m_richTextsPool[m_richTextsOffset].Append(m_helperSb.ToString());
                        currentWordIndex++;
                    }
                    else
                    {
                        // if this word is wider than line and it will be only one word at line, then we append it to current line
                        if ((m_currentLine == null || m_currentLine.IsEmpty()) && m_richTextsPool[m_richTextsOffset].Text.Length == 0)
                        {
                            m_richTextsPool[m_richTextsOffset].Append(m_helperSb.ToString());
                            currentWordIndex++;
                        }

                        AppendPart(m_richTextsPool[m_richTextsOffset]);
                        RealocateRichTexts();
                        m_richTextsPool[++m_richTextsOffset].Init("", font, scale, color);
                        if (currentWordIndex < words.Length)
                        {
                            AppendLine();
                        }
                    }
                }

                if (m_richTextsPool[m_richTextsOffset].Text.Length > 0)
                {
                    AppendPart(m_richTextsPool[m_richTextsOffset]);
                }
            }
        }
Example #37
0
 public MyColoredText(StringBuilder text, Color color, MyGuiFont font, float textScale)
     : this(text, color, MyGuiConstants.COLORED_TEXT_DEFAULT_HIGHLIGHT_COLOR, font, textScale, Vector2.Zero)
 {
 }
        // initialize:
        public static void LoadContent()
        {
            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("MyHudNotification::LoadContent");

            m_usedFont = MyGuiManager.GetFontMinerWarsWhite();
            if (m_screenNotifications == null)
            {
                int allScreensCount = (int) MyGuiScreenGamePlayType.ALL_SCREEN_COUNT;
                m_screenNotifications = new MyScreenNotifications[allScreensCount];
                for (int i = 0; i < allScreensCount; ++i)
                {
                    m_screenNotifications[i] = new MyScreenNotifications();
                }
            }
            m_fogColor = MyGuiConstants.SELECT_AMMO_TIP_BACKGROUND_FADE_COLOR;
            m_fogColor.A = (byte) (m_fogColor.A * 0.85f);

            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock();
        }
        /// <summary>
        /// Adds the test.
        /// </summary>
        /// <param name="position">Position in game units.</param>
        /// <param name="str"></param>
        /// <param name="alignment"></param>
        /// <param name="scale"></param>
        /// <param name="offset"></param>
        private void AddText(Vector3 position, string str, MyGuiDrawAlignEnum alignment, float scale, Color color, MyGuiFont font, Vector2 offset = new Vector2())
        {
            if (String.IsNullOrWhiteSpace(str))
            {
                return;
            }
                 
            Vector3 objToCamera = position - MyCamera.Position;
            if (Vector3.Dot(MyCamera.ForwardVector, objToCamera) < 0)
            {
                return;
            }

            Vector3 target = SharpDXHelper.ToXNA(MyCamera.Viewport.Project(SharpDXHelper.ToSharpDX(position), SharpDXHelper.ToSharpDX(MyCamera.ProjectionMatrix), SharpDXHelper.ToSharpDX(MyCamera.ViewMatrix), SharpDXHelper.ToSharpDX(Matrix.Identity)));
            Vector2 projectedPoint2D = new Vector2(target.X, target.Y) + offset / 1080 * MyGuiManager.GetFullscreenRectangle().Height;

            MyHudText text = m_texts.Allocate();
            if (text != null)
            {
                text.Start(font, projectedPoint2D, color, scale * 1.0f, alignment);
                text.Append(str);
            }      
        }        
 void AddIcon(Vector3 pos, float radius, MyTransparentMaterialEnum texture, Vector4 color, string textDown, string textUp, float textSize, bool highlight, Vector3 offset, MyGuiFont font = null, float? importance = null)
 {
     AddIcon(pos, radius, texture, new Color(color), textDown, textUp, textSize, highlight, offset, font, importance);
 }
        public MyGuiControlLabel(IMyGuiControlsParent parent, Vector2 position, Vector2? size, StringBuilder text, Vector4 textColor, float textScale, MyGuiDrawAlignEnum textAlign,MyGuiFont font)
            : base(parent, position, size, null, null, false)
        {
            m_type = MyGuiControlLabelType.DEFINED_BY_STRING_BUILDER;
            Font = font;
            if (text != null)
            {
                //  Create COPY of the text (Don't just point to one string builder!!! This was my original mistake!)
                m_textDefinition = new StringBuilder(text.ToString());
                m_textDraw = new StringBuilder(text.ToString());
            }

            Init(textColor, textScale, textAlign);
        }
Example #42
0
 // Draws string with default label text color
 public static MyRectangle2D DrawString(MyGuiFont font, StringBuilder sb, Vector2 normalizedCoord, float scale, MyGuiDrawAlignEnum drawAlign, bool fullscreen = false)
 {
     return DrawString(font, sb, normalizedCoord, scale, new Color(MyGuiConstants.LABEL_TEXT_COLOR), drawAlign, fullscreen);
 }