示例#1
0
        private MyGuiControlImage AddIcon(Vector2 position, string texture, Vector2 size)
        {
            var image = new MyGuiControlImage()
            {
                Position = position,
                Size     = size,
            };

            image.SetTexture(texture);
            Controls.Add(image);
            return(image);
        }
示例#2
0
        private void RecreateControls(bool contructor)
        {
            m_toolbarItemsGrid = new MyGuiControlGrid()
            {
                OriginAlign  = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM,
                VisualStyle  = MyGuiControlGridStyleEnum.Toolbar,
                ColumnsCount = MyToolbarComponent.CurrentToolbar.SlotCount + 1,
                RowsCount    = 1
            };
            m_toolbarItemsGrid.ItemDoubleClicked             += grid_ItemDoubleClicked;
            m_toolbarItemsGrid.ItemClickedWithoutDoubleClick += grid_ItemClicked;

            m_selectedItemLabel = new MyGuiControlLabel();
            m_colorVariantPanel = new MyGuiControlPanel(size: new Vector2(0.1f, 0.025f));
            m_colorVariantPanel.BackgroundTexture = MyGuiConstants.TEXTURE_GUI_BLANK;

            //grid size image (left from toolbar)
            m_gridSize             = new MyGuiControlImage(size: m_toolbarItemsGrid.ItemSize * 0.6f);
            m_gridSize.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM;
            m_gridSize.SetTexture(MyGuiConstants.TEXTURE_ICON_LARGE_BLOCK);
            m_gridSize.Visible           = false;
            m_gridSize.BackgroundTexture = MyGuiConstants.TEXTURE_GUI_BLANK;
            Elements.Add(m_gridSize);

            //grid size label (above grid size image)
            m_gridSizeLabel                   = new MyGuiControlLabel();
            m_gridSizeLabel.Text              = "";
            m_gridSizeLabel.Visible           = false;
            m_gridSizeLabel.Size              = new Vector2(m_toolbarItemsGrid.ItemSize.X * 3f, m_toolbarItemsGrid.ItemSize.Y / 2f);
            m_gridSizeLabel.OriginAlign       = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM;
            m_gridSizeLabel.BackgroundTexture = null;
            m_gridSizeLabel.TextScale         = 0.75f;
            Elements.Add(m_gridSizeLabel);

            m_contextMenu             = new MyGuiControlContextMenu();
            m_contextMenu.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM;
            m_contextMenu.Deactivate();
            m_contextMenu.ItemClicked += contextMenu_ItemClicked;

            Elements.Add(m_colorVariantPanel);
            Elements.Add(m_selectedItemLabel);
            Elements.Add(m_toolbarItemsGrid);
            Elements.Add(m_contextMenu);

            m_colorVariantPanel.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM;
            m_selectedItemLabel.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM;
            m_toolbarItemsGrid.OriginAlign  = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM;
            m_contextMenu.OriginAlign       = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM;

            RefreshInternals();
        }
示例#3
0
        public MyGuiDetailScreenBase(bool isTopMostScreen, MyGuiBlueprintScreenBase parent, string 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 MyGuiControlImage()
            {
                BackgroundTexture = MyGuiConstants.TEXTURE_RECTANGLE_DARK,
            };
            m_thumbnailImage.SetPadding(new MyGuiBorderThickness(3f, 2f, 3f, 2f));
            m_thumbnailImage.SetTexture(thumbnailTexture);

            m_selectedItem  = selectedItem;
            m_blueprintName = selectedItem.Text.ToString();
            m_textScale     = textScale;
            m_parent        = parent;
        }
示例#4
0
    private MyGuiControlBase CreateImageTooltip(string path, string text)
    {
        MyGuiControlParent myGuiControlParent = new MyGuiControlParent
        {
            OriginAlign       = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
            BackgroundTexture = new MyGuiCompositeTexture("Textures\\GUI\\Blank.dds"),
            ColorMask         = MyGuiConstants.THEMED_GUI_BACKGROUND_COLOR
        };

        myGuiControlParent.CanHaveFocus  = false;
        myGuiControlParent.HighlightType = MyGuiControlHighlightType.NEVER;
        myGuiControlParent.BorderEnabled = true;
        Vector2           vector            = new Vector2(0.005f, 0.002f);
        MyGuiControlLabel myGuiControlLabel = new MyGuiControlLabel(Vector2.Zero, null, text)
        {
            OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP
        };

        myGuiControlLabel.CanHaveFocus  = false;
        myGuiControlLabel.HighlightType = MyGuiControlHighlightType.NEVER;
        MyGuiControlImage myGuiControlImage = null;

        if (!string.IsNullOrEmpty(path))
        {
            myGuiControlImage = new MyGuiControlImage(Vector2.Zero, new Vector2(0.175625f, 0.131718755f))
            {
                OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_BOTTOM
            };
            myGuiControlImage.SetTexture(path);
            myGuiControlImage.CanHaveFocus  = false;
            myGuiControlImage.HighlightType = MyGuiControlHighlightType.NEVER;
        }
        else
        {
            myGuiControlImage = new MyGuiControlImage(Vector2.Zero, Vector2.Zero)
            {
                OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_BOTTOM
            };
        }
        myGuiControlParent.Size = new Vector2(Math.Max(myGuiControlLabel.Size.X, myGuiControlImage.Size.X) + vector.X * 2f, myGuiControlLabel.Size.Y + myGuiControlImage.Size.Y + vector.Y * 4f);
        myGuiControlParent.Controls.Add(myGuiControlImage);
        myGuiControlParent.Controls.Add(myGuiControlLabel);
        myGuiControlLabel.Position = -myGuiControlParent.Size / 2f + vector;
        myGuiControlImage.Position = new Vector2(0f, myGuiControlParent.Size.Y / 2f - vector.Y);
        return(myGuiControlParent);
    }
示例#5
0
        public override void Update()
        {
            base.Update();

            //grid size image
            if (m_gridSize.Visible && MyCubeBuilder.Static != null)
            {
                bool newSizeLarge = MyCubeBuilder.Static.CubeBuilderState.CubeSizeMode == MyCubeSize.Large;
                if (newSizeLarge != m_gridSizeLargeBlock)
                {
                    m_gridSizeLargeBlock = newSizeLarge;
                    m_gridSize.SetTexture(newSizeLarge ? MyGuiConstants.TEXTURE_ICON_LARGE_BLOCK : MyGuiConstants.TEXTURE_ICON_SMALL_BLOCK);
                }
            }

            //grid size label
            bool showLabel = m_gridSize.Visible && MySandboxGame.Config.ShowBuildingSizeHint;

            if (m_gridSizeLabel.Visible != showLabel)
            {
                m_gridSizeLabel.Visible = showLabel;
            }
        }