Beispiel #1
0
        public void Reset()
        {
            foreach (GUIComponent child in Children)
            {
                child.ClearChildren();
            }

            foreach (GUIComponent child in ChildrenToAdd)
            {
                child.ClearChildren();
            }

            Children.Clear();
            ChildrenToAdd.Clear();
            ChildrenToRemove.Clear();
        }
Beispiel #2
0
        public virtual void Update(DwarfTime time)
        {
            if (!IsVisible)
            {
                return;
            }

            UpdateSize();

            if (Tweens.Count > 0)
            {
                GUITween currTween = Tweens.First();
                currTween.Update(time);
                LocalBounds = currTween.GetCurrentRect();
                if (currTween.TweenTimer.HasTriggered)
                {
                    switch (currTween.Tween)
                    {
                    case GUITween.TweenType.TweenAnimate:
                        break;

                    case GUITween.TweenType.TweenIn:
                        break;

                    case GUITween.TweenType.TweenOut:
                        IsVisible   = false;
                        LocalBounds = currTween.Start;
                        break;
                    }

                    Tweens.RemoveAt(0);
                }
            }

            OnUpdate.Invoke();

            foreach (GUIComponent child in Children)
            {
                child.Update(time);
            }

            MouseState state = Mouse.GetState();

            if (GUI.EnableMouseEvents)
            {
                if (OverrideClickBehavior)
                {
                    HandleClicks(state);
                }
                else if (GlobalBounds.Contains(state.X, state.Y))
                {
                    if (IsMouseOver)
                    {
                        HandleClicks(state);
                    }

                    if (!IsMouseOver)
                    {
                        IsMouseOver = true;
                        OnHover();
                    }
                }
                else if (IsMouseOver)
                {
                    IsMouseOver = false;
                    OnUnHover();
                    IsLeftPressed  = false;
                    IsRightPressed = false;
                }
            }

            foreach (GUIComponent child in ChildrenToAdd)
            {
                Children.Add(child);
            }
            ChildrenToAdd.Clear();

            foreach (GUIComponent child in ChildrenToRemove)
            {
                if (!Children.Remove(child))
                {
                    Console.Out.WriteLine("Something's wrong with removing child...");
                }
            }
            ChildrenToRemove.Clear();
        }