Beispiel #1
0
        private void patchConverterToolStripMenuItem_Click(object sender, EventArgs e)
        {
            openFileDialog.Title    = "Select the patch you wish to convert";
            openFileDialog.Filter   = "MUO patch (*.muo)|*.muo|UOP patch (*.uop)|*.uop|Verdata patch (verdata.mul)|verdata.mul";
            openFileDialog.FileName = string.Empty;

            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                UpdateStatus("Loading " = openFileDialog.FileName + "...");
                PatchReader reader = new PatchReader(File.Open(openFileDialog.FileName, FileMode.Open), PatchReader.ExtensionToPatchFileType(Path.GetExtension(openFileDialog.FileName)));

                UpdateStatus("Reading patches, please wait... ");
                List <Patch> patches = reader.ReadPatches();


                UpdateStatus("Loaded " + patches.Count.ToString() + " patches into memory...");
                saveFileDialog.Title    = "Select where you wish to save the patches to";
                saveFileDialog.Filter   = "MUO patch (*.muo)|*.muo|UOP patch (*.uop)|*.uop|Verdata patch (verdata.mul)|verdata.mul";
                saveFileDialog.FileName = string.Empty;

                if (saveFileDialog.ShowDialog() == DialogResult.OK)
                {
                    PatchFileType type = PatchReader.ExtensionToPatchFileType(Path.GetExtension(saveFileDialog.FileName));

                    UpdateStatus("Saving patches, please wait... ");

                    PatchWriter writer = new PatchWriter(File.Open(saveFileDialog.FileName, FileMode.OpenOrCreate), type);

                    switch (type)
                    {
                    case PatchFileType.MUO:
                        PatchWriter.CreateMUO(saveFileDialog.FileName, patches); break;

                    case PatchFileType.UOP:
                        PatchWriter.CreateUOP(saveFileDialog.FileName, patches); break;

                    case PatchFileType.Verdata:
                        break;
                    }

                    UpdateStatus("Patch conversion complete");
                    MessageBox.Show("Patch conversion complete", "Success");
                }
                else
                {
                    MessageBox.Show("Patch conversion process aborted", "Aborted");
                }

                if (reader != null)
                {
                    reader.Close();
                }

                patches = null;
            }
        }
Beispiel #2
0
        private void InitializePatchingProcess()
        {
            Invoke((MethodInvoker) delegate()
            {
                lblStatus.Text = "Status: Gathering patching information...";
            });

            DirectoryInfo   directory = new DirectoryInfo(_serverDirectory);
            List <FileInfo> files     = new List <FileInfo>();

            FileInfo[] muoFiles = directory.GetFiles("*.muo");
            FileInfo[] uopFiles = directory.GetFiles("*.uop");
            FileInfo[] mulFiles = directory.GetFiles("verdata.mul");

            List <FileInfo> patchFiles = new List <FileInfo>();

            patchFiles.AddRange(muoFiles);
            patchFiles.AddRange(uopFiles);
            patchFiles.AddRange(mulFiles);

            List <Patch> patches = new List <Patch>();

            for (int i = 0; i < patchFiles.Count; i++)
            {
                PatchReader reader = new PatchReader(
                    File.OpenRead(patchFiles[i].FullName), PatchReader.ExtensionToPatchFileType(patchFiles[i].FullName));

                patches.AddRange(reader.ReadPatches());
                reader.Close();
            }

            for (int i = 0; i < muoFiles.Length; i++)
            {
                muoFiles[i].Delete();
            }
            for (int i = 0; i < uopFiles.Length; i++)
            {
                uopFiles[i].Delete();
            }
            for (int i = 0; i < mulFiles.Length; i++)
            {
                mulFiles[i].Delete();
            }

            if (patches.Count <= 0)
            {
                Complete();
                return;
            }

            Dictionary <int, List <Patch> > typedPatchTable = new Dictionary <int, List <Patch> >();

            for (int i = 0; i < patches.Count; i++)
            {
                if (!typedPatchTable.ContainsKey(patches[i].FileId))
                {
                    typedPatchTable.Add(patches[i].FileId, new List <Patch>());
                }

                typedPatchTable[patches[i].FileId].Add(patches[i]);
            }

            Invoke((MethodInvoker) delegate()
            {
                lvDownloads.Items.Clear();

                columnHeader1.Text = "Mul File";
                columnHeader2.Text = "Total";
                columnHeader3.Text = "Completed";
                columnHeader4.Text = "Progress";
                columnHeader7.Text = "Status";
            });

            List <int> keys = new List <int>(typedPatchTable.Keys);

            _patchCount = keys.Count;

            for (int i = 0; i < keys.Count; i++)
            {
                int key = keys[i];
                patches = typedPatchTable[keys[i]];

                if (patches.Count > 0)
                {
                    FileId id = (FileId)i;

                    PatchingTask task = new PatchingTask(patches.ToArray(), _serverDirectory, id.ToString().Replace('_', '.'));

                    task.ProgressUpdate    += new EventHandler <ProgressUpdateEventArgs>(OnPatchingProgressUpdate);
                    task.ProgressCompleted += new EventHandler <ProgressCompletedEventArgs>(OnPatchingProgressCompleted);

                    ListViewItem item = new ListViewItem(new string[5]);

                    Invoke((MethodInvoker) delegate()
                    {
                        lvDownloads.Items.Add(item);
                        UpdatePatchingStatus(task, item, 0, 100, 0, "Patching Queued");
                    });

                    _patchTable.Add(task, item);
                    _patchManager.Queue(task);
                }
            }

            _patchManager.Begin();
        }