Some more fixes

This commit is contained in:
KillzXGaming 2020-02-08 15:09:40 -05:00
parent 817367343a
commit 1e62b23013
2 changed files with 34 additions and 6 deletions

View file

@ -54,6 +54,12 @@ namespace FirstPlugin
set { }
}
public override void OnAfterAdded()
{
if (Nodes.Count > 0 && this.TreeView != null)
this.TreeView.SelectedNode = Nodes[0];
}
public Header header;
public void Load(System.IO.Stream stream)
@ -161,11 +167,10 @@ namespace FirstPlugin
{
for (int t = 0; t < Chunks[i].Textures.Count; t++)
{
var texWrapper = new TextureWrapper();
var texWrapper = new TextureWrapper(Chunks[i].Textures[t]);
texWrapper.Text = $"Texture_{t}";
texWrapper.ImageKey = "texture";
texWrapper.SelectedImageKey = texWrapper.ImageKey;
texWrapper.TextureInfo = Chunks[i].Textures[t];
if (Chunks[i].Textures[t].Name != string.Empty)
texWrapper.Text = Chunks[i].Textures[t].Name;
@ -264,6 +269,8 @@ namespace FirstPlugin
LA8 = 0x14016758,
}
public Texture() { }
public Texture(FileReader reader)
{
ImageSize = reader.ReadUInt32();
@ -343,8 +350,9 @@ namespace FirstPlugin
}
}
public TextureWrapper()
public TextureWrapper(Texture textureInfo)
{
TextureInfo = textureInfo;
PlatformSwizzle = PlatformSwizzle.Platform_3DS;
CanReplace = true;
@ -372,6 +380,12 @@ namespace FirstPlugin
editor.LoadImage(this);
}
public void CreateNew(string fileName)
{
TextureInfo = new Texture();
Replace(fileName);
}
public override void Replace(string FileName)
{
CTR_3DSTextureImporter importer = new CTR_3DSTextureImporter();

View file

@ -203,8 +203,6 @@ namespace Toolbox.Library.Forms
public List<byte[]> GenerateMipList(int SurfaceLevel = 0)
{
MipCount = 1;
Bitmap Image = BitmapExtension.GetBitmap(DecompressedData[SurfaceLevel], (int)TexWidth, (int)TexHeight);
List<byte[]> mipmaps = new List<byte[]>();
@ -215,7 +213,23 @@ namespace Toolbox.Library.Forms
// for (int mipLevel = 0; mipLevel < MipCount; mipLevel++)
for (int mipLevel = 0; mipLevel < MipCount; mipLevel++)
{
Image = BitmapExtension.Resize(Image, Image.Width / 2, Image.Height / 2);
int width = Image.Width / 2;
int height = Image.Width / 2;
if (Format == CTR_3DS.PICASurfaceFormat.ETC1 || Format == CTR_3DS.PICASurfaceFormat.ETC1A4) {
if (width < 16)
break;
if (height < 16)
break;
}
else
{
if (width < 8)
break;
if (height < 8)
break;
}
Image = BitmapExtension.Resize(Image, width, height);
mipmaps.Add(CTR_3DS.EncodeBlock(BitmapExtension.ImageToByte(Image),
Image.Width, Image.Height, Format));
}