예제 #1
0
        private void StartGame()
        {
            var local = MProfileInfo.GetProfilesFromLocal();

            MProfileInfo[] versions = MProfileInfo.GetProfiles();
            MProfile       profile  = MProfile.GetProfile(versions, "1.12.2-forge1.12.2-14.23.5.2847");
            MLaunchOption  option   = new MLaunchOption()
            {
                StartProfile        = profile,
                JavaPath            = GADD_Application.Properties.Settings.Default.mclocation + "\\runtime\\bin\\javaw.exe",
                MaximumRamMb        = GADD_Application.Properties.Settings.Default.ram,
                LauncherName        = "GADD",
                Session             = session,
                CustomJavaParameter = Properties.Settings.Default.javargs
            };
            MLaunch launch = new MLaunch(option);
            var     proc   = launch.GetProcess();

            //proc.Start();
            //launch.GetProcess().Start();
            StartDebug(proc);
            //Console.ProcessLock(launch);
            Invoke((MethodInvoker) delegate
            {
                GaddPage.GP.ButtonStat(true);
            });
        }
예제 #2
0
        private void Btn_Launch_Click(object sender, EventArgs e)
        {
            // 실행 버튼 눌렀을때
            // 실행할 버전으로 프로파일 검색하고 패치
            // 실행에 필요한 인수 설정
            // 실행

            if (session == null)
            {
                MessageBox.Show("Login First");
                return;
            }

            if (Cb_Version.Text == "")
            {
                return;
            }
            groupBox1.Enabled = false;
            groupBox2.Enabled = false;

            string nn     = Cb_Version.Text;
            string jj     = Txt_Java.Text;
            string xmx    = Txt_Ram.Text;
            string ln     = Txt_LauncherName.Text;
            string server = Txt_ServerIp.Text;

            var th = new Thread(new ThreadStart(delegate
            {
                var profile = MProfile.GetProfile(versions, nn);

                DownloadGame(profile);

                MLaunchOption option = new MLaunchOption()
                {
                    StartProfile        = profile,
                    JavaPath            = jj,
                    LauncherName        = ln,
                    MaximumRamMb        = int.Parse(xmx),
                    ServerIp            = server,
                    Session             = session,
                    CustomJavaParameter = Txt_JavaArgs.Text
                };

                if (Txt_ScWd.Text != "" && Txt_ScHt.Text != "")
                {
                    option.ScreenHeight = int.Parse(Txt_ScHt.Text);
                    option.ScreenWidth  = int.Parse(Txt_ScWd.Text);
                }

                MLaunch launch = new MLaunch(option);

                if (true)
                {
                    StartDebug(launch);
                }
                else
                {
                    var pro = launch.GetProcess();                                     // 인수 생성 후 설정된 Process 객체 가져옴
                    System.IO.File.WriteAllText("mcarg.txt", pro.StartInfo.Arguments); // 만들어진 인수 파일로 저장 (디버그용)
                    pro.Start();                                                       // Process 객체로 실행
                }

                this.Invoke((MethodInvoker) delegate
                {
                    groupBox1.Enabled = true;
                    groupBox2.Enabled = true;
                });
            }));

            th.Start();
        }
예제 #3
0
        public void MC_Play()
        {
            try
            {
                Debug(1);
                GaddPage.GP.ButtonStat(false);
                int    update             = 0;
                string localv             = GADD_Application.Properties.Settings.Default.version;
                bool   mcprofileinstalled = GADD_Application.Properties.Settings.Default.MCProfileInstalled;
                string versionfile;
                using (WebClient wc = new WebClient())
                {
                    versionfile = wc.DownloadString(Classes.Definitions.UpdateURL + "version.txt");
                }
                update = GADD_Application.Classes.Toolkit.VersionParser(versionfile.Split('-'), localv, versionfile);
                string pubver  = versionfile.Split('-')[0];
                string fullver = versionfile;

                var th = new Thread(new ThreadStart(delegate
                {
                    Minecraft.Initialize(MCHandler.mclocation);
                    if (!Directory.Exists(MHC.version_folder))
                    {
                        Directory.CreateDirectory(MHC.version_folder);
                    }
                    if (!File.Exists(MHC.version_file))
                    {
                        using (var client = new WebClient())
                        {
                            client.DownloadFile(Classes.Definitions.UpdateURL + "original/1.12.2-forge1.12.2-14.23.5.2847.json", MCHandler.mclocation + "/" + "versions/1.12.2-forge1.12.2-14.23.5.2847/1.12.2-forge1.12.2-14.23.5.2847.json");
                        }
                    }
                    var local = MProfileInfo.GetProfilesFromLocal();
                    MProfileInfo[] versions = MProfileInfo.GetProfiles();
                    MProfile profile        = MProfile.GetProfile(versions, "1.12.2-forge1.12.2-14.23.5.2847");
                    MProfile profileb       = MProfile.GetProfile(versions, "1.12.2");
                    if (update != 0)
                    {
                        mcprofileinstalled = false;
                    }
                    if (!mcprofileinstalled)
                    {
                        DownloadGame(profile);
                        DownloadGame(profileb);
                        Invoke((MethodInvoker) delegate
                        {
                            GADD_Application.Properties.Settings.Default.MCProfileInstalled = true;
                            Properties.Settings.Default.Save();
                        });
                    }
                    if (update == 1)
                    {
                        DownloadModpack(pubver);
                    }
                    if (update == 2)
                    {
                        DownloadModpack(pubver);
                    }
                    if (update == 3)
                    {
                        DownloadModpack(pubver, GADD_Application.Classes.Toolkit.PublicPatchVersion());
                    }
                    Invoke((MethodInvoker) delegate
                    {
                        GADD_Application.Properties.Settings.Default.version = fullver;
                        Properties.Settings.Default.Save();
                    });
                    if (update == 0)
                    {
                        StartGame();
                    }
                }));
                th.Start();
            }
            catch (Exception errormessage)
            {
                SphubCore.Reporting.Reporting.ER(errormessage);
            }
        }