protected override void OnSizeChanged()
        {
            if (m_currentBlocks.Length == 0)
            {
                return;
            }

            var     topLeftRelative = Size * -0.5f;
            Vector2 leftColumnSize  = new Vector2(0.3f, 0.55f);

            m_separatorList.Clear();
            m_separatorList.AddHorizontal(topLeftRelative, Size.X);
            m_separatorList.AddVertical(topLeftRelative + new Vector2(leftColumnSize.X, 0), Size.Y);
            m_separatorList.AddHorizontal(topLeftRelative + new Vector2(leftColumnSize.X + 0.008f, 0.18f), leftColumnSize.X * 0.96f);//above ownership


            m_terminalControlList.Position = topLeftRelative + new Vector2(leftColumnSize.X * 0.5f, 0.01f);
            m_terminalControlList.Size     = new Vector2(leftColumnSize.X, 0.625f);

            float propertiesOffset = 0.06f;

            if (MyFakes.SHOW_FACTIONS_GUI)
            {
                foreach (var block in m_currentBlocks)
                {
                    if (block.IDModule != null)
                    {
                        propertiesOffset = 0.22f;
                        m_separatorList.AddHorizontal(topLeftRelative + new Vector2(leftColumnSize.X + 0.008f, propertiesOffset + 0.11f), leftColumnSize.X * 0.96f);
                        break;
                    }
                }
            }

            m_blockPropertiesMultilineText.Position = topLeftRelative + new Vector2(leftColumnSize.X + 0.008f, propertiesOffset + 0.12f);
            m_blockPropertiesMultilineText.Size     = 0.5f * Size - m_blockPropertiesMultilineText.Position;

            base.OnSizeChanged();
        }
        private static void AddSeparator(MyGuiControlList list)
        {
            var separator = new MyGuiControlSeparatorList();
            separator.Size = new Vector2(1, 0.01f);
            separator.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_TOP;
            separator.AddHorizontal(Vector2.Zero, 1);

            list.Controls.Add(separator);
        }
        private void RecreateServerLimitInfo(MyGuiControlList list)
        {
            var identity = MySession.Static.Players.TryGetIdentity(MySession.Static.LocalPlayerId);
            int built;

            if (MySession.Static.MaxBlocksPerPlayer > 0 || MySession.Static.BlockTypeLimits.Keys.Count > 0)
            {
                MyGuiControlLabel totalBlocksLabel = new MyGuiControlLabel(text: MyTexts.GetString(MySpaceTexts.TerminalTab_Info_Overview), textScale: 1.3f);
                list.Controls.Add(totalBlocksLabel);
            }

            if (MySession.Static.MaxBlocksPerPlayer > 0)
            {
                MyGuiControlLabel totalBlocksLabel = new MyGuiControlLabel(text: String.Format("{0} {1}/{2} {3}", MyTexts.Get(MySpaceTexts.TerminalTab_Info_YouBuilt), identity.BlocksBuilt, MySession.Static.MaxBlocksPerPlayer + identity.BlockLimitModifier, MyTexts.Get(MySpaceTexts.TerminalTab_Info_BlocksLower)));
                list.Controls.Add(totalBlocksLabel);
            }
            foreach (var blockType in MySession.Static.BlockTypeLimits)
            {
                identity.BlockTypeBuilt.TryGetValue(blockType.Key, out built);
                var definition = Sandbox.Definitions.MyDefinitionManager.Static.TryGetDefinitionGroup(blockType.Key);
                if (definition == null)
                    continue;
                MyGuiControlLabel blockTypeLabel = new MyGuiControlLabel(text: String.Format("{0} {1}/{2} {3}", MyTexts.Get(MySpaceTexts.TerminalTab_Info_YouBuilt), built, MySession.Static.GetBlockTypeLimit(blockType.Key), definition.Any.DisplayNameText));
                list.Controls.Add(blockTypeLabel);
            }

            foreach (var grid in m_infoGrids)
            {
                grid.OnAuthorshipChanged -= grid_OnAuthorshipChanged;
            }

            m_infoGrids.Clear();
            identity.LockBlocksBuiltByGrid.AcquireExclusive();
            for (int i = 0; i < identity.BlocksBuiltByGrid.Count; i++)
            {
                var grid = identity.BlocksBuiltByGrid.ElementAt(i);
                MyGuiControlParent panel = new MyGuiControlParent();

                if (m_infoGrids.Count == 0)
                {
                    MyGuiControlSeparatorList infoSeparator = new MyGuiControlSeparatorList();
                    infoSeparator.AddHorizontal(new Vector2(-0.2f, -0.052f), 0.4f, width: 0.004f);
                    panel.Controls.Add(infoSeparator);
                }

                MyGuiControlLabel gridNameLabel = new MyGuiControlLabel(text: grid.Key.DisplayName, textScale: 0.9f);
                MyGuiControlLabel gridBlockCountLabel = new MyGuiControlLabel(text: String.Format("{0} {1}", grid.Value, MyTexts.Get(MySpaceTexts.TerminalTab_Info_BlocksLower)), textScale: 0.9f);
                MyGuiControlLabel assignLabel = new MyGuiControlLabel(text: MyTexts.GetString(MySpaceTexts.TerminalTab_Info_Assign), originAlign: VRage.Utils.MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER, textScale: 0.9f);
                MyGuiControlCombobox assignCombobox = new MyGuiControlCombobox(originAlign: VRage.Utils.MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER, size: new Vector2(0.11f, 0.008f));
                MyGuiControlSeparatorList lineSeparator = new MyGuiControlSeparatorList();

                gridNameLabel.Position = new Vector2(-0.15f, -0.025f);
                gridBlockCountLabel.Position = new Vector2(-0.15f, 0.000f);
                assignLabel.Position = new Vector2(0.035f, 0.025f);
                assignCombobox.Position = new Vector2(0.15f, 0.025f);

                assignCombobox.ItemSelected += delegate()
                {
                    assignCombobox_ItemSelected(grid.Key, m_playerIds[(int)assignCombobox.GetSelectedKey()]);
                };

                m_playerIds.Clear();
                foreach (var player in MySession.Static.Players.GetOnlinePlayers())
                {
                    if (MySession.Static.LocalHumanPlayer != player)
                    {
                        assignCombobox.AddItem(m_playerIds.Count, player.DisplayName);
                        m_playerIds.Add(player.Id);
                    }
                }
                lineSeparator.AddHorizontal(new Vector2(-0.15f, 0.05f), 0.3f, width: 0.002f);

                panel.Controls.Add(gridNameLabel);
                panel.Controls.Add(gridBlockCountLabel);
                panel.Controls.Add(assignLabel);
                panel.Controls.Add(assignCombobox);
                panel.Controls.Add(lineSeparator);

                if (MySession.Static.EnableRemoteBlockRemoval)
                {
                    MyGuiControlLabel deleteOwnedBlocksLabel = new MyGuiControlLabel(
                        text: MyTexts.GetString(MySpaceTexts.buttonRemove), 
                        originAlign: VRage.Utils.MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER, 
                        textScale: 0.9f);
                    MyGuiControlButton deleteOwnedBlocksButton = new MyGuiControlButton(
                        text: new StringBuilder("X"), 
                        onButtonClick: deleteOwnedBlocksButton_ButtonClicked, 
                        buttonIndex: m_infoGrids.Count, 
                        visualStyle: MyGuiControlButtonStyleEnum.SquareSmall, 
                        originAlign: VRage.Utils.MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER);
                    deleteOwnedBlocksLabel.Position = new Vector2(0.11f, -0.02f);
                    deleteOwnedBlocksButton.Position = new Vector2(0.15f, -0.02f);
                    panel.Controls.Add(deleteOwnedBlocksLabel);
                    panel.Controls.Add(deleteOwnedBlocksButton);
                }

                grid.Key.OnAuthorshipChanged += grid_OnAuthorshipChanged;

                m_infoGrids.Add(grid.Key);

                panel.Size = new Vector2(panel.Size.X, 0.09f);
                list.Controls.Add(panel);
            }
            identity.LockBlocksBuiltByGrid.ReleaseExclusive();
        }
Ejemplo n.º 4
0
        void Reposition()
        {
            this.Size = new Vector2(this.Size.X, 0.12f * baseScale + itemHeight * BlockInfo.Components.Count);

            //BackgroundTexture =  @"Textures\GUI\Screens\aa";
            var topleft     = -this.Size / 2;
            var topRight    = new Vector2(this.Size.X / 2, -this.Size.Y / 2);
            var rightColumn = topleft + (m_progressMode ? new Vector2(0.0815f, 0) : new Vector2(0.036f, 0));

            var titleHeight = 0.072f * baseScale;

            Vector2 borderGap = new Vector2(0.0055f) * new Vector2(0.75f, 1) * baseScale;

            if (!m_progressMode)
            {
                borderGap.Y *= 0.5f;
            }

            m_installedRequiredLabel.TextToDraw = MyTexts.Get(BlockInfo.BlockIntegrity > 0 ? m_style.InstalledRequiredLabelText : m_style.RequiredLabelText);

            m_leftColumnBackground.ColorMask         = m_style.LeftColumnBackgroundColor;
            m_leftColumnBackground.Position          = topleft + borderGap;
            m_leftColumnBackground.Size              = new Vector2(rightColumn.X - topleft.X, this.Size.Y) - new Vector2(borderGap.X, 0.0088f);
            m_leftColumnBackground.BackgroundTexture = MyGuiConstants.TEXTURE_GUI_BLANK;

            m_titleBackground.ColorMask = m_style.TitleBackgroundColor;
            if (m_progressMode)
            {
                m_titleBackground.Position = rightColumn + new Vector2(-0.0015f, borderGap.Y);
            }
            else
            {
                m_titleBackground.Position = topleft + borderGap;
            }
            m_titleBackground.Size = new Vector2(topRight.X - m_titleBackground.Position.X - (m_progressMode ? borderGap.X : 0), 0.101f * baseScale);
            m_titleBackground.BackgroundTexture = MyGuiConstants.TEXTURE_GUI_BLANK;

            Vector2 separatorPos;

            if (m_progressMode)
            {
                separatorPos = rightColumn + new Vector2(0, titleHeight);
            }
            else
            {
                separatorPos = topleft + new Vector2(borderGap.X, titleHeight);
            }
            m_separator.Clear();
            m_separator.AddHorizontal(separatorPos, this.Size.X + topleft.X - separatorPos.X - 0.002f, 0.003f); // Title separator

            if (m_progressMode)
            {
                if (BlockInfo.BlockIntegrity > 0)
                {
                    float integrityHeight = itemHeight * BlockInfo.Components.Count - 0.002f;
                    float integrityWidth  = 0.032f;
                    var   integrityPos    = topleft + new Vector2(0.01f, 0.11f + integrityHeight);

                    m_integrityBackground.ColorMask         = m_style.IntegrityBackgroundColor;
                    m_integrityBackground.Position          = integrityPos;
                    m_integrityBackground.Size              = new Vector2(integrityWidth, integrityHeight);
                    m_integrityBackground.BackgroundTexture = MyGuiConstants.TEXTURE_GUI_BLANK;

                    var color = (BlockInfo.BlockIntegrity > BlockInfo.CriticalIntegrity)
                        ? m_style.IntegrityForegroundColorOverCritical
                        : m_style.IntegrityForegroundColor;

                    m_integrityForeground.ColorMask         = color;
                    m_integrityForeground.Position          = integrityPos;
                    m_integrityForeground.Size              = new Vector2(integrityWidth, integrityHeight * BlockInfo.BlockIntegrity);
                    m_integrityForeground.BackgroundTexture = MyGuiConstants.TEXTURE_GUI_BLANK;

                    if (ShowCriticalIntegrity)
                    {
                        float lineWidth = 0;
                        if (Math.Abs(BlockInfo.CriticalIntegrity - BlockInfo.OwnershipIntegrity) < 0.005f)
                        {
                            lineWidth = 0.004f; //if lines are overdrawing
                        }
                        m_separator.AddHorizontal(integrityPos - new Vector2(0, integrityHeight * BlockInfo.CriticalIntegrity), integrityWidth, width: lineWidth, color: CriticalIntegrityColor);
                    }

                    if (ShowOwnershipIntegrity && BlockInfo.OwnershipIntegrity > 0)
                    {
                        m_separator.AddHorizontal(integrityPos - new Vector2(0, integrityHeight * BlockInfo.OwnershipIntegrity), integrityWidth, color: OwnershipIntegrityColor);
                    }

                    m_integrityLabel.Position = integrityPos + new Vector2(integrityWidth / 2, -0.005f);
                    m_integrityLabel.Font     = MyFontEnum.White;
                    m_integrityLabel.TextToDraw.Clear();
                    m_integrityLabel.TextToDraw.AppendInt32((int)Math.Floor(BlockInfo.BlockIntegrity * 100)).Append("%");

                    m_integrityBackground.Visible = true;
                    m_integrityForeground.Visible = true;
                    m_integrityLabel.Visible      = true;
                }
                else
                {
                    m_integrityBackground.Visible = false;
                    m_integrityForeground.Visible = false;
                    m_integrityLabel.Visible      = false;
                }
            }

            if (m_progressMode)
            {
                m_blockNameLabel.Position = rightColumn + new Vector2(0.006f, 0.026f * baseScale);

                if (m_style.ShowAvailableComponents)
                {
                    Vector2 offset = new Vector2(0, -0.006f);
                    m_componentsLabel.Position = m_blockNameLabel.Position + new Vector2(0, m_blockNameLabel.Size.Y) + offset;
                    m_blockNameLabel.Position  = m_blockNameLabel.Position + offset;
                }
                else
                {
                    m_componentsLabel.Position = rightColumn + new Vector2(0.006f, 0.076f * baseScale);
                }

                m_blockNameLabel.Size              = new Vector2(Size.X / 2 - m_blockNameLabel.Position.X, m_blockNameLabel.Size.Y);
                m_blockTypeLabel.Visible           = false;
                m_blockTypePanel.Visible           = false;
                m_blockTypePanelBackground.Visible = false;
            }
            else
            {
                m_blockTypePanel.Position           = topRight + new Vector2(-0.0085f, 0.012f);
                m_blockTypePanelBackground.Position = topRight + new Vector2(-0.0085f, 0.012f);
                if (m_style.EnableBlockTypePanel)
                {
                    m_blockTypePanel.Visible           = true;
                    m_blockTypePanelBackground.Visible = true;

                    m_blockNameLabel.Size = new Vector2(m_blockTypePanel.Position.X - m_blockTypePanel.Size.X - m_blockNameLabel.Position.X, m_blockNameLabel.Size.Y);
                }
                else
                {
                    m_blockTypePanel.Visible           = false;
                    m_blockTypePanelBackground.Visible = false;

                    m_blockNameLabel.Size = new Vector2(m_blockTypePanel.Position.X - m_blockNameLabel.Position.X, m_blockNameLabel.Size.Y);
                }

                m_blockNameLabel.TextScale   = 0.95f * baseScale;
                m_blockNameLabel.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM;
                m_blockNameLabel.Position    = m_blockIconPanel.Position + m_blockIconPanel.Size + new Vector2(0.004f, 0);


                m_blockTypeLabel.Visible     = true;
                m_blockTypeLabel.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP;
                m_blockTypeLabel.TextScale   = m_smallerFontSize * baseScale;
                m_blockTypeLabel.Position    = m_blockIconPanel.Position + new Vector2(m_blockIconPanel.Size.X, 0) + new Vector2(0.004f, -0.0025f);

                m_componentsLabel.Position = rightColumn + new Vector2(0.006f, 0.076f * baseScale);
            }

            m_installedRequiredLabel.Position = topRight + new Vector2(-0.011f, 0.076f * baseScale);

            m_blockIconPanel.Position           = topleft + new Vector2(0.0085f, 0.012f);
            m_blockIconPanelBackground.Position = topleft + new Vector2(0.0085f, 0.012f);

            Vector2 listPos;

            if (m_progressMode)
            {
                listPos = topleft + new Vector2(0.0485f, 0.102f);
            }
            else
            {
                listPos = topleft + new Vector2(0.008f, 0.102f * baseScale);
            }

            for (int i = 0; i < BlockInfo.Components.Count; i++)
            {
                m_componentLines[i].Position = listPos + new Vector2(0, (BlockInfo.Components.Count - i - 1) * itemHeight);
                m_componentLines[i].IconPanelProgress.Visible = ShowComponentProgress;
                m_componentLines[i].IconPanel.BorderColor     = CriticalComponentColor;
                m_componentLines[i].NameLabel.TextScale       = m_smallerFontSize * baseScale;
                m_componentLines[i].NumbersLabel.TextScale    = m_smallerFontSize * baseScale;
            }
        }
            public WarningArea(string name, bool graphicsButton)
            {
                Warnings = new List<WarningLine>();

                m_header = new MyGuiControlParent();
                m_titleBackground = new MyGuiControlPanel(texture: @"Textures\GUI\Controls\item_highlight_dark.dds");
                m_title = new MyGuiControlLabel(text: name);
                m_lastOccurence = new MyGuiControlLabel(text: MyTexts.GetString(MyCommonTexts.PerformanceWarningLastOccurrence), originAlign: VRage.Utils.MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER);
                m_separator = new MyGuiControlSeparatorList();
                m_separator.AddHorizontal(new Vector2(-0.45f, 0.018f), 0.9f);

                m_title.Position = new Vector2(-0.43f, 0f);
                m_lastOccurence.Position = new Vector2(0.43f, 0f);
                m_titleBackground.Size = new Vector2(m_titleBackground.Size.X, 0.035f);
                m_header.Size = new Vector2(m_header.Size.X, m_titleBackground.Size.Y);
                if (graphicsButton) 
                {
                    m_graphicsButton = new MyGuiControlButton(text: MyTexts.Get(MyCommonTexts.ScreenCaptionGraphicsOptions), onButtonClick: (sender) => { MyGuiSandbox.AddScreen(new MyGuiScreenOptionsGraphics()); });
                }
            }
Ejemplo n.º 6
0
        public void RecreateControls()
        {
            if (QuestInfo == null || Elements == null)
                return;
            Elements.Clear();

            Vector2 topleft = -this.Size / 2;
            Vector2 textOffset = new Vector2(0.015f, 0.015f);

            // Title
            MyGuiControlLabel title = new MyGuiControlLabel();
            title.Text = QuestInfo.QuestTitle;
            title.Position = topleft + textOffset;
            title.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP;
            title.Visible = true;
            Elements.Add(title);

            // Pages
            if (QuestInfo.MaxPages != 0)
            {
                MyGuiControlLabel numbers = new MyGuiControlLabel();
                numbers.Text = QuestInfo.Page + "/" + QuestInfo.MaxPages;
                numbers.Position = topleft + Vector2.UnitX * this.Size - textOffset * new Vector2(1, -1);
                numbers.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_TOP;
                Elements.Add(numbers);
            }

            // Separator
            MyGuiControlSeparatorList m_separator;
            m_separator = new MyGuiControlSeparatorList();
            m_separator.AddHorizontal(topleft + textOffset + new Vector2(0, 0.03f), this.Size.X - 2 * textOffset.X, 0.003f); // Title separator
            m_separator.Visible = true;
            Elements.Add(m_separator);

            // Details
            var rowOffset = new Vector2(0, 0.025f);
            string[] details = QuestInfo.GetQuestGetails();
            int idx = 0;
            for (int i = 0; i < details.Length; i++)
            {
                if (details[i] == null)
                    continue;
                MyGuiControlMultilineText textBox = new MyGuiControlMultilineText(
                    size: new Vector2(Size.X * 0.92f, rowOffset.Y * 5),
                    position: topleft + textOffset + new Vector2(0, 0.04f) + rowOffset * idx,
                    textAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                    textBoxAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                    //Debug purpose
                    //backgroundColor: Vector4.One,
                    //backgroundTexture: BackgroundTexture,
                    drawScrollbar: false
                    );
                textBox.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP;
                textBox.TextScale = 0.9f;
                textBox.AppendText(details[i]);
                textBox.Visible = true;
                idx += textBox.NumberOfRows;
                Elements.Add(textBox);
            }
        }