mirror of
https://github.com/KillzXGaming/Switch-Toolbox
synced 2024-11-30 08:20:24 +00:00
d1f03b161f
Rework UI from scratch with proper themes and custom controls. MDI windows are now used for workspaces, comparing docs, and multiple usages. Tabs organise multiple workspaces and you can keep mdi windows maximized if you want to only use tabs. Themes currently include dark and white theme but plan to have XML files with list of color and styles Alot of things optimized. UI is very fast and snappy now Dae rigging fixed. Dae bones can be imported. Dae with textures can be imported and exported to a folder Custom sampler editor for sampler data. Texture refs, shader options, params, render info, and basically all material data can be added/removed and edited User data editor Update opengl framework by JuPaHe64 to the newest. Includes an origintation cube, multiple models in a scene, and many improvements Skeleton can be viewed GFPAK with some fixes in saving NUTEXB has proper mip map viewing PTCL Editor (Wii U and Switch). Can edit colors ( Wii U) and view textures. Also EFFN files in smash ultimate can be previewed Files can be associated with the program and opened with on clicking them ASTC textures can be viewed UVs can be viewed. Includes wrap modes and also translating and scaling for some basic edits Textures use a new editor. It includes channel viewing and some new editing options Fixed black textures on some wii u bfres Fixed saving sarcs in sarcs Shortcut keys have been added in. CTRL + S can save the active file in the currently used window Fix more issues with bfres crashing File - New includes BNTX for creating new bntx files from scatch Raw shader binaries can be extracted from bnsh and bfsha. Yuzu and Ryujinx can decompile these Sharc files can have source data previewed and shader programs in XML Aamp v1 and v2 data can be previewed. v1 can be edited and saved atm, v2 will be at a later update Byaml uses it's own editor instead of a seperate window for easy saving within sarcs Archives have a hex viewer Dae exporting greatly improved and can export rigged meshes Scene, shader param, srt, color, and texture pattern animations can all be previewed (in a list) Memory usage is greatly improved Narc (Nitro Archives) can be viewed and extracted. Fixed importing TGA images Support importing ASTC textures for bntx Added in PBR lighting for bfres from my implimentaion in forge Added gradient background for viewport. This can be edited in the settings Added skybox background option for viewport. Can load cubemaps Added grid with customizable cells for viewport. DDS decompression no longer requires Direct X tex. Zlib decompression has been improved for opening files that use it Rigid bones are properly ordered on importing a mesh. May fix some exploding issues. Endianness for KCL can be toggled for saving. Will be set to what it was using orignally Tangents can be filled with a constant value. Will allow them to not cause seams nor flat lighting however normal maps may not work as good Vertex buffers can be added and removed. Also re encoded Parameters now use drop down panels with values for easier editing Reworked the bone editor. Everything for a bone can be fully edited now besides the index, billboard index and parent index which get set automatically Fixed animation scaling for skeletal animations finally! Textures can be loaded in a tab now with thumbnail displaying for easy real time edits while previewing in the viewport Fixed support for audio files to be big endian in BARS Textures for switch now use their own folder. You can easily add textures to this and add textures to bfres that have no bntx. If there are no textures then the bfres will automatically not have one on save. Animations are split into multiple sub sections for switch's material animation for easier access Bfres for wii u has better binary exporting and is fully compatiable with Wexos Toolbox (to and from) Every section can be added in as new for both wii u and switch. Every section can be renamed properly and mostly everything can be edited. (Key frame editing and a more in depth curve editor later) Added option to copy UV channel Bone weights can be previewed Tons of fixes for the switch bfres library with more games working. Splatoon 2 (more work now), BOTW, Kirby Star Allies, and more! Fixed 3.3 Wii U bfres from not opening Wii U Sharcfb files can have shader program data previewed (XML) And possibly alot more things i missed! All this is still experimental but will improve over the next few weeks
260 lines
8.8 KiB
C#
260 lines
8.8 KiB
C#
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 FirstPlugin.Forms;
|
|
|
|
namespace FirstPlugin
|
|
{
|
|
public class SHARC : TreeNodeFile, IFileFormat
|
|
{
|
|
public bool CanSave { get; set; }
|
|
public string[] Description { get; set; } = new string[] { "Shader Archive" };
|
|
public string[] Extension { get; set; } = new string[] { "*.sharc" };
|
|
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))
|
|
{
|
|
return reader.CheckSignature(4, "AAHS");
|
|
}
|
|
}
|
|
|
|
public Type[] Types
|
|
{
|
|
get
|
|
{
|
|
List<Type> types = new List<Type>();
|
|
return types.ToArray();
|
|
}
|
|
}
|
|
|
|
public Header header;
|
|
|
|
public void Load(System.IO.Stream stream)
|
|
{
|
|
header = new Header();
|
|
header.Read(new FileReader(stream));
|
|
|
|
this.Text = header.Name;
|
|
|
|
Nodes.Add("SourceData");
|
|
Nodes.Add("ShaderPrograms");
|
|
|
|
foreach (var item in header.SourceDatas)
|
|
{
|
|
Nodes[0].Nodes.Add(item);
|
|
}
|
|
foreach (var item in header.ShaderPrograms)
|
|
{
|
|
Nodes[1].Nodes.Add(item);
|
|
}
|
|
}
|
|
public void Unload()
|
|
{
|
|
|
|
}
|
|
public byte[] Save()
|
|
{
|
|
return null;
|
|
}
|
|
|
|
//Docs https://github.com/Kinnay/Wii-U-File-Formats/wiki/SHARCFB-File-Format
|
|
public class Header
|
|
{
|
|
public string Name;
|
|
public uint Version;
|
|
public List<SourceData> SourceDatas = new List<SourceData>();
|
|
public List<ShaderProgram> ShaderPrograms = new List<ShaderProgram>();
|
|
|
|
public void Read (FileReader reader)
|
|
{
|
|
reader.ByteOrder = Syroot.BinaryData.ByteOrder.LittleEndian;
|
|
reader.ReadSignature(4, "AAHS");
|
|
Version = reader.ReadUInt32();
|
|
uint FileSize = reader.ReadUInt32();
|
|
uint bom = reader.ReadUInt32();
|
|
uint FileLength = reader.ReadUInt32();
|
|
Name = reader.ReadString((int)FileLength);
|
|
|
|
|
|
var pos = reader.Position;
|
|
uint SourceArrayOffset = reader.ReadUInt32();
|
|
uint ProgramCount = reader.ReadUInt32();
|
|
|
|
for (int i = 0; i < ProgramCount; i++)
|
|
{
|
|
ShaderProgram program = new ShaderProgram();
|
|
program.Read(reader, this);
|
|
ShaderPrograms.Add(program);
|
|
}
|
|
|
|
reader.Seek(SourceArrayOffset + pos, System.IO.SeekOrigin.Begin);
|
|
|
|
uint SourceSecSize = reader.ReadUInt32(); //Seems to cover that section entirely
|
|
uint SourceFileCount = reader.ReadUInt32();
|
|
|
|
for (int i = 0; i < SourceFileCount; i++)
|
|
{
|
|
SourceData source = new SourceData();
|
|
source.Read(reader);
|
|
SourceDatas.Add(source);
|
|
}
|
|
|
|
reader.Close();
|
|
reader.Dispose();
|
|
}
|
|
public void Write(FileWriter reader)
|
|
{
|
|
|
|
}
|
|
}
|
|
|
|
public class ShaderProgram : TreeNodeCustom
|
|
{
|
|
public enum ShaderType
|
|
{
|
|
GX2VertexShader = 0x1,
|
|
GX2PixelShader = 0x2,
|
|
GX2ComputeShader = 0x3,
|
|
GX2GeometryShader = 0x4,
|
|
}
|
|
public ShaderType Type;
|
|
|
|
public VariationMacroData variationVertexMacroData;
|
|
public VariationMacroData variationFragmenMacroData;
|
|
public VariationMacroData variationGeometryMacroData;
|
|
public VariationMacroData variationComputeMacroData;
|
|
|
|
public VariationSymbolData variationSymbolData;
|
|
public VariationSymbolData variationSymbolDataFull;
|
|
|
|
public ShaderSymbolData UniformVariables;
|
|
public ShaderSymbolData UniformBlocks;
|
|
public ShaderSymbolData SamplerVariables;
|
|
public ShaderSymbolData AttributeVariables;
|
|
|
|
public override void OnClick(TreeView treeview)
|
|
{
|
|
ShaderEditor editor = (ShaderEditor)LibraryGUI.Instance.GetActiveContent(typeof(ShaderEditor));
|
|
if (editor == null)
|
|
{
|
|
editor = new ShaderEditor();
|
|
LibraryGUI.Instance.LoadEditor(editor);
|
|
}
|
|
|
|
editor.Text = Text;
|
|
editor.Dock = DockStyle.Fill;
|
|
editor.FillEditor(this, ((SHARC)Parent.Parent).header);
|
|
}
|
|
|
|
public void Read(FileReader reader, SHARC.Header header)
|
|
{
|
|
var pos = reader.Position;
|
|
|
|
uint SectionSize = reader.ReadUInt32();
|
|
uint NameLength = reader.ReadUInt32();
|
|
|
|
if (header.Version >= 13)
|
|
{
|
|
ushort vertexUnk1 = reader.ReadUInt16();
|
|
ushort fragmentUnk1 = reader.ReadUInt16();
|
|
ushort geometryUnk1 = reader.ReadUInt16();
|
|
ushort computeUnk1 = reader.ReadUInt16();
|
|
ushort vertexUnk2 = reader.ReadUInt16();
|
|
ushort fragmentUnk2 = reader.ReadUInt16();
|
|
ushort geometryUnk2 = reader.ReadUInt16();
|
|
ushort computeUnk2 = reader.ReadUInt16();
|
|
}
|
|
else
|
|
{
|
|
uint vertexUnk1 = reader.ReadUInt32();
|
|
uint fragmentUnk1 = reader.ReadUInt32();
|
|
uint geometryUnk1 = reader.ReadUInt32();
|
|
}
|
|
|
|
Text = reader.ReadString((int)NameLength);
|
|
|
|
variationVertexMacroData = new VariationMacroData();
|
|
variationFragmenMacroData = new VariationMacroData();
|
|
variationGeometryMacroData = new VariationMacroData();
|
|
variationComputeMacroData = new VariationMacroData();
|
|
|
|
variationSymbolData = new VariationSymbolData();
|
|
variationSymbolDataFull = new VariationSymbolData();
|
|
UniformVariables = new ShaderSymbolData();
|
|
UniformBlocks = new ShaderSymbolData();
|
|
SamplerVariables = new ShaderSymbolData();
|
|
AttributeVariables = new ShaderSymbolData();
|
|
|
|
variationVertexMacroData.Read(reader, header.Version);
|
|
variationFragmenMacroData.Read(reader, header.Version);
|
|
variationGeometryMacroData.Read(reader, header.Version);
|
|
|
|
if (header.Version >= 13)
|
|
{
|
|
variationComputeMacroData.Read(reader, header.Version);
|
|
}
|
|
|
|
variationSymbolData.Read(reader);
|
|
variationSymbolDataFull.Read(reader);
|
|
UniformBlocks.Read(reader, header.Version);
|
|
|
|
if (header.Version <= 12)
|
|
{
|
|
UniformVariables.Read(reader);
|
|
SamplerVariables.Read(reader);
|
|
AttributeVariables.Read(reader);
|
|
}
|
|
|
|
reader.Seek(SectionSize + pos, System.IO.SeekOrigin.Begin);
|
|
}
|
|
}
|
|
|
|
public class SourceData : TreeNodeCustom
|
|
{
|
|
public string Code;
|
|
|
|
public override void OnClick(TreeView treeview)
|
|
{
|
|
TextEditor editor = (TextEditor)LibraryGUI.Instance.GetActiveContent(typeof(TextEditor));
|
|
if (editor == null)
|
|
{
|
|
editor = new TextEditor();
|
|
LibraryGUI.Instance.LoadEditor(editor);
|
|
}
|
|
|
|
editor.Text = Text;
|
|
editor.Dock = DockStyle.Fill;
|
|
editor.FillEditor(Code);
|
|
}
|
|
|
|
public void Read(FileReader reader)
|
|
{
|
|
var pos = reader.Position;
|
|
|
|
uint SectioSize = reader.ReadUInt32();
|
|
uint FileNameLength = reader.ReadUInt32();
|
|
uint CodeLength = reader.ReadUInt32();
|
|
uint CodeLength2 = reader.ReadUInt32(); //?????
|
|
Text = reader.ReadString((int)FileNameLength);
|
|
Code = reader.ReadString((int)CodeLength);
|
|
|
|
reader.Seek(SectioSize + pos, System.IO.SeekOrigin.Begin);
|
|
}
|
|
public void Write(FileWriter reader)
|
|
{
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|