Exemplo n.º 1
0
        public bool Upload(byte[] mission, string missionName)
        {
            try
            {
                LauncherConfigJson presetFile = ReturnPresetFile();

                using (WebClient client = new WebClient())
                {
                    client.Headers.Add("auth", password_textBox.Text);
                    client.Headers.Add("filename", missionName);

                    client.UploadData(new Uri(presetFile.missions_link), mission);
                }

                MessageBox.Show("Upload Done!");
            }
            catch (WebException e)
            {
                dynamic resp = new StreamReader(e.Response.GetResponseStream()).ReadToEnd();
                dynamic obj  = JsonConvert.DeserializeObject(resp);
                MessageBox.Show((string)obj.error[0]);

                return(false);
            }
            catch (Exception e)
            {
                MessageBox.Show("Upload error.\n" + e.Message);

                return(false);
            }

            return(true);
        }
Exemplo n.º 2
0
        public async void CreateVerifyFile()
        {
            if (!ReadPresetFile())
            {
                return;
            }

            List <string> folderFiles = Directory.GetFiles(pathToModsFolder_textBox.Text, "*", SearchOption.AllDirectories).ToList();

            folderFiles = folderFiles.Select(a => a.Replace(pathToModsFolder_textBox.Text, "")).Select(b => b.ToLower()).ToList();

            Console.WriteLine(folderFiles.Count);

            folderFiles = folderFiles.Where(a => presetModsList.Any(b => a.StartsWith("\\" + b.ToLower() + "\\"))).Where(c => c.EndsWith(".pbo") || c.EndsWith(".dll")).ToList();

            Console.WriteLine(folderFiles.Count);

            LauncherConfigJson json = new LauncherConfigJson();

            json.server        = server;
            json.password      = password;
            json.verify_link   = verifyModsLink;
            json.missions_link = missionsLink;
            json.mods          = presetModsList.ToArray();
            json.files         = new Dictionary <string, LauncherConfigJsonFile>();

            LauncherConfigJson json_old = new LauncherConfigJson();

            string murshunLauncherFilesPath = pathToModsFolder_textBox.Text + "\\MurshunLauncherFiles.json";

            if (File.Exists(murshunLauncherFilesPath))
            {
                json_old = JsonConvert.DeserializeObject <LauncherConfigJson>(File.ReadAllText(murshunLauncherFilesPath));
            }

            progressBar1.Minimum = 0;
            progressBar1.Maximum = folderFiles.Count();
            progressBar1.Value   = 0;
            progressBar1.Step    = 1;

            json = await Task.Run(() => BuildVerifyList(folderFiles, json_old, json));

            string json_new = JsonConvert.SerializeObject(json, Formatting.Indented);

            SetLauncherFiles(GetMD5FromBuffer(json_new));

            SaveLauncherFiles(json_new);
        }
Exemplo n.º 3
0
        public LauncherConfigJson ReturnPresetFile()
        {
            string xmlPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\MurshunLauncher\\MurshunLauncher.xml";

            XmlSerializer serializer = new XmlSerializer(typeof(MurshunLauncherXmlSettings));

            StreamReader reader = new StreamReader(xmlPath);

            MurshunLauncherXmlSettings LauncherSettings = (MurshunLauncherXmlSettings)serializer.Deserialize(reader);

            reader.Close();

            string murshunLauncherFilesPath = LauncherSettings.pathToArma3ClientMods_textBox + "\\MurshunLauncherFiles.json";

            LauncherConfigJson json = JsonConvert.DeserializeObject <LauncherConfigJson>(File.ReadAllText(murshunLauncherFilesPath));

            return(json);
        }
Exemplo n.º 4
0
        public LauncherConfigJson BuildVerifyList(List <string> folderFiles, LauncherConfigJson json_old, LauncherConfigJson json)
        {
            LockInterface("Building Verify File...");

            foreach (string X in folderFiles)
            {
                FileInfo file = new FileInfo(pathToModsFolder_textBox.Text + X);

                ChangeHeader("Reading... (" + progressBar1.Value + "/" + progressBar1.Maximum + ") - " + file.Name + "/" + file.Length / 1024 / 1024 + "mb");

                LauncherConfigJsonFile data = new LauncherConfigJsonFile();

                data.size = file.Length;
                data.date = GetUnixTime(file.LastWriteTimeUtc).ToString();

                try
                {
                    if (json_old.files[X].date == GetUnixTime(file.LastWriteTimeUtc).ToString())
                    {
                        data.md5 = json_old.files[X].md5;
                    }
                    else
                    {
                        data.md5 = GetMD5FromPath(pathToModsFolder_textBox.Text + X);
                    }
                }
                catch
                {
                    data.md5 = GetMD5FromPath(pathToModsFolder_textBox.Text + X);
                }

                json.files[X] = data;

                Invoke(new Action(() => progressBar1.PerformStep()));

                ChangeHeader("Reading... (" + progressBar1.Value + "/" + progressBar1.Maximum + ") - " + file.Name + "/" + file.Length / 1024 / 1024 + "mb");
            }

            UnlockInterface();

            return(json);
        }
Exemplo n.º 5
0
        public bool ReadPresetFile()
        {
            string murshunLauncherFilesPath = pathToMods_textBox.Text + "\\MurshunLauncherFiles.json";

            presetModsList = new List <string>();

            if (!File.Exists(murshunLauncherFilesPath))
            {
                MessageBox.Show("MurshunLauncherFiles.json not found. Select your BTsync folder as Arma 3 Mods folder.");
                return(false);
            }

            LauncherConfigJson json = JsonConvert.DeserializeObject <LauncherConfigJson>(File.ReadAllText(murshunLauncherFilesPath));

            presetModsList = json.mods.ToList();

            RefreshPresetModsList();

            return(true);
        }
Exemplo n.º 6
0
        public async Task <bool> VerifyMods(bool fullVerify)
        {
            if (!ReadPresetFile())
            {
                return(false);
            }

            string murshunLauncherFilesPath = pathToMods_textBox.Text + "\\MurshunLauncherFiles.json";

            LauncherConfigJson json = JsonConvert.DeserializeObject <LauncherConfigJson>(File.ReadAllText(murshunLauncherFilesPath));

            if (!await Task.Run(() => CheckLauncherFiles(json.verify_link, GetMD5(murshunLauncherFilesPath))))
            {
                return(false);
            }

            List <string> folderFiles = Directory.GetFiles(pathToMods_textBox.Text, "*", SearchOption.AllDirectories).ToList();

            folderFiles = folderFiles.Select(a => a.Replace(pathToMods_textBox.Text, "")).Select(b => b.ToLower()).ToList();

            folderFiles = folderFiles.Where(a => presetModsList.Any(b => a.StartsWith("\\" + b.ToLower() + "\\"))).Where(c => c.EndsWith(".pbo") || c.EndsWith(".dll")).ToList();

            modsFiles_listView.Items.Clear();
            launcherFiles_listView.Items.Clear();

            progressBar1.Minimum = 0;
            progressBar1.Maximum = folderFiles.Count();
            progressBar1.Value   = 0;
            progressBar1.Step    = 1;

            List <string> clientFiles = await Task.Run(() => GetVerifyList(folderFiles, fullVerify));

            foreach (string X in clientFiles)
            {
                modsFiles_listView.Items.Add(X);
            }

            foreach (KeyValuePair <string, LauncherConfigJsonFile> X in json.files)
            {
                long   size = X.Value.size;
                string date = X.Value.date;
                string md5  = X.Value.md5;

                if (!fullVerify)
                {
                    launcherFiles_listView.Items.Add(X.Key + ":" + size + ":" + date);
                }
                else
                {
                    launcherFiles_listView.Items.Add(X.Key + ":" + md5);
                }
            }

            folderFiles = modsFiles_listView.Items.Cast <ListViewItem>().Select(x => x.Text).ToList();

            List <string> jsonFiles = launcherFiles_listView.Items.Cast <ListViewItem>().Select(x => x.Text).ToList();

            List <string> missingFilesList = jsonFiles.Where(x => !folderFiles.Contains(x)).ToList();
            List <string> excessFilesList  = folderFiles.Where(x => !jsonFiles.Contains(x)).ToList();

            missingFiles_listView.Items.Clear();
            excessFiles_listView.Items.Clear();

            foreach (string X in missingFilesList)
            {
                missingFiles_listView.Items.Add(X);
            }

            foreach (string X in excessFilesList)
            {
                excessFiles_listView.Items.Add(X);
            }

            modsFiles_textBox.Text     = pathToMods_textBox.Text + " (" + modsFiles_listView.Items.Count + " files / " + missingFiles_listView.Items.Count + " missing)";
            launcherFiles_textBox.Text = "MurshunLauncherFiles.json (" + launcherFiles_listView.Items.Count + " files / " + excessFiles_listView.Items.Count + " excess)";

            if (missingFiles_listView.Items.Count != 0 || excessFiles_listView.Items.Count != 0)
            {
                if (tabControl1.SelectedTab != tabPage4)
                {
                    MessageBox.Show("You have missing or excess files.");
                }

                return(false);
            }

            return(true);
        }