Exemple #1
0
        public void RemovePanel()
        {
            if (panel == null)
            {
                return;
            }

            Ui.Root.RemoveChild(fullscreenMask);
            Ui.Root.RemoveChild(panel);
            panel = fullscreenMask = null;
        }
        public void AttachPanel(Widget p)
        {
            if (panel != null)
            {
                throw new InvalidOperationException("Attempted to attach a panel to an open dropdown");
            }
            panel = p;

            // Mask to prevent any clicks from being sent to other widgets
            fullscreenMask             = new MaskWidget();
            fullscreenMask.Bounds      = new Rectangle(0, 0, Game.viewport.Width, Game.viewport.Height);
            fullscreenMask.OnMouseDown = mi => RemovePanel();
            Ui.Root.AddChild(fullscreenMask);

            var oldBounds = panel.Bounds;

            panel.Bounds = new Rectangle(RenderOrigin.X, RenderOrigin.Y + Bounds.Height, oldBounds.Width, oldBounds.Height);
            Ui.Root.AddChild(panel);
        }
Exemple #3
0
        public void AttachPanel(Widget p, Action onCancel)
        {
            if (panel != null)
            {
                throw new InvalidOperationException("Attempted to attach a panel to an open dropdown");
            }
            panel = p;

            // Mask to prevent any clicks from being sent to other widgets
            fullscreenMask              = new MaskWidget();
            fullscreenMask.Bounds       = new Rectangle(0, 0, Game.Renderer.Resolution.Width, Game.Renderer.Resolution.Height);
            fullscreenMask.OnMouseDown += mi => { Sound.PlayNotification(this.ModRules, null, "Sounds", "ClickSound", null); RemovePanel(); };
            if (onCancel != null)
            {
                fullscreenMask.OnMouseDown += _ => onCancel();
            }

            Ui.Root.AddChild(fullscreenMask);

            var oldBounds = panel.Bounds;

            panel.Bounds = new Rectangle(RenderOrigin.X, RenderOrigin.Y + Bounds.Height, oldBounds.Width, oldBounds.Height);
            Ui.Root.AddChild(panel);
        }
Exemple #4
0
 public MaskWidget(MaskWidget other)
     : base(other)
 {
     OnMouseDown = other.OnMouseDown;
 }