Exemple #1
0
        public void PushEmpty(float opacity)
        {
            var modalDialog = new UI.ModalDialog
            {
                Opacity = opacity
            };

            modalDialog.Begin(GameApp.Service<UIManager>().Root.Listeners.Last(l => l is UI.EventDispatcher) as UI.EventDispatcher, null);
            m_dialogStack.Push(modalDialog);
        }
Exemple #2
0
        public void PushMessageBox(string message, MessageBox.ButtonFlags buttons, float opacity, Action<int> action)
        {
            if (message == null)
            {
                throw new ArgumentNullException("message");
            }

            var buttonTexts = new TextRenderer.IFormattedText[MessageBox.NumButtons];
            for (int i = 0; i < MessageBox.NumButtons; ++i)
            {
                buttonTexts[i] = ((uint)buttons & (1U << i)) != 0 ? m_buttonTexts[i] : null;
            }
            var messageBox = new MessageBox(m_buttonFace, buttonTexts)
            {
                Text = GameApp.Service<TextRenderer>().FormatText(message, new Graphics.TextRenderer.FormatOptions(m_msgFont))
            };
            messageBox.ButtonClicked += button =>
            {
                if (action != null)
                {
                    action(button);
                }
                System.Diagnostics.Debug.Assert(m_dialogStack.Peek().Content == messageBox);
                PopTopDialog();
            };

            var modalDialog = new UI.ModalDialog
            {
                Opacity = opacity
            };
            modalDialog.Begin(GameApp.Service<UIManager>().Root.Listeners.Last(l => l is UI.EventDispatcher) as UI.EventDispatcher, messageBox);
            m_dialogStack.Push(modalDialog);
        }
Exemple #3
0
        public void PushCardModelSelector(string message, IIndexable<ICardModel> candidates, float opacity, Action<ICardModel> action)
        {
            if (message == null)
            {
                throw new ArgumentNullException("message");
            }

            var cardModelSelector = new CardModelSelector(m_buttonFace,
                m_buttonTexts[MessageBox.ButtonOK], m_buttonTexts[MessageBox.ButtonCancel],
                m_leftButtonFace, null, m_rightButtonFace, null, candidates)
            {
                Text = GameApp.Service<TextRenderer>().FormatText(message, new Graphics.TextRenderer.FormatOptions(m_msgFont))
            };
            cardModelSelector.DialogClosed += card =>
            {
                if (action != null)
                {
                    action(card);
                }
                System.Diagnostics.Debug.Assert(m_dialogStack.Peek().Content == cardModelSelector);
                PopTopDialog();
            };

            var modalDialog = new UI.ModalDialog
            {
                Opacity = opacity
            };
            modalDialog.Begin(GameApp.Service<UIManager>().Root.Listeners.Last(l => l is UI.EventDispatcher) as UI.EventDispatcher, cardModelSelector);
            m_dialogStack.Push(modalDialog);
        }
Exemple #4
0
        public void PushNumberSelector(string message, int min, int max, float opacity, Action<int, int> action)
        {
            if (message == null)
            {
                throw new ArgumentNullException("message");
            }

            var numberSelector = new NumberSelector(m_digits, m_signs, m_upButtonFace, m_downButtonFace, m_buttonFace, m_okCancelTexts)
            {
                Text = GameApp.Service<TextRenderer>().FormatText(message, new Graphics.TextRenderer.FormatOptions(m_msgFont)),
                OkCancelButtonFaceDisabled = m_buttonFaceDisabled
            };
            numberSelector.SetRange(min, max);
            numberSelector.ButtonClicked += (btn, value) =>
            {
                if (action != null)
                {
                    action(btn, value);
                }
                System.Diagnostics.Debug.Assert(m_dialogStack.Peek().Content == numberSelector);
                PopTopDialog();
            };

            var modalDialog = new UI.ModalDialog
            {
                Opacity = opacity
            };
            modalDialog.Begin(GameApp.Service<UIManager>().Root.Listeners.Last(l => l is UI.EventDispatcher) as UI.EventDispatcher, numberSelector);
            m_dialogStack.Push(modalDialog);
        }