예제 #1
0
        private void button_CreateTAD_Click(object sender, EventArgs e)
        {
            SaveFileDialog saveFileDialog = new SaveFileDialog();

            saveFileDialog.Filter = "TAD File (*.tad)|*.tad";

            if (saveFileDialog.ShowDialog() == DialogResult.OK)
            {
                string tadFilepath = saveFileDialog.FileName;
                string tacFilepath = Path.ChangeExtension(tadFilepath, ".tac");

                TAD tad = new TAD();
                tad.FilePath = tadFilepath;
                foreach (TADEntry entry in listBox_ArchiveFiles.Items)
                {
                    tad.Entries.Add(entry);
                }
                TAC tac = new TAC();
                tac.TAD = tad;

                LoadingDialog loadingDialog = new LoadingDialog();
                loadingDialog.SetProgessable(tac);
                Thread thread = new Thread(delegate() {
                    tac.Pack(tacFilepath);
                });
                loadingDialog.ShowDialog(thread);

                tad.UnixTimestamp = dateTimePicker_TAD.Value;
                tad.Write(tadFilepath);
            }
        }
예제 #2
0
        private void button_SelectFolder_Click(object sender, EventArgs e)
        {
            VistaFolderBrowserDialog folderDialog = new VistaFolderBrowserDialog();

            if (folderDialog.ShowDialog() == DialogResult.OK)
            {
                string          folder  = folderDialog.SelectedPath;
                List <string>   files   = GetFiles(folder);
                List <TADEntry> entries = new List <TADEntry>();

                foreach (var file in files)
                {
                    FileHash hash;
                    string   f = file.Replace(folder, "");

                    hash = MurmurHash2.GetFileHash(f, true);
                    Console.WriteLine("{0} -> {1} : {2} -> {3}", hash.FilePath, hash.FilePathWithHash, hash.Hash.ToString("x8"), hash.FinalHash.ToString("x8"));

                    FileInfo fileInfo = new FileInfo(file);
                    TADEntry entry    = new TADEntry();
                    entry.FilePath   = file;
                    entry.FileName   = file;
                    entry.FileSize   = (uint)fileInfo.Length;
                    entry.Index      = 0;
                    entry.FirstHash  = hash.FinalHash;
                    entry.SecondHash = hash.FilePathHash;
                    entries.Add(entry);
                }

                SaveFileDialog saveFileDialog = new SaveFileDialog();
                saveFileDialog.Filter = "TAD File (*.tad)|*.tad";

                if (saveFileDialog.ShowDialog() == DialogResult.OK)
                {
                    string tadFilepath = saveFileDialog.FileName;
                    string tacFilepath = Path.ChangeExtension(tadFilepath, ".tac");

                    TAD tad = new TAD();
                    tad.FilePath = tadFilepath;
                    foreach (TADEntry entry in entries)
                    {
                        tad.Entries.Add(entry);
                    }
                    TAC tac = new TAC();
                    tac.TAD = tad;

                    LoadingDialog loadingDialog = new LoadingDialog();
                    loadingDialog.SetProgessable(tac);
                    Thread thread = new Thread(delegate() {
                        tac.Pack(tacFilepath);
                    });
                    loadingDialog.ShowDialog(thread);

                    tad.UnixTimestamp = DateTime.Now;
                    tad.Write(tadFilepath);
                }
            }
        }
예제 #3
0
        private void button_Pack2_Click(object sender, EventArgs e)
        {
            InitializeJSON();

            string          folder  = textBox_Folder2.Text + SM_TEXTURES;
            List <string>   files   = GetFiles(folder);
            List <TADEntry> entries = new List <TADEntry>();

            // iterate through files in /textures/ and create TAD entry for each of them
            foreach (var file in files)
            {
                FileHash hash;
                string   f = file.Replace(folder, "");

                hash = MurmurHash2.GetFileHash(f, true);
                Console.WriteLine("{0} -> {1} : {2} -> {3}", hash.FilePath, hash.FilePathWithHash, hash.Hash.ToString("x8"), hash.FinalHash.ToString("x8"));

                FileInfo fileInfo = new FileInfo(file);
                TADEntry entry    = new TADEntry();
                entry.FilePath   = file;
                entry.FileName   = file;
                entry.FileSize   = (uint)fileInfo.Length;
                entry.Index      = 0;
                entry.FirstHash  = hash.FinalHash;
                entry.SecondHash = hash.FilePathHash;
                entries.Add(entry);
            }

            // create tac/tad
            string tadFilepath = textBox_Folder2.Text + SM_ARCHIVE_DATA + "texture_mod.tad";
            string tacFilepath = Path.ChangeExtension(tadFilepath, ".tac");

            TAD tad = new TAD();

            tad.FilePath = tadFilepath;
            foreach (TADEntry entry in entries)
            {
                tad.Entries.Add(entry);
            }
            TAC tac = new TAC();

            tac.TAD = tad;

            LoadingDialog loadingDialog = new LoadingDialog();

            loadingDialog.SetProgessable(tac);
            Thread thread = new Thread(delegate() {
                tac.Pack(tacFilepath);
            });

            loadingDialog.ShowDialog(thread);

            tad.UnixTimestamp = DateTime.Now;
            tad.Write(tadFilepath);
        }
예제 #4
0
        private void button_ExtractTAD_Click(object sender, EventArgs e)
        {
            VistaFolderBrowserDialog folderDialog = new VistaFolderBrowserDialog();

            if (folderDialog.ShowDialog() == DialogResult.OK)
            {
                foreach (TAD tad in listBox_ExtractFiles.Items)
                {
                    string folder = folderDialog.SelectedPath + "\\_" + Path.ChangeExtension(tad.FileName, ".tac") + "_\\";
                    if (!Directory.Exists(folder))
                    {
                        Directory.CreateDirectory(folder);
                    }
                    TAC tac = new TAC(tad);

                    LoadingDialog loadingDialog = new LoadingDialog();
                    loadingDialog.SetProgessable(tac);
                    Thread thread = new Thread(delegate() {
                        tac.Unpack(false, false, folder);
                    });
                    loadingDialog.ShowDialog(thread);
                }
            }
        }