Switch-Toolbox/Toolbox/GUI/Settings.cs

372 lines
13 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 16:55:09 +00: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 Switch_Toolbox.Library;
using Switch_Toolbox.Library.Forms;
namespace Toolbox
{
public partial class Settings : STForm
{
private bool IsStartup = false;
public Settings()
{
CanResize = false;
IsStartup = true;
InitializeComponent();
stTabControl1.myBackColor = FormThemes.BaseTheme.FormBackColor;
Text = "Settings";
foreach (Runtime.ViewportShading shading in Enum.GetValues(typeof(Runtime.ViewportShading)))
{
shadingComboBox.Items.Add(shading.ToString());
}
foreach (Runtime.CameraMovement shading in Enum.GetValues(typeof(Runtime.CameraMovement)))
{
camMoveComboBox.Items.Add(shading.ToString());
}
foreach (FormThemes.Preset themes in Enum.GetValues(typeof(FormThemes.Preset)))
{
formThemeCB.Items.Add(themes);
}
foreach (TEX_FORMAT format in Enum.GetValues(typeof(TEX_FORMAT)))
{
preferredTexFormatCB.Items.Add(format);
}
normalsLineUD.Value = (decimal)Runtime.normalsLineLength;
normalPointsCB.Checked = Runtime.renderNormalsPoints;
vtxColorCB.Checked = Runtime.renderVertColor;
gridColorPB.BackColor = Runtime.gridSettings.color;
gridCellCountUD.Value = Runtime.gridSettings.CellAmount;
gridCellSizeUD.Value = (decimal)Runtime.gridSettings.CellSize;
bgGradientTop.BackColor = Runtime.backgroundGradientTop;
bgGradientBottom.BackColor = Runtime.backgroundGradientBottom;
preferredTexFormatCB.SelectedItem = Runtime.PreferredTexFormat;
formThemeCB.SelectedItem = FormThemes.ActivePreset;
chkBoxNormalMap.Checked = Runtime.useNormalMap;
chkBoxDisplayModels.Checked = Runtime.RenderModels;
chkBoxDisplayWireframe.Checked = Runtime.RenderModelWireframe;
chkBoxSpecular.Checked = Runtime.renderSpecular;
chkBoxStereoscopy.Checked = Runtime.stereoscopy;
chkBoxDisplayPolyCount.Checked = Runtime.DisplayPolyCount;
camNearNumUD.Value = (decimal)Runtime.CameraNear;
camFarNumUD.Value = (decimal)Runtime.CameraFar;
previewScaleUD.Value = (decimal)Runtime.previewScale;
yazoCompressionLevelUD.Value = Runtime.Yaz0CompressionLevel;
2019-03-23 17:44:27 +00:00
enableVersionCheckCHK.Checked = Runtime.EnableVersionCheck;
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 16:55:09 +00:00
chkBoxEnablePBR.Checked = Runtime.EnablePBR;
chkBoxMdiMaximized.Checked = Runtime.MaximizeMdiWindow;
chkBoxDisplayBones.Checked = Runtime.renderBones;
boneSizeUD.Value = (decimal)Runtime.bonePointSize;
cameraMaxSpeedUD.Value = (decimal)Runtime.MaxCameraSpeed;
GLSLVerLabel.Text = $"Open GL Version: {Runtime.GLSLVersion}";
openGLVerLabel.Text = $"GLSL Version: {Runtime.openGLVersion}";
shadingComboBox.SelectedIndex = (int)Runtime.viewportShading;
camMoveComboBox.SelectedIndex = (int)Runtime.cameraMovement;
IsStartup = false;
}
private void shadingComboBox_SelectedIndexChanged(object sender, EventArgs e)
{
Runtime.viewportShading = (Runtime.ViewportShading)shadingComboBox.SelectedIndex;
UpdateViewportSettings();
}
private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
Runtime.useNormalMap = chkBoxNormalMap.Checked;
UpdateViewportSettings();
}
private void chkBoxDisplayModels_CheckedChanged(object sender, EventArgs e)
{
Runtime.RenderModels = chkBoxDisplayModels.Checked;
UpdateViewportSettings();
}
private void chkBoxDisplayWireframe_CheckedChanged(object sender, EventArgs e)
{
Runtime.RenderModelWireframe = chkBoxDisplayWireframe.Checked;
UpdateViewportSettings();
}
private void camMoveComboBox_SelectedIndexChanged(object sender, EventArgs e)
{
Runtime.cameraMovement = (Runtime.CameraMovement)camMoveComboBox.SelectedIndex;
UpdateViewportSettings();
}
private void checkBox1_CheckedChanged_1(object sender, EventArgs e)
{
Runtime.stereoscopy = chkBoxStereoscopy.Checked;
UpdateViewportSettings();
}
private void camNearNumUD_ValueChanged(object sender, EventArgs e)
{
Runtime.CameraNear = (float)camNearNumUD.Value;
UpdateViewportSettings();
}
private void camFarNumUD_ValueChanged(object sender, EventArgs e)
{
Runtime.CameraFar = (float)camFarNumUD.Value;
UpdateViewportSettings();
}
private void btnSave_Click(object sender, EventArgs e)
{
// UpdateViewportSettings();
Config.Save();
this.Close();
}
private void chkBoxDisplayPolyCount_CheckedChanged(object sender, EventArgs e)
{
Runtime.DisplayPolyCount = chkBoxDisplayPolyCount.Checked;
}
private void Settings_Load(object sender, EventArgs e)
{
}
private void numericUpDown1_ValueChanged(object sender, EventArgs e)
{
Runtime.previewScale = (float)previewScaleUD.Value;
UpdateViewportSettings();
}
private void yazoCompressionLevelUD_ValueChanged(object sender, EventArgs e)
{
Runtime.Yaz0CompressionLevel = (int)yazoCompressionLevelUD.Value;
}
private void checkBox1_CheckedChanged_2(object sender, EventArgs e)
{
2019-03-23 17:44:27 +00:00
Runtime.EnableVersionCheck = enableVersionCheckCHK.Checked;
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 16:55:09 +00:00
}
private void chkBoxEnablePBR_CheckedChanged(object sender, EventArgs e)
{
Runtime.EnablePBR = chkBoxEnablePBR.Checked;
UpdateViewportSettings();
}
private void UpdateViewportSettings()
{
if (IsStartup)
return;
Viewport viewport = LibraryGUI.Instance.GetActiveViewport();
if (viewport == null)
return;
viewport.LoadViewportRuntimeValues();
viewport.UpdateViewport();
}
private void formThemeCB_SelectedIndexChanged(object sender, EventArgs e)
{
if (formThemeCB.SelectedIndex >= 0 && !IsStartup)
{
var result = MessageBox.Show("Changing themes will require to restart the program. Do you want to restart now?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
FormThemes.ActivePreset = (FormThemes.Preset)formThemeCB.SelectedItem;
if (result == DialogResult.Yes)
{
Config.Save();
this.Close();
Application.Restart();
Environment.Exit(0);
}
}
}
private void chkBoxMdiMaximized_CheckedChanged_3(object sender, EventArgs e)
{
Runtime.MaximizeMdiWindow = chkBoxMdiMaximized.Checked;
}
private void preferredTexFormatCB_SelectedIndexChanged(object sender, EventArgs e)
{
if (preferredTexFormatCB.SelectedIndex >= 0)
{
Runtime.PreferredTexFormat = (TEX_FORMAT)preferredTexFormatCB.SelectedItem;
}
}
private void bgGradientTop_Click(object sender, EventArgs e)
{
ColorDialog dlg = new ColorDialog();
if (dlg.ShowDialog() == DialogResult.OK)
Runtime.backgroundGradientTop = dlg.Color;
bgGradientTop.BackColor = Runtime.backgroundGradientTop;
UpdateViewportSettings();
}
private void bgGradientBottom_Click(object sender, EventArgs e)
{
ColorDialog dlg = new ColorDialog();
if (dlg.ShowDialog() == DialogResult.OK)
Runtime.backgroundGradientBottom = dlg.Color;
bgGradientBottom.BackColor = Runtime.backgroundGradientBottom;
UpdateViewportSettings();
}
#region Grid Settings
private void girdCellSizeUD_ValueChanged(object sender, EventArgs e)
{
Runtime.gridSettings.CellSize = (float)gridCellSizeUD.Value;
UpdateViewportGrid();
}
private void gridCellCountUD_ValueChanged(object sender, EventArgs e)
{
Runtime.gridSettings.CellAmount = (uint)gridCellCountUD.Value;
UpdateViewportGrid();
}
private void gridColorPB_Click(object sender, EventArgs e)
{
ColorDialog dlg = new ColorDialog();
if (dlg.ShowDialog() == DialogResult.OK)
Runtime.gridSettings.color = dlg.Color;
gridColorPB.BackColor = Runtime.gridSettings.color;
UpdateViewportGrid();
}
private void UpdateViewportGrid()
{
if (IsStartup)
return;
Viewport viewport = LibraryGUI.Instance.GetActiveViewport();
if (viewport == null)
return;
viewport.UpdateGrid();
}
#endregion
private void vtxColorCB_CheckedChanged(object sender, EventArgs e)
{
Runtime.renderVertColor = vtxColorCB.Checked;
UpdateViewportSettings();
}
private void normalPointsCB_CheckedChanged(object sender, EventArgs e)
{
Runtime.renderNormalsPoints = normalPointsCB.Checked;
UpdateViewportSettings();
}
private void normalsLineUD_ValueChanged(object sender, EventArgs e)
{
Runtime.normalsLineLength = (float)normalsLineUD.Value;
UpdateViewportSettings();
}
private void chkBoxDisplayBones_CheckedChanged(object sender, EventArgs e)
{
Runtime.renderBones = chkBoxDisplayBones.Checked;
UpdateViewportSettings();
}
private void boneSizeUD_ValueChanged(object sender, EventArgs e)
{
Runtime.bonePointSize = (float)boneSizeUD.Value;
UpdateViewportSettings();
}
private void redChannelBtn_Click(object sender, EventArgs e) {
if (Runtime.renderR) {
Runtime.renderR = false;
redChannelBtn.BackColor = FormThemes.BaseTheme.DisabledBorderColor;
redChannelBtn.ForeColor = FormThemes.BaseTheme.DisabledItemColor;
}
else {
Runtime.renderR = true;
redChannelBtn.BackColor = Color.FromArgb(192, 0, 0);
redChannelBtn.ForeColor = FormThemes.BaseTheme.FormForeColor;
}
UpdateViewportSettings();
}
private void greenChannelBtn_Click(object sender, EventArgs e) {
if (Runtime.renderG)
{
Runtime.renderG = false;
greenChannelBtn.BackColor = FormThemes.BaseTheme.DisabledBorderColor;
greenChannelBtn.ForeColor = FormThemes.BaseTheme.DisabledItemColor;
}
else
{
Runtime.renderG = true;
greenChannelBtn.BackColor = Color.FromArgb(0, 192, 0);
greenChannelBtn.ForeColor = FormThemes.BaseTheme.FormForeColor;
}
UpdateViewportSettings();
}
private void blueChannelBtn_Click(object sender, EventArgs e) {
if (Runtime.renderB)
{
Runtime.renderB = false;
blueChannelBtn.BackColor = FormThemes.BaseTheme.DisabledBorderColor;
blueChannelBtn.ForeColor = FormThemes.BaseTheme.DisabledItemColor;
}
else
{
Runtime.renderB = true;
blueChannelBtn.BackColor = Color.FromArgb(0, 0, 192);
blueChannelBtn.ForeColor = FormThemes.BaseTheme.FormForeColor;
}
UpdateViewportSettings();
}
private void alphaChannelBtn_Click(object sender, EventArgs e) {
if (Runtime.renderAlpha)
{
Runtime.renderAlpha = false;
alphaChannelBtn.BackColor = FormThemes.BaseTheme.DisabledBorderColor;
alphaChannelBtn.ForeColor = FormThemes.BaseTheme.DisabledItemColor;
}
else
{
Runtime.renderAlpha = true;
alphaChannelBtn.BackColor = Color.Silver;
alphaChannelBtn.ForeColor = FormThemes.BaseTheme.FormForeColor;
}
UpdateViewportSettings();
}
private void cameraMaxSpeedUD_ValueChanged(object sender, EventArgs e)
{
Runtime.MaxCameraSpeed = (float)cameraMaxSpeedUD.Value;
}
}
}