示例#1
0
 private List<string> ExportCPP(TextWriter writer, bool SA2)
 {
     ModelFormat modelfmt = SA2 ? ModelFormat.Chunk : ModelFormat.BasicDX;
     LandTableFormat landfmt = SA2 ? LandTableFormat.SA2 : LandTableFormat.SADX;
     writer.WriteLine("// Generated by SA Tools DLL Mod Generator");
     writer.WriteLine();
     if (SA2)
         writer.WriteLine("#include \"SA2ModLoader.h\"");
     else
         writer.WriteLine("#include \"SADXModLoader.h\"");
     writer.WriteLine();
     List<string> labels = new List<string>();
     foreach (KeyValuePair<string, FileTypeHash> item in IniData.Files.Where((a, i) => listView1.CheckedIndices.Contains(i)))
         switch (item.Value.Type)
         {
             case "landtable":
                 LandTable tbl = LandTable.LoadFromFile(item.Key);
                 writer.WriteLine(tbl.ToStructVariables(landfmt, new List<string>()));
                 labels.AddRange(tbl.GetLabels());
                 break;
             case "model":
                 SonicRetro.SAModel.NJS_OBJECT mdl = new ModelFile(item.Key).Model;
                 writer.WriteLine(mdl.ToStructVariables(modelfmt == ModelFormat.BasicDX, new List<string>()));
                 labels.AddRange(mdl.GetLabels());
                 break;
             case "basicmodel":
             case "chunkmodel":
                 mdl = new ModelFile(item.Key).Model;
                 writer.WriteLine(mdl.ToStructVariables(false, new List<string>()));
                 labels.AddRange(mdl.GetLabels());
                 break;
             case "basicdxmodel":
                 mdl = new ModelFile(item.Key).Model;
                 writer.WriteLine(mdl.ToStructVariables(true, new List<string>()));
                 labels.AddRange(mdl.GetLabels());
                 break;
             case "animation":
                 Animation ani = Animation.Load(item.Key);
                 writer.WriteLine(ani.ToStructVariables());
                 labels.Add(ani.Name);
                 break;
         }
     return labels;
 }
示例#2
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();
             output.Name = IniData.Name;
             output.Game = IniData.Game;
             output.Exports = IniData.Exports;
             output.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":
                         SonicRetro.SAModel.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);
         }
 }