public void AddStem(MenuStem Stem, int Margins)
        {
            Vector2 Size = new Vector2(ItemWidth, MenuManager.Font.MeasureString(Stem.MyText).Y + Margins);

            Children.Add((MenuStem)Stem.Create(PlacePosition, Size, PlaceX, PlaceY, Parent));

            PlaceY++;
            PlacePosition.Y += MenuManager.Font.MeasureString(Stem.MyText).Y + Margins + Seperation.Y;

            Vector2 MaxSize = Size;
            float   SizeY   = this.Margins.Y;

            // foreach (MenuStem child in Children)
            {
                //    MaxSize.X = Math.Max(MaxSize.X, child.Size.X);
            }



            foreach (MenuStem child in Children)
            {
                //   child.ChangeSize(new Vector2(MaxSize.X,child.Size.Y));
                SizeY = Math.Max(SizeY, (child.Position.Y - Position.Y) + child.Size.Y + this.Margins.Y);
            }

            Parent.AddItem(Stem);

            TargetSize = new Vector2(Size.X, Math.Max(Size.Y, SizeY + this.Margins.Y));
        }
Esempio n. 2
0
        public virtual MenuItem Discard(Vector2 NewMenuTop, bool AddSelected)
        {
            MenuItem Result = null;

            IsDiscarded = true;

            if (Header != null)
            {
                Header.Selected = false;
                Header.Discard();
                Header.Discarded = true;
            }

            foreach (MenuItem Item in Children)
            {
                if (AddSelected && Item.Hovering && Item.GetType().Equals(typeof(MenuStem)))
                {
                    Result        = Item;
                    Item.Selected = true;
                    MenuStem Stem = (MenuStem)Item;
                    Stem.TargetPosition = NewMenuTop - new Vector2(0, Stem.Size.Y + 25);
                }
                else
                {
                    Item.Discard();
                }
            }

            return(Result);
        }
Esempio n. 3
0
        public virtual void Update(GameTime gameTime)
        {
            if (Header == null)
            {
                Header = MakeHeader();
                if (Header != null)
                {
                    LocalHeader     = true;
                    Header.Selected = true;
                    MenuStem Stem = (MenuStem)Header;
                    Stem.TargetPosition = HeaderPosition - new Vector2(0, Stem.Size.Y + 25);
                    Children.Add(Header);
                }
                else
                {
                    Alive = true;
                }
            }

            CurrentStep = -1;

            if (Alive)
            {
                AliveTime += gameTime.ElapsedGameTime.Milliseconds;

                if (!IsDiscarded)
                {
                    if (AliveTime > Steps * 100)
                    {
                        CurrentStep = (int)Math.Floor(AliveTime / 100f);
                        Steps       = CurrentStep;
                    }
                }

                if (AliveTime > 100)
                {
                    for (int i = 0; i < Children.Count; i++)
                    {
                        MenuItem Item = Children[i];

                        if (Item != null)
                        {
                            if (ScrollX == Item.X && ScrollY == Item.Y)
                            {
                                Item.Hovering = true;
                            }
                            else
                            {
                                Item.Hovering = false;
                            }

                            Item.Update(gameTime);
                        }
                    }
                }
            }
            if (LocalHeader && Header != null)
            {
                Header.Update(gameTime);
            }

            if (IsDiscarded && Children.Count == 0)
            {
                Destroy();
            }
        }