mirror of
https://github.com/kwsch/NHSE.git
synced 2026-04-25 07:37:02 -05:00
Extract villager editing to separate control
This commit is contained in:
parent
31dd3e04bc
commit
0e437bd5d1
|
|
@ -11,8 +11,24 @@ public sealed class MainSave : EncryptedFilePair
|
|||
public readonly MainSaveOffsets Offsets;
|
||||
public MainSave(string folder) : base(folder, "main") => Offsets = MainSaveOffsets.GetOffsets(Info);
|
||||
|
||||
public const int VillagerCount = 10;
|
||||
public Villager GetVillager(int index) => Offsets.ReadVillager(Data, index);
|
||||
public void SetVillager(Villager value, int index) => Offsets.WriteVillager(value, Data, index);
|
||||
|
||||
public Villager[] GetVillagers()
|
||||
{
|
||||
var villagers = new Villager[VillagerCount];
|
||||
for (int i = 0; i < villagers.Length; i++)
|
||||
villagers[i] = GetVillager(i);
|
||||
return villagers;
|
||||
}
|
||||
|
||||
public void SetVillagers(IReadOnlyList<Villager> villagers)
|
||||
{
|
||||
for (int i = 0; i < villagers.Count; i++)
|
||||
SetVillager(villagers[i], i);
|
||||
}
|
||||
|
||||
public DesignPattern GetDesign(int index) => Offsets.ReadPattern(Data, index);
|
||||
public void SetDesign(DesignPattern value, int index) => Offsets.WritePattern(value, Data, index);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
namespace NHSE.Core
|
||||
{
|
||||
|
|
@ -54,17 +55,19 @@ private static void Dump(string path, byte[] data, string name)
|
|||
/// <summary>
|
||||
/// Dumps all villagers in their decrypted state to the requested <see cref="path"/>.
|
||||
/// </summary>
|
||||
/// <param name="sav">Save Data to dump from</param>
|
||||
/// <param name="villagers">Data to dump from</param>
|
||||
/// <param name="path">Path to dump to</param>
|
||||
public static void DumpVillagers(this MainSave sav, string path)
|
||||
public static void DumpVillagers(this IEnumerable<Villager> villagers, string path)
|
||||
{
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
var v = sav.GetVillager(i);
|
||||
var name = GameInfo.Strings.GetVillager(v.InternalName);
|
||||
var dest = Path.Combine(path, $"{name}.nhv");
|
||||
File.WriteAllBytes(dest, v.Data);
|
||||
}
|
||||
foreach (var v in villagers)
|
||||
v.DumpVillager(path);
|
||||
}
|
||||
|
||||
private static void DumpVillager(this Villager v, string path)
|
||||
{
|
||||
var name = GameInfo.Strings.GetVillager(v.InternalName);
|
||||
var dest = Path.Combine(path, $"{name}.nhv");
|
||||
File.WriteAllBytes(dest, v.Data);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
299
NHSE.WinForms/Controls/VillagerEditor.Designer.cs
generated
Normal file
299
NHSE.WinForms/Controls/VillagerEditor.Designer.cs
generated
Normal file
|
|
@ -0,0 +1,299 @@
|
|||
namespace NHSE.WinForms
|
||||
{
|
||||
partial class VillagerEditor
|
||||
{
|
||||
/// <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 Component 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.B_EditVillagerFlags = new System.Windows.Forms.Button();
|
||||
this.CHK_VillagerMovingOut = new System.Windows.Forms.CheckBox();
|
||||
this.B_EditFurniture = new System.Windows.Forms.Button();
|
||||
this.B_LoadVillager = new System.Windows.Forms.Button();
|
||||
this.B_DumpVillager = new System.Windows.Forms.Button();
|
||||
this.L_ExternalName = new System.Windows.Forms.Label();
|
||||
this.L_InternalName = new System.Windows.Forms.Label();
|
||||
this.TB_Catchphrase = new System.Windows.Forms.TextBox();
|
||||
this.L_Catchphrase = new System.Windows.Forms.Label();
|
||||
this.L_Personality = new System.Windows.Forms.Label();
|
||||
this.NUD_Variant = new System.Windows.Forms.NumericUpDown();
|
||||
this.L_Variant = new System.Windows.Forms.Label();
|
||||
this.NUD_Species = new System.Windows.Forms.NumericUpDown();
|
||||
this.L_Species = new System.Windows.Forms.Label();
|
||||
this.CB_Personality = new System.Windows.Forms.ComboBox();
|
||||
this.PB_Villager = new System.Windows.Forms.PictureBox();
|
||||
this.L_VillagerID = new System.Windows.Forms.Label();
|
||||
this.NUD_Villager = new System.Windows.Forms.NumericUpDown();
|
||||
((System.ComponentModel.ISupportInitialize)(this.NUD_Variant)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.NUD_Species)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.PB_Villager)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.NUD_Villager)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// B_EditVillagerFlags
|
||||
//
|
||||
this.B_EditVillagerFlags.Location = new System.Drawing.Point(297, 165);
|
||||
this.B_EditVillagerFlags.Name = "B_EditVillagerFlags";
|
||||
this.B_EditVillagerFlags.Size = new System.Drawing.Size(92, 40);
|
||||
this.B_EditVillagerFlags.TabIndex = 46;
|
||||
this.B_EditVillagerFlags.Text = "Edit Flags";
|
||||
this.B_EditVillagerFlags.UseVisualStyleBackColor = true;
|
||||
this.B_EditVillagerFlags.Click += new System.EventHandler(this.B_EditVillagerFlags_Click);
|
||||
//
|
||||
// CHK_VillagerMovingOut
|
||||
//
|
||||
this.CHK_VillagerMovingOut.AutoSize = true;
|
||||
this.CHK_VillagerMovingOut.Location = new System.Drawing.Point(229, 96);
|
||||
this.CHK_VillagerMovingOut.Name = "CHK_VillagerMovingOut";
|
||||
this.CHK_VillagerMovingOut.Size = new System.Drawing.Size(81, 17);
|
||||
this.CHK_VillagerMovingOut.TabIndex = 45;
|
||||
this.CHK_VillagerMovingOut.Text = "Moving Out";
|
||||
this.CHK_VillagerMovingOut.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// B_EditFurniture
|
||||
//
|
||||
this.B_EditFurniture.Location = new System.Drawing.Point(199, 165);
|
||||
this.B_EditFurniture.Name = "B_EditFurniture";
|
||||
this.B_EditFurniture.Size = new System.Drawing.Size(92, 40);
|
||||
this.B_EditFurniture.TabIndex = 44;
|
||||
this.B_EditFurniture.Text = "Edit Furniture";
|
||||
this.B_EditFurniture.UseVisualStyleBackColor = true;
|
||||
this.B_EditFurniture.Click += new System.EventHandler(this.B_EditFurniture_Click);
|
||||
//
|
||||
// B_LoadVillager
|
||||
//
|
||||
this.B_LoadVillager.Location = new System.Drawing.Point(101, 165);
|
||||
this.B_LoadVillager.Name = "B_LoadVillager";
|
||||
this.B_LoadVillager.Size = new System.Drawing.Size(92, 40);
|
||||
this.B_LoadVillager.TabIndex = 43;
|
||||
this.B_LoadVillager.Text = "Load Villager";
|
||||
this.B_LoadVillager.UseVisualStyleBackColor = true;
|
||||
this.B_LoadVillager.Click += new System.EventHandler(this.B_LoadVillager_Click);
|
||||
//
|
||||
// B_DumpVillager
|
||||
//
|
||||
this.B_DumpVillager.Location = new System.Drawing.Point(3, 165);
|
||||
this.B_DumpVillager.Name = "B_DumpVillager";
|
||||
this.B_DumpVillager.Size = new System.Drawing.Size(92, 40);
|
||||
this.B_DumpVillager.TabIndex = 42;
|
||||
this.B_DumpVillager.Text = "Dump Villager";
|
||||
this.B_DumpVillager.UseVisualStyleBackColor = true;
|
||||
this.B_DumpVillager.Click += new System.EventHandler(this.B_DumpVillager_Click);
|
||||
//
|
||||
// L_ExternalName
|
||||
//
|
||||
this.L_ExternalName.AutoSize = true;
|
||||
this.L_ExternalName.Font = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.L_ExternalName.Location = new System.Drawing.Point(272, 8);
|
||||
this.L_ExternalName.Name = "L_ExternalName";
|
||||
this.L_ExternalName.Size = new System.Drawing.Size(91, 14);
|
||||
this.L_ExternalName.TabIndex = 41;
|
||||
this.L_ExternalName.Text = "externalName";
|
||||
//
|
||||
// L_InternalName
|
||||
//
|
||||
this.L_InternalName.AutoSize = true;
|
||||
this.L_InternalName.Font = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.L_InternalName.Location = new System.Drawing.Point(272, 28);
|
||||
this.L_InternalName.Name = "L_InternalName";
|
||||
this.L_InternalName.Size = new System.Drawing.Size(91, 14);
|
||||
this.L_InternalName.TabIndex = 40;
|
||||
this.L_InternalName.Text = "internalName";
|
||||
//
|
||||
// TB_Catchphrase
|
||||
//
|
||||
this.TB_Catchphrase.Location = new System.Drawing.Point(229, 70);
|
||||
this.TB_Catchphrase.Name = "TB_Catchphrase";
|
||||
this.TB_Catchphrase.Size = new System.Drawing.Size(100, 20);
|
||||
this.TB_Catchphrase.TabIndex = 39;
|
||||
//
|
||||
// L_Catchphrase
|
||||
//
|
||||
this.L_Catchphrase.Location = new System.Drawing.Point(139, 70);
|
||||
this.L_Catchphrase.Name = "L_Catchphrase";
|
||||
this.L_Catchphrase.Size = new System.Drawing.Size(84, 20);
|
||||
this.L_Catchphrase.TabIndex = 38;
|
||||
this.L_Catchphrase.Text = "Catchphrase:";
|
||||
this.L_Catchphrase.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
|
||||
//
|
||||
// L_Personality
|
||||
//
|
||||
this.L_Personality.Location = new System.Drawing.Point(139, 48);
|
||||
this.L_Personality.Name = "L_Personality";
|
||||
this.L_Personality.Size = new System.Drawing.Size(84, 20);
|
||||
this.L_Personality.TabIndex = 37;
|
||||
this.L_Personality.Text = "Personality:";
|
||||
this.L_Personality.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
|
||||
//
|
||||
// NUD_Variant
|
||||
//
|
||||
this.NUD_Variant.Location = new System.Drawing.Point(229, 26);
|
||||
this.NUD_Variant.Maximum = new decimal(new int[] {
|
||||
255,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.NUD_Variant.Name = "NUD_Variant";
|
||||
this.NUD_Variant.Size = new System.Drawing.Size(37, 20);
|
||||
this.NUD_Variant.TabIndex = 36;
|
||||
this.NUD_Variant.ValueChanged += new System.EventHandler(this.ChangeVillager);
|
||||
//
|
||||
// L_Variant
|
||||
//
|
||||
this.L_Variant.Location = new System.Drawing.Point(139, 26);
|
||||
this.L_Variant.Name = "L_Variant";
|
||||
this.L_Variant.Size = new System.Drawing.Size(84, 20);
|
||||
this.L_Variant.TabIndex = 35;
|
||||
this.L_Variant.Text = "Variant:";
|
||||
this.L_Variant.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
|
||||
//
|
||||
// NUD_Species
|
||||
//
|
||||
this.NUD_Species.Location = new System.Drawing.Point(229, 4);
|
||||
this.NUD_Species.Maximum = new decimal(new int[] {
|
||||
400,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.NUD_Species.Name = "NUD_Species";
|
||||
this.NUD_Species.Size = new System.Drawing.Size(37, 20);
|
||||
this.NUD_Species.TabIndex = 34;
|
||||
this.NUD_Species.ValueChanged += new System.EventHandler(this.ChangeVillager);
|
||||
//
|
||||
// L_Species
|
||||
//
|
||||
this.L_Species.Location = new System.Drawing.Point(139, 4);
|
||||
this.L_Species.Name = "L_Species";
|
||||
this.L_Species.Size = new System.Drawing.Size(84, 20);
|
||||
this.L_Species.TabIndex = 33;
|
||||
this.L_Species.Text = "Species:";
|
||||
this.L_Species.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
|
||||
//
|
||||
// CB_Personality
|
||||
//
|
||||
this.CB_Personality.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.CB_Personality.FormattingEnabled = true;
|
||||
this.CB_Personality.Location = new System.Drawing.Point(229, 48);
|
||||
this.CB_Personality.Name = "CB_Personality";
|
||||
this.CB_Personality.Size = new System.Drawing.Size(100, 21);
|
||||
this.CB_Personality.TabIndex = 32;
|
||||
//
|
||||
// PB_Villager
|
||||
//
|
||||
this.PB_Villager.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
this.PB_Villager.Location = new System.Drawing.Point(3, 30);
|
||||
this.PB_Villager.Name = "PB_Villager";
|
||||
this.PB_Villager.Size = new System.Drawing.Size(130, 130);
|
||||
this.PB_Villager.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
|
||||
this.PB_Villager.TabIndex = 31;
|
||||
this.PB_Villager.TabStop = false;
|
||||
//
|
||||
// L_VillagerID
|
||||
//
|
||||
this.L_VillagerID.Location = new System.Drawing.Point(3, 3);
|
||||
this.L_VillagerID.Name = "L_VillagerID";
|
||||
this.L_VillagerID.Size = new System.Drawing.Size(87, 20);
|
||||
this.L_VillagerID.TabIndex = 30;
|
||||
this.L_VillagerID.Text = "Villager Index:";
|
||||
this.L_VillagerID.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
|
||||
//
|
||||
// NUD_Villager
|
||||
//
|
||||
this.NUD_Villager.Location = new System.Drawing.Point(96, 3);
|
||||
this.NUD_Villager.Maximum = new decimal(new int[] {
|
||||
10,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.NUD_Villager.Minimum = new decimal(new int[] {
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.NUD_Villager.Name = "NUD_Villager";
|
||||
this.NUD_Villager.Size = new System.Drawing.Size(37, 20);
|
||||
this.NUD_Villager.TabIndex = 29;
|
||||
this.NUD_Villager.Value = new decimal(new int[] {
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.NUD_Villager.ValueChanged += new System.EventHandler(this.LoadVillager);
|
||||
//
|
||||
// VillagerEditor
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.Controls.Add(this.B_EditVillagerFlags);
|
||||
this.Controls.Add(this.CHK_VillagerMovingOut);
|
||||
this.Controls.Add(this.B_EditFurniture);
|
||||
this.Controls.Add(this.B_LoadVillager);
|
||||
this.Controls.Add(this.B_DumpVillager);
|
||||
this.Controls.Add(this.L_ExternalName);
|
||||
this.Controls.Add(this.L_InternalName);
|
||||
this.Controls.Add(this.TB_Catchphrase);
|
||||
this.Controls.Add(this.L_Catchphrase);
|
||||
this.Controls.Add(this.L_Personality);
|
||||
this.Controls.Add(this.NUD_Variant);
|
||||
this.Controls.Add(this.L_Variant);
|
||||
this.Controls.Add(this.NUD_Species);
|
||||
this.Controls.Add(this.L_Species);
|
||||
this.Controls.Add(this.CB_Personality);
|
||||
this.Controls.Add(this.PB_Villager);
|
||||
this.Controls.Add(this.L_VillagerID);
|
||||
this.Controls.Add(this.NUD_Villager);
|
||||
this.Name = "VillagerEditor";
|
||||
this.Size = new System.Drawing.Size(397, 214);
|
||||
((System.ComponentModel.ISupportInitialize)(this.NUD_Variant)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.NUD_Species)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.PB_Villager)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.NUD_Villager)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Button B_EditVillagerFlags;
|
||||
private System.Windows.Forms.CheckBox CHK_VillagerMovingOut;
|
||||
private System.Windows.Forms.Button B_EditFurniture;
|
||||
private System.Windows.Forms.Button B_LoadVillager;
|
||||
private System.Windows.Forms.Button B_DumpVillager;
|
||||
private System.Windows.Forms.Label L_ExternalName;
|
||||
private System.Windows.Forms.Label L_InternalName;
|
||||
private System.Windows.Forms.TextBox TB_Catchphrase;
|
||||
private System.Windows.Forms.Label L_Catchphrase;
|
||||
private System.Windows.Forms.Label L_Personality;
|
||||
private System.Windows.Forms.NumericUpDown NUD_Variant;
|
||||
private System.Windows.Forms.Label L_Variant;
|
||||
private System.Windows.Forms.NumericUpDown NUD_Species;
|
||||
private System.Windows.Forms.Label L_Species;
|
||||
private System.Windows.Forms.ComboBox CB_Personality;
|
||||
private System.Windows.Forms.PictureBox PB_Villager;
|
||||
private System.Windows.Forms.Label L_VillagerID;
|
||||
private System.Windows.Forms.NumericUpDown NUD_Villager;
|
||||
}
|
||||
}
|
||||
165
NHSE.WinForms/Controls/VillagerEditor.cs
Normal file
165
NHSE.WinForms/Controls/VillagerEditor.cs
Normal file
|
|
@ -0,0 +1,165 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Windows.Forms;
|
||||
using NHSE.Core;
|
||||
using NHSE.Sprites;
|
||||
|
||||
namespace NHSE.WinForms
|
||||
{
|
||||
public partial class VillagerEditor : UserControl
|
||||
{
|
||||
public Villager[] Villagers;
|
||||
public IVillagerOrigin Origin;
|
||||
private int VillagerIndex = -1;
|
||||
|
||||
public VillagerEditor(Villager[] villagers, IVillagerOrigin origin)
|
||||
{
|
||||
Villagers = villagers;
|
||||
Origin = origin;
|
||||
InitializeComponent();
|
||||
LoadVillagers();
|
||||
}
|
||||
|
||||
public void Save() => SaveVillager(VillagerIndex);
|
||||
|
||||
private void LoadVillagers()
|
||||
{
|
||||
CB_Personality.Items.Clear();
|
||||
var personalities = Enum.GetNames(typeof(VillagerPersonality));
|
||||
foreach (var p in personalities)
|
||||
CB_Personality.Items.Add(p);
|
||||
|
||||
VillagerIndex = -1;
|
||||
LoadVillager(0);
|
||||
}
|
||||
|
||||
private void LoadVillager(object sender, EventArgs e) => LoadVillager((int)NUD_Villager.Value - 1);
|
||||
|
||||
private void LoadVillager(int index)
|
||||
{
|
||||
if (VillagerIndex >= 0)
|
||||
SaveVillager(VillagerIndex);
|
||||
|
||||
if (index < 0)
|
||||
return;
|
||||
|
||||
LoadVillager(Villagers[index]);
|
||||
VillagerIndex = index;
|
||||
}
|
||||
|
||||
private void LoadVillager(Villager v)
|
||||
{
|
||||
NUD_Species.Value = v.Species;
|
||||
NUD_Variant.Value = v.Variant;
|
||||
CB_Personality.SelectedIndex = (int)v.Personality;
|
||||
TB_Catchphrase.Text = v.CatchPhrase;
|
||||
CHK_VillagerMovingOut.Checked = v.MovingOut;
|
||||
}
|
||||
|
||||
private void SaveVillager(int index)
|
||||
{
|
||||
var v = Villagers[index];
|
||||
|
||||
v.Species = (byte)NUD_Species.Value;
|
||||
v.Variant = (byte)NUD_Variant.Value;
|
||||
v.Personality = (VillagerPersonality)CB_Personality.SelectedIndex;
|
||||
v.CatchPhrase = TB_Catchphrase.Text;
|
||||
v.MovingOut = CHK_VillagerMovingOut.Checked;
|
||||
}
|
||||
|
||||
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;
|
||||
Villagers.DumpVillagers(fbd.SelectedPath);
|
||||
return;
|
||||
}
|
||||
|
||||
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 v = Villagers[VillagerIndex];
|
||||
File.WriteAllBytes(sfd.FileName, v.Data);
|
||||
}
|
||||
|
||||
private void B_LoadVillager_Click(object sender, EventArgs e)
|
||||
{
|
||||
var name = L_ExternalName.Text;
|
||||
using var ofd = new OpenFileDialog
|
||||
{
|
||||
Filter = "New Horizons Villager (*.nhv)|*.nhv|All files (*.*)|*.*",
|
||||
FileName = $"{name}.nhv",
|
||||
};
|
||||
if (ofd.ShowDialog() != DialogResult.OK)
|
||||
return;
|
||||
|
||||
var file = ofd.FileName;
|
||||
var original = Villagers[VillagerIndex];
|
||||
var expectLength = original.Data.Length;
|
||||
var fi = new FileInfo(file);
|
||||
if (fi.Length != expectLength)
|
||||
{
|
||||
var msg = $"Imported villager's data length (0x{fi.Length:X}) does not match the required length (0x{expectLength:X}).";
|
||||
WinFormsUtil.Error("Cancelling:", msg);
|
||||
return;
|
||||
}
|
||||
|
||||
var data = File.ReadAllBytes(ofd.FileName);
|
||||
var v = new Villager(data);
|
||||
var player0 = Origin;
|
||||
if (!v.IsOriginatedFrom(player0))
|
||||
{
|
||||
var result = WinFormsUtil.Prompt(MessageBoxButtons.YesNoCancel,
|
||||
$"Imported Villager did not originate from Resident Rep's data.", "Update values?");
|
||||
if (result == DialogResult.Cancel)
|
||||
return;
|
||||
if (result == DialogResult.Yes)
|
||||
v.ChangeOrigins(player0, v.Data);
|
||||
}
|
||||
|
||||
LoadVillager(Villagers[VillagerIndex] = v);
|
||||
}
|
||||
|
||||
private void B_EditFurniture_Click(object sender, EventArgs e)
|
||||
{
|
||||
var v = Villagers[VillagerIndex];
|
||||
var items = v.Furniture;
|
||||
using var editor = new PlayerItemEditor<VillagerItem>(items, 8, 2);
|
||||
if (editor.ShowDialog() == DialogResult.OK)
|
||||
v.Furniture = items;
|
||||
}
|
||||
|
||||
private void B_EditVillagerFlags_Click(object sender, EventArgs e)
|
||||
{
|
||||
var v = Villagers[VillagerIndex];
|
||||
var flags = v.GetEventFlagsSave();
|
||||
using var editor = new VillagerFlagEditor(flags);
|
||||
if (editor.ShowDialog() == DialogResult.OK)
|
||||
v.SetEventFlagsSave(flags);
|
||||
}
|
||||
|
||||
private string GetCurrentVillagerInternalName() => VillagerUtil.GetInternalVillagerName((VillagerSpecies)NUD_Species.Value, (int)NUD_Variant.Value);
|
||||
private void ChangeVillager(object sender, EventArgs e) => ChangeVillager();
|
||||
private void ChangeVillager()
|
||||
{
|
||||
var name = GetCurrentVillagerInternalName();
|
||||
L_InternalName.Text = name;
|
||||
L_ExternalName.Text = GameInfo.Strings.GetVillager(name);
|
||||
PB_Villager.Image = VillagerSprite.GetVillagerSprite(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
120
NHSE.WinForms/Controls/VillagerEditor.resx
Normal file
120
NHSE.WinForms/Controls/VillagerEditor.resx
Normal 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>
|
||||
257
NHSE.WinForms/Editor.Designer.cs
generated
257
NHSE.WinForms/Editor.Designer.cs
generated
|
|
@ -16,6 +16,7 @@ protected override void Dispose(bool disposing)
|
|||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
Villagers.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
|
@ -61,22 +62,6 @@ private void InitializeComponent()
|
|||
this.CM_Picture = new System.Windows.Forms.ContextMenuStrip(this.components);
|
||||
this.Menu_SavePNG = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.Tab_Villagers = new System.Windows.Forms.TabPage();
|
||||
this.B_EditFurniture = new System.Windows.Forms.Button();
|
||||
this.B_LoadVillager = new System.Windows.Forms.Button();
|
||||
this.B_DumpVillager = new System.Windows.Forms.Button();
|
||||
this.L_ExternalName = new System.Windows.Forms.Label();
|
||||
this.L_InternalName = new System.Windows.Forms.Label();
|
||||
this.TB_Catchphrase = new System.Windows.Forms.TextBox();
|
||||
this.L_Catchphrase = new System.Windows.Forms.Label();
|
||||
this.L_Personality = new System.Windows.Forms.Label();
|
||||
this.NUD_Variant = new System.Windows.Forms.NumericUpDown();
|
||||
this.L_Variant = new System.Windows.Forms.Label();
|
||||
this.NUD_Species = new System.Windows.Forms.NumericUpDown();
|
||||
this.L_Species = new System.Windows.Forms.Label();
|
||||
this.CB_Personality = new System.Windows.Forms.ComboBox();
|
||||
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.Tab_Designs = new System.Windows.Forms.TabPage();
|
||||
this.PB_Palette = new System.Windows.Forms.PictureBox();
|
||||
this.L_PatternName = new System.Windows.Forms.Label();
|
||||
|
|
@ -92,8 +77,6 @@ private void InitializeComponent()
|
|||
this.B_EditTurnipExchange = new System.Windows.Forms.Button();
|
||||
this.B_EditBuildings = new System.Windows.Forms.Button();
|
||||
this.B_RecycleBin = new System.Windows.Forms.Button();
|
||||
this.CHK_VillagerMovingOut = new System.Windows.Forms.CheckBox();
|
||||
this.B_EditVillagerFlags = new System.Windows.Forms.Button();
|
||||
this.Menu_Editor.SuspendLayout();
|
||||
this.TC_Editors.SuspendLayout();
|
||||
this.Tab_Players.SuspendLayout();
|
||||
|
|
@ -102,11 +85,6 @@ private void InitializeComponent()
|
|||
((System.ComponentModel.ISupportInitialize)(this.NUD_BankBells)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.PB_Player)).BeginInit();
|
||||
this.CM_Picture.SuspendLayout();
|
||||
this.Tab_Villagers.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.NUD_Variant)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.NUD_Species)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.PB_Villager)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.NUD_Villager)).BeginInit();
|
||||
this.Tab_Designs.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.PB_Palette)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.NUD_PatternIndex)).BeginInit();
|
||||
|
|
@ -428,24 +406,6 @@ private void InitializeComponent()
|
|||
//
|
||||
// Tab_Villagers
|
||||
//
|
||||
this.Tab_Villagers.Controls.Add(this.B_EditVillagerFlags);
|
||||
this.Tab_Villagers.Controls.Add(this.CHK_VillagerMovingOut);
|
||||
this.Tab_Villagers.Controls.Add(this.B_EditFurniture);
|
||||
this.Tab_Villagers.Controls.Add(this.B_LoadVillager);
|
||||
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);
|
||||
this.Tab_Villagers.Controls.Add(this.L_Catchphrase);
|
||||
this.Tab_Villagers.Controls.Add(this.L_Personality);
|
||||
this.Tab_Villagers.Controls.Add(this.NUD_Variant);
|
||||
this.Tab_Villagers.Controls.Add(this.L_Variant);
|
||||
this.Tab_Villagers.Controls.Add(this.NUD_Species);
|
||||
this.Tab_Villagers.Controls.Add(this.L_Species);
|
||||
this.Tab_Villagers.Controls.Add(this.CB_Personality);
|
||||
this.Tab_Villagers.Controls.Add(this.PB_Villager);
|
||||
this.Tab_Villagers.Controls.Add(this.L_VillagerID);
|
||||
this.Tab_Villagers.Controls.Add(this.NUD_Villager);
|
||||
this.Tab_Villagers.Location = new System.Drawing.Point(4, 22);
|
||||
this.Tab_Villagers.Name = "Tab_Villagers";
|
||||
this.Tab_Villagers.Padding = new System.Windows.Forms.Padding(3);
|
||||
|
|
@ -454,177 +414,6 @@ private void InitializeComponent()
|
|||
this.Tab_Villagers.Text = "Villagers";
|
||||
this.Tab_Villagers.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// B_EditFurniture
|
||||
//
|
||||
this.B_EditFurniture.Location = new System.Drawing.Point(202, 168);
|
||||
this.B_EditFurniture.Name = "B_EditFurniture";
|
||||
this.B_EditFurniture.Size = new System.Drawing.Size(92, 40);
|
||||
this.B_EditFurniture.TabIndex = 26;
|
||||
this.B_EditFurniture.Text = "Edit Furniture";
|
||||
this.B_EditFurniture.UseVisualStyleBackColor = true;
|
||||
this.B_EditFurniture.Click += new System.EventHandler(this.B_EditFurniture_Click);
|
||||
//
|
||||
// B_LoadVillager
|
||||
//
|
||||
this.B_LoadVillager.Location = new System.Drawing.Point(104, 168);
|
||||
this.B_LoadVillager.Name = "B_LoadVillager";
|
||||
this.B_LoadVillager.Size = new System.Drawing.Size(92, 40);
|
||||
this.B_LoadVillager.TabIndex = 25;
|
||||
this.B_LoadVillager.Text = "Load Villager";
|
||||
this.B_LoadVillager.UseVisualStyleBackColor = true;
|
||||
this.B_LoadVillager.Click += new System.EventHandler(this.B_LoadVillager_Click);
|
||||
//
|
||||
// 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(92, 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);
|
||||
//
|
||||
// L_ExternalName
|
||||
//
|
||||
this.L_ExternalName.AutoSize = true;
|
||||
this.L_ExternalName.Font = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.L_ExternalName.Location = new System.Drawing.Point(275, 11);
|
||||
this.L_ExternalName.Name = "L_ExternalName";
|
||||
this.L_ExternalName.Size = new System.Drawing.Size(91, 14);
|
||||
this.L_ExternalName.TabIndex = 23;
|
||||
this.L_ExternalName.Text = "externalName";
|
||||
//
|
||||
// L_InternalName
|
||||
//
|
||||
this.L_InternalName.AutoSize = true;
|
||||
this.L_InternalName.Font = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.L_InternalName.Location = new System.Drawing.Point(275, 31);
|
||||
this.L_InternalName.Name = "L_InternalName";
|
||||
this.L_InternalName.Size = new System.Drawing.Size(91, 14);
|
||||
this.L_InternalName.TabIndex = 22;
|
||||
this.L_InternalName.Text = "internalName";
|
||||
//
|
||||
// TB_Catchphrase
|
||||
//
|
||||
this.TB_Catchphrase.Location = new System.Drawing.Point(232, 73);
|
||||
this.TB_Catchphrase.Name = "TB_Catchphrase";
|
||||
this.TB_Catchphrase.Size = new System.Drawing.Size(100, 20);
|
||||
this.TB_Catchphrase.TabIndex = 21;
|
||||
//
|
||||
// L_Catchphrase
|
||||
//
|
||||
this.L_Catchphrase.Location = new System.Drawing.Point(142, 73);
|
||||
this.L_Catchphrase.Name = "L_Catchphrase";
|
||||
this.L_Catchphrase.Size = new System.Drawing.Size(84, 20);
|
||||
this.L_Catchphrase.TabIndex = 20;
|
||||
this.L_Catchphrase.Text = "Catchphrase:";
|
||||
this.L_Catchphrase.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
|
||||
//
|
||||
// L_Personality
|
||||
//
|
||||
this.L_Personality.Location = new System.Drawing.Point(142, 51);
|
||||
this.L_Personality.Name = "L_Personality";
|
||||
this.L_Personality.Size = new System.Drawing.Size(84, 20);
|
||||
this.L_Personality.TabIndex = 19;
|
||||
this.L_Personality.Text = "Personality:";
|
||||
this.L_Personality.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
|
||||
//
|
||||
// NUD_Variant
|
||||
//
|
||||
this.NUD_Variant.Location = new System.Drawing.Point(232, 29);
|
||||
this.NUD_Variant.Maximum = new decimal(new int[] {
|
||||
255,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.NUD_Variant.Name = "NUD_Variant";
|
||||
this.NUD_Variant.Size = new System.Drawing.Size(37, 20);
|
||||
this.NUD_Variant.TabIndex = 18;
|
||||
this.NUD_Variant.ValueChanged += new System.EventHandler(this.ChangeVillager);
|
||||
//
|
||||
// L_Variant
|
||||
//
|
||||
this.L_Variant.Location = new System.Drawing.Point(142, 29);
|
||||
this.L_Variant.Name = "L_Variant";
|
||||
this.L_Variant.Size = new System.Drawing.Size(84, 20);
|
||||
this.L_Variant.TabIndex = 17;
|
||||
this.L_Variant.Text = "Variant:";
|
||||
this.L_Variant.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
|
||||
//
|
||||
// NUD_Species
|
||||
//
|
||||
this.NUD_Species.Location = new System.Drawing.Point(232, 7);
|
||||
this.NUD_Species.Maximum = new decimal(new int[] {
|
||||
400,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.NUD_Species.Name = "NUD_Species";
|
||||
this.NUD_Species.Size = new System.Drawing.Size(37, 20);
|
||||
this.NUD_Species.TabIndex = 16;
|
||||
this.NUD_Species.ValueChanged += new System.EventHandler(this.ChangeVillager);
|
||||
//
|
||||
// L_Species
|
||||
//
|
||||
this.L_Species.Location = new System.Drawing.Point(142, 7);
|
||||
this.L_Species.Name = "L_Species";
|
||||
this.L_Species.Size = new System.Drawing.Size(84, 20);
|
||||
this.L_Species.TabIndex = 15;
|
||||
this.L_Species.Text = "Species:";
|
||||
this.L_Species.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
|
||||
//
|
||||
// CB_Personality
|
||||
//
|
||||
this.CB_Personality.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.CB_Personality.FormattingEnabled = true;
|
||||
this.CB_Personality.Location = new System.Drawing.Point(232, 51);
|
||||
this.CB_Personality.Name = "CB_Personality";
|
||||
this.CB_Personality.Size = new System.Drawing.Size(100, 21);
|
||||
this.CB_Personality.TabIndex = 14;
|
||||
//
|
||||
// PB_Villager
|
||||
//
|
||||
this.PB_Villager.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
this.PB_Villager.ContextMenuStrip = this.CM_Picture;
|
||||
this.PB_Villager.Location = new System.Drawing.Point(6, 33);
|
||||
this.PB_Villager.Name = "PB_Villager";
|
||||
this.PB_Villager.Size = new System.Drawing.Size(130, 130);
|
||||
this.PB_Villager.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
|
||||
this.PB_Villager.TabIndex = 13;
|
||||
this.PB_Villager.TabStop = false;
|
||||
//
|
||||
// L_VillagerID
|
||||
//
|
||||
this.L_VillagerID.Location = new System.Drawing.Point(6, 6);
|
||||
this.L_VillagerID.Name = "L_VillagerID";
|
||||
this.L_VillagerID.Size = new System.Drawing.Size(87, 20);
|
||||
this.L_VillagerID.TabIndex = 12;
|
||||
this.L_VillagerID.Text = "Villager Index:";
|
||||
this.L_VillagerID.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
|
||||
//
|
||||
// NUD_Villager
|
||||
//
|
||||
this.NUD_Villager.Location = new System.Drawing.Point(99, 6);
|
||||
this.NUD_Villager.Maximum = new decimal(new int[] {
|
||||
10,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.NUD_Villager.Minimum = new decimal(new int[] {
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.NUD_Villager.Name = "NUD_Villager";
|
||||
this.NUD_Villager.Size = new System.Drawing.Size(37, 20);
|
||||
this.NUD_Villager.TabIndex = 0;
|
||||
this.NUD_Villager.Value = new decimal(new int[] {
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.NUD_Villager.ValueChanged += new System.EventHandler(this.LoadVillager);
|
||||
//
|
||||
// Tab_Designs
|
||||
//
|
||||
this.Tab_Designs.Controls.Add(this.PB_Palette);
|
||||
|
|
@ -803,26 +592,6 @@ private void InitializeComponent()
|
|||
this.B_RecycleBin.UseVisualStyleBackColor = true;
|
||||
this.B_RecycleBin.Click += new System.EventHandler(this.B_RecycleBin_Click);
|
||||
//
|
||||
// CHK_VillagerMovingOut
|
||||
//
|
||||
this.CHK_VillagerMovingOut.AutoSize = true;
|
||||
this.CHK_VillagerMovingOut.Location = new System.Drawing.Point(232, 99);
|
||||
this.CHK_VillagerMovingOut.Name = "CHK_VillagerMovingOut";
|
||||
this.CHK_VillagerMovingOut.Size = new System.Drawing.Size(81, 17);
|
||||
this.CHK_VillagerMovingOut.TabIndex = 27;
|
||||
this.CHK_VillagerMovingOut.Text = "Moving Out";
|
||||
this.CHK_VillagerMovingOut.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// B_EditVillagerFlags
|
||||
//
|
||||
this.B_EditVillagerFlags.Location = new System.Drawing.Point(300, 168);
|
||||
this.B_EditVillagerFlags.Name = "B_EditVillagerFlags";
|
||||
this.B_EditVillagerFlags.Size = new System.Drawing.Size(92, 40);
|
||||
this.B_EditVillagerFlags.TabIndex = 28;
|
||||
this.B_EditVillagerFlags.Text = "Edit Flags";
|
||||
this.B_EditVillagerFlags.UseVisualStyleBackColor = true;
|
||||
this.B_EditVillagerFlags.Click += new System.EventHandler(this.B_EditVillagerFlags_Click);
|
||||
//
|
||||
// Editor
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
|
|
@ -846,12 +615,6 @@ private void InitializeComponent()
|
|||
((System.ComponentModel.ISupportInitialize)(this.NUD_BankBells)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.PB_Player)).EndInit();
|
||||
this.CM_Picture.ResumeLayout(false);
|
||||
this.Tab_Villagers.ResumeLayout(false);
|
||||
this.Tab_Villagers.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.NUD_Variant)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.NUD_Species)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.PB_Villager)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.NUD_Villager)).EndInit();
|
||||
this.Tab_Designs.ResumeLayout(false);
|
||||
this.Tab_Designs.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.PB_Palette)).EndInit();
|
||||
|
|
@ -887,30 +650,14 @@ private void InitializeComponent()
|
|||
private System.Windows.Forms.NumericUpDown NUD_Wallet;
|
||||
private System.Windows.Forms.Button B_EditPlayerItems;
|
||||
private System.Windows.Forms.ToolStripMenuItem Menu_DumpDecrypted;
|
||||
private System.Windows.Forms.Label L_VillagerID;
|
||||
private System.Windows.Forms.NumericUpDown NUD_Villager;
|
||||
private System.Windows.Forms.PictureBox PB_Villager;
|
||||
private System.Windows.Forms.Label L_Species;
|
||||
private System.Windows.Forms.ComboBox CB_Personality;
|
||||
private System.Windows.Forms.NumericUpDown NUD_Species;
|
||||
private System.Windows.Forms.NumericUpDown NUD_Variant;
|
||||
private System.Windows.Forms.Label L_Variant;
|
||||
private System.Windows.Forms.Label L_Personality;
|
||||
private System.Windows.Forms.TextBox TB_Catchphrase;
|
||||
private System.Windows.Forms.Label L_Catchphrase;
|
||||
private System.Windows.Forms.Label L_InternalName;
|
||||
private System.Windows.Forms.Label L_ExternalName;
|
||||
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;
|
||||
private System.Windows.Forms.Button B_EditPlayerRecipes;
|
||||
private System.Windows.Forms.TabPage Tab_Map;
|
||||
private System.Windows.Forms.Button B_RecycleBin;
|
||||
private System.Windows.Forms.Button B_EditPlayerStorage;
|
||||
private System.Windows.Forms.ToolStripMenuItem Menu_LoadDecrypted;
|
||||
private System.Windows.Forms.Button B_LoadVillager;
|
||||
private System.Windows.Forms.Button B_EditFurniture;
|
||||
private System.Windows.Forms.Button B_EditPlayerReceivedItems;
|
||||
private System.Windows.Forms.TabPage Tab_Designs;
|
||||
private System.Windows.Forms.Button B_LoadDesign;
|
||||
|
|
@ -928,8 +675,6 @@ private void InitializeComponent()
|
|||
private System.Windows.Forms.Button B_EditTerrain;
|
||||
private System.Windows.Forms.Button B_EditPlayerFlags;
|
||||
private System.Windows.Forms.Button B_EditFieldItems;
|
||||
private System.Windows.Forms.CheckBox CHK_VillagerMovingOut;
|
||||
private System.Windows.Forms.Button B_EditVillagerFlags;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,12 +13,16 @@ namespace NHSE.WinForms
|
|||
public partial class Editor : Form
|
||||
{
|
||||
private readonly HorizonSave SAV;
|
||||
private readonly VillagerEditor Villagers;
|
||||
|
||||
public Editor(HorizonSave file)
|
||||
{
|
||||
InitializeComponent();
|
||||
SAV = file;
|
||||
LoadAll();
|
||||
|
||||
LoadPlayers();
|
||||
LoadMain();
|
||||
Villagers = LoadVillagers();
|
||||
}
|
||||
|
||||
private void Menu_Open_Click(object sender, EventArgs e)
|
||||
|
|
@ -75,7 +79,7 @@ private void LoadDecryptedFromPath(string main)
|
|||
}
|
||||
|
||||
SAV.Load(dir);
|
||||
LoadAll(); // reload all fields
|
||||
ReloadAll(); // reload all fields
|
||||
System.Media.SystemSounds.Asterisk.Play();
|
||||
}
|
||||
|
||||
|
|
@ -108,17 +112,28 @@ private void Menu_RAMEdit_Click(object sender, EventArgs e)
|
|||
sysbot.Show();
|
||||
}
|
||||
|
||||
private void LoadAll()
|
||||
private void ReloadAll()
|
||||
{
|
||||
Villagers.Villagers = SAV.Main.GetVillagers();
|
||||
Villagers.Origin = SAV.Players[0].Personal;
|
||||
LoadPlayers();
|
||||
LoadVillagers();
|
||||
LoadMain();
|
||||
}
|
||||
|
||||
private VillagerEditor LoadVillagers()
|
||||
{
|
||||
var p0 = SAV.Players[0].Personal;
|
||||
var villagers = SAV.Main.GetVillagers();
|
||||
var v = new VillagerEditor(villagers, p0) {Dock = DockStyle.Fill};
|
||||
Tab_Villagers.Controls.Add(v);
|
||||
return v;
|
||||
}
|
||||
|
||||
private void SaveAll()
|
||||
{
|
||||
SavePlayer(PlayerIndex);
|
||||
SaveVillager(VillagerIndex);
|
||||
Villagers.Save();
|
||||
SAV.Main.SetVillagers(Villagers.Villagers);
|
||||
}
|
||||
|
||||
#region Player Editing
|
||||
|
|
@ -133,17 +148,6 @@ private void LoadPlayers()
|
|||
CB_Players.SelectedIndex = 0;
|
||||
}
|
||||
|
||||
private void LoadVillagers()
|
||||
{
|
||||
CB_Personality.Items.Clear();
|
||||
var personalities = Enum.GetNames(typeof(VillagerPersonality));
|
||||
foreach (var p in personalities)
|
||||
CB_Personality.Items.Add(p);
|
||||
|
||||
VillagerIndex = -1;
|
||||
LoadVillager(0);
|
||||
}
|
||||
|
||||
private void LoadMain()
|
||||
{
|
||||
LoadPattern(0);
|
||||
|
|
@ -151,7 +155,6 @@ private void LoadMain()
|
|||
|
||||
private int PlayerIndex = -1;
|
||||
private void LoadPlayer(object sender, EventArgs e) => LoadPlayer(CB_Players.SelectedIndex);
|
||||
private void LoadVillager(object sender, EventArgs e) => LoadVillager((int)NUD_Villager.Value - 1);
|
||||
private void LoadPattern(object sender, EventArgs e) => LoadPattern((int)NUD_PatternIndex.Value - 1);
|
||||
|
||||
private void B_EditPlayerItems_Click(object sender, EventArgs e)
|
||||
|
|
@ -283,57 +286,6 @@ private void B_EditPlayerFlags_Click(object sender, EventArgs e)
|
|||
|
||||
#endregion
|
||||
|
||||
#region Villager Editing
|
||||
|
||||
private int VillagerIndex = -1;
|
||||
|
||||
private void LoadVillager(int index)
|
||||
{
|
||||
if (VillagerIndex >= 0)
|
||||
SaveVillager(VillagerIndex);
|
||||
|
||||
if (index < 0)
|
||||
return;
|
||||
|
||||
var v = SAV.Main.GetVillager(index);
|
||||
LoadVillager(v);
|
||||
VillagerIndex = index;
|
||||
}
|
||||
|
||||
private void LoadVillager(Villager v)
|
||||
{
|
||||
NUD_Species.Value = v.Species;
|
||||
NUD_Variant.Value = v.Variant;
|
||||
CB_Personality.SelectedIndex = (int) v.Personality;
|
||||
TB_Catchphrase.Text = v.CatchPhrase;
|
||||
CHK_VillagerMovingOut.Checked = v.MovingOut;
|
||||
}
|
||||
|
||||
private void SaveVillager(int index)
|
||||
{
|
||||
var v = SAV.Main.GetVillager(index);
|
||||
|
||||
v.Species = (byte)NUD_Species.Value;
|
||||
v.Variant = (byte)NUD_Variant.Value;
|
||||
v.Personality = (VillagerPersonality)CB_Personality.SelectedIndex;
|
||||
v.CatchPhrase = TB_Catchphrase.Text;
|
||||
v.MovingOut = CHK_VillagerMovingOut.Checked;
|
||||
|
||||
SAV.Main.SetVillager(v, index);
|
||||
}
|
||||
|
||||
private string GetCurrentVillagerInternalName() => VillagerUtil.GetInternalVillagerName((VillagerSpecies)NUD_Species.Value, (int)NUD_Variant.Value);
|
||||
private void ChangeVillager(object sender, EventArgs e) => ChangeVillager();
|
||||
private void ChangeVillager()
|
||||
{
|
||||
var name = GetCurrentVillagerInternalName();
|
||||
L_InternalName.Text = name;
|
||||
L_ExternalName.Text = GameInfo.Strings.GetVillager(name);
|
||||
PB_Villager.Image = VillagerSprite.GetVillagerSprite(name);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Patterns
|
||||
|
||||
private int PatternIndex = -1;
|
||||
|
|
@ -368,8 +320,6 @@ private void Menu_SavePNG_Click(object sender, EventArgs e)
|
|||
string name;
|
||||
if (pb == PB_Player)
|
||||
name = SAV.Players[PlayerIndex].Personal.PlayerName;
|
||||
else if (pb == PB_Villager)
|
||||
name = L_ExternalName.Text;
|
||||
else
|
||||
name = "photo";
|
||||
|
||||
|
|
@ -385,98 +335,6 @@ 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(fbd.SelectedPath);
|
||||
return;
|
||||
}
|
||||
|
||||
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 v = SAV.Main.GetVillager(VillagerIndex);
|
||||
File.WriteAllBytes(sfd.FileName, v.Data);
|
||||
}
|
||||
|
||||
private void B_LoadVillager_Click(object sender, EventArgs e)
|
||||
{
|
||||
var name = L_ExternalName.Text;
|
||||
using var ofd = new OpenFileDialog
|
||||
{
|
||||
Filter = "New Horizons Villager (*.nhv)|*.nhv|All files (*.*)|*.*",
|
||||
FileName = $"{name}.nhv",
|
||||
};
|
||||
if (ofd.ShowDialog() != DialogResult.OK)
|
||||
return;
|
||||
|
||||
var file = ofd.FileName;
|
||||
var original = SAV.Main.GetVillager(VillagerIndex);
|
||||
var expectLength = original.Data.Length;
|
||||
var fi = new FileInfo(file);
|
||||
if (fi.Length != expectLength)
|
||||
{
|
||||
var msg = $"Imported villager's data length (0x{fi.Length:X}) does not match the required length (0x{expectLength:X}).";
|
||||
WinFormsUtil.Error("Cancelling:", msg);
|
||||
return;
|
||||
}
|
||||
|
||||
var data = File.ReadAllBytes(ofd.FileName);
|
||||
var v = new Villager(data);
|
||||
var player0 = SAV.Players[0].Personal;
|
||||
if (!v.IsOriginatedFrom(player0))
|
||||
{
|
||||
var result = WinFormsUtil.Prompt(MessageBoxButtons.YesNoCancel,
|
||||
$"Imported Villager did not originate from Villager0 ({player0.PlayerName})'s data.", "Update values?");
|
||||
if (result == DialogResult.Cancel)
|
||||
return;
|
||||
if (result == DialogResult.Yes)
|
||||
v.ChangeOrigins(player0, v.Data);
|
||||
}
|
||||
|
||||
SAV.Main.SetVillager(v, VillagerIndex);
|
||||
LoadVillager(v);
|
||||
}
|
||||
|
||||
private void B_EditFurniture_Click(object sender, EventArgs e)
|
||||
{
|
||||
var v = SAV.Main.GetVillager(VillagerIndex);
|
||||
var items = v.Furniture;
|
||||
using var editor = new PlayerItemEditor<VillagerItem>(items, 8, 2);
|
||||
if (editor.ShowDialog() != DialogResult.OK)
|
||||
return;
|
||||
|
||||
v.Furniture = items;
|
||||
SAV.Main.SetVillager(v, VillagerIndex);
|
||||
}
|
||||
|
||||
private void B_EditVillagerFlags_Click(object sender, EventArgs e)
|
||||
{
|
||||
var v = SAV.Main.GetVillager(VillagerIndex);
|
||||
var flags = v.GetEventFlagsSave();
|
||||
using var editor = new VillagerFlagEditor(flags);
|
||||
if (editor.ShowDialog() != DialogResult.OK)
|
||||
return;
|
||||
|
||||
v.SetEventFlagsSave(flags);
|
||||
SAV.Main.SetVillager(v, VillagerIndex);
|
||||
}
|
||||
|
||||
private void B_DumpDesign_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (ModifierKeys == Keys.Shift)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user