コード例 #1
0
 private void Settings_Load(object sender, EventArgs e)
 {
     this.checkBox1.Checked = FileSettings.GetValue("Windowed") == "1";
     this.checkBox2.Checked = FileSettings.GetValue("CloseAfterJoin") == "1";
     this.textBox1.Text     = FileSettings.GetValue("Path");
     this.textBox2.Text     = FileSettings.GetValue("LaunchParameters");
 }
コード例 #2
0
ファイル: VerifyFiles.cs プロジェクト: OutbreakMod/Launcher
        private void button1_Click(object sender, EventArgs e)
        {
            if (this.FileList.Count < 1)
            {
                MessageBox.Show("There's no required updates");
            }
            else
            {
                WebClient client = new WebClient();
                client.DownloadProgressChanged += new DownloadProgressChangedEventHandler(client_DownloadProgressChanged);
                client.DownloadFileCompleted   += new AsyncCompletedEventHandler(client_DownloadFileCompleted);

                foreach (KeyValuePair <string, object[]> kvp in this.DownloadUrls)
                {
                    this.CurrentFile = kvp.Key;
                    string URL = kvp.Value[0].ToString();

                    client.DownloadFileAsync(new Uri(URL), FileSettings.GetValue("Path") + "/@Outbreak/" + kvp.Key);
                    return;
                }
            }
        }
コード例 #3
0
ファイル: VerifyFiles.cs プロジェクト: OutbreakMod/Launcher
        private void client_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
        {
            Label status = (Label)this.DownloadUrls[this.CurrentFile][1];

            status.Text      = "Installed && Up to date";
            status.ForeColor = System.Drawing.Color.DarkGreen;

            this.DownloadUrls.Remove(this.CurrentFile);

            if (this.DownloadUrls.Count > 0)
            {
                WebClient client = new WebClient();
                client.DownloadProgressChanged += new DownloadProgressChangedEventHandler(client_DownloadProgressChanged);
                client.DownloadFileCompleted   += new AsyncCompletedEventHandler(client_DownloadFileCompleted);

                foreach (KeyValuePair <string, object[]> kvp in this.DownloadUrls)
                {
                    this.CurrentFile = kvp.Key;
                    string URL = kvp.Value[0].ToString();

                    client.DownloadFileAsync(new Uri(URL), FileSettings.GetValue("Path") + "/@Outbreak/" + kvp.Key);
                    return;
                }
            }
            else
            {
                this.downloadNotif.Text = "Downloading completed!";

                DelayAction(2000, new Action(() =>
                {
                    this.ResetForm();
                    this.DownloadList();
                }));

                Form1.Form.txtVersionStatus.ForeColor = System.Drawing.Color.Green;
                Form1.Form.txtVersionStatus.Text      = "Up to date";
            }
        }
コード例 #4
0
        public Form1(SplashScreen SplashForm)
        {
            Form = this;
            InitializeComponent();

            Form1.SplashForm  = SplashForm;
            this.FormClosing += Form1_FormClosing;

            String ConfigPath = Environment.CurrentDirectory + "\\config.ini";

            ConfigFile = new INIFile(ConfigPath);

            if (!File.Exists(ConfigPath))
            {
                ConfigFile.Write("Launcher", "Path", "C:/Program Files (x86)/Steam/SteamApps/common/Arma 3");
                ConfigFile.Write("Launcher", "LaunchParameters", "-mod=@CBA_A3;@CUP_Terrains;@CUP_Weapons;@Outbreak");
                ConfigFile.Write("Launcher", "Windowed", "0");
                ConfigFile.Write("Launcher", "CloseAfterJoin", "0");

                ConfigFile.Write("Mod", "CBA", "@CBA_A3");
                ConfigFile.Write("Mod", "Terrains", "@CUP_Terrains");
                ConfigFile.Write("Mod", "Weapons", "@CUP_Weapons");
                ConfigFile.Write("Mod", "Outbreak", "@Outbreak");
            }

            FileSettings.SetValue("Path", ConfigFile.Read("Launcher", "Path"));
            FileSettings.SetValue("LaunchParameters", ConfigFile.Read("Launcher", "LaunchParameters"));
            FileSettings.SetValue("Windowed", ConfigFile.Read("Launcher", "Windowed"));
            FileSettings.SetValue("CloseAfterJoin", ConfigFile.Read("Launcher", "CloseAfterJoin"));

            bool foundPath = false;

            if (Directory.Exists(FileSettings.GetValue("Path")))
            {
                foundPath = File.Exists(FileSettings.GetValue("Path") + "/arma3.exe");
            }

            if (!foundPath)
            {
                MessageBox.Show(this, "Could not find Arma 3 directory, please correct correct it in the settings menu.");
            }

            bool statusAIATP    = false;
            bool statusMAS      = false;
            bool statusOutbreak = true;

            if (Directory.Exists(FileSettings.GetValue("Path") + "/" + ConfigFile.Read("Mod", "Outbreak")))
            {
                try {
                    WebClient client   = new WebClient();
                    string    response = client.DownloadString("http://outbreakmod.com/download/file_list_generate.php");

                    foreach (String FileData in response.Split(Environment.NewLine.ToCharArray()))
                    {
                        if (FileData.Length < 1)
                        {
                            continue;
                        }

                        string Name     = FileData.Split('|')[0];
                        string Checksum = FileData.Split('|')[1];

                        bool FileExists = File.Exists(FileSettings.GetValue("Path") + "/" + ConfigFile.Read("Mod", "Outbreak") + "/" + Name);

                        if (!FileExists)
                        {
                            statusOutbreak = false;
                        }
                        else
                        {
                            string Filesum = "";

                            using (var stream = File.Open(FileSettings.GetValue("Path") + "/" + ConfigFile.Read("Mod", "Outbreak") + "/" + Name, FileMode.Open))
                            {
                                SHA1Managed sha      = new SHA1Managed();
                                byte[]      checksum = sha.ComputeHash(stream);
                                Filesum = BitConverter.ToString(checksum).Replace("-", string.Empty);
                            }

                            if (Checksum.ToLower() != Filesum.ToLower())
                            {
                                statusOutbreak = false;
                            }
                        }
                    }

                    if (statusOutbreak)
                    {
                        this.txtVersionStatus.ForeColor = System.Drawing.Color.Green;
                        this.txtVersionStatus.Text      = "Up to date";
                    }
                    else
                    {
                        this.txtVersionStatus.ForeColor = System.Drawing.Color.Red;
                        this.txtVersionStatus.Text      = "Needs Update (Click to Update)";
                    }
                } catch
                {
                }
            }

            if (Directory.Exists(FileSettings.GetValue("Path") + "/" + ConfigFile.Read("Mod", "CBA")))
            {
                statusMAS = true;
                this.txtCBAA3.ForeColor  = System.Drawing.Color.Green;
                this.txtCBAA3Status.Text = "Installed";
            }

            if (Directory.Exists(FileSettings.GetValue("Path") + "/" + ConfigFile.Read("Mod", "Weapons")))
            {
                statusMAS = true;
                this.txtWeaponsStatus.ForeColor = System.Drawing.Color.Green;
                this.txtWeaponsStatus.Text      = "Installed";
            }

            if (Directory.Exists(FileSettings.GetValue("Path") + "/" + ConfigFile.Read("Mod", "Terrains")))
            {
                statusAIATP = true;
                this.txtTerrainStatus.ForeColor = System.Drawing.Color.Green;
                this.txtTerrainStatus.Text      = "Installed";
            }

            if (!statusAIATP || !statusMAS)
            {
                ModsNotFound notFoundForm = new ModsNotFound();
                notFoundForm.Show();
            }
        }
コード例 #5
0
ファイル: VerifyFiles.cs プロジェクト: OutbreakMod/Launcher
        public void DownloadList()
        {
            this.FileList.Clear();
            this.tableLayoutPanel1.Controls.Clear();

            String Path = FileSettings.GetValue("Path") + "/@Outbreak/";

            WebClient client   = new WebClient();
            string    response = "";

            try
            {
                response = client.DownloadString("http://outbreakmod.com/download/file_list_generate.php");
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
            }

            foreach (String FileData in response.Split(Environment.NewLine.ToCharArray()))
            {
                if (FileData.Length < 1)
                {
                    continue;
                }

                string Name     = FileData.Split('|')[0];
                string Checksum = FileData.Split('|')[1];

                Label label = new Label();
                label.Text  = Name.Split('/')[1];
                label.Width = 160;
                label.Name  = Checksum;

                bool FileExists = File.Exists(FileSettings.GetValue("Path") + "/" + Form1.GetConfig().Read("Mod", "Outbreak") + "/" + Name);

                Label status = new Label();
                status.Width = 240;

                if (!FileExists)
                {
                    status.Text      = "Not Installed";
                    status.ForeColor = System.Drawing.Color.Red;
                }
                else
                {
                    string Filesum = "";

                    using (var stream = File.Open(FileSettings.GetValue("Path") + "/" + Form1.GetConfig().Read("Mod", "Outbreak") + "/" + Name, FileMode.Open))
                    {
                        SHA1Managed sha      = new SHA1Managed();
                        byte[]      checksum = sha.ComputeHash(stream);
                        Filesum = BitConverter.ToString(checksum).Replace("-", string.Empty);
                    }

                    if (Checksum.ToLower() == Filesum.ToLower())
                    {
                        status.Text      = "Installed && Up to date";
                        status.ForeColor = System.Drawing.Color.DarkGreen;
                    }
                    else
                    {
                        status.Text      = "Requires Update";
                        status.ForeColor = System.Drawing.Color.Red;
                    }
                }

                if (status.ForeColor == System.Drawing.Color.Red)
                {
                    this.FileList.Add(new ModFile(label.Text, true));
                    DownloadUrls.Add(Name, new object[] { "http://outbreakmod.com/download/" + Name, status });
                }

                int count = tableLayoutPanel1.Controls.Count;
                tableLayoutPanel1.Controls.Add(label, 0, count);
                tableLayoutPanel1.Controls.Add(status, 1, count);

                int HeightAdd = 20;

                this.Height = this.Height + HeightAdd;
                this.tableLayoutPanel1.Height = this.tableLayoutPanel1.Height + HeightAdd;
                this.button1.Location         = new Point(this.button1.Location.X, this.button1.Location.Y + HeightAdd);
                this.downloadBar.Location     = new Point(this.downloadBar.Location.X, this.downloadBar.Location.Y + HeightAdd);
                this.downloadNotif.Location   = new Point(this.downloadNotif.Location.X, this.downloadNotif.Location.Y + HeightAdd);
            }

            if (this.FileList.Count < 1)
            {
                this.button1.Enabled  = false;
                this.button1.Location = new Point(this.button1.Location.X, this.button1.Location.Y - 10);
                this.Height           = this.Height - 100;

                this.downloadBar.Hide();
                this.downloadNotif.Hide();
            }
            else
            {
                MessageBox.Show("Some files were found to be either out of date or missing.");
                //this.Height = this.Height - 58;
                // this.downloadBar.Hide();
                //this.downloadNotif.Hide();
            }
        }