Add odyssey costume selector/viewer

This commit is contained in:
KillzXGaming 2019-05-14 21:43:37 -04:00
parent 8f35052887
commit 82040c6913
16 changed files with 422 additions and 3 deletions

Binary file not shown.

View file

@ -40,6 +40,7 @@ namespace FirstPlugin
} }
public Dictionary<string, byte[]> OpenedFiles = new Dictionary<string, byte[]>(); public Dictionary<string, byte[]> OpenedFiles = new Dictionary<string, byte[]>();
public Dictionary<string, byte[]> Files = new Dictionary<string, byte[]>();
public SarcData sarcData; public SarcData sarcData;
public string SarcHash; public string SarcHash;
@ -562,7 +563,7 @@ namespace FirstPlugin
sarcEntry.sarc = this; sarcEntry.sarc = this;
sarcEntry.Data = data; sarcEntry.Data = data;
Console.WriteLine(name); Files.Add(name, data);
string ext = Path.GetExtension(name); string ext = Path.GetExtension(name);
string SarcEx = SARCExt.SARC.GuessFileExtension(data); string SarcEx = SARCExt.SARC.GuessFileExtension(data);

View file

@ -0,0 +1,93 @@
namespace FirstPlugin.Forms
{
partial class OdysseyCostumeSelector
{
/// <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.listViewCustom1 = new Switch_Toolbox.Library.Forms.ListViewCustom();
this.columnHeader1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.stPanel1 = new Switch_Toolbox.Library.Forms.STPanel();
this.contentContainer.SuspendLayout();
this.stPanel1.SuspendLayout();
this.SuspendLayout();
//
// contentContainer
//
this.contentContainer.Controls.Add(this.stPanel1);
this.contentContainer.Size = new System.Drawing.Size(310, 521);
this.contentContainer.Controls.SetChildIndex(this.stPanel1, 0);
//
// listViewCustom1
//
this.listViewCustom1.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.listViewCustom1.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.columnHeader1});
this.listViewCustom1.Dock = System.Windows.Forms.DockStyle.Fill;
this.listViewCustom1.FullRowSelect = true;
this.listViewCustom1.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.None;
this.listViewCustom1.Location = new System.Drawing.Point(0, 0);
this.listViewCustom1.Name = "listViewCustom1";
this.listViewCustom1.OwnerDraw = true;
this.listViewCustom1.Size = new System.Drawing.Size(310, 496);
this.listViewCustom1.TabIndex = 0;
this.listViewCustom1.UseCompatibleStateImageBehavior = false;
this.listViewCustom1.View = System.Windows.Forms.View.Details;
this.listViewCustom1.DoubleClick += new System.EventHandler(this.listViewCustom1_DoubleClick);
//
// columnHeader1
//
this.columnHeader1.Width = 310;
//
// stPanel1
//
this.stPanel1.Controls.Add(this.listViewCustom1);
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(310, 496);
this.stPanel1.TabIndex = 11;
//
// OdysseyCostumeSelector
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(316, 526);
this.Name = "OdysseyCostumeSelector";
this.Text = "Odyssey Costume Selector";
this.contentContainer.ResumeLayout(false);
this.stPanel1.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private Switch_Toolbox.Library.Forms.ListViewCustom listViewCustom1;
private System.Windows.Forms.ColumnHeader columnHeader1;
private Switch_Toolbox.Library.Forms.STPanel stPanel1;
}
}

View file

@ -0,0 +1,52 @@
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 System.IO;
using Switch_Toolbox.Library;
using Switch_Toolbox.Library.Forms;
namespace FirstPlugin.Forms
{
public partial class OdysseyCostumeSelector : STForm
{
public string SelectedCostumeName = "";
public List<string> ExcludeFileList = new List<string>(new string[] {
"Eye","Face", "Head", "HeadTexture","Under","HandL","HandR","HandTexture", "BodyTexture","Hair","2D","Cap","Tail","Ruck",
"aHakama","Skirt","Shell","PonchoPoncho","PonchoGuitar"
});
public OdysseyCostumeSelector(string GamePath)
{
InitializeComponent();
foreach (string dir in Directory.GetFiles($"{GamePath}\\ObjectData", "Mario*"))
{
string filename = Path.GetFileNameWithoutExtension(dir);
bool Exluded = ExcludeFileList.Any(filename.Contains);
if (Exluded == false)
{
listViewCustom1.Items.Add(new ListViewItem(filename) { Tag = dir });
}
}
}
private void listViewCustom1_DoubleClick(object sender, EventArgs e)
{
if (listViewCustom1.SelectedIndices.Count <= 0)
return;
SelectedCostumeName = (string)listViewCustom1.SelectedItems[0].Tag;
DialogResult = DialogResult.OK;
}
}
}

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

@ -5,6 +5,8 @@ using System.Collections.Generic;
using System.Windows.Forms; using System.Windows.Forms;
using Switch_Toolbox.Library; using Switch_Toolbox.Library;
using Switch_Toolbox.Library.Forms; using Switch_Toolbox.Library.Forms;
using Switch_Toolbox.Library.IO;
using FirstPlugin.Forms;
namespace FirstPlugin namespace FirstPlugin
{ {
@ -95,7 +97,139 @@ namespace FirstPlugin
} }
private void OpenSelector(object sender, EventArgs args) private void OpenSelector(object sender, EventArgs args)
{ {
if (System.IO.Directory.Exists(Runtime.SmoGamePath))
{
OpenCostumeDialog(Runtime.SmoGamePath);
}
else
{
var result = MessageBox.Show("Please set your Mario Odyssey game path!");
if (result == DialogResult.OK)
{
FolderSelectDialog ofd = new FolderSelectDialog();
if (ofd.ShowDialog() == DialogResult.OK)
{
Runtime.SmoGamePath = ofd.SelectedPath;
OpenCostumeDialog(Runtime.SmoGamePath);
}
}
}
}
private void OpenCostumeDialog(string GamePath)
{
var costumSelector = new OdysseyCostumeSelector(GamePath);
if (costumSelector.ShowDialog() == DialogResult.OK)
{
LoadCostumes(costumSelector.SelectedCostumeName);
}
}
public void LoadCostumes(string fileName)
{
editor = null;
fileName = System.IO.Path.ChangeExtension(fileName, null);
List<string> CostumeNames = new List<string>();
CostumeNames.Add($"{fileName}.szs");
CostumeNames.Add($"{fileName}Face.szs");
CostumeNames.Add($"{fileName}Eye.szs");
CostumeNames.Add($"{fileName}Head.szs");
CostumeNames.Add($"{fileName}HeadTexture.szs");
CostumeNames.Add($"{fileName}Under.szs");
CostumeNames.Add($"{fileName}HandL.szs");
CostumeNames.Add($"{fileName}HandR.szs");
CostumeNames.Add($"{fileName}HandTexture.szs");
CostumeNames.Add($"{fileName}BodyTexture.szs");
CostumeNames.Add($"{fileName}Shell.szs");
CostumeNames.Add($"{fileName}Tail.szs");
CostumeNames.Add($"{fileName}Hair.szs");
// CostumeNames.Add($"{fileName}Hakama.szs");
CostumeNames.Add($"{fileName}Skirt.szs");
// CostumeNames.Add($"{fileName}Poncho.szs");
CostumeNames.Add($"{fileName}Guitar.szs");
foreach (string path in CostumeNames)
{
Console.WriteLine("Path = " + path);
if (System.IO.File.Exists(path))
{
LoadCostume(path);
}
else
{
//Load default meshes unless it's these file names
List<string> ExcludeFileList = new List<string>(new string[] {
"MarioHack","MarioDot",
});
bool Exluded = ExcludeFileList.Any(path.Contains);
if (Exluded == false)
{
string parent = System.IO.Directory.GetParent(path).FullName;
if (path.Contains($"{fileName}Face"))
LoadCostume($"{parent}\\MarioFace.szs");
else if (path.Contains($"{fileName}Eye"))
LoadCostume($"{parent}\\MarioEye.szs");
else if (path.Contains($"{fileName}HeadTexture"))
LoadCostume($"{parent}\\MarioHeadTexture.szs");
else if (path.Contains($"{fileName}Head"))
LoadCostume($"{parent}\\MarioHead.szs");
else if (path.Contains($"{fileName}HandL"))
LoadCostume($"{parent}\\MarioHandL.szs");
else if (path.Contains($"{fileName}HandR"))
LoadCostume($"{parent}\\MarioHandR.szs");
else if (path.Contains($"{fileName}HandTexture"))
LoadCostume($"{parent}\\MarioHandTexture.szs");
}
}
}
}
private ObjectEditor editor;
public void LoadCostume(string fileName)
{
List<BFRES> bfresFiles = new List<BFRES>();
var FileFormat = STFileLoader.OpenFileFormat(fileName);
if (FileFormat is SARC)
{
foreach (var file in ((SARC)FileFormat).Files)
{
string ext = System.IO.Path.GetExtension(file.Key);
if (ext == ".bfres")
{
bfresFiles.Add((BFRES)STFileLoader.OpenFileFormat(file.Key, file.Value));
}
}
}
if (FileFormat is BFRES)
bfresFiles.Add((BFRES)FileFormat);
if (editor == null)
{
editor = new ObjectEditor();
LibraryGUI.Instance.CreateMdiWindow(editor);
}
foreach (var bfres in bfresFiles)
{
editor.AddNode(bfres);
bfres.LoadEditors(null);
DiableLoadCheck();
}
}
private void DiableLoadCheck()
{
BfresEditor bfresEditor = (BfresEditor)LibraryGUI.Instance.GetActiveContent(typeof(BfresEditor));
bfresEditor.IsLoaded = false;
} }
} }

View file

@ -444,11 +444,17 @@
<Compile Include="GUI\Message\MSBTEditor.Designer.cs"> <Compile Include="GUI\Message\MSBTEditor.Designer.cs">
<DependentUpon>MSBTEditor.cs</DependentUpon> <DependentUpon>MSBTEditor.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="GUI\SMO\OdysseyCostumeLoader.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="GUI\SMO\OdysseyCostumeLoader.Designer.cs">
<DependentUpon>OdysseyCostumeLoader.cs</DependentUpon>
</Compile>
<Compile Include="GUI\TextureUI\Importers\3DS\CTR_3DSImporterSettings.cs" /> <Compile Include="GUI\TextureUI\Importers\3DS\CTR_3DSImporterSettings.cs" />
<Compile Include="GUI\TextureUI\Importers\3DS\CTR_3DSTextureImporter.cs"> <Compile Include="GUI\TextureUI\Importers\3DS\CTR_3DSTextureImporter.cs">
<SubType>Form</SubType> <SubType>Form</SubType>
</Compile> </Compile>
<Compile Include="MarioCostumeEditor.cs" /> <Compile Include="GUI\SMO\MarioCostumeEditor.cs" />
<Compile Include="GUI\AAMP\AampV1Editor.cs"> <Compile Include="GUI\AAMP\AampV1Editor.cs">
<SubType>Form</SubType> <SubType>Form</SubType>
</Compile> </Compile>
@ -1125,6 +1131,9 @@
<EmbeddedResource Include="GUI\BFRES\Materials\Texture Selector.resx"> <EmbeddedResource Include="GUI\BFRES\Materials\Texture Selector.resx">
<DependentUpon>Texture Selector.cs</DependentUpon> <DependentUpon>Texture Selector.cs</DependentUpon>
</EmbeddedResource> </EmbeddedResource>
<EmbeddedResource Include="GUI\SMO\OdysseyCostumeLoader.resx">
<DependentUpon>OdysseyCostumeLoader.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="GUI\TextureLoader.resx"> <EmbeddedResource Include="GUI\TextureLoader.resx">
<DependentUpon>TextureLoader.cs</DependentUpon> <DependentUpon>TextureLoader.cs</DependentUpon>
</EmbeddedResource> </EmbeddedResource>

View file

@ -1 +1 @@
d87d0dcd49f0581ca7d8c6ec700d22a2cb739172 de397ba635a09cef3e2cf1a780d3519a6c3b7d5d

View file

@ -329,3 +329,4 @@ C:\Users\Nathan\Documents\GitHub\SwitchToolboxV1\Switch_FileFormatsMain\obj\Rele
C:\Users\Nathan\Documents\GitHub\SwitchToolboxV1\Switch_FileFormatsMain\obj\Release\FirstPlugin.CTR_3DSTextureImporter.resources C:\Users\Nathan\Documents\GitHub\SwitchToolboxV1\Switch_FileFormatsMain\obj\Release\FirstPlugin.CTR_3DSTextureImporter.resources
C:\Users\Nathan\Documents\GitHub\SwitchToolboxV1\Switch_FileFormatsMain\obj\Release\FirstPlugin.Forms.BcresEditor.resources C:\Users\Nathan\Documents\GitHub\SwitchToolboxV1\Switch_FileFormatsMain\obj\Release\FirstPlugin.Forms.BcresEditor.resources
C:\Users\Nathan\Documents\GitHub\SwitchToolboxV1\Switch_FileFormatsMain\obj\Release\FirstPlugin.Forms.BcresSamplerEditorSimple.resources C:\Users\Nathan\Documents\GitHub\SwitchToolboxV1\Switch_FileFormatsMain\obj\Release\FirstPlugin.Forms.BcresSamplerEditorSimple.resources
C:\Users\Nathan\Documents\GitHub\SwitchToolboxV1\Switch_FileFormatsMain\obj\Release\FirstPlugin.Forms.OdysseyCostumeSelector.resources

View file

@ -69,6 +69,15 @@ namespace Switch_Toolbox.Library.Forms
public bool UseListView = true; public bool UseListView = true;
public ObjectEditor()
{
InitializeComponent();
ObjectTree = new ObjectEditorTree();
ObjectTree.Dock = DockStyle.Fill;
stPanel1.Controls.Add(ObjectTree);
}
public ObjectEditor(IFileFormat FileFormat) public ObjectEditor(IFileFormat FileFormat)
{ {
InitializeComponent(); InitializeComponent();