1
0
mirror of synced 2024-11-12 02:00:50 +01:00

Link botw actors to msbt for defining and organsing. Load msbt labels.

This commit is contained in:
KillzXGaming 2019-08-10 20:52:58 -04:00
parent 3fd07bd46b
commit 9f829b714b
11 changed files with 259 additions and 150 deletions

Binary file not shown.

View File

@ -7,8 +7,9 @@ using Toolbox.Library;
using Toolbox.Library.Forms;
using System.IO;
using OpenTK;
using FirstPlugin;
namespace FirstPlugin
namespace UKing.Actors
{
/// <summary>
/// A class that holds methods to load actor data for botw.
@ -20,6 +21,34 @@ namespace FirstPlugin
private static string ActorInfoTable = $"/Actor/ActorInfo.product.sbyml";
//MSBT stores certain properties and helps define our actor names
private string ActorMessageData
{
get { return $"/Pack/Bootup_{MessageRegion}{MessageLanguage}.pack"; }
}
public Language MessageLanguage = Language.en;
public Region MessageRegion = Region.US;
public enum Region
{
US,
EU,
JP,
}
public enum Language
{
en, //English
de, //German
es, //Spanish
fr, //Frence
it, //Italian
nl, //
ru, //Russian
ja, //Japanese
}
public enum ActorCategory
{
Armour,
@ -47,6 +76,10 @@ namespace FirstPlugin
private const string N_aabbMin = "aabbMin";
private const string N_aabbMax = "aabbMax";
public string MessageName = "";
public string MessageDescription = "";
public string MessageFile = "";
public string Name
{
get { return this[N_name] != null ? this[N_name] : ""; }
@ -121,32 +154,6 @@ namespace FirstPlugin
}
}
public static Dictionary<string, ActorDefineInfo> ArmorActorDefine = new Dictionary<string, ActorDefineInfo>()
{
{"001", new ActorDefineInfo("Hylian Tunic Set") },
{"002",new ActorDefineInfo("Hylian Tunic Set Upgraded") },
{"003",new ActorDefineInfo("Hylian Tunic Set Upgraded 2") },
{"004",new ActorDefineInfo("Hylian Tunic Set Upgraded 3") },
{"005",new ActorDefineInfo("Tunic of the Wild Set") },
{"006",new ActorDefineInfo("Zora Set") },
{"007",new ActorDefineInfo("Zora Set Upgraded") },
{"008",new ActorDefineInfo("Desert Voe Set") },
{"009",new ActorDefineInfo("Snowquill Set" )},
{"011",new ActorDefineInfo("Flamebreaker Set") },
{"012",new ActorDefineInfo("Stealth Set" )},
{"014",new ActorDefineInfo("Climbing Gear Set" )},
{"017",new ActorDefineInfo("Radiant Set" )},
{"020",new ActorDefineInfo("Soldier's Armor Set" )},
{"021",new ActorDefineInfo("Ancient Set") },
{"022",new ActorDefineInfo("Bokoblin Mask") },
{"024",new ActorDefineInfo("Diamond Circlet") },
{"025",new ActorDefineInfo("Ruby Circlet") },
{"026",new ActorDefineInfo("Sapphire Circlet") },
{"027",new ActorDefineInfo("Topaz Circlet") },
{"028",new ActorDefineInfo("Opal Circlet") },
{"029",new ActorDefineInfo("Amber Circlet") },
};
private ObjectEditor editor;
public BotwActorLoader()
@ -154,6 +161,7 @@ namespace FirstPlugin
editor = new ObjectEditor();
editor.Text = "Actor Editor BOTW";
LibraryGUI.CreateMdiWindow(editor);
editor.SortTreeAscending();
LoadActors();
}
@ -194,52 +202,90 @@ namespace FirstPlugin
}
}
foreach (var info in Actors)
//Parse message data for our actor names, and additional info to add to the editor
Console.WriteLine("msbtEXT " + File.Exists($"{Runtime.BotwGamePath}{ActorMessageData}"));
Console.WriteLine($"{Runtime.BotwGamePath}{ActorMessageData}");
if (File.Exists($"{Runtime.BotwGamePath}{ActorMessageData}"))
{
ActorEntry entry = new ActorEntry();
entry.Text = info.Key;
ArmourFolder.Nodes.Add(entry);
}
var msgPack = SARCExt.SARC.UnpackRamN(File.Open($"{Runtime.BotwGamePath}{ActorMessageData}", FileMode.Open));
/* //Load all our actors into a class
foreach (var file in Directory.GetFiles($"{Runtime.BotwGamePath}{ActorPath}"))
{
string name = Path.GetFileNameWithoutExtension(file);
var actorType = name.Split('_').First();
var actorID = name.Split('_').Skip(1).FirstOrDefault();
var actorProperty = name.Split('_').Last();
if (actorType == "Armor")
//Get the other sarc inside
foreach (var pack in msgPack.Files)
{
if (ArmorActorDefine.ContainsKey(actorID))
{
ActorDefineInfo info = ArmorActorDefine[actorID];
var msgProductPack = SARCExt.SARC.UnpackRamN(EveryFileExplorer.YAZ0.Decompress(pack.Value));
//Folders are setup with actors
foreach (var msbtFile in msgProductPack.Files)
{
using (var stream = new MemoryStream(msbtFile.Value))
{
MSBT msbt = new MSBT();
if (!msbt.Identify(stream))
continue;
msbt.Load(new MemoryStream(msbtFile.Value));
//Get our labels and match up with our actors
if (msbt.header.Label1 != null)
{
for (int i = 0; i < msbt.header.Label1.Labels.Count; i++)
{
var lbl = msbt.header.Label1.Labels[i];
if (lbl.Name.Contains("_Name"))
{
string actorName = lbl.Name.Replace("_Name", string.Empty);
if (Actors.ContainsKey(actorName))
{
Actors[actorName].MessageFile = Path.GetFileNameWithoutExtension(msbtFile.Key);
Actors[actorName].MessageName = lbl.String.GetText(msbt.header.StringEncoding);
}
}
if (lbl.Name.Contains("_Desc"))
{
string actorName = lbl.Name.Replace("_Desc", string.Empty);
if (Actors.ContainsKey(actorName))
{
Actors[actorName].MessageFile = Path.GetFileNameWithoutExtension(msbtFile.Key);
Actors[actorName].MessageDescription = lbl.String.GetText(msbt.header.StringEncoding);
}
}
}
}
msbt.Unload();
}
}
}
else if (actorType == "Animal")
}
Dictionary<string, TreeNode> Categories = new Dictionary<string, TreeNode>();
foreach (var info in Actors)
{
if (info.Value.MessageName != string.Empty)
{
//Temp atm. Use message file name for organing
string catgeory = info.Value.MessageFile;
if (!Categories.ContainsKey(catgeory))
{
TreeNode node = new TreeNode(catgeory);
editor.AddNode(node);
Categories.Add(catgeory, node);
}
ActorEntry entry = new ActorEntry();
entry.Text = info.Value.MessageName;
Categories[catgeory].Nodes.Add(entry);
}
else if (actorType == "Npc")
{
}
}
}*/
//The game also caches certain actors to the pack folder at boot
if (ArmourFolder.Nodes.Count != 0)
editor.AddNode(ArmourFolder);
if (EnemyFolder.Nodes.Count != 0)
editor.AddNode(EnemyFolder);
if (ItemsFolder.Nodes.Count != 0)
editor.AddNode(ItemsFolder);
if (WeaponsFolder.Nodes.Count != 0)
editor.AddNode(WeaponsFolder);
Categories.Clear();
GC.Collect();
}
private bool NotifySetGamePath()
@ -254,7 +300,7 @@ namespace FirstPlugin
{
dir = folderSelect.SelectedPath;
Runtime.BotwGamePath = dir;
Config.Save();
Toolbox.Library.Config.Save();
}
}

View File

@ -150,6 +150,13 @@ namespace FirstPlugin
reader.ReadByte();
}
}
//Setup labels to text properly
if (Label1 != null && Text2 != null)
{
foreach (var label in Label1.Labels)
label.String = Text2.TextData[(int)label.Index];
}
}
public void Write(FileWriter writer)
@ -488,6 +495,8 @@ namespace FirstPlugin
entry.Index = reader.ReadUInt32();
entry.Checksum = (uint)Groups.IndexOf(group);
Labels.Add(entry);
Console.WriteLine("label entry " + entry.Name);
}
}

View File

@ -31,14 +31,16 @@
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
this.listViewCustom1 = new Toolbox.Library.Forms.ListViewCustom();
this.columnHeader1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.editTextTB = new Toolbox.Library.Forms.STTextBox();
this.stLabel1 = new Toolbox.Library.Forms.STLabel();
this.stLabel2 = new Toolbox.Library.Forms.STLabel();
this.originalTextTB = new Toolbox.Library.Forms.STTextBox();
this.stLabel3 = new Toolbox.Library.Forms.STLabel();
this.hexEditor1 = new Toolbox.Library.Forms.HexEditor();
this.splitContainer2 = new System.Windows.Forms.SplitContainer();
this.splitContainer3 = new System.Windows.Forms.SplitContainer();
this.editTextTB = new Toolbox.Library.Forms.STTextBox();
this.stLabel1 = new Toolbox.Library.Forms.STLabel();
this.originalTextTB = new Toolbox.Library.Forms.STTextBox();
this.stLabel2 = new Toolbox.Library.Forms.STLabel();
this.hexEditor1 = new Toolbox.Library.Forms.HexEditor();
this.stLabel3 = new Toolbox.Library.Forms.STLabel();
this.stMenuStrip1 = new Toolbox.Library.Forms.STMenuStrip();
this.viewToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
this.splitContainer1.Panel1.SuspendLayout();
this.splitContainer1.Panel2.SuspendLayout();
@ -51,13 +53,15 @@
this.splitContainer3.Panel1.SuspendLayout();
this.splitContainer3.Panel2.SuspendLayout();
this.splitContainer3.SuspendLayout();
this.stMenuStrip1.SuspendLayout();
this.SuspendLayout();
this.Controls.Add(this.splitContainer1);
//
// splitContainer1
//
this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
this.splitContainer1.Location = new System.Drawing.Point(0, 25);
this.splitContainer1.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.splitContainer1.Location = new System.Drawing.Point(0, 27);
this.splitContainer1.Name = "splitContainer1";
//
// splitContainer1.Panel1
@ -67,7 +71,7 @@
// splitContainer1.Panel2
//
this.splitContainer1.Panel2.Controls.Add(this.splitContainer2);
this.splitContainer1.Size = new System.Drawing.Size(916, 495);
this.splitContainer1.Size = new System.Drawing.Size(916, 493);
this.splitContainer1.SplitterDistance = 305;
this.splitContainer1.TabIndex = 11;
//
@ -80,7 +84,7 @@
this.listViewCustom1.Location = new System.Drawing.Point(0, 0);
this.listViewCustom1.Name = "listViewCustom1";
this.listViewCustom1.OwnerDraw = true;
this.listViewCustom1.Size = new System.Drawing.Size(305, 495);
this.listViewCustom1.Size = new System.Drawing.Size(305, 493);
this.listViewCustom1.TabIndex = 0;
this.listViewCustom1.UseCompatibleStateImageBehavior = false;
this.listViewCustom1.View = System.Windows.Forms.View.Details;
@ -88,69 +92,7 @@
//
// columnHeader1
//
this.columnHeader1.Width = 181;
//
// editTextTB
//
this.editTextTB.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.editTextTB.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.editTextTB.Location = new System.Drawing.Point(3, 16);
this.editTextTB.Multiline = true;
this.editTextTB.Name = "editTextTB";
this.editTextTB.Size = new System.Drawing.Size(200, 286);
this.editTextTB.TabIndex = 0;
//
// stLabel1
//
this.stLabel1.AutoSize = true;
this.stLabel1.Location = new System.Drawing.Point(0, 0);
this.stLabel1.Name = "stLabel1";
this.stLabel1.Size = new System.Drawing.Size(28, 13);
this.stLabel1.TabIndex = 1;
this.stLabel1.Text = "Edit:";
//
// stLabel2
//
this.stLabel2.AutoSize = true;
this.stLabel2.Location = new System.Drawing.Point(3, 0);
this.stLabel2.Name = "stLabel2";
this.stLabel2.Size = new System.Drawing.Size(45, 13);
this.stLabel2.TabIndex = 2;
this.stLabel2.Text = "Original:";
//
// originalTextTB
//
this.originalTextTB.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.originalTextTB.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.originalTextTB.Location = new System.Drawing.Point(3, 16);
this.originalTextTB.Multiline = true;
this.originalTextTB.Name = "originalTextTB";
this.originalTextTB.ReadOnly = true;
this.originalTextTB.Size = new System.Drawing.Size(385, 286);
this.originalTextTB.TabIndex = 3;
//
// stLabel3
//
this.stLabel3.AutoSize = true;
this.stLabel3.Location = new System.Drawing.Point(13, 4);
this.stLabel3.Name = "stLabel3";
this.stLabel3.Size = new System.Drawing.Size(55, 13);
this.stLabel3.TabIndex = 4;
this.stLabel3.Text = "Hex View:";
//
// hexEditor1
//
this.hexEditor1.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.hexEditor1.Location = new System.Drawing.Point(13, 29);
this.hexEditor1.Name = "hexEditor1";
this.hexEditor1.Size = new System.Drawing.Size(591, 154);
this.hexEditor1.TabIndex = 5;
this.columnHeader1.Width = 305;
//
// splitContainer2
//
@ -167,8 +109,8 @@
//
this.splitContainer2.Panel2.Controls.Add(this.hexEditor1);
this.splitContainer2.Panel2.Controls.Add(this.stLabel3);
this.splitContainer2.Size = new System.Drawing.Size(607, 495);
this.splitContainer2.SplitterDistance = 305;
this.splitContainer2.Size = new System.Drawing.Size(607, 493);
this.splitContainer2.SplitterDistance = 303;
this.splitContainer2.TabIndex = 6;
//
// splitContainer3
@ -186,17 +128,97 @@
//
this.splitContainer3.Panel2.Controls.Add(this.originalTextTB);
this.splitContainer3.Panel2.Controls.Add(this.stLabel2);
this.splitContainer3.Size = new System.Drawing.Size(607, 305);
this.splitContainer3.Size = new System.Drawing.Size(607, 303);
this.splitContainer3.SplitterDistance = 202;
this.splitContainer3.TabIndex = 0;
//
// editTextTB
//
this.editTextTB.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.editTextTB.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.editTextTB.Location = new System.Drawing.Point(3, 16);
this.editTextTB.Multiline = true;
this.editTextTB.Name = "editTextTB";
this.editTextTB.Size = new System.Drawing.Size(200, 284);
this.editTextTB.TabIndex = 0;
//
// stLabel1
//
this.stLabel1.AutoSize = true;
this.stLabel1.Location = new System.Drawing.Point(0, 0);
this.stLabel1.Name = "stLabel1";
this.stLabel1.Size = new System.Drawing.Size(28, 13);
this.stLabel1.TabIndex = 1;
this.stLabel1.Text = "Edit:";
//
// originalTextTB
//
this.originalTextTB.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.originalTextTB.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.originalTextTB.Location = new System.Drawing.Point(3, 16);
this.originalTextTB.Multiline = true;
this.originalTextTB.Name = "originalTextTB";
this.originalTextTB.ReadOnly = true;
this.originalTextTB.Size = new System.Drawing.Size(385, 284);
this.originalTextTB.TabIndex = 3;
//
// stLabel2
//
this.stLabel2.AutoSize = true;
this.stLabel2.Location = new System.Drawing.Point(3, 0);
this.stLabel2.Name = "stLabel2";
this.stLabel2.Size = new System.Drawing.Size(45, 13);
this.stLabel2.TabIndex = 2;
this.stLabel2.Text = "Original:";
//
// hexEditor1
//
this.hexEditor1.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.hexEditor1.EnableMenuBar = true;
this.hexEditor1.Location = new System.Drawing.Point(13, 29);
this.hexEditor1.Name = "hexEditor1";
this.hexEditor1.Size = new System.Drawing.Size(591, 154);
this.hexEditor1.TabIndex = 5;
//
// stLabel3
//
this.stLabel3.AutoSize = true;
this.stLabel3.Location = new System.Drawing.Point(13, 4);
this.stLabel3.Name = "stLabel3";
this.stLabel3.Size = new System.Drawing.Size(55, 13);
this.stLabel3.TabIndex = 4;
this.stLabel3.Text = "Hex View:";
//
// stMenuStrip1
//
this.stMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.viewToolStripMenuItem});
this.stMenuStrip1.Location = new System.Drawing.Point(0, 0);
this.stMenuStrip1.Name = "stMenuStrip1";
this.stMenuStrip1.Size = new System.Drawing.Size(922, 24);
this.stMenuStrip1.TabIndex = 12;
this.stMenuStrip1.Text = "stMenuStrip1";
//
// viewToolStripMenuItem
//
this.viewToolStripMenuItem.Name = "viewToolStripMenuItem";
this.viewToolStripMenuItem.Size = new System.Drawing.Size(44, 20);
this.viewToolStripMenuItem.Text = "View";
//
// MSBTEditor
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(922, 525);
this.Controls.Add(this.splitContainer1);
this.Controls.Add(this.stMenuStrip1);
this.Name = "MSBTEditor";
this.Text = "MSBTEditor";
this.Size = new System.Drawing.Size(922, 525);
this.splitContainer1.Panel1.ResumeLayout(false);
this.splitContainer1.Panel2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit();
@ -212,7 +234,10 @@
this.splitContainer3.Panel2.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.splitContainer3)).EndInit();
this.splitContainer3.ResumeLayout(false);
this.stMenuStrip1.ResumeLayout(false);
this.stMenuStrip1.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
}
@ -229,5 +254,7 @@
private Toolbox.Library.Forms.STTextBox editTextTB;
private System.Windows.Forms.SplitContainer splitContainer2;
private System.Windows.Forms.SplitContainer splitContainer3;
private Toolbox.Library.Forms.STMenuStrip stMenuStrip1;
private System.Windows.Forms.ToolStripMenuItem viewToolStripMenuItem;
}
}

View File

@ -15,6 +15,7 @@ namespace FirstPlugin.Forms
public partial class MSBTEditor : UserControl, IFIleEditor
{
public bool ShowPreviewText = true;
public bool ShowLabels = true;
public List<IFileFormat> GetFileFormats()
{
@ -42,14 +43,27 @@ namespace FirstPlugin.Forms
if (msbt.header.Text2 != null)
{
foreach (var text in msbt.header.Text2.TextData)
if (ShowLabels)
{
string listText = text.GetTextLabel(ShowPreviewText, msbt.header.StringEncoding);
foreach (var text in msbt.header.Label1.Labels)
{
string listText = text.Name;
listViewCustom1.Items.Add(listText);
}
listViewCustom1.Sorting = SortOrder.Ascending;
listViewCustom1.Sort();
}
else
{
foreach (var text in msbt.header.Text2.TextData)
{
string listText = text.GetTextLabel(ShowPreviewText, msbt.header.StringEncoding);
if (listText.Length > 25)
listText = $"{listText.Substring(0, 25)}......";
if (listText.Length > 25)
listText = $"{listText.Substring(0, 25)}......";
listViewCustom1.Items.Add(listText);
listViewCustom1.Items.Add(listText);
}
}
}
}
@ -62,7 +76,10 @@ namespace FirstPlugin.Forms
if (listViewCustom1.SelectedItems.Count > 0)
{
int index = listViewCustom1.SelectedIndices[0];
if (ShowLabels)
{
index = (int)activeMessageFile.header.Label1.Labels[index].Index;
}
var textSection = activeMessageFile.header.Text2;
if (textSection != null)
{

View File

@ -117,4 +117,7 @@
<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

@ -107,7 +107,7 @@ namespace FirstPlugin
private void ActorEditor(object sender, EventArgs args)
{
BotwActorLoader actorEditor = new BotwActorLoader();
UKing.Actors.BotwActorLoader actorEditor = new UKing.Actors.BotwActorLoader();
}
private void OpenKingdomSelector(object sender, EventArgs args)

View File

@ -107,6 +107,8 @@ namespace Toolbox.Library.Forms
public void SelectFirstNode() { if (ObjectTree != null) ObjectTree.SelectFirstNode(); }
public void SortTreeAscending() { if (ObjectTree != null) ObjectTree.SortTreeAscending(); }
public void UpdateTextureIcon(ISingleTextureIconLoader texturIcon) {
ObjectTree.LoadGenericTextureIcons(texturIcon);
}

View File

@ -558,6 +558,11 @@ namespace Toolbox.Library.Forms
treeViewCustom1.Sort();
}
public void SortTreeAscending()
{
treeViewCustom1.Sort();
}
private void splitter1_Resize(object sender, EventArgs e)
{
}