Exemplo n.º 1
0
        private void SetItemAtIndexInternal(int i, MyToolbarItem item, bool initialization = false)
        {
            if (!m_items.IsValidIndex(i))
            {
                return;
            }

            var definitionItem = item as MyToolbarItemDefinition;

            if (definitionItem != null && definitionItem.Definition != null && !definitionItem.Definition.AvailableInSurvival && MySession.Static.SurvivalMode)
            {
                return;
            }

            if (item != null && !item.AllowedInToolbarType(m_toolbarType))
            {
                return;
            }

            bool oldEnabledState = true;
            bool newEnabledState = true;

            if (m_items[i] != null)
            {
                oldEnabledState = m_items[i].Enabled;
                m_items[i].OnRemovedFromToolbar(this);
            }

            m_items[i] = item;
            if (item != null)
            {
                item.OnAddedToToolbar(this);
                newEnabledState = true;
            }

            if (initialization)
            {
                return;
            }

            UpdateItem(i);
            if (ItemChanged != null)
            {
                ItemChanged(this, new IndexArgs()
                {
                    ItemIndex = i
                });
            }

            if (oldEnabledState != newEnabledState)
            {
                int slot = IndexToSlot(i);
                if (IsValidSlot(slot))
                {
                    SlotEnabledChanged(slot);
                }
            }
        }
Exemplo n.º 2
0
        private void SetItemAtIndexInternal(int i, MyToolbarItem item, bool initialization = false)
        {
            if (!m_items.IsValidIndex(i))
            {
                return;
            }

            if (item != null && !item.AllowedInToolbarType(m_toolbarType))
            {
                return;
            }

            bool oldEnabledState = true;
            bool newEnabledState = true;

            if (m_items[i] != null)
            {
                oldEnabledState = m_items[i].Enabled;
                m_items[i].OnClose();
            }

            m_items[i] = item;

            if (m_items[i] != null)
            {
                newEnabledState = true;
            }

            if (initialization)
            {
                return;
            }

            UpdateItem(i);
            if (ItemChanged != null)
            {
                ItemChanged(this, new IndexArgs()
                {
                    ItemIndex = i
                });
            }

            if (oldEnabledState != newEnabledState)
            {
                int slot = IndexToSlot(i);
                if (IsValidSlot(slot))
                {
                    SlotEnabledChanged(slot);
                }
            }
        }
Exemplo n.º 3
0
        private void SetItemAtIndexInternal(int i, MyToolbarItem item, bool initialization = false)
        {
            if (!m_items.IsValidIndex(i))
                return;

			var definitionItem = item as MyToolbarItemDefinition;
			if (definitionItem != null && definitionItem.Definition != null && !definitionItem.Definition.AvailableInSurvival && MySession.Static.SurvivalMode)
				return;
            
            if (item != null && !item.AllowedInToolbarType(m_toolbarType))
                return;

            bool oldEnabledState = true;
            bool newEnabledState = true;

            if (m_items[i] != null)
            {
                oldEnabledState = m_items[i].Enabled;
                m_items[i].OnClose();
            }

            m_items[i] = item;

            if (m_items[i] != null)
            {
                newEnabledState = true;
            }

            if (initialization)
                return;

            UpdateItem(i);
            if (ItemChanged != null)
                ItemChanged(this, new IndexArgs() { ItemIndex = i });

            if (oldEnabledState != newEnabledState)
            {
                int slot = IndexToSlot(i);
                if (IsValidSlot(slot))
                    SlotEnabledChanged(slot);
            }
        }