Пример #1
0
 public MyRichLabelText()
 {
     m_text = new StringBuilder(512);
     m_font = MyFontEnum.Blue;
     m_scale = 0;
     m_color = Vector4.Zero;
 }
 public ControlWithDescription(StringBuilder boundButtons, StringBuilder description, MyFontEnum leftFont = MyFontEnum.Red, MyFontEnum rightFont = MyFontEnum.White)
 {
     BoundButtons = new StringBuilder(boundButtons.Length).AppendStringBuilder(boundButtons);
     Description = new StringBuilder(description.Length).AppendStringBuilder(description);
     LeftFont = leftFont;
     RightFont = rightFont;
 }
Пример #3
0
 public void AddToolTip(String toolTip,
     float textScale = MyGuiConstants.TOOL_TIP_TEXT_SCALE,
     MyFontEnum font = MyFontEnum.Blue)
 {
     if (toolTip != null)
         ToolTips.Add(new MyColoredText(toolTip, Color.White, font: font, textScale: textScale));
 }
Пример #4
0
 public MyRichLabelText(StringBuilder text, MyFontEnum font, float scale, Vector4 color)
 {
     m_text = text;
     m_font = font;
     m_scale = scale;
     m_color = color;
     RecalculateSize();
 }
Пример #5
0
 public void Init(string text, MyFontEnum font, float scale, Vector4 color)
 {
     m_text.Append(text);
     m_font = font;
     m_scale = scale;
     m_color = color;
     RecalculateSize();
 }
 public ControlWithDescription(MyStringId control)
 {
     MyControl c = MyInput.Static.GetGameControl(control);
     BoundButtons = null;
     c.AppendBoundButtonNames(ref BoundButtons, unassignedText: MyInput.Static.GetUnassignedName());
     Description = MyTexts.Get(c.GetControlDescription() ?? c.GetControlName());
     LeftFont = MyFontEnum.Red;
     RightFont = MyFontEnum.White;
 }
Пример #7
0
        public void ShowMessage(string sender, string messageText, MyFontEnum font = MyFontEnum.Blue)
        {
            MessagesQueue.Enqueue(new Tuple<string, string, MyFontEnum>(sender, messageText, font));

            if (MessagesQueue.Count > MAX_MESSAGES_IN_CHAT)
                MessagesQueue.Dequeue();

            UpdateTimestamp();
        }
 public MyHudMissingComponentNotification(MyStringId text,
     int disapearTimeMs           = 2500,
     MyFontEnum font              = MyFontEnum.White,
     MyGuiDrawAlignEnum textAlign = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER,
     int priority                 = 0,
     MyNotificationLevel level    = MyNotificationLevel.Normal)
     : base(disapearTimeMs, font, textAlign, priority, level)
 {
     m_originalText = text;
 }
 public void Add(MyDefinitionId id, double val1, double val2, MyFontEnum font)
 {
     var control = new ComponentControl(id);
     control.Size            = new Vector2(Size.X - m_padding.HorizontalSum, control.Size.Y);
     m_currentOffsetFromTop += control.Size.Y;
     control.Position        = -0.5f * Size + new Vector2(m_padding.Left, m_currentOffsetFromTop);
     control.OriginAlign     = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM;
     control.ValuesFont      = font;
     control.SetValues(val1, val2);
     Elements.Add(control);
 }
 public MyHudNameValueData(int itemCount,
     MyFontEnum defaultNameFont = MyFontEnum.Blue,
     MyFontEnum defaultValueFont = MyFontEnum.White,
     float lineSpacing      = MyGuiConstants.HUD_LINE_SPACING,
     bool showBackgroundFog = false)
 {
     DefaultNameFont   = defaultNameFont;
     DefaultValueFont  = defaultValueFont;
     LineSpacing       = lineSpacing;
     m_count           = itemCount;
     m_items           = new List<Data>(itemCount);
     ShowBackgroundFog = showBackgroundFog;
     EnsureItemsExist();
 }
        public MyGuiControlSlider(
            Vector2? position = null,
            float minValue = 0f,
            float maxValue = 1f,
            float width = 464f/1600f,
            float? defaultValue = null,
            Vector4? color = null,
            String labelText = null,
            int labelDecimalPlaces = 1,
            float labelScale = MyGuiConstants.DEFAULT_TEXT_SCALE,
            float labelSpaceWidth = 0f,
            MyFontEnum labelFont = MyFontEnum.White,
            String toolTip = null,
            MyGuiControlSliderStyleEnum visualStyle = MyGuiControlSliderStyleEnum.Default,
            MyGuiDrawAlignEnum originAlign = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER,
            bool intValue = false)
            : base(
                position: position,
                width: width,
                color: color,
                labelScale: labelScale,
                labelSpaceWidth: labelSpaceWidth,
                labelFont: labelFont,
                toolTip: toolTip,
                visualStyle: visualStyle,
                originAlign: originAlign
            )
        {
            m_minValue = minValue;
            m_maxValue = maxValue;
            m_range = m_maxValue - m_minValue;

            MyDebug.AssertDebug(m_maxValue > m_minValue && m_maxValue != m_minValue);

            Propeties = new MyGuiSliderProperties()
            {
                FormatLabel = FormatValue,
                RatioFilter = FilterRatio,
                RatioToValue = RatioToValue,
                ValueToRatio = ValueToRatio
            };

            DefaultRatio = defaultValue.HasValue ? ValueToRatio(defaultValue.Value) : default(float?);
            Ratio = DefaultRatio ?? minValue;
            m_intValue = intValue;

            LabelDecimalPlaces = labelDecimalPlaces;
            
            m_labelFormat = labelText;
        }
Пример #12
0
        public void multiplayer_ScriptedChatMessageReceived(string message, string author, MyFontEnum font)
        {
            if (MySteam.IsActive)
            {
                ShowMessage(author, message, font);

                MySession.Static.GlobalChatHistory.GlobalChatHistory.Chat.Enqueue(new MyGlobalChatItem
                {
                    Author = author,
                    Text = message,
                    AuthorFont = font
                });
            }
        }
 public MyColoredText(
     String text,
     Color? normalColor    = null,
     Color? highlightColor = null,
     MyFontEnum font       = MyFontEnum.White,
     float textScale       = MyGuiConstants.COLORED_TEXT_DEFAULT_TEXT_SCALE,
     Vector2? offset       = null)
 {
     Text           = new StringBuilder(text.Length).Append(text);
     NormalColor    = normalColor ?? MyGuiConstants.COLORED_TEXT_DEFAULT_COLOR;
     HighlightColor = highlightColor ?? MyGuiConstants.COLORED_TEXT_DEFAULT_HIGHLIGHT_COLOR;
     Font           = font;
     Scale          = textScale;
     Offset         = offset ?? Vector2.Zero;
 }
 public MyGuiControlMultilineEditableText(
     Vector2? position = null,
     Vector2? size = null,
     Vector4? backgroundColor = null,
     MyFontEnum font = MyFontEnum.Blue,
     float textScale = MyGuiConstants.DEFAULT_TEXT_SCALE,
     MyGuiDrawAlignEnum textAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
     StringBuilder contents = null,
     bool drawScrollbar = true,
     MyGuiDrawAlignEnum textBoxAlign = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER)
     : base(position, size, backgroundColor, font, textScale, textAlign, contents, drawScrollbar, textBoxAlign, true)
 {
     m_fontHeight = MyGuiManager.GetFontHeight(Font, TextScaleWithLanguage);
     this.AllowFocusingElements = false;
 }
Пример #15
0
 public MyHudControlChat(
     MyHudChat chat,
     Vector2? position = null,
     Vector2? size = null,
     Vector4? backgroundColor = null,
     MyFontEnum font = MyFontEnum.White,
     float textScale = 0.7f,
     MyGuiDrawAlignEnum textAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM,
     StringBuilder contents = null,
     bool drawScrollbar = false,
     MyGuiDrawAlignEnum textBoxAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM,
     bool selectable = false)
     : base (position, size, backgroundColor, font, textScale, textAlign, contents, drawScrollbar, textBoxAlign, selectable, true)
 {
     m_forceUpdate = true;
     m_chat = chat;
     OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM;
     base.VisibleChanged += MyHudControlChat_VisibleChanged;
 }
        /// <summary>
        /// Inserts newlines into text to make it fit size.
        /// </summary>
        public static void Autowrap(this StringBuilder sb, float width, MyFontEnum font, float textScale)
        {
            int inputPos = 0;
            int wordCount = 0;
            if (m_tmp == null)
                m_tmp = new StringBuilder(sb.Length);

            m_tmp.Clear();

            while (true)
            {
                int beforeWord = m_tmp.Length;
                int oldPos = inputPos;
                inputPos = AppendWord(sb, m_tmp, inputPos);
                if (inputPos == oldPos)
                    break;
                wordCount++;
                float measuredWidth = MyGuiManager.MeasureString(font, m_tmp, textScale).X;
                bool fits = measuredWidth <= width;
                if (!fits)
                {
                    if (wordCount == 1)
                    {
                        m_tmp.AppendLine();
                        inputPos = MoveSpaces(sb, inputPos);
                        wordCount = 0;
                        width = measuredWidth;
                    }
                    else
                    {
                        m_tmp.Length = beforeWord;
                        inputPos = oldPos;
                        m_tmp.AppendLine();
                        inputPos = MoveSpaces(sb, inputPos);
                        wordCount = 0;
                    }
                }
            }
            sb.Clear().AppendStringBuilder(m_tmp);
        }
Пример #17
0
 public void Init(MyObjectBuilder_GlobalChatItem chatBuilder)
 {
     Text = chatBuilder.Text;
     AuthorFont = chatBuilder.Font;
     if (chatBuilder.IdentityIdUniqueNumber == 0)
     {
         IdentityId = 0;
         Author = chatBuilder.Author;
     }
     else
     {
         IdentityId = MyEntityIdentifier.ConstructId(MyEntityIdentifier.ID_OBJECT_TYPE.IDENTITY, chatBuilder.IdentityIdUniqueNumber);
         Author = "";
     }
 }
Пример #18
0
            /// <summary>
            /// Retrieves font and colouring information for a relationship.
            /// </summary>
            /// <param name="relationship"></param>
            /// <param name="color"></param>
            /// <param name="fontColor"></param>
            /// <param name="font"></param>
            public void GetColorAndFontForRelationship(MyRelationsBetweenPlayerAndBlock relationship, out Color color, out Color fontColor, out MyFontEnum font)
            {
                color = Color.White;
                fontColor = Color.White;
                font = MyFontEnum.White;
                switch (relationship)
                {
                    case MyRelationsBetweenPlayerAndBlock.Owner:
                        color = new Color(117, 201, 241);
                        fontColor = new Color(117, 201, 241);
                        font = MyFontEnum.Blue;
                        break;

                    case MyRelationsBetweenPlayerAndBlock.FactionShare:
                        color = new Color(101, 178, 90);
                        font = MyFontEnum.Green;
                        break;

                    // Neutral and unowned are the same colour
                    case MyRelationsBetweenPlayerAndBlock.Neutral:
                    case MyRelationsBetweenPlayerAndBlock.NoOwnership:
                        break;

                    case MyRelationsBetweenPlayerAndBlock.Enemies:
                        color = new Color(227, 62, 63);
                        font = MyFontEnum.Red;
                        break;
                }
            }
Пример #19
0
            /// <summary>
            /// Returns the POI color and font information.
            /// </summary>
            /// <param name="poiColor">The colour of the POI.</param>
            /// <param name="fontColor">The colour that should be used with this font.</param>
            /// <param name="font">The font to be used for this POI.</param>
            public void GetPOIColorAndFontInformation(out Color poiColor, out Color fontColor, out MyFontEnum font)
            {
                poiColor = Color.White;
                fontColor = Color.White;
                font = MyFontEnum.White;

                // Colour overrides for specific types
                switch (POIType)
                {
                    default:
                        GetColorAndFontForRelationship(Relationship, out poiColor, out fontColor, out font);
                        break;

                    case PointOfInterestType.Ore:       // Ore markers are white
                    case PointOfInterestType.Unknown:   // Unknowns should be white
                        poiColor = Color.White;
                        font = MyFontEnum.White;
                        fontColor = Color.White;
                        break;

                        // Group colour depends on group make-up. If all of 1 type, use that type, else use mixed colour
                    case PointOfInterestType.Group:
                        {
                            MyRelationsBetweenPlayerAndBlock groupRelation = GetGroupRelation();
                            GetColorAndFontForRelationship(groupRelation, out poiColor, out fontColor, out font);
                            break;
                        }

                    // GPS is always blue
                    case PointOfInterestType.GPS:
                        poiColor = new Color(117, 201, 241);
                        fontColor = new Color(117, 201, 241);
                        font = MyFontEnum.Blue;
                        break;
                }
            }
        private void DrawNetgraphScaleForPacketScale(Vector2 position, int optimalLengthOfBarInPx, float optimalDataSizeOfBarInBytes, int stepCount, StringBuilder unitForScale, bool showIntervals, bool alignToRight = true, float textScale = 0.7f, MyFontEnum fontType = MyFontEnum.White)
        {
            int step = optimalLengthOfBarInPx / stepCount;
            float stepValue = (float)(Math.Truncate((optimalDataSizeOfBarInBytes / stepCount) * 100.0) * 0.01f);
            float totalStepValue = 0;
            Vector2 vecStep = new Vector2(0, step);
            vecStep = MyGuiManager.GetNormalizedCoordinateFromScreenCoordinate(vecStep);
            vecStep.X = 0;

            MyGuiDrawAlignEnum align = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER;
            if (alignToRight)
                align = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER;

            m_helperSB.Clear();
            for (int i = 0; i < stepCount; i++)
            {
                Vector2 oldPosition = position;
                position -= vecStep;

                // small intervals next to the scale
                //if (showIntervals)
                //{
                //float intervalOffset = vecStep.Y / MyGuiConstants.NETGRAPH_SMALL_INTERVAL_COUNT;
                //for (int j = 1; j <= MyGuiConstants.NETGRAPH_SMALL_INTERVAL_COUNT; j++)
                //{
                //    Vector2 intervalMarkPosition = new Vector2(oldPosition.X + 0.005f, oldPosition.Y - j * intervalOffset);
                //    bool isLast = j == MyGuiConstants.NETGRAPH_SMALL_INTERVAL_COUNT;
                //    Vector2 intervalMarkEndPosition;
                //    Color intervalColor;
                //    if (isLast)
                //    {
                //        intervalMarkEndPosition = new Vector2(0.008f, 0.002f);
                //        intervalColor = MyGuiConstants.NETGRAPH_PACKET_SCALE_INTERVAL_POINT_COLOR;
                //    }
                //    else
                //    {
                //        intervalMarkEndPosition = new Vector2(0.005f, 0.002f);
                //        intervalColor = MyGuiConstants.NETGRAPH_PACKET_SCALE_SMALL_INTERVAL_COLOR;
                //    }
                //    MyGuiManager.DrawSpriteBatch(MyGuiConstants.BLANK_TEXTURE, intervalMarkPosition, intervalMarkEndPosition, MyGuiConstants.NETGRAPH_PACKET_SCALE_SMALL_INTERVAL_COLOR, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER);
                //}
                //}

                totalStepValue += stepValue;
                m_helperSB.Clear();
                m_helperSB.Append(totalStepValue);
                MyGuiManager.DrawString(fontType, m_helperSB, position, textScale, null, align);
            }

            if (unitForScale.Length != 0)
            {
                position.Y -= 0.02f;
                MyGuiManager.DrawString(fontType, unitForScale, position, textScale, null, align);
            }
        }
Пример #21
0
 public static void SetLadderStatus(string text, MyFontEnum font, int aliveTime = 100)
 public ControlWithDescription(string boundButtons, string description, MyFontEnum leftFont = MyFontEnum.Red, MyFontEnum rightFont = MyFontEnum.White)
     : this(new StringBuilder(boundButtons), new StringBuilder(description), leftFont, rightFont)
 { }
        private void DrawNetgraphScaleForAverageScale(Vector2 position, int optimalLengthOfBarInPx, float maximumValueOfScale, int stepCount, bool alignToRight = true, float textScale = 0.7f, MyFontEnum fontType = MyFontEnum.White)
        {
            int step = optimalLengthOfBarInPx / stepCount;
            float stepValue = (maximumValueOfScale) / stepCount;
            float totalStepValue = 0;
            Vector2 vecStep = new Vector2(0, step);
            vecStep = MyGuiManager.GetNormalizedCoordinateFromScreenCoordinate(vecStep);
            vecStep.X = 0;

            MyGuiDrawAlignEnum align = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER;
            if (alignToRight)
                align = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER;

            m_helperSB.Clear();
            for (int i = 0; i < stepCount; i++)
            {
                position -= vecStep;
                totalStepValue += stepValue;
                m_helperSB.Clear();
                m_helperSB.Append(totalStepValue);
                MyGuiManager.DrawString(fontType, m_helperSB, position, textScale, null, align);
            }

            m_helperSB.Clear().Append("[kB]");
            position.Y -= 0.02f;
            MyGuiManager.DrawString(fontType, m_helperSB, position, textScale, null, align);
        }
Пример #24
0
 public void Append(StringBuilder text, MyFontEnum font, float scale, Vector4 color)
 {
     Append(text.ToString(), font, scale, color);
 }
Пример #25
0
        public void Append(string text, MyFontEnum 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();
                }
            }
        }
Пример #26
0
        private void AppendParagraph(string paragraph, MyFontEnum font, float scale, Vector4 color)
        {
            m_helperSb.Clear();
            m_helperSb.Append(paragraph);
            float textWidth = MyGuiManager.MeasureString(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.MeasureString(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, we add what fits and leave the rest for other lines
                        if ((m_currentLine == null || m_currentLine.IsEmpty()) && m_richTextsPool[m_richTextsOffset].Text.Length == 0)
                        {
                            int numCharsThatFit = MyGuiManager.ComputeNumCharsThatFit(font, m_helperSb, scale, m_currentLineRestFreeSpace);
                            m_richTextsPool[m_richTextsOffset].Append(words[currentWordIndex].Substring(0, numCharsThatFit));
                            words[currentWordIndex] = words[currentWordIndex].Substring(numCharsThatFit);
                        }

                        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]);
                }
            }
        }
Пример #27
0
        public MyGuiControlSliderBase(
            Vector2? position                       = null,
            float width                             = 464f/1600f,
            MyGuiSliderProperties props                  = null,
            float? defaultRatio                     = null,
            Vector4? color                          = null,
            float labelScale                        = MyGuiConstants.DEFAULT_TEXT_SCALE,
            float labelSpaceWidth                   = 0f,
            MyFontEnum labelFont                    = MyFontEnum.White,
            String toolTip                   = null,
            MyGuiControlSliderStyleEnum visualStyle = MyGuiControlSliderStyleEnum.Default,
            MyGuiDrawAlignEnum originAlign          = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER)
            : base(
                 position: position,
                 toolTip: toolTip,
                 isActiveControl: true,
                 originAlign: originAlign,
                 canHaveFocus: true)
        {
            // Make sure the default value makes sense
            if (defaultRatio.HasValue)
            {
                Debug.Assert(defaultRatio.Value >= 0 && defaultRatio.Value <= 1);
                defaultRatio = MathHelper.Clamp(defaultRatio.Value, 0, 1);
            }

            if (props == null)
                props = MyGuiSliderProperties.Default;
            m_props = props;

            DefaultRatio = defaultRatio;
            m_ratio = defaultRatio.HasValue ? defaultRatio.Value : 0;
            m_labelSpaceWidth = labelSpaceWidth;

            m_label = new MyGuiControlLabel(
                text: String.Empty,
                originAlign: MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER,
                textScale: labelScale,
                font: labelFont);
            Elements.Add(m_label);

            VisualStyle = visualStyle;
            Size = new Vector2(width, Size.Y);
            
            UpdateLabel();
        }
        private void RefreshInternals()
        {
            if (HasHighlight)
            {
                BackgroundTexture  = m_styleDef.ComboboxTextureHighlight;
                m_selectedItemFont = m_styleDef.ItemFontHighlight;
            }
            else
            {
                BackgroundTexture  = m_styleDef.ComboboxTextureNormal;
                m_selectedItemFont = m_styleDef.ItemFontNormal;
            }
            MinSize = BackgroundTexture.MinSizeGui;
            MaxSize = BackgroundTexture.MaxSizeGui;

            m_scrollbarTexture = (HasHighlight)
                ? MyGuiConstants.TEXTURE_SCROLLBAR_V_THUMB_HIGHLIGHT
                : MyGuiConstants.TEXTURE_SCROLLBAR_V_THUMB;

            m_selectedItemArea.Position = m_styleDef.SelectedItemOffset;
            m_selectedItemArea.Size = new Vector2(Size.X - (m_scrollbarTexture.MinSizeGui.X + m_styleDef.ScrollbarMargin.HorizontalSum + m_styleDef.SelectedItemOffset.X), ITEM_HEIGHT);

            var openedArea = GetOpenedArea();
            m_openedArea.Position = openedArea.LeftTop;
            m_openedArea.Size = openedArea.Size;

            m_openedItemArea.Position = m_openedArea.Position + new Vector2(m_styleDef.SelectedItemOffset.X, m_styleDef.DropDownTexture.LeftTop.SizeGui.Y);
            m_openedItemArea.Size = new Vector2(m_selectedItemArea.Size.X,
                (m_showScrollBar ? m_openAreaItemsCount : m_items.Count) * m_selectedItemArea.Size.Y);

            m_textScaleWithLanguage = m_styleDef.TextScale * MyGuiManager.LanguageTextScale;
        }
Пример #29
0
        private void ShowNotification(string text, MyFontEnum color)
        {
            if(mNotify == null)
            {
                mNotify = MyAPIGateway.Utilities.CreateNotification(text, 10000, MyFontEnum.Red);
            }
            else
            {
                mNotify.Text = text;
                mNotify.ResetAliveTime();
            }

            mNotify.Show();
        }
        private void RefreshInternals()
        {
            ColorMask = m_styleDefinition.BackgroundColor;
            if (!Enabled)
            {
                BackgroundTexture = m_styleDefinition.Disabled.Texture;
                TextFont = m_styleDefinition.Disabled.Font;
                CornerTextFont = m_styleDefinition.Disabled.CornerTextFont;
                CornerTextSize = m_styleDefinition.Disabled.CornerTextSize;
            }
            if (HasHighlight && Checked)
            {
                BackgroundTexture = m_styleDefinition.ActiveHighlight.Texture;
                TextFont = m_styleDefinition.ActiveHighlight.Font;
                CornerTextFont = m_styleDefinition.ActiveHighlight.CornerTextFont;
                CornerTextSize = m_styleDefinition.ActiveHighlight.CornerTextSize;
            }
            else if (HasHighlight)
            {
                BackgroundTexture = m_styleDefinition.Highlight.Texture;
                TextFont = m_styleDefinition.Highlight.Font;
                CornerTextFont = m_styleDefinition.Highlight.CornerTextFont;
                CornerTextSize = m_styleDefinition.Highlight.CornerTextSize;
            }
            else if (Checked)
            {
                BackgroundTexture = m_styleDefinition.Active.Texture;
                TextFont = m_styleDefinition.Active.Font;
                CornerTextFont = m_styleDefinition.Active.CornerTextFont;
                CornerTextSize = m_styleDefinition.Active.CornerTextSize;
            }
            else
            {
                BackgroundTexture = m_styleDefinition.Normal.Texture;
                TextFont = m_styleDefinition.Normal.Font;
                CornerTextFont = m_styleDefinition.Normal.CornerTextFont;
                CornerTextSize = m_styleDefinition.Normal.CornerTextSize;
            }

            var size = Size;
            if (BackgroundTexture != null)
            {
                MinSize = BackgroundTexture.MinSizeGui;
                MaxSize = BackgroundTexture.MaxSizeGui;
            }
            else
            {
                MinSize = Vector2.Zero;
                MaxSize = Vector2.PositiveInfinity;
                size = Vector2.Zero;
            }

            // No size specified, but we have string and font ... probably its a clickable text so let's use that as size.
            if (size == Vector2.Zero && m_drawText != null)
            {
                size = MyGuiManager.MeasureString(TextFont, m_drawText, TextScaleWithLanguage);
            }

            var padding = m_styleDefinition.Padding;
            m_internalArea.Position = padding.TopLeftOffset;
            m_internalArea.Size = Size - padding.SizeChange;
            Size = size;
        }