Example #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);
        }
        public MyGuiControlCampaignButton(string title, string imagePath)
        {
            IsWorkshopMod = false;
            IsLocalMod    = false;
            VisualStyle   = MyGuiControlRadioButtonStyleEnum.ScenarioButton;
            OriginAlign   = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP;

            m_titleLabel = new MyGuiControlLabel()
            {
                OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                Text        = title
            };

            m_previewImage = new MyGuiControlImage(textures: new [] { imagePath })
            {
                OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP
            };

            m_workshopIconNormal = new MyGuiControlImage(textures: new[] { MyGuiConstants.TEXTURE_ICON_MODS_WORKSHOP.Normal })
            {
                OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM,
                Size        = MyGuiConstants.TEXTURE_ICON_MODS_WORKSHOP.SizeGui
            };

            m_workshopIconHighlight = new MyGuiControlImage(textures: new[] { MyGuiConstants.TEXTURE_ICON_MODS_WORKSHOP.Highlight })
            {
                OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM,
                Size        = MyGuiConstants.TEXTURE_ICON_MODS_WORKSHOP.SizeGui
            };

            m_localmodIconNormal = new MyGuiControlImage(textures: new[] { MyGuiConstants.TEXTURE_ICON_MODS_LOCAL.Normal })
            {
                OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM,
                Size        = MyGuiConstants.TEXTURE_ICON_MODS_WORKSHOP.SizeGui
            };

            m_localmodIconHighlight = new MyGuiControlImage(textures: new[] { MyGuiConstants.TEXTURE_ICON_MODS_LOCAL.Highlight })
            {
                OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM,
                Size        = MyGuiConstants.TEXTURE_ICON_MODS_WORKSHOP.SizeGui
            };

            m_previewImage.Size          = new Vector2(229f, 128f) / MyGuiConstants.GUI_OPTIMAL_SIZE;
            m_previewImage.BorderEnabled = true;
            m_previewImage.BorderColor   = MyGuiConstants.THEMED_GUI_LINE_COLOR.ToVector4();

            Size = new Vector2(m_previewImage.Size.X,
                               m_titleLabel.Size.Y + m_previewImage.Size.Y);

            Elements.Add(m_titleLabel);
            Elements.Add(m_previewImage);
        }
Example #3
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();
        }
Example #4
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;
        }
Example #5
0
        private void AddSeparator(string sectionName)
        {
            var panel = new MyGuiControlCompositePanel()
            {
                BackgroundTexture = MyGuiConstants.TEXTURE_RECTANGLE_DARK,
                OriginAlign       = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                Position          = Vector2.Zero
            };

            var label = new MyGuiControlLabel()
            {
                OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                Text        = sectionName,
                Font        = MyFontEnum.Blue,
                PositionX   = 0.005f
            };

            var imageOffset = 0.003f;
            var colorMask   = MyGuiConstants.THEMED_GUI_LINE_COLOR;
            var img         = new MyGuiControlImage(textures: new[] { @"Textures\GUI\FogSmall3.dds" })
            {
                Size        = new Vector2(label.Size.X + imageOffset * 10, 0.007f),
                OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                //ColorMask = new Vector4(0,0,0,1),
                ColorMask = colorMask.ToVector4(),
                Position  = new Vector2(-imageOffset, label.Size.Y)
            };

            var parent = new MyGuiControlParent
            {
                Size        = new Vector2(m_campaignList.Size.X, label.Size.Y),
                OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                Position    = Vector2.Zero
            };

            panel.Size = parent.Size + new Vector2(-0.035f, 0.01f);

            panel.Position -= parent.Size / 2 - new Vector2(-0.01f, 0f);
            label.Position -= parent.Size / 2;
            img.Position   -= parent.Size / 2;

            parent.Controls.Add(panel);
            parent.Controls.Add(img);
            parent.Controls.Add(label);

            m_campaignList.Controls.Add(parent);
        }
Example #6
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);
    }
        public sealed override void RecreateControls(bool constructor)
        {
            Elements.Clear();

            this.m_backgroundTexture = MyGuiConstants.TEXTURE_MESSAGEBOX_BACKGROUND_INFO.Texture;
            this.m_backgroundColor   = new Vector4(0, 0, 0, 0.5f);     // Grey, half opacity
            this.m_size     = new Vector2(_screenScale, 0.5f);         // Half the screen, drop down from the top
            this.m_position = new Vector2(0.5f, 0.25f);                // HorizontalCenter / Quarter vertical

            base.RecreateControls(constructor);

            Vector4 value     = new Vector4(1f, 1f, 1f, 1f);
            float   textScale = 1f;

            _textBox             = new MyGuiControlTextbox(new Vector2?(new Vector2(0f, 0.25f)), null, 512, new Vector4?(value), 0.8f, MyGuiControlTextboxType.Normal, MyGuiControlTextboxStyleEnum.Default);
            _textBox.Position   -= new Vector2(0f, _textBox.Size.Y + _margin.Y / 2f);
            _textBox.Size        = new Vector2(_screenScale, _textBox.Size.Y) - 2f * _margin;
            _textBox.ColorMask   = new Vector4(0f, 0f, 0f, 0.5f);
            _textBox.VisualStyle = MyGuiControlTextboxStyleEnum.Default;
            _textBox.Name        = "HaE CMD";

            _displayScreen             = new MyGuiControlMultilineText(new Vector2?(new Vector2(-0.5f * _screenScale, -0.25f) + _margin), new Vector2?(new Vector2(_screenScale, 0.5f - _textBox.Size.Y) - 2f * _margin), null, "Debug", 0.8f, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, null, true, true, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, null, true, false, null, null);
            _displayScreen.TextColor   = Color.White;
            _displayScreen.TextScale   = textScale;
            _displayScreen.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP;
            _displayScreen.Text        = HaEConsole.Instance.displayScreen;
            _displayScreen.ColorMask   = new Vector4(0f, 0f, 0f, 0.5f);
            _displayScreen.Name        = "DisplayScreen";

            _logo = new MyGuiControlImage(new Vector2?(new Vector2(0.46f * _screenScale, -0.24f)), new Vector2?(new Vector2(0.05f, _screenScale * 0.05f)), null, null, new string[]
            {
                $"{HaEConstants.pluginFolder}\\Assets\\logo.png"
            }, null, MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_TOP);
            _logo.ColorMask = new Vector4(1f, 1f, 1f, 0.5f);
            _logo.SetToolTip("HaE PluginCore");

            this.Controls.Add(_textBox);
            this.Controls.Add(_displayScreen);
            this.Controls.Add(_logo);
        }
Example #8
0
        public MyGuiControlScenarioButton(MyScenarioDefinition scenario) :
            base(key: MyDefinitionManager.Static.GetScenarioDefinitions().IndexOf(scenario))
        {
            VisualStyle    = MyGuiControlRadioButtonStyleEnum.ScenarioButton;
            OriginAlign    = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP;
            Scenario       = scenario;
            m_titleLabel   = new MyGuiControlLabel(text: scenario.DisplayNameText, originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP);
            m_previewImage = new MyGuiControlImage(textures: scenario.Icons, originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP);
            MyGuiSizedTexture image = new MyGuiSizedTexture()
            {
                SizePx = new Vector2(229f, 128f),
            };

            m_previewImage.Size          = image.SizeGui;
            m_previewImage.BorderEnabled = true;
            m_previewImage.BorderColor   = MyGuiConstants.THEMED_GUI_LINE_COLOR.ToVector4();
            SetToolTip(scenario.DescriptionText);
            Size = new Vector2(Math.Max(m_titleLabel.Size.X, m_previewImage.Size.X),
                               m_titleLabel.Size.Y + m_previewImage.Size.Y);
            Elements.Add(m_titleLabel);
            Elements.Add(m_previewImage);
        }
Example #9
0
        private MyGuiControlTable.Cell CreateStatusIcons(CubeGridInfo gridInfo, bool isActive)
        {
            MyGuiControlTable.Cell cell = new MyGuiControlTable.Cell();
            float iconSize = m_shipsData.RowHeight * 0.7f;

            bool antIsActive, keyIsActive, remIsActive;

            antIsActive = keyIsActive = remIsActive = isActive;
            MyStringId antTooltip, remTooltip;

            antTooltip = remTooltip = MyStringId.NullOrEmpty;
            StringBuilder keyTooltip = new StringBuilder();

            MyGuiControlParent gr = new MyGuiControlParent();

            MyRefuseReason reasonT  = CanTakeTerminal(gridInfo);
            MyRefuseReason reasonRC = CanTakeRemoteControl(gridInfo);

            //Antenna icon
            switch (reasonT)
            {
            case MyRefuseReason.PlayerBroadcastOff:
                antIsActive = false;
                antTooltip  = MySpaceTexts.BroadcastScreen_TerminalButton_PlayerBroadcastOffToolTip;
                break;

            case MyRefuseReason.NoStableConnection:
                antIsActive = false;
                antTooltip  = MySpaceTexts.BroadcastScreen_TerminalButton_NoStableConnectionToolTip;
                break;

            case MyRefuseReason.NoOwner:
            case MyRefuseReason.NoProblem:
                antTooltip = MySpaceTexts.BroadcastScreen_TerminalButton_StableConnectionToolTip;
                break;
            }
            MyGuiControlImage antenna = new MyGuiControlImage(
                position: new Vector2(-2 * iconSize, 0),
                size: new Vector2(iconSize, iconSize),
                originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER,
                backgroundTexture: (antIsActive ? MyGuiConstants.BS_ANTENNA_ON : MyGuiConstants.BS_ANTENNA_OFF)
                );

            antenna.SetToolTip(antTooltip);
            gr.Controls.Add(antenna);

            //Remote Control icon
            switch (reasonRC)
            {
            case MyRefuseReason.NoRemoteControl:
                remTooltip  = MySpaceTexts.BroadcastScreen_TakeControlButton_NoRemoteToolTip;
                remIsActive = false;
                break;

            case MyRefuseReason.NoMainRemoteControl:
                remTooltip  = MySpaceTexts.BroadcastScreen_TakeControlButton_NoMainRemoteControl;
                remIsActive = false;
                break;

            case MyRefuseReason.NoOwner:
            case MyRefuseReason.NoProblem:
                remTooltip = MySpaceTexts.BroadcastScreen_TakeControlButton_RemoteToolTip;
                break;
            }
            MyGuiControlImage remote = new MyGuiControlImage(
                position: new Vector2(-1 * iconSize, 0),
                size: new Vector2(iconSize, iconSize),
                originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER,
                backgroundTexture: (remIsActive ? MyGuiConstants.BS_REMOTE_ON : MyGuiConstants.BS_REMOTE_OFF)
                );

            remote.SetToolTip(remTooltip);
            gr.Controls.Add(remote);

            //Key icon
            if ((reasonT == MyRefuseReason.NoStableConnection || reasonT == MyRefuseReason.PlayerBroadcastOff) && reasonRC == MyRefuseReason.NoRemoteControl)
            {
                keyTooltip.Append(MyTexts.Get(MySpaceTexts.BroadcastScreen_UnavailableControlButton));
                keyIsActive = false;
            }
            if (keyIsActive && (reasonT == MyRefuseReason.NoOwner || reasonRC == MyRefuseReason.NoOwner || reasonT == MyRefuseReason.NoStableConnection || reasonT == MyRefuseReason.PlayerBroadcastOff))
            {
                keyIsActive = false;
                keyTooltip.Append(MyTexts.Get(MySpaceTexts.BroadcastScreen_NoOwnership));
            }
            if (reasonT == MyRefuseReason.NoOwner)
            {
                keyTooltip.AppendLine();
                keyTooltip.Append(MyTexts.Get(MySpaceTexts.DisplayName_Block_Antenna));
            }
            if (reasonRC == MyRefuseReason.NoOwner)
            {
                keyTooltip.AppendLine();
                keyTooltip.Append(MyTexts.Get(MySpaceTexts.DisplayName_Block_RemoteControl));
            }
            if (keyIsActive)
            {
                keyTooltip.Append(MyTexts.Get(MySpaceTexts.BroadcastScreen_Ownership));
            }
            MyGuiControlImage key = new MyGuiControlImage(
                size: new Vector2(iconSize, iconSize),
                originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER,
                backgroundTexture: (keyIsActive ? MyGuiConstants.BS_KEY_ON : MyGuiConstants.BS_KEY_OFF)
                );

            key.SetToolTip(keyTooltip.ToString());
            gr.Controls.Add(key);


            cell.Control = gr;
            m_shipsData.Controls.Add(gr);
            return(cell);
        }