Beispiel #1
0
        public override void Init(MyObjectBuilder_GuiControlBase objectBuilder)
        {
            base.Init(objectBuilder);

            var buttonObjectBuilder = (MyObjectBuilder_GuiControlButton)objectBuilder;

            Text          = buttonObjectBuilder.Text;
            m_textEnum    = MyStringId.GetOrCompute(buttonObjectBuilder.TextEnum);
            TextScale     = buttonObjectBuilder.TextScale;
            TextAlignment = (MyGuiDrawAlignEnum)buttonObjectBuilder.TextAlignment;
            DrawCrossTextureWhenDisabled = buttonObjectBuilder.DrawCrossTextureWhenDisabled;
            VisualStyle = buttonObjectBuilder.VisualStyle;

            UpdateText();
        }
Beispiel #2
0
        public MyGuiControlButton(
            Vector2?position = null,
            MyGuiControlButtonStyleEnum visualStyle = MyGuiControlButtonStyleEnum.Default,
            Vector2?size      = null,
            Vector4?colorMask = null,
            MyGuiDrawAlignEnum originAlign = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER,
            String toolTip     = null,
            StringBuilder text = null,
            float textScale    = MyGuiConstants.DEFAULT_TEXT_SCALE,
            MyGuiDrawAlignEnum textAlignment        = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER,
            MyGuiControlHighlightType highlightType = MyGuiControlHighlightType.WHEN_ACTIVE,
            bool implementedFeature = true,
            Action <MyGuiControlButton> onButtonClick = null,
            GuiSounds cueEnum           = GuiSounds.MouseClick,
            float buttonScale           = 1.0f,
            int?buttonIndex             = null,
            bool activateOnMouseRelease = false)
            : base(position :        position ?? Vector2.Zero,
                   size :            size,
                   colorMask :       colorMask ?? MyGuiConstants.BUTTON_BACKGROUND_COLOR,
                   toolTip :         toolTip,
                   highlightType :   highlightType,
                   originAlign :     originAlign,
                   canHaveFocus :    implementedFeature)
        {
            Name                 = "Button";
            ButtonClicked        = onButtonClick;
            Index                = buttonIndex ?? 0;
            m_implementedFeature = implementedFeature;
            UpdateText();

            m_drawText.Clear().Append(text);
            TextScale     = textScale;
            TextAlignment = textAlignment;

            VisualStyle = visualStyle;
            m_cueEnum   = cueEnum;
            m_activateOnMouseRelease = activateOnMouseRelease;

            ButtonScale = buttonScale;

            Size *= ButtonScale;
        }
Beispiel #3
0
 public static StyleDefinition GetVisualStyle(MyGuiControlButtonStyleEnum style)
 {
     return(m_styles[(int)style]);
 }
        public override void Init(MyObjectBuilder_GuiControlBase objectBuilder)
        {
            base.Init(objectBuilder);

            var buttonObjectBuilder = (MyObjectBuilder_GuiControlButton)objectBuilder;

            Text                         = buttonObjectBuilder.Text;
            m_textEnum                   = MyStringId.GetOrCompute(buttonObjectBuilder.TextEnum);
            TextScale                    = buttonObjectBuilder.TextScale;
            TextAlignment                = (MyGuiDrawAlignEnum)buttonObjectBuilder.TextAlignment;
            DrawCrossTextureWhenDisabled = buttonObjectBuilder.DrawCrossTextureWhenDisabled;
            VisualStyle                  = buttonObjectBuilder.VisualStyle;

            UpdateText();
        }
        public MyGuiControlButton(
            Vector2? position                         = null,
            MyGuiControlButtonStyleEnum visualStyle   = MyGuiControlButtonStyleEnum.Default,
            Vector2? size                             = null,
            Vector4? colorMask                        = null,
            MyGuiDrawAlignEnum originAlign            = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER,
            String toolTip                     = null,
            StringBuilder text                        = null,
            float textScale                           = MyGuiConstants.DEFAULT_TEXT_SCALE,
            MyGuiDrawAlignEnum textAlignment          = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER,
            MyGuiControlHighlightType highlightType   = MyGuiControlHighlightType.WHEN_ACTIVE,
            bool implementedFeature                   = true,
            Action<MyGuiControlButton> onButtonClick  = null,
            GuiSounds cueEnum                   = GuiSounds.MouseClick,
            float buttonScale                         = 1.0f,
            int? buttonIndex = null,
            bool activateOnMouseRelease               = false)
            : base( position:        position ?? Vector2.Zero,
                    size:            size,
                    colorMask:       colorMask ?? MyGuiConstants.BUTTON_BACKGROUND_COLOR,
                    toolTip:         toolTip,
                    highlightType:   highlightType,
                    originAlign:     originAlign,
                    canHaveFocus:    implementedFeature)
        {
            Name                             = "Button";
            ButtonClicked                    = onButtonClick;
            Index                            = buttonIndex ?? 0;
            m_implementedFeature             = implementedFeature;
            UpdateText();

            m_drawText.Clear().Append(text);
            TextScale = textScale;
            TextAlignment = textAlignment;

            VisualStyle = visualStyle;
            m_cueEnum = cueEnum;
            m_activateOnMouseRelease = activateOnMouseRelease;

            ButtonScale = buttonScale;

            Size *= ButtonScale;
        }
 public static StyleDefinition GetVisualStyle(MyGuiControlButtonStyleEnum style)
 {
     return m_styles[(int)style];
 }