public Main() { Stopwatch sw = Stopwatch.StartNew(); Splash = new SplashScreen(); Instance = this; Cursor temp = Cursor.Current; Cursor.Current = Cursors.AppStarting; string pluginsDir = LoaderTools.PluginsDir; Directory.CreateDirectory(pluginsDir); LogFile.Init(pluginsDir); LogFile.WriteLine("Starting - v" + Assembly.GetExecutingAssembly().GetName().Version.ToString(3)); // Fix tls 1.2 not supported on Windows 7 - github.com is tls 1.2 only try { ServicePointManager.SecurityProtocol |= SecurityProtocolType.Tls12; } catch (NotSupportedException e) { LogFile.WriteLine("An error occurred while setting up networking, web requests will probably fail: " + e); } Splash.SetText("Finding references..."); RoslynReferences.GenerateAssemblyList(); AppDomain.CurrentDomain.AssemblyResolve += ResolveDependencies; Config = PluginConfig.Load(pluginsDir); List = new PluginList(pluginsDir, Config); Config.Init(List); StatsClient.OverrideBaseUrl(Config.StatsServerBaseUrl); Splash.SetText("Patching..."); LogFile.WriteLine("Patching"); // Check harmony version Version expectedHarmony = new Version(HarmonyVersion); Version actualHarmony = typeof(Harmony).Assembly.GetName().Version; if (expectedHarmony != actualHarmony) { LogFile.WriteLine($"WARNING: Unexpected Harmony version, plugins may be unstable. Expected {expectedHarmony} but found {actualHarmony}"); } new Harmony("avaness.PluginLoader").PatchAll(Assembly.GetExecutingAssembly()); Splash.SetText("Instantiating plugins..."); LogFile.WriteLine("Instantiating plugins"); foreach (string id in Config) { PluginData data = List[id]; if (data is GitHubPlugin github) { github.Init(pluginsDir); } if (PluginInstance.TryGet(data, out PluginInstance p)) { plugins.Add(p); if (data.IsLocal) { HasLocal = true; } } } sw.Stop(); // FIXME: It can potentially run in the background speeding up the game's startup ReportEnabledPlugins(); LogFile.WriteLine($"Finished startup. Took {sw.ElapsedMilliseconds}ms"); Cursor.Current = temp; Splash.Delete(); Splash = null; }
public void DisablePlugins() { Config.Disable(); plugins.Clear(); LogFile.WriteLine("Disabled all plugins"); }