private void VersionManager_Load(object sender, EventArgs e) { this.Owner = Program.GMS; Directory.CreateDirectory(@"versions"); for (int cdnIndex = 1; cdnIndex <= NUMBER_OF_CDN_URLS; cdnIndex++) { Thread downloadThread = new Thread(() => { CDN.UseCDN(CDNUrls.FromIndex(cdnIndex)); }); downloadThread.Start(); while (downloadThread.IsAlive) { Application.DoEvents(); } foreach (String Version in CDN.GetVersions("ps4")) { if (Version != "1.4.9999" || DownloadList.Items.Contains(Version)) { DownloadList.Items.Add(Version); } } } foreach (String dir in Directory.GetDirectories(@"versions")) { DownloadedList.Items.Add(Path.GetFileName(dir)); DownloadList.Items.Remove(Path.GetFileName(dir)); } }
private void DownloadButton_Click(object sender, EventArgs e) { if (DownloadList.SelectedIndex <= -1) { return; } DownloadList.Enabled = false; DownloadButton.Enabled = false; ControlBox = false; string version = DownloadList.SelectedItem.ToString(); for (int cdnIndex = 1; cdnIndex <= NUMBER_OF_CDN_URLS; cdnIndex++) { Thread downloadThread = new Thread(() => { CDN.UseCDN(CDNUrls.FromIndex(cdnIndex)); }); downloadThread.Start(); while (downloadThread.IsAlive) { Application.DoEvents(); } string ps4Url = CDN.GetModuleForVersion(version, "ps4"); if (ps4Url != "NF") { string ps4Filename = getUrlFileName(ps4Url); string ps4Password = CDN.GetPassword(ps4Filename); string gamemakerUrl = CDN.GetModuleForVersion(version, "original"); string gamemakerFilename = getUrlFileName(gamemakerUrl); string gamemakerPassword = CDN.GetPassword(gamemakerFilename); startDownload(ps4Url, ps4Filename); extractFile(ps4Filename, @"_ps4", ps4Password); startDownload(gamemakerUrl, gamemakerFilename); extractFile(gamemakerFilename, @"_gamemaker", gamemakerPassword); DownloadProgress.Style = ProgressBarStyle.Marquee; StatusText.Text = "Copying Files..."; Application.DoEvents(); Thread copyThread = new Thread(() => { Directory.CreateDirectory(@"versions\\" + version + "\\Runner"); Directory.CreateDirectory(@"versions\\" + version + "\\Shaders"); if (version.StartsWith("1.")) { try { File.Copy(@"_gamemaker\\GMAssetCompiler.exe", @"versions\\" + version + "\\GMAssetCompiler.exe", true); File.Copy(@"_gamemaker\\ffmpeg.exe", @"versions\\" + version + "\\ffmpeg.exe", true); File.Copy(@"_gamemaker\\BouncyCastle.Crypto.dll", @"versions\\" + version + "\\BouncyCastle.Crypto.dll", true); File.Copy(@"_gamemaker\\spine-csharp.dll", @"versions\\" + version + "\\spine-csharp.dll", true); File.Copy(@"_gamemaker\\SharpCompress.dll", @"versions\\" + version + "\\SharpCompress.dll", true); File.Copy(@"_gamemaker\\Ionic.Zip.Reduced.dll", @"versions\\" + version + "\\Ionic.Zip.Reduced.dll", true); File.Copy(@"_gamemaker\\Newtonsoft.Json.dll", @"versions\\" + version + "\\Newtonsoft.Json.dll", true); } catch (Exception) { }; } else if (version.StartsWith("2.")) { try { File.Copy(@"_gamemaker\\bin\\GMAssetCompiler.exe", @"versions\\" + version + "\\GMAssetCompiler.exe", true); File.Copy(@"_gamemaker\\bin\\ffmpeg.exe", @"versions\\" + version + "\\ffmpeg.exe", true); File.Copy(@"_gamemaker\\bin\\Newtonsoft.Json.dll", @"versions\\" + version + "\\Newtonsoft.Json.dll", true); File.Copy(@"_gamemaker\\bin\\BouncyCastle.Crypto.dll", @"versions\\" + version + "\\BouncyCastle.Crypto.dll", true); File.Copy(@"_gamemaker\\bin\\spine-csharp.dll", @"versions\\" + version + "\\spine-csharp.dll", true); File.Copy(@"_gamemaker\\bin\\SharpCompress.dll", @"versions\\" + version + "\\SharpCompress.dll", true); File.Copy(@"_gamemaker\\bin\\Ionic.Zip.Reduced.dll", @"versions\\" + version + "\\Ionic.Zip.Reduced.dll", true); } catch (Exception) { }; } CopyDir(@"Runner", @"versions\\" + version + "\\Runner"); if (version.StartsWith("1.")) { CopyDir(@"_gamemaker\\Shaders", @"versions\\" + version + "\\Shaders"); } else if (version.StartsWith("2.")) { CopyDir(@"_gamemaker\\bin\Shaders", @"versions\\" + version + "\\Shaders"); CopyDir(@"_gamemaker\\BaseProject", @"versions\\" + version + "\\BaseProject"); CopyDir(@"_ps4\\BaseProject", @"versions\\" + version + "\\BaseProject"); } File.Delete(@"versions\\" + version + "\\Runner\\eboot.bin"); try { File.Copy(@"_ps4\\PS4\\PSSL_PShaderCommon.shader", @"versions\\" + version + "\\Shaders\\PSSL_PShaderCommon.shade", true); File.Copy(@"_ps4\\PS4\\PSSL_VShaderCommon.shader", @"versions\\" + version + "\\Shaders\\PSSL_VShaderCommon.shader", true); File.Copy(@"_ps4\\PS4\\HLSL_to_PSSL.h", @"versions\\" + version + "\\Shaders\\HLSL_to_PSSL.h", true); } catch (Exception) { }; }); copyThread.Start(); while (copyThread.IsAlive) { Application.DoEvents(); } if (version.StartsWith("2.") || version == "1.4.9999") { DownloadProgress.Style = ProgressBarStyle.Marquee; StatusText.Text = "Applying SceVerDown Magic (by dots_tb)..."; Application.DoEvents(); ELF.Tools.SceVerDown(@"_ps4\\PS4\\PS4Runner.elf", 0x05008001); } DownloadProgress.Style = ProgressBarStyle.Marquee; StatusText.Text = "Running Make FSELF (by flat_z)..."; Application.DoEvents(); ELF.Tools.MakeFself(@"_ps4\\PS4\\PS4Runner.elf", @"versions\\" + version + "\\Runner\\eboot.bin"); DownloadProgress.Style = ProgressBarStyle.Marquee; StatusText.Text = "Deleting Unused Files..."; Application.DoEvents(); Thread deleteThread = new Thread(() => { while (true) { try { Directory.Delete(@"_ps4", true); Directory.Delete(@"_gamemaker", true); } catch (Exception) { }; break; } }); deleteThread.Start(); while (deleteThread.IsAlive) { Application.DoEvents(); } DownloadProgress.Style = ProgressBarStyle.Continuous; DownloadProgress.Value = 0; StatusText.Text = "Waiting..."; DownloadedList.Items.Add(version); DownloadList.Items.Remove(version); DownloadList.Enabled = true; DownloadButton.Enabled = true; ControlBox = true; } } }