Beispiel #1
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);
        }
Beispiel #2
0
 public void PushMessageBox(string message, MessageBox.ButtonFlags buttons, Action<int> action)
 {
     PushMessageBox(message, buttons, UI.ModalDialog.DefaultOpacity, action);
 }