/// <summary> /// Updates the displayed image /// </summary> /// <remarks> /// This is called when an image has either been imported or enabled/disabled /// </remarks> /// <param name="offset">The new offset for the image.</param> /// <param name="isColor">Is the image being udpated a color set.</param> public void UpdateImage(int offset, bool isColor) { if (isColor) { var colorBMP = MTRL.GetColorBitmap(offset); TextureType = "A16B16G16R16F"; TextureDimensions = "(4 x 16)"; alphaBitmap = Imaging.CreateBitmapSourceFromHBitmap(colorBMP.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()); var removeAlphaBitmap = SetAlpha(colorBMP, 255); noAlphaBitmap = Imaging.CreateBitmapSourceFromHBitmap(removeAlphaBitmap.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()); colorBMP.Dispose(); removeAlphaBitmap.Dispose(); } else { if (SelectedMap.ID.Contains("vfx")) { texData = TEX.GetVFX(offset); } else { texData = TEX.GetTex(offset); } TextureType = texData.TypeString; TextureDimensions = "(" + texData.Width + " x " + texData.Height + ")"; alphaBitmap = Imaging.CreateBitmapSourceFromHBitmap(texData.BMP.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()); var removeAlphaBitmap = SetAlpha(texData.BMP, 255); noAlphaBitmap = Imaging.CreateBitmapSourceFromHBitmap(removeAlphaBitmap.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()); texData.Dispose(); removeAlphaBitmap.Dispose(); } if (AlphaChecked) { ImageSource = alphaBitmap; } else { ImageSource = noAlphaBitmap; } }
public ModListModel ParseEntry(JsonEntry entry) { ModListModel mlm = new ModListModel(); string race, map, part, type; if (entry.fullPath.Contains("weapon") || entry.fullPath.Contains("accessory") || entry.fullPath.Contains("decal") || entry.fullPath.Contains("vfx") || entry.fullPath.Contains("ui/")) { race = Strings.All; } else if (entry.fullPath.Contains("monster") || entry.fullPath.Contains("demihuman")) { race = Strings.Monster; } else { race = entry.fullPath.Substring(entry.fullPath.LastIndexOf('/')); if ((entry.fullPath.Contains("_fac_") || entry.fullPath.Contains("_etc_") || entry.fullPath.Contains("_acc_")) && Properties.Settings.Default.DX_Ver.Equals(Strings.DX11)) { race = race.Substring(race.LastIndexOf("--c") + 3, 4); } else if (entry.fullPath.Contains("_fac_") || entry.fullPath.Contains("_etc_") || entry.fullPath.Contains("_acc_")) { race = race.Substring(race.LastIndexOf("/c") + 2, 4); } else if (entry.fullPath.Contains("_c_")) { race = race.Substring(race.IndexOf("_c") + 2, 4); } else { race = race.Substring(race.LastIndexOf('c') + 1, 4); } race = Info.IDRace[race]; } mlm.Race = race; if (entry.fullPath.Contains("_d.")) { map = Strings.Diffuse; } else if (entry.fullPath.Contains("_n.")) { map = Strings.Normal; } else if (entry.fullPath.Contains("_s.")) { map = Strings.Specular; } else if (entry.fullPath.Contains("material")) { map = Strings.ColorSet; } else if (entry.fullPath.Contains("model")) { map = "3D"; } else if (entry.fullPath.Contains("ui/")) { map = "UI"; } else { map = Strings.Mask; } mlm.Map = map; if (entry.fullPath.Contains("_b_")) { part = "b"; } else if (entry.fullPath.Contains("_c_")) { part = "c"; } else if (entry.fullPath.Contains("_d_")) { part = "d"; } else if (entry.fullPath.Contains("decal")) { part = entry.fullPath.Substring(entry.fullPath.LastIndexOf('_') + 1, entry.fullPath.LastIndexOf('.') - (entry.fullPath.LastIndexOf('_') + 1)); } else { part = "a"; } mlm.Part = part; if (entry.fullPath.Contains("_iri_")) { type = "Iris"; } else if (entry.fullPath.Contains("_etc_")) { type = "Etc."; } else if (entry.fullPath.Contains("_fac_")) { type = "Face"; } else if (entry.fullPath.Contains("_hir_")) { type = "Hair"; } else if (entry.fullPath.Contains("_acc_")) { type = "Accessory"; } else if (entry.fullPath.Contains("demihuman")) { type = entry.fullPath.Substring(entry.fullPath.LastIndexOf('_') - 3, 3); type = (Info.slotAbr).FirstOrDefault(x => x.Value == type).Key; } else { type = "-"; } mlm.Type = type; if (entry.fullPath.Contains("material")) { var info = MTRL.GetMTRLInfo(entry.modOffset, false); var bitmap = TEX.TextureToBitmap(info.ColorData, 9312, 4, 16); mlm.BMP = Imaging.CreateBitmapSourceFromHBitmap(bitmap.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()); } else if (entry.fullPath.Contains("model")) { mlm.BMP = new BitmapImage(new Uri("pack://application:,,,/FFXIV TexTools 2;component/Resources/3DModel.png")); } else { TEXData texData; if (entry.fullPath.Contains("vfx")) { texData = TEX.GetVFX(entry.modOffset, entry.datFile); } else { if (entry.fullPath.Contains("icon")) { texData = TEX.GetTex(entry.modOffset, entry.datFile); } else { texData = TEX.GetTex(entry.modOffset, entry.datFile); } } mlm.BMP = Imaging.CreateBitmapSourceFromHBitmap(texData.BMP.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()); } var offset = Helper.GetDataOffset(FFCRC.GetHash(entry.fullPath.Substring(0, entry.fullPath.LastIndexOf("/"))), FFCRC.GetHash(Path.GetFileName(entry.fullPath)), entry.datFile); if (offset == entry.modOffset) { mlm.ActiveBorder = Brushes.Green; mlm.Active = Brushes.Transparent; mlm.ActiveOpacity = 1; } else if (offset == entry.originalOffset) { mlm.ActiveBorder = Brushes.Red; mlm.Active = Brushes.Gray; mlm.ActiveOpacity = 0.5f; } else { mlm.ActiveBorder = Brushes.Red; mlm.Active = Brushes.Red; mlm.ActiveOpacity = 1; } mlm.Entry = entry; return(mlm); }
/// <summary> /// Gets the texture data and displays it for the currently selected item given a specified race, part, type(if applicable), and map /// </summary> private void MapComboBoxChanged() { if (saveClone != null) { //saveClone.UnlockBits(cloneLock); saveClone.Dispose(); } Bitmap colorBmp = null; int offset = 0; bool isVFX = false; bool isUI = false; if (selectedMap.Name.Equals(Strings.Normal)) { fullPath = mtrlData.NormalPath; offset = mtrlData.NormalOffset; FullPathString = fullPath; } else if (selectedMap.Name.Equals(Strings.Specular)) { fullPath = mtrlData.SpecularPath; offset = mtrlData.SpecularOffset; FullPathString = fullPath; } else if (selectedMap.Name.Equals(Strings.Diffuse)) { fullPath = mtrlData.DiffusePath; offset = mtrlData.DiffuseOffset; FullPathString = fullPath; } else if (selectedMap.Name.Equals(Strings.Mask) || selectedMap.Name.Equals(Strings.Skin)) { if (selectedItem.ItemName.Equals(Strings.Face_Paint) || selectedItem.ItemName.Equals(Strings.Equipment_Decals)) { string part; if (selectedItem.ItemName.Equals(Strings.Equipment_Decals)) { if (!SelectedPart.Name.Contains("stigma")) { part = selectedPart.Name.PadLeft(3, '0'); } else { part = SelectedPart.Name; } } else { part = selectedPart.Name; } fullPath = String.Format(mtrlData.MaskPath, part); offset = MTRL.GetDecalOffset(selectedItem.ItemName, selectedPart.Name); } else { fullPath = mtrlData.MaskPath; offset = mtrlData.MaskOffset; } FullPathString = fullPath; } else if (selectedMap.Name.Equals(Strings.ColorSet)) { colorBmp = TEX.TextureToBitmap(mtrlData.ColorData, 9312, 4, 16); fullPath = mtrlData.MTRLPath; FullPathString = fullPath; } else if (SelectedMap.Name.Contains("Icon")) { if (SelectedMap.Name.Contains("HQ")) { fullPath = mtrlData.UIHQPath; offset = mtrlData.UIHQOffset; } else { fullPath = mtrlData.UIPath; offset = mtrlData.UIOffset; } FullPathString = fullPath; isUI = true; } else if (selectedItem.ItemCategory.Equals(Strings.Maps)) { if (selectedMap.Name.Contains("HighRes Map")) { fullPath = string.Format(mtrlData.UIPath, "_m"); offset = mtrlData.UIOffset = int.Parse(selectedMap.ID); } else if (selectedMap.Name.Contains("LowRes Map")) { fullPath = string.Format(mtrlData.UIPath, "_s"); offset = mtrlData.UIOffset = int.Parse(selectedMap.ID); } else if (selectedMap.Name.Contains("PoI")) { fullPath = string.Format(mtrlData.UIPath, "d"); offset = mtrlData.UIOffset = int.Parse(selectedMap.ID); } else if (selectedMap.Name.Contains("HighRes Mask")) { fullPath = string.Format(mtrlData.UIPath, "m_m"); offset = mtrlData.UIOffset = int.Parse(selectedMap.ID); } else if (selectedMap.Name.Contains("LowRes Mask")) { fullPath = string.Format(mtrlData.UIPath, "m_s"); offset = mtrlData.UIOffset = int.Parse(selectedMap.ID); } FullPathString = fullPath; isUI = true; } else if (selectedItem.ItemCategory.Equals("HUD") || selectedItem.ItemCategory.Equals("LoadingImage")) { fullPath = mtrlData.UIPath; offset = mtrlData.UIOffset; FullPathString = fullPath; isUI = true; } else { fullPath = SelectedMap.ID; var VFXFolder = fullPath.Substring(0, fullPath.LastIndexOf("/")); var VFXFile = fullPath.Substring(fullPath.LastIndexOf("/") + 1); offset = Helper.GetDataOffset(FFCRC.GetHash(VFXFolder), FFCRC.GetHash(VFXFile), Strings.ItemsDat); FullPathString = fullPath; isVFX = true; } string line; JsonEntry modEntry = null; bool inModList = false; try { using (StreamReader sr = new StreamReader(Properties.Settings.Default.Modlist_Directory)) { while ((line = sr.ReadLine()) != null) { modEntry = JsonConvert.DeserializeObject <JsonEntry>(line); if (modEntry.fullPath.Equals(fullPath)) { inModList = true; break; } } } } catch (Exception ex) { MessageBox.Show("[TVM] Error Accessing .modlist File \n" + ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); } if (inModList) { var currOffset = Helper.GetDataOffset(FFCRC.GetHash(modEntry.fullPath.Substring(0, modEntry.fullPath.LastIndexOf("/"))), FFCRC.GetHash(Path.GetFileName(modEntry.fullPath)), modEntry.datFile); if (currOffset == modEntry.modOffset) { ActiveToggle = "Disable"; } else if (currOffset == modEntry.originalOffset) { ActiveToggle = "Enable"; } else { ActiveToggle = "Error"; } ActiveEnabled = true; } else { ActiveEnabled = false; ActiveToggle = "Enable/Disable"; } if (offset == 0) { TextureType = "Type: 16.16.16.16f ABGR\nMipMaps: None"; TextureDimensions = "(4 x 16)"; alphaBitmap = Imaging.CreateBitmapSourceFromHBitmap(colorBmp.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()); alphaBitmap.Freeze(); var removeAlphaBitmap = SetAlpha(colorBmp, 255); noAlphaBitmap = Imaging.CreateBitmapSourceFromHBitmap(removeAlphaBitmap.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()); noAlphaBitmap.Freeze(); colorBmp.Dispose(); removeAlphaBitmap.Dispose(); } else { if (!isVFX) { if (!isUI) { texData = TEX.GetTex(offset, Strings.ItemsDat); } else { texData = TEX.GetTex(offset, Strings.UIDat); } } else { texData = TEX.GetVFX(offset, Strings.ItemsDat); } string mipMaps = "Yes (" + texData.MipCount + ")"; if (texData.MipCount < 1) { mipMaps = "None"; } TextureType = "Type: " + texData.TypeString + "\nMipMaps: " + mipMaps; TextureDimensions = "(" + texData.Width + " x " + texData.Height + ")"; var clonerect = new Rectangle(0, 0, texData.Width, texData.Height); saveClone = texData.BMP.Clone(new Rectangle(0, 0, texData.Width, texData.Height), PixelFormat.Format32bppArgb); alphaBitmap = Imaging.CreateBitmapSourceFromHBitmap(texData.BMP.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()); alphaBitmap.Freeze(); if (!isUI) { var removeAlphaBitmap = SetAlpha(texData.BMP, 255); noAlphaBitmap = Imaging.CreateBitmapSourceFromHBitmap(removeAlphaBitmap.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()); noAlphaBitmap.Freeze(); removeAlphaBitmap.Dispose(); } } try { ImageEffect = new ColorChannels() { Channel = new System.Windows.Media.Media3D.Point4D(1.0f, 1.0f, 1.0f, 0.0f) }; } catch (Exception ex) { Debug.WriteLine(ex.StackTrace); } if (!isUI) { ImageSource = noAlphaBitmap; SetColorChannelFilter(imageEffect); ChannelsEnabled = true; } else { ImageSource = alphaBitmap; SetColorChannelFilter(imageEffect); ChannelsEnabled = true; } SaveEnabled = true; texData.Dispose(); string dxPath = Path.GetFileNameWithoutExtension(fullPath); string savePath = Properties.Settings.Default.Save_Directory + "/" + selectedCategory + "/" + selectedItem.ItemName + "/" + dxPath + ".dds"; if (selectedCategory.Equals("UI")) { savePath = Properties.Settings.Default.Save_Directory + "/" + selectedCategory + "/" + selectedItem.ItemCategory + "/" + dxPath + ".dds"; } if (File.Exists(savePath)) { ImportEnabled = true; } else { ImportEnabled = false; } string folderPath = Properties.Settings.Default.Save_Directory + "/" + selectedCategory + "/" + selectedItem.ItemName; if (selectedCategory.Equals("UI")) { folderPath = Properties.Settings.Default.Save_Directory + "/" + selectedCategory + "/" + selectedItem.ItemCategory; } if (Directory.Exists(folderPath)) { OpenEnabled = true; } else { OpenEnabled = false; } }
public void SaveAllDDS() { foreach (var m in MapComboBox) { int offset = 0; if (m.Name.Equals(Strings.Normal)) { fullPath = mtrlData.NormalPath; offset = mtrlData.NormalOffset; } else if (m.Name.Equals(Strings.Specular)) { fullPath = mtrlData.SpecularPath; offset = mtrlData.SpecularOffset; } else if (m.Name.Equals(Strings.Diffuse)) { fullPath = mtrlData.DiffusePath; offset = mtrlData.DiffuseOffset; } else if (m.Name.Equals(Strings.Mask) || m.Name.Equals(Strings.Skin)) { if (selectedItem.ItemName.Equals(Strings.Face_Paint) || selectedItem.ItemName.Equals(Strings.Equipment_Decals)) { string part; if (selectedItem.ItemName.Equals(Strings.Equipment_Decals)) { if (!SelectedPart.Name.Contains("stigma")) { part = selectedPart.Name.PadLeft(3, '0'); } else { part = SelectedPart.Name; } } else { part = selectedPart.Name; } fullPath = String.Format(mtrlData.MaskPath, part); offset = MTRL.GetDecalOffset(selectedItem.ItemName, selectedPart.Name); } else { fullPath = mtrlData.MaskPath; offset = mtrlData.MaskOffset; } } else if (m.Name.Equals(Strings.ColorSet)) { fullPath = mtrlData.MTRLPath; } else if (m.Name.Contains("Icon")) { if (m.Name.Contains("HQ")) { fullPath = mtrlData.UIHQPath; offset = mtrlData.UIHQOffset; } else { fullPath = mtrlData.UIPath; offset = mtrlData.UIOffset; } } else if (selectedItem.ItemCategory.Equals(Strings.Maps)) { if (selectedMap.Name.Contains("HighRes Map")) { fullPath = string.Format(mtrlData.UIPath, "_m"); offset = mtrlData.UIOffset = int.Parse(selectedMap.ID); } else if (selectedMap.Name.Contains("LowRes Map")) { fullPath = string.Format(mtrlData.UIPath, "_s"); offset = mtrlData.UIOffset = int.Parse(selectedMap.ID); } else if (selectedMap.Name.Contains("PoI")) { fullPath = string.Format(mtrlData.UIPath, "d"); offset = mtrlData.UIOffset = int.Parse(selectedMap.ID); } else if (selectedMap.Name.Contains("HighRes Mask")) { fullPath = string.Format(mtrlData.UIPath, "m_m"); offset = mtrlData.UIOffset = int.Parse(selectedMap.ID); } else if (selectedMap.Name.Contains("LowRes Mask")) { fullPath = string.Format(mtrlData.UIPath, "m_s"); offset = mtrlData.UIOffset = int.Parse(selectedMap.ID); } } else if (selectedItem.ItemCategory.Equals("HUD")) { fullPath = mtrlData.UIPath; offset = mtrlData.UIOffset; } else { fullPath = SelectedMap.ID; var VFXFolder = fullPath.Substring(0, fullPath.LastIndexOf("/")); var VFXFile = fullPath.Substring(fullPath.LastIndexOf("/") + 1); offset = Helper.GetDataOffset(FFCRC.GetHash(VFXFolder), FFCRC.GetHash(VFXFile), Strings.ItemsDat); } if (offset != 0) { if (m.ID.Contains("vfx")) { texData = TEX.GetVFX(offset, Strings.ItemsDat); } else { if (selectedCategory.Equals("UI")) { texData = TEX.GetTex(offset, Strings.UIDat); } else { texData = TEX.GetTex(offset, Strings.ItemsDat); } } } SaveTex.SaveDDS(selectedCategory, selectedItem.ItemName, fullPath, m.Name, mtrlData, texData, selectedItem.ItemCategory); } }
/// <summary> /// Updates the displayed image /// </summary> /// <remarks> /// This is called when an image has either been imported or enabled/disabled /// </remarks> /// <param name="offset">The new offset for the image.</param> /// <param name="isColor">Is the image being udpated a color set.</param> public void UpdateImage(int offset, bool isColor) { try { if (isColor) { var colorBMP = MTRL.GetColorBitmap(offset); TextureType = "Type: 16.16.16.16f ABGR\nMipMaps: 0"; TextureDimensions = "(4 x 16)"; alphaBitmap = Imaging.CreateBitmapSourceFromHBitmap(colorBMP.Item1.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()); alphaBitmap.Freeze(); var removeAlphaBitmap = SetAlpha(colorBMP.Item1, 255); noAlphaBitmap = Imaging.CreateBitmapSourceFromHBitmap(removeAlphaBitmap.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()); noAlphaBitmap.Freeze(); mtrlData.ColorData = colorBMP.Item2; colorBMP.Item1.Dispose(); removeAlphaBitmap.Dispose(); } else { if (SelectedMap.ID.Contains("vfx")) { texData = TEX.GetVFX(offset, Strings.ItemsDat); } else { if (selectedCategory.Equals("UI")) { texData = TEX.GetTex(offset, Strings.UIDat); } else { texData = TEX.GetTex(offset, Strings.ItemsDat); } } string mipMaps = "Yes (" + texData.MipCount + ")"; if (texData.MipCount < 1) { mipMaps = "None"; } TextureType = "Type: " + texData.TypeString + "\nMipMaps: " + mipMaps; TextureDimensions = "(" + texData.Width + " x " + texData.Height + ")"; alphaBitmap = Imaging.CreateBitmapSourceFromHBitmap(texData.BMP.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()); var removeAlphaBitmap = SetAlpha(texData.BMP, 255); noAlphaBitmap = Imaging.CreateBitmapSourceFromHBitmap(removeAlphaBitmap.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()); texData.Dispose(); removeAlphaBitmap.Dispose(); } if (AlphaChecked) { ImageSource = alphaBitmap; } else { ImageSource = noAlphaBitmap; } } catch (Exception e) { MessageBox.Show("[TVM] There was an error updating the image.\n" + e.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); } }
public ModListModel ParseEntry(JsonEntry entry) { ModListModel mlm = new ModListModel(); string race, map, part, type; if (entry.fullPath.Contains("mt_")) { Debug.WriteLine(entry.fullPath); } if (entry.fullPath.Contains("weapon") || entry.fullPath.Contains("accessory") || entry.fullPath.Contains("decal") || entry.fullPath.Contains("vfx") || entry.fullPath.Contains("ui/")) { race = Strings.All; } else if (entry.fullPath.Contains("monster") || entry.fullPath.Contains("demihuman")) { race = Strings.Monster; } else { race = entry.fullPath.Substring(entry.fullPath.LastIndexOf('/')); if (entry.fullPath.Contains("mt_") && entry.fullPath.Contains("_acc_")) { race = race.Substring(race.IndexOf("_") + 2, 4); } else if ((entry.fullPath.Contains("_fac_") || entry.fullPath.Contains("_etc_") || entry.fullPath.Contains("_acc_")) && Properties.Settings.Default.DX_Ver.Equals(Strings.DX11)) { race = race.Substring(race.LastIndexOf("--c") + 3, 4); } else if (entry.fullPath.Contains("_fac_") || entry.fullPath.Contains("_etc_") || entry.fullPath.Contains("_acc_")) { race = race.Substring(race.LastIndexOf("/c") + 2, 4); } else if (entry.fullPath.Contains("_c_")) { race = race.Substring(race.IndexOf("_c") + 2, 4); } else { if (entry.fullPath.Contains(".mdl") && entry.fullPath.Contains("_fac")) { race = race.Substring(race.IndexOf('c') + 1, 4); } else { race = race.Substring(race.LastIndexOf('c') + 1, 4); } } if (entry.fullPath.Contains("mt_")) { Debug.WriteLine(race + "\n"); } race = Info.IDRace[race]; } mlm.Race = race; if (entry.fullPath.Contains("_d.")) { map = Strings.Diffuse; } else if (entry.fullPath.Contains("_n.")) { map = Strings.Normal; } else if (entry.fullPath.Contains("_s.")) { map = Strings.Specular; } else if (entry.fullPath.Contains("material")) { map = Strings.ColorSet; } else if (entry.fullPath.Contains("model")) { map = "3D"; } else if (entry.fullPath.Contains("ui/")) { map = "UI"; } else { map = Strings.Mask; } mlm.Map = map; if (entry.fullPath.Contains("_b_")) { part = "b"; } else if (entry.fullPath.Contains("_c_")) { part = "c"; } else if (entry.fullPath.Contains("_d_")) { part = "d"; } else if (entry.fullPath.Contains("decal")) { part = entry.fullPath.Substring(entry.fullPath.LastIndexOf('_') + 1, entry.fullPath.LastIndexOf('.') - (entry.fullPath.LastIndexOf('_') + 1)); } else { part = "a"; } mlm.Part = part; if (entry.fullPath.Contains("_iri_")) { type = "Iris"; } else if (entry.fullPath.Contains("_etc_")) { type = "Etc."; } else if (entry.fullPath.Contains("_fac_")) { type = "Face"; } else if (entry.fullPath.Contains("_hir_")) { type = "Hair"; } else if (entry.fullPath.Contains("_acc_")) { type = "Accessory"; } else if (entry.fullPath.Contains("demihuman")) { type = entry.fullPath.Substring(entry.fullPath.LastIndexOf('_') - 3, 3); type = (Info.slotAbr).FirstOrDefault(x => x.Value == type).Key; } else { type = "-"; } mlm.Type = type; if (entry.fullPath.Contains("material")) { var info = MTRL.GetMTRLInfo(entry.modOffset, false); using (var bitmap = TEX.ColorSetToBitmap(info.ColorData)) mlm.BMP = TexHelper.CreateBitmapSource(bitmap); mlm.BMP.Freeze(); } else if (entry.fullPath.Contains("model")) { mlm.BMP = new BitmapImage(new Uri("pack://application:,,,/FFXIV TexTools 2;component/Resources/3DModel.png")); } else { TEXData texData; if (entry.fullPath.Contains("vfx")) { texData = TEX.GetVFX(entry.modOffset, entry.datFile); } else { if (entry.fullPath.Contains("icon")) { texData = TEX.GetTex(entry.modOffset, entry.datFile); } else { texData = TEX.GetTex(entry.modOffset, entry.datFile); } } var scale = 1; if (texData.Width >= 4096 || texData.Height >= 4096) { scale = 16; } else if (texData.Width >= 2048 || texData.Height >= 2048) { scale = 8; } else if (texData.Width >= 1024 || texData.Height >= 1024) { scale = 4; } var nWidth = texData.Width / scale; var nHeight = texData.Height / scale; var resizedImage = TexHelper.CreateResizedImage(texData.BMPSouceNoAlpha, nWidth, nHeight); mlm.BMP = (BitmapSource)resizedImage; mlm.BMP.Freeze(); } var offset = Helper.GetDataOffset(FFCRC.GetHash(entry.fullPath.Substring(0, entry.fullPath.LastIndexOf("/"))), FFCRC.GetHash(Path.GetFileName(entry.fullPath)), entry.datFile); if (offset == entry.modOffset) { mlm.ActiveBorder = Brushes.Green; mlm.Active = Brushes.Transparent; mlm.ActiveOpacity = 1; } else if (offset == entry.originalOffset) { mlm.ActiveBorder = Brushes.Red; mlm.Active = Brushes.Gray; mlm.ActiveOpacity = 0.5f; } else { mlm.ActiveBorder = Brushes.Red; mlm.Active = Brushes.Red; mlm.ActiveOpacity = 1; } mlm.Entry = entry; return(mlm); }
/// <summary> /// Gets the texture data and displays it for the currently selected item given a specified race, part, type(if applicable), and map /// </summary> private void MapComboBoxChanged() { Bitmap colorBmp = null; int offset = 0; bool isVFX = false; if (selectedMap.Name.Equals(Strings.Normal)) { fullPath = mtrlData.NormalPath; offset = mtrlData.NormalOffset; FullPathString = fullPath + " [" + FFCRC.GetHash(fullPath) + "]"; } else if (selectedMap.Name.Equals(Strings.Specular)) { fullPath = mtrlData.SpecularPath; offset = mtrlData.SpecularOffset; FullPathString = fullPath + " [" + FFCRC.GetHash(fullPath) + "]"; } else if (selectedMap.Name.Equals(Strings.Diffuse)) { fullPath = mtrlData.DiffusePath; offset = mtrlData.DiffuseOffset; FullPathString = fullPath + " [" + FFCRC.GetHash(fullPath) + "]"; } else if (selectedMap.Name.Equals(Strings.Mask) || selectedMap.Name.Equals(Strings.Skin)) { if (selectedItem.ItemName.Equals(Strings.Face_Paint) || selectedItem.ItemName.Equals(Strings.Equipment_Decals)) { string part; if (selectedItem.ItemName.Equals(Strings.Equipment_Decals)) { part = selectedPart.Name.PadLeft(3, '0'); } else { part = selectedPart.Name; } fullPath = String.Format(mtrlData.MaskPath, part); offset = MTRL.GetDecalOffset(selectedItem.ItemName, selectedPart.Name); FullPathString = fullPath + " [" + FFCRC.GetHash(fullPath) + "]"; } else { fullPath = mtrlData.MaskPath; offset = mtrlData.MaskOffset; FullPathString = fullPath + " [" + FFCRC.GetHash(fullPath) + "]"; } } else if (selectedMap.Name.Equals(Strings.ColorSet)) { colorBmp = TEX.TextureToBitmap(mtrlData.ColorData, 9312, 4, 16); fullPath = mtrlData.MTRLPath; FullPathString = fullPath + " [" + FFCRC.GetHash(fullPath) + "]"; } else { fullPath = SelectedMap.ID; var VFXFolder = fullPath.Substring(0, fullPath.LastIndexOf("/")); var VFXFile = fullPath.Substring(fullPath.LastIndexOf("/") + 1); offset = Helper.GetItemOffset(FFCRC.GetHash(VFXFolder), FFCRC.GetHash(VFXFile)); FullPathString = fullPath; isVFX = true; } if (Properties.Settings.Default.Mod_List == 0) { string line; JsonEntry modEntry = null; bool inModList = false; try { using (StreamReader sr = new StreamReader(Info.modListDir)) { while ((line = sr.ReadLine()) != null) { modEntry = JsonConvert.DeserializeObject <JsonEntry>(line); if (modEntry.fullPath.Equals(fullPath)) { inModList = true; break; } } } } catch (Exception ex) { MessageBox.Show("[Main] Error Accessing .modlist File \n" + ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); } if (inModList) { var currOffset = Helper.GetItemOffset(FFCRC.GetHash(modEntry.fullPath.Substring(0, modEntry.fullPath.LastIndexOf("/"))), FFCRC.GetHash(Path.GetFileName(modEntry.fullPath))); if (currOffset == modEntry.modOffset) { ActiveToggle = "Disable"; } else if (currOffset == modEntry.originalOffset) { ActiveToggle = "Enable"; } else { ActiveToggle = "Error"; } ActiveEnabled = true; } else { ActiveEnabled = false; ActiveToggle = "Enable/Disable"; } } else { ActiveEnabled = false; ActiveToggle = "Enable/Disable"; } if (offset == 0) { TextureType = "A16B16G16R16F"; textureType = "A16B16G16R16F"; TextureDimensions = "(4 x 16)"; textureDimensions = "(4 x 16)"; alphaBitmap = Imaging.CreateBitmapSourceFromHBitmap(colorBmp.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()); var removeAlphaBitmap = SetAlpha(colorBmp, 255); noAlphaBitmap = Imaging.CreateBitmapSourceFromHBitmap(removeAlphaBitmap.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()); colorBmp.Dispose(); removeAlphaBitmap.Dispose(); } else { if (!isVFX) { texData = TEX.GetTex(offset); } else { texData = TEX.GetVFX(offset); } TextureType = texData.TypeString; TextureDimensions = "(" + texData.Width + " x " + texData.Height + ")"; alphaBitmap = Imaging.CreateBitmapSourceFromHBitmap(texData.BMP.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()); var removeAlphaBitmap = SetAlpha(texData.BMP, 255); noAlphaBitmap = Imaging.CreateBitmapSourceFromHBitmap(removeAlphaBitmap.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()); removeAlphaBitmap.Dispose(); } try { ImageEffect = new ColorChannels() { Channel = new System.Windows.Media.Media3D.Point4D(1.0f, 1.0f, 1.0f, 0.0f) }; } catch (Exception ex) { Debug.WriteLine(ex.StackTrace); } ImageSource = noAlphaBitmap; SetColorChannelFilter(); SaveEnabled = true; texData.Dispose(); string dxPath = Path.GetFileNameWithoutExtension(fullPath); if (File.Exists(Properties.Settings.Default.Save_Directory + "/" + selectedCategory + "/" + selectedItem.ItemName + "/" + dxPath + ".dds")) { ImportEnabled = true; } else { ImportEnabled = false; } }