diff --git a/NHSE.Core/Save/Offsets/PersonalOffsets.cs b/NHSE.Core/Save/Offsets/PersonalOffsets.cs index 9f231ae..c0af1b2 100644 --- a/NHSE.Core/Save/Offsets/PersonalOffsets.cs +++ b/NHSE.Core/Save/Offsets/PersonalOffsets.cs @@ -18,6 +18,7 @@ public abstract class PersonalOffsets public abstract int Storage { get; } public abstract int Recipes { get; } + public abstract int ReceivedItems { get; } public virtual int Pockets1Count { get; } = 20; public virtual int Pockets2Count { get; } = 20; diff --git a/NHSE.Core/Save/Offsets/PersonalOffsets10.cs b/NHSE.Core/Save/Offsets/PersonalOffsets10.cs index 8ead0bb..69c7cdc 100644 --- a/NHSE.Core/Save/Offsets/PersonalOffsets10.cs +++ b/NHSE.Core/Save/Offsets/PersonalOffsets10.cs @@ -14,6 +14,7 @@ public sealed class PersonalOffsets10 : PersonalOffsets public override int Pockets1 => 0x35BD4; public override int Pockets2 => Pockets1 + (8 * Pockets1Count) + 0x18; public override int Storage => Pockets2 + (8 * Pockets2Count) + 0x24; + public override int ReceivedItems => 0x3FC1C; public override int Recipes => 0x68BF4; } diff --git a/NHSE.Core/Save/Offsets/PersonalOffsets11.cs b/NHSE.Core/Save/Offsets/PersonalOffsets11.cs index a50f2a5..f727a56 100644 --- a/NHSE.Core/Save/Offsets/PersonalOffsets11.cs +++ b/NHSE.Core/Save/Offsets/PersonalOffsets11.cs @@ -11,9 +11,10 @@ public sealed class PersonalOffsets11 : PersonalOffsets public override int NookMiles => 0x11588; public override int Photo => 0x115C4; - public override int Pockets1 => 0x35C20; + public override int Pockets1 => 0x35C20; // +0x4C from v1.0 public override int Pockets2 => Pockets1 + (8 * Pockets1Count) + 0x18; public override int Storage => Pockets2 + (8 * Pockets2Count) + 0x24; + public override int ReceivedItems => 0x3FC68; // +0x4C from v1.0 public override int Recipes => 0x68C44; // + 0x50 from v1.0 } diff --git a/NHSE.Core/Structures/GameLists.cs b/NHSE.Core/Structures/GameLists.cs new file mode 100644 index 0000000..592a694 --- /dev/null +++ b/NHSE.Core/Structures/GameLists.cs @@ -0,0 +1,184 @@ +using System.Collections.Generic; + +namespace NHSE.Core.Structures +{ + public static class GameLists + { + public static IReadOnlyList Bugs = new ushort[] + { + 582, // brown cicada + 583, // tiger butterfly + 584, // Rajah Brooke's birdwing + 585, // red dragonfly + 586, // Queen Alexandra's birdwing + 587, // pondskater + 588, // ant + 590, // pill bug + 591, // wharf roach + 592, // moth + 594, // diving beetle + 595, // darner dragonfly + 596, // goliath beetle + 597, // fly + 598, // orchid mantis + 599, // tiger beetle + 600, // horned hercules + 601, // evening cicada + 602, // cyclommatus stag + 603, // firefly + 604, // dung beetle + 605, // rice grasshopper + 606, // mosquito + 607, // mantis + 608, // stinkbug + 609, // citrus long-horned beetle + 610, // peacock butterfly + 611, // snail + 612, // horned dynastid + 613, // grasshopper + 614, // earth-boring dung beetle + 615, // horned atlas + 616, // walking leaf + 617, // cricket + 618, // giant cicada + 619, // spider + 620, // agrias butterfly + 621, // robust cicada + 622, // bagworm + 623, // honeybee + 624, // miyama stag + 625, // yellow butterfly + 626, // common butterfly + 627, // emperor butterfly + 628, // centipede + 630, // walking stick + 631, // rainbow stag + 632, // saw stag + 633, // flea + 634, // mole cricket + 635, // banded dragonfly + 636, // monarch butterfly + 637, // giant stag + 638, // golden stag + 639, // scarab beetle + 640, // scorpion + 641, // cicada shell + 642, // bell cricket + 643, // wasp + 644, // long locust + 645, // jewel beetle + 646, // tarantula + 647, // ladybug + 648, // migratory locust + 649, // walker cicada + 650, // violin beetle + 651, // hermit crab + 652, // Atlas moth + 653, // horned elephant + 3477, // common bluebottle + 3478, // paper kite butterfly + 3479, // great purple emperor + 3480, // drone beetle + 3482, // giraffe stag + 3483, // man-faced stink bug + 3484, // Madagascan sunset moth + 3485, // blue weevil beetle + 3487, // rosalia batesi beetle + 3539, // snowflake + 3540, // large snowflake + 4702, // Wisp spirit piece + 5157, // giant water bug + 5339, // damselfly + 5859, // cherry-blossom petal + 7374, // maple leaf + }; + + public static IReadOnlyList Fish = new ushort[] + { + 0328, // crucian carp + 0329, // goldfish + 2215, // bitterling + 2216, // pale chub + 2217, // dace + 2219, // carp + 2220, // koi + 2221, // pop-eyed goldfish + 2222, // killifish + 2223, // crawfish + 2224, // soft-shelled turtle + 2225, // tadpole + 2226, // frog + 2227, // freshwater goby + 2228, // loach + 2229, // catfish + 2231, // giant snakehead + 2232, // bluegill + 2233, // yellow perch + 2234, // black bass + 2235, // pike + 2236, // pond smelt + 2237, // sweetfish + 2238, // cherry salmon + 2239, // char + 2241, // stringfish + 2242, // salmon + 2243, // king salmon + 2244, // mitten crab + 2245, // guppy + 2246, // nibble fish + 2247, // angelfish + 2248, // neon tetra + 2249, // piranha + 2250, // arowana + 2251, // dorado + 2252, // gar + 2253, // arapaima + 2254, // saddled bichir + 2255, // sea butterfly + 2256, // sea horse + 2257, // clown fish + 2258, // surgeonfish + 2259, // butterfly fish + 2260, // Napoleonfish + 2261, // zebra turkeyfish + 2262, // blowfish + 2263, // puffer fish + 2264, // horse mackerel + 2265, // barred knifejaw + 2266, // sea bass + 2267, // red snapper + 2268, // dab + 2269, // olive flounder + 2270, // squid + 2271, // moray eel + 2272, // ribbon eel + 2273, // football fish + 2274, // tuna + 2275, // blue marlin + 2276, // giant trevally + 2277, // ray + 2278, // ocean sunfish + 2279, // hammerhead shark + 2280, // great white shark + 2281, // saw shark + 2282, // whale shark + 2283, // oarfish + 2284, // coelacanth + 2502, // stone + 3466, // empty can + 3469, // boot + 3470, // old tire + 4189, // sturgeon + 4190, // tilapia + 4191, // betta + 4192, // snapping turtle + 4193, // golden trout + 4194, // rainbowfish + 4201, // anchovy + 4202, // mahi-mahi + 4203, // suckerfish + 4204, // barreleye + 5254, // ranchu goldfish + }; + } +} diff --git a/NHSE.Core/Util/FlagUtil.cs b/NHSE.Core/Util/FlagUtil.cs new file mode 100644 index 0000000..1518a41 --- /dev/null +++ b/NHSE.Core/Util/FlagUtil.cs @@ -0,0 +1,23 @@ +namespace NHSE.Core +{ + /// + /// Utility logic for dealing with bitflags in a byte array. + /// + public static class FlagUtil + { + public static bool GetFlag(byte[] arr, int offset, int bitIndex) + { + var b = arr[offset + (bitIndex >> 3)]; + var mask = 1 << (bitIndex & 7); + return (b & mask) != 0; + } + + public static void SetFlag(byte[] arr, int offset, int bitIndex, bool value) + { + offset += (bitIndex >> 3); + bitIndex &= 7; // ensure bit access is 0-7 + arr[offset] &= (byte)~(1 << bitIndex); + arr[offset] |= (byte)((value ? 1 : 0) << bitIndex); + } + } +} \ No newline at end of file diff --git a/NHSE.WinForms/Editor.Designer.cs b/NHSE.WinForms/Editor.Designer.cs index d9905eb..fea270f 100644 --- a/NHSE.WinForms/Editor.Designer.cs +++ b/NHSE.WinForms/Editor.Designer.cs @@ -36,6 +36,7 @@ private void InitializeComponent() this.Menu_Tools = new System.Windows.Forms.ToolStripMenuItem(); this.Menu_DumpDecrypted = new System.Windows.Forms.ToolStripMenuItem(); this.Menu_VerifyHashes = new System.Windows.Forms.ToolStripMenuItem(); + this.Menu_LoadDecrypted = new System.Windows.Forms.ToolStripMenuItem(); this.TC_Editors = new System.Windows.Forms.TabControl(); this.Tab_Players = new System.Windows.Forms.TabPage(); this.B_EditPlayerStorage = new System.Windows.Forms.Button(); @@ -56,6 +57,8 @@ 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(); @@ -72,9 +75,7 @@ private void InitializeComponent() this.NUD_Villager = new System.Windows.Forms.NumericUpDown(); this.Tab_Map = new System.Windows.Forms.TabPage(); this.B_RecycleBin = new System.Windows.Forms.Button(); - this.Menu_LoadDecrypted = new System.Windows.Forms.ToolStripMenuItem(); - this.B_LoadVillager = new System.Windows.Forms.Button(); - this.B_EditFurniture = new System.Windows.Forms.Button(); + this.B_EditPlayerReceivedItems = new System.Windows.Forms.Button(); this.Menu_Editor.SuspendLayout(); this.TC_Editors.SuspendLayout(); this.Tab_Players.SuspendLayout(); @@ -154,6 +155,14 @@ private void InitializeComponent() this.Menu_VerifyHashes.Text = "Verify Hashes"; this.Menu_VerifyHashes.Click += new System.EventHandler(this.Menu_VerifyHashes_Click); // + // Menu_LoadDecrypted + // + this.Menu_LoadDecrypted.Name = "Menu_LoadDecrypted"; + this.Menu_LoadDecrypted.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.L))); + this.Menu_LoadDecrypted.Size = new System.Drawing.Size(206, 22); + this.Menu_LoadDecrypted.Text = "Load Decrypted"; + this.Menu_LoadDecrypted.Click += new System.EventHandler(this.Menu_LoadDecrypted_Click); + // // TC_Editors // this.TC_Editors.Controls.Add(this.Tab_Players); @@ -168,6 +177,7 @@ private void InitializeComponent() // // Tab_Players // + this.Tab_Players.Controls.Add(this.B_EditPlayerReceivedItems); this.Tab_Players.Controls.Add(this.B_EditPlayerStorage); this.Tab_Players.Controls.Add(this.B_EditPlayerRecipes); this.Tab_Players.Controls.Add(this.B_EditPlayerItems); @@ -193,9 +203,9 @@ private void InitializeComponent() // // B_EditPlayerStorage // - this.B_EditPlayerStorage.Location = new System.Drawing.Point(112, 168); + this.B_EditPlayerStorage.Location = new System.Drawing.Point(104, 168); this.B_EditPlayerStorage.Name = "B_EditPlayerStorage"; - this.B_EditPlayerStorage.Size = new System.Drawing.Size(100, 40); + this.B_EditPlayerStorage.Size = new System.Drawing.Size(92, 40); this.B_EditPlayerStorage.TabIndex = 14; this.B_EditPlayerStorage.Text = "Edit Storage"; this.B_EditPlayerStorage.UseVisualStyleBackColor = true; @@ -203,9 +213,9 @@ private void InitializeComponent() // // B_EditPlayerRecipes // - this.B_EditPlayerRecipes.Location = new System.Drawing.Point(218, 168); + this.B_EditPlayerRecipes.Location = new System.Drawing.Point(202, 168); this.B_EditPlayerRecipes.Name = "B_EditPlayerRecipes"; - this.B_EditPlayerRecipes.Size = new System.Drawing.Size(100, 40); + this.B_EditPlayerRecipes.Size = new System.Drawing.Size(92, 40); this.B_EditPlayerRecipes.TabIndex = 13; this.B_EditPlayerRecipes.Text = "Edit Recipes"; this.B_EditPlayerRecipes.UseVisualStyleBackColor = true; @@ -215,7 +225,7 @@ private void InitializeComponent() // this.B_EditPlayerItems.Location = new System.Drawing.Point(6, 168); this.B_EditPlayerItems.Name = "B_EditPlayerItems"; - this.B_EditPlayerItems.Size = new System.Drawing.Size(100, 40); + this.B_EditPlayerItems.Size = new System.Drawing.Size(92, 40); this.B_EditPlayerItems.TabIndex = 12; this.B_EditPlayerItems.Text = "Edit Items"; this.B_EditPlayerItems.UseVisualStyleBackColor = true; @@ -378,11 +388,31 @@ 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(100, 40); + 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; @@ -544,39 +574,21 @@ private void InitializeComponent() // this.B_RecycleBin.Location = new System.Drawing.Point(6, 168); this.B_RecycleBin.Name = "B_RecycleBin"; - this.B_RecycleBin.Size = new System.Drawing.Size(100, 40); + this.B_RecycleBin.Size = new System.Drawing.Size(92, 40); this.B_RecycleBin.TabIndex = 13; this.B_RecycleBin.Text = "Edit Recycle Bin"; this.B_RecycleBin.UseVisualStyleBackColor = true; this.B_RecycleBin.Click += new System.EventHandler(this.B_RecycleBin_Click); // - // Menu_LoadDecrypted + // B_EditPlayerReceivedItems // - this.Menu_LoadDecrypted.Name = "Menu_LoadDecrypted"; - this.Menu_LoadDecrypted.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.L))); - this.Menu_LoadDecrypted.Size = new System.Drawing.Size(206, 22); - this.Menu_LoadDecrypted.Text = "Load Decrypted"; - this.Menu_LoadDecrypted.Click += new System.EventHandler(this.Menu_LoadDecrypted_Click); - // - // B_LoadVillager - // - this.B_LoadVillager.Location = new System.Drawing.Point(112, 168); - this.B_LoadVillager.Name = "B_LoadVillager"; - this.B_LoadVillager.Size = new System.Drawing.Size(100, 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_EditFurniture - // - this.B_EditFurniture.Location = new System.Drawing.Point(218, 168); - this.B_EditFurniture.Name = "B_EditFurniture"; - this.B_EditFurniture.Size = new System.Drawing.Size(100, 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); + this.B_EditPlayerReceivedItems.Location = new System.Drawing.Point(300, 168); + this.B_EditPlayerReceivedItems.Name = "B_EditPlayerReceivedItems"; + this.B_EditPlayerReceivedItems.Size = new System.Drawing.Size(92, 40); + this.B_EditPlayerReceivedItems.TabIndex = 15; + this.B_EditPlayerReceivedItems.Text = "Edit Received Items"; + this.B_EditPlayerReceivedItems.UseVisualStyleBackColor = true; + this.B_EditPlayerReceivedItems.Click += new System.EventHandler(this.B_EditPlayerReceivedItems_Click); // // Editor // @@ -661,6 +673,7 @@ private void InitializeComponent() 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; } } diff --git a/NHSE.WinForms/Editor.cs b/NHSE.WinForms/Editor.cs index 8db5f97..1934978 100644 --- a/NHSE.WinForms/Editor.cs +++ b/NHSE.WinForms/Editor.cs @@ -148,6 +148,13 @@ private void B_EditPlayerRecipes_Click(object sender, EventArgs e) editor.ShowDialog(); } + private void B_EditPlayerReceivedItems_Click(object sender, EventArgs e) + { + var player = SAV.Players[PlayerIndex]; + using var editor = new ItemReceivedEditor(player); + editor.ShowDialog(); + } + private void LoadPlayer(int index) { if (PlayerIndex >= 0) diff --git a/NHSE.WinForms/NHSE.WinForms.csproj b/NHSE.WinForms/NHSE.WinForms.csproj index 03eec18..911c3bf 100644 --- a/NHSE.WinForms/NHSE.WinForms.csproj +++ b/NHSE.WinForms/NHSE.WinForms.csproj @@ -39,6 +39,9 @@ True Settings.settings + + Form + diff --git a/NHSE.WinForms/Subforms/ItemReceivedEditor.Designer.cs b/NHSE.WinForms/Subforms/ItemReceivedEditor.Designer.cs new file mode 100644 index 0000000..ce48ef4 --- /dev/null +++ b/NHSE.WinForms/Subforms/ItemReceivedEditor.Designer.cs @@ -0,0 +1,122 @@ +namespace NHSE.WinForms +{ + partial class ItemReceivedEditor + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.B_Cancel = new System.Windows.Forms.Button(); + this.B_Save = new System.Windows.Forms.Button(); + this.CLB_Items = new System.Windows.Forms.CheckedListBox(); + this.B_AllBugs = new System.Windows.Forms.Button(); + this.B_AllFish = new System.Windows.Forms.Button(); + this.SuspendLayout(); + // + // B_Cancel + // + this.B_Cancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.B_Cancel.Location = new System.Drawing.Point(130, 280); + this.B_Cancel.Name = "B_Cancel"; + this.B_Cancel.Size = new System.Drawing.Size(72, 23); + this.B_Cancel.TabIndex = 7; + this.B_Cancel.Text = "Cancel"; + this.B_Cancel.UseVisualStyleBackColor = true; + this.B_Cancel.Click += new System.EventHandler(this.B_Cancel_Click); + // + // B_Save + // + this.B_Save.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.B_Save.Location = new System.Drawing.Point(208, 280); + this.B_Save.Name = "B_Save"; + this.B_Save.Size = new System.Drawing.Size(72, 23); + this.B_Save.TabIndex = 6; + this.B_Save.Text = "Save"; + this.B_Save.UseVisualStyleBackColor = true; + this.B_Save.Click += new System.EventHandler(this.B_Save_Click); + // + // CLB_Items + // + this.CLB_Items.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.CLB_Items.Font = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.CLB_Items.FormattingEnabled = true; + this.CLB_Items.Location = new System.Drawing.Point(12, 12); + this.CLB_Items.Name = "CLB_Items"; + this.CLB_Items.Size = new System.Drawing.Size(268, 229); + this.CLB_Items.TabIndex = 8; + // + // B_AllBugs + // + this.B_AllBugs.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.B_AllBugs.Location = new System.Drawing.Point(12, 252); + this.B_AllBugs.Name = "B_AllBugs"; + this.B_AllBugs.Size = new System.Drawing.Size(82, 23); + this.B_AllBugs.TabIndex = 11; + this.B_AllBugs.Text = "Give All Bugs"; + this.B_AllBugs.UseVisualStyleBackColor = true; + this.B_AllBugs.Click += new System.EventHandler(this.B_AllBugs_Click); + // + // B_AllFish + // + this.B_AllFish.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.B_AllFish.Location = new System.Drawing.Point(12, 280); + this.B_AllFish.Name = "B_AllFish"; + this.B_AllFish.Size = new System.Drawing.Size(82, 23); + this.B_AllFish.TabIndex = 12; + this.B_AllFish.Text = "Give All Fish"; + this.B_AllFish.UseVisualStyleBackColor = true; + this.B_AllFish.Click += new System.EventHandler(this.B_AllFish_Click); + // + // ItemReceivedEditor + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(292, 315); + this.Controls.Add(this.B_AllFish); + this.Controls.Add(this.B_AllBugs); + this.Controls.Add(this.CLB_Items); + this.Controls.Add(this.B_Cancel); + this.Controls.Add(this.B_Save); + this.Icon = global::NHSE.WinForms.Properties.Resources.icon; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "ItemReceivedEditor"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "Received Item List Editor"; + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.Button B_Cancel; + private System.Windows.Forms.Button B_Save; + private System.Windows.Forms.CheckedListBox CLB_Items; + private System.Windows.Forms.Button B_AllBugs; + private System.Windows.Forms.Button B_AllFish; + } +} \ No newline at end of file diff --git a/NHSE.WinForms/Subforms/ItemReceivedEditor.cs b/NHSE.WinForms/Subforms/ItemReceivedEditor.cs new file mode 100644 index 0000000..988f314 --- /dev/null +++ b/NHSE.WinForms/Subforms/ItemReceivedEditor.cs @@ -0,0 +1,58 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Windows.Forms; +using NHSE.Core; +using NHSE.Core.Structures; + +namespace NHSE.WinForms +{ + public partial class ItemReceivedEditor : Form + { + private readonly Player Player; + + public ItemReceivedEditor(Player player) + { + Player = player; + InitializeComponent(); + FillCheckBoxes(); + } + + private void FillCheckBoxes() + { + var items = GameInfo.Strings.itemlist.ToArray(); + items[0] = string.Empty; + var ofs = Player.Personal.Offsets.ReceivedItems; + var data = Player.Personal.Data; + for (int i = 0; i < items.Length; i++) + { + var flag = FlagUtil.GetFlag(data, ofs, i); + string value = items[i]; + if (string.IsNullOrEmpty(value)) + value = i.ToString(); + string name = $"0x{i:X3} - {value}"; + CLB_Items.Items.Add(name, flag); + } + } + + public void GiveAll(IReadOnlyList indexes, bool value = true) + { + foreach (var item in indexes) + CLB_Items.SetItemChecked(item, value); + System.Media.SystemSounds.Asterisk.Play(); + } + + private void B_AllBugs_Click(object sender, EventArgs e) => GiveAll(GameLists.Bugs, ModifierKeys != Keys.Alt); + private void B_AllFish_Click(object sender, EventArgs e) => GiveAll(GameLists.Fish, ModifierKeys != Keys.Alt); + private void B_Cancel_Click(object sender, EventArgs e) => Close(); + + private void B_Save_Click(object sender, EventArgs e) + { + var ofs = Player.Personal.Offsets.ReceivedItems; + var data = Player.Personal.Data; + for (int i = 0; i < CLB_Items.Items.Count; i++) + FlagUtil.SetFlag(data, ofs, i, CLB_Items.GetItemChecked(i)); + Close(); + } + } +} diff --git a/NHSE.WinForms/Subforms/ItemReceivedEditor.resx b/NHSE.WinForms/Subforms/ItemReceivedEditor.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/NHSE.WinForms/Subforms/ItemReceivedEditor.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file