Exemplo n.º 1
0
 private void OnApplicationPause(bool pause)
 {
     if (pause)
     {
         OnQuit?.Invoke();
     }
 }
Exemplo n.º 2
0
        public static void ProcessEvents()
        {
            while (SDL_PollEvent(out var ev) == 1)
            {
                switch (ev.type)
                {
                case SDL_EventType.SDL_QUIT:
                    OnQuit?.Invoke();
                    break;

                case SDL_EventType.SDL_KEYDOWN:
                case SDL_EventType.SDL_KEYUP:
                    ProcessKeyEvent(ev);
                    break;

                case SDL_EventType.SDL_MOUSEBUTTONDOWN:
                case SDL_EventType.SDL_MOUSEBUTTONUP:
                case SDL_EventType.SDL_MOUSEMOTION:
                    ProcessMouseEvent(ev);
                    break;

                case SDL_EventType.SDL_WINDOWEVENT:
                    ProcessWindowEvent(ev);
                    break;

                case SDL_EventType.SDL_CONTROLLERDEVICEADDED:
                    break;

                case SDL_EventType.SDL_CONTROLLERDEVICEREMOVED:
                    break;
                }
            }
        }
Exemplo n.º 3
0
 public void Quit()
 {
     OnQuit?.Invoke();
     OnQuit         = null;
     Time.timeScale = 1;
     SceneManager.LoadScene(0);
 }
Exemplo n.º 4
0
 private void OnApplicationFocus(bool focus)
 {
     if (!focus)
     {
         OnQuit?.Invoke();
     }
 }
Exemplo n.º 5
0
 internal void Quit(string msg)
 {
     if (OnQuit != null)
     {
         OnQuit.Invoke(this, msg);
     }
 }
Exemplo n.º 6
0
 private void Update()
 {
     if (input.Esc)
     {
         OnQuit.Invoke();
     }
 }
 private void Update()
 {
     if (Input.GetKey(KeyCode.Escape))
     {
         OnQuit?.Invoke();
     }
 }
        public void Execute(string[] args)
        {
            var ts = new TemplateSpecification();

            foreach (var q in ts.Questions)
            {
                string answer = q.AskQuestion();

                if (IsQuit(answer))
                {
                    OnQuit.Invoke(this, null);
                }
            }

            ts.ProcessChoices();

            Console.WriteLine();

            var json = JsonConvert.SerializeObject(ts, Formatting.Indented);

            Console.WriteLine();
            Console.WriteLine("Serialised Result (that is passed to template creation service):");
            Console.WriteLine();
            Console.WriteLine(json);
        }
Exemplo n.º 9
0
 private static void BeforeQuit()
 {
     OnBeforeQuit?.Invoke();
     Console.WriteLine("Press a key to complete...");
     Console.ReadKey();
     OnQuit?.Invoke();
 }
Exemplo n.º 10
0
        /// <summary>
        /// Stops the API.
        /// </summary>
        public void Stop()
        {
            //Mark the API as not running.
            IsRunning = false;

            Logger.Log("EliteAPI has been terminated.");

            OnQuit?.Invoke(this, EventArgs.Empty);
        }
Exemplo n.º 11
0
        /// <summary>
        /// Verarbeitet das Verlassen eines Users des Servers
        /// </summary>
        /// <seealso cref="OnQuit"/>
        private void _connection_OnQuit(object sender, QuitEventArgs e)
        {
            Log.Information("{Nickname} hat den Server verlassen ({QuitMessage})", e.Who, e.QuitMessage);
            MaintainUser(e.Who);

            ThreadPool.QueueUserWorkItem(x =>
            {
                OnQuit?.Invoke(this, e);
            });
        }
Exemplo n.º 12
0
    public void OnQuitIconClicked()
    {
        if (OnQuit != null)
        {
            OnQuit.Invoke();
        }

        OnUnfocus();

        Application.Quit();
    }
Exemplo n.º 13
0
        private void load(OsuColour colours)
        {
            AddButton("Continue", colours.Green, () => OnResume?.Invoke());
            AddButton("Retry", colours.YellowDark, () => OnRetry?.Invoke());
            AddButton("Quit", new Color4(170, 27, 39, 255), () => OnQuit?.Invoke());

            AddInternal(pauseLoop = new SkinnableSound(new SampleInfo("pause-loop"))
            {
                Looping = true,
                Volume  = { Value = 0 }
            });
        }
Exemplo n.º 14
0
        private static void HandleStandardKey(ConsoleKeyInfo?keyInfo)
        {
            string key = keyInfo.Value.KeyChar.ToString();

            switch (key)
            {
            case " ":     // Refresh
                Console.Clear();
                break;

            case "|":
                ConsoleEx.WriteLineEnh("*Cancelling..*");
                _cts.Cancel();
                ShortDelay();
                Console.Clear();
                break;

            case "^":     // Restart (forget all state)
                if (ConsoleEx.PromptEnhForInputKeysUpper("Are you sure? Y/N ", "yn") == "Y")
                {
                    ConsoleEx.WriteLineEnh("*Restarting..* (if supported)"); ShortDelay();
                    OnRestart?.Invoke(); ShortDelay();
                    Console.Clear();
                }
                else
                {
                    ShortDelay(); Console.Clear();
                }
                break;

            case "q":     // Quit (lower)
                if (ConsoleEx.PromptEnhForInputKeysUpper("Are you sure? Y/N ", "yn") == "Y")
                {
                    ConsoleEx.WriteLineEnh("\n*Quitting..*"); ShortDelay();
                    OnQuit?.Invoke(); ShortDelay();
                    _running = false;
                }
                else
                {
                    ShortDelay(); Console.Clear();
                }
                break;

            case "Q":     // Quit (upper)
                ConsoleEx.WriteLineEnh("*Quitting..*"); ShortDelay();
                OnQuit?.Invoke(); ShortDelay();
                _running = false;
                break;

            default:
                break;
            }
        }
Exemplo n.º 15
0
        public override Task StopAsync(CancellationToken cancellationToken)
        {
            streams.ForEach(stream => { stream.Dispose(); }); //close all FileStreams to allow for deletion

            OnQuit?.Invoke();                                 //delete unfinished files

            var serializer = new BinaryFormatter();

            serializer.Serialize(File.Open($@"{FwgetterDir}\ipsw\last.bin", FileMode.OpenOrCreate), lastUpdates);//write log of downloaded files

            _logger.LogCritical("successfully saved update log ");
            return(base.StopAsync(cancellationToken));
        }
Exemplo n.º 16
0
        private void load(OsuColour colours)
        {
            AddButton("Continue", colours.Green, () => OnResume?.Invoke());
            AddButton("Retry", colours.YellowDark, () => OnRetry?.Invoke());
            AddButton("Quit", new Color4(170, 27, 39, 255), () => OnQuit?.Invoke());

            AddInternal(pauseLoop = new SkinnableSound(new SampleInfo("pause-loop"))
            {
                Looping = true,
            });

            // SkinnableSound only plays a sound if its aggregate volume is > 0, so the volume must be turned up before playing it
            pauseLoop.VolumeTo(minimum_volume);
        }
Exemplo n.º 17
0
        public RuntimeService()
        {
            _runtimeGameObject = new GameObject("RuntimeClients");

            Object.DontDestroyOnLoad(_runtimeGameObject);

            _runtimeClient = RegisterClient <RuntimeClient>();

            _runtimeClient.OnUpdate      += () => OnUpdate?.Invoke();
            _runtimeClient.OnFixedUpdate += () => OnFixedUpdate?.Invoke();
            _runtimeClient.OnLateUpdate  += () => OnLateUpdate?.Invoke();
            _runtimeClient.OnQuit        += () => OnQuit?.Invoke();
            _runtimeClient.OnPause       += pause => OnPause?.Invoke(pause);
        }
Exemplo n.º 18
0
    public void Exit(string input)
    {
        if (!pauseMode)
        {
            OnQuit?.Invoke();
#if UNITY_EDITOR
            UnityEditor.EditorApplication.isPlaying = false;
#else
            Application.Quit();
#endif
        }
        else
        {
            SceneManager.LoadScene("MainMenu");
        }
    }
Exemplo n.º 19
0
        internal void Stop()
        {
            if (hasStopped)
            {
                return;
            }
            LogMuxer.Instance.Debug("Killing child processes");
            foreach (var wrapper in _programPool)
            {
                wrapper.Stop();
            }

            // First we notify all running process to quit
            LogMuxer.Instance.Debug("Killing subprocesses");
            foreach (var pid in ProgramWrapper.GetChildProcessIds(ProgramWrapper.SelfProcessId))
            {
                ProgramWrapper.QuitProcess(Process.GetProcessById(pid));
            }

            // ExecStop
            // only if the service started successfully
            if (hasStartedSuccessfully)
            {
                LogMuxer.Instance.Debug("Executing ExecStop");
                for (var i = 0; i < Globals.Config.ExecStop.Count; ++i)
                {
                    Run(Globals.Config.ExecStop[i], "ExecStop", i, isAsync: false);
                }
            }

            // ExecStopPost
            LogMuxer.Instance.Debug("Executing ExecStopPost");
            for (var i = 0; i < Globals.Config.ExecStopPost.Count; ++i)
            {
                Run(Globals.Config.ExecStopPost[i], "ExecStopPost", i, isAsync: false);
            }

            OnQuit?.Invoke(this, null);

            hasStopped = true;
        }
Exemplo n.º 20
0
        private void load(OsuColour colours)
        {
            AddButton("Retry", colours.YellowDark, () => OnRetry?.Invoke());
            AddButton("Quit", new Color4(170, 27, 39, 255), () => OnQuit?.Invoke());

            Add(new Container
            {
                Anchor           = Anchor.BottomLeft,
                Origin           = Anchor.BottomLeft,
                RelativeSizeAxes = Axes.X,
                Height           = TwoLayerButton.SIZE_EXTENDED.Y,
                Children         = new Drawable[]
                {
                    new Box
                    {
                        RelativeSizeAxes = Axes.Both,
                        Colour           = Color4Extensions.FromHex("#333")
                    },
                    new FillFlowContainer
                    {
                        Anchor           = Anchor.Centre,
                        Origin           = Anchor.Centre,
                        AutoSizeAxes     = Axes.X,
                        RelativeSizeAxes = Axes.Y,
                        Spacing          = new Vector2(5),
                        Padding          = new MarginPadding(10),
                        Direction        = FillDirection.Horizontal,
                        Children         = new Drawable[]
                        {
                            new SaveScoreButton()
                            {
                                OnSave           = OnSave,
                                RelativeSizeAxes = Axes.Y,
                                Width            = 300
                            },
                        }
                    }
                }
            });
        }
Exemplo n.º 21
0
 private void load(OsuColour colours)
 {
     AddButton("Continue", colours.Green, () => OnResume?.Invoke());
     AddButton("Retry", colours.YellowDark, () => OnRetry?.Invoke());
     AddButton("Quit", new Color4(170, 27, 39, 255), () => OnQuit?.Invoke());
 }
Exemplo n.º 22
0
        public static void Run(string title, int width, int height, ErrorHandler errorHandler)
        {
            App.errorHandler = errorHandler;

            if (errorHandler != null)
            {
                try { Run(); }
                catch (Exception e) { errorHandler(e); }
            }
            else
            {
                Run();
            }

            void Run()
            {
                if (platform == null)
                {
                    throw new Exception("App has not been initialized.");
                }
                if (Running)
                {
                    throw new Exception("App is already running.");
                }

                Running = true;
                platform.Init(title, width, height);
                platform.CenterWindow();

                platform.OnQuit           += Quit;
                platform.OnWinClose       += Quit;
                platform.OnWinFocusGained += () => Focused = true;
                platform.OnWinFocusLost   += () => Focused = false;

                GL.Init();
                Time.Init(1f / 60f);
                Screen.Init();
                Mouse.Init();
                Keyboard.Init();
                Joystick.Init();

                OnInit?.Invoke();

                double prevTime   = platform.GetTime();
                double frameTimer = 0.0;

                while (Running)
                {
                    platform.PollEvents();

                    if (!Focused && !UpdateWhileFocused)
                    {
                        prevTime = (float)platform.GetTime();
                        continue;
                    }

                    if (Running)
                    {
                        double currTime  = platform.GetTime();
                        double deltaTime = currTime - prevTime;
                        if (deltaTime > 0.0)
                        {
                            FPS = (int)(1.0 / (currTime - prevTime));
                        }
                        prevTime = currTime;

                        if (FixedFramerate)
                        {
                            if (!Screen.VSync)
                            {
                                frameTimer += deltaTime;
                                while (frameTimer >= frameDuration)
                                {
                                    frameTimer -= frameDuration;
                                    Update(frameDuration);
                                }
                            }
                            else
                            {
                                Update(frameDuration);
                            }
                        }
                        else
                        {
                            Update(deltaTime);
                        }

                        void Update(double dt)
                        {
                            Time.PreUpdate((float)dt);
                            Mouse.PreUpdate();

                            OnUpdate?.Invoke();

                            Mouse.PostUpdate();
                            Keyboard.PostUpdate();
                            Joystick.PostUpdate();

                            Texture.UnbindAll();

                            DrawCall.Begin();
                            OnRender?.Invoke();
                            DrawCall.End();

                            platform.SwapBuffers();
                        }
                    }
                }

                OnQuit?.Invoke();

                platform.Quit();
            }
        }
Exemplo n.º 23
0
 private void OnApplicationQuit()
 {
     OnQuit.Invoke();
 }
Exemplo n.º 24
0
 public virtual void Quit()
 {
     AudioManager.Instance.PlaySound(cancelClip);
     if (OnQuit != null) OnQuit.Invoke();
 }
Exemplo n.º 25
0
 private void RenderWindowOnClosed(object sender, EventArgs e)
 {
     OnQuit?.Invoke(this);
     RenderWindow.Close();
 }
Exemplo n.º 26
0
        public override void PollEvents()
        {
            while (SDL.PollEvent(out ev) == 1)
            {
                switch (ev.Type)
                {
                case EventType.Quit:
                    OnQuit?.Invoke();
                    break;

                case EventType.KeyDown:
                    OnKeyDown?.Invoke(ev.Key.Keysym.Sym, ev.Key.Keysym.ScanCode);
                    break;

                case EventType.KeyUp:
                    OnKeyUp?.Invoke(ev.Key.Keysym.Sym, ev.Key.Keysym.ScanCode);
                    break;

                case EventType.MouseMotion:
                    OnMouseMove?.Invoke(ev.Motion.X, ev.Motion.Y);
                    break;

                case EventType.MouseButtonDown:
                    OnMouseButtonDown?.Invoke(ev.Button.Button);
                    break;

                case EventType.MouseButtonUp:
                    OnMouseButtonUp?.Invoke(ev.Button.Button);
                    break;

                case EventType.MouseWheel:
                    OnMouseScroll?.Invoke(ev.Wheel.X, ev.Wheel.Y);
                    break;

                case EventType.JoyDeviceAdded:
                    OnJoyDeviceAdd?.Invoke(ev.JDevice.Which);
                    break;

                case EventType.JoyDeviceRemoved:
                    OnJoyDeviceRemove?.Invoke(ev.JDevice.Which);
                    break;

                case EventType.JoyButtonDown:
                    OnJoyButtonDown?.Invoke(ev.JButton.Which, ev.JButton.Button);
                    break;

                case EventType.JoyButtonUp:
                    OnJoyButtonDown?.Invoke(ev.JButton.Which, ev.JButton.Button);
                    break;

                case EventType.JoyAxisMotion:
                    OnJoyAxisMove?.Invoke(ev.JAxis.Which, ev.JAxis.Axis, ev.JAxis.Value / (float)short.MaxValue);
                    break;

                case EventType.WindowEvent:
                    if (ev.Window.WindowID == windowID)
                    {
                        switch (ev.Window.Event)
                        {
                        case WindowEventID.Close:
                            OnWinClose?.Invoke();
                            break;

                        case WindowEventID.Shown:
                            OnWinShown?.Invoke();
                            break;

                        case WindowEventID.Hidden:
                            OnWinHidden?.Invoke();
                            break;

                        case WindowEventID.Exposed:
                            OnWinExposed?.Invoke();
                            break;

                        case WindowEventID.Moved:
                            OnWinMoved?.Invoke();
                            break;

                        case WindowEventID.Resized:
                            OnWinResized?.Invoke();
                            break;

                        case WindowEventID.Minimized:
                            OnWinMinimized?.Invoke();
                            break;

                        case WindowEventID.Maximized:
                            OnWinMaximized?.Invoke();
                            break;

                        case WindowEventID.Restored:
                            OnWinRestored?.Invoke();
                            break;

                        case WindowEventID.Enter:
                            OnWinEnter?.Invoke();
                            break;

                        case WindowEventID.Leave:
                            OnWinLeave?.Invoke();
                            break;

                        case WindowEventID.FocusGained:
                            OnWinFocusGained?.Invoke();
                            break;

                        case WindowEventID.FocusLost:
                            OnWinFocusLost?.Invoke();
                            break;

                        default:
                            OnWinOtherEvent?.Invoke((int)ev.Window.Event);
                            break;
                        }
                    }
                    break;

                default:
                    OnOtherEvent?.Invoke((int)ev.Type);
                    break;
                }
            }
        }
 public void OnQuickClicked()
 {
     OnQuit?.Invoke(this, EventArgs.Empty);
 }
Exemplo n.º 28
0
 void OnPlatformClose(object sender, EventArgs e)
 {
     OnQuit?.Invoke(this, e);
 }
Exemplo n.º 29
0
 private static void RaiseOnQuit()
 {
     IsQuitting = true;
     OnQuit?.Invoke();
     OnQuit = null;
 }
Exemplo n.º 30
0
 public void quitGame()
 {
     Time.timeScale = 1f;
     SceneManager.LoadScene("Main Menu");
     OnQuit?.Invoke();
 }