Exemplo n.º 1
0
        public void Restart()
        {
            // If Cheat tool is loaded, restarting will restart the list too anyway
            if (!GlobalWin.Tools.Has <Cheats>())
            {
                Global.CheatList.NewList(GenerateDefaultCheatFilename(), autosave: true);
            }

            var unavailable = new List <IToolForm>();

            foreach (var tool in _tools)
            {
                if (ServiceInjector.IsAvailable(Global.Emulator.ServiceProvider, tool.GetType()))
                {
                    ServiceInjector.UpdateServices(Global.Emulator.ServiceProvider, tool);

                    if ((tool.IsHandleCreated && !tool.IsDisposed) || tool is RamWatch)                     // Hack for RAM Watch - in display watches mode it wants to keep running even closed, it will handle disposed logic
                    {
                        tool.Restart();
                    }
                }
                else
                {
                    unavailable.Add(tool);
                    ServiceInjector.ClearServices(tool);                     // the services of the old emulator core are no longer valid on the tool
                }
            }

            foreach (var tool in unavailable)
            {
                tool.Close();
                _tools.Remove(tool);
            }
        }