示例#1
0
        public MyGuiControlRotatingWheel(
            Vector2?position            = null,
            Vector4?colorMask           = null,
            float scale                 = MyGuiConstants.ROTATING_WHEEL_DEFAULT_SCALE,
            MyGuiDrawAlignEnum align    = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER,
            string texture              = MyGuiConstants.LOADING_TEXTURE,
            bool manualRotationUpdate   = true,
            bool multipleSpinningWheels = true,
            Vector2?textureResolution   = null,
            float radiansPerSecond      = 1.5f)
            : base(position: position,
                   size: null,
                   colorMask: colorMask,
                   toolTip: null,
                   isActiveControl: false)
        {
            UpdateRotation();

            m_wheelScale        = scale;
            m_texture           = texture;
            m_textureResolution = textureResolution.HasValue ? textureResolution.Value : new Vector2(256, 256);

            MultipleSpinningWheels = multipleSpinningWheels;
            ManualRotationUpdate   = manualRotationUpdate;

            m_rotationSpeed = radiansPerSecond;
        }
示例#2
0
        private unsafe void DrawDisconnectedIndicator()
        {
            MyPlayer player;

            MyPlayer.PlayerId?savedPlayer = (base.Entity as MyCharacter).SavedPlayer;
            if (((savedPlayer != null) && (savedPlayer.Value.SerialId == 0)) && !MySession.Static.Players.TryGetPlayerById(savedPlayer.Value, out player))
            {
                Vector3D vectord = (base.Entity.PositionComp.GetPosition() + (base.Entity.PositionComp.LocalAABB.Height * base.Entity.PositionComp.WorldMatrix.Up)) + (base.Entity.PositionComp.WorldMatrix.Up * 0.20000000298023224);
                double   num     = Vector3D.Distance(MySector.MainCamera.Position, vectord);
                if (num <= MAX_DISCONNECT_ICON_DISTANCE)
                {
                    Color  white     = Color.White;
                    Color *colorPtr1 = (Color *)ref white;
                    colorPtr1.A = (byte)(white.A * ((float)Math.Min(1.0, Math.Max((double)0.0, (double)((MAX_DISCONNECT_ICON_DISTANCE - num) / 10.0)))));
                    MyGuiDrawAlignEnum drawAlign = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_BOTTOM;
                    MyGuiPaddedTexture texture   = MyGuiConstants.TEXTURE_DISCONNECTED_PLAYER;
                    Vector3D           vectord2  = Vector3D.Transform(vectord, MySector.MainCamera.ViewMatrix * MySector.MainCamera.ProjectionMatrix);
                    if (vectord2.Z < 1.0)
                    {
                        Vector2 hudPos = new Vector2((float)vectord2.X, (float)vectord2.Y);
                        hudPos = (hudPos * 0.5f) + (0.5f * Vector2.One);
                        Vector2 *vectorPtr1 = (Vector2 *)ref hudPos;
                        vectorPtr1->Y = 1f - hudPos.Y;
                        Vector2 normalizedCoord = MyGuiScreenHudBase.ConvertHudToNormalizedGuiPosition(ref hudPos);
                        MyGuiManager.DrawSpriteBatch(texture.Texture, normalizedCoord, (texture.SizeGui * 0.5f) * (1f - (((float)num) / ((float)MAX_DISCONNECT_ICON_DISTANCE))), white, drawAlign, false, true);
                    }
                }
            }
        }
示例#3
0
 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)
 {
 }
        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);
        }
 // with delegate for indexed onButtonClick
 public MyGuiControlButton(IMyGuiControlsParent parent, Vector2 position, Vector2?size, Vector4 backgroundColor, MyTextsWrapperEnum textEnum,
                           Vector4 textColor, float textScale, OnIndexedButtonClick onIndexedButtonClick, int buttonIndex, MyGuiControlButtonTextAlignment textAlignment, bool canHandleKeyboardInput,
                           MyGuiDrawAlignEnum align, bool implementedFeature)
     : this(parent, position, size, backgroundColor, MyTextsWrapper.Get(textEnum), textColor, textScale, onIndexedButtonClick, buttonIndex,
            textAlignment, canHandleKeyboardInput, align, null, implementedFeature)
 {
 }
 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)
 {
 }
示例#7
0
        /// <summary>
        /// Returns coordinate within given rectangle specified by draw align. Rectangle position should be
        /// upper left corner. Conversion assumes that Y coordinates increase downwards.
        /// </summary>
        public static Vector2 GetCoordAlignedFromRectangle(ref RectangleF rect, MyGuiDrawAlignEnum drawAlign)
        {
            switch (drawAlign)
            {
            case MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP: return(rect.Position);

            case MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER: return(rect.Position + rect.Size * new Vector2(0f, 0.5f));

            case MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM: return(rect.Position + rect.Size * new Vector2(0f, 1f));

            case MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_TOP: return(rect.Position + rect.Size * new Vector2(0.5f, 0f));

            case MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER: return(rect.Position + rect.Size * 0.5f);

            case MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_BOTTOM: return(rect.Position + rect.Size * new Vector2(0.5f, 1f));

            case MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_TOP: return(rect.Position + rect.Size * new Vector2(1f, 0f));

            case MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER: return(rect.Position + rect.Size * new Vector2(1f, 0.5f));

            case MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM: return(rect.Position + rect.Size * 1f);

            default:
                throw new InvalidBranchException();
            }
        }
示例#8
0
        public MyGuiControlProgressBar(Vector2?position                        = null,
                                       Vector2?size                            = null,
                                       Color?progressBarColor                  = null,
                                       MyGuiDrawAlignEnum originAlign          = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER,
                                       MyGuiCompositeTexture backgroundTexture = null,
                                       bool isHorizontal                       = true,
                                       bool potentialBarEnabled                = true)
            : base(position: position,
                   size: size,
                   backgroundTexture: backgroundTexture,
                   originAlign: originAlign,
                   colorMask: null,
                   toolTip: null)
        {
            ProgressColor        = (progressBarColor.HasValue ? progressBarColor.Value : DEFAULT_PROGRESS_COLOR);
            IsHorizontal         = isHorizontal;
            m_progressForeground = new MyGuiControlPanel(position: new Vector2(-Size.X / 2.0f, 0.0f),
                                                         originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER,
                                                         backgroundColor: ProgressColor);
            m_progressForeground.BackgroundTexture = MyGuiConstants.TEXTURE_GUI_BLANK;

            m_potentialBar = new MyGuiControlPanel(originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER,
                                                   size: new Vector2(0f, Size.Y));
            m_potentialBar.BackgroundTexture = MyGuiConstants.TEXTURE_GUI_BLANK;
            m_potentialBar.ColorMask         = new Vector4(ProgressColor, 0.7f);
            m_potentialBar.Visible           = false;
            m_potentialBar.Enabled           = potentialBarEnabled;

            Elements.Add(m_potentialBar);
            Elements.Add(m_progressForeground);
        }
        public MyGuiControlRotatingWheel(
            Vector2? position = null,
            Vector4? colorMask = null,
            float scale = MyGuiConstants.ROTATING_WHEEL_DEFAULT_SCALE,
            MyGuiDrawAlignEnum align = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER,
            string texture = MyGuiConstants.LOADING_TEXTURE,
            bool manualRotationUpdate = true,
            bool multipleSpinningWheels = true,
            Vector2? textureResolution = null,
            float radiansPerSecond = 1.5f)
            : base(position: position,
                    size: null,
                    colorMask: colorMask,
                    toolTip: null,
                    isActiveControl: false)
        {
            UpdateRotation();

            m_wheelScale = scale;
            m_texture = texture;
            m_textureResolution = textureResolution.HasValue ? textureResolution.Value : new Vector2(256, 256);

            MultipleSpinningWheels = multipleSpinningWheels;
            ManualRotationUpdate = manualRotationUpdate;

            m_rotationSpeed = radiansPerSecond;
        }
        protected MyGuiControlBase(
            Vector2?position  = null,
            Vector2?size      = null,
            Vector4?colorMask = null,
            String toolTip    = null,
            MyGuiCompositeTexture backgroundTexture = null,
            bool isActiveControl       = true,
            bool canHaveFocus          = false,
            bool allowFocusingElements = false,
            MyGuiControlHighlightType highlightType = MyGuiControlHighlightType.WHEN_ACTIVE,
            MyGuiDrawAlignEnum originAlign          = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER)
        {
            Name                  = GetType().Name;
            Visible               = true;
            m_enabled             = true;
            m_position            = position ?? Vector2.Zero;
            m_canHaveFocus        = canHaveFocus;
            m_size                = size ?? Vector2.One;
            m_colorMask           = colorMask ?? Vector4.One;
            BackgroundTexture     = backgroundTexture;
            IsActiveControl       = isActiveControl;
            HighlightType         = highlightType;
            m_originAlign         = originAlign;
            BorderSize            = 1;
            BorderColor           = Vector4.One;
            BorderEnabled         = false;
            DrawWhilePaused       = true;
            Elements              = new MyGuiControls(this);
            AllowFocusingElements = allowFocusingElements;

            if (toolTip != null)
            {
                m_toolTip = new MyToolTips(toolTip);
            }
        }
示例#11
0
        /// <summary>
        /// Aligns rectangle, works in screen/texture/pixel coordinates, not normalized coordinates.
        /// </summary>
        /// <returns>Pixel coordinates for texture.</returns>
        public static Vector2 GetCoordAligned(Vector2 coordScreen, Vector2 size, MyGuiDrawAlignEnum drawAlign)
        {
            switch (drawAlign)
            {
            case MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP:
                return(coordScreen);

            case MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER:
                return(coordScreen - size * 0.5f);

            case MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_TOP:
                return(coordScreen - size * new Vector2(0.5f, 0.0f));

            case MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_BOTTOM:
                return(coordScreen - size * new Vector2(0.5f, 1.0f));

            case MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM:
                return(coordScreen - size);

            case MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER:
                return(coordScreen - size * new Vector2(0.0f, 0.5f));

            case MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER:
                return(coordScreen - size * new Vector2(1.0f, 0.5f));

            case MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM:
                return(coordScreen - size * new Vector2(0.0f, 1.0f));

            case MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_TOP:
                return(coordScreen - size * new Vector2(1.0f, 0.0f));

            default:
                throw new InvalidBranchException();
            }
        }
        public void DrawBottomUp(Vector2 namesBottomLeft, Vector2 valuesBottomRight, float textScale)
        {
            const MyGuiDrawAlignEnum alignNames  = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM;
            const MyGuiDrawAlignEnum alignValues = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM;
            Color color = Color.White;

            if (ShowBackgroundFog)
            {
                DrawBackgroundFog(namesBottomLeft, valuesBottomRight, topDown: false);
            }

            for (int i = Count - 1; i >= 0; --i)
            {
                var item = m_items[i];
                if (!item.Visible)
                {
                    continue;
                }

                MyGuiManager.DrawString(item.NameFont ?? DefaultNameFont, item.Name, namesBottomLeft, textScale, color, alignNames);
                MyGuiManager.DrawString(item.ValueFont ?? DefaultValueFont, item.Value, valuesBottomRight, textScale, color, alignValues);

                namesBottomLeft.Y   -= LineSpacing;
                valuesBottomRight.Y -= LineSpacing;
            }
        }
示例#13
0
        public static void DrawFog(ref Vector2 centerPosition, ref Vector2 textSize, float fogAlphaMultiplier = 1,
                                   MyGuiDrawAlignEnum alignment = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER)
        {
            Vector2 fogFadeSize = textSize * new Vector2(1.5f, 3.0f);

            DrawFogInternal(MyGuiConstants.FOG_SMALL1, ref centerPosition, ref fogFadeSize, fogAlphaMultiplier, alignment);
        }
示例#14
0
    private void DrawPerformanceWarning(int xPosition, int yPosition, MyGuiDrawAlignEnum alignment, string texturepath, float length, float width)
    {
        if (!Controls.Contains(m_warningLabel))
        {
            Controls.Add(m_warningLabel);
        }
        if (m_warningNotifications.Count != 0)
        {
            Vector2 position = MyGuiManager.ComputeFullscreenGuiCoordinate(alignment, xPosition, yPosition);
            position -= new Vector2(length / 1.5f, 0f);

            MyGuiManager.DrawSpriteBatch(Path.GetFullPath(Path.Combine(MyFileSystem.UserDataPath, texturepath)), position, new Vector2(length / 1.5f, width / 1.5f), Color.White, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER);
            StringBuilder stringBuilder = new StringBuilder();
            if (MyInput.Static.IsJoystickLastUsed)
            {
                stringBuilder.AppendFormat(MyCommonTexts.PerformanceWarningCombinationGamepad, MyControllerHelper.GetCodeForControl(MyControllerHelper.CX_BASE, MyControlsSpace.WARNING_SCREEN));
            }
            else
            {
                stringBuilder.AppendFormat(MyCommonTexts.PerformanceWarningCombination, MyGuiSandbox.GetKeyName(MyControlsSpace.HELP_SCREEN));
            }
            MyGuiManager.DrawString("White", MyTexts.GetString(m_warningNotifications[0]), position + new Vector2(0.09f, -0.011f), 0.7f, null, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER);
            MyGuiManager.DrawString("White", stringBuilder.ToString(), position + new Vector2(0.09f, 0.018f), 0.6f, null, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER);
            stringBuilder.Clear();
            MyGuiManager.DrawString("White", stringBuilder.AppendFormat("({0})", m_warningNotifications.Count).ToString(), position + new Vector2(0.177f, -0.023f), 0.55f, null, MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER);
            m_warningNotifications.RemoveAt(0);
        }
    }
示例#15
0
            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;
            }
示例#16
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);
            }
        }
示例#17
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 size of the string in normalized coordinates.
        public static void DrawString(
            MyFontEnum font,
            StringBuilder text,
            Vector2 normalizedCoord,
            float scale,
            Color?colorMask = null,
            MyGuiDrawAlignEnum drawAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
            bool fullscreen    = false,
            float maxTextWidth = float.PositiveInfinity)
        {
            var size = MeasureString(font, text, scale);

            size.X = Math.Min(maxTextWidth, size.X);
            var     topLeft        = MyUtils.GetCoordTopLeftFromAligned(normalizedCoord, size, drawAlign);
            Vector2 screenCoord    = GetScreenCoordinateFromNormalizedCoordinate(topLeft, fullscreen);
            float   screenScale    = scale * m_safeScreenScale;
            float   screenMaxWidth = GetScreenSizeFromNormalizedSize(new Vector2(maxTextWidth, 0f)).X;

#if DEBUG_TEXT_SIZE
            DebugTextSize(text, ref size);
#endif

            VRageRender.MyRenderProxy.DrawString(
                (int)font,
                screenCoord,
                colorMask ?? new Color(MyGuiConstants.LABEL_TEXT_COLOR),
                text,
                screenScale,
                screenMaxWidth);
        }
		public MyGuiControlProgressBar(	Vector2? position = null,
										Vector2? size = null,
										Color? progressBarColor = null,
										MyGuiDrawAlignEnum originAlign = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER,
										MyGuiCompositeTexture backgroundTexture = null,
										bool isHorizontal = true,
										bool potentialBarEnabled = true)
            : base( position: position,
                    size: size,
					backgroundTexture: backgroundTexture,
					originAlign: originAlign,
                    colorMask: null,
                    toolTip: null)
        {
            ProgressColor = (progressBarColor.HasValue ? progressBarColor.Value : DEFAULT_PROGRESS_COLOR);
			IsHorizontal = isHorizontal;
			m_progressForeground = new MyGuiControlPanel(	position: new Vector2(-Size.X/2.0f, 0.0f),
															originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER,
															backgroundColor: ProgressColor);
			m_progressForeground.BackgroundTexture = MyGuiConstants.TEXTURE_GUI_BLANK;

			m_potentialBar = new MyGuiControlPanel(originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER,
													size: new Vector2(0f, Size.Y));
			m_potentialBar.BackgroundTexture = MyGuiConstants.TEXTURE_GUI_BLANK;
			m_potentialBar.ColorMask = new Vector4(ProgressColor, 0.7f);
			m_potentialBar.Visible = false;
			m_potentialBar.Enabled = potentialBarEnabled;

			Elements.Add(m_potentialBar);
			Elements.Add(m_progressForeground);
        }
        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);
            }
        }                
        /// <summary>
        /// Aligns rectangle, works in screen/texture/pixel coordinates, not normalized coordinates.
        /// </summary>
        /// <returns>Pixel coordinates for texture.</returns>
        public static Vector2 GetCoordAligned(Vector2 coordScreen, Vector2 size, MyGuiDrawAlignEnum drawAlign)
        {
            switch (drawAlign)
            {
                case MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP:
                    return coordScreen;

                case MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER:
                    return coordScreen - size * 0.5f;

                case MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_TOP:
                    return coordScreen - size * new Vector2(0.5f, 0.0f);

                case MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_BOTTOM:
                    return coordScreen - size * new Vector2(0.5f, 1.0f);

                case MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM:
                    return coordScreen - size;

                case MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER:
                    return coordScreen - size * new Vector2(0.0f, 0.5f);

                case MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER:
                    return coordScreen - size * new Vector2(1.0f, 0.5f);

                case MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM:
                    return coordScreen - size * new Vector2(0.0f, 1.0f);

                case MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_TOP:
                    return coordScreen - size * new Vector2(1.0f, 0.0f);

                default:
                    throw new InvalidBranchException();
            }
        }
 public ColumnMetaData()
 {
     Name            = new StringBuilder();
     SortState       = SortStateEnum.Unsorted;
     TextAlign       = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER;
     HeaderTextAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER;
 }
        public void DrawTopDown(Vector2 namesTopLeft, Vector2 valuesTopRight, float textScale)
        {
            const MyGuiDrawAlignEnum alignNames  = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP;
            const MyGuiDrawAlignEnum alignValues = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_TOP;
            Color color = Color.White;

            if (ShowBackgroundFog)
            {
                DrawBackgroundFog(namesTopLeft, valuesTopRight, topDown: true);
            }

            for (int i = 0; i < Count; ++i)
            {
                var item = m_items[i];
                if (!item.Visible)
                {
                    continue;
                }

                MyGuiManager.DrawString(item.NameFont ?? DefaultNameFont, item.Name, namesTopLeft, textScale, color, alignNames);
                MyGuiManager.DrawString(item.ValueFont ?? DefaultValueFont, item.Value, valuesTopRight, textScale, color, alignValues);

                namesTopLeft.Y   += LineSpacing;
                valuesTopRight.Y += LineSpacing;
            }
        }
示例#23
0
        /// <summary>
        /// Computes aligned coordinate for screens without size (Size == null) with optional pixel offset from given origin.
        /// </summary>
        public static Vector2 ComputeFullscreenGuiCoordinate(MyGuiDrawAlignEnum align, int pixelOffsetX = 54, int pixelOffsetY = 54)
        {
            float deltaPixelsX = pixelOffsetX * m_safeScreenScale;
            float deltaPixelsY = pixelOffsetY * m_safeScreenScale;
            var   topLeft      = MyGuiManager.GetNormalizedCoordinateFromScreenCoordinate_FULLSCREEN(new Vector2(deltaPixelsX, deltaPixelsY));

            switch (align)
            {
            case MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP:    return(topLeft);

            case MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER: return(new Vector2(topLeft.X, 0.5f));

            case MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM: return(new Vector2(topLeft.X, 1f - topLeft.Y));

            case MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_TOP:    return(new Vector2(0.5f, topLeft.Y));

            case MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER: return(new Vector2(0.5f, 0.5f));

            case MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_BOTTOM: return(new Vector2(0.5f, 1f - topLeft.Y));

            case MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_TOP:    return(new Vector2(1f - topLeft.X, topLeft.Y));

            case MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER: return(new Vector2(1f - topLeft.X, 0.5f));

            case MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM: return(new Vector2(1f - topLeft.X, 1f - topLeft.Y));

            default:
                Debug.Fail("Invalid branch.");
                return(topLeft);
            }
        }
示例#24
0
        private static Vector2 AdjustPosition(Vector2 position, ref Vector2 textSize, ref Vector2 shadowSize, MyGuiDrawAlignEnum alignment)
        {
            // CHECK-ME: May be needed to support other alignments
            switch (alignment)
            {
                case MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER:
                {
                    // Do nothing
                    break;
                }
                case MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP:
                {
                    float diffWidth = shadowSize.X - textSize.X;
                    float diffHeight = shadowSize.Y - textSize.Y;
                    position.X -= diffWidth / 2;
                    position.Y -= diffHeight / 2;
                    break;
                }
                case MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_TOP:
                {
                    float diffWidth = shadowSize.X - textSize.X;
                    float diffHeight = shadowSize.Y - textSize.Y;
                    position.X += diffWidth / 2;
                    position.Y -= diffHeight / 2;
                    break;
                }
            }

            return position;
        }
示例#25
0
            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;
            }
        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);
            }
        }
示例#27
0
 public MyGuiControlPanel(IMyGuiControlsParent parent, Vector2 position, Vector2? size, Vector4 backgroundColor, 
     MyTexture2D texture, MyTexture2D hoverTexture, MyTexture2D pressedTexture, MyTexture2D shadowTexture, 
     MyGuiDrawAlignEnum align)
     : base(parent, position, size, backgroundColor, new StringBuilder(), 
             texture, hoverTexture, pressedTexture, false)
 {
     Visible = true;            
 }
 public MyGuiControlPanel(IMyGuiControlsParent parent, Vector2 position, Vector2?size, Vector4 backgroundColor,
                          MyTexture2D texture, MyTexture2D hoverTexture, MyTexture2D pressedTexture, MyTexture2D shadowTexture,
                          MyGuiDrawAlignEnum align)
     : base(parent, position, size, backgroundColor, new StringBuilder(),
            texture, hoverTexture, pressedTexture, false)
 {
     Visible = true;
 }
示例#29
0
        public MyGuiControlLabel(IMyGuiControlsParent parent, Vector2 position, Vector2? size, MyTextsWrapperEnum textEnum, Vector4 textColor, float textScale, MyGuiDrawAlignEnum textAlign)
            : base(parent, position, size, null, null, false)
        {
            m_type = MyGuiControlLabelType.DEFINED_BY_TEXT_WRAPPER_ENUM;

            m_textEnum = textEnum;

            Init(textColor, textScale, textAlign);
        }
示例#30
0
        public void Draw(Vector2 normalizedPosition, MyGuiDrawAlignEnum drawAlign, float backgroundAlphaFade, bool isHighlight, float colorMultiplicator = 1f)
        {
            Color drawColor = isHighlight ? HighlightColor : NormalColor;
            Vector4 vctColor = drawColor.ToVector4();
            vctColor.W *= backgroundAlphaFade;
            vctColor *= colorMultiplicator;

            MyGuiManager.DrawString(Font, Text, normalizedPosition + Offset, ScaleWithLanguage, new Color(vctColor), drawAlign);
        }
 public MyGuiControlButton(IMyGuiControlsParent parent, Vector2 position, Vector2?size, Vector4 backgroundColor, MyTextsWrapperEnum textEnum,
                           Vector4 textColor, float textScale, OnButtonClick onButtonClick, MyGuiControlButtonTextAlignment textAlignment, bool canHandleKeyboardInput,
                           MyGuiDrawAlignEnum align, bool implementedFeature, MyTextsWrapperEnum?accessForbiddenReason)
     : this(parent, position, size, backgroundColor, MyTextsWrapper.Get(textEnum), null, textColor, textScale, onButtonClick, textAlignment,
            canHandleKeyboardInput, align, implementedFeature)
 {
     m_accessForbiddenReason           = accessForbiddenReason;
     m_canHandleKeyboardActiveControl &= m_accessForbiddenReason == null;
 }
 public MyGuiControlRotatingWheel(IMyGuiControlsParent parent, Vector2 position, Vector4 color, float scale, MyGuiDrawAlignEnum align, MyTexture2D texture)
     : base(parent, position, null, null, null, false)
 {
     m_rotatingAngle = MyMwcUtils.GetRandomRadian();
     m_color         = color;
     m_wheelScale    = scale;
     //m_scale = 4;
     m_align   = align;
     m_texture = texture;
 }
 //  Text constructor
 public MyGuiControlButton(IMyGuiControlsParent parent, Vector2 position, Vector2?size, Vector4 backgroundColor, StringBuilder text, StringBuilder tooltip,
                           Vector4 textColor, float textScale, OnButtonClick onButtonClick, MyGuiControlButtonTextAlignment textAlignment, bool canHandleKeyboardInput,
                           MyGuiDrawAlignEnum align, bool implementedFeature)
     : this(parent, position, size, backgroundColor, null, null, null, onButtonClick, canHandleKeyboardInput, align, tooltip, implementedFeature, true, MyGuiControlHighlightType.WHEN_ACTIVE, null, null /*, null, null*/)
 {
     m_textColor     = textColor;
     Text            = text;
     m_textScale     = textScale;
     m_textAlignment = textAlignment;
 }
 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;
 }
示例#35
0
 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;
 }
示例#36
0
        public void Draw(Vector2 normalizedPosition, MyGuiDrawAlignEnum drawAlign, float backgroundAlphaFade, bool isHighlight, float colorMultiplicator = 1f)
        {
            Color   drawColor = isHighlight ? HighlightColor : NormalColor;
            Vector4 vctColor  = drawColor.ToVector4();

            vctColor.W *= backgroundAlphaFade;
            vctColor   *= colorMultiplicator;

            MyGuiManager.DrawString(Font, Text, normalizedPosition + Offset, ScaleWithLanguage, new Color(vctColor), drawAlign);
        }
示例#37
0
 public MyHudNotificationDebug(string text,
                               int disapearTimeMs           = 2500,
                               MyFontEnum font              = MyFontEnum.White,
                               MyGuiDrawAlignEnum textAlign = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER,
                               int priority = 0,
                               MyNotificationLevel level = MyNotificationLevel.Debug) :
     base(disapearTimeMs, font, textAlign, priority, level)
 {
     m_originalText = text;
 }
 public MyGuiControlRotatingWheel(IMyGuiControlsParent parent, Vector2 position, Vector4 color, float scale, MyGuiDrawAlignEnum align, MyTexture2D texture)
     : base(parent, position, null, null, null, false)
 {
     m_rotatingAngle = MyMwcUtils.GetRandomRadian();
     m_color = color;
     m_wheelScale = scale;
     //m_scale = 4;
     m_align = align;
     m_texture = texture;
 }
示例#39
0
            public MyGuiControlStat(MyEntityStat stat, Vector2 position, Vector2 size, MyGuiDrawAlignEnum originAlign = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER)
				: base(position: position, size: size, originAlign: originAlign)
            {
				Debug.Assert(stat != null);
				m_stat = stat;
				if(m_stat != null)
				{
					m_stat.OnStatChanged += UpdateStatText;
				}
            }
 //  Text constructor with delegate for indexed onButtonClick
 public MyGuiControlButton(IMyGuiControlsParent parent, Vector2 position, Vector2?size, Vector4 backgroundColor, StringBuilder text,
                           Vector4 textColor, float textScale, OnIndexedButtonClick onIndexedButtonClick, int buttonIndex, MyGuiControlButtonTextAlignment textAlignement, bool canHandleKeyboardInput,
                           MyGuiDrawAlignEnum align, StringBuilder tooltip, bool implementedFeature)
     : this(parent, position, size, backgroundColor, onIndexedButtonClick, buttonIndex, canHandleKeyboardInput, align, tooltip, implementedFeature, true)
 {
     m_textColor     = textColor;
     Text            = text;
     m_textScale     = textScale;
     m_textAlignment = textAlignement;
 }
示例#41
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);
        }
示例#42
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);
        }
 public void AddIcon(ColoredIcon icon, MyGuiDrawAlignEnum iconAlign = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_TOP)
 {
     if (!IconsByAlign.ContainsKey(iconAlign))
     {
         IconsByAlign.Add(iconAlign, icon);
     }
     else
     {
         IconsByAlign[iconAlign] = icon;
     }
 }
示例#44
0
        //  IMPORTANT: This class isn't initialized by constructor, but by Start() because it's supposed to be used in memory pool
        public MyHudText Start(MyFontEnum font, Vector2 position, Color color, float scale, MyGuiDrawAlignEnum alignement)
        {
            Font       = font;
            Position   = position;
            Color      = color;
            Scale      = scale;
            Alignement = alignement;

            m_text.Clear();
            return(this);
        }
示例#45
0
        protected MyGuiControlCompositePanel AddCompositePanel(MyGuiCompositeTexture texture, Vector2 position, Vector2 size, MyGuiDrawAlignEnum panelAlign)
        {
            var panel = new MyGuiControlCompositePanel()
            {
                BackgroundTexture = texture
            };
            panel.Position = position;
            panel.Size = size;
            panel.OriginAlign = panelAlign;
            Controls.Add(panel);

            return panel;
        }
示例#46
0
        public static void DrawShadow(ref Vector2 position, ref Vector2 textSize, string textureSet = null, float fogAlphaMultiplier = 1,
            MyGuiDrawAlignEnum alignment = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER)
        {
            if (textureSet == null)
                textureSet = TEXT_SHADOW_DEFAULT;

            ShadowTexture texture;
            Vector2 shadowSize = GetShadowSize(ref textSize, textureSet, out texture);
            Vector2 shadowPosition = AdjustPosition(position, ref textSize, ref shadowSize, alignment);

            Color color = new Color(0, 0, 0, (byte)(255 * texture.DefaultAlpha * fogAlphaMultiplier));
            MyGuiManager.DrawSpriteBatch(texture.Texture, shadowPosition, shadowSize, color, alignment);
        }
示例#47
0
        public MyGuiControlLabel(IMyGuiControlsParent parent, Vector2 position, Vector2? size, StringBuilder text, Vector4 textColor, float textScale, MyGuiDrawAlignEnum textAlign)
            : base(parent, position, size, null, null, false)
        {
            m_type = MyGuiControlLabelType.DEFINED_BY_STRING_BUILDER;

            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);
        }
示例#48
0
            public MyGuiControlStat(MyEntityStat stat, Vector2 position, Vector2 size, MyGuiDrawAlignEnum originAlign = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER)
				: base(position: position, size: size, originAlign: originAlign)
            {
				Debug.Assert(stat != null);
				m_stat = stat;
                var vecColor = m_stat.StatDefinition.GuiDef.CriticalColorFrom;
                m_criticalValueColorFrom = new Color(vecColor.X, vecColor.Y, vecColor.Z);
                vecColor = m_stat.StatDefinition.GuiDef.CriticalColorTo;
                m_criticalValueColorTo = new Color(vecColor.X, vecColor.Y, vecColor.Z);
				if(m_stat != null)
				{
					m_stat.OnStatChanged += UpdateStatControl;
				}
            }
示例#49
0
        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,
            string 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;
        }
 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;
 }
            public MyGuiControlStat(MyEntityStat stat, Vector2 position, Vector2 size, MyGuiDrawAlignEnum originAlign = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER)
				: base(position: position, size: size, originAlign: originAlign)
            {
				Debug.Assert(stat != null);
				m_stat = stat;
                var vecColor = m_stat.StatDefinition.GuiDef.CriticalColorFrom;
                m_criticalValueColorFrom = new Color(vecColor.X, vecColor.Y, vecColor.Z);
                vecColor = m_stat.StatDefinition.GuiDef.CriticalColorTo;
                m_criticalValueColorTo = new Color(vecColor.X, vecColor.Y, vecColor.Z);
				if(m_stat != null)
				{
					m_stat.OnStatChanged += UpdateStatControl;
                    m_stat.OnStatChanged += DisplayStatNotification;
                    m_outOfStatNotification = new MyHudNotification(MyCommonTexts.NotificationStatZero, disappearTimeMs: 1000, font: MyFontEnum.Red, level: MyNotificationLevel.Important);
                    m_outOfStatNotification.SetTextFormatArguments(m_stat.StatId.ToString());
				}
            }
示例#52
0
 public MyGuiControlPanel(
     Vector2? position = null,
     Vector2? size = null,
     Vector4? backgroundColor = null,
     string texture = null,
     String toolTip = null,
     MyGuiDrawAlignEnum originAlign = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER)
     : base(position: position,
             size: size,
             colorMask: backgroundColor,
             toolTip: toolTip,
             backgroundTexture: new MyGuiCompositeTexture() { Center = new MyGuiSizedTexture() { Texture = texture } },
             isActiveControl: false,
             originAlign: originAlign,
             highlightType: MyGuiControlHighlightType.NEVER)
 {
     Visible = true;
 }
示例#53
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)
 {
     m_forceUpdate = true;
     m_chat = chat;
     OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM;
     base.VisibleChanged += MyHudControlChat_VisibleChanged;
 }
		public MyGuiControlProgressBar(	Vector2? position = null, Vector2? size = null, Color? progressBarColor = null,
										MyGuiDrawAlignEnum originAlign = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, MyGuiCompositeTexture backgroundTexture = null, bool isHorizontal = true)
            : base( position: position,
                    size: size,
					backgroundTexture: backgroundTexture,
					originAlign: originAlign,
                    colorMask: null,
                    toolTip: null)
        {
            ProgressColor = (progressBarColor.HasValue ? progressBarColor.Value : DEFAULT_PROGRESS_COLOR);
			IsHorizontal = isHorizontal;
			var pixelHorizontal = 1.1f/MyGuiManager.GetFullscreenRectangle().Width;
			var pixelVertical = 1.1f / MyGuiManager.GetFullscreenRectangle().Height;
			m_progressForeground = new MyGuiControlPanel(	position: new Vector2(-Size.X/2.0f + pixelHorizontal, 0.0f),
															originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER,
															backgroundColor: ProgressColor);
			m_progressForeground.BackgroundTexture = MyGuiConstants.TEXTURE_GUI_BLANK;
			Elements.Add(m_progressForeground);
        }
        /// <summary>
        /// Modifies input coordinate (in center) using alignment and
        /// size of the rectangle. Result is at position inside rectangle
        /// specified by alignment.
        /// </summary>
        public static Vector2 GetCoordAlignedFromCenter(Vector2 coordCenter, Vector2 size, MyGuiDrawAlignEnum drawAlign)
        {
            switch (drawAlign)
            {
                case MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP:    return coordCenter + size * new Vector2(-0.5f, -0.5f);
                case MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER: return coordCenter + size * new Vector2(-0.5f,  0.0f);
                case MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM: return coordCenter + size * new Vector2(-0.5f,  0.5f);

                case MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_TOP:    return coordCenter + size * new Vector2(0.0f, -0.5f);
                case MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER: return coordCenter;
                case MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_BOTTOM: return coordCenter + size * new Vector2(0.0f, 0.5f);

                case MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_TOP:    return coordCenter + size * new Vector2(0.5f, -0.5f);
                case MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER: return coordCenter + size * new Vector2(0.5f,  0.0f);
                case MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM: return coordCenter + size * new Vector2(0.5f,  0.5f);

                default:
                    throw new InvalidBranchException();
            }
        }
 public MyGuiControlRotatingWheel(
     Vector2? position         = null,
     Vector4? colorMask        = null,
     float scale               = MyGuiConstants.ROTATING_WHEEL_DEFAULT_SCALE,
     MyGuiDrawAlignEnum align  = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER,
     string texture            = MyGuiConstants.LOADING_TEXTURE,
     bool manualRotationUpdate = true,
     bool multipleSpinningWheels = true)
     : base( position: position,
             size: null,
             colorMask: colorMask,
             toolTip: null,
             isActiveControl: false)
 {
     UpdateRotation();
     m_wheelScale = scale;
     m_texture = texture;
     MultipleSpinningWheels = multipleSpinningWheels;
     ManualRotationUpdate = manualRotationUpdate;
 }
示例#57
0
        public MyHudNotificationBase(
            int disapearTimeMs,
            string font = MyFontEnum.White,
            MyGuiDrawAlignEnum textAlign = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER,
            int priority                 = 0,
            MyNotificationLevel level    = MyNotificationLevel.Normal)
        {
            Font = font;
            Priority = priority;
            m_isTextDirty = true;

            m_actualTextAlign = textAlign;
            AssignFormatArgs(null);
            Level = level;

            // timing:
            m_lifespanMs = disapearTimeMs;
            m_aliveTime = 0;
            RefreshAlive();
        }
示例#58
0
 void Init(Vector4 textColor, float textScale, MyGuiDrawAlignEnum textAlign)
 {
     m_textColor = textColor;            
     m_textAlign = textAlign;
     SetTextScale(textScale);            
 }
 private MyGuiControlLabel MakeLabel(MyStringId? text = null,
     MyGuiDrawAlignEnum labelAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP)
 {
     float labelTextScale = 0.85f;
     var res = new MyGuiControlLabel(
         text: (text.HasValue) ? MyTexts.GetString(text.Value) : null,
         textScale: labelTextScale,
         originAlign: labelAlign);
     res.AutoEllipsis = true;
     return res;
 }
 public MyGuiControlCheckbox(
     Vector2? position                         = null,
     Vector4? color                            = null,
     String toolTip                     = null,
     bool isChecked                            = false,
     MyGuiControlCheckboxStyleEnum visualStyle = MyGuiControlCheckboxStyleEnum.Default,
     MyGuiDrawAlignEnum originAlign            = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER):
     base(
          position:        position ?? Vector2.Zero,
          toolTip:         toolTip,
          colorMask: color,
          isActiveControl: true,
          originAlign: originAlign,
          canHaveFocus: true)
 {
     Name = "CheckBox";
     m_isChecked = isChecked;
     VisualStyle = visualStyle;
 }