Esempio n. 1
0
        public override bool DoEvent(DoomEvent e)
        {
            if (e.Type != EventType.KeyDown)
            {
                return(true);
            }

            if (textInput != null)
            {
                var result = textInput.DoEvent(e);

                if (textInput.State == TextInputState.Canceled)
                {
                    textInput = null;
                }
                else if (textInput.State == TextInputState.Finished)
                {
                    textInput = null;
                }

                if (result)
                {
                    return(true);
                }
            }

            if (e.Key == DoomKey.Up)
            {
                Up();
                Menu.StartSound(Sfx.PSTOP);
            }

            if (e.Key == DoomKey.Down)
            {
                Down();
                Menu.StartSound(Sfx.PSTOP);
            }

            if (e.Key == DoomKey.Enter)
            {
                textInput = choice.Edit(() => DoSave(index));
                Menu.StartSound(Sfx.PISTOL);
            }

            if (e.Key == DoomKey.Escape)
            {
                Menu.Close();
                Menu.StartSound(Sfx.SWTCHX);
            }

            return(true);
        }
Esempio n. 2
0
        public override bool DoEvent(DoomEvent e)
        {
            if (e.Type != EventType.KeyDown)
            {
                return(true);
            }

            if (textInput != null)
            {
                var result = textInput.DoEvent(e);

                if (textInput.State == TextInputState.Canceled)
                {
                    textInput = null;
                }
                else if (textInput.State == TextInputState.Finished)
                {
                    textInput = null;
                }

                if (result)
                {
                    return(true);
                }
            }

            if (e.Key == DoomKey.Up)
            {
                Up();
                Menu.StartSound(Sfx.PSTOP);
            }

            if (e.Key == DoomKey.Down)
            {
                Down();
                Menu.StartSound(Sfx.PSTOP);
            }

            if (e.Key == DoomKey.Left)
            {
                var toggle = choice as ToggleMenuItem;
                if (toggle != null)
                {
                    toggle.Down();
                    Menu.StartSound(Sfx.PISTOL);
                }

                var slider = choice as SliderMenuItem;
                if (slider != null)
                {
                    slider.Down();
                    Menu.StartSound(Sfx.STNMOV);
                }
            }

            if (e.Key == DoomKey.Right)
            {
                var toggle = choice as ToggleMenuItem;
                if (toggle != null)
                {
                    toggle.Up();
                    Menu.StartSound(Sfx.PISTOL);
                }

                var slider = choice as SliderMenuItem;
                if (slider != null)
                {
                    slider.Up();
                    Menu.StartSound(Sfx.STNMOV);
                }
            }

            if (e.Key == DoomKey.Enter)
            {
                var toggle = choice as ToggleMenuItem;
                if (toggle != null)
                {
                    toggle.Up();
                    Menu.StartSound(Sfx.PISTOL);
                }

                var simple = choice as SimpleMenuItem;
                if (simple != null)
                {
                    if (simple.Selectable)
                    {
                        if (simple.Action != null)
                        {
                            simple.Action();
                        }
                        if (simple.Next != null)
                        {
                            Menu.SetCurrent(simple.Next);
                        }
                        else
                        {
                            Menu.Close();
                        }
                    }
                    Menu.StartSound(Sfx.PISTOL);
                    return(true);
                }

                if (choice.Next != null)
                {
                    Menu.SetCurrent(choice.Next);
                    Menu.StartSound(Sfx.PISTOL);
                }
            }

            if (e.Key == DoomKey.Escape)
            {
                Menu.Close();
                Menu.StartSound(Sfx.SWTCHX);
            }

            return(true);
        }
Esempio n. 3
0
        public bool DoEvent(DoomEvent e)
        {
            if (e.Type != EventType.KeyDown)
            {
                return(true);
            }

            if (textInput != null)
            {
                var result = textInput.DoEvent(e);

                if (textInput.State == TextInputState.Canceled)
                {
                    textInput = null;
                }
                else if (textInput.State == TextInputState.Finished)
                {
                    textInput = null;
                }

                if (result)
                {
                    return(true);
                }
            }

            if (e.Key == DoomKeys.Up)
            {
                Up();
            }

            if (e.Key == DoomKeys.Down)
            {
                Down();
            }

            if (e.Key == DoomKeys.Left)
            {
                var toggle = choice as ToggleMenuItem;
                if (toggle != null)
                {
                    toggle.Down();
                }

                var slider = choice as SliderMenuItem;
                if (slider != null)
                {
                    slider.Down();
                }
            }

            if (e.Key == DoomKeys.Right)
            {
                var toggle = choice as ToggleMenuItem;
                if (toggle != null)
                {
                    toggle.Up();
                }

                var slider = choice as SliderMenuItem;
                if (slider != null)
                {
                    slider.Up();
                }
            }

            if (e.Key == DoomKeys.Enter)
            {
                var toggle = choice as ToggleMenuItem;
                if (toggle != null)
                {
                    toggle.Up();
                }

                var textBox = choice as TextBoxMenuItem;
                if (textBox != null)
                {
                    textInput = textBox.Edit();
                }

                var simple = choice as SimpleMenuItem;
                if (simple != null && simple.Action != null)
                {
                    simple.Action();
                    menu.Close();
                    return(true);
                }

                if (choice.Next != null)
                {
                    menu.SetCurrent(choice.Next);
                }
            }

            if (e.Key == DoomKeys.Escape)
            {
                menu.Close();
            }

            return(true);
        }