Example #1
0
        private void frmMain_Loaded(object sender, RoutedEventArgs e)
        {
            ConfigApp.initDirSetting();

            webServer = new WebServer(clientInfoAdd);

            os = new OS();
            os.interfaceServerDisabled    = interfaceServerDisabled;
            os.interfaceMinecraftDisabled = interfaceMinecraftDisabled;
            os.serverRunning    = serverRunning;
            os.minecraftRunning = minicraftRunning;
            os.startMonitor();

            this.frmMain.Title = ConfigApp.getAppTitle();

            cfgClient  = ConfigApp.LoadClientSetting();
            cfgServer  = ConfigApp.LoadServerSetting();
            listServer = ConfigApp.LoadListServer();


            cmbMemory.ItemsSource = os.freeMemory();
            //cmbMemory.ite;
            cmbMemoryServer.ItemsSource  = os.freeMemory();
            lblIsx64.Content             = os.getIsOSx64() + os.getJavaInfo();
            cmbVersionGame.ItemsSource   = game.getGameVersions();
            cmbVersionServer.ItemsSource = server.getVersions();


            //SERVER SETTING
            for (int i = 0; i < listServer.Length; i++)
            {
                cmbGameServer.Items.Add(listServer[i]);
            }

            // CLIENT
            txtUserName.Text    = (!String.IsNullOrEmpty(cfgClient.Username)) ? cfgClient.Username : os.getUserName();
            IsForge.IsChecked   = cfgClient.IsForge;
            isReMods.IsChecked  = cfgClient.IsinstallMods;
            cmbMemory.Text      = (!String.IsNullOrEmpty(cfgClient.Memory)) ? cfgClient.Memory.Trim() : "";
            cmbVersionGame.Text = (!String.IsNullOrEmpty(cfgClient.VersionGame)) ? cfgClient.VersionGame.Trim() : "";
            //txtHostServerMap.Text = cfgClient.HostServer;
            cmbGameServer.Text     = cfgClient.HostServer;
            txtPortGameServer.Text = cfgClient.PortGameServer;
            txtPortMapServer.Text  = cfgClient.PortMapServer;

            //SERVER
            cmbMemoryServer.Text  = (!String.IsNullOrEmpty(cfgServer.Memory)) ? cfgServer.Memory.Trim() : "";
            cmbVersionServer.Text = (!String.IsNullOrEmpty(cfgServer.Version)) ? cfgServer.Version.Trim() : "";
            isGUI.IsChecked       = cfgServer.IsGUI;


            // Отправить данные на сервер
            string postData = String.Format("login={0}&memory={1}&version={2}&is_forge={3}&version_launcher={4}",
                                            cfgClient.Username, cfgClient.Memory, cfgClient.VersionGame, cfgClient.IsForge, ConfigApp.getVersion());

            new WebClientInfo(serverResponseInfo).send(postData);
        }
Example #2
0
        //Сохранить конфигурацию
        public static void SaveClientSetting(ConfigClient cf)
        {
            string fileConfig = DIR_ROOT + @"\" + DIR_SETTING + @"\" + FILE_CLIENT_CONFIG;

            StreamWriter save = new StreamWriter(fileConfig);

            save.WriteLine(cf.Username);
            save.WriteLine(cf.Memory);
            save.WriteLine(cf.VersionGame);
            save.WriteLine(cf.IsForge);
            save.WriteLine(cf.IsinstallMods);
            save.WriteLine(cf.HostServer);
            save.WriteLine(cf.PortGameServer);
            save.WriteLine(cf.PortMapServer);
            save.Close();
        }
Example #3
0
        //Загрузка настроек
        public static ConfigClient LoadClientSetting()
        {
            ConfigClient cf         = new ConfigClient();
            string       fileConfig = DIR_ROOT + @"\" + DIR_SETTING + @"\" + FILE_CLIENT_CONFIG;

            if (!File.Exists(fileConfig))
            {
                return(cf);
            }

            StreamReader load = new StreamReader(fileConfig);

            cf.Username       = load.ReadLine();
            cf.Memory         = load.ReadLine();
            cf.VersionGame    = load.ReadLine();
            cf.IsForge        = Convert.ToBoolean(load.ReadLine());
            cf.IsinstallMods  = Convert.ToBoolean(load.ReadLine());
            cf.HostServer     = load.ReadLine();
            cf.PortGameServer = load.ReadLine();
            cf.PortMapServer  = load.ReadLine();
            load.Close();
            return(cf);
        }
Example #4
0
        public bool run(ConfigClient cfg, string java)
        {
            string pathNatives = ConfigApp.currentDir + @"\natives\" + cfg.VersionGame;

            if (!existNatives(pathNatives))
            {
                System.Windows.MessageBox.Show("Библиотеки natives не найдены");
                return(false);
            }

            libraries = new List <String>();
            JsonForge     jsonForge  = null;
            JsonMinecraft jsonNative = null;
            JsonRift      jsonRift   = null;

            // Загрузка Rift библиотек
            if (cfg.IsRift)
            {
                jsonRift = addRaftLibs(cfg.VersionGame);
            }

            // Загрузка Forge библиотек
            if (cfg.IsForge)
            {
                jsonForge = loadLibrariesForge(cfg.VersionGame);
            }

            //Загрузка Native библиотек
            jsonNative = loadNativeLibraries(cfg.VersionGame);

            if (jsonNative == null)
            {
                System.Windows.MessageBox.Show("Библиотеки не загружены"); return(false);
            }

            // Установка класса запуска
            if (cfg.IsForge)
            {
                mainClass = jsonForge.mainClass;
            }
            else
            {
                mainClass = jsonNative.mainClass;
            }

            // Переустановка модов
            if (cfg.IsinstallMods)
            {
                ModForge.install(cfg.VersionGame);
            }

            // Строка запуска
            string param = generateParamString(cfg.Memory, pathNatives, jsonNative, cfg.Username, cfg.HostServer, cfg.PortGameServer);

            if (cfg.IsForge)
            {
                if (cfg.VersionGame == "1.12.2" || cfg.VersionGame == "1.11.2")
                {
                    param += @" --tweakClass net.minecraftforge.fml.common.launcher.FMLTweaker";         // --tweakClass cpw.mods.fml.common.launcher.FMLTweaker
                }
                param += " " + modParams;
            }

            try
            {
                Process start = new Process();
                start.StartInfo.CreateNoWindow  = true;
                start.StartInfo.UseShellExecute = false;
                start.StartInfo.Arguments       = param;
                start.StartInfo.FileName        = java + @"\javaw.exe";
                start.Start();
                return(true);
            }
            catch (Exception ex)
            {
                System.Windows.MessageBox.Show(ex.Message + " " + ex.StackTrace);
            }

            return(false);
        }