Exemplo n.º 1
0
        private void DownloadGame(MProfile profile, bool downloadResource = true)
        {
            MDownloader downloader = new MDownloader(profile);

            downloader.ChangeFile += Downloader_ChangeFile;
            downloader.DownloadAll(downloadResource);
        }
Exemplo n.º 2
0
        public void CheckGameFiles(MProfile profile, bool downloadAsset = true)
        {
            var downloader = new MDownloader(profile);

            downloader.ChangeFile     += (e) => fire(e);
            downloader.ChangeProgress += (sender, e) => fire(e.ProgressPercentage);
            downloader.DownloadAll(downloadAsset);
        }
Exemplo n.º 3
0
        private void DownloadGame(MProfile profile)
        {
            MDownloader downloader = new MDownloader(profile);

            downloader.ChangeFile     += formMain.Downloader_ChangeFile;
            downloader.ChangeProgress += formMain.Downloader_ChangeProgress;
            downloader.DownloadAll();
        }
Exemplo n.º 4
0
        private void DownloadGame(MProfile profile) // download game files
        {
            MDownloader downloader = new MDownloader(profile);

            downloader.ChangeFile     += Downloader_ChangeFile;
            downloader.ChangeProgress += Downloader_ChangeProgress;
            downloader.DownloadAll();
        }
Exemplo n.º 5
0
 public async Task <IActionResult> OnPostDownload()
 {
     if (LStarted == true)
     {
         HttpContext.Session.Set("LQueryProgress", true);
         return(RedirectToPage("/Launcher"));
     }
     HttpContext.Session.Set("DLQueryProgress", true);
     if (DLStarted == false)
     {
         DLStarted            = true;
         DLFileKind           = string.Empty;
         DLFileName           = string.Empty;
         DLProgressedFileCnt  = "0";
         DLTotFileCnt         = "?";
         DLProgressPercentage = "0";
         DLSuccess            = "false";
         var         minecraft        = new MinecraftPath(Path.Combine(Utility.GetWorkingDir(), ".minecraft"));
         var         versionMetadatas = new MVersionLoader().GetVersionMetadatas(minecraft);
         var         version          = versionMetadatas.GetVersion("1.16.5");
         MDownloader downloader       = new MDownloader(minecraft, version);
         downloader.ChangeFile += (e) => {
             DLFileKind          = e.FileKind.ToString();
             DLFileName          = e.FileName;
             DLProgressedFileCnt = e.ProgressedFileCount.ToString();
             DLTotFileCnt        = e.TotalFileCount.ToString();
         };
         downloader.ChangeProgress += (sender, e) => {
             DLProgressPercentage = e.ProgressPercentage.ToString();
         };
         await Task.Run(() => {
             try
             {
                 downloader.DownloadAll();
                 HttpContext.Session.Set("SuccessMsg", Translation.Translate("launcher-success-dl"));
             } catch (Exception e)
             {
                 HttpContext.Session.Set("ErrorMsg", e.Message);
             }
             HttpContext.Session.Set("DLQueryProgress", false);
             DLSuccess = "true";
             DLStarted = false;
         });
     }
     return(RedirectToPage("/Launcher"));
 }
Exemplo n.º 6
0
        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();
        }
Exemplo n.º 7
0
        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();
        }
Exemplo n.º 8
0
        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();
        }
Exemplo n.º 9
0
        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();
            }
        }