public void ImportTexture(ImageKeyFrame[] Keys, string TextureName) { if (ResourceNodes.ContainsKey(TextureName) || Type != BRESGroupType.Textures) { return; } GTXTextureImporter importer = new GTXTextureImporter(); List <GTXImporterSettings> settings = new List <GTXImporterSettings>(); foreach (var key in Keys) { settings.Add(FTEX.SetImporterSettings(key.Image, $"{TextureName}{key.Frame}")); } importer.LoadSettings(settings); if (importer.ShowDialog() == DialogResult.OK) { ImportTexture(settings); } settings.Clear(); GC.Collect(); Cursor.Current = Cursors.Default; }
private void ImportTexture(List <GTXImporterSettings> settings) { Cursor.Current = Cursors.WaitCursor; foreach (var setting in settings) { if (setting.GenerateMipmaps) { setting.DataBlockOutput.Clear(); setting.DataBlockOutput.Add(setting.GenerateMips()); } if (setting.DataBlockOutput != null) { FTEX ftex = new FTEX(); ftex.texture = new ResU.Texture(); var surface = GTXSwizzle.CreateGx2Texture(setting.DataBlockOutput[0], setting); var tex = FTEX.FromGx2Surface(surface, setting.TexName); ftex.UpdateTex(tex); ftex.IsEdited = true; ftex.Read(ftex.texture); ftex.LoadOpenGLTexture(); AddNode(ftex); } else { MessageBox.Show("Something went wrong???"); } } }
private void AddFTEXTextures(ResU.ResFile resFile) { FTEXContainer ftexContainer = new FTEXContainer(); foreach (ResU.Texture tex in resFile.Textures.Values) { string TextureName = tex.Name; FTEX texture = new FTEX(); texture.Read(tex); ftexContainer.Nodes.Add(texture); ftexContainer.Textures.Add(texture.Text, texture); } PluginRuntime.ftexContainers.Add(ftexContainer); Nodes.Add(ftexContainer); }
private void ImportPlaceholderTexture(byte[] data, string TextureName) { GTXImporterSettings setting = new GTXImporterSettings(); setting.LoadDDS(TextureName, data); var surface = GTXSwizzle.CreateGx2Texture(setting.DataBlockOutput[0], setting); FTEX ftex = new FTEX(); ftex.texture = new ResU.Texture(); ftex.texture = FTEX.FromGx2Surface(surface, setting.TexName); ftex.IsEdited = true; ftex.Read(ftex.texture); AddNode(ftex); ftex.LoadOpenGLTexture(); }
private void AddFTEXTextures(ResU.ResFile resFile) { MessageBox.Show("Note! Textures are disabled atm."); return; FTEXContainer ftexContainer = new FTEXContainer(); Nodes.Add(ftexContainer); foreach (ResU.Texture tex in resFile.Textures.Values) { string TextureName = tex.Name; FTEX texture = new FTEX(); texture.Read(tex); ftexContainer.Nodes.Add(texture); ftexContainer.Textures.Add(texture.Text, texture); } PluginRuntime.ftexContainers.Add(ftexContainer); }
public void ImportTexture(string[] FileNames) { GTXTextureImporter importer = new GTXTextureImporter(); List <GTXImporterSettings> settings = new List <GTXImporterSettings>(); foreach (string name in FileNames) { string TextureName = Path.GetFileNameWithoutExtension(name); string ext = Path.GetExtension(name); ext = ext.ToLower(); if (ext == ".bftex") { FTEX ftex = new FTEX(); ftex.texture = new ResU.Texture(); ftex.texture.Import(name, GetResFileU()); ftex.IsEdited = true; ftex.Read(ftex.texture); AddNode(ftex); } else if (ext == ".dds" || ext == ".dds2") { FTEX ftex = new FTEX(); ftex.texture = new ResU.Texture(); GTXImporterSettings setting = FTEX.SetImporterSettings(name); if (setting.DataBlockOutput != null) { var surface = GTXSwizzle.CreateGx2Texture(setting.DataBlockOutput[0], setting); var tex = FTEX.FromGx2Surface(surface, setting.TexName); ftex.UpdateTex(tex); ftex.IsEdited = true; ftex.Read(ftex.texture); ftex.LoadOpenGLTexture(); AddNode(ftex); } } else { settings.Add(FTEX.SetImporterSettings(name)); } } if (settings.Count == 0) { importer.Dispose(); } else { importer.LoadSettings(settings); if (importer.ShowDialog() == DialogResult.OK) { ImportTexture(settings); settings.Clear(); GC.Collect(); Cursor.Current = Cursors.Default; } } }
public override void ReplaceAll() { FolderSelectDialog sfd = new FolderSelectDialog(); if (sfd.ShowDialog() == DialogResult.OK) { if (Type == BRESGroupType.Textures) { GTXTextureImporter importer = new GTXTextureImporter(); List <GTXImporterSettings> settings = new List <GTXImporterSettings>(); foreach (string file in System.IO.Directory.GetFiles(sfd.SelectedPath)) { string FileName = System.IO.Path.GetFileNameWithoutExtension(file); foreach (FTEX ftex in Nodes) { if (FileName == ftex.Text) { string ext = Path.GetExtension(file); ext = ext.ToLower(); if (ext == ".bftex") { ftex.texture = new ResU.Texture(); ftex.texture.Import(file, GetResFileU()); ftex.IsEdited = true; ftex.Read(ftex.texture); } else if (ext == ".dds" || ext == ".dds2") { GTXImporterSettings setting = FTEX.SetImporterSettings(file); if (setting.DataBlockOutput != null) { var surface = GTXSwizzle.CreateGx2Texture(setting.DataBlockOutput[0], setting); var tex = FTEX.FromGx2Surface(surface, setting.TexName); ftex.UpdateTex(tex); ftex.IsReplaced = true; ftex.Read(ftex.texture); ftex.LoadOpenGLTexture(); } } else { var setting = FTEX.SetImporterSettings(file); setting.MipCountOriginal = (int)ftex.MipCount; setting.Format = (GX2.GX2SurfaceFormat)FTEX.ConvertToGx2Format(ftex.Format); settings.Add(setting); } } } } if (settings.Count == 0) { importer.Dispose(); } else { importer.LoadSettings(settings); if (importer.ShowDialog() == DialogResult.OK) { foreach (var setting in settings) { foreach (FTEX ftex in Nodes) { if (setting.TexName == ftex.Text) { if (setting.GenerateMipmaps && !setting.IsFinishedCompressing) { setting.DataBlockOutput.Clear(); setting.DataBlockOutput.Add(setting.GenerateMips()); } if (setting.DataBlockOutput != null) { var surface = GTXSwizzle.CreateGx2Texture(setting.DataBlockOutput[0], setting); var tex = FTEX.FromGx2Surface(surface, setting.TexName); ftex.UpdateTex(tex); tex.Name = ftex.Text; ftex.IsEdited = true; ftex.Read(ftex.texture); ftex.LoadOpenGLTexture(); } else { MessageBox.Show("Something went wrong???"); } } } } settings.Clear(); GC.Collect(); Cursor.Current = Cursors.Default; } } } else { foreach (string file in System.IO.Directory.GetFiles(sfd.SelectedPath)) { string FileName = System.IO.Path.GetFileNameWithoutExtension(file); foreach (TreeNode node in Nodes) { if (node is STGenericWrapper) { if (FileName == node.Text) { ((STGenericWrapper)node).Replace(file); } } } } } } }