示例#1
0
        private void button6_Click(object sender, EventArgs e)
        {
            using (SaveFileDialog fd = new SaveFileDialog()
            {
                DefaultExt = "ini", Filter = "INI files|*.ini", InitialDirectory = Environment.CurrentDirectory, RestoreDirectory = true
            })
                if (fd.ShowDialog(this) == DialogResult.OK)
                {
                    string     dstfol = Path.GetDirectoryName(fd.FileName);
                    DllIniData output = new DllIniData()
                    {
                        Name     = IniData.Name,
                        Game     = IniData.Game,
                        Exports  = IniData.Exports,
                        TexLists = IniData.TexLists,
                        Files    = new DictionaryContainer <FileTypeHash>()
                    };
                    List <string> labels = new List <string>();
                    foreach (KeyValuePair <string, FileTypeHash> item in IniData.Files.Where((a, i) => listView1.CheckedIndices.Contains(i)))
                    {
                        Directory.CreateDirectory(Path.GetDirectoryName(Path.Combine(dstfol, item.Key)));
                        File.Copy(item.Key, Path.Combine(dstfol, item.Key), true);
                        switch (item.Value.Type)
                        {
                        case "landtable":
                            LandTable tbl = LandTable.LoadFromFile(item.Key);
                            labels.AddRange(tbl.GetLabels());
                            break;

                        case "model":
                        case "basicmodel":
                        case "chunkmodel":
                        case "basicdxmodel":
                            NJS_OBJECT mdl = new ModelFile(item.Key).Model;
                            labels.AddRange(mdl.GetLabels());
                            break;

                        case "animation":
                            Animation ani = Animation.Load(item.Key);
                            labels.Add(ani.Name);
                            break;
                        }
                        output.Files.Add(item.Key, new FileTypeHash(item.Value.Type, null));
                    }
                    output.Items = new List <DllItemInfo>(IniData.Items.Where(a => labels.Contains(a.Label)));
                    IniSerializer.Serialize(output, fd.FileName);
                }
        }
示例#2
0
 private void LoadINI(string filename)
 {
     IniData = IniSerializer.Deserialize <DllIniData>(filename);
     if (Settings.MRUList.Contains(filename))
     {
         recentProjectsToolStripMenuItem.DropDownItems.RemoveAt(Settings.MRUList.IndexOf(filename));
         Settings.MRUList.Remove(filename);
     }
     Settings.MRUList.Insert(0, filename);
     recentProjectsToolStripMenuItem.DropDownItems.Insert(0, new ToolStripMenuItem(filename));
     Environment.CurrentDirectory = Path.GetDirectoryName(filename);
     listView1.BeginUpdate();
     listView1.Items.Clear();
     foreach (KeyValuePair <string, FileTypeHash> item in IniData.Files)
     {
         bool modified = HelperFunctions.FileHash(item.Key) != item.Value.Hash;
         listView1.Items.Add(new ListViewItem(new[] { item.Key, modified ? "Yes" : "No" })
         {
             Checked = modified
         });
     }
     listView1.EndUpdate();
 }