private void LoadIniFiles() { assemblyIniFiles.Clear(); assemblyItemsToExport.Clear(); foreach (KeyValuePair <string, AssemblyType> assembly in assemblies) { string iniPath = Path.Combine(projectFolder, assembly.Key + "_data.ini"); Dictionary <string, bool> itemsToExport = new Dictionary <string, bool>(); switch (assembly.Value) { case AssemblyType.Exe: SA_Tools.IniData iniData = StructConverter.StructConverter.LoadINI(iniPath, ref itemsToExport); assemblyItemsToExport.Add(assembly.Key, itemsToExport); assemblyIniFiles.Add(assembly.Key, iniData); break; case AssemblyType.DLL: DLLModGenerator.DllIniData dllIniData = DLLModGenerator.DLLModGen.LoadINI(iniPath, ref itemsToExport); assemblyItemsToExport.Add(assembly.Key, itemsToExport); assemblyIniFiles.Add(assembly.Key, dllIniData); break; default: break; } } }
private void FillListViewIniData(ListView listView, AssemblyType assemblyType, string assemblyname, SA_Tools.IniData iniData, Dictionary <string, bool> itemsToExport) { listView.BeginUpdate(); listView.Items.Clear(); foreach (KeyValuePair <string, SA_Tools.FileInfo> item in iniData.Files) { KeyValuePair <string, bool> exportStatus = itemsToExport.First(export => export.Key == item.Key); bool modified = exportStatus.Value; listView.Items.Add(new ListViewItem ( new[] { item.Key, StructConverter.StructConverter.DataTypeList[item.Value.Type], (modified ? "Yes" : "No") }) { Checked = modified }); } listView.EndUpdate(); }
private List <string> FindRelevantINIFiles(string file, string inilocation) { bool dllmode = false; string extension = Path.GetExtension(file).ToLowerInvariant(); List <string> relevantini = new List <string>(); if (extension == ".dll") { dllmode = true; } else if (extension == ".nb") { return(relevantini); } if (findAll) { Console.WriteLine("Finding relevant split INI files for {0} in {1}", Path.GetFileName(file), inilocation); string[] inifiles = System.IO.Directory.GetFiles(inilocation, "*.ini", SearchOption.AllDirectories); for (int u = 0; u < inifiles.Length; u++) { if (inifiles[u].ToLowerInvariant().Contains("_data") || inifiles[u].ToLowerInvariant().Contains("output")) { continue; } if (dllmode) { SA_Tools.SplitDLL.IniData inifile = IniSerializer.Deserialize <SA_Tools.SplitDLL.IniData>(inifiles[u]); if (inifile.ModuleName != null && inifile.ModuleName.ToLowerInvariant() == Path.GetFileNameWithoutExtension(file).ToLowerInvariant()) { relevantini.Add(Path.GetFullPath(inifiles[u])); Console.WriteLine("Found split file {0}", inifiles[u]); } } else { SA_Tools.IniData inifile = IniSerializer.Deserialize <SA_Tools.IniData>(inifiles[u]); if (inifile.DataFilename != null && inifile.DataFilename.ToLowerInvariant() == Path.GetFileName(file).ToLowerInvariant()) { relevantini.Add(Path.GetFullPath(inifiles[u])); Console.WriteLine("Found split file {0}", inifiles[u]); } else if (inifile.DataFilename != null) { Console.WriteLine("Datafilename: {0}", inifile.DataFilename); } else { Console.WriteLine("Datafilename in {0} is null", inifiles[u]); } } } } return(relevantini); }
// Scans a folder for .sa1lvl, .sa1mdl and .saanim files and creates a sorted split INI file based on their labels and filenames static void SplitLD(string[] args) { string dirpath = args[0]; string[] modelfiles = System.IO.Directory.GetFiles(dirpath, "*.sa1mdl", SearchOption.AllDirectories); string[] levelfiles = System.IO.Directory.GetFiles(dirpath, "*.sa1lvl", SearchOption.AllDirectories); string[] animfiles = System.IO.Directory.GetFiles(dirpath, "*.saanim", SearchOption.AllDirectories); Dictionary <string, SA_Tools.FileInfo> files_ini = new Dictionary <string, SA_Tools.FileInfo>(); for (int u = 0; u < modelfiles.Length; u++) { ModelFile mdl = new ModelFile(modelfiles[u]); SA_Tools.FileInfo fileinfo = new SA_Tools.FileInfo(); fileinfo.Type = "model"; fileinfo.Filename = modelfiles[u]; string mdlname = mdl.Model.Name; fileinfo.Address = int.Parse(mdlname.Substring(mdlname.Length - 8, 8), System.Globalization.NumberStyles.AllowHexSpecifier); //Console.WriteLine("{0}={1}", fileinfo.Address.ToString("X8"), modelfiles[u]); if (!files_ini.ContainsKey(mdlname)) { files_ini.Add(mdlname, fileinfo); } else { Console.WriteLine("Duplicate of {0}", mdlname); } } for (int u = 0; u < levelfiles.Length; u++) { LandTable lvl = LandTable.LoadFromFile(levelfiles[u]); SA_Tools.FileInfo fileinfo = new SA_Tools.FileInfo(); fileinfo.Type = "landtable"; fileinfo.Filename = levelfiles[u]; string lvlname = lvl.Name; fileinfo.Address = int.Parse(lvlname.Substring(lvlname.Length - 8, 8), System.Globalization.NumberStyles.AllowHexSpecifier); //Console.WriteLine("{0}={1}", fileinfo.Address.ToString("X8"), levelfiles[u]); if (!files_ini.ContainsKey(lvlname)) { files_ini.Add(lvlname, fileinfo); } else { Console.WriteLine("Duplicate of {0}", lvlname); } } for (int u = 0; u < animfiles.Length; u++) { NJS_MOTION mtn = NJS_MOTION.Load(animfiles[u]); SA_Tools.FileInfo fileinfo = new SA_Tools.FileInfo(); fileinfo.Type = "animation"; fileinfo.Filename = animfiles[u]; string mtnname = mtn.Name; fileinfo.Address = int.Parse(mtnname.Substring(mtnname.Length - 8, 8), System.Globalization.NumberStyles.AllowHexSpecifier); //Console.WriteLine("{0}={1}", fileinfo.Address.ToString("X8"), animfiles[u]); if (!files_ini.ContainsKey(mtnname)) { files_ini.Add(mtnname, fileinfo); } else { Console.WriteLine("Duplicate of {0}", mtnname); } } IniData inidata_new = new SA_Tools.IniData(); inidata_new.Files = SortIniData(files_ini); IniSerializer.Serialize(inidata_new, dirpath + "_sorted.ini"); }