예제 #1
0
        private void winactive(object sender, RoutedEventArgs e)
        {
            var th = new Thread(new ThreadStart(delegate
            {
                var McPath   = Minecraft.GetOSDefaultPath();
                var launcher = new CMLauncher(McPath);

                // you must write this because of cmllib.core bug. it will be fixed soon
                launcher.ProgressChanged += Launcher_ProgressChanged;
                launcher.FileChanged     += Launcher_FileChanged;

                launcher.UpdateProfiles();                 // this code will block ui, so it should run in thread

                Dispatcher.BeginInvoke(new Action(delegate // call UI Thread
                {
                    foreach (var item in launcher.Profiles)
                    {
                        if (item.MType == MProfileType.Release || item.MType == MProfileType.Custom)
                        {
                            LauncherProfiles.Items.Add(item.Name);
                        }
                    }
                }));
            }));

            th.Start();
        }
예제 #2
0
        private void reloadVersions()
        {
            string path = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + @"\MaiksLauncher\";

            File.WriteAllText(path + @"VersionList.mvl", String.Empty);
            var McPath = Minecraft.GetOSDefaultPath();

            launcher = new CMLauncher(McPath);
            // you must write this because of cmllib.core bug. it will be fixed soon
            launcher.ProgressChanged += Launcher_ProgressChanged;
            launcher.FileChanged     += Launcher_FileChanged;
            launcher.UpdateProfiles();
            int MTypeAmount = 0;

            foreach (var profile in launcher.Profiles)
            {
                if (profile.MType == MProfileType.Release)
                {
                    MTypeAmount++;
                }
            }
            string[] vers  = new string[MTypeAmount];// this code will block ui, so it should run in thread
            int      index = 0;

            foreach (var profile in launcher.Profiles)
            {
                if (profile.MType == MProfileType.Release)
                {
                    vers[index] = profile.Name; index++;
                }
            }

            StreamWriter sw = new StreamWriter(path + @"VersionList.mvl");

            foreach (string VARIABLE in vers)
            {
                sw.WriteLine(VARIABLE);
            }
            sw.Close();
            Application.Current.Dispatcher.Invoke(delegate
            {
                versionList.Items.Clear();
                foreach (string ver in vers)
                {
                    versionList.Items.Add(ver);
                }
            });
        }
        private void MainLauncher_Load(object sender, EventArgs e)
        {
            string path = Minecraft.GetOSDefaultPath();

            Data.MC_OS_PATH = path;
            CMLauncher launcher = new CMLauncher(path);

            launcher.UpdateProfiles();
            Data.launcher = launcher;
            if (File.Exists("mars_client\\serverip.ser"))
            {
                string ip = File.ReadAllText("mars_client\\serverip.ser");
                Data.serverIP = ip;
            }
            if (File.Exists("mars_client\\version.ser"))
            {
                string ver = File.ReadAllText("mars_client\\version.ser");
                Data.versionString = ver;
            }
        }