Exemplo n.º 1
0
        private void SelectBlocks()
        {
            if (m_blockControl != null)
            {
                m_controlsParent.Controls.Remove(m_blockControl);
                m_blockControl = null;
            }
            m_blockNameLabel.Text = "";
            m_groupName.Text      = "";

            if (m_currentGroups.Count() == 1)
            {
                m_blockNameLabel.Text = m_currentGroups[0].Name.ToString();
                m_groupName.Text      = m_blockNameLabel.Text;
            }

            if (CurrentBlocks.Count() > 0)
            {
                CurrentBlocks.Sort(MyTerminalComparer.Static);

                if (CurrentBlocks.Count() == 1)
                {
                    m_blockNameLabel.Text = CurrentBlocks[0].CustomName.ToString();
                }

                m_blockControl = new MyGuiControlGenericFunctionalBlock(CurrentBlocks.ToArray());
                m_controlsParent.Controls.Add(m_blockControl);

                m_blockControl.Size        = new Vector2(0.595f, 0.64f);
                m_blockControl.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP;
                m_blockControl.Position    = new Vector2(-0.1415f, -0.3f); // m_blockNameLabel.Position + new Vector2(0f, 0.1f);
            }

            UpdateGroupControl();

            m_blockListbox.SelectedItems.Clear();
            foreach (var b in CurrentBlocks)
            {
                foreach (var item in m_blockListbox.Items)
                {
                    if (item.UserData == b)
                    {
                        m_blockListbox.SelectedItems.Add(item);
                        break;
                    }
                }
            }
            foreach (var g in m_currentGroups)
            {
                foreach (var item in m_blockListbox.Items)
                {
                    if (item.UserData == g)
                    {
                        m_blockListbox.SelectedItems.Add(item);
                        break;
                    }
                }
            }
        }
Exemplo n.º 2
0
        public void SelectBlocks(MyTerminalBlock[] blocks)
        {
            m_tmpGroup.Blocks.Clear();
            m_tmpGroup.Blocks.AddArray(blocks);
            m_currentGroups.Clear();

            CurrentBlocks.Clear();
            CurrentBlocks.AddArray(blocks);
            SelectBlocks();
        }
Exemplo n.º 3
0
        private void blockListbox_ItemSelected(MyGuiControlListbox sender)
        {
            Debug.Assert(sender == m_blockListbox);
            m_oldGroups.Clear();
            m_oldGroups.AddList(m_currentGroups);
            m_currentGroups.Clear();
            m_tmpGroup.Blocks.Clear();

            foreach (var item in sender.SelectedItems)
            {
                if (item.UserData is MyBlockGroup)
                {
                    m_currentGroups.Add((MyBlockGroup)item.UserData);
                }
                else if (item.UserData is MyTerminalBlock)
                {
                    CurrentBlocks.Add(item.UserData as MyTerminalBlock);
                }
                else
                {
                    Debug.Fail("Terminal list must contain only Functional blocks and groups.");
                }
            }
            for (int i = 0; i < m_currentGroups.Count; i++)
            {
                if (m_oldGroups.Contains(m_currentGroups[i]) && m_currentGroups[i].Blocks.Intersect(CurrentBlocks).Count() != 0)
                {
                    continue;
                }
                foreach (var b in m_currentGroups[i].Blocks)
                {
                    if (!CurrentBlocks.Contains(b))
                    {
                        CurrentBlocks.Add(b);
                    }
                }
            }
            SelectBlocks();
        }
Exemplo n.º 4
0
        void groupSave_ButtonClicked(MyGuiControlButton obj)
        {
            bool containsEnemyBlock = false;

            foreach (var block in m_tmpGroup.Blocks)
            {
                if (!block.HasLocalPlayerAccess())
                {
                    containsEnemyBlock = true;
                    break;
                }
            }

            if (containsEnemyBlock)
            {
                MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(
                                           buttonType: MyMessageBoxButtonsType.OK,
                                           messageCaption: MyTexts.Get(MySpaceTexts.MessageBoxCaptionError),
                                           messageText: MyTexts.Get(MySpaceTexts.MessageBoxTextCannotCreateGroup)
                                           ));
            }
            else
            {
                Debug.Assert(!string.IsNullOrEmpty(m_groupName.Text));
                if (m_groupName.Text != "")
                {
                    m_currentGroups.Clear();
                    m_tmpGroup.Name.Clear().Append(m_groupName.Text);
                    m_tmpGroup = m_terminalSystem.AddUpdateGroup(m_tmpGroup);
                    m_currentGroups.Add(m_tmpGroup);
                    m_tmpGroup = new MyBlockGroup(null);
                    CurrentBlocks.AddList(m_currentGroups[0].Blocks);
                    SelectBlocks();
                }
            }
        }