Exemplo n.º 1
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();
            }

            panelRoot = PanelRoot == null ? Ui.Root : Ui.Root.Get(PanelRoot);

            panelRoot.AddChild(fullscreenMask);

            var oldBounds = panel.Bounds;

            panel.Bounds = new Rectangle(
                RenderOrigin.X - panelRoot.RenderOrigin.X,
                RenderOrigin.Y + Bounds.Height - panelRoot.RenderOrigin.Y,
                oldBounds.Width,
                oldBounds.Height);
            panelRoot.AddChild(panel);
        }
Exemplo n.º 2
0
		public void RemovePanel()
		{
			if (panel == null)
				return;

			panelRoot.RemoveChild(fullscreenMask);
			panelRoot.RemoveChild(panel);
			panel = fullscreenMask = null;

			Ui.ResetTooltips();
		}
Exemplo n.º 3
0
        public void RemovePanel()
        {
            if (panel == null)
            {
                return;
            }

            panelRoot.RemoveChild(fullscreenMask);
            panelRoot.RemoveChild(panel);
            panel = fullscreenMask = null;
        }
Exemplo n.º 4
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 => { Game.Sound.PlayNotification(ModRules, null, "Sounds", ClickSound, null); RemovePanel(); };
            if (onCancel != null)
            {
                fullscreenMask.OnMouseDown += _ => onCancel();
            }

            panelRoot = PanelRoot == null ? Ui.Root : Ui.Root.Get(PanelRoot);

            panelRoot.AddChild(fullscreenMask);

            var oldBounds = panel.Bounds;
            var panelX    = RenderOrigin.X - panelRoot.RenderOrigin.X;

            if (PanelAlign == TextAlign.Right)
            {
                panelX += Bounds.Width - oldBounds.Width;
            }
            else if (PanelAlign == TextAlign.Center)
            {
                panelX += (Bounds.Width - oldBounds.Width) / 2;
            }

            var panelY = RenderOrigin.Y + Bounds.Height - panelRoot.RenderOrigin.Y;

            if (panelY + oldBounds.Height > Game.Renderer.Resolution.Height)
            {
                panelY -= (Bounds.Height + oldBounds.Height);
            }

            panel.Bounds = new Rectangle(
                panelX,
                panelY,
                oldBounds.Width,
                oldBounds.Height);
            panelRoot.AddChild(panel);

            var scrollPanel = panel as ScrollPanelWidget;

            if (scrollPanel != null)
            {
                scrollPanel.ScrollToSelectedItem();
            }
        }
Exemplo n.º 5
0
		public MaskWidget(MaskWidget other)
			: base(other)
		{
			OnMouseDown = other.OnMouseDown;
		}