Add pocket/bag count

Rename Pocket1/Pocket2 to Bag/Pocket respectively (bag is slots21-40)
This commit is contained in:
Kurt
2020-04-26 21:11:11 -07:00
parent 2b9d8b0c7a
commit beb4e8111a
5 changed files with 100 additions and 15 deletions

View File

@@ -58,18 +58,30 @@ public EncryptedInt32 NookMiles
set => value.Write(Data, Offsets.NookMiles);
}
public IReadOnlyList<Item> Pocket1
public IReadOnlyList<Item> Bag // Slots 21-40
{
get => Item.GetArray(Data.Slice(Offsets.Pockets1, Offsets.Pockets1Count * Item.SIZE));
set => Item.SetArray(value).CopyTo(Data, Offsets.Pockets1);
}
public IReadOnlyList<Item> Pocket2
public uint BagCount // Count of the Bag Slots that are available for use
{
get => BitConverter.ToUInt32(Data, Offsets.Pockets1 + (Offsets.Pockets1Count * Item.SIZE));
set => BitConverter.GetBytes(value).CopyTo(Data, Offsets.Pockets1 + (Offsets.Pockets1Count * Item.SIZE));
}
public IReadOnlyList<Item> Pocket // Slots 1-20
{
get => Item.GetArray(Data.Slice(Offsets.Pockets2, Offsets.Pockets2Count * Item.SIZE));
set => Item.SetArray(value).CopyTo(Data, Offsets.Pockets2);
}
public uint PocketCount // Count of the Pocket Slots that are available for use
{
get => BitConverter.ToUInt32(Data, Offsets.Pockets2 + (Offsets.Pockets2Count * Item.SIZE));
set => BitConverter.GetBytes(value).CopyTo(Data, Offsets.Pockets2 + (Offsets.Pockets2Count * Item.SIZE));
}
public IReadOnlyList<Item> Storage
{
get => Item.GetArray(Data.Slice(Offsets.Storage, Offsets.StorageCount * Item.SIZE));

View File

@@ -79,6 +79,10 @@ private void InitializeComponent()
this.PB_Player = new System.Windows.Forms.PictureBox();
this.TC_Editors = new System.Windows.Forms.TabControl();
this.B_EditPlayerHouses = new System.Windows.Forms.Button();
this.NUD_PocketCount1 = new System.Windows.Forms.NumericUpDown();
this.NUD_PocketCount2 = new System.Windows.Forms.NumericUpDown();
this.L_PocketCount1 = new System.Windows.Forms.Label();
this.L_PocketCount2 = new System.Windows.Forms.Label();
this.Menu_Editor.SuspendLayout();
this.CM_Picture.SuspendLayout();
this.Tab_Map.SuspendLayout();
@@ -90,6 +94,8 @@ private void InitializeComponent()
((System.ComponentModel.ISupportInitialize)(this.NUD_BankBells)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.PB_Player)).BeginInit();
this.TC_Editors.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.NUD_PocketCount1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.NUD_PocketCount2)).BeginInit();
this.SuspendLayout();
//
// Menu_Editor
@@ -340,6 +346,10 @@ private void InitializeComponent()
//
// Tab_Players
//
this.Tab_Players.Controls.Add(this.L_PocketCount2);
this.Tab_Players.Controls.Add(this.L_PocketCount1);
this.Tab_Players.Controls.Add(this.NUD_PocketCount2);
this.Tab_Players.Controls.Add(this.NUD_PocketCount1);
this.Tab_Players.Controls.Add(this.B_EditPlayer);
this.Tab_Players.Controls.Add(this.B_EditPlayerFlags);
this.Tab_Players.Controls.Add(this.B_EditPlayerItems);
@@ -570,6 +580,60 @@ private void InitializeComponent()
this.B_EditPlayerHouses.UseVisualStyleBackColor = true;
this.B_EditPlayerHouses.Click += new System.EventHandler(this.B_EditPlayerHouses_Click);
//
// NUD_PocketCount1
//
this.NUD_PocketCount1.Location = new System.Drawing.Point(104, 167);
this.NUD_PocketCount1.Maximum = new decimal(new int[] {
2147483647,
0,
0,
0});
this.NUD_PocketCount1.Name = "NUD_PocketCount1";
this.NUD_PocketCount1.Size = new System.Drawing.Size(41, 20);
this.NUD_PocketCount1.TabIndex = 19;
this.NUD_PocketCount1.Value = new decimal(new int[] {
20,
0,
0,
0});
//
// NUD_PocketCount2
//
this.NUD_PocketCount2.Location = new System.Drawing.Point(104, 188);
this.NUD_PocketCount2.Maximum = new decimal(new int[] {
2147483647,
0,
0,
0});
this.NUD_PocketCount2.Name = "NUD_PocketCount2";
this.NUD_PocketCount2.Size = new System.Drawing.Size(41, 20);
this.NUD_PocketCount2.TabIndex = 20;
this.NUD_PocketCount2.Value = new decimal(new int[] {
20,
0,
0,
0});
//
// L_PocketCount1
//
this.L_PocketCount1.AutoSize = true;
this.L_PocketCount1.Location = new System.Drawing.Point(148, 170);
this.L_PocketCount1.Name = "L_PocketCount1";
this.L_PocketCount1.Size = new System.Drawing.Size(81, 13);
this.L_PocketCount1.TabIndex = 21;
this.L_PocketCount1.Text = "Pocket Count 1";
this.L_PocketCount1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// L_PocketCount2
//
this.L_PocketCount2.AutoSize = true;
this.L_PocketCount2.Location = new System.Drawing.Point(148, 191);
this.L_PocketCount2.Name = "L_PocketCount2";
this.L_PocketCount2.Size = new System.Drawing.Size(81, 13);
this.L_PocketCount2.TabIndex = 22;
this.L_PocketCount2.Text = "Pocket Count 2";
this.L_PocketCount2.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// Editor
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@@ -596,6 +660,8 @@ private void InitializeComponent()
((System.ComponentModel.ISupportInitialize)(this.NUD_BankBells)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.PB_Player)).EndInit();
this.TC_Editors.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.NUD_PocketCount1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.NUD_PocketCount2)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
@@ -652,6 +718,10 @@ private void InitializeComponent()
private System.Windows.Forms.ToolStripMenuItem B_EditPlayerRecipes;
private System.Windows.Forms.Button B_EditPlayer;
private System.Windows.Forms.Button B_EditPlayerHouses;
private System.Windows.Forms.Label L_PocketCount2;
private System.Windows.Forms.Label L_PocketCount1;
private System.Windows.Forms.NumericUpDown NUD_PocketCount2;
private System.Windows.Forms.NumericUpDown NUD_PocketCount1;
}
}

View File

@@ -176,15 +176,15 @@ private void B_EditPlayerItems_Click(object sender, EventArgs e)
var player = SAV.Players[PlayerIndex];
{
var pers = player.Personal;
var p1 = pers.Pocket1;
var p2 = pers.Pocket2;
var items = p2.Concat(p1).ToArray();
var bag = pers.Bag;
var pocket = pers.Pocket;
var items = pocket.Concat(bag).ToArray();
using var editor = new PlayerItemEditor<Item>(items, 10, 4, sysbot: true);
if (editor.ShowDialog() != DialogResult.OK)
return;
pers.Pocket2 = items.Take(p2.Count).ToArray();
pers.Pocket1 = items.Skip(p2.Count).Take(p1.Count).ToArray();
pers.Pocket = items.Take(pocket.Count).ToArray();
pers.Bag = items.Skip(pocket.Count).Take(bag.Count).ToArray();
}
}
@@ -237,6 +237,10 @@ private void LoadPlayer(int index)
NUD_NookMiles.Value = Math.Min(int.MaxValue, pers.NookMiles.Value);
NUD_Wallet.Value = Math.Min(int.MaxValue, pers.Wallet.Value);
// swapped on purpose -- first count is the first two rows of items
NUD_PocketCount1.Value = Math.Min(int.MaxValue, pers.PocketCount);
NUD_PocketCount2.Value = Math.Min(int.MaxValue, pers.BagCount);
try
{
var photo = pers.GetPhotoData();
@@ -286,6 +290,10 @@ private void SavePlayer(int index)
var wallet = pers.Wallet;
wallet.Value = (uint)NUD_Wallet.Value;
pers.Wallet = wallet;
// swapped on purpose -- first count is the first two rows of items
pers.PocketCount = (uint)NUD_PocketCount1.Value;
pers.BagCount = (uint)NUD_PocketCount2.Value;
}
private void B_EditAchievements_Click(object sender, EventArgs e)
@@ -317,12 +325,7 @@ private void Menu_SavePNG_Click(object sender, EventArgs e)
return;
}
string name;
if (pb == PB_Player)
name = SAV.Players[PlayerIndex].Personal.PlayerName;
else
name = "photo";
string name = SAV.Players[PlayerIndex].Personal.PlayerName;
var bmp = pb.Image;
using var sfd = new SaveFileDialog
{

View File

@@ -8,7 +8,7 @@ namespace NHSE.WinForms
{
public partial class PlayerHouseEditor : Form
{
public readonly PlayerHouse[] Houses;
private readonly PlayerHouse[] Houses;
private readonly IReadOnlyList<Player> Players;
private int Index;

View File

@@ -9,7 +9,7 @@ namespace NHSE.WinForms
public partial class VillagerHouseEditor : Form
{
private readonly MainSave SAV;
public readonly VillagerHouse[] Houses;
private readonly VillagerHouse[] Houses;
private readonly IReadOnlyList<Villager> Villagers;
private int Index;