示例#1
0
        private void MainWindow_Load(object sender, EventArgs e)
        {
            vers = Core.GetVersions().ToArray();
            if (vers.Length == 0)
            {
                MessageBox.Show("游戏损坏!", "警告");
                Application.Exit();
            }
            lbVer.Text = vers.Last().Id;
            //如果设置文件存在
            string inifile = Application.StartupPath + @"\.minecraft\set.ini";

            if (System.IO.File.Exists(inifile))
            {
                Config.Java = Util.ConfigOpt.INIGetStringValue(inifile, "Setting", "Java", KMCCC.Tools.SystemTools.FindJava().Last());
                string strRAM = Util.ConfigOpt.INIGetStringValue(inifile, "Setting", "RAM", "1024");
                Config.maxRAM = int.Parse(strRAM);
                Config.nick   = Util.ConfigOpt.INIGetStringValue(inifile, "Setting", "NickName", "");
            }
            else
            {
                string java;
                try
                {
                    java = KMCCC.Tools.SystemTools.FindJava().Last();
                }
                catch (Exception)
                {
                    MessageBox.Show("找不到Javaw.exe, 请手动输入");
                    java = MSPDT.Windows.InputForm.Show("提示", "请输入java路径(javaw.exe完整路径)");
                    if (!System.IO.File.Exists(java))
                    {
                        MessageBox.Show("文件不存在!");
                        Application.Exit();
                    }
                    else
                    {
                        if (!(java.EndsWith("javaw.exe")))
                        {
                            MessageBox.Show("文件不存在!");
                            Application.Exit();
                        }
                    }
                }
                Config.Java = java;
                string nick = MSPDT.Windows.InputForm.Show("提示", "请输入玩家昵称(英文, 字母, 下划线混合)");
                Config.nick   = nick;
                Config.maxRAM = 1024;

                Save(inifile);
            }
            txtJava.Text   = Config.Java;
            txtMaxRem.Text = Config.maxRAM.ToString();
            txtNick.Text   = Config.nick;
        }
        public MainWindow()
        {
            InitializeComponent();
            comboBox1.SelectedIndex = 0;
            java_path.Add(Environment.GetEnvironmentVariable("JAVA_HOME") + @"\bin\javaw.exe");
            javapath.Text = java_path[0].ToString();
            var versions = Core.GetVersions().ToArray(); //定义变量获取版本列表

            comboBox1.ItemsSource       = versions;      //绑定数据源
            comboBox1.DisplayMemberPath = "Id";          //设置comboBox显示的为版本Id
        }
示例#3
0
    protected void LoadVersions()
    {
        LauncherCore core     = LauncherCore.Create();
        var          versions = core.GetVersions().Cast <KMCCC.Launcher.Version>();

        if (versions.Any())
        {
            foreach (KMCCC.Launcher.Version version in versions)
            {
                comboboxVersion.AppendText(version.Id);
            }
            comboboxVersion.Model.IterNthChild(out TreeIter iter, 0);
            comboboxVersion.SetActiveIter(iter);
        }
    }
示例#4
0
        public static void LoadVersions()
        {
            YingConfig.YArgs.Versions.Clear();
            foreach (var ver in YCore.GetVersions())
            {
                YingConfig.YArgs.Versions.Add(ver);
            }

            if (!YingConfig.YArgs.Versions.Any())
            {
                YingConfig.YArgs.VersionIndex = -1;
            }
            else if (YingConfig.YArgs.VersionIndex == -1 || YingConfig.YArgs.VersionIndex >= YingConfig.YArgs.Versions.Count)
            {
                YingConfig.YArgs.VersionIndex = 0;
            }
        }
示例#5
0
        private void Initialize_LauncherCore()
        {
            Core           = LauncherCore.Create();
            Core.GameExit += OnGameExit;
            Core.GameLog  += OnGameLog;

            uint count = 0;

            foreach (Version ver in Core.GetVersions())
            {
                Versions.Add(ver);
                count++;
            }

            if (count == 0)
            {
                Config.VersionIndex = -1;
            }
            else
            {
                if (Config.VersionIndex == -1 || Config.VersionIndex >= count)
                {
                    Config.VersionIndex = 0;
                }
            }

            var logPath = Core.GameRootPath + @"\logs\";

            if (!Directory.Exists(logPath))
            {
                Directory.CreateDirectory(logPath);
            }

            log_FileStream = new FileStream(logPath + "mcrun.log", FileMode.Create);
            Logger         = new StreamWriter(log_FileStream);
        }