예제 #1
0
        /// <summary>
        /// Try change group name, returns false on error
        /// </summary>
        public bool ChangeGroupName(MyObjectGroup group, string newName)
        {
            MyTreeViewItem groupItem = null;

            for (int i = 0; i < m_groupList.GetItemCount(); i++)
            {
                var item = m_groupList.GetItem(i);

                // Find group list item
                if (item.Tag == group)
                {
                    groupItem = item;
                }
                else
                {
                    if (item.Text.ToString() == newName)
                    {
                        return(false);
                    }
                }
            }

            if (groupItem != null)
            {
                group.Name     = new StringBuilder(newName);
                groupItem.Text = group.Name;
                return(true);
            }

            return(false);
        }
예제 #2
0
        private MyTreeViewItem AddGroup(MyObjectGroup group)
        {
            var item = m_groupList.AddItem(group.Name, null, Vector2.Zero, null, null, Vector2.Zero);

            item.Tag = group;
            return(item);
        }
예제 #3
0
        private void OnCreateGroup(MyGuiControlButton sender)
        {
            var generatedName = new StringBuilder(GenerateName("Group"));
            var group         = new MyObjectGroup(generatedName);

            if (group.AddObjects(MyEditorGizmo.SelectedEntities))
            {
                AddGroup(group);
                MyEditor.Static.ObjectGroups.Add(group);
            }
            else
            {
                MyGuiManager.AddScreen(new MyGuiScreenMessageBox(MyMessageBoxType.ERROR, MyTextsWrapperEnum.EditorGroupsCantCreateGroupText, MyTextsWrapperEnum.EditorGroupsCantCreateGroupCaption, MyTextsWrapperEnum.Ok, null));
            }
        }
예제 #4
0
        public MyGuiScreenEditorRenameGroup(MyGuiScreenEditorGroups myGuiScreenEditorGroups, MyObjectGroup group)
            : base(new Vector2(0.5f, 0.5f), new Vector2(0.33f, 0.85f))
        {
            m_myGuiScreenEditorGroups = myGuiScreenEditorGroups;
            m_group = group;
            m_size  = MyGuiConstants.TEXTBOX_MEDIUM_SIZE +
                      new Vector2(MyGuiConstants.MESSAGE_BOX_BORDER_AREA_X * 2,
                                  0.1f + MyGuiConstants.MESSAGE_BOX_BORDER_AREA_Y * 2 +
                                  MyGuiConstants.MESSAGE_BOX_BUTTON_SIZE.Y);

            AddCaption(MyTextsWrapperEnum.EditorGroupsRenameGroup, MyGuiConstants.LABEL_TEXT_COLOR);

            m_nameTextbox = new MyGuiControlTextbox(this,
                                                    new Vector2(0, 0.1f + MyGuiConstants.TEXTBOX_MEDIUM_SIZE.Y / 2 - m_size.Value.Y / 2),
                                                    MyGuiControlPreDefinedSize.MEDIUM,
                                                    group.Name.ToString(), MAXIMUM_GROUP_NAME_LENGTH,
                                                    MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiControlTextboxType.NORMAL);

            Controls.Add(m_nameTextbox);
            AddOkAndCancelButtonControls();
        }
        public MyGuiScreenEditorRenameGroup(MyGuiScreenEditorGroups myGuiScreenEditorGroups, MyObjectGroup group)
            : base(new Vector2(0.5f, 0.5f), new Vector2(0.33f, 0.85f))
        {
            m_myGuiScreenEditorGroups = myGuiScreenEditorGroups; 
            m_group = group;
            m_size = MyGuiConstants.TEXTBOX_MEDIUM_SIZE +
                           new Vector2(MyGuiConstants.MESSAGE_BOX_BORDER_AREA_X*2,
                                       0.1f + MyGuiConstants.MESSAGE_BOX_BORDER_AREA_Y*2 +
                                       MyGuiConstants.MESSAGE_BOX_BUTTON_SIZE.Y);

            AddCaption(MyTextsWrapperEnum.EditorGroupsRenameGroup, MyGuiConstants.LABEL_TEXT_COLOR);
            
            m_nameTextbox = new MyGuiControlTextbox(this,
                new Vector2(0, 0.1f + MyGuiConstants.TEXTBOX_MEDIUM_SIZE.Y / 2 - m_size.Value.Y / 2), 
                MyGuiControlPreDefinedSize.MEDIUM,
                group.Name.ToString(), MAXIMUM_GROUP_NAME_LENGTH, 
                MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiControlTextboxType.NORMAL);

            Controls.Add(m_nameTextbox);
            AddOkAndCancelButtonControls();
        }
 private void OnCreateGroup(MyGuiControlButton sender)
 {
     var generatedName = new StringBuilder(GenerateName("Group"));
     var group = new MyObjectGroup(generatedName);
     if (group.AddObjects(MyEditorGizmo.SelectedEntities))
     {
         AddGroup(group);
         MyEditor.Static.ObjectGroups.Add(group);
     }
     else
     {
         MyGuiManager.AddScreen(new MyGuiScreenMessageBox(MyMessageBoxType.ERROR, MyTextsWrapperEnum.EditorGroupsCantCreateGroupText, MyTextsWrapperEnum.EditorGroupsCantCreateGroupCaption, MyTextsWrapperEnum.Ok, null));
     }
 }
        /// <summary>
        /// Try change group name, returns false on error
        /// </summary>
        public bool ChangeGroupName(MyObjectGroup group, string newName)
        {
            MyTreeViewItem groupItem = null;
            for (int i = 0; i < m_groupList.GetItemCount(); i++)
            {
                var item = m_groupList.GetItem(i);
                
                // Find group list item
                if (item.Tag == group)
                {
                    groupItem = item;
                }
                else
                {
                    if (item.Text.ToString() == newName)
                    {
                        return false;
                    }
                }
            }

            if (groupItem != null)
            {
                group.Name = new StringBuilder(newName);
                groupItem.Text = group.Name;
                return true;
            }

            return false;
        }
 private MyTreeViewItem AddGroup(MyObjectGroup group)
 {
     var item = m_groupList.AddItem(group.Name, null, Vector2.Zero, null, null, Vector2.Zero);
     item.Tag = group;
     return item;
 }