Add villager quickswap from GUI + clipboard

No juggling the house after finding the correct villager file; just put the villager internal name in your clipboard.
This commit is contained in:
Kurt 2021-02-06 15:12:04 -08:00
parent 9638ea6f45
commit 1403a5ed19
4 changed files with 60 additions and 7 deletions

View File

@ -38,6 +38,7 @@ private void InitializeComponent()
this.B_EditVillagerRoom = new System.Windows.Forms.ToolStripMenuItem();
this.B_EditVillagerDesign = new System.Windows.Forms.ToolStripMenuItem();
this.B_EditVillagerPlayerMemories = new System.Windows.Forms.ToolStripMenuItem();
this.B_EditDIYTimer = new System.Windows.Forms.ToolStripMenuItem();
this.TSS_toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
this.B_MoveOutAllVillagers = new System.Windows.Forms.ToolStripMenuItem();
this.B_LoadVillager = new System.Windows.Forms.Button();
@ -57,7 +58,7 @@ private void InitializeComponent()
this.NUD_Villager = new System.Windows.Forms.NumericUpDown();
this.B_EditHouses = new System.Windows.Forms.Button();
this.B_SetPhraseOriginal = new System.Windows.Forms.Button();
this.B_EditDIYTimer = new System.Windows.Forms.ToolStripMenuItem();
this.B_ReplaceVillager = new System.Windows.Forms.Button();
this.CM_EditVillager.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.NUD_Variant)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.NUD_Species)).BeginInit();
@ -109,7 +110,7 @@ private void InitializeComponent()
this.TSS_toolStripSeparator1,
this.B_MoveOutAllVillagers});
this.CM_EditVillager.Name = "CM_EditPlayer";
this.CM_EditVillager.Size = new System.Drawing.Size(186, 186);
this.CM_EditVillager.Size = new System.Drawing.Size(186, 164);
//
// B_EditFurniture
//
@ -146,6 +147,13 @@ private void InitializeComponent()
this.B_EditVillagerPlayerMemories.Text = "Edit Player Memories";
this.B_EditVillagerPlayerMemories.Click += new System.EventHandler(this.B_EditVillagerPlayerMemories_Click);
//
// B_EditDIYTimer
//
this.B_EditDIYTimer.Name = "B_EditDIYTimer";
this.B_EditDIYTimer.Size = new System.Drawing.Size(185, 22);
this.B_EditDIYTimer.Text = "Edit DIY Timer";
this.B_EditDIYTimer.Click += new System.EventHandler(this.B_EditDIYTimer_Click);
//
// TSS_toolStripSeparator1
//
this.TSS_toolStripSeparator1.Name = "TSS_toolStripSeparator1";
@ -328,17 +336,21 @@ private void InitializeComponent()
this.B_SetPhraseOriginal.UseVisualStyleBackColor = true;
this.B_SetPhraseOriginal.Click += new System.EventHandler(this.B_SetPhraseOriginal_Click);
//
// B_EditDIYTimer
// B_ReplaceVillager
//
this.B_EditDIYTimer.Name = "B_EditDIYTimer";
this.B_EditDIYTimer.Size = new System.Drawing.Size(185, 22);
this.B_EditDIYTimer.Text = "Edit DIY Timer";
this.B_EditDIYTimer.Click += new System.EventHandler(this.B_EditDIYTimer_Click);
this.B_ReplaceVillager.Location = new System.Drawing.Point(139, 119);
this.B_ReplaceVillager.Name = "B_ReplaceVillager";
this.B_ReplaceVillager.Size = new System.Drawing.Size(92, 40);
this.B_ReplaceVillager.TabIndex = 49;
this.B_ReplaceVillager.Text = "Replace Villager";
this.B_ReplaceVillager.UseVisualStyleBackColor = true;
this.B_ReplaceVillager.Click += new System.EventHandler(this.B_ReplaceVillager_Click);
//
// VillagerEditor
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.B_ReplaceVillager);
this.Controls.Add(this.B_SetPhraseOriginal);
this.Controls.Add(this.B_EditHouses);
this.Controls.Add(this.B_EditVillagerFlags);
@ -402,5 +414,6 @@ private void InitializeComponent()
private System.Windows.Forms.ToolStripMenuItem B_EditWear;
private System.Windows.Forms.Button B_SetPhraseOriginal;
private System.Windows.Forms.ToolStripMenuItem B_EditDIYTimer;
private System.Windows.Forms.Button B_ReplaceVillager;
}
}

View File

@ -3,6 +3,7 @@
using System.Windows.Forms;
using NHSE.Core;
using NHSE.Sprites;
using NHSE.Villagers;
namespace NHSE.WinForms
{
@ -276,5 +277,39 @@ private void B_SetPhraseOriginal_Click(object sender, EventArgs e)
var internalName = GetCurrentVillagerInternalName();
TB_Catchphrase.Text = GameInfo.Strings.GetVillagerDefaultPhrase(internalName);
}
private void B_ReplaceVillager_Click(object sender, EventArgs e)
{
if (!Clipboard.ContainsText())
{
WinFormsUtil.Error(MessageStrings.MsgVillagerReplaceNoText);
return;
}
var internalName = Clipboard.GetText();
if (!VillagerResources.IsVillagerDataKnown(internalName))
{
WinFormsUtil.Error(string.Format(MessageStrings.MsgVillagerReplaceUnknownName, internalName));
return;
}
var index = VillagerIndex;
var villager = Villagers[index];
if (villager is not Villager2 v2)
{
WinFormsUtil.Error(MessageStrings.MsgVillagerReplaceOutdatedSaveFormat);
return;
}
var houses = SAV.GetVillagerHouses();
var houseIndex = Array.FindIndex(houses, z => z.NPC1 == index);
var exist = new VillagerInfo(v2, houses[houseIndex]);
var replace = VillagerSwap.GetReplacementVillager(exist, internalName);
var nh = new VillagerHouse(replace.House);
SAV.SetVillagerHouse(nh, houseIndex);
var nv = new Villager2(replace.Villager);
LoadVillager(Villagers[index] = nv);
}
}
}

View File

@ -19,6 +19,7 @@
<ProjectReference Include="..\NHSE.Core\NHSE.Core.csproj" />
<ProjectReference Include="..\NHSE.Injection\NHSE.Injection.csproj" />
<ProjectReference Include="..\NHSE.Sprites\NHSE.Sprites.csproj" />
<ProjectReference Include="..\NHSE.Villagers\NHSE.Villagers.csproj" />
</ItemGroup>
<ItemGroup>

View File

@ -47,5 +47,9 @@ public static class MessageStrings
public static string MsgTerrainSetAllSkipExterior { get; set; } = "Do you want to skip the tiles in exterior acres (beach/rocks)?";
public static string MsgVillagerFriendshipMax { get; set; } = "Do you want to set all Villager Friendship memories to 255?";
public static string MsgVillagerReplaceNoText { get; set; } = "Clipboard: No text found! Expected internal villager name.";
public static string MsgVillagerReplaceOutdatedSaveFormat { get; set; } = "Save file is not up to date with latest villager format. Please update in-game.";
public static string MsgVillagerReplaceUnknownName { get; set; } = "Clipboard: {0} is not a valid internal villager name.";
}
}