1
0
mirror of synced 2024-12-05 20:38:11 +01:00
Switch-Toolbox/Switch_FileFormatsMain/GUI/AAMP/EditBox.cs

223 lines
7.4 KiB
C#
Raw Normal View History

Add files for the new one. 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
2019-03-23 17:55:09 +01:00
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 AampV1Library;
using Aampv2 = AampV2Library;
using Syroot.Maths;
namespace FirstPlugin.Forms
{
public partial class EditBox : Form
{
public EditBox()
{
InitializeComponent();
foreach (var type in Enum.GetValues(typeof(ParamType)).Cast<ParamType>())
typeCB.Items.Add(type);
}
public void ToggleNameEditing(bool CanEdit)
{
nameTB.Enabled = CanEdit;
}
Add files for the new one. 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
2019-03-23 17:55:09 +01:00
ParamEntry paramEntry;
Aampv2.ParamEntry paramEntryV2;
public void LoadEntry(Aampv2.ParamEntry entry)
{
paramEntryV2 = entry;
nameTB.Text = entry.HashString;
typeCB.SelectedItem = entry.ParamType;
dataTB.Text = entry.Value.ToString();
switch (paramEntry.ParamType)
{
case ParamType.Vector2F:
var vec2 = (Vector2F)entry.Value;
dataTB.Text = $"{vec2.X} {vec2.Y}";
break;
case ParamType.Vector3F:
var vec3 = (Vector3F)entry.Value;
dataTB.Text = $"{vec3.X} {vec3.Y} {vec3.Z}";
break;
case ParamType.Vector4F:
case ParamType.Color4F:
var vec4 = (Vector4F)entry.Value;
dataTB.Text = $"{vec4.X} {vec4.Y} {vec4.Z} {vec4.W}";
break;
}
}
public void LoadEntry(ParamEntry entry)
{
paramEntry = entry;
nameTB.Text = entry.HashString;
typeCB.SelectedItem = entry.ParamType;
dataTB.Text = entry.Value.ToString();
switch (paramEntry.ParamType)
{
case ParamType.Vector2F:
var vec2 = (Vector2F)entry.Value;
dataTB.Text = $"{vec2.X} {vec2.Y}";
break;
case ParamType.Vector3F:
var vec3 = (Vector3F)entry.Value;
dataTB.Text = $"{vec3.X} {vec3.Y} {vec3.Z}";
break;
case ParamType.Vector4F:
case ParamType.Color4F:
var vec4 = (Vector4F)entry.Value;
dataTB.Text = $"{vec4.X} {vec4.Y} {vec4.Z} {vec4.W}";
break;
}
}
public void SaveEntry()
{
paramEntry.ParamType = (ParamType)typeCB.SelectedItem;
if (nameTB.Enabled)
paramEntry.HashString = nameTB.Text;
Add files for the new one. 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
2019-03-23 17:55:09 +01:00
switch (paramEntry.ParamType)
{
case ParamType.Boolean:
bool value = false;
bool.TryParse(dataTB.Text, out value);
paramEntry.Value = value;
break;
case ParamType.Float:
float valueF = 0;
float.TryParse(dataTB.Text, out valueF);
paramEntry.Value = valueF;
break;
case ParamType.Int:
int valueInt = 0;
int.TryParse(dataTB.Text, out valueInt);
paramEntry.Value = valueInt;
break;
case ParamType.Vector2F:
var values2F = dataTB.Text.Split(' ');
if (values2F.Length != 2)
{
}
else
{
float x, y;
float.TryParse(values2F[0], out x);
float.TryParse(values2F[1], out y);
paramEntry.Value = new Vector2F(x, y);
}
break;
case ParamType.Vector3F:
var values3F = dataTB.Text.Split(' ');
if (values3F.Length != 3)
{
}
else
{
float x, y, z;
float.TryParse(values3F[0], out x);
float.TryParse(values3F[1], out y);
float.TryParse(values3F[2], out z);
paramEntry.Value = new Vector3F(x, y, z);
}
break;
case ParamType.Vector4F:
case ParamType.Color4F:
var values = dataTB.Text.Split(' ');
if (values.Length != 4)
{
}
else
{
float x, y, z, w;
float.TryParse(values[0], out x);
float.TryParse(values[1], out y);
float.TryParse(values[2], out z);
float.TryParse(values[3], out w);
paramEntry.Value = new Vector4F(x,y,z,w);
}
break;
case ParamType.Uint:
uint valueUInt = 0;
uint.TryParse(dataTB.Text, out valueUInt);
paramEntry.Value = valueUInt;
break;
case ParamType.String64:
case ParamType.String32:
case ParamType.String256:
case ParamType.StringRef:
paramEntry.Value = dataTB.Text;
break;
}
}
private void dataTB_TextChanged(object sender, EventArgs e)
{
switch (paramEntry.ParamType)
{
case ParamType.Color4F:
var values = dataTB.Text.Split(' ');
if (values.Length == 4)
{
float x, y, z, w;
float.TryParse(values[0], out x);
float.TryParse(values[1], out y);
float.TryParse(values[2], out z);
float.TryParse(values[3], out w);
pictureBox1.BackColor = System.Drawing.Color.FromArgb(
FloatToIntClamp(w), FloatToIntClamp(x), FloatToIntClamp(y), FloatToIntClamp(z));
}
break;
}
}
public static int FloatToIntClamp(float r)
{
return Clamp((int)(r * 255), 0, 255);
}
public static T Clamp<T>(T val, T min, T max) where T : IComparable<T>
{
if (val.CompareTo(min) < 0) return min;
else if (val.CompareTo(max) > 0) return max;
else return val;
}
private void pictureBox1_Click(object sender, EventArgs e)
{
if (paramEntry.ParamType == ParamType.Color4F)
{
ColorDialog dlg = new ColorDialog();
if (dlg.ShowDialog() == DialogResult.OK)
{
paramEntry.Value = new Vector4F(
dlg.Color.R / 255.0f,
dlg.Color.G / 255.0f,
dlg.Color.B / 255.0f,
dlg.Color.A / 255.0f);
var vec4 = (Vector4F)paramEntry.Value;
dataTB.Text = $"{vec4.X} {vec4.Y} {vec4.Z} {vec4.W}";
}
}
}
}
}