private void btnForgeInstall_Click(object sender, EventArgs e) { setUIEnabled(false); new Thread(() => { var forgeJava = ""; if (useMJava) { var java = new MJava(); java.ProgressChanged += Launcher_ProgressChanged; forgeJava = java.CheckJava(); } else { forgeJava = javaPath; } Invoke(new Action(() => { var forgeForm = new ForgeInstall(MinecraftPath, forgeJava); forgeForm.ShowDialog(); setUIEnabled(true); refreshVersions(forgeForm.LastInstalledVersion); })); }).Start(); }
private void downloadMinecraftStuff_DoWork(object sender, DoWorkEventArgs e) { if (cancel) { return; } startButtonEnabled = false; var minecraft = new Minecraft(Path.Combine(path, modpack.Name)); minecraft.SetAssetsPath(path); var launcher = new Launcher(minecraft); launcher.ProgressChanged += Downloader_ChangeProgress; launcher.FileChanged += Downloader_ChangeFile; launcher.UpdateProfiles(); progressLabel = "Download der Assets abgeschlossen."; MJava java = new MJava(); var javaBinary = java.CheckJava(); var option = new MLaunchOption { GameLauncherName = "LandOfRailsLauncher", GameLauncherVersion = "0.1", JavaPath = javaBinary, Session = session, StartProfile = profile, MaximumRamMb = Settings.Default.RAM, }; string forgeVersion; using (StreamReader r = new StreamReader(Path.Combine(path, modpack.Name, "bin", "version.txt"))) { forgeVersion = r.ReadLine(); } var process = launcher.CreateProcess(modpack.MinecraftVersion, forgeVersion, option); Log.Debug($"{process.StartInfo.WorkingDirectory}\n{process.StartInfo.Arguments}\n{process.StartInfo.Domain}\n{process.StartInfo.FileName}\n{process.StartInfo.UserName}\n{process.StartInfo.Verb}"); if (Settings.Default.openConsole) { processWindow.Start(process); } else { process.Start(); } }
public string CheckJRE() { fire(MFile.Runtime, "java", 1, 0); var mjava = new MJava(Minecraft.Runtime); mjava.DownloadProgressChanged += (sender, e) => fire(e.ProgressPercentage); mjava.DownloadCompleted += (sender, e) => { fire(MFile.Runtime, "java", 1, 1); }; return(mjava.CheckJava()); }
void StartWithAdvancedOptions(MSession session) { // game directory var defaultPath = MinecraftPath.GetOSDefaultPath(); var path = Path.Combine(Environment.CurrentDirectory, "game dir"); // create minecraft path instance var minecraft = new MinecraftPath(path); minecraft.SetAssetsPath(Path.Combine(defaultPath, "assets")); // this speed up asset downloads // get all version metadatas // you can also use MVersionLoader.GetVersionMetadatasFromLocal and GetVersionMetadatasFromWeb var versionMetadatas = MVersionLoader.GetVersionMetadatas(minecraft); foreach (var item in versionMetadatas) { Console.WriteLine("Name : {0}", item.Name); Console.WriteLine("Type : {0}", item.Type); Console.WriteLine("Path : {0}", item.Path); Console.WriteLine("IsLocalVersion : {0}", item.IsLocalVersion); Console.WriteLine("============================================"); } Console.WriteLine(""); Console.WriteLine("LatestRelease : {0}", versionMetadatas.LatestReleaseVersion?.Name); Console.WriteLine("LatestSnapshot : {0}", versionMetadatas.LatestSnapshotVersion?.Name); Console.WriteLine("Input Version Name (ex: 1.15.2) : "); var versionName = Console.ReadLine(); // get MVersion from MVersionMetadata var version = versionMetadatas.GetVersion(versionName); if (version == null) { Console.WriteLine("{0} is not exist", versionName); return; } Console.WriteLine("\n\nVersion Information : "); Console.WriteLine("Id : {0}", version.Id); Console.WriteLine("Type : {0}", version.TypeStr); Console.WriteLine("ReleaseTime : {0}", version.ReleaseTime); Console.WriteLine("AssetId : {0}", version.AssetId); Console.WriteLine("JAR : {0}", version.Jar); Console.WriteLine("Libraries : {0}", version.Libraries.Length); if (version.IsInherited) { Console.WriteLine("Inherited Profile from {0}", version.ParentVersionId); } // Download mode Console.WriteLine("\nSelect download mode : "); Console.WriteLine("(1) Sequence Download"); Console.WriteLine("(2) Parallel Download"); var downloadModeInput = Console.ReadLine(); MDownloader downloader; if (downloadModeInput == "1") { downloader = new MDownloader(minecraft, version); // Sequence Download } else if (downloadModeInput == "2") { downloader = new MParallelDownloader(minecraft, version); // Parallel Download (note: Parallel Download is not stable yet) } else { Console.WriteLine("Input 1 or 2"); Console.ReadLine(); return; } downloader.ChangeFile += Downloader_ChangeFile; downloader.ChangeProgress += Downloader_ChangeProgress; // Start download downloader.DownloadAll(); Console.WriteLine("Download Completed.\n"); // Set java Console.WriteLine("Input java path (empty input will download java) : "); var javaInput = Console.ReadLine(); if (javaInput == "") { var java = new MJava(); java.ProgressChanged += Downloader_ChangeProgress; javaInput = java.CheckJava(); } // LaunchOption var option = new MLaunchOption() { JavaPath = javaInput, Session = session, StartVersion = version, Path = minecraft, MaximumRamMb = 4096, ScreenWidth = 1600, ScreenHeight = 900, }; // Launch var launch = new MLaunch(option); var process = launch.GetProcess(); Console.WriteLine(process.StartInfo.Arguments); process.Start(); Console.WriteLine("Started"); Console.ReadLine(); }
private void Btn_Launch_Click(object sender, EventArgs e) { // Launch if (Session == null) { MessageBox.Show("Login First"); return; } if (cbVersion.Text == "") { MessageBox.Show("Select Version"); return; } // disable ui setUIEnabled(false); // create LaunchOption var launchOption = createLaunchOption(); if (launchOption == null) { return; } var version = cbVersion.Text; var useParallel = rbParallelDownload.Checked; var checkHash = cbCheckFileHash.Checked; var downloadAssets = !cbSkipAssetsDownload.Checked; var th = new Thread(() => { try { if (useMJava) // Download Java { var mjava = new MJava(MinecraftPath.Runtime); mjava.ProgressChanged += Launcher_ProgressChanged; var javapath = mjava.CheckJava(); launchOption.JavaPath = javapath; } MVersion versionInfo = Versions.GetVersion(version); // Get Version Info launchOption.StartVersion = versionInfo; MDownloader downloader; // Create Downloader if (useParallel) { downloader = new MParallelDownloader(MinecraftPath, versionInfo, 10, true); } else { downloader = new MDownloader(MinecraftPath, versionInfo); } downloader.ChangeFile += Launcher_FileChanged; downloader.ChangeProgress += Launcher_ProgressChanged; downloader.CheckHash = checkHash; downloader.DownloadAll(downloadAssets); var launch = new MLaunch(launchOption); // Create Arguments and Process var process = launch.GetProcess(); StartProcess(process); // Start Process with debug options // or just start process // process.Start(); } catch (MDownloadFileException mex) // download exception { MessageBox.Show( $"FileName : {mex.ExceptionFile.Name}\n" + $"FilePath : {mex.ExceptionFile.Path}\n" + $"FileUrl : {mex.ExceptionFile.Url}\n" + $"FileType : {mex.ExceptionFile.Type}\n\n" + mex.ToString()); } catch (Win32Exception wex) // java exception { MessageBox.Show(wex.ToString() + "\n\nIt seems your java setting has problem"); } catch (Exception ex) // all exception { MessageBox.Show(ex.ToString()); } finally { Invoke(new Action(() => { // re open log form if (logForm != null) { logForm.Close(); } logForm = new GameLog(); logForm.Show(); // enable ui setUIEnabled(true); })); } }); th.Start(); }
private void btnLaunch_Click(object sender, EventArgs e) { //Launches game string selected = this.cbVersion.GetItemText(this.cbVersion.SelectedItem); System.Reflection.Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly(); FileVersionInfo versionInf = FileVersionInfo.GetVersionInfo(assembly.Location); if (guna2CheckBox1.Checked == true) { //Playing rpc if (Properties.Settings.Default.langtr == true) { client.UpdateState($"{selected} oynuyor."); } else { client.UpdateState($"Playing {selected}."); } } UpdateSession(MSession.GetOfflineSession(lbUsername.Text)); if (Session == null) { MessageBox.Show("İlk önce giriş yap"); return; } if (cbVersion.Text == "") { MessageBox.Show("Versiyon Seç / Select Version"); return; } var launchOption = createLaunchOption(); if (launchOption == null) { return; } //Creates launch options var version = cbVersion.Text; var useParallel = rbParallelDownload.Checked; var checkHash = cbCheckFileHash.Checked; var downloadAssets = !cbSkipAssetsDownload.Checked; var th = new Thread(() => { try { if (useMJava) { //Minecraft custom java var mjava = new MJava(MinecraftPath.Runtime); mjava.ProgressChanged += Launcher_ProgressChanged; var javapath = mjava.CheckJava(); launchOption.JavaPath = javapath; } MVersion versionInfo = Versions.GetVersion(version); launchOption.StartVersion = versionInfo; MDownloader downloader; if (useParallel) { downloader = new MParallelDownloader(MinecraftPath, versionInfo, 10, true); } else { downloader = new MDownloader(MinecraftPath, versionInfo); } downloader.ChangeFile += Launcher_FileChanged; downloader.ChangeProgress += Launcher_ProgressChanged; downloader.CheckHash = checkHash; downloader.DownloadAll(downloadAssets); var launch = new MLaunch(launchOption); var process = launch.GetProcess(); StartProcess(process); } catch (MDownloadFileException mex) { MessageBox.Show( $"FileName : {mex.ExceptionFile.Name}\n" + $"FilePath : {mex.ExceptionFile.Path}\n" + $"FileUrl : {mex.ExceptionFile.Url}\n" + $"FileType : {mex.ExceptionFile.Type}\n\n" + mex.ToString()); } catch (Win32Exception wex) { MessageBox.Show(wex.ToString() + "\n\nJava Problem"); } catch (Exception ex) { if (Properties.Settings.Default.langtr == true) { this.Alert("Oyun başlatılamadı", "Libaryler indirilemedi veya", "birşeyler ters gitti.", Form_Info.enmType.Error); }//error else { this.Alert("ERROR", "Libraries could not be downloaded or ", "something goes wrong.", Form_Info.enmType.Error); } MessageBox.Show(ex.ToString()); } }); th.Start(); }
private void btn_Launch_Click(object sender, EventArgs e) { if (gameistarted == true) { killgame(); } else { gameistarted = true; string selected = this.cbVersion.GetItemText(this.cbVersion.SelectedItem); System.Reflection.Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly(); FileVersionInfo versionInf = FileVersionInfo.GetVersionInfo(assembly.Location); client.UpdateState($"Playing {selected}."); UpdateSession(MSession.GetOfflineSession(username_lbl.Text)); if (Session == null) { MessageBox.Show("İlk önce giriş yap"); return; } if (cbVersion.Text == "") { MessageBox.Show("Versiyon Seç / Select Version"); return; } var launchOption = createLaunchOption(); if (launchOption == null) { return; } //Creates launch options var version = cbVersion.Text; var th = new Thread(() => { try { if (useMJava) { //Minecraft custom java var mjava = new MJava(MinecraftPath.Runtime); mjava.ProgressChanged += Launcher_ProgressChanged; var javapath = mjava.CheckJava(); launchOption.JavaPath = javapath; } else { launchOption.JavaPath = javapath; } MVersion versionInfo = Versions.GetVersion(version); launchOption.StartVersion = versionInfo; MDownloader downloader; downloader = new MDownloader(MinecraftPath, versionInfo); downloader.ChangeFile += Launcher_FileChanged; downloader.ChangeProgress += Launcher_ProgressChanged; downloader.CheckHash = true; downloader.DownloadAll(); var launch = new MLaunch(launchOption); var process = launch.GetProcess(); StartProcess(process); btn_Launch.Text = "Oyunu Kapat"; } catch (MDownloadFileException mex) { MessageBox.Show( $"FileName : {mex.ExceptionFile.Name}\n" + $"FilePath : {mex.ExceptionFile.Path}\n" + $"FileUrl : {mex.ExceptionFile.Url}\n" + $"FileType : {mex.ExceptionFile.Type}\n\n" + mex.ToString()); gameistarted = false; } catch (Win32Exception wex) { gameistarted = false; MessageBox.Show(wex.ToString() + "\n\nJava Problem"); } catch (Exception ex) { gameistarted = false; MessageBox.Show(ex.ToString()); } }); th.Start(); } }