private void button1_Click(object sender, EventArgs e) { button1.Enabled = false; if (AssemblyFullPath != null) { if (MDradio.Checked) { InitMethod = "Init_MD"; try { modPath = mdPath; PatchStarter(); if (!Directory.Exists(mdPath)) { //if mods folder not exists, create it. Directory.CreateDirectory(mdPath); } } catch (Exception ex) { MessageBox.Show(string.Format("Error:{1}{0}{1}{1}Please restart patcher!", ex.Message, Environment.NewLine), "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else if (GFradio.Checked) { InitMethod = "Init_GF"; try { modPath = gfPath; PatchStarter(); if (!Directory.Exists(gfPath)) { //if mods folder not exists, create it. Directory.CreateDirectory(gfPath); } } catch (Exception ex) { MessageBox.Show(string.Format("Error:{1}{0}{1}{1}Please restart patcher!", ex.Message, Environment.NewLine), "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else if (ADradio.Checked) { InitMethod = "Init_AD"; try { modPath = adPath; PatchStarter(); if (!Directory.Exists(adPath)) { //if mods folder not exists, create it. Directory.CreateDirectory(adPath); } } catch (Exception ex) { MessageBox.Show(string.Format("Error:{1}{0}{1}{1}Please restart patcher!", ex.Message, Environment.NewLine), "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); } } //Apply changes to mainData MainData.ApplyChanges(enOutputlog.Checked, resDialogCheck.Checked, false); //check if everything is ok MainData.LoadMainData(OutputlogLabel, resDialogLabel, resDialogCheck); } else { MessageBox.Show("Select game path first", "Error path unknown", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void button1_Click(object sender, EventArgs e) { button1.Enabled = false; if (AssemblyFullPath != null) { if (MDradio.Checked) { InitMethod = "Init_MD"; bool isCloudIgnore = true; if (Directory.GetParent(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)).ToString() == "OneDrive") { if (MessageBox.Show($"You are about to set your mods folder to a directory that is part of OneDrive cloud.{Environment.NewLine}This is not supported due to On-Demand files that may cause issues.{Environment.NewLine}{Environment.NewLine}Do you want to continue?", "Cloud folder warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No) { isCloudIgnore = false; } } if (isCloudIgnore) { try { modPath = mdPath; PatchStarter(); if (!Directory.Exists(mdPath)) { //if mods folder not exists, create it. Directory.CreateDirectory(mdPath); } } catch (Exception ex) { MessageBox.Show(string.Format("Error:{1}{0}", ex.Message, Environment.NewLine), "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); Log.Write("Error", true, true); Log.Write(ex.Message); Log.Write(ex.ToString()); } } } else if (GFradio.Checked) { InitMethod = "Init_GF"; try { modPath = gfPath; PatchStarter(); if (!Directory.Exists(gfPath)) { //if mods folder not exists, create it. Directory.CreateDirectory(gfPath); } } catch (Exception ex) { MessageBox.Show(string.Format("Error:{1}{0}", ex.Message, Environment.NewLine), "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); Log.Write("Error", true, true); Log.Write(ex.Message); Log.Write(ex.ToString()); } } else if (ADradio.Checked) { InitMethod = "Init_AD"; try { modPath = adPath; PatchStarter(); if (!Directory.Exists(adPath)) { //if mods folder not exists, create it. Directory.CreateDirectory(adPath); } } catch (Exception ex) { MessageBox.Show(string.Format("Error:{1}{0}", ex.Message, Environment.NewLine), "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); Log.Write("Error", true, true); Log.Write(ex.Message); Log.Write(ex.ToString()); } } //Apply changes to mainData MainData.ApplyChanges(enOutputlog.Checked, resDialogCheck.Checked, false); //check if everything is ok MainData.LoadMainData(OutputlogLabel, resDialogLabel, resDialogCheck); } else { MessageBox.Show("Select game path first", "Error path unknown", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public Form1() { form1 = this; InitializeComponent(); Log.logBox = logBox; if (File.Exists("Assembly-CSharp.dll") || File.Exists("UnityEngine.dll")) //check if idiot unpacked this to managed folder. { if (MessageBox.Show("Did you read the instructions? (Readme.txt)", "Question for you!", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { MessageBox.Show(string.Format("Why are you lying?{0}Or maybe you can't read?{0}If you could read, you would know what you did wrong.", Environment.NewLine), "You are a liar", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { MessageBox.Show(string.Format("Yes I see.{0}Go back to readme and you will know what you did wrong.", Environment.NewLine), "You are a liar", MessageBoxButtons.OK, MessageBoxIcon.Warning); } Environment.Exit(0); } if (File.Exists("MSCFolder.txt")) { mscPath = File.ReadAllText("MSCFolder.txt"); Log.Write(string.Format("Loaded saved MSC Folder: {0}", mscPath)); } mscPathLabel.Text = mscPath; MDlabel.Text = mdPath; if (Directory.Exists(mdPath)) { Log.Write(string.Format("Found mods folder in: {0}", mdPath)); MDlabel.ForeColor = Color.Green; MDradio.Checked = true; modPath = mdPath; } ADlabel.Text = adPath; if (Directory.Exists(adPath)) { Log.Write(string.Format("Found mods folder in: {0}", adPath)); ADlabel.ForeColor = Color.Green; ADradio.Checked = true; modPath = adPath; } try { mscLoaderVersion = FileVersionInfo.GetVersionInfo("MSCLoader.dll"); string currentVersion; if (mscLoaderVersion.FileBuildPart != 0) { currentVersion = string.Format("{0}.{1}.{2}", mscLoaderVersion.FileMajorPart, mscLoaderVersion.FileMinorPart, mscLoaderVersion.FileBuildPart); } else { currentVersion = string.Format("{0}.{1}", mscLoaderVersion.FileMajorPart, mscLoaderVersion.FileMinorPart); } //TODO: replace with async string version; using (WebClient client = new WebClient()) { client.QueryString.Add("core", "stable"); version = client.DownloadString("http://my-summer-car.ml/ver.php"); } if (version.Trim().Length > 8) { throw new Exception("Parse Error, please report that problem!"); } int i = currentVersion.CompareTo(version.Trim()); if (i != 0) { Log.Write(string.Format("{2}MCSLoader v{0}, New version available: v{1}", currentVersion, version.Trim(), Environment.NewLine)); if (MessageBox.Show(string.Format("New version is available: v{0}, wanna check it out?", version.Trim()), "MCSLoader v" + currentVersion, MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { try { if (File.Exists("MSCLoader_Launcher.exe")) { Process.Start("MSCLoader_Launcher.exe"); } else { Process.Start("https://github.com/piotrulos/MSCModLoader/releases"); } Environment.Exit(0); } catch (Exception ex) { MessageBox.Show(string.Format("Failed to open update info!{1}{1}Error details:{1}{0}", ex.Message, Environment.NewLine), "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); } } statusBarLabel.Text = string.Format("New version available: v{0}", version.Trim()); } else if (i == 0) { Log.Write(string.Format("{1}MCSLoader v{0} is up to date, no new version found.", currentVersion, Environment.NewLine)); statusBarLabel.Text = "MSCPatcher Ready!"; } } catch (Exception e) { Log.Write(string.Format("Check for new version failed with error: {0}", e.Message)); statusBarLabel.Text = "MSCPatcher Ready!"; } if (!Directory.Exists("64bit")) { groupBox6.Visible = false; basic64info.Visible = true; } if (!Directory.Exists("Debug")) { groupBox5.Visible = false; basicDebugInfo.Visible = true; } Log.Write("MSCPatcher ready!", true, true); if (mscPath != "(unknown)") { mscPathLabel.Text = mscPath; AssemblyFullPath = Path.Combine(mscPath, AssemblyPath); gfPath = Path.Combine(mscPath, @"Mods"); GFlabel.Text = gfPath; if (Directory.Exists(gfPath)) { Log.Write(string.Format("Found mods folder in: {0}", gfPath)); GFlabel.ForeColor = Color.Green; GFradio.Checked = true; modPath = gfPath; } Log.Write(string.Format("Game folder set to: {0}{1}", mscPath, Environment.NewLine)); MainData.LoadMainData(OutputlogLabel, resDialogLabel, resDialogCheck); DebugStatusInfo(); CheckPatchStatus(); } if (!Environment.Is64BitOperatingSystem) { status64.Text = "You are not running 64-bit Windows."; status64.ForeColor = Color.Red; status64g.Text = "64-bit patch cannot be installed."; status64g.ForeColor = Color.Red; } else { status64.Text = "You are running 64-bit Windows."; status64.ForeColor = Color.Green; Check64Info(); } }
public Form1() { form1 = this; InitializeComponent(); Log.logBox = logBox; if (File.Exists("Assembly-CSharp.dll") || File.Exists("UnityEngine.dll") || File.Exists("mysummercar.exe") || File.Exists("mainData") || File.Exists("mono.dll") || File.Exists("CSteamworks.dll") || Directory.Exists("References")) //check if idiot unpacked this to game folder. { if (MessageBox.Show("Did you read the instructions? (Readme.txt)", "Question for you!", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { MessageBox.Show(string.Format("Why are you lying?{0}Or maybe you can't read?{0}If you could read, you would know where not to unpack files.", Environment.NewLine), "You are a liar", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { MessageBox.Show(string.Format("Yes I see.{0}Go back to readme and you will know you would know where not to unpack files.", Environment.NewLine), "Read manual", MessageBoxButtons.OK, MessageBoxIcon.Warning); } Environment.Exit(0); } if (!File.Exists("MSCLoader.dll")) { MessageBox.Show(string.Format("Don't run this file from zip folder. Unpack all files and start patcher again.", Environment.NewLine), "Read the freaking instructions", MessageBoxButtons.OK, MessageBoxIcon.Error); Environment.Exit(0); } if (File.Exists("MSCFolder.txt")) { mscPath = File.ReadAllText("MSCFolder.txt"); if (!Directory.Exists(mscPath)) { Log.Write(string.Format("Saved MSC Folder, doesn't exists: {0}", mscPath)); mscPath = "(unknown)"; try { File.Delete("MSCFolder.txt"); } catch (Exception e) { Log.Write("Error", true, true); Log.Write(e.Message); Log.Write(e.ToString()); } } else { Log.Write(string.Format("Loaded saved MSC Folder: {0}", mscPath)); } } mscPathLabel.Text = mscPath; MDlabel.Text = mdPath; if (Directory.Exists(mdPath)) { Log.Write(string.Format("Found mods folder in: {0}", mdPath)); MDlabel.ForeColor = Color.Green; MDradio.Checked = true; modPath = mdPath; } ADlabel.Text = adPath; if (Directory.Exists(adPath)) { Log.Write(string.Format("Found mods folder in: {0}", adPath)); ADlabel.ForeColor = Color.Green; ADradio.Checked = true; modPath = adPath; } Log.Write(string.Format("Current folder: {0}", Path.GetFullPath("."))); try { mscLoaderVersion = FileVersionInfo.GetVersionInfo("MSCLoader.dll"); string currentVersion; if (mscLoaderVersion.FileBuildPart != 0) { currentVersion = string.Format("{0}.{1}.{2}", mscLoaderVersion.FileMajorPart, mscLoaderVersion.FileMinorPart, mscLoaderVersion.FileBuildPart); } else { currentVersion = string.Format("{0}.{1}", mscLoaderVersion.FileMajorPart, mscLoaderVersion.FileMinorPart); } string version; string res; using (WebClient client = new WebClient()) { client.QueryString.Add("core", "stable"); res = client.DownloadString("http://my-summer-car.ml/ver.php"); } string[] result = res.Split('|'); if (result[0] == "error") { switch (result[1]) { case "0": throw new Exception("Unknown branch"); case "1": throw new Exception("Database connection error"); default: throw new Exception("Unknown error"); } } else if (result[0] == "ok") { if (result[1].Trim().Length > 8) { throw new Exception("Parse Error, please report that problem!"); } version = result[1].Trim(); } else { throw new Exception("Unknown server response."); } int i = currentVersion.CompareTo(version.Trim()); if (i != 0) { Log.Write(string.Format("{2}MCSLoader v{0}, New version available: v{1}", currentVersion, version.Trim(), Environment.NewLine)); if (MessageBox.Show(string.Format("New version is available: v{0}, wanna check it out?", version.Trim()), "MCSLoader v" + currentVersion, MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { try { // if (File.Exists("MSCLoader_Launcher.exe")) // Process.Start("MSCLoader_Launcher.exe"); // else Process.Start("https://www.nexusmods.com/mysummercar/mods/147"); Environment.Exit(0); } catch (Exception ex) { MessageBox.Show(string.Format("Failed to open update info!{1}{1}Error details:{1}{0}", ex.Message, Environment.NewLine), "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); Log.Write("Error", true, true); Log.Write(ex.Message); Log.Write(ex.ToString()); } } statusBarLabel.Text = string.Format("New version available: v{0}", version.Trim()); } else if (i == 0) { Log.Write(string.Format("{1}MCSLoader v{0} is up to date, no new version found.", currentVersion, Environment.NewLine)); statusBarLabel.Text = "MSCPatcher Ready!"; } } catch (Exception e) { Log.Write("Error", true, true); Log.Write(string.Format("Check for new version failed with error: {0}", e.Message)); statusBarLabel.Text = "MSCPatcher Ready!"; Log.Write(e.ToString()); } if (!Directory.Exists("Debug")) { groupBox5.Visible = false; basicDebugInfo.Visible = true; } Log.Write("MSCPatcher ready!", true, true); if (mscPath != "(unknown)") { mscPathLabel.Text = mscPath; AssemblyFullPath = Path.Combine(mscPath, AssemblyPath); gfPath = Path.Combine(mscPath, @"Mods"); GFlabel.Text = gfPath; if (Directory.Exists(gfPath)) { Log.Write(string.Format("Found mods folder in: {0}", gfPath)); GFlabel.ForeColor = Color.Green; GFradio.Checked = true; modPath = gfPath; } Log.Write(string.Format("Game folder set to: {0}{1}", mscPath, Environment.NewLine)); MainData.LoadMainData(OutputlogLabel, resDialogLabel, resDialogCheck); DebugStatusInfo(); CheckPatchStatus(); } }