// Add code to be executed when game is preparing to be started.
        public override void OnGameStopped(OnGameStoppedEventArgs args)
        {
            try
            {
                var TaskGameStopped = Task.Run(() =>
                {
                    try
                    {
                        GameSettings gameSettings = PluginDatabase.GetGameSettings(args.Game.Id);
                        if (gameSettings != null)
                        {
                            PluginDatabase.SetDataFromSettings(gameSettings);
                        }
                    }
                    catch (Exception ex)
                    {
                        Common.LogError(ex, false, true, PluginDatabase.PluginName);
                    }

                    if (args.Game.Id == PluginDatabase.GameContext.Id)
                    {
                        PluginDatabase.SetThemesResources(PluginDatabase.GameContext);
                    }
                });
            }
            catch (Exception ex)
            {
                Common.LogError(ex, false, true, PluginDatabase.PluginName);
            }
        }
コード例 #2
0
        public override void OnGameStopped(OnGameStoppedEventArgs args)
        {
            if (!resolutionChanged || !detectedResolutions.Any())
            {
                return;
            }

            //Due to issue #2634 this event is raised before the game IsRunning property
            //is reverted to false, so we need to verify that only this game is set to
            //running in all the database
            if (settings.Settings.ChangeResOnlyGamesNotRunning && IsAnyOtherGameRunning(args.Game))
            {
                logger.Debug("Another game was detected as running during game stop");
            }
            else if (detectedResolutions.Any())
            {
                logger.Info("Restoring default resolution...");
                var resChangeResult = ChangeResolution(detectedResolutions.First().Key, detectedResolutions.First().Value);
                if (resChangeResult)
                {
                    resolutionChanged = false;
                }
            }
            else
            {
                logger.Info("Did not restore resolution because none were detected on startup");
            }
        }
コード例 #3
0
 public override void OnGameStopped(OnGameStoppedEventArgs args)
 {
     if (SupportedEvents.Contains(ApplicationEvent.OnGameStopped))
     {
         InvokeFunction(ApplicationEvent.OnGameStopped.ToString(), new List <object> {
             args
         });
     }
 }
コード例 #4
0
        public override void OnGameStopped(OnGameStoppedEventArgs args)
        {
            // Close splash screen manually it was not closed automatically
            IntPtr windowPtr = FindWindowByCaption(IntPtr.Zero, "PlayniteSplashScreenExtension");

            if (windowPtr != IntPtr.Zero)
            {
                SendMessage(windowPtr, WM_CLOSE, IntPtr.Zero, IntPtr.Zero);
                logger.Info("Splash window was active after closing game and was closed");
            }
        }
コード例 #5
0
        public override void OnGameStopped(OnGameStoppedEventArgs args)
        {
            RestoreBackgroundMusic();
            // Close splash screen manually it was not closed automatically
            if (currentSplashWindow != null)
            {
                currentSplashWindow.Dispatcher.Invoke(() => currentSplashWindow.Close());
                currentSplashWindow = null;
            }

            if (PlayniteApi.ApplicationInfo.Mode == ApplicationMode.Fullscreen)
            {
                timer.Start();
            }
        }
コード例 #6
0
        public override void OnGameStopped(OnGameStoppedEventArgs args)
        {
            var game = args.Game;

            if (currentGame != null && currentGame.Id == game.Id)
            {
                gameProcesses = null;
            }
            if (currentSplashWindow != null)
            {
                currentSplashWindow.Hide();
                currentSplashWindow.Topmost = false;
            }

            if (settings.Settings.SubstractSuspendedPlaytimeOnStopped)
            {
                if (game.PluginId == Guid.Empty ||
                    (game.PluginId != Guid.Empty && !settings.Settings.SubstractOnlyNonLibraryGames))
                {
                    var suspendedTime = stopwatchList.FirstOrDefault(x => x.Item1 == game.Id)?.Item2.Elapsed;
                    if (suspendedTime != null)
                    {
                        var elapsedSeconds = Convert.ToUInt64(suspendedTime.Value.TotalSeconds);
                        logger.Debug($"Suspend elapsed seconds for game {game.Name} was {elapsedSeconds}");
                        if (elapsedSeconds != 0)
                        {
                            var newPlaytime = game.Playtime > elapsedSeconds ? game.Playtime - elapsedSeconds : elapsedSeconds - game.Playtime;
                            logger.Debug($"Old playtime {game.Playtime}, new playtime {newPlaytime}");
                            game.Playtime = newPlaytime;
                            PlayniteApi.Database.Games.Update(game);
                        }
                    }
                }
            }

            RemoveGameStopwatchTuple(game);
        }
コード例 #7
0
 public override void OnGameStopped(OnGameStoppedEventArgs args)
 {
     // Add code to be executed when game is preparing to be started.
 }
コード例 #8
0
 public override void OnGameStopped(OnGameStoppedEventArgs args)
 {
     logger.Info($"TestPluginDev OnGameStopped {args.Game.Name}");
 }
コード例 #9
0
 // Add code to be executed when game is preparing to be started.
 public override void OnGameStopped(OnGameStoppedEventArgs args)
 {
 }
コード例 #10
0
 /// <summary>
 /// Called when game stopped running.
 /// </summary>
 public virtual void OnGameStopped(OnGameStoppedEventArgs args)
 {
 }