/// <summary> /// Disposes of the view model data /// </summary> public void Dispose() { if (CompositeVM != null) { CompositeVM.Dispose(); } }
/// <summary> /// Sets the data for the mesh combo box /// </summary> private void PartComboBoxChanged() { is3DLoaded = false; if (CompositeVM != null && !disposing) { disposing = true; CompositeVM.Dispose(); } try { List <ComboBoxInfo> cbi = new List <ComboBoxInfo>(); MDL mdl = new MDL(selectedItem, selectedCategory, Info.raceID[SelectedRace.Name], SelectedBody.ID, SelectedPart.ID); meshList = mdl.GetMeshList(); modelName = mdl.GetModelName(); materialStrings = mdl.GetMaterialStrings(); cbi.Add(new ComboBoxInfo() { Name = Strings.All, ID = Strings.All, IsNum = false }); if (meshList.Count > 1) { for (int i = 0; i < meshList.Count; i++) { cbi.Add(new ComboBoxInfo() { Name = i.ToString(), ID = i.ToString(), IsNum = true }); } } MeshComboBox = new ObservableCollection <ComboBoxInfo>(cbi); MeshIndex = 0; if (cbi.Count > 1) { MeshEnabled = true; } else { MeshEnabled = false; } } catch (Exception ex) { MessageBox.Show("[Main] part 3D Error \n" + ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); } }
/// <summary> /// Sets the data for the part combo box /// </summary> private void BodyComboBoxChanged() { is3DLoaded = false; bool isDemiHuman = false; if (CompositeVM != null && !disposing) { disposing = true; CompositeVM.Dispose(); } if (selectedItem.PrimaryMTRLFolder != null && selectedItem.PrimaryMTRLFolder.Contains("demihuman")) { isDemiHuman = true; } List <ComboBoxInfo> cbi = new List <ComboBoxInfo>(); string type = Helper.GetCategoryType(selectedCategory); string MDLFolder = ""; string MDLFile = ""; string[] abrParts = null; if (type.Equals("character")) { if (selectedItem.ItemName.Equals(Strings.Body)) { MDLFolder = string.Format(Strings.BodyMDLFolder, SelectedRace.ID, SelectedBody.ID.PadLeft(4, '0')); MDLFile = string.Format(Strings.BodyMDLFile, SelectedRace.ID, SelectedBody.ID.PadLeft(4, '0'), "{0}"); abrParts = new string[5] { "met", "glv", "dwn", "sho", "top" }; } else if (selectedItem.ItemName.Equals(Strings.Face)) { MDLFolder = string.Format(Strings.FaceMDLFolder, SelectedRace.ID, SelectedBody.ID.PadLeft(4, '0')); MDLFile = string.Format(Strings.FaceMDLFile, SelectedRace.ID, SelectedBody.ID.PadLeft(4, '0'), "{0}"); abrParts = new string[3] { "fac", "iri", "etc" }; } else if (selectedItem.ItemName.Equals(Strings.Hair)) { MDLFolder = string.Format(Strings.HairMDLFolder, SelectedRace.ID, SelectedBody.ID.PadLeft(4, '0')); MDLFile = string.Format(Strings.HairMDLFile, SelectedRace.ID, SelectedBody.ID.PadLeft(4, '0'), "{0}"); abrParts = new string[2] { "hir", "acc" }; } else if (selectedItem.ItemName.Equals(Strings.Tail)) { MDLFolder = string.Format(Strings.TailMDLFolder, SelectedRace.ID, SelectedBody.ID.PadLeft(4, '0')); MDLFile = string.Format(Strings.TailMDLFile, SelectedRace.ID, SelectedBody.ID.PadLeft(4, '0'), "{0}"); abrParts = new string[1] { "til" }; } var fileHashList = Helper.GetAllFilesInFolder(FFCRC.GetHash(MDLFolder)); foreach (string abrPart in abrParts) { var file = String.Format(MDLFile, abrPart); if (fileHashList.Contains(FFCRC.GetHash(file))) { if (selectedItem.ItemName.Equals(Strings.Body)) { cbi.Add(new ComboBoxInfo() { Name = Info.slotAbr.FirstOrDefault(x => x.Value == abrPart).Key, ID = abrPart, IsNum = false }); } else if (selectedItem.ItemName.Equals(Strings.Face)) { cbi.Add(new ComboBoxInfo() { Name = Info.FaceTypes.FirstOrDefault(x => x.Value == abrPart).Key, ID = abrPart, IsNum = false }); } else if (selectedItem.ItemName.Equals(Strings.Hair)) { cbi.Add(new ComboBoxInfo() { Name = Info.HairTypes.FirstOrDefault(x => x.Value == abrPart).Key, ID = abrPart, IsNum = false }); } else if (selectedItem.ItemName.Equals(Strings.Tail)) { cbi.Add(new ComboBoxInfo() { Name = Strings.Tail, ID = abrPart, IsNum = false }); } } } } else if (isDemiHuman) { MDLFolder = string.Format(Strings.DemiMDLFolder, selectedItem.PrimaryModelID, selectedItem.PrimaryModelBody); MDLFile = string.Format(Strings.DemiMDLFile, selectedItem.PrimaryModelID, selectedItem.PrimaryModelBody, "{0}"); abrParts = new string[5] { "met", "glv", "dwn", "sho", "top" }; var fileHashList = Helper.GetAllFilesInFolder(FFCRC.GetHash(MDLFolder)); foreach (string abrPart in abrParts) { var file = String.Format(MDLFile, abrPart); if (fileHashList.Contains(FFCRC.GetHash(file))) { cbi.Add(new ComboBoxInfo() { Name = Info.slotAbr.FirstOrDefault(x => x.Value == abrPart).Key, ID = abrPart, IsNum = false }); } } } else if (type.Equals("weapon")) { if (selectedItem.SecondaryModelID != null) { cbi.Add(new ComboBoxInfo() { Name = "Primary", ID = "Primary", IsNum = false }); cbi.Add(new ComboBoxInfo() { Name = "Secondary", ID = "Secondary", IsNum = false }); } else { cbi.Add(new ComboBoxInfo() { Name = "Primary", ID = "Primary", IsNum = false }); } } else if (type.Equals("monster")) { cbi.Add(new ComboBoxInfo() { Name = "1", ID = "1", IsNum = false }); } else { cbi.Add(new ComboBoxInfo() { Name = "-", ID = "-", IsNum = false }); } PartComboBox = new ObservableCollection <ComboBoxInfo>(cbi); PartIndex = 0; if (cbi.Count <= 1) { PartEnabled = false; } else { PartEnabled = true; } }
/// <summary> /// Sets the data for the body combo box /// </summary> private void RaceComboBoxChanged() { is3DLoaded = false; if (CompositeVM != null && !disposing) { disposing = true; CompositeVM.Dispose(); } List <ComboBoxInfo> cbi = new List <ComboBoxInfo>(); string categoryType = Helper.GetCategoryType(selectedCategory); string MDLFolder = ""; if (categoryType.Equals("weapon")) { cbi.Add(new ComboBoxInfo() { Name = selectedItem.PrimaryModelBody, ID = selectedItem.PrimaryModelBody, IsNum = false }); } else if (categoryType.Equals("food")) { cbi.Add(new ComboBoxInfo() { Name = selectedItem.PrimaryModelBody, ID = selectedItem.PrimaryModelBody, IsNum = false }); } else if (categoryType.Equals("accessory")) { cbi.Add(new ComboBoxInfo() { Name = "-", ID = "-", IsNum = false }); } else if (categoryType.Equals("character")) { if (selectedItem.ItemName.Equals(Strings.Body)) { MDLFolder = string.Format(Strings.BodyMDLFolder, SelectedRace.ID, "{0}"); } else if (selectedItem.ItemName.Equals(Strings.Face)) { MDLFolder = string.Format(Strings.FaceMDLFolder, SelectedRace.ID, "{0}"); } else if (selectedItem.ItemName.Equals(Strings.Hair)) { MDLFolder = string.Format(Strings.HairMDLFolder, SelectedRace.ID, "{0}"); } else if (selectedItem.ItemName.Equals(Strings.Tail)) { MDLFolder = string.Format(Strings.TailMDLFolder, SelectedRace.ID, "{0}"); } } else if (categoryType.Equals("monster")) { cbi.Add(new ComboBoxInfo() { Name = selectedItem.PrimaryModelBody, ID = selectedItem.PrimaryModelBody, IsNum = false }); } else { cbi.Add(new ComboBoxInfo() { Name = "-", ID = "-", IsNum = false }); } if (categoryType.Equals("character")) { for (int i = 0; i < 50; i++) { string folder = String.Format(MDLFolder, i.ToString().PadLeft(4, '0')); if (Helper.FolderExists(FFCRC.GetHash(folder))) { cbi.Add(new ComboBoxInfo() { Name = i.ToString(), ID = i.ToString(), IsNum = true }); if (selectedItem.ItemName.Equals(Strings.Body)) { break; } } } } BodyComboBox = new ObservableCollection <ComboBoxInfo>(cbi); BodyIndex = 0; if (cbi.Count <= 1) { BodyEnabled = false; } else { BodyEnabled = true; } }