public ModelLoadInfo(string modelFilePath, SAMDLMetadata meta, string modFolder) { ModelFilePath = modelFilePath; ModelName = meta.ModelName; TextureArchives = meta.TextureArchives; TextureIDs = meta.TextureIDs; TexturePalettePath = meta.TexturePalette; if (meta.TextureNameFile != null && meta.TextureNameFile != "") { string texnamefile = Path.Combine(modFolder, meta.TextureNameFile); TextureNames = NJS_TEXLIST.Load(texnamefile); } }
private void comboCategories_SelectedIndexChanged(object sender, EventArgs e) { if (comboCategories.SelectedItem == null) { return; } if (comboCategories.GetItemText(comboCategories.SelectedItem) == SelectedCategory) { return; } Models.Clear(); listModels.Items.Clear(); SelectedCategory = comboCategories.GetItemText(comboCategories.SelectedItem); foreach (SplitEntry entry in Categories[SelectedCategory]) { string inipath = Path.Combine(modFolder, entry.IniFile + "_data.ini"); // Get models from inidata by type switch (Path.GetExtension(entry.SourceFile).ToLowerInvariant()) { case ".dll": IniDictionary iniFile = SplitTools.IniFile.Load(inipath); foreach (var dllItem in iniFile["SAMDLData"]) { SAMDLMetadata meta = new SAMDLMetadata(dllItem.Value); Models.Add(new ModelLoadInfo(dllItem.Key, meta, modFolder)); } break; case ".nb": Dictionary <int, string> nbFilenames = IniSerializer.Deserialize <Dictionary <int, string> >(inipath); foreach (var nbitem in nbFilenames) { string entryFilename = nbitem.Value; string entryDescription = ""; string entryTexture = ""; if (nbitem.Value.Contains("|")) { string[] nbMeta = nbitem.Value.Split('|'); entryFilename = nbMeta[0]; if (nbMeta.Length > 1) { entryDescription = nbMeta[1]; } if (nbMeta.Length > 2) { entryTexture = nbMeta[2]; } } else { entryDescription = Path.GetFileNameWithoutExtension(nbitem.Value); } switch (Path.GetExtension(entryFilename).ToLowerInvariant()) { case ".sa1mdl": case ".sa2mdl": case ".sa2bmdl": string[] textures = new string[1]; textures[0] = entryTexture; Models.Add(new ModelLoadInfo(entryDescription, entryFilename, textures, null, null, null)); break; default: break; } } break; default: IniData inidata = IniSerializer.Deserialize <IniData>(inipath); foreach (var item in inidata.Files) { switch (item.Value.Type) { case "model": case "basicmodel": case "basicdxmodel": case "chunkmodel": case "gcmodel": Models.Add(new ModelLoadInfo(item.Key, item.Value, modFolder)); break; default: break; } } break; } } // Fill in models foreach (var item in Models) { listModels.Items.Add(item.ModelName); } }