예제 #1
0
 private void RefreshInternals()
 {
     if (m_styleDefinition != null)
     {
         BackgroundTexture = m_styleDefinition.BackgroundTexture;
         m_padding         = m_styleDefinition.Padding;
     }
 }
예제 #2
0
 private void RefreshVisualStyle()
 {
     m_styleDef      = GetVisualStyle(VisualStyle);
     m_itemMargin    = m_styleDef.ItemMargin;
     m_showScrollbar = m_styleDef.ScrollbarEnabled;
     MinSize         = m_styleDef.Texture.MinSizeGui;
     MaxSize         = m_styleDef.Texture.MaxSizeGui;
     RefreshInternals();
 }
예제 #3
0
        public MyGuiControlMultilineText(
            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,
            int?visibleLinesCount                   = null,
            bool selectable                         = false,
            bool showTextShadow                     = false,
            MyGuiCompositeTexture backgroundTexture = null,
            MyGuiBorderThickness?textPadding        = null
            )
            : base(position: position,
                   size: size,
                   colorMask: backgroundColor,
                   toolTip: null,
                   backgroundTexture: backgroundTexture)
        {
            Font            = font;
            TextScale       = textScale;
            m_drawScrollbar = drawScrollbar;
            TextColor       = new Color(Vector4.One);
            TextBoxAlign    = textBoxAlign;
            m_selectable    = selectable;

            m_textPadding   = textPadding ?? new MyGuiBorderThickness(0, 0, 0, 0);
            m_scrollbar     = new MyVScrollbar(this);
            m_scrollbarSize = new Vector2(0.0334f, MyGuiConstants.COMBOBOX_VSCROLLBAR_SIZE.Y);
            m_scrollbarSize = MyGuiConstants.COMBOBOX_VSCROLLBAR_SIZE;
            float minLineHeight = MyGuiManager.MeasureString(Font, m_lineHeightMeasure, TextScaleWithLanguage).Y;

            m_label = new MyRichLabel(this, ComputeRichLabelWidth(), minLineHeight, visibleLinesCount)
            {
                ShowTextShadow = showTextShadow
            };
            m_label.AdjustingScissorRectangle += AdjustScissorRectangleLabel;
            m_label.TextAlign = textAlign;
            m_text            = new StringBuilder();
            m_selection       = new MyGuiControlMultilineSelection();

            if (contents != null && contents.Length > 0)
            {
                Text = contents;
            }

            m_keyThrottler = new MyKeyThrottler();
        }
예제 #4
0
        static MyGuiControlButton()
        {
            var defaultPadding = new MyGuiBorderThickness()
            {
                Left   = 7f / MyGuiConstants.GUI_OPTIMAL_SIZE.X,
                Right  = 5f / MyGuiConstants.GUI_OPTIMAL_SIZE.X,
                Top    = 6f / MyGuiConstants.GUI_OPTIMAL_SIZE.Y,
                Bottom = 10f / MyGuiConstants.GUI_OPTIMAL_SIZE.Y,
            };

            m_styles = new StyleDefinition[MyUtils.GetMaxValueFromEnum <MyGuiControlButtonStyleEnum>() + 1];
            m_styles[(int)MyGuiControlButtonStyleEnum.Default] = new StyleDefinition()
            {
                NormalTexture    = MyGuiConstants.TEXTURE_BUTTON_DEFAULT_NORMAL,
                HighlightTexture = MyGuiConstants.TEXTURE_BUTTON_DEFAULT_HIGHLIGHT,
                NormalFont       = MyFontEnum.Blue,
                HighlightFont    = MyFontEnum.White,
                Padding          = defaultPadding,
            };
            m_styles[(int)MyGuiControlButtonStyleEnum.Small] = new StyleDefinition()
            {
                NormalTexture = new MyGuiCompositeTexture()
                {
                    Center = MyGuiConstants.TEXTURE_BUTTON_DEFAULT_NORMAL.LeftTop
                },
                HighlightTexture = new MyGuiCompositeTexture()
                {
                    Center = MyGuiConstants.TEXTURE_BUTTON_DEFAULT_HIGHLIGHT.LeftTop
                },
                NormalFont    = MyFontEnum.Blue,
                HighlightFont = MyFontEnum.White,
                SizeOverride  = MyGuiConstants.TEXTURE_BUTTON_DEFAULT_NORMAL.MinSizeGui * 0.75f,
                Padding       = defaultPadding,
            };
            m_styles[(int)MyGuiControlButtonStyleEnum.Tiny] = new StyleDefinition()
            {
                NormalTexture = new MyGuiCompositeTexture()
                {
                    Center = MyGuiConstants.TEXTURE_SWITCHONOFF_LEFT_NORMAL.LeftTop
                },
                HighlightTexture = new MyGuiCompositeTexture()
                {
                    Center = MyGuiConstants.TEXTURE_SWITCHONOFF_LEFT_HIGHLIGHT.LeftTop
                },
                NormalFont    = MyFontEnum.Blue,
                HighlightFont = MyFontEnum.White,
                SizeOverride  = MyGuiConstants.TEXTURE_SWITCHONOFF_LEFT_NORMAL.MinSizeGui * 0.75f,
                Padding       = defaultPadding,
            };
            m_styles[(int)MyGuiControlButtonStyleEnum.ClickableText] = new StyleDefinition()
            {
                NormalFont    = MyFontEnum.Blue,
                HighlightFont = MyFontEnum.White,
            };
            m_styles[(int)MyGuiControlButtonStyleEnum.UrlText] = new StyleDefinition()
            {
                NormalFont         = MyFontEnum.UrlNormal,
                HighlightFont      = MyFontEnum.UrlHighlight,
                Underline          = @"Textures\GUI\Underline.dds",
                UnderlineHighlight = @"Textures\GUI\UnderlineHighlight.dds",
                MouseOverCursor    = MyGuiConstants.CURSOR_HAND,
            };
            m_styles[(int)MyGuiControlButtonStyleEnum.Red] = new StyleDefinition()
            {
                NormalTexture    = MyGuiConstants.TEXTURE_BUTTON_RED_NORMAL,
                HighlightTexture = MyGuiConstants.TEXTURE_BUTTON_RED_HIGHLIGHT,
                NormalFont       = MyFontEnum.Red,
                HighlightFont    = MyFontEnum.White,
                Padding          = defaultPadding,
            };
            m_styles[(int)MyGuiControlButtonStyleEnum.Close] = new StyleDefinition()
            {
                NormalTexture    = MyGuiConstants.TEXTURE_BUTTON_CLOSE_NORMAL,
                HighlightTexture = MyGuiConstants.TEXTURE_BUTTON_CLOSE_HIGHLIGHT,
                NormalFont       = MyFontEnum.Blue,
                HighlightFont    = MyFontEnum.White,
            };
            m_styles[(int)MyGuiControlButtonStyleEnum.Info] = new StyleDefinition()
            {
                NormalTexture    = MyGuiConstants.TEXTURE_BUTTON_INFO_NORMAL,
                HighlightTexture = MyGuiConstants.TEXTURE_BUTTON_INFO_HIGHLIGHT,
                NormalFont       = MyFontEnum.Blue,
                HighlightFont    = MyFontEnum.White,
            };
            m_styles[(int)MyGuiControlButtonStyleEnum.InventoryTrash] = new StyleDefinition()
            {
                NormalTexture    = MyGuiConstants.TEXTURE_INVENTORY_TRASH_NORMAL,
                HighlightTexture = MyGuiConstants.TEXTURE_INVENTORY_TRASH_HIGHLIGHT,
                NormalFont       = MyFontEnum.Blue,
                HighlightFont    = MyFontEnum.White,
            };
            m_styles[(int)MyGuiControlButtonStyleEnum.Debug] = new StyleDefinition()
            {
                NormalTexture = new MyGuiCompositeTexture()
                {
                    Center = MyGuiConstants.TEXTURE_BUTTON_DEFAULT_NORMAL.LeftTop
                },
                HighlightTexture = new MyGuiCompositeTexture()
                {
                    Center = MyGuiConstants.TEXTURE_BUTTON_DEFAULT_HIGHLIGHT.LeftTop
                },
                NormalFont    = MyFontEnum.Blue,
                HighlightFont = MyFontEnum.White,
                SizeOverride  = MyGuiConstants.TEXTURE_BUTTON_DEFAULT_NORMAL.MinSizeGui * new Vector2(0.55f, 0.65f),
                Padding       = defaultPadding,
            };
            m_styles[(int)MyGuiControlButtonStyleEnum.ControlSetting] = new StyleDefinition()
            {
                NormalTexture = new MyGuiCompositeTexture()
                {
                    Center = MyGuiConstants.TEXTURE_BUTTON_DEFAULT_NORMAL.LeftTop
                },
                HighlightTexture = new MyGuiCompositeTexture()
                {
                    Center = MyGuiConstants.TEXTURE_BUTTON_DEFAULT_HIGHLIGHT.LeftTop
                },
                NormalFont    = MyFontEnum.Blue,
                HighlightFont = MyFontEnum.White,
                SizeOverride  = MyGuiConstants.TEXTURE_BUTTON_DEFAULT_NORMAL.MinSizeGui * new Vector2(0.5f, 0.8f),
                Padding       = defaultPadding,
            };
            m_styles[(int)MyGuiControlButtonStyleEnum.Increase] = new StyleDefinition()
            {
                NormalTexture    = MyGuiConstants.TEXTURE_BUTTON_INCREASE,
                HighlightTexture = MyGuiConstants.TEXTURE_BUTTON_INCREASE,
            };
            m_styles[(int)MyGuiControlButtonStyleEnum.Decrease] = new StyleDefinition()
            {
                NormalTexture    = MyGuiConstants.TEXTURE_BUTTON_DECREASE,
                HighlightTexture = MyGuiConstants.TEXTURE_BUTTON_DECREASE,
            };
            m_styles[(int)MyGuiControlButtonStyleEnum.Rectangular] = new StyleDefinition()
            {
                NormalTexture    = MyGuiConstants.TEXTURE_RECTANGLE_DARK,
                HighlightTexture = MyGuiConstants.TEXTURE_RECTANGLE_NEUTRAL,
                NormalFont       = MyFontEnum.Blue,
                HighlightFont    = MyFontEnum.White,
                Padding          = new MyGuiBorderThickness(5f / MyGuiConstants.GUI_OPTIMAL_SIZE.X,
                                                            5f / MyGuiConstants.GUI_OPTIMAL_SIZE.Y),
            };
            m_styles[(int)MyGuiControlButtonStyleEnum.ArrowLeft] = new StyleDefinition()
            {
                NormalTexture    = MyGuiConstants.TEXTURE_BUTTON_ARROW_LEFT,
                HighlightTexture = MyGuiConstants.TEXTURE_BUTTON_ARROW_LEFT_HIGHLIGHT,
            };
            m_styles[(int)MyGuiControlButtonStyleEnum.ArrowRight] = new StyleDefinition()
            {
                NormalTexture    = MyGuiConstants.TEXTURE_BUTTON_ARROW_RIGHT,
                HighlightTexture = MyGuiConstants.TEXTURE_BUTTON_ARROW_RIGHT_HIGHLIGHT,
            };
            m_styles[(int)MyGuiControlButtonStyleEnum.Square] = new StyleDefinition()
            {
                NormalTexture    = MyGuiConstants.TEXTURE_BUTTON_SQUARE_NORMAL,
                HighlightTexture = MyGuiConstants.TEXTURE_BUTTON_SQUARE_HIGHLIGHT,
            };

            m_styles[(int)MyGuiControlButtonStyleEnum.SquareSmall] = new StyleDefinition()
            {
                NormalTexture    = MyGuiConstants.TEXTURE_BUTTON_SQUARE_SMALL_NORMAL,
                HighlightTexture = MyGuiConstants.TEXTURE_BUTTON_SQUARE_SMALL_HIGHLIGHT,
            };

            m_styles[(int)MyGuiControlButtonStyleEnum.Error] = new StyleDefinition()
            {
                NormalTexture    = MyGuiConstants.TEXTURE_BUTTON_RED_NORMAL,
                HighlightTexture = MyGuiConstants.TEXTURE_BUTTON_RED_HIGHLIGHT,
                NormalFont       = MyFontEnum.ErrorMessageBoxText,
                HighlightFont    = MyFontEnum.White,
                Padding          = defaultPadding,
            };
        }
예제 #5
0
 public void SetPadding(MyGuiBorderThickness padding)
 {
     m_padding = padding;
 }
        static MyGuiControlGrid()
        {
            var itemPadding = new MyGuiBorderThickness(horizontal: 4f / MyGuiConstants.GUI_OPTIMAL_SIZE.X,
                                                       vertical: 3f / MyGuiConstants.GUI_OPTIMAL_SIZE.Y);
            var itemMargin = new MyGuiBorderThickness(horizontal: 2f / MyGuiConstants.GUI_OPTIMAL_SIZE.X,
                                                      vertical: 2f / MyGuiConstants.GUI_OPTIMAL_SIZE.Y);

            m_styles = new StyleDefinition[MyUtils.GetMaxValueFromEnum <MyGuiControlGridStyleEnum>() + 1];
            m_styles[(int)MyGuiControlGridStyleEnum.Default] = new StyleDefinition()
            {
                BackgroundTexture = new MyGuiCompositeTexture()
                {
                    LeftTop = new MyGuiSizedTexture(MyGuiConstants.TEXTURE_SCREEN_BACKGROUND)
                },
                BackgroundPaddingSize = MyGuiConstants.TEXTURE_SCREEN_BACKGROUND.PaddingSizeGui,
                ItemTexture           = MyGuiConstants.TEXTURE_GRID_ITEM,
                ItemFontNormal        = MyFontEnum.Blue,
                ItemFontHighlight     = MyFontEnum.White,
                ItemPadding           = itemPadding,
            };
            m_styles[(int)MyGuiControlGridStyleEnum.Toolbar] = new StyleDefinition()
            {
                ItemTexture       = MyGuiConstants.TEXTURE_GRID_ITEM,
                ItemFontNormal    = MyFontEnum.Blue,
                ItemFontHighlight = MyFontEnum.White,
                SizeOverride      = MyGuiConstants.TEXTURE_GRID_ITEM.SizeGui * new Vector2(10, 1),
                ItemMargin        = itemMargin,
                ItemPadding       = itemPadding,
                ItemTextScale     = MyGuiConstants.DEFAULT_TEXT_SCALE * 0.75f,
                FitSizeToItems    = true,
            };
            m_styles[(int)MyGuiControlGridStyleEnum.ToolsBlocks] = new StyleDefinition()
            {
                BackgroundTexture = new MyGuiCompositeTexture()
                {
                    LeftTop = new MyGuiSizedTexture(MyGuiConstants.TEXTURE_SCREEN_TOOLS_BACKGROUND_BLOCKS)
                },
                BackgroundPaddingSize = MyGuiConstants.TEXTURE_SCREEN_TOOLS_BACKGROUND_BLOCKS.PaddingSizeGui,
                ItemTexture           = MyGuiConstants.TEXTURE_GRID_ITEM,
                ItemFontNormal        = MyFontEnum.Blue,
                ItemFontHighlight     = MyFontEnum.White,
                ItemMargin            = itemMargin,
                ItemPadding           = itemPadding,
            };
            m_styles[(int)MyGuiControlGridStyleEnum.ToolsWeapons] = new StyleDefinition()
            {
                BackgroundTexture = new MyGuiCompositeTexture()
                {
                    LeftTop = new MyGuiSizedTexture(MyGuiConstants.TEXTURE_SCREEN_TOOLS_BACKGROUND_WEAPONS)
                },
                BackgroundPaddingSize = MyGuiConstants.TEXTURE_SCREEN_TOOLS_BACKGROUND_WEAPONS.PaddingSizeGui,
                ItemTexture           = MyGuiConstants.TEXTURE_GRID_ITEM,
                ItemFontNormal        = MyFontEnum.Blue,
                ItemFontHighlight     = MyFontEnum.White,
                ItemMargin            = itemMargin,
                ItemPadding           = itemPadding,
                FitSizeToItems        = true,
            };
            m_styles[(int)MyGuiControlGridStyleEnum.Inventory] = new StyleDefinition()
            {
                ItemTexture       = MyGuiConstants.TEXTURE_GRID_ITEM,
                ItemFontNormal    = MyFontEnum.Blue,
                ItemFontHighlight = MyFontEnum.White,
                ItemMargin        = itemMargin,
                ItemPadding       = itemPadding,
                SizeOverride      = new Vector2(593f, 91f) / MyGuiConstants.GUI_OPTIMAL_SIZE,
                ItemTextScale     = MyGuiConstants.DEFAULT_TEXT_SCALE * 0.8f,
                BorderEnabled     = true,
                BorderColor       = new Vector4(0.37f, 0.58f, 0.68f, 1f),
                FitSizeToItems    = true,
                ContentPadding    = new MyGuiBorderThickness(horizontal: 1f / MyGuiConstants.GUI_OPTIMAL_SIZE.X,
                                                             vertical: 2f / MyGuiConstants.GUI_OPTIMAL_SIZE.Y),
            };
        }