Many more improvements and additions

Added NUT support (viewing GX2 and DDS texture data)
Fixed importing uncompressed dds using the mask data.
Add EFE support from smash 4 wii u and 3ds.
Redo the shader param editor. Uses a list again for faster access and viewing. I will have items drop down from a floating window next to the item soon.
This commit is contained in:
KillzXGaming 2019-04-24 21:17:29 -04:00
parent 05f4d57ef6
commit dd15ef59c5
43 changed files with 2031 additions and 262 deletions

Binary file not shown.

View file

@ -253,12 +253,25 @@ namespace FirstPlugin
if (bone.BoneAnimU != null)
{
foreach (var curve in bone.BoneAnimU.Curves)
bone.Nodes.Add("Anim Curve " + index++);
GetSkeletonAnimCurveOffset(curve.AnimDataOffset);
}
else
{
foreach (var curve in bone.BoneAnim.Curves)
bone.Nodes.Add("Anim Curve " + index++);
GetSkeletonAnimCurveOffset(curve.AnimDataOffset);
}
}
}
}
if (animFolder.Type == BRESGroupType.ColorAnim)
{
foreach (var anim in animFolder.Nodes)
{
if (anim is FMAA)
{
foreach (FMAA.MaterialAnimEntry mat in ((FSKA)anim).Nodes)
{
}
}
}
@ -270,6 +283,26 @@ namespace FirstPlugin
editor.treeViewCustom1.EndUpdate();
}
private string GetSkeletonAnimCurveOffset(uint offset)
{
switch ((FSKA.TrackType)offset)
{
case FSKA.TrackType.XPOS: return "Translate_X";
case FSKA.TrackType.YPOS: return "Translate_Y";
case FSKA.TrackType.ZPOS: return "Translate_Z";
case FSKA.TrackType.XROT: return "Rotate_X";
case FSKA.TrackType.YROT: return "Rotate_Y";
case FSKA.TrackType.ZROT: return "Rotate_Z";
case FSKA.TrackType.WROT: return "Rotate_W";
case FSKA.TrackType.XSCA: return "Scale_X";
case FSKA.TrackType.YSCA: return "Scale_Y";
case FSKA.TrackType.ZSCA: return "Scale_Z";
default: offset.ToString(); break;
}
return "";
}
List<AbstractGlDrawable> drawables = new List<AbstractGlDrawable>();
public void LoadEditors(object SelectedSection)
{

View file

@ -319,7 +319,7 @@ namespace Bfres.Structs
public class BfresShaderParam
{
public ShaderParamType Type;
public string Name;
public string Name { get; set; }
public bool HasPadding;
public int PaddingLength = 0;

View file

@ -0,0 +1,160 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Switch_Toolbox;
using System.Windows.Forms;
using Switch_Toolbox.Library;
using Switch_Toolbox.Library.IO;
using FirstPlugin.Forms;
namespace FirstPlugin
{
public class EFCF : IFileFormat, IEditor<EffectTableEditor>
{
public bool CanSave { get; set; }
public string[] Description { get; set; } = new string[] { "Effect Table" };
public string[] Extension { get; set; } = new string[] { "*.efc" };
public string FileName { get; set; }
public string FilePath { get; set; }
public IFileInfo IFileInfo { get; set; }
public bool Identify(System.IO.Stream stream)
{
using (var reader = new Switch_Toolbox.Library.IO.FileReader(stream, true))
{
if (reader.CheckSignature(4, "EFCF") ||
reader.CheckSignature(4, "EFCC"))
return true;
else
return false;
}
}
public Type[] Types
{
get
{
List<Type> types = new List<Type>();
return types.ToArray();
}
}
public Header EfcHeader;
public EffectTableEditor OpenForm()
{
bool IsDialog = IFileInfo != null && IFileInfo.InArchive;
var form = new EffectTableEditor();
form.Text = FileName;
form.Dock = DockStyle.Fill;
form.LoadEffectFile(this);
return form;
}
public void Load(System.IO.Stream stream)
{
CanSave = true;
EfcHeader = new Header();
EfcHeader.Read(new FileReader(stream));
}
public void Unload()
{
}
public byte[] Save()
{
var mem = new System.IO.MemoryStream();
EfcHeader.Write(new FileWriter(mem));
return mem.ToArray();
}
public class Header
{
public string Magic { get; set; }
public uint Version { get; set; }
public List<Entry> Entries = new List<Entry>();
public List<string> StringEntries = new List<string>();
public void Read(FileReader reader)
{
reader.ByteOrder = Syroot.BinaryData.ByteOrder.BigEndian;
Magic = reader.ReadString(4, Encoding.ASCII);
if (Magic == "EFCC")
reader.ByteOrder = Syroot.BinaryData.ByteOrder.LittleEndian;
uint Version = reader.ReadUInt32();
ushort EntryCount = reader.ReadUInt16();
ushort StringCount = reader.ReadUInt16();
ushort SlotSpecificDataCount = reader.ReadUInt16();
ushort Padding = reader.ReadUInt16();
for (int i = 0; i < EntryCount; i++)
{
Entry entry = new Entry();
entry.Read(reader);
Entries.Add(entry);
}
for (int i = 0; i < StringCount; i++)
{
StringEntries.Add(reader.ReadString(Syroot.BinaryData.BinaryStringFormat.ZeroTerminated));
reader.Align(2);
}
}
public void Write(FileWriter writer)
{
writer.WriteSignature(Magic);
if (Magic == "EFCC")
writer.ByteOrder = Syroot.BinaryData.ByteOrder.LittleEndian;
else
writer.ByteOrder = Syroot.BinaryData.ByteOrder.BigEndian;
writer.Write(Version);
writer.Write((ushort)Entries.Count);
writer.Write((ushort)StringEntries.Count);
writer.Write((ushort)0);
for (int i = 0; i < Entries.Count; i++)
{
Entries[i].Write(writer);
}
for (int i = 0; i < StringEntries.Count; i++)
{
writer.Write(StringEntries[i]);
writer.Align(2);
}
}
}
public class Entry
{
public uint ActiveTime { get; set; }
public int PtclStringSlot { get; set; }
public int StringBankSlot { get; set; }
public int SlotSpecificPtclData { get; set; }
public void Read(FileReader reader)
{
ActiveTime = reader.ReadUInt32();
PtclStringSlot = reader.ReadInt32() - 1;
StringBankSlot = reader.ReadInt32() - 1;
SlotSpecificPtclData = reader.ReadInt32();
}
public void Write(FileWriter writer)
{
writer.Write(ActiveTime);
writer.Write(PtclStringSlot + 1);
writer.Write(StringBankSlot + 1);
writer.Write(SlotSpecificPtclData);
}
}
}
}

View file

@ -8,7 +8,7 @@ using Switch_Toolbox.Library;
namespace FirstPlugin
{
public class EFF : TreeNodeFile, IFileFormat
public class EFF : TreeNodeFile,IFileFormat
{
public bool CanSave { get; set; }
public string[] Description { get; set; } = new string[] { "Namco Effect" };

View file

@ -46,8 +46,8 @@ namespace FirstPlugin
}
}
Header header;
WiiU.Header headerU;
public Header header;
public WiiU.Header headerU;
byte[] data;
bool IsWiiU = false;

View file

@ -500,7 +500,6 @@ namespace FirstPlugin
}
public class SurfaceInfoParse : GX2.GX2Surface
{
public void Read(FileReader reader)
{
reader.ByteOrder = Syroot.BinaryData.ByteOrder.BigEndian;

View file

@ -0,0 +1,502 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Switch_Toolbox;
using System.Windows.Forms;
using Switch_Toolbox.Library;
using Switch_Toolbox.Library.IO;
using Switch_Toolbox.Library.Forms;
using System.Drawing;
using Syroot.NintenTools.Bfres.GX2;
namespace FirstPlugin
{
public class NUT : TreeNodeFile, IFileFormat
{
public bool CanSave { get; set; }
public string[] Description { get; set; } = new string[] { "Namco Universal Texture Container" };
public string[] Extension { get; set; } = new string[] { "*.nut" };
public string FileName { get; set; }
public string FilePath { get; set; }
public IFileInfo IFileInfo { get; set; }
public bool Identify(System.IO.Stream stream)
{
using (var reader = new Switch_Toolbox.Library.IO.FileReader(stream, true))
{
if (reader.CheckSignature(4, "NTWU") ||
reader.CheckSignature(4, "NTP3") ||
reader.CheckSignature(4, "NTWD"))
return true;
else
return false;
}
}
public Type[] Types
{
get
{
List<Type> types = new List<Type>();
return types.ToArray();
}
}
Header NutHeader;
public void Load(System.IO.Stream stream)
{
Text = FileName;
NutHeader = new Header();
NutHeader.Read(new FileReader(stream));
foreach (var image in NutHeader.Images)
Nodes.Add(image);
}
public void Unload()
{
}
public byte[] Save()
{
var mem = new System.IO.MemoryStream();
NutHeader.Write(new FileWriter(mem));
return mem.ToArray();
}
public class Header
{
public string Magic;
public ushort ByteOrderMark;
public ushort Version;
public List<NutImage> Images = new List<NutImage>();
byte[] Reserved;
public bool IsNTP3;
public void Read(FileReader reader)
{
reader.ByteOrder = Syroot.BinaryData.ByteOrder.BigEndian;
Magic = reader.ReadString(4, Encoding.ASCII);
Version = reader.ReadUInt16();
IsNTP3 = Magic == "NTP3";
if (Magic == "NTWD")
{
reader.ByteOrder = Syroot.BinaryData.ByteOrder.LittleEndian;
IsNTP3 = true;
}
ushort ImageCount = reader.ReadUInt16();
Reserved = reader.ReadBytes(8);
for (int i = 0; i < ImageCount; i++)
{
NutImage image = new NutImage();
image.Read(reader, this);
Images.Add(image);
}
}
public void Write(FileWriter writer)
{
writer.WriteSignature(Magic);
writer.Write(Version);
writer.Write((ushort)Images.Count);
writer.Write(Reserved);
for (int i = 0; i < Images.Count; i++)
{
Images[i].Write(writer, IsNTP3);
}
}
}
public class NutImage : STGenericTexture
{
public override TEX_FORMAT[] SupportedFormats
{
get
{
return new TEX_FORMAT[]
{
TEX_FORMAT.BC1_UNORM,
TEX_FORMAT.BC1_UNORM_SRGB,
TEX_FORMAT.BC2_UNORM,
TEX_FORMAT.BC2_UNORM_SRGB,
TEX_FORMAT.BC3_UNORM,
TEX_FORMAT.BC3_UNORM_SRGB,
TEX_FORMAT.BC4_UNORM,
TEX_FORMAT.BC4_SNORM,
TEX_FORMAT.BC5_UNORM,
TEX_FORMAT.BC5_SNORM,
TEX_FORMAT.B5G5R5A1_UNORM,
TEX_FORMAT.B5G6R5_UNORM,
TEX_FORMAT.B8G8R8A8_UNORM_SRGB,
TEX_FORMAT.B8G8R8A8_UNORM,
TEX_FORMAT.R10G10B10A2_UNORM,
TEX_FORMAT.R16_UNORM,
TEX_FORMAT.B4G4R4A4_UNORM,
TEX_FORMAT.B5_G5_R5_A1_UNORM,
TEX_FORMAT.R8G8B8A8_UNORM_SRGB,
TEX_FORMAT.R8G8B8A8_UNORM,
TEX_FORMAT.R8_UNORM,
TEX_FORMAT.R8G8_UNORM,
TEX_FORMAT.R32G8X24_FLOAT,
};
}
}
public override bool CanEdit { get; set; } = false;
public uint TotalTextureSize;
public uint PaletteSize;
public uint ImageSize;
public uint HeaderSize;
public ushort PaletteCount;
public byte NutFormat;
public byte OldFormat;
public byte PaletteFormat;
public bool IsCubeMap = false;
public EXT ExternalData;
public GIDX GIDXHeaderData;
public NutGX2Surface Gx2HeaderData;
public byte[] Data;
public byte[] MipData;
public uint[] ImageSizes;
public override void OnClick(TreeView treeview)
{
UpdateEditor();
}
private void UpdateEditor()
{
ImageEditorBase editor = (ImageEditorBase)LibraryGUI.Instance.GetActiveContent(typeof(ImageEditorBase));
if (editor == null)
{
editor = new ImageEditorBase();
editor.Dock = DockStyle.Fill;
LibraryGUI.Instance.LoadEditor(editor);
}
Properties prop = new Properties();
prop.Width = Width;
prop.Height = Height;
prop.Depth = Depth;
prop.MipCount = MipCount;
prop.ArrayCount = ArrayCount;
prop.ImageSize = (uint)ImageSize;
prop.Format = Format;
editor.Text = Text;
editor.LoadProperties(prop);
editor.LoadImage(this);
}
private TEX_FORMAT SetFormat(byte format)
{
switch (format)
{
case 0x0: return TEX_FORMAT.BC1_UNORM;
case 0x1: return TEX_FORMAT.BC2_UNORM;
case 0x2: return TEX_FORMAT.BC3_UNORM;
case 8: return TEX_FORMAT.B5_G5_R5_A1_UNORM;
case 12: return TEX_FORMAT.R16G16B16A16_UNORM;
case 14: return TEX_FORMAT.R8G8B8A8_UNORM;
case 16: return TEX_FORMAT.R8G8B8A8_UNORM;
case 17: return TEX_FORMAT.R8G8B8A8_UNORM;
case 21: return TEX_FORMAT.BC4_UNORM;
case 22: return TEX_FORMAT.BC5_UNORM;
default:
throw new NotImplementedException($"Unsupported Nut Format {format}");
}
}
public void Read(FileReader reader, Header header)
{
long pos = reader.Position;
Console.WriteLine("pos " + pos);
TotalTextureSize = reader.ReadUInt32(); //Including header
PaletteSize = reader.ReadUInt32(); //Used in older versions
ImageSize = reader.ReadUInt32();
HeaderSize = reader.ReadUInt16();
PaletteCount = reader.ReadUInt16(); //Used in older versions
OldFormat = reader.ReadByte(); //Used in older versions
MipCount = reader.ReadByte();
PaletteFormat = reader.ReadByte(); //Used in older versions
NutFormat = reader.ReadByte();
Format = SetFormat(NutFormat);
Width = reader.ReadUInt16();
Height = reader.ReadUInt16();
uint Unknown = reader.ReadUInt32(); //Maybe related to 3D depth size
uint Flags = reader.ReadUInt32(); //Determine when to use cube maps
uint dataOffset = 0;
if (header.IsNTP3)
{
if (header.Version < 0x0200) {
dataOffset = HeaderSize;
uint padding2 = reader.ReadUInt32();
}
else if (header.Version >= 0x0200)
dataOffset = reader.ReadUInt32();
}
else
dataOffset = reader.ReadUInt32();
uint mipOffset = reader.ReadUInt32();
uint gtxHeaderOffset = reader.ReadUInt32();
uint padding = reader.ReadUInt32(); //Could be an offset to an unused section?
uint cubeMapSize1 = 0;
uint cubeMapSize2 = 0;
if ((Flags & (uint)DDS.DDSCAPS2.CUBEMAP) == (uint)DDS.DDSCAPS2.CUBEMAP)
{
//Only supporting all six faces
if ((Flags & (uint)DDS.DDSCAPS2.CUBEMAP_ALLFACES) == (uint)DDS.DDSCAPS2.CUBEMAP_ALLFACES)
{
IsCubeMap = true;
ArrayCount = 6;
}
else
{
throw new NotImplementedException($"Unsupported cubemap face amount for texture.");
}
}
if (IsCubeMap)
{
cubeMapSize1 = reader.ReadUInt32();
cubeMapSize2 = reader.ReadUInt32();
uint unk = reader.ReadUInt32();
uint unk2 = reader.ReadUInt32();
}
ImageSizes = new uint[MipCount];
uint MipBlockSize = 0;
if (MipCount == 1) {
if (IsCubeMap)
ImageSizes[0] = cubeMapSize1;
else
ImageSizes[0] = ImageSize;
}
else
{
if (header.IsNTP3)
{
ImageSizes = reader.ReadUInt32s((int)MipCount );
}
else
{
ImageSizes[0] = reader.ReadUInt32();
MipBlockSize = reader.ReadUInt32();
reader.ReadUInt32s((int)MipCount - 2); //Padding / Unused
}
reader.Align(16);
}
ExternalData = new EXT();
ExternalData.Read(reader, header.IsNTP3);
GIDXHeaderData = new GIDX();
GIDXHeaderData.Read(reader, header.IsNTP3);
Text = GIDXHeaderData.HashID.ToString();
if (dataOffset != 0)
{
using (reader.TemporarySeek(dataOffset + pos, System.IO.SeekOrigin.Begin)) {
if (header.IsNTP3)
Data = reader.ReadBytes((int)ImageSize);
else
Data = reader.ReadBytes((int)ImageSizes[0]); //Mip maps are seperate for GX2
}
}
if (mipOffset != 0)
{
using (reader.TemporarySeek(mipOffset + pos, System.IO.SeekOrigin.Begin)) {
MipData = reader.ReadBytes((int)MipBlockSize);
}
}
if (gtxHeaderOffset != 0)
{
using (reader.TemporarySeek(gtxHeaderOffset + pos, System.IO.SeekOrigin.Begin))
{
//Now here is where the GX2 header starts
Gx2HeaderData = new NutGX2Surface();
Gx2HeaderData.Read(reader);
Gx2HeaderData.data = Data;
Gx2HeaderData.mipData = MipData;
Format = Bfres.Structs.FTEX.ConvertFromGx2Format((GX2SurfaceFormat)Gx2HeaderData.format);
}
}
//Seek back for next image
reader.Seek(pos + HeaderSize, System.IO.SeekOrigin.Begin);
}
public void Write(FileWriter writer, bool IsNTP3)
{
}
public override void SetImageData(Bitmap bitmap, int ArrayLevel)
{
throw new NotImplementedException();
}
public override byte[] GetImageData(int ArrayLevel = 0, int MipLevel = 0)
{
if (Gx2HeaderData != null)
{
var surfaces = GX2.Decode(Gx2HeaderData);
return surfaces[ArrayLevel][MipLevel];
}
else
{
uint DataOffset = 0;
for (byte arrayLevel = 0; arrayLevel < ArrayCount; ++arrayLevel)
{
for (byte mipLevel = 0; mipLevel < MipCount; ++mipLevel)
{
if (ArrayLevel == arrayLevel && MipLevel == mipLevel)
{
return Utils.SubArray(Data, DataOffset, ImageSizes[mipLevel]);
}
else
{
DataOffset += ImageSizes[mipLevel];
}
}
}
return null;
}
}
}
public class GIDX
{
public uint HeaderSize;
public uint HashID;
public uint Padding;
public void Read(FileReader reader, bool IsNTP3)
{
var Magic = reader.ReadSignature(4, "GIDX");
HeaderSize = reader.ReadUInt32();
HashID = reader.ReadUInt32();
Padding = reader.ReadUInt32();
}
public void Write(FileWriter writer, bool IsNTP3)
{
writer.WriteSignature("GIDX");
writer.Write(HeaderSize);
writer.Write(HashID);
writer.Write(Padding);
}
}
public class EXT
{
public uint Unknown = 32;
public uint HeaderSize = 16;
public uint Padding;
public void Read(FileReader reader, bool IsNTP3)
{
var Magic = reader.ReadSignature(3, "eXt");
byte padding = reader.ReadByte();
Unknown = reader.ReadUInt32();
HeaderSize = reader.ReadUInt32();
Padding = reader.ReadUInt32();
}
public void Write(FileWriter writer, bool IsNTP3)
{
writer.WriteSignature("Ext");
writer.Write((byte)0);
writer.Write(Unknown);
writer.Write(HeaderSize);
writer.Write(Padding);
}
}
public class NutGX2Surface : GX2.GX2Surface
{
public void Read(FileReader reader)
{
reader.ByteOrder = Syroot.BinaryData.ByteOrder.BigEndian;
dim = reader.ReadUInt32();
width = reader.ReadUInt32();
height = reader.ReadUInt32();
depth = reader.ReadUInt32();
numMips = reader.ReadUInt32();
format = reader.ReadUInt32();
aa = reader.ReadUInt32();
use = reader.ReadUInt32();
imageSize = reader.ReadUInt32();
imagePtr = reader.ReadUInt32();
mipSize = reader.ReadUInt32();
mipPtr = reader.ReadUInt32();
tileMode = reader.ReadUInt32();
swizzle = reader.ReadUInt32();
alignment = reader.ReadUInt32();
pitch = reader.ReadUInt32();
mipOffset = reader.ReadUInt32s(13);
firstMip = reader.ReadUInt32();
imageCount = reader.ReadUInt32();
firstSlice = reader.ReadUInt32();
}
public void Write(FileWriter writer)
{
writer.Write(dim);
writer.Write(width);
writer.Write(height);
writer.Write(depth);
writer.Write(numMips);
writer.Write(format);
writer.Write(aa);
writer.Write(use);
writer.Write(imageSize);
writer.Write(imagePtr);
writer.Write(mipSize);
writer.Write(mipPtr);
writer.Write(tileMode);
writer.Write(swizzle);
writer.Write(alignment);
writer.Write(pitch);
writer.Write(mipOffset);
writer.Write(firstMip);
writer.Write(imageCount);
writer.Write(firstSlice);
}
}
}
}

View file

@ -235,50 +235,61 @@ namespace FirstPlugin
{
public STToolStripItem[] NewFileMenuExtensions => null;
public STToolStripItem[] NewFromFileMenuExtensions => null;
public STToolStripItem[] ToolsMenuExtensions => newFileExt;
public STToolStripItem[] ToolsMenuExtensions => toolExt;
public STToolStripItem[] TitleBarExtensions => null;
public STToolStripItem[] CompressionMenuExtensions => null;
public STToolStripItem[] ExperimentalMenuExtensions => null;
public STToolStripItem[] EditMenuExtensions => null;
STToolStripItem[] newFileExt = new STToolStripItem[1];
STToolStripItem[] toolExt = new STToolStripItem[1];
public MenuExt()
{
newFileExt[0] = new STToolStripItem("Batch Export NUTEXB");
newFileExt[0].Click += Export;
toolExt[0] = new STToolStripItem("Batch Export NUTEXB");
toolExt[0].Click += Export;
}
private void Export(object sender, EventArgs args)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.Multiselect = true;
string formats = FileFilters.NUTEXB;
if (ofd.ShowDialog() == DialogResult.OK)
string[] forms = formats.Split('|');
List<string> Formats = new List<string>();
for (int i = 0; i < forms.Length; i++)
{
foreach (string file in ofd.FileNames)
if (i > 1 || i == (forms.Length - 1)) //Skip lines with all extensions
{
NUTEXB texture = new NUTEXB();
texture.Read(new FileReader(file));
if (!forms[i].StartsWith("*"))
Formats.Add(forms[i]);
}
}
Console.WriteLine(texture.Format.ToString("x") + " " + file + " " + texture.Text);
try
BatchFormatExport form = new BatchFormatExport(Formats);
if (form.ShowDialog() == DialogResult.OK)
{
string extension = form.GetSelectedExtension();
OpenFileDialog ofd = new OpenFileDialog();
ofd.Multiselect = true;
if (ofd.ShowDialog() == DialogResult.OK)
{
foreach (string file in ofd.FileNames)
{
Bitmap bitmap = texture.GetBitmap();
NUTEXB texture = new NUTEXB();
texture.Read(new FileReader(file));
if (bitmap != null)
bitmap.Save(System.IO.Path.GetFullPath(file) + texture.ArcOffset + texture.Text + ".png");
else
Console.WriteLine(" Not supported Format! " + texture.Format);
try
{
texture.Export(System.IO.Path.GetFullPath(file) + texture.ArcOffset + texture.Text + extension);
}
catch
{
Console.WriteLine("Something went wrong??");
}
if (bitmap != null)
bitmap.Dispose();
texture = null;
GC.Collect();
}
catch
{
Console.WriteLine("Something went wrong??");
}
texture = null;
GC.Collect();
}
}
}
@ -292,16 +303,13 @@ namespace FirstPlugin
public byte[] ImageData;
public string ArcOffset; //Temp for exporting in batch
public override string ExportFilter => FileFilters.NUTEXB;
public override string ReplaceFilter => FileFilters.NUTEXB;
private void Replace(object sender, EventArgs args)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = "Supported Formats|*.dds; *.png;*.tga;*.jpg;*.tiff|" +
"Microsoft DDS |*.dds|" +
"Portable Network Graphics |*.png|" +
"Joint Photographic Experts Group |*.jpg|" +
"Bitmap Image |*.bmp|" +
"Tagged Image File Format |*.tiff|" +
"All files(*.*)|*.*";
ofd.Filter = FileFilters.NUTEXB;
ofd.Multiselect = false;
if (ofd.ShowDialog() == DialogResult.OK)
@ -446,11 +454,12 @@ namespace FirstPlugin
reader.Seek(pos - 112, System.IO.SeekOrigin.Begin); //Subtract size where the name occurs
byte padding = reader.ReadByte();
string StrMagic = reader.ReadString(3);
Text = reader.ReadString(Syroot.BinaryData.BinaryStringFormat.ZeroTerminated);
//We cannot check if it's swizzled properly
//So far if the name is blank, it's for Taiko No Tatsujin "Drum 'n' Fun
if (Text == "XNT")
//So far if this part is blank, it's for Taiko No Tatsujin "Drum 'n' Fun
if (StrMagic != "XNT")
IsSwizzled = false;
reader.Seek(pos - 48, System.IO.SeekOrigin.Begin); //Subtract size of header
@ -559,6 +568,7 @@ namespace FirstPlugin
}
long stringPos = writer.Position;
writer.Write((byte)0x20);
writer.WriteSignature("XNT");
writer.WriteString(Text);
writer.Seek(stringPos + 0x40, System.IO.SeekOrigin.Begin);
writer.Seek(4); //padding

View file

@ -0,0 +1,94 @@
namespace FirstPlugin.Forms
{
partial class ParamValueDialog
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.stPanel1 = new Switch_Toolbox.Library.Forms.STPanel();
this.stButton2 = new Switch_Toolbox.Library.Forms.STButton();
this.stButton1 = new Switch_Toolbox.Library.Forms.STButton();
this.contentContainer.SuspendLayout();
this.SuspendLayout();
//
// contentContainer
//
this.contentContainer.Controls.Add(this.stButton1);
this.contentContainer.Controls.Add(this.stButton2);
this.contentContainer.Controls.Add(this.stPanel1);
this.contentContainer.Controls.SetChildIndex(this.stPanel1, 0);
this.contentContainer.Controls.SetChildIndex(this.stButton2, 0);
this.contentContainer.Controls.SetChildIndex(this.stButton1, 0);
//
// stPanel1
//
this.stPanel1.Location = new System.Drawing.Point(5, 31);
this.stPanel1.Name = "stPanel1";
this.stPanel1.Size = new System.Drawing.Size(538, 327);
this.stPanel1.TabIndex = 11;
//
// stButton2
//
this.stButton2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.stButton2.DialogResult = System.Windows.Forms.DialogResult.OK;
this.stButton2.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.stButton2.Location = new System.Drawing.Point(384, 364);
this.stButton2.Name = "stButton2";
this.stButton2.Size = new System.Drawing.Size(75, 23);
this.stButton2.TabIndex = 13;
this.stButton2.Text = "Ok";
this.stButton2.UseVisualStyleBackColor = false;
//
// stButton1
//
this.stButton1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.stButton1.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.stButton1.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.stButton1.Location = new System.Drawing.Point(465, 364);
this.stButton1.Name = "stButton1";
this.stButton1.Size = new System.Drawing.Size(75, 23);
this.stButton1.TabIndex = 14;
this.stButton1.Text = "Cancel";
this.stButton1.UseVisualStyleBackColor = false;
//
// ParamValueDialog
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(549, 398);
this.Name = "ParamValueDialog";
this.Text = "ParamValueDialog";
this.contentContainer.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private Switch_Toolbox.Library.Forms.STPanel stPanel1;
private Switch_Toolbox.Library.Forms.STButton stButton1;
private Switch_Toolbox.Library.Forms.STButton stButton2;
}
}

View file

@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Switch_Toolbox.Library.Forms;
namespace FirstPlugin.Forms
{
public partial class ParamValueDialog : STForm
{
public ParamValueDialog()
{
InitializeComponent();
}
public void AddControl(UserControl control)
{
stPanel1.Controls.Clear();
stPanel1.Controls.Add(control);
}
}
}

View file

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View file

@ -28,35 +28,25 @@
/// </summary>
private void InitializeComponent()
{
this.stFlowLayoutPanel1 = new Switch_Toolbox.Library.Forms.STFlowLayoutPanel();
this.stButton1 = new Switch_Toolbox.Library.Forms.STButton();
this.stButton2 = new Switch_Toolbox.Library.Forms.STButton();
this.btnExport = new Switch_Toolbox.Library.Forms.STButton();
this.btnImport = new Switch_Toolbox.Library.Forms.STButton();
this.btnScrolDown = new Switch_Toolbox.Library.Forms.STButton();
this.btnScrollUp = new Switch_Toolbox.Library.Forms.STButton();
this.shaderParamListView = new Switch_Toolbox.Library.Forms.ListViewCustom();
this.columnHeader10 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.columnHeader11 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.columnHeader1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.columnHeader2 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.SuspendLayout();
//
// stFlowLayoutPanel1
//
this.stFlowLayoutPanel1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.stFlowLayoutPanel1.AutoScroll = true;
this.stFlowLayoutPanel1.FixedHeight = false;
this.stFlowLayoutPanel1.FixedWidth = true;
this.stFlowLayoutPanel1.FlowDirection = System.Windows.Forms.FlowDirection.TopDown;
this.stFlowLayoutPanel1.Location = new System.Drawing.Point(3, 29);
this.stFlowLayoutPanel1.Margin = new System.Windows.Forms.Padding(0);
this.stFlowLayoutPanel1.Name = "stFlowLayoutPanel1";
this.stFlowLayoutPanel1.Size = new System.Drawing.Size(413, 578);
this.stFlowLayoutPanel1.TabIndex = 0;
this.stFlowLayoutPanel1.WrapContents = false;
//
// stButton1
//
this.stButton1.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.stButton1.Location = new System.Drawing.Point(3, 3);
this.stButton1.Name = "stButton1";
this.stButton1.Size = new System.Drawing.Size(75, 23);
this.stButton1.Size = new System.Drawing.Size(57, 23);
this.stButton1.TabIndex = 1;
this.stButton1.Text = "Add";
this.stButton1.UseVisualStyleBackColor = false;
@ -64,9 +54,9 @@
// stButton2
//
this.stButton2.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.stButton2.Location = new System.Drawing.Point(84, 3);
this.stButton2.Location = new System.Drawing.Point(66, 3);
this.stButton2.Name = "stButton2";
this.stButton2.Size = new System.Drawing.Size(75, 23);
this.stButton2.Size = new System.Drawing.Size(62, 23);
this.stButton2.TabIndex = 2;
this.stButton2.Text = "Remove";
this.stButton2.UseVisualStyleBackColor = false;
@ -93,27 +83,102 @@
this.btnImport.UseVisualStyleBackColor = false;
this.btnImport.Click += new System.EventHandler(this.btnImport_Click);
//
// btnScrolDown
//
this.btnScrolDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.btnScrolDown.Enabled = false;
this.btnScrolDown.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnScrolDown.Location = new System.Drawing.Point(345, 64);
this.btnScrolDown.Name = "btnScrolDown";
this.btnScrolDown.Size = new System.Drawing.Size(32, 24);
this.btnScrolDown.TabIndex = 32;
this.btnScrolDown.Text = "▼";
this.btnScrolDown.UseVisualStyleBackColor = true;
//
// btnScrollUp
//
this.btnScrollUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.btnScrollUp.Enabled = false;
this.btnScrollUp.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnScrollUp.Location = new System.Drawing.Point(345, 35);
this.btnScrollUp.Name = "btnScrollUp";
this.btnScrollUp.Size = new System.Drawing.Size(32, 24);
this.btnScrollUp.TabIndex = 31;
this.btnScrollUp.Text = "▲";
this.btnScrollUp.UseVisualStyleBackColor = true;
//
// shaderParamListView
//
this.shaderParamListView.AllowColumnReorder = true;
this.shaderParamListView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.shaderParamListView.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.shaderParamListView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.columnHeader10,
this.columnHeader11,
this.columnHeader1,
this.columnHeader2});
this.shaderParamListView.Location = new System.Drawing.Point(3, 35);
this.shaderParamListView.MultiSelect = false;
this.shaderParamListView.Name = "shaderParamListView";
this.shaderParamListView.OwnerDraw = true;
this.shaderParamListView.Size = new System.Drawing.Size(336, 582);
this.shaderParamListView.TabIndex = 30;
this.shaderParamListView.UseCompatibleStateImageBehavior = false;
this.shaderParamListView.View = System.Windows.Forms.View.Details;
this.shaderParamListView.SelectedIndexChanged += new System.EventHandler(this.shaderParamListView_SelectedIndexChanged);
this.shaderParamListView.Click += new System.EventHandler(this.shaderParamListView_Click);
this.shaderParamListView.DoubleClick += new System.EventHandler(this.shaderParamListView_DoubleClick);
//
// columnHeader10
//
this.columnHeader10.Text = "Name";
this.columnHeader10.Width = 94;
//
// columnHeader11
//
this.columnHeader11.Text = "Value";
this.columnHeader11.Width = 122;
//
// columnHeader1
//
this.columnHeader1.Text = "Color (If Used)";
this.columnHeader1.Width = 120;
//
// columnHeader2
//
this.columnHeader2.Text = "";
this.columnHeader2.Width = 12;
//
// ShaderParamEditor
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.btnScrolDown);
this.Controls.Add(this.btnScrollUp);
this.Controls.Add(this.shaderParamListView);
this.Controls.Add(this.btnImport);
this.Controls.Add(this.btnExport);
this.Controls.Add(this.stButton2);
this.Controls.Add(this.stButton1);
this.Controls.Add(this.stFlowLayoutPanel1);
this.Name = "ShaderParamEditor";
this.Size = new System.Drawing.Size(420, 620);
this.Size = new System.Drawing.Size(380, 620);
this.ResumeLayout(false);
}
#endregion
private Switch_Toolbox.Library.Forms.STFlowLayoutPanel stFlowLayoutPanel1;
private Switch_Toolbox.Library.Forms.STButton stButton1;
private Switch_Toolbox.Library.Forms.STButton stButton2;
private Switch_Toolbox.Library.Forms.STButton btnExport;
private Switch_Toolbox.Library.Forms.STButton btnImport;
private Switch_Toolbox.Library.Forms.STButton btnScrolDown;
private Switch_Toolbox.Library.Forms.STButton btnScrollUp;
private Switch_Toolbox.Library.Forms.ListViewCustom shaderParamListView;
private System.Windows.Forms.ColumnHeader columnHeader10;
private System.Windows.Forms.ColumnHeader columnHeader11;
private System.Windows.Forms.ColumnHeader columnHeader1;
private System.Windows.Forms.ColumnHeader columnHeader2;
}
}

View file

@ -10,6 +10,7 @@ using System.Windows.Forms;
using Bfres.Structs;
using Syroot.NintenTools.NSW.Bfres;
using Switch_Toolbox.Library.Forms;
using OpenTK;
namespace FirstPlugin.Forms
{
@ -20,93 +21,194 @@ namespace FirstPlugin.Forms
InitializeComponent();
}
public ImageList il = new ImageList();
FMAT material;
public void InitializeShaderParamList(FMAT mat)
{
material = mat;
stFlowLayoutPanel1.SuspendLayout();
stFlowLayoutPanel1.Controls.Clear();
int CurParam = 0;
foreach (BfresShaderParam param in mat.matparam.Values)
shaderParamListView.Items.Clear();
foreach (BfresShaderParam prm in mat.matparam.Values)
{
if (param.Type == ShaderParamType.Bool ||
param.Type == ShaderParamType.Bool2 ||
param.Type == ShaderParamType.Bool3 ||
param.Type == ShaderParamType.Bool4)
string DisplayValue = "";
var item = new ListViewItem(prm.Name);
switch (prm.Type)
{
booleanPanel panel = new booleanPanel(param.ValueBool, param);
LoadDropPanel(panel, param);
case ShaderParamType.Float:
case ShaderParamType.Float2:
case ShaderParamType.Float2x2:
case ShaderParamType.Float2x3:
case ShaderParamType.Float2x4:
case ShaderParamType.Float3x2:
case ShaderParamType.Float3x3:
case ShaderParamType.Float3x4:
case ShaderParamType.Float4x2:
case ShaderParamType.Float4x3:
case ShaderParamType.Float4x4:
DisplayValue = SetValueToString(prm.ValueFloat);
break;
case ShaderParamType.Float3:
DisplayValue = SetValueToString(prm.ValueFloat);
break;
case ShaderParamType.Float4:
DisplayValue = SetValueToString(prm.ValueFloat);
break;
}
if (param.Type == ShaderParamType.TexSrt)
item.UseItemStyleForSubItems = false;
item.SubItems.Add(DisplayValue);
item.SubItems.Add("");
item.SubItems[2].BackColor = GetColor(prm);
shaderParamListView.View = View.Details;
shaderParamListView.Items.Add(item);
CurParam++;
}
il.ImageSize = new Size(10, 10);
shaderParamListView.SmallImageList = il;
shaderParamListView.FullRowSelect = true;
}
private Color GetColor(BfresShaderParam prm)
{
Vector4 col = new Vector4();
switch (prm.Type)
{
case ShaderParamType.Float3:
col = new Vector4(prm.ValueFloat[0], prm.ValueFloat[1], prm.ValueFloat[2], 1);
break;
case ShaderParamType.Float4:
col = new Vector4(prm.ValueFloat[0], prm.ValueFloat[1], prm.ValueFloat[2], prm.ValueFloat[3]);
break;
}
bool IsColor = prm.Name.Contains("Color") || prm.Name.Contains("color");
Color SetColor = Color.FromArgb(40, 40, 40);
if (IsColor)
{
int someIntX = (int)Math.Ceiling(col.X * 255);
int someIntY = (int)Math.Ceiling(col.Y * 255);
int someIntZ = (int)Math.Ceiling(col.Z * 255);
int someIntW = (int)Math.Ceiling(col.W * 255);
if (someIntX <= 255 && someIntY <= 255 && someIntZ <= 255 && someIntW <= 255)
{
TexSrtPanel panel = new TexSrtPanel(param.ValueTexSrt, param);
LoadDropPanel(panel, param);
}
if (param.Type == ShaderParamType.Float)
{
vector1SliderPanel panel = new vector1SliderPanel(param.ValueFloat, param);
LoadDropPanel(panel, param);
}
if (param.Type == ShaderParamType.Float2)
{
vector2SliderPanel panel = new vector2SliderPanel(param.ValueFloat, param);
LoadDropPanel(panel, param);
}
if (param.Type == ShaderParamType.Float3)
{
vector3SliderPanel panel = new vector3SliderPanel(param.Name, param.ValueFloat, param);
LoadDropPanel(panel, param);
}
if (param.Type == ShaderParamType.Float4)
{
vector4SliderPanel panel = new vector4SliderPanel(param.Name, param.ValueFloat, param);
LoadDropPanel(panel, param);
}
if (param.Type == ShaderParamType.UInt)
{
vector1SliderPanel panel = new vector1SliderPanel(param.ValueUint, param);
LoadDropPanel(panel, param);
}
if (param.Type == ShaderParamType.UInt2)
{
vector2SliderPanel panel = new vector2SliderPanel(param.ValueUint, param);
LoadDropPanel(panel, param);
}
if (param.Type == ShaderParamType.UInt3)
{
vector3SliderPanel panel = new vector3SliderPanel(param.Name, param.ValueUint, param);
LoadDropPanel(panel, param);
}
if (param.Type == ShaderParamType.UInt4)
{
vector4SliderPanel panel = new vector4SliderPanel(param.Name, param.ValueUint, param);
LoadDropPanel(panel, param);
}
if (param.Type == ShaderParamType.Int)
{
vector1SliderPanel panel = new vector1SliderPanel(param.ValueInt, param);
LoadDropPanel(panel, param);
}
if (param.Type == ShaderParamType.Int2)
{
vector2SliderPanel panel = new vector2SliderPanel(param.ValueInt, param);
LoadDropPanel(panel, param);
}
if (param.Type == ShaderParamType.Int3)
{
vector3SliderPanel panel = new vector3SliderPanel(param.Name, param.ValueInt, param);
LoadDropPanel(panel, param);
}
if (param.Type == ShaderParamType.Int4)
{
vector4SliderPanel panel = new vector4SliderPanel(param.Name, param.ValueInt, param);
LoadDropPanel(panel, param);
Console.WriteLine($"{prm.Name} R {someIntX} G {someIntY} B {someIntZ}");
SetColor = Color.FromArgb(
255,
someIntX,
someIntY,
someIntZ
);
}
}
return SetColor;
}
private string SetValueToString(object values)
{
if (values is float[])
return string.Join(" , ", values as float[]);
else if (values is bool[])
return string.Join(" , ", values as bool[]);
else if (values is int[])
return string.Join(" , ", values as int[]);
else if (values is uint[])
return string.Join(" , ", values as uint[]);
else
return "";
}
STFlowLayoutPanel stFlowLayoutPanel1;
private void LoadDropDownPanel(BfresShaderParam param)
{
stFlowLayoutPanel1 = new STFlowLayoutPanel();
stFlowLayoutPanel1.Dock = DockStyle.Fill;
stFlowLayoutPanel1.SuspendLayout();
if (param.Type == ShaderParamType.Bool ||
param.Type == ShaderParamType.Bool2 ||
param.Type == ShaderParamType.Bool3 ||
param.Type == ShaderParamType.Bool4)
{
booleanPanel panel = new booleanPanel(param.ValueBool, param);
LoadDropPanel(panel, param);
}
if (param.Type == ShaderParamType.TexSrt)
{
TexSrtPanel panel = new TexSrtPanel(param.ValueTexSrt, param);
LoadDropPanel(panel, param);
}
if (param.Type == ShaderParamType.Float)
{
vector1SliderPanel panel = new vector1SliderPanel(param.ValueFloat, param);
LoadDropPanel(panel, param);
}
if (param.Type == ShaderParamType.Float2)
{
vector2SliderPanel panel = new vector2SliderPanel(param.ValueFloat, param);
LoadDropPanel(panel, param);
}
if (param.Type == ShaderParamType.Float3)
{
vector3SliderPanel panel = new vector3SliderPanel(param.Name, param.ValueFloat, param);
LoadDropPanel(panel, param);
}
if (param.Type == ShaderParamType.Float4)
{
vector4SliderPanel panel = new vector4SliderPanel(param.Name, param.ValueFloat, param);
LoadDropPanel(panel, param);
}
if (param.Type == ShaderParamType.UInt)
{
vector1SliderPanel panel = new vector1SliderPanel(param.ValueUint, param);
LoadDropPanel(panel, param);
}
if (param.Type == ShaderParamType.UInt2)
{
vector2SliderPanel panel = new vector2SliderPanel(param.ValueUint, param);
LoadDropPanel(panel, param);
}
if (param.Type == ShaderParamType.UInt3)
{
vector3SliderPanel panel = new vector3SliderPanel(param.Name, param.ValueUint, param);
LoadDropPanel(panel, param);
}
if (param.Type == ShaderParamType.UInt4)
{
vector4SliderPanel panel = new vector4SliderPanel(param.Name, param.ValueUint, param);
LoadDropPanel(panel, param);
}
if (param.Type == ShaderParamType.Int)
{
vector1SliderPanel panel = new vector1SliderPanel(param.ValueInt, param);
LoadDropPanel(panel, param);
}
if (param.Type == ShaderParamType.Int2)
{
vector2SliderPanel panel = new vector2SliderPanel(param.ValueInt, param);
LoadDropPanel(panel, param);
}
if (param.Type == ShaderParamType.Int3)
{
vector3SliderPanel panel = new vector3SliderPanel(param.Name, param.ValueInt, param);
LoadDropPanel(panel, param);
}
if (param.Type == ShaderParamType.Int4)
{
vector4SliderPanel panel = new vector4SliderPanel(param.Name, param.ValueInt, param);
LoadDropPanel(panel, param);
}
stFlowLayoutPanel1.ResumeLayout();
}
@ -124,6 +226,37 @@ namespace FirstPlugin.Forms
return true;
}
public void LoadDialogDropPanel(ParamValueDialog control, BfresShaderParam param)
{
ParamValueEditorBase panel = new ParamValueEditorBase();
switch (param.Type)
{
case ShaderParamType.Float: panel = new vector1SliderPanel(param.ValueFloat, param); break;
case ShaderParamType.Float2: panel = new vector2SliderPanel(param.ValueFloat, param); break;
case ShaderParamType.Float3: panel = new vector3SliderPanel(param.Name, param.ValueFloat, param); break;
case ShaderParamType.Float4: panel = new vector4SliderPanel(param.Name, param.ValueFloat, param); break;
case ShaderParamType.Int: panel = new vector1SliderPanel(param.ValueFloat, param); break;
case ShaderParamType.Int2: panel = new vector2SliderPanel(param.ValueFloat, param); break;
case ShaderParamType.Int3: panel = new vector3SliderPanel(param.Name, param.ValueFloat, param); break;
case ShaderParamType.Int4: panel = new vector4SliderPanel(param.Name, param.ValueFloat, param); break;
case ShaderParamType.UInt: panel = new vector1SliderPanel(param.ValueFloat, param); break;
case ShaderParamType.UInt2: panel = new vector2SliderPanel(param.ValueFloat, param); break;
case ShaderParamType.UInt3: panel = new vector3SliderPanel(param.Name, param.ValueFloat, param); break;
case ShaderParamType.UInt4: panel = new vector4SliderPanel(param.Name, param.ValueFloat, param); break;
case ShaderParamType.TexSrt: panel = new TexSrtPanel(param.ValueTexSrt,param); break;
case ShaderParamType.Bool: panel = new booleanPanel(param.ValueBool, param); break;
case ShaderParamType.Bool2: panel = new booleanPanel(param.ValueBool, param); break;
case ShaderParamType.Bool3: panel = new booleanPanel(param.ValueBool, param); break;
case ShaderParamType.Bool4: panel = new booleanPanel(param.ValueBool, param); break;
}
control.Width = panel.Width;
control.Height = panel.Height + 70;
control.CanResize = false;
control.BackColor = FormThemes.BaseTheme.DropdownPanelBackColor;
control.AddControl(panel);
}
public void LoadDropPanel(ParamValueEditorBase control, BfresShaderParam param)
{
STDropDownPanel panel = new STDropDownPanel();
@ -220,5 +353,36 @@ namespace FirstPlugin.Forms
FMAT2XML.Read(material, ofd.FileName, true);
}
}
private void shaderParamListView_SelectedIndexChanged(object sender, EventArgs e)
{
}
private void shaderParamListView_Click(object sender, EventArgs e)
{
}
private void shaderParamListView_DoubleClick(object sender, EventArgs e)
{
if (shaderParamListView.SelectedItems.Count > 0)
{
var currentItem = shaderParamListView.SelectedItems[0];
if (material.matparam.ContainsKey(currentItem.Text))
{
ParamValueDialog dialog = new ParamValueDialog();
LoadDialogDropPanel(dialog, material.matparam[currentItem.Text]);
dialog.Location = currentItem.Position;
if (dialog.ShowDialog() == DialogResult.OK)
{
currentItem.SubItems[1].Text = GetValueString(material.matparam[currentItem.Text]);
currentItem.SubItems[2].BackColor = GetColor(material.matparam[currentItem.Text]);
}
}
}
}
}
}

View file

@ -38,6 +38,7 @@
this.rotXUD = new BarSlider.BarSlider();
this.transXUD = new BarSlider.BarSlider();
this.transYUD = new BarSlider.BarSlider();
this.stTextBox1 = new Switch_Toolbox.Library.Forms.STTextBox();
this.SuspendLayout();
//
// scalingModeCN
@ -46,7 +47,7 @@
this.scalingModeCN.BorderStyle = System.Windows.Forms.ButtonBorderStyle.Inset;
this.scalingModeCN.ButtonColor = System.Drawing.Color.Empty;
this.scalingModeCN.FormattingEnabled = true;
this.scalingModeCN.Location = new System.Drawing.Point(214, 25);
this.scalingModeCN.Location = new System.Drawing.Point(214, 33);
this.scalingModeCN.Name = "scalingModeCN";
this.scalingModeCN.ReadOnly = true;
this.scalingModeCN.Size = new System.Drawing.Size(121, 21);
@ -56,7 +57,7 @@
// stLabel1
//
this.stLabel1.AutoSize = true;
this.stLabel1.Location = new System.Drawing.Point(133, 28);
this.stLabel1.Location = new System.Drawing.Point(133, 36);
this.stLabel1.Name = "stLabel1";
this.stLabel1.Size = new System.Drawing.Size(75, 13);
this.stLabel1.TabIndex = 1;
@ -71,6 +72,7 @@
this.scaYUD.BarPenColorMiddle = System.Drawing.Color.FromArgb(((int)(((byte)(45)))), ((int)(((byte)(45)))), ((int)(((byte)(45)))));
this.scaYUD.BarPenColorTop = System.Drawing.Color.FromArgb(((int)(((byte)(40)))), ((int)(((byte)(40)))), ((int)(((byte)(40)))));
this.scaYUD.BorderRoundRectSize = new System.Drawing.Size(32, 32);
this.scaYUD.DataType = null;
this.scaYUD.DrawSemitransparentThumb = false;
this.scaYUD.ElapsedInnerColor = System.Drawing.Color.FromArgb(((int)(((byte)(60)))), ((int)(((byte)(60)))), ((int)(((byte)(60)))));
this.scaYUD.ElapsedPenColorBottom = System.Drawing.Color.FromArgb(((int)(((byte)(60)))), ((int)(((byte)(60)))), ((int)(((byte)(60)))));
@ -78,9 +80,10 @@
this.scaYUD.ElapsedPenColorTop = System.Drawing.Color.FromArgb(((int)(((byte)(60)))), ((int)(((byte)(60)))), ((int)(((byte)(60)))));
this.scaYUD.Font = new System.Drawing.Font("Microsoft Sans Serif", 8F);
this.scaYUD.ForeColor = System.Drawing.Color.White;
this.scaYUD.IncrementAmount = 0.01F;
this.scaYUD.InputName = "Y";
this.scaYUD.LargeChange = 5F;
this.scaYUD.Location = new System.Drawing.Point(204, 57);
this.scaYUD.Location = new System.Drawing.Point(204, 65);
this.scaYUD.Maximum = 100F;
this.scaYUD.Minimum = 0F;
this.scaYUD.Name = "scaYUD";
@ -108,7 +111,7 @@
// stLabel2
//
this.stLabel2.AutoSize = true;
this.stLabel2.Location = new System.Drawing.Point(7, 57);
this.stLabel2.Location = new System.Drawing.Point(7, 65);
this.stLabel2.Name = "stLabel2";
this.stLabel2.Size = new System.Drawing.Size(37, 13);
this.stLabel2.TabIndex = 2;
@ -117,7 +120,7 @@
// stLabel3
//
this.stLabel3.AutoSize = true;
this.stLabel3.Location = new System.Drawing.Point(7, 91);
this.stLabel3.Location = new System.Drawing.Point(7, 99);
this.stLabel3.Name = "stLabel3";
this.stLabel3.Size = new System.Drawing.Size(50, 13);
this.stLabel3.TabIndex = 3;
@ -126,7 +129,7 @@
// stLabel4
//
this.stLabel4.AutoSize = true;
this.stLabel4.Location = new System.Drawing.Point(0, 125);
this.stLabel4.Location = new System.Drawing.Point(0, 133);
this.stLabel4.Name = "stLabel4";
this.stLabel4.Size = new System.Drawing.Size(62, 13);
this.stLabel4.TabIndex = 4;
@ -141,6 +144,7 @@
this.scaXUD.BarPenColorMiddle = System.Drawing.Color.FromArgb(((int)(((byte)(45)))), ((int)(((byte)(45)))), ((int)(((byte)(45)))));
this.scaXUD.BarPenColorTop = System.Drawing.Color.FromArgb(((int)(((byte)(40)))), ((int)(((byte)(40)))), ((int)(((byte)(40)))));
this.scaXUD.BorderRoundRectSize = new System.Drawing.Size(32, 32);
this.scaXUD.DataType = null;
this.scaXUD.DrawSemitransparentThumb = false;
this.scaXUD.ElapsedInnerColor = System.Drawing.Color.FromArgb(((int)(((byte)(60)))), ((int)(((byte)(60)))), ((int)(((byte)(60)))));
this.scaXUD.ElapsedPenColorBottom = System.Drawing.Color.FromArgb(((int)(((byte)(60)))), ((int)(((byte)(60)))), ((int)(((byte)(60)))));
@ -148,9 +152,10 @@
this.scaXUD.ElapsedPenColorTop = System.Drawing.Color.FromArgb(((int)(((byte)(60)))), ((int)(((byte)(60)))), ((int)(((byte)(60)))));
this.scaXUD.Font = new System.Drawing.Font("Microsoft Sans Serif", 8F);
this.scaXUD.ForeColor = System.Drawing.Color.White;
this.scaXUD.IncrementAmount = 0.01F;
this.scaXUD.InputName = "X";
this.scaXUD.LargeChange = 5F;
this.scaXUD.Location = new System.Drawing.Point(67, 57);
this.scaXUD.Location = new System.Drawing.Point(67, 65);
this.scaXUD.Maximum = 100F;
this.scaXUD.Minimum = 0F;
this.scaXUD.Name = "scaXUD";
@ -184,6 +189,7 @@
this.rotXUD.BarPenColorMiddle = System.Drawing.Color.FromArgb(((int)(((byte)(45)))), ((int)(((byte)(45)))), ((int)(((byte)(45)))));
this.rotXUD.BarPenColorTop = System.Drawing.Color.FromArgb(((int)(((byte)(40)))), ((int)(((byte)(40)))), ((int)(((byte)(40)))));
this.rotXUD.BorderRoundRectSize = new System.Drawing.Size(32, 32);
this.rotXUD.DataType = null;
this.rotXUD.DrawSemitransparentThumb = false;
this.rotXUD.ElapsedInnerColor = System.Drawing.Color.FromArgb(((int)(((byte)(60)))), ((int)(((byte)(60)))), ((int)(((byte)(60)))));
this.rotXUD.ElapsedPenColorBottom = System.Drawing.Color.FromArgb(((int)(((byte)(60)))), ((int)(((byte)(60)))), ((int)(((byte)(60)))));
@ -191,9 +197,10 @@
this.rotXUD.ElapsedPenColorTop = System.Drawing.Color.FromArgb(((int)(((byte)(60)))), ((int)(((byte)(60)))), ((int)(((byte)(60)))));
this.rotXUD.Font = new System.Drawing.Font("Microsoft Sans Serif", 8F);
this.rotXUD.ForeColor = System.Drawing.Color.White;
this.rotXUD.IncrementAmount = 0.01F;
this.rotXUD.InputName = "X";
this.rotXUD.LargeChange = 5F;
this.rotXUD.Location = new System.Drawing.Point(67, 88);
this.rotXUD.Location = new System.Drawing.Point(67, 96);
this.rotXUD.Maximum = 100F;
this.rotXUD.Minimum = 0F;
this.rotXUD.Name = "rotXUD";
@ -227,6 +234,7 @@
this.transXUD.BarPenColorMiddle = System.Drawing.Color.FromArgb(((int)(((byte)(45)))), ((int)(((byte)(45)))), ((int)(((byte)(45)))));
this.transXUD.BarPenColorTop = System.Drawing.Color.FromArgb(((int)(((byte)(40)))), ((int)(((byte)(40)))), ((int)(((byte)(40)))));
this.transXUD.BorderRoundRectSize = new System.Drawing.Size(32, 32);
this.transXUD.DataType = null;
this.transXUD.DrawSemitransparentThumb = false;
this.transXUD.ElapsedInnerColor = System.Drawing.Color.FromArgb(((int)(((byte)(60)))), ((int)(((byte)(60)))), ((int)(((byte)(60)))));
this.transXUD.ElapsedPenColorBottom = System.Drawing.Color.FromArgb(((int)(((byte)(60)))), ((int)(((byte)(60)))), ((int)(((byte)(60)))));
@ -234,9 +242,10 @@
this.transXUD.ElapsedPenColorTop = System.Drawing.Color.FromArgb(((int)(((byte)(60)))), ((int)(((byte)(60)))), ((int)(((byte)(60)))));
this.transXUD.Font = new System.Drawing.Font("Microsoft Sans Serif", 8F);
this.transXUD.ForeColor = System.Drawing.Color.White;
this.transXUD.IncrementAmount = 0.01F;
this.transXUD.InputName = "X";
this.transXUD.LargeChange = 5F;
this.transXUD.Location = new System.Drawing.Point(67, 119);
this.transXUD.Location = new System.Drawing.Point(67, 127);
this.transXUD.Maximum = 100F;
this.transXUD.Minimum = 0F;
this.transXUD.Name = "transXUD";
@ -270,6 +279,7 @@
this.transYUD.BarPenColorMiddle = System.Drawing.Color.FromArgb(((int)(((byte)(45)))), ((int)(((byte)(45)))), ((int)(((byte)(45)))));
this.transYUD.BarPenColorTop = System.Drawing.Color.FromArgb(((int)(((byte)(40)))), ((int)(((byte)(40)))), ((int)(((byte)(40)))));
this.transYUD.BorderRoundRectSize = new System.Drawing.Size(32, 32);
this.transYUD.DataType = null;
this.transYUD.DrawSemitransparentThumb = false;
this.transYUD.ElapsedInnerColor = System.Drawing.Color.FromArgb(((int)(((byte)(60)))), ((int)(((byte)(60)))), ((int)(((byte)(60)))));
this.transYUD.ElapsedPenColorBottom = System.Drawing.Color.FromArgb(((int)(((byte)(60)))), ((int)(((byte)(60)))), ((int)(((byte)(60)))));
@ -277,9 +287,10 @@
this.transYUD.ElapsedPenColorTop = System.Drawing.Color.FromArgb(((int)(((byte)(60)))), ((int)(((byte)(60)))), ((int)(((byte)(60)))));
this.transYUD.Font = new System.Drawing.Font("Microsoft Sans Serif", 8F);
this.transYUD.ForeColor = System.Drawing.Color.White;
this.transYUD.IncrementAmount = 0.01F;
this.transYUD.InputName = "Y";
this.transYUD.LargeChange = 5F;
this.transYUD.Location = new System.Drawing.Point(204, 119);
this.transYUD.Location = new System.Drawing.Point(204, 127);
this.transYUD.Maximum = 100F;
this.transYUD.Minimum = 0F;
this.transYUD.Name = "transYUD";
@ -304,10 +315,20 @@
this.transYUD.Value = 30F;
this.transYUD.ValueChanged += new System.EventHandler(this.barSlider_ValueChanged);
//
// stTextBox1
//
this.stTextBox1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.stTextBox1.Location = new System.Drawing.Point(3, 3);
this.stTextBox1.Name = "stTextBox1";
this.stTextBox1.ReadOnly = true;
this.stTextBox1.Size = new System.Drawing.Size(332, 20);
this.stTextBox1.TabIndex = 10;
//
// TexSrtPanel
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.stTextBox1);
this.Controls.Add(this.transXUD);
this.Controls.Add(this.transYUD);
this.Controls.Add(this.rotXUD);
@ -319,7 +340,7 @@
this.Controls.Add(this.stLabel1);
this.Controls.Add(this.scalingModeCN);
this.Name = "TexSrtPanel";
this.Size = new System.Drawing.Size(338, 150);
this.Size = new System.Drawing.Size(338, 155);
this.ResumeLayout(false);
this.PerformLayout();
@ -337,5 +358,6 @@
private BarSlider.BarSlider rotXUD;
private BarSlider.BarSlider transXUD;
private BarSlider.BarSlider transYUD;
private Switch_Toolbox.Library.Forms.STTextBox stTextBox1;
}
}

View file

@ -17,10 +17,11 @@ namespace FirstPlugin.Forms
{
public TexSrtPanel(TexSrt TexSrt, BfresShaderParam param)
{
activeParam = param;
InitializeComponent();
activeParam = param;
stTextBox1.Bind(activeParam, "Name");
scalingModeCN.Bind(typeof(TexSrtMode), TexSrt, "Mode");
scalingModeCN.SelectedItem = TexSrt.Mode;

View file

@ -32,6 +32,7 @@
this.stCheckBox2 = new Switch_Toolbox.Library.Forms.STCheckBox();
this.stCheckBox3 = new Switch_Toolbox.Library.Forms.STCheckBox();
this.stCheckBox4 = new Switch_Toolbox.Library.Forms.STCheckBox();
this.stTextBox1 = new Switch_Toolbox.Library.Forms.STTextBox();
this.SuspendLayout();
//
// stCheckBox1
@ -74,16 +75,26 @@
this.stCheckBox4.Text = "Value4";
this.stCheckBox4.UseVisualStyleBackColor = true;
//
// stTextBox1
//
this.stTextBox1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.stTextBox1.Location = new System.Drawing.Point(3, 2);
this.stTextBox1.Name = "stTextBox1";
this.stTextBox1.ReadOnly = true;
this.stTextBox1.Size = new System.Drawing.Size(276, 20);
this.stTextBox1.TabIndex = 6;
//
// booleanPanel
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.stTextBox1);
this.Controls.Add(this.stCheckBox3);
this.Controls.Add(this.stCheckBox4);
this.Controls.Add(this.stCheckBox2);
this.Controls.Add(this.stCheckBox1);
this.Name = "booleanPanel";
this.Size = new System.Drawing.Size(282, 78);
this.Size = new System.Drawing.Size(282, 82);
this.ResumeLayout(false);
this.PerformLayout();
@ -94,5 +105,6 @@
private Switch_Toolbox.Library.Forms.STCheckBox stCheckBox2;
private Switch_Toolbox.Library.Forms.STCheckBox stCheckBox3;
private Switch_Toolbox.Library.Forms.STCheckBox stCheckBox4;
private Switch_Toolbox.Library.Forms.STTextBox stTextBox1;
}
}

View file

@ -8,10 +8,11 @@ namespace FirstPlugin.Forms
{
public booleanPanel(bool[] values, BfresShaderParam param)
{
activeParam = param;
InitializeComponent();
activeParam = param;
stTextBox1.Bind(activeParam, "Name");
if (values.Length >= 1)
stCheckBox1.Checked = values[0];
if (values.Length >= 2)

View file

@ -29,6 +29,7 @@
private void InitializeComponent()
{
this.barSlider1 = new BarSlider.BarSlider();
this.stTextBox1 = new Switch_Toolbox.Library.Forms.STTextBox();
this.SuspendLayout();
//
// barSlider1
@ -41,15 +42,20 @@
this.barSlider1.BarPenColorMiddle = System.Drawing.Color.FromArgb(((int)(((byte)(45)))), ((int)(((byte)(45)))), ((int)(((byte)(45)))));
this.barSlider1.BarPenColorTop = System.Drawing.Color.FromArgb(((int)(((byte)(40)))), ((int)(((byte)(40)))), ((int)(((byte)(40)))));
this.barSlider1.BorderRoundRectSize = new System.Drawing.Size(32, 32);
this.barSlider1.DataType = null;
this.barSlider1.DrawSemitransparentThumb = false;
this.barSlider1.ElapsedInnerColor = System.Drawing.Color.FromArgb(((int)(((byte)(60)))), ((int)(((byte)(60)))), ((int)(((byte)(60)))));
this.barSlider1.ElapsedPenColorBottom = System.Drawing.Color.FromArgb(((int)(((byte)(60)))), ((int)(((byte)(60)))), ((int)(((byte)(60)))));
this.barSlider1.ElapsedPenColorMiddle = System.Drawing.Color.FromArgb(((int)(((byte)(65)))), ((int)(((byte)(65)))), ((int)(((byte)(65)))));
this.barSlider1.ElapsedPenColorTop = System.Drawing.Color.FromArgb(((int)(((byte)(60)))), ((int)(((byte)(60)))), ((int)(((byte)(60)))));
this.barSlider1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8F);
this.barSlider1.ForeColor = this.ForeColor;
this.barSlider1.IncrementAmount = 0.01F;
this.barSlider1.InputName = "X";
this.barSlider1.LargeChange = 5F;
this.barSlider1.Location = new System.Drawing.Point(3, 24);
this.barSlider1.Location = new System.Drawing.Point(3, 29);
this.barSlider1.Maximum = 300000F;
this.barSlider1.Minimum = -300000F;
this.barSlider1.Name = "barSlider1";
this.barSlider1.Precision = 0.01F;
this.barSlider1.ScaleDivisions = 1;
@ -71,23 +77,32 @@
this.barSlider1.UseInterlapsedBar = false;
this.barSlider1.Value = 30F;
this.barSlider1.ValueChanged += new System.EventHandler(this.barSlider1_ValueChanged);
this.barSlider1.Maximum = 300000;
this.barSlider1.Minimum = -300000;
this.barSlider1.ForeColor = this.ForeColor;
//
// stTextBox1
//
this.stTextBox1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.stTextBox1.Location = new System.Drawing.Point(3, 3);
this.stTextBox1.Name = "stTextBox1";
this.stTextBox1.ReadOnly = true;
this.stTextBox1.Size = new System.Drawing.Size(276, 20);
this.stTextBox1.TabIndex = 2;
//
// vector1SliderPanel
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.stTextBox1);
this.Controls.Add(this.barSlider1);
this.Name = "vector1SliderPanel";
this.Size = new System.Drawing.Size(282, 52);
this.Size = new System.Drawing.Size(282, 57);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private BarSlider.BarSlider barSlider1;
private Switch_Toolbox.Library.Forms.STTextBox stTextBox1;
}
}

View file

@ -6,8 +6,10 @@ namespace FirstPlugin.Forms
public partial class vector1SliderPanel : ParamValueEditorBase
{
public vector1SliderPanel(float[] values, BfresShaderParam param) {
activeParam = param;
InitializeComponent();
activeParam = param;
stTextBox1.Bind(activeParam, "Name");
barSlider1.DataType = typeof(float);
barSlider1.Value = values[0];
@ -15,8 +17,10 @@ namespace FirstPlugin.Forms
public vector1SliderPanel(int[] values, BfresShaderParam param)
{
activeParam = param;
InitializeComponent();
activeParam = param;
stTextBox1.Bind(activeParam, "Name");
barSlider1.DataType = typeof(int);
barSlider1.Value = values[0];
@ -24,8 +28,10 @@ namespace FirstPlugin.Forms
public vector1SliderPanel(uint[] values, BfresShaderParam param)
{
activeParam = param;
InitializeComponent();
activeParam = param;
stTextBox1.Bind(activeParam, "Name");
barSlider1.DataType = typeof(uint);
barSlider1.Value = values[0];

View file

@ -30,6 +30,7 @@
{
this.barSlider1 = new BarSlider.BarSlider();
this.barSlider2 = new BarSlider.BarSlider();
this.stTextBox1 = new Switch_Toolbox.Library.Forms.STTextBox();
this.SuspendLayout();
//
// barSlider1
@ -42,18 +43,20 @@
this.barSlider1.BarPenColorMiddle = System.Drawing.Color.FromArgb(((int)(((byte)(45)))), ((int)(((byte)(45)))), ((int)(((byte)(45)))));
this.barSlider1.BarPenColorTop = System.Drawing.Color.FromArgb(((int)(((byte)(40)))), ((int)(((byte)(40)))), ((int)(((byte)(40)))));
this.barSlider1.BorderRoundRectSize = new System.Drawing.Size(32, 32);
this.barSlider1.DataType = null;
this.barSlider1.DrawSemitransparentThumb = false;
this.barSlider1.ElapsedInnerColor = System.Drawing.Color.FromArgb(((int)(((byte)(60)))), ((int)(((byte)(60)))), ((int)(((byte)(60)))));
this.barSlider1.ElapsedPenColorBottom = System.Drawing.Color.FromArgb(((int)(((byte)(60)))), ((int)(((byte)(60)))), ((int)(((byte)(60)))));
this.barSlider1.ElapsedPenColorMiddle = System.Drawing.Color.FromArgb(((int)(((byte)(65)))), ((int)(((byte)(65)))), ((int)(((byte)(65)))));
this.barSlider1.ElapsedPenColorTop = System.Drawing.Color.FromArgb(((int)(((byte)(60)))), ((int)(((byte)(60)))), ((int)(((byte)(60)))));
this.barSlider1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8F);
this.barSlider1.ForeColor = System.Drawing.Color.White;
this.barSlider1.ForeColor = this.ForeColor;
this.barSlider1.IncrementAmount = 0.01F;
this.barSlider1.InputName = "X";
this.barSlider1.LargeChange = 5F;
this.barSlider1.Location = new System.Drawing.Point(3, 24);
this.barSlider1.Maximum = 100F;
this.barSlider1.Minimum = 0F;
this.barSlider1.Location = new System.Drawing.Point(3, 29);
this.barSlider1.Maximum = 300000F;
this.barSlider1.Minimum = -300000F;
this.barSlider1.Name = "barSlider1";
this.barSlider1.Precision = 0.01F;
this.barSlider1.ScaleDivisions = 1;
@ -86,18 +89,20 @@
this.barSlider2.BarPenColorMiddle = System.Drawing.Color.FromArgb(((int)(((byte)(45)))), ((int)(((byte)(45)))), ((int)(((byte)(45)))));
this.barSlider2.BarPenColorTop = System.Drawing.Color.FromArgb(((int)(((byte)(40)))), ((int)(((byte)(40)))), ((int)(((byte)(40)))));
this.barSlider2.BorderRoundRectSize = new System.Drawing.Size(32, 32);
this.barSlider2.DataType = null;
this.barSlider2.DrawSemitransparentThumb = false;
this.barSlider2.ElapsedInnerColor = System.Drawing.Color.FromArgb(((int)(((byte)(60)))), ((int)(((byte)(60)))), ((int)(((byte)(60)))));
this.barSlider2.ElapsedPenColorBottom = System.Drawing.Color.FromArgb(((int)(((byte)(60)))), ((int)(((byte)(60)))), ((int)(((byte)(60)))));
this.barSlider2.ElapsedPenColorMiddle = System.Drawing.Color.FromArgb(((int)(((byte)(65)))), ((int)(((byte)(65)))), ((int)(((byte)(65)))));
this.barSlider2.ElapsedPenColorTop = System.Drawing.Color.FromArgb(((int)(((byte)(60)))), ((int)(((byte)(60)))), ((int)(((byte)(60)))));
this.barSlider2.Font = new System.Drawing.Font("Microsoft Sans Serif", 8F);
this.barSlider2.ForeColor = System.Drawing.Color.White;
this.barSlider2.ForeColor = this.ForeColor;
this.barSlider2.IncrementAmount = 0.01F;
this.barSlider2.InputName = "Y";
this.barSlider2.LargeChange = 5F;
this.barSlider2.Location = new System.Drawing.Point(143, 24);
this.barSlider2.Maximum = 100F;
this.barSlider2.Minimum = 0F;
this.barSlider2.Location = new System.Drawing.Point(143, 29);
this.barSlider2.Maximum = 300000F;
this.barSlider2.Minimum = -300000F;
this.barSlider2.Name = "barSlider2";
this.barSlider2.Precision = 0.01F;
this.barSlider2.ScaleDivisions = 1;
@ -119,25 +124,27 @@
this.barSlider2.UseInterlapsedBar = false;
this.barSlider2.Value = 30F;
this.barSlider2.ValueChanged += new System.EventHandler(this.barSlider_ValueChanged);
this.barSlider1.Maximum = 300000;
this.barSlider2.Maximum = 300000;
this.barSlider1.Minimum = -300000;
this.barSlider2.Minimum = -300000;
this.barSlider1.ForeColor = this.ForeColor;
this.barSlider2.ForeColor = this.ForeColor;
//
// stTextBox1
//
this.stTextBox1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.stTextBox1.Location = new System.Drawing.Point(3, 3);
this.stTextBox1.Name = "stTextBox1";
this.stTextBox1.ReadOnly = true;
this.stTextBox1.Size = new System.Drawing.Size(276, 20);
this.stTextBox1.TabIndex = 4;
//
// vector2SliderPanel
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.stTextBox1);
this.Controls.Add(this.barSlider2);
this.Controls.Add(this.barSlider1);
this.Name = "vector2SliderPanel";
this.Size = new System.Drawing.Size(282, 52);
this.Size = new System.Drawing.Size(282, 57);
this.ResumeLayout(false);
this.PerformLayout();
}
@ -145,5 +152,6 @@
private BarSlider.BarSlider barSlider1;
private BarSlider.BarSlider barSlider2;
private Switch_Toolbox.Library.Forms.STTextBox stTextBox1;
}
}

View file

@ -7,9 +7,11 @@ namespace FirstPlugin.Forms
{
public vector2SliderPanel(float[] values, BfresShaderParam param)
{
activeParam = param;
InitializeComponent();
activeParam = param;
stTextBox1.Bind(activeParam, "Name");
barSlider1.DataType = typeof(float);
barSlider2.DataType = typeof(float);
@ -19,9 +21,11 @@ namespace FirstPlugin.Forms
public vector2SliderPanel(int[] values, BfresShaderParam param)
{
activeParam = param;
InitializeComponent();
activeParam = param;
stTextBox1.Bind(activeParam, "Name");
barSlider1.DataType = typeof(int);
barSlider2.DataType = typeof(int);
@ -31,9 +35,11 @@ namespace FirstPlugin.Forms
public vector2SliderPanel(uint[] values, BfresShaderParam param)
{
activeParam = param;
InitializeComponent();
activeParam = param;
stTextBox1.Bind(activeParam, "Name");
barSlider1.DataType = typeof(uint);
barSlider2.DataType = typeof(uint);

View file

@ -32,6 +32,7 @@
this.barSlider2 = new BarSlider.BarSlider();
this.barSlider3 = new BarSlider.BarSlider();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.stTextBox1 = new Switch_Toolbox.Library.Forms.STTextBox();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
this.SuspendLayout();
//
@ -45,6 +46,7 @@
this.barSlider1.BarPenColorMiddle = System.Drawing.Color.FromArgb(((int)(((byte)(45)))), ((int)(((byte)(45)))), ((int)(((byte)(45)))));
this.barSlider1.BarPenColorTop = System.Drawing.Color.FromArgb(((int)(((byte)(40)))), ((int)(((byte)(40)))), ((int)(((byte)(40)))));
this.barSlider1.BorderRoundRectSize = new System.Drawing.Size(32, 32);
this.barSlider1.DataType = null;
this.barSlider1.DrawSemitransparentThumb = false;
this.barSlider1.ElapsedInnerColor = System.Drawing.Color.FromArgb(((int)(((byte)(60)))), ((int)(((byte)(60)))), ((int)(((byte)(60)))));
this.barSlider1.ElapsedPenColorBottom = System.Drawing.Color.FromArgb(((int)(((byte)(60)))), ((int)(((byte)(60)))), ((int)(((byte)(60)))));
@ -52,9 +54,10 @@
this.barSlider1.ElapsedPenColorTop = System.Drawing.Color.FromArgb(((int)(((byte)(60)))), ((int)(((byte)(60)))), ((int)(((byte)(60)))));
this.barSlider1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8F);
this.barSlider1.ForeColor = System.Drawing.Color.White;
this.barSlider1.IncrementAmount = 0.01F;
this.barSlider1.InputName = "X";
this.barSlider1.LargeChange = 5F;
this.barSlider1.Location = new System.Drawing.Point(3, 23);
this.barSlider1.Location = new System.Drawing.Point(3, 29);
this.barSlider1.Maximum = 100F;
this.barSlider1.Minimum = 0F;
this.barSlider1.Name = "barSlider1";
@ -89,6 +92,7 @@
this.barSlider2.BarPenColorMiddle = System.Drawing.Color.FromArgb(((int)(((byte)(45)))), ((int)(((byte)(45)))), ((int)(((byte)(45)))));
this.barSlider2.BarPenColorTop = System.Drawing.Color.FromArgb(((int)(((byte)(40)))), ((int)(((byte)(40)))), ((int)(((byte)(40)))));
this.barSlider2.BorderRoundRectSize = new System.Drawing.Size(32, 32);
this.barSlider2.DataType = null;
this.barSlider2.DrawSemitransparentThumb = false;
this.barSlider2.ElapsedInnerColor = System.Drawing.Color.FromArgb(((int)(((byte)(60)))), ((int)(((byte)(60)))), ((int)(((byte)(60)))));
this.barSlider2.ElapsedPenColorBottom = System.Drawing.Color.FromArgb(((int)(((byte)(60)))), ((int)(((byte)(60)))), ((int)(((byte)(60)))));
@ -96,9 +100,10 @@
this.barSlider2.ElapsedPenColorTop = System.Drawing.Color.FromArgb(((int)(((byte)(60)))), ((int)(((byte)(60)))), ((int)(((byte)(60)))));
this.barSlider2.Font = new System.Drawing.Font("Microsoft Sans Serif", 8F);
this.barSlider2.ForeColor = System.Drawing.Color.White;
this.barSlider2.IncrementAmount = 0.01F;
this.barSlider2.InputName = "Y";
this.barSlider2.LargeChange = 5F;
this.barSlider2.Location = new System.Drawing.Point(141, 23);
this.barSlider2.Location = new System.Drawing.Point(141, 29);
this.barSlider2.Maximum = 100F;
this.barSlider2.Minimum = 0F;
this.barSlider2.Name = "barSlider2";
@ -133,6 +138,7 @@
this.barSlider3.BarPenColorMiddle = System.Drawing.Color.FromArgb(((int)(((byte)(45)))), ((int)(((byte)(45)))), ((int)(((byte)(45)))));
this.barSlider3.BarPenColorTop = System.Drawing.Color.FromArgb(((int)(((byte)(40)))), ((int)(((byte)(40)))), ((int)(((byte)(40)))));
this.barSlider3.BorderRoundRectSize = new System.Drawing.Size(32, 32);
this.barSlider3.DataType = null;
this.barSlider3.DrawSemitransparentThumb = false;
this.barSlider3.ElapsedInnerColor = System.Drawing.Color.FromArgb(((int)(((byte)(60)))), ((int)(((byte)(60)))), ((int)(((byte)(60)))));
this.barSlider3.ElapsedPenColorBottom = System.Drawing.Color.FromArgb(((int)(((byte)(60)))), ((int)(((byte)(60)))), ((int)(((byte)(60)))));
@ -140,9 +146,10 @@
this.barSlider3.ElapsedPenColorTop = System.Drawing.Color.FromArgb(((int)(((byte)(60)))), ((int)(((byte)(60)))), ((int)(((byte)(60)))));
this.barSlider3.Font = new System.Drawing.Font("Microsoft Sans Serif", 8F);
this.barSlider3.ForeColor = System.Drawing.Color.White;
this.barSlider3.IncrementAmount = 0.01F;
this.barSlider3.InputName = "Z";
this.barSlider3.LargeChange = 5F;
this.barSlider3.Location = new System.Drawing.Point(3, 49);
this.barSlider3.Location = new System.Drawing.Point(3, 55);
this.barSlider3.Maximum = 100F;
this.barSlider3.Minimum = 0F;
this.barSlider3.Name = "barSlider3";
@ -169,25 +176,37 @@
//
// pictureBox1
//
this.pictureBox1.Location = new System.Drawing.Point(141, 49);
this.pictureBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.pictureBox1.Location = new System.Drawing.Point(141, 56);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(137, 25);
this.pictureBox1.TabIndex = 7;
this.pictureBox1.TabStop = false;
this.pictureBox1.Click += new System.EventHandler(this.pictureBox1_Click);
//
// stTextBox1
//
this.stTextBox1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.stTextBox1.Location = new System.Drawing.Point(3, 3);
this.stTextBox1.Name = "stTextBox1";
this.stTextBox1.ReadOnly = true;
this.stTextBox1.Size = new System.Drawing.Size(275, 20);
this.stTextBox1.TabIndex = 8;
//
// vector3SliderPanel
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.stTextBox1);
this.Controls.Add(this.pictureBox1);
this.Controls.Add(this.barSlider3);
this.Controls.Add(this.barSlider2);
this.Controls.Add(this.barSlider1);
this.Name = "vector3SliderPanel";
this.Size = new System.Drawing.Size(284, 77);
this.Size = new System.Drawing.Size(284, 83);
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
@ -197,5 +216,6 @@
private BarSlider.BarSlider barSlider2;
private BarSlider.BarSlider barSlider3;
private System.Windows.Forms.PictureBox pictureBox1;
private Switch_Toolbox.Library.Forms.STTextBox stTextBox1;
}
}

View file

@ -21,9 +21,11 @@ namespace FirstPlugin.Forms
public vector3SliderPanel(string UniformName, float[] values, BfresShaderParam param)
{
activeParam = param;
InitializeComponent();
activeParam = param;
stTextBox1.Bind(activeParam, "Name");
barSlider1.DataType = typeof(float);
barSlider2.DataType = typeof(float);
barSlider3.DataType = typeof(float);
@ -37,9 +39,11 @@ namespace FirstPlugin.Forms
public vector3SliderPanel(string UniformName, int[] values, BfresShaderParam param)
{
activeParam = param;
InitializeComponent();
activeParam = param;
stTextBox1.Bind(activeParam, "Name");
barSlider1.DataType = typeof(int);
barSlider2.DataType = typeof(int);
barSlider3.DataType = typeof(int);
@ -51,9 +55,11 @@ namespace FirstPlugin.Forms
public vector3SliderPanel(string UniformName, uint[] values, BfresShaderParam param)
{
activeParam = param;
InitializeComponent();
activeParam = param;
stTextBox1.Bind(activeParam, "Name");
barSlider1.DataType = typeof(uint);
barSlider2.DataType = typeof(int);
barSlider3.DataType = typeof(int);
@ -74,6 +80,10 @@ namespace FirstPlugin.Forms
if (IsColor)
{
barSlider1.Minimum = 0;
barSlider2.Minimum = 0;
barSlider3.Minimum = 0;
var SetColor = Color.FromArgb(255,
Utils.FloatToIntClamp(values[0]),
Utils.FloatToIntClamp(values[1]),

View file

@ -34,13 +34,14 @@
this.barSlider3 = new BarSlider.BarSlider();
this.barSlider2 = new BarSlider.BarSlider();
this.barSlider1 = new BarSlider.BarSlider();
this.stTextBox1 = new Switch_Toolbox.Library.Forms.STTextBox();
((System.ComponentModel.ISupportInitialize)(this.alphaPB)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.colorPB)).BeginInit();
this.SuspendLayout();
//
// alphaPB
//
this.alphaPB.Location = new System.Drawing.Point(207, 27);
this.alphaPB.Location = new System.Drawing.Point(208, 29);
this.alphaPB.Name = "alphaPB";
this.alphaPB.Size = new System.Drawing.Size(71, 16);
this.alphaPB.TabIndex = 6;
@ -49,7 +50,7 @@
//
// colorPB
//
this.colorPB.Location = new System.Drawing.Point(140, 27);
this.colorPB.Location = new System.Drawing.Point(141, 29);
this.colorPB.Name = "colorPB";
this.colorPB.Size = new System.Drawing.Size(63, 16);
this.colorPB.TabIndex = 7;
@ -77,7 +78,7 @@
this.barSlider4.IncrementAmount = 0.01F;
this.barSlider4.InputName = "W";
this.barSlider4.LargeChange = 5F;
this.barSlider4.Location = new System.Drawing.Point(141, 72);
this.barSlider4.Location = new System.Drawing.Point(141, 77);
this.barSlider4.Maximum = 100F;
this.barSlider4.Minimum = 0F;
this.barSlider4.Name = "barSlider4";
@ -123,7 +124,7 @@
this.barSlider3.IncrementAmount = 0.01F;
this.barSlider3.InputName = "Z";
this.barSlider3.LargeChange = 5F;
this.barSlider3.Location = new System.Drawing.Point(3, 72);
this.barSlider3.Location = new System.Drawing.Point(3, 77);
this.barSlider3.Maximum = 100F;
this.barSlider3.Minimum = 0F;
this.barSlider3.Name = "barSlider3";
@ -169,7 +170,7 @@
this.barSlider2.IncrementAmount = 0.01F;
this.barSlider2.InputName = "Y";
this.barSlider2.LargeChange = 5F;
this.barSlider2.Location = new System.Drawing.Point(141, 46);
this.barSlider2.Location = new System.Drawing.Point(141, 51);
this.barSlider2.Maximum = 100F;
this.barSlider2.Minimum = 0F;
this.barSlider2.Name = "barSlider2";
@ -215,7 +216,7 @@
this.barSlider1.IncrementAmount = 0.01F;
this.barSlider1.InputName = "X";
this.barSlider1.LargeChange = 5F;
this.barSlider1.Location = new System.Drawing.Point(3, 46);
this.barSlider1.Location = new System.Drawing.Point(3, 51);
this.barSlider1.Maximum = 100F;
this.barSlider1.Minimum = 0F;
this.barSlider1.Name = "barSlider1";
@ -241,10 +242,20 @@
this.barSlider1.ValueChanged += new System.EventHandler(this.barSlider_ValueChanged);
this.barSlider1.Scroll += new System.Windows.Forms.ScrollEventHandler(this.barSlider1_Scroll);
//
// stTextBox1
//
this.stTextBox1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.stTextBox1.Location = new System.Drawing.Point(3, 3);
this.stTextBox1.Name = "stTextBox1";
this.stTextBox1.ReadOnly = true;
this.stTextBox1.Size = new System.Drawing.Size(275, 20);
this.stTextBox1.TabIndex = 8;
//
// vector4SliderPanel
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.stTextBox1);
this.Controls.Add(this.colorPB);
this.Controls.Add(this.alphaPB);
this.Controls.Add(this.barSlider4);
@ -252,10 +263,11 @@
this.Controls.Add(this.barSlider2);
this.Controls.Add(this.barSlider1);
this.Name = "vector4SliderPanel";
this.Size = new System.Drawing.Size(282, 100);
this.Size = new System.Drawing.Size(282, 105);
((System.ComponentModel.ISupportInitialize)(this.alphaPB)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.colorPB)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
@ -267,5 +279,6 @@
private BarSlider.BarSlider barSlider4;
private System.Windows.Forms.PictureBox alphaPB;
private System.Windows.Forms.PictureBox colorPB;
private Switch_Toolbox.Library.Forms.STTextBox stTextBox1;
}
}

View file

@ -51,10 +51,11 @@ namespace FirstPlugin.Forms
public vector4SliderPanel(string UniformName, float[] values, BfresShaderParam param)
{
activeParam = param;
InitializeComponent();
activeParam = param;
stTextBox1.Bind(activeParam, "Name");
barSlider1.DataType = typeof(float);
barSlider2.DataType = typeof(float);
barSlider3.DataType = typeof(float);
@ -72,10 +73,11 @@ namespace FirstPlugin.Forms
public vector4SliderPanel(string UniformName, uint[] values, BfresShaderParam param)
{
activeParam = param;
InitializeComponent();
activeParam = param;
stTextBox1.Bind(activeParam, "Name");
barSlider1.DataType = typeof(uint);
barSlider2.DataType = typeof(uint);
barSlider3.DataType = typeof(uint);
@ -91,10 +93,11 @@ namespace FirstPlugin.Forms
public vector4SliderPanel(string UniformName, int[] values, BfresShaderParam param)
{
activeParam = param;
InitializeComponent();
activeParam = param;
stTextBox1.Bind(activeParam, "Name");
barSlider1.DataType = typeof(int);
barSlider2.DataType = typeof(int);
barSlider3.DataType = typeof(int);
@ -118,6 +121,11 @@ namespace FirstPlugin.Forms
{
if (IsColor)
{
barSlider1.Minimum = 0;
barSlider2.Minimum = 0;
barSlider3.Minimum = 0;
barSlider4.Minimum = 0;
colorPB.BackColor = Color.FromArgb(
Utils.FloatToIntClamp(255),
Utils.FloatToIntClamp(values[0]),
@ -142,7 +150,6 @@ namespace FirstPlugin.Forms
public void ApplyValueSingles()
{
SetColor(activeParam.Name, activeParam.ValueFloat);
activeParam.ValueFloat = new float[]
{
(float)barSlider1.Value,

View file

@ -0,0 +1,112 @@
namespace FirstPlugin.Forms
{
partial class EffectTableEditor
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.stDataGridView1 = new Switch_Toolbox.Library.Forms.STDataGridView();
this.stPanel1 = new Switch_Toolbox.Library.Forms.STPanel();
this.stMenuStrip1 = new Switch_Toolbox.Library.Forms.STMenuStrip();
this.addPTCLReferenceToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.contentContainer.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.stDataGridView1)).BeginInit();
this.stPanel1.SuspendLayout();
this.stMenuStrip1.SuspendLayout();
this.SuspendLayout();
//
// contentContainer
//
this.contentContainer.Controls.Add(this.stPanel1);
this.contentContainer.Controls.SetChildIndex(this.stPanel1, 0);
//
// stDataGridView1
//
this.stDataGridView1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.stDataGridView1.BackgroundColor = System.Drawing.Color.Gray;
this.stDataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.stDataGridView1.EnableHeadersVisualStyles = false;
this.stDataGridView1.GridColor = System.Drawing.Color.Black;
this.stDataGridView1.Location = new System.Drawing.Point(0, 27);
this.stDataGridView1.Name = "stDataGridView1";
this.stDataGridView1.Size = new System.Drawing.Size(540, 341);
this.stDataGridView1.TabIndex = 11;
//
// stPanel1
//
this.stPanel1.Controls.Add(this.stDataGridView1);
this.stPanel1.Controls.Add(this.stMenuStrip1);
this.stPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
this.stPanel1.Location = new System.Drawing.Point(0, 25);
this.stPanel1.Name = "stPanel1";
this.stPanel1.Size = new System.Drawing.Size(543, 368);
this.stPanel1.TabIndex = 12;
//
// stMenuStrip1
//
this.stMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.addPTCLReferenceToolStripMenuItem});
this.stMenuStrip1.Location = new System.Drawing.Point(0, 0);
this.stMenuStrip1.Name = "stMenuStrip1";
this.stMenuStrip1.Size = new System.Drawing.Size(543, 24);
this.stMenuStrip1.TabIndex = 12;
this.stMenuStrip1.Text = "stMenuStrip1";
//
// addPTCLReferenceToolStripMenuItem
//
this.addPTCLReferenceToolStripMenuItem.Name = "addPTCLReferenceToolStripMenuItem";
this.addPTCLReferenceToolStripMenuItem.Size = new System.Drawing.Size(71, 20);
this.addPTCLReferenceToolStripMenuItem.Text = "Link PTCL";
this.addPTCLReferenceToolStripMenuItem.Click += new System.EventHandler(this.addPTCLReferenceToolStripMenuItem_Click);
//
// EffectTableEditor
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(549, 398);
this.MainMenuStrip = this.stMenuStrip1;
this.Name = "EffectTableEditor";
this.Text = "EffectTableEditor";
this.contentContainer.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.stDataGridView1)).EndInit();
this.stPanel1.ResumeLayout(false);
this.stPanel1.PerformLayout();
this.stMenuStrip1.ResumeLayout(false);
this.stMenuStrip1.PerformLayout();
this.ResumeLayout(false);
}
#endregion
private Switch_Toolbox.Library.Forms.STDataGridView stDataGridView1;
private Switch_Toolbox.Library.Forms.STPanel stPanel1;
private Switch_Toolbox.Library.Forms.STMenuStrip stMenuStrip1;
private System.Windows.Forms.ToolStripMenuItem addPTCLReferenceToolStripMenuItem;
}
}

View file

@ -0,0 +1,111 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Switch_Toolbox.Library.Forms;
using Switch_Toolbox.Library;
namespace FirstPlugin.Forms
{
public partial class EffectTableEditor : STForm, IFIleEditor
{
public List<IFileFormat> GetFileFormats()
{
return new List<IFileFormat>() { EffectTableFile };
}
public EffectTableEditor()
{
InitializeComponent();
}
PTCL ptcl;
EFCF EffectTableFile;
public void LoadEffectFile(EFCF efcf)
{
EffectTableFile = efcf;
stDataGridView1.Columns.Add(new DataGridViewTextBoxColumn()
{
HeaderText = "ActiveTime",
Name = "ActiveTime",
ReadOnly = true,
});
stDataGridView1.Columns.Add(new DataGridViewTextBoxColumn()
{
HeaderText = "PtclEmitter",
Name = "PtclEmitter",
});
stDataGridView1.Columns.Add(new DataGridViewTextBoxColumn()
{
HeaderText = "PtclSlotData",
Name = "PtclSlotData",
});
stDataGridView1.Columns.Add(new DataGridViewTextBoxColumn()
{
HeaderText = "StringBankSlot",
Name = "StringBankSlot",
});
ReloadDataGrid();
}
private void ReloadDataGrid()
{
stDataGridView1.Rows.Clear();
int rowIndex = 0;
foreach (var effect in EffectTableFile.EfcHeader.Entries)
{
rowIndex = this.stDataGridView1.Rows.Add();
var row = stDataGridView1.Rows[rowIndex];
row.Cells["ActiveTime"].Value = effect.ActiveTime;
if (ptcl != null)
{
if (ptcl.headerU.emitterSets.Count > effect.PtclStringSlot && effect.PtclStringSlot != -1)
{
row.Cells["PtclEmitter"].Value = ptcl.headerU.emitterSets[(int)effect.PtclStringSlot].Text;
row.Cells["PtclSlotData"].Value = effect.SlotSpecificPtclData;
}
else
{
row.Cells["PtclEmitter"].Value = effect.PtclStringSlot;
row.Cells["PtclSlotData"].Value = effect.SlotSpecificPtclData;
}
}
else
{
row.Cells["PtclEmitter"].Value = effect.PtclStringSlot;
row.Cells["PtclSlotData"].Value = effect.SlotSpecificPtclData;
}
if (EffectTableFile.EfcHeader.StringEntries.Count > effect.StringBankSlot && effect.StringBankSlot != - 1)
row.Cells["StringBankSlot"].Value = EffectTableFile.EfcHeader.StringEntries[(int)effect.StringBankSlot];
else
row.Cells["StringBankSlot"].Value = effect.StringBankSlot;
}
stDataGridView1.ApplyStyles();
}
private void addPTCLReferenceToolStripMenuItem_Click(object sender, EventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog();
if (ofd.ShowDialog() == DialogResult.OK)
{
ptcl = (PTCL)Switch_Toolbox.Library.IO.STFileLoader.OpenFileFormat(ofd.FileName);
ReloadDataGrid();
}
}
}
}

View file

@ -0,0 +1,123 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="stMenuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>

View file

@ -126,13 +126,16 @@ namespace FirstPlugin
// Formats.Add(typeof(BFLYT));
Formats.Add(typeof(GFPAK));
Formats.Add(typeof(NUTEXB));
Formats.Add(typeof(NUT));
Formats.Add(typeof(GTXFile));
Formats.Add(typeof(AAMP));
Formats.Add(typeof(PTCL));
Formats.Add(typeof(EFF));
Formats.Add(typeof(EFCF));
// Formats.Add(typeof(NCA));
// Formats.Add(typeof(XCI));
// Formats.Add(typeof(NSP));
// Formats.Add(typeof(NSP));
Formats.Add(typeof(BFSAR));
Formats.Add(typeof(BNSH));
Formats.Add(typeof(BFSHA));

View file

@ -31,6 +31,8 @@ namespace FirstPlugin
public static string FSCN = GetFilter(".bfscn");
public static string FSHA = GetFilter(".bfspa");
public static string NUTEXB = GetFilter(".dds",".png", ".tga", ".jpg", ".tiff", ".tif", ".gif");
public static string GetFilter(Type type, object CheckAnimEffect = null, bool IsExporting = false)
{
if (type == typeof(TextureData)) return BNTX_TEX;

View file

@ -206,6 +206,7 @@
<Compile Include="FileFormats\BFRES\GLEnumConverter.cs" />
<Compile Include="FileFormats\Bin\KartParts.cs" />
<Compile Include="FileFormats\Collision\KclFile.cs" />
<Compile Include="FileFormats\Effects\EFCF.cs" />
<Compile Include="FileFormats\Font\BFFNT.cs" />
<Compile Include="FileFormats\Audio\Archives\BFGRP.cs" />
<Compile Include="FileFormats\Hashes\SAHT.cs" />
@ -215,6 +216,7 @@
<Compile Include="FileFormats\Layout\BFLYT.cs" />
<Compile Include="FileFormats\BFRES\Bfres Structs\CurveHelper.cs" />
<Compile Include="FileFormats\BFRES\BFRES.cs" />
<Compile Include="FileFormats\Texture\NUT.cs" />
<Compile Include="FileFormats\XLINK\XLINK.cs" />
<Compile Include="GL\Helpers\DepthGLControl.cs" />
<Compile Include="GL\ShaderData\AglShaderOdyssey.cs" />
@ -264,6 +266,12 @@
<Compile Include="GUI\BFRES\Materials\ShaderAssign\SamplerInputListEdit.Designer.cs">
<DependentUpon>SamplerInputListEdit.cs</DependentUpon>
</Compile>
<Compile Include="GUI\BFRES\Materials\ShaderParams\ParamValueDialog.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="GUI\BFRES\Materials\ShaderParams\ParamValueDialog.Designer.cs">
<DependentUpon>ParamValueDialog.cs</DependentUpon>
</Compile>
<Compile Include="GUI\BFRES\Materials\ShaderParams\ParamValueEditorBase.cs">
<SubType>UserControl</SubType>
</Compile>
@ -373,6 +381,12 @@
<Compile Include="GUI\Byaml\CourseMuunt\Wrappers\PathPointNode.cs" />
<Compile Include="GUI\Byaml\CourseMuunt\Wrappers\ProbeLightingEntryWrapper.cs" />
<Compile Include="GUI\Byaml\CourseMuunt\Wrappers\ProbeLightingWrapper.cs" />
<Compile Include="GUI\Editors\EffectTableEditor.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="GUI\Editors\EffectTableEditor.Designer.cs">
<DependentUpon>EffectTableEditor.cs</DependentUpon>
</Compile>
<Compile Include="GUI\KCL\CollisionMaterialEditor.cs">
<SubType>Form</SubType>
</Compile>
@ -861,6 +875,9 @@
<EmbeddedResource Include="GUI\BFRES\Materials\ShaderParams\ColorWheel.resx">
<DependentUpon>ColorWheel.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="GUI\BFRES\Materials\ShaderParams\ParamValueDialog.resx">
<DependentUpon>ParamValueDialog.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="GUI\BFRES\Materials\ShaderParams\ShaderParamEditor.resx">
<DependentUpon>ShaderParamEditor.cs</DependentUpon>
</EmbeddedResource>
@ -975,6 +992,9 @@
<EmbeddedResource Include="GUI\BFRES\AnimKeyViewer.resx">
<DependentUpon>AnimKeyViewer.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="GUI\Editors\EffectTableEditor.resx">
<DependentUpon>EffectTableEditor.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="GUI\Editors\MK8TrackEditor\MK8MapCameraEditor.resx">
<DependentUpon>MK8MapCameraEditor.cs</DependentUpon>
</EmbeddedResource>

View file

@ -1 +1 @@
75aca8a71972838de6e8f123a623f1026e38bd08
eb767ec069a2b51342316e58b88dfbfbeaa1b4b2

View file

@ -322,3 +322,5 @@ C:\Users\Nathan\Documents\GitHub\SwitchToolboxV1\Switch_FileFormatsMain\obj\Rele
C:\Users\Nathan\Documents\GitHub\SwitchToolboxV1\Switch_FileFormatsMain\obj\Release\FirstPlugin.Forms.CollisionMaterialEditor.resources
C:\Users\Nathan\Documents\GitHub\SwitchToolboxV1\Switch_FileFormatsMain\obj\Release\FirstPlugin.Forms.MSBTEditor.resources
C:\Users\Nathan\Documents\GitHub\SwitchToolboxV1\Switch_FileFormatsMain\obj\Release\FirstPlugin.Forms.SamplerEditorSimple.resources
C:\Users\Nathan\Documents\GitHub\SwitchToolboxV1\Switch_FileFormatsMain\obj\Release\FirstPlugin.Forms.EffectTableEditor.resources
C:\Users\Nathan\Documents\GitHub\SwitchToolboxV1\Switch_FileFormatsMain\obj\Release\FirstPlugin.Forms.ParamValueDialog.resources

View file

@ -97,6 +97,21 @@ namespace Switch_Toolbox.Library
public const uint FOURCC_ATI2 = 0x32495441;
public const uint FOURCC_RXGB = 0x42475852;
// RGBA Masks
private static int[] A1R5G5B5_MASKS = { 0x7C00, 0x03E0, 0x001F, 0x8000 };
private static int[] X1R5G5B5_MASKS = { 0x7C00, 0x03E0, 0x001F, 0x0000 };
private static int[] A4R4G4B4_MASKS = { 0x0F00, 0x00F0, 0x000F, 0xF000 };
private static int[] X4R4G4B4_MASKS = { 0x0F00, 0x00F0, 0x000F, 0x0000 };
private static int[] R5G6B5_MASKS = { 0xF800, 0x07E0, 0x001F, 0x0000 };
private static int[] R8G8B8_MASKS = { 0xFF0000, 0x00FF00, 0x0000FF, 0x000000 };
private static uint[] A8B8G8R8_MASKS = { 0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000 };
private static int[] X8B8G8R8_MASKS = { 0x000000FF, 0x0000FF00, 0x00FF0000, 0x00000000 };
private static uint[] A8R8G8B8_MASKS = { 0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000 };
private static int[] X8R8G8B8_MASKS = { 0x00FF0000, 0x0000FF00, 0x000000FF, 0x00000000 };
private static int[] L8_MASKS = { 0x000000FF, 0x0000 ,};
private static int[] A8L8_MASKS = { 0x000000FF, 0x0F00, };
public enum CubemapFace
{
PosX,
@ -156,8 +171,6 @@ namespace Switch_Toolbox.Library
{
switch (fourCC)
{
case 0x00000000: //RGBA
return false;
case FOURCC_DXT1:
case FOURCC_DXT2:
case FOURCC_DXT3:
@ -175,34 +188,6 @@ namespace Switch_Toolbox.Library
}
}
public static uint getFormatSize(uint fourCC)
{
switch (fourCC)
{
case 0x00000000: //RGBA
return 0x4;
case FOURCC_DXT1:
return 0x8;
case FOURCC_DXT2:
return 0x10;
case FOURCC_DXT3:
return 0x10;
case FOURCC_DXT4:
return 0x10;
case FOURCC_DXT5:
return 0x10;
case FOURCC_ATI1:
case FOURCC_BC4U:
case FOURCC_BC4S:
return 0x8;
case FOURCC_ATI2:
case FOURCC_BC5U:
case FOURCC_BC5S:
return 0x10;
default:
return 0;
}
}
public void SetFourCC(DXGI_FORMAT Format)
{
switch (Format)
@ -222,7 +207,6 @@ namespace Switch_Toolbox.Library
}
}
public bool IsDX10;
public uint imageSize;
public Header header;
public DX10Header DX10header;
@ -513,12 +497,36 @@ namespace Switch_Toolbox.Library
ReadDX10Header(reader);
}
if (IsCompressed())
bool IsCompressed = false;
bool HasLuminance = false;
bool HasAlpha = false;
bool IsRGB = false;
if (header.ddspf.flags == 4)
IsCompressed = true;
else if (header.ddspf.flags == (uint)DDPF.LUMINANCE || header.ddspf.flags == 2)
HasLuminance = true;
else if (header.ddspf.flags == 0x20001)
{
imageSize = ((header.width + 3) >> 2) * ((header.height + 3) >> 2) * getFormatSize(header.ddspf.fourCC);
HasLuminance = true;
HasAlpha = true;
}
else if (header.ddspf.flags == (uint)DDPF.RGB)
{
IsRGB = true;
}
else if (header.ddspf.flags == 0x41)
{
IsRGB = true;
HasAlpha = true;
HasAlpha = true;
}
Format = GetFormat();
if (!IsDX10 && !IsCompressed) {
Format = GetUncompressedType(IsRGB, HasAlpha, HasLuminance, header.ddspf);
}
else
imageSize = header.width * header.height * getFormatSize(header.ddspf.fourCC);
reader.TemporarySeek((int)(4 + header.size + DX10HeaderSize), SeekOrigin.Begin);
bdata = reader.ReadBytes((int)(reader.BaseStream.Length - reader.BaseStream.Position));
@ -526,11 +534,89 @@ namespace Switch_Toolbox.Library
reader.Dispose();
reader.Close();
ArrayCount = 1;
MipCount = header.mipmapCount;
Width = header.width;
Height = header.height;
Format = GetFormat();
}
private TEX_FORMAT GetUncompressedType(bool IsRGB, bool HasAlpha, bool HasLuminance, Header.DDS_PixelFormat header)
{
uint bpp = header.RGBBitCount;
uint RedMask = header.RBitMask;
uint GreenMask = header.GBitMask;
uint BlueMask = header.BBitMask;
uint AlphaMask = HasAlpha ? header.ABitMask : 0;
if (HasLuminance)
{
throw new Exception("Luminance not supported!");
}
else if (IsRGB)
{
if (bpp == 16)
{
if (RedMask == A1R5G5B5_MASKS[0] && GreenMask == A1R5G5B5_MASKS[1] && BlueMask == A1R5G5B5_MASKS[2] && AlphaMask == A1R5G5B5_MASKS[3])
{
return TEX_FORMAT.B5G5R5A1_UNORM;
}
else if (RedMask == X1R5G5B5_MASKS[0] && GreenMask == X1R5G5B5_MASKS[1] && BlueMask == X1R5G5B5_MASKS[2] && AlphaMask == X1R5G5B5_MASKS[3])
{
return TEX_FORMAT.B5G6R5_UNORM;
}
else if (RedMask == A4R4G4B4_MASKS[0] && GreenMask == A4R4G4B4_MASKS[1] && BlueMask == A4R4G4B4_MASKS[2] && AlphaMask == A4R4G4B4_MASKS[3])
{
return TEX_FORMAT.B4G4R4A4_UNORM;
}
else if (RedMask == X4R4G4B4_MASKS[0] && GreenMask == X4R4G4B4_MASKS[1] && BlueMask == X4R4G4B4_MASKS[2] && AlphaMask == X4R4G4B4_MASKS[3])
{
return TEX_FORMAT.B4G4R4A4_UNORM;
}
else if (RedMask == R5G6B5_MASKS[0] && GreenMask == R5G6B5_MASKS[1] && BlueMask == R5G6B5_MASKS[2] && AlphaMask == R5G6B5_MASKS[3])
{
return TEX_FORMAT.B5G6R5_UNORM;
}
else
{
throw new Exception("Unsupported 16 bit image!");
}
}
else if (bpp == 24)
{
if (RedMask == R8G8B8_MASKS[0] && GreenMask == R8G8B8_MASKS[1] && BlueMask == R8G8B8_MASKS[2] && AlphaMask == R8G8B8_MASKS[3])
{
return TEX_FORMAT.R8G8_B8G8_UNORM;
}
else
{
throw new Exception("Unsupported 24 bit image!");
}
}
else if (bpp == 32)
{
if (RedMask == A8B8G8R8_MASKS[0] && GreenMask == A8B8G8R8_MASKS[1] && BlueMask == A8B8G8R8_MASKS[2] && AlphaMask == A8B8G8R8_MASKS[3])
{
return TEX_FORMAT.R8G8B8A8_UNORM;
}
else if (RedMask == X8B8G8R8_MASKS[0] && GreenMask == X8B8G8R8_MASKS[1] && BlueMask == X8B8G8R8_MASKS[2] && AlphaMask == X8B8G8R8_MASKS[3])
{
return TEX_FORMAT.R8G8_B8G8_UNORM;
}
else if (RedMask == A8R8G8B8_MASKS[0] && GreenMask == A8R8G8B8_MASKS[1] && BlueMask == A8R8G8B8_MASKS[2] && AlphaMask == A8R8G8B8_MASKS[3])
{
return TEX_FORMAT.R8G8B8A8_UNORM;
}
else if (RedMask == X8R8G8B8_MASKS[0] && GreenMask == X8R8G8B8_MASKS[1] && BlueMask == X8R8G8B8_MASKS[2] && AlphaMask == X8R8G8B8_MASKS[3])
{
return TEX_FORMAT.R8G8_B8G8_UNORM;
}
else
{
throw new Exception("Unsupported 32 bit image!");
}
}
}
return TEX_FORMAT.UNKNOWN;
}
private void ReadDX10Header(BinaryDataReader reader)
{
@ -663,9 +749,9 @@ namespace Switch_Toolbox.Library
using (FileReader reader = new FileReader(dds.bdata))
{
var Surfaces = new List<STGenericTexture.Surface>();
uint formatSize = getFormatSize(dds.header.ddspf.fourCC);
bool isBlock = getFormatBlock(dds.header.ddspf.fourCC);
uint formatSize = GetBytesPerPixel(dds.Format);
bool isBlock = dds.IsCompressed();
if (dds.header.mipmapCount == 0)
dds.header.mipmapCount = 1;
@ -818,6 +904,12 @@ namespace Switch_Toolbox.Library
case DXGI_FORMAT.DXGI_FORMAT_BC5_UNORM:
case DXGI_FORMAT.DXGI_FORMAT_BC5_TYPELESS:
case DXGI_FORMAT.DXGI_FORMAT_BC5_SNORM:
case DXGI_FORMAT.DXGI_FORMAT_BC6H_TYPELESS:
case DXGI_FORMAT.DXGI_FORMAT_BC6H_UF16:
case DXGI_FORMAT.DXGI_FORMAT_BC6H_SF16:
case DXGI_FORMAT.DXGI_FORMAT_BC7_UNORM:
case DXGI_FORMAT.DXGI_FORMAT_BC7_UNORM_SRGB:
case DXGI_FORMAT.DXGI_FORMAT_BC7_TYPELESS:
return true;
default:
return false;
@ -843,7 +935,7 @@ namespace Switch_Toolbox.Library
}
}
}
public void Save(DDS dds, string FileName, List<STGenericTexture.Surface> data = null)
public void Save(DDS dds, string FileName, List<Surface> data = null)
{
FileWriter writer = new FileWriter(new FileStream(FileName, FileMode.Create, FileAccess.Write, FileShare.Write));
var header = dds.header;

View file

@ -497,6 +497,9 @@ namespace Switch_Toolbox.Library
public static unsafe byte[] DecompressBlock(Byte[] data, int width, int height, DDS.DXGI_FORMAT format)
{
Console.WriteLine(format);
Console.WriteLine(data.Length);
Console.WriteLine(width);
Console.WriteLine(height);
long inputRowPitch;
long inputSlicePitch;

View file

@ -412,8 +412,8 @@ namespace Switch_Toolbox.Library
else
{
//If blue channel becomes first, do not swap them!
// if (Format.ToString().StartsWith("B") || Format == TEX_FORMAT.B5G6R5_UNORM)
// return DDSCompressor.DecodePixelBlock(data, (int)Width, (int)Height, (DDS.DXGI_FORMAT)Format);
if (Format.ToString().StartsWith("B") || Format == TEX_FORMAT.B5G6R5_UNORM)
return DDSCompressor.DecodePixelBlock(data, (int)Width, (int)Height, (DDS.DXGI_FORMAT)Format);
if (IsAtscFormat(Format))
return ConvertBgraToRgba(ASTCDecoder.DecodeToRGBA8888(data, (int)GetBlockWidth(Format), (int)GetBlockHeight(Format), 1, (int)Width, (int)Height, 1));
else
@ -586,8 +586,7 @@ namespace Switch_Toolbox.Library
}
public void SaveDDS(string FileName, int SurfaceLevel = 0, int MipLevel = 0)
{
var data = GetImageData(SurfaceLevel, MipLevel);
var surfaces = new List<Surface>();
var surfaces = GetSurfaces();
if (Depth == 0)
Depth = 1;
@ -598,8 +597,12 @@ namespace Switch_Toolbox.Library
dds.header.height = Height;
dds.header.depth = Depth;
dds.header.mipmapCount = (uint)MipCount;
dds.header.pitchOrLinearSize = (uint)data.Length;
dds.SetFlags((DDS.DXGI_FORMAT)Format);
dds.header.pitchOrLinearSize = (uint)surfaces[0].mipmaps[0].Length;
if (surfaces.Count > 0)
dds.SetFlags((DDS.DXGI_FORMAT)Format);
else
dds.SetFlags((DDS.DXGI_FORMAT)Format);
if (dds.IsDX10)
{
@ -607,11 +610,11 @@ namespace Switch_Toolbox.Library
dds.DX10header = new DDS.DX10Header();
dds.DX10header.ResourceDim = 3;
dds.DX10header.arrayFlag = 1;
dds.DX10header.arrayFlag = (uint)surfaces.Count;
}
dds.Save(dds, FileName, GetSurfaces());
dds.Save(dds, FileName, surfaces);
}
public void LoadOpenGLTexture()
{
@ -715,6 +718,9 @@ namespace Switch_Toolbox.Library
}
private static byte[] ConvertBgraToRgba(byte[] bytes)
{
if (bytes == null)
throw new Exception("Data block returned null. Make sure the parameters and image properties are correct!");
for (int i = 0; i < bytes.Length; i += 4)
{
var temp = bytes[i];