Exemplo n.º 1
0
        private void OnInput(InputMessage.MessageType inputType, bool pressed = false, char key = char.MinValue, Player player = null)
        {
            var inputMessage = new InputMessage(inputType, pressed, key, player);

            if (Ballz.The().MessageOverlay != null)
            {
                Ballz.The().MessageOverlay.HandleInput(inputMessage);
            }
            else
            {
                Input?.Invoke(this, inputMessage);                 //todo: use object pooling and specify message better
            }
        }
Exemplo n.º 2
0
        public static MessageOverlay Show(string header, string message = null, string buttonText = "OK", Action onButton = null, InputMessage.MessageType buttonKey = InputMessage.MessageType.ControlsAction)
        {
            if (Ballz.The().MessageOverlay != null)
            {
                return(null);
            }

            MessageOverlay overlay = new MessageOverlay(header, message, buttonText, onButton, buttonKey);

            UserInterface.AddEntity(overlay);

            return(overlay);
        }
Exemplo n.º 3
0
        public MessageOverlay(string header, string message = null, string buttonText = "OK", Action onButton = null, InputMessage.MessageType buttonKey = InputMessage.MessageType.ControlsAction) : base(new Vector2(1, 1), PanelSkin.Simple)
        {
            InnerPanel = new Panel(new Vector2(600, 400), PanelSkin.Default, Anchor.Center);
            FillColor  = new Color(Color.Black, 0.5f);

            AddChild(InnerPanel);

            if (header != null)
            {
                HeaderText = new Header(header);
                InnerPanel.AddChild(HeaderText);
            }

            if (message != null)
            {
                MessageText = new Label(message, Anchor.Center);
                InnerPanel.AddChild(MessageText);
            }

            if (buttonText != null)
            {
                CloseButton          = new Button(buttonText, anchor: Anchor.BottomCenter);
                CloseButton.OnClick += (e) =>
                {
                    Hide();
                    onButton?.Invoke();
                };
                InnerPanel.AddChild(CloseButton);
            }
        }