예제 #1
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);
                }
            }
        }
예제 #2
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);
        }
예제 #3
0
        private void listBox_ArchiveFiles_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (listBox_ArchiveFiles.SelectedIndex >= listBox_ArchiveFiles.Items.Count || listBox_ArchiveFiles.SelectedIndex < 0)
            {
                return;
            }
            TADEntry entry = (TADEntry)listBox_ArchiveFiles.Items[listBox_ArchiveFiles.SelectedIndex];

            textBox_Filepath.Text = entry.FileName;
            textBox_Hash1.Text    = String.Format("{0:X8}", entry.FirstHash);
            textBox_Hash2.Text    = String.Format("{0:X8}", entry.SecondHash);
        }
예제 #4
0
        private void textBox_Filepath_TextChanged(object sender, EventArgs e)
        {
            if (listBox_ArchiveFiles.SelectedIndex >= listBox_ArchiveFiles.Items.Count || listBox_ArchiveFiles.SelectedIndex < 0)
            {
                return;
            }
            TADEntry entry = (TADEntry)listBox_ArchiveFiles.Items[listBox_ArchiveFiles.SelectedIndex];

            entry.FileName = textBox_Filepath.Text;
            entry.CalculateFilenameHashes(checkBox_SingleHash.Checked);
            textBox_Hash1.Text = String.Format("{0:X8}", entry.FirstHash);
            textBox_Hash2.Text = String.Format("{0:X8}", entry.SecondHash);
        }
예제 #5
0
 private void listBox_ArchiveFiles_DragDrop(object sender, DragEventArgs e)
 {
     string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
     for (int i = 0; i < files.Length; i++)
     {
         string   file     = files[i];
         FileInfo fileInfo = new FileInfo(file);
         TADEntry entry    = new TADEntry();
         entry.FilePath = file;
         entry.FileName = file;
         entry.FileSize = (uint)fileInfo.Length;
         entry.Index    = (uint)i;
         listBox_ArchiveFiles.Items.Add(entry);
     }
 }