Пример #1
0
        private static void Install_Legacy_01(string dirpath)
        {
            SetDisplayText("Downloading MelonLoader...");
            string tempfilepath = TempFileCache.CreateFile();

            webClient.DownloadFileAsync(new Uri("https://github.com/HerpDerpinstine/MelonLoader/releases/download/v0.1.0/MelonLoader.zip"), tempfilepath);
            while (webClient.IsBusy)
            {
            }

            SetDisplayText("Downloading Dependencies...");
            string tempfilepath2 = TempFileCache.CreateFile();

            webClient.DownloadFileAsync(new Uri("https://github.com/HerpDerpinstine/MelonLoader/releases/download/v0.1.0/MonoDependencies.zip"), tempfilepath2);
            while (webClient.IsBusy)
            {
            }

            SetDisplayText("Extracting MelonLoader...");
            Cleanup(dirpath);
            ExtractZip(dirpath, tempfilepath);

            SetDisplayText("Extracting Dependencies...");
            ExtractZip(dirpath, tempfilepath2);

            CreateDirectories(dirpath, "v0.1.0", true);
        }
Пример #2
0
 private void MainForm_FormClosed(object sender, FormClosedEventArgs e)
 {
     if ((e.CloseReason == CloseReason.WindowsShutDown) || (e.CloseReason == CloseReason.UserClosing) || (e.CloseReason == CloseReason.TaskManagerClosing))
     {
         TempFileCache.ClearCache();
         Process.GetCurrentProcess().Kill();
     }
 }
Пример #3
0
        private static void Install_Legacy_02(string dirpath, string selectedVersion)
        {
            SetDisplayText("Downloading MelonLoader...");
            bool   is_02        = selectedVersion.Equals("v0.2");
            string tempfilepath = TempFileCache.CreateFile();

            webClient.DownloadFile("https://github.com/HerpDerpinstine/MelonLoader/releases/download/" + selectedVersion + "/MelonLoader" + (is_02 ? "_" : ".") + (File.Exists(Path.Combine(dirpath, "GameAssembly.dll")) ? "Il2Cpp" : "Mono") + ".zip", tempfilepath);

            SetDisplayText("Extracting MelonLoader...");
            if (is_02)
            {
                SetPercentage(20);
            }
            else
            {
                SetPercentage(50);
            }
            Cleanup(dirpath, true);
            ExtractZip(dirpath, tempfilepath);

            if (is_02)
            {
                string AssemblyGenerator_Folder        = Path.Combine(Path.Combine(dirpath, "MelonLoader"), "AssemblyGenerator");
                string Il2CppDumper_Folder             = Path.Combine(AssemblyGenerator_Folder, "Il2CppDumper");
                string Il2CppAssemblyUnhollower_Folder = Path.Combine(AssemblyGenerator_Folder, "Il2CppAssemblyUnhollower");
                string UnityDependencies_Folder        = Path.Combine(Il2CppAssemblyUnhollower_Folder, "UnityDependencies");

                SetDisplayText("Downloading Il2CppDumper...");
                SetPercentage(40);
                string tempfilepath2 = TempFileCache.CreateFile();
                webClient.DownloadFile("https://github.com/Perfare/Il2CppDumper/releases/download/v6.2.1/Il2CppDumper-v6.2.1.zip", tempfilepath2);

                SetDisplayText("Downloading Il2CppUnhollower...");
                SetPercentage(50);
                string tempfilepath3 = TempFileCache.CreateFile();
                webClient.DownloadFile("https://github.com/knah/Il2CppAssemblyUnhollower/releases/download/v0.4.3.0/Il2CppAssemblyUnhollower.0.4.3.0.zip", tempfilepath3);

                SetDisplayText("Downloading Dependencies...");
                SetPercentage(60);
                string tempfilepath4 = TempFileCache.CreateFile();
                webClient.DownloadFile("https://github.com/HerpDerpinstine/MelonLoader/raw/master/BaseLibs/UnityDependencies/" + mainForm.UnityVersion + ".zip", tempfilepath4);

                SetDisplayText("Extracting Il2CppDumper...");
                SetPercentage(70);
                ExtractZip(Il2CppDumper_Folder, tempfilepath2);

                SetDisplayText("Extracting Il2CppUnhollower...");
                SetPercentage(80);
                ExtractZip(Il2CppAssemblyUnhollower_Folder, tempfilepath3);

                SetDisplayText("Extracting Dependencies...");
                SetPercentage(90);
                ExtractZip(UnityDependencies_Folder, tempfilepath4);
            }

            CreateDirectories(dirpath, selectedVersion, true);
        }
Пример #4
0
        private static void Install_Silent(string dirpath, string selectedVersion)
        {
            string tempfilepath = TempFileCache.CreateFile();

            webClient.DownloadFileAsync(new Uri("https://github.com/HerpDerpinstine/MelonLoader/releases/download/" + selectedVersion + "/MelonLoader.zip"), tempfilepath);
            while (webClient.IsBusy)
            {
            }
            Cleanup(dirpath);
            ExtractZip(dirpath, tempfilepath);
            CreateDirectories(dirpath, selectedVersion, false);
        }
Пример #5
0
 internal static void Install(string dirpath, string selectedVersion, bool legacy_install)
 {
     if (!legacy_install)
     {
         Install_Normal(dirpath, selectedVersion);
     }
     else
     {
         Install_Legacy(dirpath, selectedVersion);
     }
     TempFileCache.ClearCache();
 }
Пример #6
0
        private static void Install_Normal(string dirpath, string selectedVersion)
        {
            SetDisplayText("Downloading MelonLoader...");
            string tempfilepath = TempFileCache.CreateFile();

            webClient.DownloadFileTaskAsync("https://github.com/HerpDerpinstine/MelonLoader/releases/download/" + selectedVersion + "/MelonLoader.zip", tempfilepath).Wait();
            SetDisplayText("Extracting MelonLoader...");
            SetPercentage(50);
            Cleanup(dirpath, false);
            ExtractZip(dirpath, tempfilepath);
            CreateDirectories(dirpath, selectedVersion, false);
        }
Пример #7
0
        private static void Install_Normal(string dirpath, string selectedVersion)
        {
            SetDisplayText("Downloading MelonLoader...");
            string tempfilepath = TempFileCache.CreateFile();

            webClient.DownloadFileAsync(new Uri("https://github.com/ThePotato97/PotatoLoader/releases/download/" + selectedVersion + "/MelonLoader.zip"), tempfilepath);
            while (webClient.IsBusy)
            {
            }
            SetDisplayText("Extracting MelonLoader...");
            Cleanup(dirpath);
            ExtractZip(dirpath, tempfilepath);
            CreateDirectories(dirpath, selectedVersion, false);
        }
Пример #8
0
 internal static void Install(string dirpath, string selectedVersion, bool legacy_install, bool silent_install)
 {
     if (File.Exists(ManualZipPath) && selectedVersion.Equals("Manual Zip"))
     {
         Install_ManualZip(dirpath);
     }
     else if (legacy_install)
     {
         Install_Legacy(dirpath, selectedVersion);
     }
     else if (silent_install)
     {
         Install_Silent(dirpath, selectedVersion);
     }
     else
     {
         Install_Normal(dirpath, selectedVersion);
     }
     TempFileCache.ClearCache();
 }
Пример #9
0
        private void btnInstall_Click(object sender, EventArgs e)
        {
            cbVersions.Hide();
            tbPath.Hide();
            btnSelect.Hide();
            btnInstall.Hide();
            btnUninstall.Hide();

            progressBar.Show();
            lblProgressInfo.Show();
            lblProgressPer.Show();

            new Thread(() =>
            {
                try
                {
                    string dirpath         = Path.GetDirectoryName(tbPath.Text);
                    string selectedVersion = ((((string)cbVersions.Items[cbVersions.SelectedIndex]).StartsWith("Latest")) ? (string)cbVersions.Items[cbVersions.SelectedIndex + 1] : (string)cbVersions.Items[cbVersions.SelectedIndex]);
                    bool legacy_install    = (selectedVersion.Equals("v0.2.1") || selectedVersion.Equals("v0.2") || selectedVersion.Equals("v0.1.0"));

                    Program.Install(dirpath, selectedVersion, legacy_install);

                    Program.SetDisplayText("SUCCESS!");
                    MessageBox.Show("Installation Successful!", Program.Title, MessageBoxButtons.OK, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly);
                    Close();
                    Application.Exit();
                }
                catch (Exception ex)
                {
                    TempFileCache.ClearCache();
                    Program.SetDisplayText("ERROR!");
                    MessageBox.Show("Installation failed; upload the created log to #melonloader-support on discord", Program.Title);
                    File.WriteAllText(Directory.GetCurrentDirectory() + $@"\MLInstaller_{DateTime.Now:yy-M-dd_HH-mm-ss.fff}.log", ex.ToString());
                    Close();
                    Application.Exit();
                }
            }).Start();
        }
Пример #10
0
        private void btnUninstall_Click_1(object sender, EventArgs e)
        {
            cbVersions.Hide();
            tbPath.Hide();
            btnSelect.Hide();
            btnInstall.Hide();
            btnUninstall.Hide();

            progressBar.Show();
            lblProgressInfo.Show();
            lblProgressPer.Show();

            new Thread(() =>
            {
                try
                {
                    string dirpath = Path.GetDirectoryName(tbPath.Text);

                    Program.Cleanup(dirpath);

                    Program.SetDisplayText("SUCCESS!");
                    Program.SetPercentage(100);
                    MessageBox.Show("Uninstall Successful!", Program.Title, MessageBoxButtons.OK, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly);
                    Close();
                    Application.Exit();
                }
                catch (Exception ex)
                {
                    TempFileCache.ClearCache();
                    Program.SetDisplayText("ERROR!");
                    MessageBox.Show("Uninstall failed; upload the created log to #melonloader-support on discord", Program.Title);
                    File.WriteAllText(Directory.GetCurrentDirectory() + $@"\MLInstaller_{DateTime.Now:yy-M-dd_HH-mm-ss.fff}.log", ex.ToString());
                    Close();
                    Application.Exit();
                }
            }).Start();
        }
Пример #11
0
        private void button2_Click(object sender, System.EventArgs e)
        {
            comboBox1.Visible = false;
            textBox1.Visible  = false;
            button1.Visible   = false;
            button2.Visible   = false;

            progressBar1.Visible = true;
            label2.Visible       = true;
            label3.Visible       = true;

            new Thread(() =>
            {
                try
                {
                    string dirpath         = Path.GetDirectoryName(textBox1.Text);
                    string selectedVersion = (((comboBox1.SelectedIndex == 0) && (comboBox1.Items.Count > 1)) ? (string)comboBox1.Items[1] : (string)comboBox1.Items[comboBox1.SelectedIndex]);
                    bool legacy_install    = (selectedVersion.Equals("v0.2.1") || selectedVersion.Equals("v0.2") || selectedVersion.Equals("v0.1.0"));

                    Program.Install(dirpath, selectedVersion, legacy_install);

                    Program.SetDisplayText("SUCCESS!");
                    Program.SetPercentage(100);
                    MessageBox.Show("Installation Successful!", Program.Title, MessageBoxButtons.OK, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly);
                    Close();
                    Application.Exit();
                }
                catch (Exception ex)
                {
                    TempFileCache.ClearCache();
                    Program.SetDisplayText("ERROR!");
                    MessageBox.Show("Installation failed; copy this dialog (press Control+C) to #melonloader-support on discord\n" + ex, Program.Title);
                    Close();
                    Application.Exit();
                }
            }).Start();
        }
Пример #12
0
        private static void Install_Legacy_02(string dirpath, string selectedVersion)
        {
            SetDisplayText("Downloading MelonLoader...");
            bool   is_02        = selectedVersion.Equals("v0.2");
            string tempfilepath = TempFileCache.CreateFile();

            webClient.DownloadFileAsync(new Uri("https://github.com/HerpDerpinstine/MelonLoader/releases/download/" + selectedVersion + "/MelonLoader" + (is_02 ? "_" : ".") + (File.Exists(Path.Combine(dirpath, "GameAssembly.dll")) ? "Il2Cpp" : "Mono") + ".zip"), tempfilepath);
            while (webClient.IsBusy)
            {
            }
            SetDisplayText("Extracting MelonLoader...");
            Cleanup(dirpath);
            ExtractZip(dirpath, tempfilepath);

            if (is_02)
            {
                string AssemblyGenerator_Folder        = Path.Combine(Path.Combine(dirpath, "MelonLoader"), "AssemblyGenerator");
                string Il2CppDumper_Folder             = Path.Combine(AssemblyGenerator_Folder, "Il2CppDumper");
                string Il2CppAssemblyUnhollower_Folder = Path.Combine(AssemblyGenerator_Folder, "Il2CppAssemblyUnhollower");
                string UnityDependencies_Folder        = Path.Combine(Il2CppAssemblyUnhollower_Folder, "UnityDependencies");

                SetDisplayText("Downloading Il2CppDumper...");
                string tempfilepath2 = TempFileCache.CreateFile();
                webClient.DownloadFileAsync(new Uri("https://github.com/Perfare/Il2CppDumper/releases/download/v6.2.1/Il2CppDumper-v6.2.1.zip"), tempfilepath2);
                while (webClient.IsBusy)
                {
                }

                SetDisplayText("Downloading Il2CppUnhollower...");
                string tempfilepath3 = TempFileCache.CreateFile();
                webClient.DownloadFileAsync(new Uri("https://github.com/knah/Il2CppAssemblyUnhollower/releases/download/v0.4.3.0/Il2CppAssemblyUnhollower.0.4.3.0.zip"), tempfilepath3);
                while (webClient.IsBusy)
                {
                }

                SetDisplayText("Downloading Dependencies...");
                string tempfilepath4 = TempFileCache.CreateFile();
                bool   run_fallback  = false;
                try { webClient.DownloadFileAsync(new Uri("https://github.com/Joeyjoe9876/MelonLoader/tree/master/BaseLibs/UnityDependencies/" + mainForm.UnityVersion + ".zip"), tempfilepath4); while (webClient.IsBusy)
                      {
                      }
                } catch (Exception ex) { run_fallback = true; }
                if (run_fallback)
                {
                    string    subver = mainForm.UnityVersion.Substring(0, mainForm.UnityVersion.LastIndexOf("."));
                    JsonArray data   = (JsonArray)JsonValue.Parse(Program.webClient.DownloadString("https://api.github.com/repos/HerpDerpinstine/MelonLoader/contents/BaseLibs/UnityDependencies")).AsJsonArray;
                    if (data.Count > 0)
                    {
                        List <string> versionlist = new List <string>();
                        foreach (var x in data)
                        {
                            string version = Path.GetFileNameWithoutExtension(x["name"].AsString);
                            if (version.StartsWith(subver))
                            {
                                versionlist.Add(version);
                            }
                        }
                        if (versionlist.Count > 0)
                        {
                            versionlist = versionlist.OrderBy(x => int.Parse(x.Split(new char[] { '.' })[2])).ToList();
                            string latest_version = versionlist.Last();
                            webClient.DownloadFileAsync(new Uri("https://github.com/Joeyjoe9876/MelonLoader/tree/master/BaseLibs/UnityDependencies/" + latest_version + ".zip"), tempfilepath4);
                            while (webClient.IsBusy)
                            {
                            }
                        }
                    }
                }

                SetDisplayText("Extracting Il2CppDumper...");
                ExtractZip(Il2CppDumper_Folder, tempfilepath2);

                SetDisplayText("Extracting Il2CppUnhollower...");
                ExtractZip(Il2CppAssemblyUnhollower_Folder, tempfilepath3);

                SetDisplayText("Extracting Dependencies...");
                ExtractZip(UnityDependencies_Folder, tempfilepath4);
            }

            CreateDirectories(dirpath, selectedVersion, true);
        }