static void ExtractDependencies() { //Wow. This'll make it easy for people... string path = Directory.GetParent(Application.ExecutablePath).FullName; if (!File.Exists(path + OSInfo.DirectorySeparator + "NetSockets.dll")) { File.WriteAllBytes(path + OSInfo.DirectorySeparator + "NetSockets.dll", Properties.Resources.NetSockets); } string temppath = path + OSInfo.DirectorySeparator + "temp"; string zippath = path + OSInfo.DirectorySeparator + "depend.zip"; var wc = new WebClient(); //Newtonsoft.Json is REQUIRED for the ShiftOS engine to start. if (!File.Exists(path + OSInfo.DirectorySeparator + "Svg.dll")) { wc.DownloadFile("http://playshiftos.ml/shiftos/dependencies/Svg.dll", path + OSInfo.DirectorySeparator + "Svg.dll"); } if (!File.Exists(path + OSInfo.DirectorySeparator + "Newtonsoft.Json.dll")) { wc.DownloadFile("http://playshiftos.ml/shiftos/dependencies/Newtonsoft.Json.dll", path + OSInfo.DirectorySeparator + "Newtonsoft.Json.dll"); } //Download optional dependencies. wc.DownloadFileCompleted += (object s, AsyncCompletedEventArgs e) => { if (Directory.Exists(temppath)) { Directory.Delete(temppath, true); } bool firstfile = false; ZipFile.ExtractToDirectory(zippath, temppath); foreach (string f in Directory.GetFiles(temppath)) { var finf = new FileInfo(f); if (!File.Exists(path + OSInfo.DirectorySeparator + finf.Name)) { File.Copy(finf.FullName, path + OSInfo.DirectorySeparator + finf.Name); } } //Delete that damn temp folder and zip file. File.Delete(zippath); Directory.Delete(temppath, true); }; //Because these files aren't needed for ShiftOS to function fundamentally, they're downloaded asynchronously in the background. try { //Create a new Lua API object, and a new Gecko web renderer. If the job fails, then redownload requisite libraries after notifying the user. var l = new LuaInterpreter(); var w = new Gecko.GeckoWebBrowser(); l = null; w.Dispose(); GC.Collect(); } catch (Exception ex) { MessageBox.Show("Sorry to break the immersion, but we're currently downloading ShiftOS dependencies that'll make the game run MUCH better, such as the Lua engine and Gecko web renderer. Give us a moment. ShiftOS will continue to run while this happens but some things won't work right until we're finished."); wc.DownloadFileAsync(new Uri("http://playshiftos.ml/shiftos/dependencies/ShiftOS_Dependencies.zip"), zippath); } }
/// <summary> /// Clean up any resources being used. /// </summary> /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> protected override void Dispose(bool disposing) { if (disposing && (components != null)) { components.Dispose(); } base.Dispose(disposing); }
private void Form1_FormClosed(object sender, FormClosedEventArgs e) { webBrowser.Dispose(); Gecko.Xpcom.Shutdown(); }