Improve texture importing for bflyt editor
This commit is contained in:
parent
60e4860cfc
commit
d56acf67ef
@ -128,7 +128,7 @@ namespace LayoutBXLYT
|
||||
}
|
||||
}
|
||||
|
||||
public List<STGenericTexture> AddTextures()
|
||||
public List<STGenericTexture> AddTextures()
|
||||
{
|
||||
List<STGenericTexture> textures = new List<STGenericTexture>();
|
||||
|
||||
@ -179,16 +179,14 @@ namespace LayoutBXLYT
|
||||
bntx = BinaryContainers.Values.FirstOrDefault();
|
||||
}
|
||||
|
||||
int startIndex = bntx.Textures.Count;
|
||||
bntx.ImportTexture();
|
||||
int startIndex = bntx.Textures.Count - 1;
|
||||
var importedTextures = bntx.ImportTexture();
|
||||
|
||||
Console.WriteLine("startIndex " + startIndex);
|
||||
|
||||
//Load all the additional textues
|
||||
|
||||
for (int i = 0; i < bntx.Textures.Count; i++)
|
||||
{
|
||||
if (i > startIndex - 1)
|
||||
textures.Add(bntx.Textures.Values.ElementAt(i));
|
||||
}
|
||||
for (int i = 0; i < importedTextures.Count; i++)
|
||||
textures.Add(importedTextures[i]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -606,7 +606,7 @@ namespace FirstPlugin
|
||||
private void ImportTextureAction(object sender, EventArgs args) {
|
||||
ImportTexture();
|
||||
}
|
||||
public void ImportTexture()
|
||||
public List<TextureData> ImportTexture()
|
||||
{
|
||||
OpenFileDialog ofd = new OpenFileDialog();
|
||||
ofd.Filter = FileFilters.GetFilter(typeof(TextureData));
|
||||
@ -614,14 +614,16 @@ namespace FirstPlugin
|
||||
ofd.DefaultExt = "png";
|
||||
ofd.Multiselect = true;
|
||||
|
||||
if (ofd.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
ImportTexture(ofd.FileNames);
|
||||
if (ofd.ShowDialog() == DialogResult.OK) {
|
||||
return ImportTexture(ofd.FileNames);
|
||||
}
|
||||
return new List<TextureData>();
|
||||
}
|
||||
|
||||
public void ImportTexture(string[] FileNames)
|
||||
public List<TextureData> ImportTexture(string[] FileNames)
|
||||
{
|
||||
List<TextureData> textures = new List<TextureData>();
|
||||
|
||||
BinaryTextureImporterList importer = new BinaryTextureImporterList();
|
||||
List<TextureImporterSettings> settings = new List<TextureImporterSettings>();
|
||||
|
||||
@ -632,7 +634,7 @@ namespace FirstPlugin
|
||||
|
||||
if (ext == ".dds" || ext == ".bftex" || ext == ".astc")
|
||||
{
|
||||
AddTexture(name);
|
||||
textures.Add(AddTexture(name));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -642,17 +644,18 @@ namespace FirstPlugin
|
||||
if (settings.Count == 0)
|
||||
{
|
||||
importer.Dispose();
|
||||
return;
|
||||
return textures;
|
||||
}
|
||||
|
||||
importer.LoadSettings(settings);
|
||||
if (importer.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
ImportTexture(settings, importer.CompressionMode);
|
||||
if (importer.ShowDialog() == DialogResult.OK) {
|
||||
textures.AddRange(ImportTexture(settings, importer.CompressionMode));
|
||||
}
|
||||
settings.Clear();
|
||||
GC.Collect();
|
||||
Cursor.Current = Cursors.Default;
|
||||
|
||||
return textures;
|
||||
}
|
||||
|
||||
public void ImportTexture(ImageKeyFrame[] Keys, string TextureName)
|
||||
@ -679,8 +682,10 @@ namespace FirstPlugin
|
||||
Cursor.Current = Cursors.Default;
|
||||
}
|
||||
|
||||
private void ImportTexture(List<TextureImporterSettings> settings, STCompressionMode CompressionMode)
|
||||
private List<TextureData> ImportTexture(List<TextureImporterSettings> settings, STCompressionMode CompressionMode)
|
||||
{
|
||||
List<TextureData> textures = new List<TextureData>();
|
||||
|
||||
Cursor.Current = Cursors.WaitCursor;
|
||||
foreach (var setting in settings)
|
||||
{
|
||||
@ -708,6 +713,8 @@ namespace FirstPlugin
|
||||
|
||||
Nodes.Add(setting.textureData);
|
||||
Textures.Add(setting.textureData.Text, setting.textureData);
|
||||
textures.Add(setting.textureData);
|
||||
|
||||
setting.textureData.LoadOpenGLTexture();
|
||||
LibraryGUI.UpdateViewport();
|
||||
}
|
||||
@ -716,6 +723,7 @@ namespace FirstPlugin
|
||||
MessageBox.Show("Something went wrong???");
|
||||
}
|
||||
}
|
||||
return textures;
|
||||
}
|
||||
|
||||
//This function is an optional feature that will import a dummy texture if one is missing in the materials
|
||||
|
@ -216,6 +216,13 @@ namespace LayoutBXLYT
|
||||
if (TextureList.ContainsKey(texture))
|
||||
{
|
||||
ActiveLayout.TextureManager.RemoveTexture(TextureList[texture]);
|
||||
foreach (var bntx in PluginRuntime.bntxContainers) {
|
||||
if (bntx.Textures.ContainsKey(texture))
|
||||
bntx.Textures.Remove(texture);
|
||||
}
|
||||
if (PluginRuntime.bflimTextures.ContainsKey(texture))
|
||||
PluginRuntime.bflimTextures.Remove(texture);
|
||||
|
||||
TextureList.Remove(texture);
|
||||
}
|
||||
|
||||
@ -247,6 +254,9 @@ namespace LayoutBXLYT
|
||||
item.ImageIndex = 0;
|
||||
|
||||
listViewCustom1.BeginUpdate();
|
||||
if (listViewCustom1.Items.ContainsKey(tex.Text))
|
||||
listViewCustom1.Items.RemoveByKey(tex.Text);
|
||||
|
||||
listViewCustom1.Items.Add(item);
|
||||
|
||||
//Add icon
|
||||
|
Loading…
x
Reference in New Issue
Block a user