Esempio n. 1
0
        public void RemoveFromManagers(bool clearThis)
        {
            if (!clearThis)
            {
                MakeOneWay();
            }


            for (int i = mSprites.Count - 1; i > -1; i--)
            {
                Sprite sprite = mSprites[i];

                PositionedObject oldParent = sprite.Parent;

                SpriteManager.RemoveSprite(sprite);

                if (!clearThis && oldParent != null)
                {
                    sprite.AttachTo(oldParent, false);
                }
            }

            for (int i = mSpriteGrids.Count - 1; i > -1; i--)
            {
                //SpriteGrids don't get attached, so there is no code to preserve Parent and re-attach
                SpriteGrid spriteGrid = mSpriteGrids[i];

                spriteGrid.Destroy();
            }

            for (int i = mSpriteFrames.Count - 1; i > -1; i--)
            {
                SpriteFrame spriteFrame = mSpriteFrames[i];

                PositionedObject oldParent = spriteFrame.Parent;

                SpriteManager.RemoveSpriteFrame(spriteFrame);

                if (!clearThis && oldParent != null)
                {
                    spriteFrame.AttachTo(oldParent, false);
                }
            }


            for (int i = mTexts.Count - 1; i > -1; i--)
            {
                Text text = mTexts[i];

                PositionedObject oldParent = text.Parent;

                TextManager.RemoveText(text);

                if (!clearThis && oldParent != null)
                {
                    text.AttachTo(oldParent, false);
                }
            }

            if (clearThis)
            {
                Clear();
            }
            else
            {
                MakeTwoWay();
            }
        }
Esempio n. 2
0
        protected internal void UpdateSeparators()
        {
            if (mSeparatorSkin == null)
            {
                return;
            }

            int requiredSeparatorCount = 0;

            if (mSeparatorSkin != null && mItems.Count != 0)
            {
                requiredSeparatorCount =
                    System.Math.Min(mItems.Count, NumberOfVisibleElements) + mSeparatorSkin.ExtraSeparators;
            }

            while (mSeparators.Count < requiredSeparatorCount)
            {
                // There aren't enough separators, so let's add them
                SpriteFrame newSeparator = new SpriteFrame(
                    mSeparatorSkin.Texture, mSeparatorSkin.BorderSides);

                SpriteManager.AddSpriteFrame(newSeparator);
                if (SpriteFrame.LayerBelongingTo != null)
                {
                    SpriteManager.AddToLayer(newSeparator, SpriteFrame.LayerBelongingTo);
                }

                int indexOfNewSeparator = mSeparators.Count;
                mSeparators.Add(newSeparator);

                newSeparator.AttachTo(SpriteFrame, false);
                newSeparator.RelativeZ =
                    -MathFunctions.ForwardVector3.Z * SeparatorZOffset;
            }

            while (mSeparators.Count > requiredSeparatorCount)
            {
                // There are too many separators, so remove some
                SpriteManager.RemoveSpriteFrame(mSeparators.Last);
            }

            UpdateSeparatorProperties();

        }
Esempio n. 3
0
 public void AttachTo(PositionedObject obj, bool changeRelative)
 {
     _backgroundSprite.AttachTo(obj, changeRelative);
 }