diff --git a/NHSE.Core/Structures/GameFileDumper.cs b/NHSE.Core/Structures/GameFileDumper.cs
index dc9e512..7af5375 100644
--- a/NHSE.Core/Structures/GameFileDumper.cs
+++ b/NHSE.Core/Structures/GameFileDumper.cs
@@ -51,5 +51,21 @@ private static void Dump(string path, byte[] data, string name)
var file = Path.Combine(path, name);
File.WriteAllBytes(file, data);
}
+
+ ///
+ /// Dumps all villagers in their decrypted state to the requested .
+ ///
+ /// Save Data to dump from
+ /// Path to dump to
+ public static void DumpVillagers(this MainSave sav, string path)
+ {
+ for (int i = 0; i < 10; i++)
+ {
+ var v = sav.Offsets.ReadVillager(sav.Data, i);
+ var name = GameInfo.Strings.GetVillager(v.InternalName);
+ var dest = Path.Combine(path, $"{name}.nhv");
+ File.WriteAllBytes(dest, v.Data);
+ }
+ }
}
}
diff --git a/NHSE.WinForms/Editor.Designer.cs b/NHSE.WinForms/Editor.Designer.cs
index 20fc030..64423a9 100644
--- a/NHSE.WinForms/Editor.Designer.cs
+++ b/NHSE.WinForms/Editor.Designer.cs
@@ -67,6 +67,7 @@ private void InitializeComponent()
this.PB_Villager = new System.Windows.Forms.PictureBox();
this.L_VillagerID = new System.Windows.Forms.Label();
this.NUD_Villager = new System.Windows.Forms.NumericUpDown();
+ this.B_DumpVillager = new System.Windows.Forms.Button();
this.Menu_Editor.SuspendLayout();
this.TC_Editors.SuspendLayout();
this.Tab_Players.SuspendLayout();
@@ -321,6 +322,7 @@ private void InitializeComponent()
//
// Tab_Villagers
//
+ this.Tab_Villagers.Controls.Add(this.B_DumpVillager);
this.Tab_Villagers.Controls.Add(this.L_ExternalName);
this.Tab_Villagers.Controls.Add(this.L_InternalName);
this.Tab_Villagers.Controls.Add(this.TB_Catchphrase);
@@ -483,6 +485,16 @@ private void InitializeComponent()
0});
this.NUD_Villager.ValueChanged += new System.EventHandler(this.LoadVillager);
//
+ // B_DumpVillager
+ //
+ this.B_DumpVillager.Location = new System.Drawing.Point(6, 168);
+ this.B_DumpVillager.Name = "B_DumpVillager";
+ this.B_DumpVillager.Size = new System.Drawing.Size(100, 40);
+ this.B_DumpVillager.TabIndex = 24;
+ this.B_DumpVillager.Text = "Dump Villager";
+ this.B_DumpVillager.UseVisualStyleBackColor = true;
+ this.B_DumpVillager.Click += new System.EventHandler(this.B_DumpVillager_Click);
+ //
// Editor
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@@ -557,6 +569,7 @@ private void InitializeComponent()
private System.Windows.Forms.ContextMenuStrip CM_Picture;
private System.Windows.Forms.ToolStripMenuItem Menu_SavePNG;
private System.Windows.Forms.ToolStripMenuItem Menu_VerifyHashes;
+ private System.Windows.Forms.Button B_DumpVillager;
}
}
diff --git a/NHSE.WinForms/Editor.cs b/NHSE.WinForms/Editor.cs
index 15f4aae..7bf208b 100644
--- a/NHSE.WinForms/Editor.cs
+++ b/NHSE.WinForms/Editor.cs
@@ -222,7 +222,7 @@ private void Menu_SavePNG_Click(object sender, EventArgs e)
var bmp = pb.Image;
using var sfd = new SaveFileDialog
{
- Filter = "png file (*.png) | *.png | All files (*.*) | *.* ",
+ Filter = "png file (*.png)|*.png|All files (*.*)|*.*",
FileName = $"{name}.png",
};
if (sfd.ShowDialog() != DialogResult.OK)
@@ -230,5 +230,33 @@ private void Menu_SavePNG_Click(object sender, EventArgs e)
bmp.Save(sfd.FileName, ImageFormat.Png);
}
+
+ private void B_DumpVillager_Click(object sender, EventArgs e)
+ {
+ if (ModifierKeys == Keys.Shift)
+ {
+ using var fbd = new FolderBrowserDialog();
+ if (fbd.ShowDialog() != DialogResult.OK)
+ return;
+
+ var dir = Path.GetDirectoryName(fbd.SelectedPath);
+ if (dir == null || !Directory.Exists(dir))
+ return;
+ SAV.Main.DumpVillagers(dir);
+ }
+
+ var name = L_ExternalName.Text;
+ using var sfd = new SaveFileDialog
+ {
+ Filter = "New Horizons Villager (*.nhv)|*.nhv|All files (*.*)|*.*",
+ FileName = $"{name}.nhv",
+ };
+ if (sfd.ShowDialog() != DialogResult.OK)
+ return;
+
+ SaveVillager(VillagerIndex);
+ var data = SAV.Main.Offsets.ReadVillager(SAV.Main.Data, VillagerIndex).Data;
+ File.WriteAllBytes(sfd.FileName, data);
+ }
}
}
diff --git a/NHSE.WinForms/Subforms/PlayerItemEditor.Designer.cs b/NHSE.WinForms/Subforms/PlayerItemEditor.Designer.cs
index 5e9d8ed..405f967 100644
--- a/NHSE.WinForms/Subforms/PlayerItemEditor.Designer.cs
+++ b/NHSE.WinForms/Subforms/PlayerItemEditor.Designer.cs
@@ -32,6 +32,8 @@ private void InitializeComponent()
this.B_Save = new System.Windows.Forms.Button();
this.TC_Groups = new System.Windows.Forms.TabControl();
this.ItemEditor = new NHSE.WinForms.ItemEditor();
+ this.B_Dump = new System.Windows.Forms.Button();
+ this.B_Load = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// B_Cancel
@@ -78,11 +80,33 @@ private void InitializeComponent()
this.ItemEditor.Size = new System.Drawing.Size(150, 210);
this.ItemEditor.TabIndex = 6;
//
+ // B_Dump
+ //
+ this.B_Dump.Location = new System.Drawing.Point(9, 228);
+ this.B_Dump.Name = "B_Dump";
+ this.B_Dump.Size = new System.Drawing.Size(90, 23);
+ this.B_Dump.TabIndex = 7;
+ this.B_Dump.Text = "Dump";
+ this.B_Dump.UseVisualStyleBackColor = true;
+ this.B_Dump.Click += new System.EventHandler(this.B_Dump_Click);
+ //
+ // B_Load
+ //
+ this.B_Load.Location = new System.Drawing.Point(105, 228);
+ this.B_Load.Name = "B_Load";
+ this.B_Load.Size = new System.Drawing.Size(90, 23);
+ this.B_Load.TabIndex = 8;
+ this.B_Load.Text = "Load";
+ this.B_Load.UseVisualStyleBackColor = true;
+ this.B_Load.Click += new System.EventHandler(this.B_Load_Click);
+ //
// PlayerItemEditor
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(584, 261);
+ this.Controls.Add(this.B_Load);
+ this.Controls.Add(this.B_Dump);
this.Controls.Add(this.ItemEditor);
this.Controls.Add(this.B_Cancel);
this.Controls.Add(this.B_Save);
@@ -103,5 +127,7 @@ private void InitializeComponent()
private System.Windows.Forms.Button B_Save;
private System.Windows.Forms.TabControl TC_Groups;
private ItemEditor ItemEditor;
+ private System.Windows.Forms.Button B_Dump;
+ private System.Windows.Forms.Button B_Load;
}
}
\ No newline at end of file
diff --git a/NHSE.WinForms/Subforms/PlayerItemEditor.cs b/NHSE.WinForms/Subforms/PlayerItemEditor.cs
index d0f0cbf..125b458 100644
--- a/NHSE.WinForms/Subforms/PlayerItemEditor.cs
+++ b/NHSE.WinForms/Subforms/PlayerItemEditor.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using System.IO;
using System.Linq;
using System.Windows.Forms;
using NHSE.Core;
@@ -11,6 +12,7 @@ public partial class PlayerItemEditor : Form
private readonly Player Player;
private readonly InventorySet[] Inventory;
private readonly string[] items;
+ private readonly ItemGridEditor[] Editors;
public PlayerItemEditor(Player player)
{
@@ -33,22 +35,27 @@ public PlayerItemEditor(Player player)
}
ItemEditor.Initialize(items);
- CreateTabs();
+ Editors = CreateTabs();
}
- private void CreateTabs()
+ private ItemGridEditor[] CreateTabs()
{
- var i = items;
- foreach (var p in Inventory)
+ var itemlist = items;
+ var editors = new ItemGridEditor[Inventory.Length];
+ for (var i = 0; i < Inventory.Length; i++)
{
- var tab = new TabPage { Name = $"Tab_{p.Type}", Text = p.Type.ToString() };
- var grid = new ItemGridEditor(ItemEditor, p.Items, i) { Dock = DockStyle.Fill };
+ var p = Inventory[i];
+ var tab = new TabPage {Name = $"Tab_{p.Type}", Text = p.Type.ToString()};
+ var grid = new ItemGridEditor(ItemEditor, p.Items, itemlist) {Dock = DockStyle.Fill};
grid.InitializeGrid(10, 4);
tab.Controls.Add(grid);
TC_Groups.TabPages.Add(tab);
TC_Groups.ShowToolTips = true;
tab.ToolTipText = p.Type.ToString();
+ editors[i] = grid;
}
+
+ return editors;
}
private static InventorySet[] GetInventory(Player player)
@@ -77,5 +84,46 @@ private void B_Save_Click(object sender, EventArgs e)
SetInventory(Player);
Close();
}
+
+ private void B_Dump_Click(object sender, EventArgs e)
+ {
+ var selected = TC_Groups.SelectedTab;
+ using var sfd = new SaveFileDialog
+ {
+ Filter = "New Horizons Inventory (*.nhi)|*.nhi|All files (*.*)|*.*",
+ FileName = $"{selected.Text}.nhi",
+ };
+ if (sfd.ShowDialog() != DialogResult.OK)
+ return;
+ var index = TC_Groups.SelectedIndex;
+ var inv = Inventory[index];
+ var content = inv.Items.ToArray();
+ var bytes = Item.SetArray(content);
+ File.WriteAllBytes(sfd.FileName, bytes);
+ }
+
+ private void B_Load_Click(object sender, EventArgs e)
+ {
+ var selected = TC_Groups.SelectedTab;
+ using var sfd = new OpenFileDialog
+ {
+ Filter = "New Horizons Inventory (*.nhi)|*.nhi|All files (*.*)|*.*",
+ FileName = $"{selected.Text}.nhi",
+ };
+ if (sfd.ShowDialog() != DialogResult.OK)
+ return;
+ var index = TC_Groups.SelectedIndex;
+ var inv = Inventory[index];
+
+ var data = File.ReadAllBytes(sfd.FileName);
+ var import = Item.GetArray(data);
+ var copyTo = inv.Items;
+ for (int i = 0; i < copyTo.Count && i < import.Length ; i++)
+ copyTo[i].CopyFrom(import[i]);
+
+ var grid = Editors[TC_Groups.SelectedIndex];
+ grid.LoadItems();
+ System.Media.SystemSounds.Asterisk.Play();
+ }
}
}