示例#1
0
        public override void receiveRightClick(int x, int y, bool playSound = true)
        {
            Point p = new Point(x, y);
            Point o = new Point(this.Area.X + zoom10, this.Area.Y + zoom10);

            if (this.FloatingComponent != null && this.FloatingComponent.InBounds(p, o))
            {
                this.FloatingComponent.RightClick(p, o);
                return;
            }
            foreach (IInteractiveMenuComponent el in this.EventOrder)
            {
                if (el.InBounds(p, o))
                {
                    GiveFocus(el);
                    this.FocusElement = el;
                    el.RightClick(p, o);
                    return;
                }
            }
            ResetFocus();
        }
        public override void performHoverAction(int x, int y)
        {
            base.performHoverAction(x, y);
            if (!this.Area.Contains(x, y) || this.Hold)
            {
                return;
            }
            Point p = new Point(x, y);
            Point o = new Point(this.Area.X + FrameworkMenu.Zoom10, this.Area.Y + FrameworkMenu.Zoom10);

            if (this.HoverInElement != null && !this.HoverInElement.InBounds(p, o))
            {
                this.HoverInElement.HoverOut(p, o);
                this.HoverInElement = null;
            }

            if (this.FloatingComponent != null && this.FloatingComponent.InBounds(p, o))
            {
                this.FloatingComponent.HoverOver(p, o);
                return;
            }

            foreach (IInteractiveMenuComponent el in this.EventOrder)
            {
                if (el.InBounds(p, o))
                {
                    if (this.HoverInElement == null)
                    {
                        this.HoverInElement = el;
                        el.HoverIn(p, o);
                    }

                    el.HoverOver(p, o);
                    break;
                }
            }
        }
示例#3
0
        /// <summary>
        ///     Gives focus to a specified component.
        /// </summary>
        /// <param name="component">
        ///     The component to give focus.
        /// </param>
        public virtual void GiveFocus(IInteractiveMenuComponent component)
        {
            if (component == this.FocusElement)
            {
                return;
            }

            this.ResetFocus();
            this.FocusElement = component;
            var focusElement = this.FocusElement as IKeyboardComponent;

            if (focusElement != null)
            {
                Game1.keyboardDispatcher.Subscriber = new KeyboardSubscriberProxy(focusElement);
            }

            if (!this.InteractiveComponents.Contains(component))
            {
                this.FloatingComponent = component;
                component.Attach(this);
            }

            component.FocusGained();
        }
示例#4
0
 public void GiveFocus(IInteractiveMenuComponent component)
 {
     throw new NotImplementedException();
 }
        public override void CommandReceived(char cmd)
        {
            if (Disabled)
            {
                return;
            }
            switch ((int)cmd)
            {
            case 8:
                if (Value.Length <= 0)
                {
                    return;
                }
                Value = Value.Substring(0, Value.Length - 1);
                Game1.playSound("tinyWhip");
                return;

            case 9:
                if (TabPressed != null)
                {
                    Value = TabPressed(this, Parent.GetAttachedMenu(), Value);
                    return;
                }
                if (!(Parent is IComponentCollection))
                {
                    return;
                }
                bool Next = false;
                IInteractiveMenuComponent first = null;
                foreach (IInteractiveMenuComponent imc in (Parent as IComponentCollection).InteractiveComponents)
                {
                    if (first == null && imc is TextboxFormComponent)
                    {
                        first = imc;
                    }
                    if (imc == this)
                    {
                        Next = true;
                        continue;
                    }
                    if (Next && imc is TextboxFormComponent)
                    {
                        Parent.GiveFocus(imc);
                        return;
                    }
                }
                Parent.GiveFocus(first);
                return;

            case 13:
                if (EnterPressed != null)
                {
                    Value = EnterPressed(this, Parent.GetAttachedMenu(), Value);
                }
                else
                {
                    Parent.ResetFocus();
                }
                return;
            }
        }
示例#6
0
 public TabInfo(IInteractiveMenuComponent component, int icon)
 {
     Component = component;
     Icon      = icon;
 }
示例#7
0
 internal static void ButtonClicked(IInteractiveMenuComponent component, IComponentContainer collection, FrameworkMenu menu)
 {
     Console.WriteLine("ButtonClicked");
 }
示例#8
0
 internal static void TextboxChanged(IInteractiveMenuComponent component, IComponentContainer collection, FrameworkMenu menu, string value)
 {
     Console.WriteLine("TextboxChanged: " + value);
 }
示例#9
0
 internal static void HeartsChanged(IInteractiveMenuComponent component, IComponentContainer collection, FrameworkMenu menu, int value)
 {
     Console.WriteLine("HeartsChanged: " + value.ToString());
 }
示例#10
0
 internal static void CheckboxChanged(IInteractiveMenuComponent component, IComponentContainer collection, FrameworkMenu menu, bool value)
 {
     Console.WriteLine("CheckBoxChanged: " + (value ? "true" : "false"));
 }
示例#11
0
 public TabInfo(IInteractiveMenuComponent component, Texture2D texture, Rectangle crop)
 {
     Component = component;
     Texture   = texture;
     Crop      = crop;
 }
 private static void OnDecline(IInteractiveMenuComponent component, IComponentContainer container,
                               FrameworkMenu menu)
 {
     Game1.activeClickableMenu = Menu;
 }
 private static void OnBackButton(IInteractiveMenuComponent component, IComponentContainer container,
                                  FrameworkMenu menu)
 {
     Game1.activeClickableMenu = BoardMainMenu.Menu;
 }
示例#14
0
 private static void OnCareButton(IInteractiveMenuComponent component, IComponentContainer container,
                                  FrameworkMenu menu)
 {
 }
示例#15
0
        /// <summary>
        ///     Called when a command is received
        /// </summary>
        /// <param name="cmd">
        ///     The command received
        /// </param>
        public override void CommandReceived(char cmd)
        {
            if (this.Disabled)
            {
                return;
            }

            switch ((int)cmd)
            {
            case 8:
                if (this.Value.Length <= 0)
                {
                    return;
                }

                this.Value = this.Value.Substring(0, this.Value.Length - 1);
                Game1.playSound("tinyWhip");
                return;

            case 9:
                if (this.TabPressed != null)
                {
                    this.Value = this.TabPressed(this, this.Parent.GetAttachedMenu(), this.Value);
                    return;
                }

                if (!(this.Parent is IComponentCollection))
                {
                    return;
                }

                var next = false;
                IInteractiveMenuComponent first = null;
                foreach (var imc in ((IComponentCollection)this.Parent).InteractiveComponents)
                {
                    if (first == null && imc is TextboxFormComponent)
                    {
                        first = imc;
                    }

                    if (imc == this)
                    {
                        next = true;
                        continue;
                    }

                    if (next && imc is TextboxFormComponent)
                    {
                        this.Parent.GiveFocus(imc);
                        return;
                    }
                }

                this.Parent.GiveFocus(first);
                return;

            case 13:
                if (this.EnterPressed != null)
                {
                    this.Value = this.EnterPressed(this, this.Parent.GetAttachedMenu(), this.Value);
                }
                else
                {
                    this.Parent.ResetFocus();
                }

                return;
            }
        }