Exemplo n.º 1
0
        private static void ShowError(MyStringId errorText, IMyGuiControlsParent controlsParent)
        {
            foreach (var control in controlsParent.Controls)
            {
                control.Visible = false;
            }

            var label = (MyGuiControlLabel)controlsParent.Controls.GetControlByName("ErrorMessage");

            if (label == null)
            {
                label = MyGuiScreenTerminal.CreateErrorLabel(errorText, "ErrorMessage");
            }
            label.TextEnum = errorText;
            if (!controlsParent.Controls.Contains(label))
            {
                controlsParent.Controls.Add(label);
            }
        }
Exemplo n.º 2
0
        public void Init(IMyGuiControlsParent controlsParent, MyPlayer controller, MyCubeGrid grid, MyTerminalBlock currentBlock, MyGridColorHelper colorHelper)
        {
            m_controlsParent = controlsParent;
            m_controller     = controller;
            m_colorHelper    = colorHelper;

            if (grid == null)
            {
                foreach (var control in controlsParent.Controls)
                {
                    control.Visible = false;
                }

                var label = MyGuiScreenTerminal.CreateErrorLabel(MySpaceTexts.ScreenTerminalError_ShipNotConnected, "ErrorMessage");
                controlsParent.Controls.Add(label);
                return;
            }

            m_terminalSystem = grid.GridSystems.TerminalSystem;
            m_tmpGroup       = new MyBlockGroup(grid);

            m_blockSearch                     = (MyGuiControlTextbox)m_controlsParent.Controls.GetControlByName("FunctionalBlockSearch");
            m_blockSearch.TextChanged        += blockSearch_TextChanged;
            m_blockSearchClear                = (MyGuiControlButton)m_controlsParent.Controls.GetControlByName("FunctionalBlockSearchClear");
            m_blockSearchClear.ButtonClicked += blockSearchClear_ButtonClicked;
            m_blockListbox                    = (MyGuiControlListbox)m_controlsParent.Controls.GetControlByName("FunctionalBlockListbox");
            m_blockNameLabel                  = (MyGuiControlLabel)m_controlsParent.Controls.GetControlByName("BlockNameLabel");
            m_blockNameLabel.Text             = "";
            m_groupName              = (MyGuiControlTextbox)m_controlsParent.Controls.GetControlByName("GroupName");
            m_groupName.TextChanged += m_groupName_TextChanged;

            m_showAll                = (MyGuiControlButton)m_controlsParent.Controls.GetControlByName("ShowAll");
            m_showAll.Selected       = m_showAllTerminalBlocks;
            m_showAll.ButtonClicked += showAll_Clicked;
            m_showAll.SetToolTip(MySpaceTexts.Terminal_ShowAllInTerminal);
            m_showAll.IconRotation = 0f;
            m_showAll.Icon         = new MyGuiHighlightTexture
            {
                Normal    = @"Textures\GUI\Controls\button_hide.dds",
                Highlight = @"Textures\GUI\Controls\button_unhide.dds",
                SizePx    = new Vector2(40f, 40f),
            };
            m_showAll.Size = new Vector2(0, 0);

            m_showAll.HighlightType   = MyGuiControlHighlightType.FORCED;
            m_showAll.IconOriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP;

            m_groupSave                  = (MyGuiControlButton)m_controlsParent.Controls.GetControlByName("GroupSave");
            m_groupSave.TextEnum         = MySpaceTexts.TerminalButton_GroupSave;
            m_groupSave.TextAlignment    = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER;
            m_groupSave.ButtonClicked   += groupSave_ButtonClicked;
            m_groupDelete                = (MyGuiControlButton)m_controlsParent.Controls.GetControlByName("GroupDelete");
            m_groupDelete.ButtonClicked += groupDelete_ButtonClicked;
            m_groupDelete.Enabled        = false;

            m_blockListbox.ItemsSelected += blockListbox_ItemSelected;

            RefreshBlockList();

            m_terminalSystem.BlockAdded   += TerminalSystem_BlockAdded;
            m_terminalSystem.BlockRemoved += TerminalSystem_BlockRemoved;
            m_terminalSystem.GroupAdded   += TerminalSystem_GroupAdded;
            m_terminalSystem.GroupRemoved += TerminalSystem_GroupRemoved;
            if (currentBlock != null)
            {
                SelectBlocks(new MyTerminalBlock[] { currentBlock });
            }
        }