Exemplo n.º 1
0
        /// <summary>
        /// Creates a new instance of a MyGuiControlRanged slider with given parameters
        /// </summary>
        /// <param name="position">The position of the slider in screenspace</param>
        /// <param name="width">The width of the slider in screenspace</param>
        /// <param name="minValue">The minimum value of the slider</param>
        /// <param name="maxValue">The maximum value of the slider</param>
        /// <param name="showLabel">Whether to show a label with the sliders values</param>
        /// <param name="labelSpaceWidth">The space between label and slider</param>
        /// <param name="labelScale">The size of the labels text</param>
        /// <param name="labelFont">The font of the label</param>
        /// <param name="toolTip">The tooltip for the slider</param>
        /// <param name="originAlign">The alignment of the slider</param>
        /// <param name="useLogScale">Whether to use logarithmic scaling of values on the slider to allow for wider ranges</param>
        /// <param name="defaultMax">Default max value</param>
        /// <param name="defaultMin">Default min value</param>
        /// <param name="intMode">If the slider should work in int mode</param>
        public MyGuiControlRangedSlider(double minValue, double maxValue, double defaultMin, double defaultMax, bool intMode = false, Vector2?position = null, float width = 0.29f, bool showLabel = true, float labelSpaceWidth = 0f, float labelScale = 0.8f, string labelFont = "White", string toolTip = null, MyGuiDrawAlignEnum originAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER, bool useLogScale = false) :
            base(position, null, null, toolTip, null, true, true, MyGuiControlHighlightType.WHEN_CURSOR_OVER_OR_FOCUS, originAlign)
        {
            m_showLabel       = showLabel;
            m_minValue        = Math.Min(minValue, maxValue);
            m_maxValue        = Math.Max(maxValue, minValue);
            m_labelSpaceWidth = labelSpaceWidth;

            m_railTexture = MyGuiConstants.TEXTURE_SLIDER_RAIL;
            m_minThumb    = new MyGuiSliderThumb(defaultMin);
            m_maxThumb    = new MyGuiSliderThumb(defaultMax);

            m_intMode = intMode;

            m_logScale = useLogScale;

            m_minLabel = new MyGuiControlLabel(null, null, "", null, labelScale, labelFont, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM);
            m_maxLabel = new MyGuiControlLabel(null, null, "", null, labelScale, labelFont, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP);
            if (m_showLabel)
            {
                Elements.Add(m_minLabel);
                Elements.Add(m_maxLabel);
            }
            Size = new Vector2(width, Size.Y);
            UpdateLabels();
            RefreshInternals();
        }
Exemplo n.º 2
0
        public void SetTexture(string texture)
        {
            if (m_borderTexture != null)
            {
                BackgroundTexture = new MyGuiCompositeTexture()
                {
                    CenterBottom = m_borderTexture.CenterBottom,
                    CenterTop    = m_borderTexture.CenterTop,
                    LeftBottom   = m_borderTexture.LeftBottom,
                    LeftTop      = m_borderTexture.LeftTop,
                    LeftCenter   = m_borderTexture.LeftCenter,

                    RightBottom = m_borderTexture.RightBottom,
                    RightCenter = m_borderTexture.RightCenter,
                    RightTop    = m_borderTexture.RightTop,
                    Center      = new MyGuiSizedTexture()
                    {
                        Texture = texture,
                    },
                };
            }
            else
            {
                BackgroundTexture = new MyGuiCompositeTexture()
                {
                    Center = new MyGuiSizedTexture()
                    {
                        Texture = texture,
                    },
                };
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Refreshes textures and sizes
        /// </summary>
        private void RefreshInternals()
        {
            if (HasHighlight)
            {
                m_railTexture = MyGuiConstants.TEXTURE_SLIDER_RAIL_HIGHLIGHT;
                if (m_maxThumb.GetBounds(GetPositionAbsoluteTopLeft()).Contains(MyGuiManager.MouseCursorPosition) != ContainmentType.Disjoint)
                {
                    m_maxThumb.HighlightThumb();
                }
                else
                {
                    m_maxThumb.ResetThumbAppearance();
                }
                if (m_minThumb.GetBounds(GetPositionAbsoluteTopLeft()).Contains(MyGuiManager.MouseCursorPosition) != ContainmentType.Disjoint)
                {
                    m_minThumb.HighlightThumb();
                }
                else
                {
                    m_minThumb.ResetThumbAppearance();
                }
            }
            else if (HasFocus)
            {
                m_railTexture = MyGuiConstants.TEXTURE_SLIDER_RAIL_FOCUS;
            }
            else
            {
                m_railTexture = MyGuiConstants.TEXTURE_SLIDER_RAIL;
                m_minThumb.ResetThumbAppearance();
                m_maxThumb.ResetThumbAppearance();
            }

            MinSize             = new Vector2(m_railTexture.MinSizeGui.X + m_labelSpaceWidth, Math.Max(m_railTexture.MinSizeGui.Y, m_minLabel.Size.Y + m_maxLabel.Size.Y));
            MaxSize             = new Vector2(m_railTexture.MaxSizeGui.X + m_labelSpaceWidth, Math.Max(m_railTexture.MaxSizeGui.Y, m_minLabel.Size.Y + m_maxLabel.Size.Y));
            m_minLabel.Position = new Vector2(Size.X * 0.5f, 0f);
            m_maxLabel.Position = new Vector2(Size.X * 0.5f, 0f);

            float startX   = MyGuiConstants.SLIDER_INSIDE_OFFSET_X;
            float endX     = Size.X - MyGuiConstants.SLIDER_INSIDE_OFFSET_X;
            float centerY  = Size.Y / 2;
            float minRatio = (float)((m_minThumb.CurrentValue - m_minValue) / (m_maxValue - m_minValue));
            float maxRatio = (float)((m_maxThumb.CurrentValue - m_minValue) / (m_maxValue - m_minValue));

            if (m_logScale)
            {
                minRatio = (float)Math.Pow(minRatio, 1f / 3f);
                maxRatio = (float)Math.Pow(maxRatio, 1f / 3f);
            }

            m_minThumb.CurrentPosition = new Vector2(MathHelper.Lerp(startX, endX, minRatio), centerY);
            m_maxThumb.CurrentPosition = new Vector2(MathHelper.Lerp(startX, endX, maxRatio), centerY);
        }
Exemplo n.º 4
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);
        }
Exemplo n.º 5
0
 public MyGuiControlQuestlog(Vector2 position)
 {
     if (MyGuiManager.FullscreenHudEnabled)
     {
         m_position = MyGuiManager.GetNormalizedCoordinateFromScreenCoordinate_FULLSCREEN(position);
     }
     else
     {
         m_position = MyGuiManager.GetNormalizedCoordinateFromScreenCoordinate(position);
     }
     Size                    = MyHud.Questlog.QuestlogSize;
     Position                = m_position + this.Size / 2;
     BackgroundTexture       = new MyGuiCompositeTexture(MyGuiConstants.TEXTURE_MESSAGEBOX_BACKGROUND_INFO.Texture);
     QuestInfo               = MyHud.Questlog;
     VisibleChanged         += VisibilityChanged;
     QuestInfo.ValueChanged += QuestInfo_ValueChanged;
 }
Exemplo n.º 6
0
 public MyGuiControlImageButton(bool visible = true)
 {
     BackgroundTexture = new MyGuiCompositeTexture();
     Visible           = visible;
     HighlightType     = MyGuiControlHighlightType.NEVER;
 }
Exemplo n.º 7
0
 public MyGuiDetailScreenBase(bool isTopMostScreen, MyGuiBlueprintScreenBase parent, MyGuiCompositeTexture thumbnailTexture, MyGuiControlListbox.Item selectedItem, float textScale)
     : base(new Vector2(0.37f, 0.325f), new Vector2(0.725f, 0.4f), MyGuiConstants.SCREEN_BACKGROUND_COLOR, isTopMostScreen)
 {
     m_thumbnailImage = new MyGuiControlImageButton(true);
     if (thumbnailTexture == null)
     {
         m_thumbnailImage.Visible = false;
     }
     else
     {
         m_thumbnailImage.BackgroundTexture = thumbnailTexture;
     }
     m_selectedItem  = selectedItem;
     m_blueprintName = selectedItem.Text.ToString();
     m_textScale     = textScale;
     m_parent        = parent;
 }
Exemplo n.º 8
0
        public MyGuiDetailScreenLocal(Action <MyGuiControlListbox.Item> callBack, MyGuiControlListbox.Item selectedItem, MyGuiBlueprintScreenBase parent, MyGuiCompositeTexture thumbnailTexture, float textScale) :
            base(false, parent, thumbnailTexture, selectedItem, textScale)
        {
            var prefabPath = Path.Combine(m_localBlueprintFolder, m_blueprintName, "bp.sbc");

            this.callBack = callBack;

            if (File.Exists(prefabPath))
            {
                m_loadedPrefab = LoadPrefab(prefabPath);

                if (m_loadedPrefab == null)
                {
                    MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(
                                               buttonType: MyMessageBoxButtonsType.OK,
                                               styleEnum: MyMessageBoxStyleEnum.Error,
                                               messageCaption: new StringBuilder("Error"),
                                               messageText: new StringBuilder("Failed to load the blueprint file.")
                                               ));
                    m_killScreen = true;
                }
                else
                {
                    RecreateControls(true);
                }
            }
            else
            {
                m_killScreen = true;
            }
        }
Exemplo n.º 9
0
        public MyGuiDetailScreenSteam(Action <MyGuiControlListbox.Item> callBack, MyGuiControlListbox.Item selectedItem, MyGuiBlueprintScreen parent, MyGuiCompositeTexture thumbnailTexture, float textScale) :
            base(false, parent, thumbnailTexture, selectedItem, textScale)
        {
            this.callBack = callBack;

            m_publishedItemId = (selectedItem.UserData as MyBlueprintItemInfo).PublishedItemId;

            var prefabPath = Path.Combine(m_workshopBlueprintFolder, m_publishedItemId.ToString() + m_workshopBlueprintSuffix);

            if (File.Exists(prefabPath))
            {
                m_loadedPrefab = LoadWorkshopPrefab(prefabPath, m_publishedItemId);

                Debug.Assert(m_loadedPrefab != null);
                if (m_loadedPrefab == null)
                {
                    m_killScreen = true;
                }
                else
                {
                    var name = m_loadedPrefab.ShipBlueprints[0].CubeGrids[0].DisplayName;
                    if (name.Length > 40)
                    {
                        var newName = name.Substring(0, 40);
                        m_loadedPrefab.ShipBlueprints[0].CubeGrids[0].DisplayName = newName;
                    }
                    RecreateControls(true);
                }
            }
            else
            {
                m_killScreen = true;
            }
        }