Ejemplo n.º 1
0
        public static void MainMenuSystem(WndWindow element, WndWindowMessage message, UIElementCallbackContext context)
        {
            switch (message.MessageType)
            {
            case WndWindowMessageType.SelectedButton:
                switch (message.Element.Name)
                {
                case "MainMenu.wnd:ButtonOptions":
                    context.WindowManager.PushWindow(@"Menus\OptionsMenu.wnd");
                    break;

                case "MainMenu.wnd:ButtonExit":
                    var exitWindow = context.WindowManager.PushWindow(@"Menus\QuitMessageBox.wnd");
                    exitWindow.Root.FindChild("QuitMessageBox.wnd:StaticTextTitle").Text          = "EXIT?";
                    exitWindow.Root.FindChild("QuitMessageBox.wnd:StaticTextTitle").TextAlignment = TextAlignment.Leading;
                    exitWindow.Root.FindChild("QuitMessageBox.wnd:StaticTextMessage").Text        = "Are you sure you want to exit?";
                    exitWindow.Root.FindChild("QuitMessageBox.wnd:ButtonOk").Show();
                    exitWindow.Root.FindChild("QuitMessageBox.wnd:ButtonOk").Text = "YES";
                    exitWindow.Root.FindChild("QuitMessageBox.wnd:ButtonCancel").Show();
                    exitWindow.Root.FindChild("QuitMessageBox.wnd:ButtonCancel").Text = "NO";
                    break;
                }
                break;
            }
        }
Ejemplo n.º 2
0
        internal WndTopLevelWindow(WndFile wndFile, WndWindow root, WndCallbackResolver callbackResolver)
        {
            Root = root;

            LayoutInit     = callbackResolver.GetGuiWindowCallback(wndFile.LayoutBlock.LayoutInit);
            LayoutUpdate   = callbackResolver.GetGuiWindowCallback(wndFile.LayoutBlock.LayoutUpdate);
            LayoutShutdown = callbackResolver.GetGuiWindowCallback(wndFile.LayoutBlock.LayoutShutdown);
        }
Ejemplo n.º 3
0
        internal WndTopLevelWindow(WndFile wndFile, WndWindow root)
        {
            Root = root;

            LayoutInit     = CallbackUtility.GetGuiWindowCallback(wndFile.LayoutBlock.LayoutInit);
            LayoutUpdate   = CallbackUtility.GetGuiWindowCallback(wndFile.LayoutBlock.LayoutUpdate);
            LayoutShutdown = CallbackUtility.GetGuiWindowCallback(wndFile.LayoutBlock.LayoutShutdown);
        }
Ejemplo n.º 4
0
        public static void PassSelectedButtonsToParentSystem(WndWindow element, WndWindowMessage message, UIElementCallbackContext context)
        {
            if (message.MessageType != WndWindowMessageType.SelectedButton)
            {
                return;
            }

            element.Parent.SystemCallback.Invoke(element.Parent, message, context);
        }
Ejemplo n.º 5
0
 public static void MainMenuInput(WndWindow element, WndWindowMessage message, UIElementCallbackContext context)
 {
     // Any input at all (mouse, keyboard) will trigger the main menu fade-in.
     if (!_doneMainMenuFadeIn)
     {
         context.WindowManager.TransitionManager.QueueTransition(null, element.Window, "MainMenuFade");
         context.WindowManager.TransitionManager.QueueTransition(null, element.Window, "MainMenuDefaultMenu");
         element.Window.Root.FindChild("MainMenu.wnd:MainMenuRuler").Show();
         _doneMainMenuFadeIn = true;
     }
 }
Ejemplo n.º 6
0
        public static void DoActionRecursive(this WndWindow element, Func <WndWindow, bool> action)
        {
            if (!action(element))
            {
                return;
            }

            foreach (var child in element.Children)
            {
                child.DoActionRecursive(action);
            }
        }
Ejemplo n.º 7
0
 public static void OptionsMenuSystem(WndWindow element, WndWindowMessage message, UIElementCallbackContext context)
 {
     switch (message.MessageType)
     {
     case WndWindowMessageType.SelectedButton:
         switch (message.Element.Name)
         {
         case "OptionsMenu.wnd:ButtonBack":
             context.WindowManager.PopWindow();
             break;
         }
         break;
     }
 }
Ejemplo n.º 8
0
 public static void QuitMessageBoxSystem(WndWindow element, WndWindowMessage message, UIElementCallbackContext context)
 {
     switch (message.MessageType)
     {
     case WndWindowMessageType.SelectedButton:
         switch (message.Element.Name)
         {
         case "QuitMessageBox.wnd:ButtonCancel":
             context.WindowManager.PopWindow();
             break;
         }
         break;
     }
 }
Ejemplo n.º 9
0
 public WndWindowMessage(
     WndWindowMessageType messageType,
     WndWindow element,
     in Point2D?mousePosition = null)
Ejemplo n.º 10
0
        public override InputMessageResult HandleMessage(InputMessage message)
        {
            var context = new UIElementCallbackContext(_windowManager, _game);

            switch (message.MessageType)
            {
            case InputMessageType.MouseMove:
            {
                var element = _windowManager.FindWindow(message.Value.MousePosition);
                if (element != _lastHighlightedElement)
                {
                    if (_lastHighlightedElement != null)
                    {
                        _lastHighlightedElement.InputCallback.Invoke(
                            _lastHighlightedElement,
                            new WndWindowMessage(WndWindowMessageType.MouseExit, _lastHighlightedElement),
                            context);
                    }
                    _lastHighlightedElement = element;
                    if (element != null)
                    {
                        element.InputCallback.Invoke(
                            element,
                            new WndWindowMessage(WndWindowMessageType.MouseEnter, element),
                            context);
                    }
                }
                if (element != null)
                {
                    var mousePosition = element?.PointToClient(message.Value.MousePosition);
                    element.InputCallback.Invoke(
                        element,
                        new WndWindowMessage(WndWindowMessageType.MouseMove, element, mousePosition),
                        context);
                    return(InputMessageResult.Handled);
                }
                break;
            }

            case InputMessageType.MouseLeftButtonDown:
            {
                var element = _windowManager.FindWindow(message.Value.MousePosition);
                if (element != null)
                {
                    var mousePosition = element.PointToClient(message.Value.MousePosition);
                    element.InputCallback.Invoke(
                        element,
                        new WndWindowMessage(WndWindowMessageType.MouseDown, element, mousePosition),
                        context);
                    return(InputMessageResult.Handled);
                }
                break;
            }

            case InputMessageType.MouseLeftButtonUp:
            {
                var element = _windowManager.FindWindow(message.Value.MousePosition);
                if (element != null)
                {
                    element.InputCallback.Invoke(
                        element,
                        new WndWindowMessage(WndWindowMessageType.MouseUp, element, message.Value.MousePosition),
                        context);
                    return(InputMessageResult.Handled);
                }
                break;
            }

            case InputMessageType.KeyDown:
            {
                if (message.Value.Key == Key.Escape && _windowManager.OpenWindowCount > 1)
                {
                    _windowManager.PopWindow();
                    return(InputMessageResult.Handled);
                }
                break;
            }
            }

            return(InputMessageResult.NotHandled);
        }
Ejemplo n.º 11
0
        public override InputMessageResult HandleMessage(InputMessage message)
        {
            var context = new UIElementCallbackContext(_windowManager);

            switch (message.MessageType)
            {
            case InputMessageType.MouseMove:
            {
                var element = _windowManager.FindWindow(new Vector2(message.MouseX.Value, message.MouseY.Value));
                if (element != _lastHighlightedElement)
                {
                    if (_lastHighlightedElement != null)
                    {
                        _lastHighlightedElement.InputCallback.Invoke(
                            _lastHighlightedElement,
                            new WndWindowMessage(WndWindowMessageType.MouseExit, _lastHighlightedElement),
                            context);
                    }
                    _lastHighlightedElement = element;
                    if (element != null)
                    {
                        element.InputCallback.Invoke(
                            element,
                            new WndWindowMessage(WndWindowMessageType.MouseEnter, element),
                            context);
                    }
                }
                if (element != null)
                {
                    element.InputCallback.Invoke(
                        element,
                        new WndWindowMessage(WndWindowMessageType.MouseMove, element),
                        context);
                    return(InputMessageResult.Handled);
                }
                break;
            }

            case InputMessageType.MouseDown:
            {
                var element = _windowManager.FindWindow(new Vector2(message.MouseX.Value, message.MouseY.Value));
                if (element != null)
                {
                    element.InputCallback.Invoke(
                        element,
                        new WndWindowMessage(WndWindowMessageType.MouseDown, element),
                        context);
                    return(InputMessageResult.Handled);
                }
                break;
            }

            case InputMessageType.MouseUp:
            {
                var element = _windowManager.FindWindow(new Vector2(message.MouseX.Value, message.MouseY.Value));
                if (element != null)
                {
                    element.InputCallback.Invoke(
                        element,
                        new WndWindowMessage(WndWindowMessageType.MouseUp, element),
                        context);
                    return(InputMessageResult.Handled);
                }
                break;
            }
            }

            return(InputMessageResult.NotHandled);
        }
Ejemplo n.º 12
0
 public static void W3DNoDraw(WndWindow element, Game game)
 {
 }
Ejemplo n.º 13
0
 public static void PassMessagesToParentSystem(WndWindow element, WndWindowMessage message, UIElementCallbackContext context)
 {
     element.Parent.SystemCallback.Invoke(element.Parent, message, context);
 }