1
0
mirror of synced 2024-11-30 18:24:39 +01:00

Load channel ocmponents for some formats

This commit is contained in:
KillzXGaming 2019-05-04 13:38:18 -04:00
parent d100a974eb
commit 6a7fe523e3
10 changed files with 68 additions and 7 deletions

Binary file not shown.

View File

@ -364,6 +364,11 @@ namespace Bfres.Structs
ArrayCount = tex.ArrayLength;
MipCount = tex.MipCount;
RedChannel = SetChannel(texture.CompSelR);
GreenChannel = SetChannel(texture.CompSelG);
BlueChannel = SetChannel(texture.CompSelB);
AlphaChannel = SetChannel(texture.CompSelA);
if (tex.ArrayLength == 0)
ArrayCount = tex.Depth; //Some older bfres don't use array length????
@ -371,6 +376,16 @@ namespace Bfres.Structs
MipCount = 1;
}
private STChannelType SetChannel(GX2CompSel comp)
{
if (comp == GX2CompSel.ChannelR) return STChannelType.Red;
else if (comp == GX2CompSel.ChannelG) return STChannelType.Green;
else if (comp == GX2CompSel.ChannelB) return STChannelType.Blue;
else if (comp == GX2CompSel.ChannelA) return STChannelType.Alpha;
else if (comp == GX2CompSel.Always0) return STChannelType.Zero;
else return STChannelType.One;
}
public void UpdateMipMaps()
{
LoadTex2Bfres();
@ -675,7 +690,7 @@ namespace Bfres.Structs
LibraryGUI.Instance.LoadEditor(editor);
}
editor.Text = Text;
editor.LoadProperties(this.texture);
editor.LoadProperties(this.texture, OnPropertyChanged);
editor.LoadImage(this);
if (texture.UserData != null)
@ -690,5 +705,23 @@ namespace Bfres.Structs
userEditor.LoadUserData(texture.UserData);
}
}
private void OnPropertyChanged()
{
Text = texture.Name;
MessageBox.Show("UPDATE PROB");
RedChannel = SetChannel(texture.CompSelR);
GreenChannel = SetChannel(texture.CompSelG);
BlueChannel = SetChannel(texture.CompSelB);
AlphaChannel = SetChannel(texture.CompSelA);
ImageEditorBase editor = (ImageEditorBase)LibraryGUI.Instance.GetActiveContent(typeof(ImageEditorBase));
if (editor != null)
{
editor.UpdateMipDisplay();
}
}
}
}

View File

@ -796,6 +796,10 @@ namespace FirstPlugin
MipCount = (uint)tex.TextureData[0].Count;
Format = ConvertFormat(tex.Format);
RedChannel = SetChannel(tex.ChannelRed);
GreenChannel = SetChannel(tex.ChannelGreen);
BlueChannel = SetChannel(tex.ChannelBlue);
AlphaChannel = SetChannel(tex.ChannelAlpha);
ContextMenuStrip = new STContextMenuStrip();
ContextMenuStrip.Items.Add(new ToolStripMenuItem("Export", null, Export, Keys.Control | Keys.E));
ContextMenuStrip.Items.Add(new ToolStripMenuItem("Replace", null, Replace, Keys.Control | Keys.R));
@ -804,6 +808,17 @@ namespace FirstPlugin
ContextMenuStrip.Items.Add(new ToolStripSeparator());
ContextMenuStrip.Items.Add(new ToolStripMenuItem("Delete", null, Remove, Keys.Control | Keys.Delete));
}
private STChannelType SetChannel(ChannelType channelType)
{
if (channelType == ChannelType.Red) return STChannelType.Red;
else if (channelType == ChannelType.Green) return STChannelType.Green;
else if (channelType == ChannelType.Blue) return STChannelType.Blue;
else if (channelType == ChannelType.Alpha) return STChannelType.Alpha;
else if (channelType == ChannelType.Zero) return STChannelType.Zero;
else return STChannelType.One;
}
public static SurfaceFormat GenericToBntxSurfaceFormat(TEX_FORMAT texFormat)
{
switch (texFormat)
@ -979,9 +994,20 @@ namespace FirstPlugin
editor.Text = Text;
editor.LoadProperties(Texture);
editor.LoadProperties(Texture, OnPropertyChanged);
editor.LoadImage(this);
}
private void OnPropertyChanged()
{
Text = Texture.Name;
RedChannel = SetChannel(Texture.ChannelRed);
GreenChannel = SetChannel(Texture.ChannelGreen);
BlueChannel = SetChannel(Texture.ChannelBlue);
AlphaChannel = SetChannel(Texture.ChannelAlpha);
}
private void Remove(object sender, EventArgs args)
{
((BNTX)Parent).RemoveTexture(this);

View File

@ -235,7 +235,7 @@ namespace Switch_Toolbox.Library.Forms
}
}
public void LoadProperties(object prop) => propertiesEditor.LoadProperties(prop);
public void LoadProperties(object prop, Action OnPropertyChanged = null) => propertiesEditor.LoadProperties(prop, OnPropertyChanged);
public void LoadImage(STGenericTexture texture)
{

View File

@ -66,7 +66,7 @@ namespace Switch_Toolbox.Library.Forms
return null;
}
public void LoadProperties(object prop)
public void LoadProperties(object prop, Action OnPropertyChanged)
{
if (stPropertyGrid1.InvokeRequired)
{
@ -98,9 +98,6 @@ namespace Switch_Toolbox.Library.Forms
stPropertyGrid1.Refresh();
}
public void OnPropertyChanged() { }
public void ResetChannels()
{
imgList.Images.Clear();

View File

@ -45,6 +45,11 @@ namespace Switch_Toolbox.Library
{
RenderableTex = new RenderableTex();
RenderableTex.GLInitialized = false;
RedChannel = STChannelType.Red;
GreenChannel = STChannelType.Green;
BlueChannel = STChannelType.Blue;
AlphaChannel = STChannelType.Alpha;
}
/// <summary>