diff --git a/SoG_Savegame_Editor/Forms/FrmMain.Designer.cs b/SoG_Savegame_Editor/Forms/FrmMain.Designer.cs index e58b7a6..4d6ea54 100644 --- a/SoG_Savegame_Editor/Forms/FrmMain.Designer.cs +++ b/SoG_Savegame_Editor/Forms/FrmMain.Designer.cs @@ -38,6 +38,15 @@ private void InitializeComponent() System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FrmMain)); this.tabControlMain = new System.Windows.Forms.TabControl(); + this.tabPins = new System.Windows.Forms.TabPage(); + this.cblstPinsSeen = new System.Windows.Forms.CheckedListBox(); + this.cblstPinsOnShelf = new System.Windows.Forms.CheckedListBox(); + this.cblstPinsEquipped = new System.Windows.Forms.CheckedListBox(); + this.cblstPinsLatest = new System.Windows.Forms.CheckedListBox(); + this.lblPinsSeen = new System.Windows.Forms.Label(); + this.lblPinsOnShelf = new System.Windows.Forms.Label(); + this.lblPinsEquipped = new System.Windows.Forms.Label(); + this.lblPinsLatest = new System.Windows.Forms.Label(); this.tabChar = new System.Windows.Forms.TabPage(); this.grpPatch = new System.Windows.Forms.GroupBox(); this.lblGamePatch = new System.Windows.Forms.Label(); @@ -700,6 +709,84 @@ private void InitializeComponent() | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.tabControlMain.Controls.Add(this.tabChar); + this.tabControlMain.Controls.Add(this.tabPins); + // tabPins + // + this.tabPins.Controls.Add(this.lblPinsSeen); + this.tabPins.Controls.Add(this.lblPinsOnShelf); + this.tabPins.Controls.Add(this.lblPinsEquipped); + this.tabPins.Controls.Add(this.lblPinsLatest); + this.tabPins.Controls.Add(this.cblstPinsSeen); + this.tabPins.Controls.Add(this.cblstPinsOnShelf); + this.tabPins.Controls.Add(this.cblstPinsEquipped); + this.tabPins.Controls.Add(this.cblstPinsLatest); + this.tabPins.Location = new System.Drawing.Point(4, 40); + this.tabPins.Name = "tabPins"; + this.tabPins.Padding = new System.Windows.Forms.Padding(3); + this.tabPins.Size = new System.Drawing.Size(559, 416); + this.tabPins.TabIndex = 20; + this.tabPins.Text = "Pins"; + this.tabPins.UseVisualStyleBackColor = true; + + // lblPinsSeen + this.lblPinsSeen.AutoSize = true; + this.lblPinsSeen.Location = new System.Drawing.Point(10, 10); + this.lblPinsSeen.Name = "lblPinsSeen"; + this.lblPinsSeen.Size = new System.Drawing.Size(60, 13); + this.lblPinsSeen.TabIndex = 4; + this.lblPinsSeen.Text = "Pins Seen:"; + + // lblPinsOnShelf + this.lblPinsOnShelf.AutoSize = true; + this.lblPinsOnShelf.Location = new System.Drawing.Point(150, 10); + this.lblPinsOnShelf.Name = "lblPinsOnShelf"; + this.lblPinsOnShelf.Size = new System.Drawing.Size(75, 13); + this.lblPinsOnShelf.TabIndex = 5; + this.lblPinsOnShelf.Text = "Pins On Shelf:"; + + // lblPinsEquipped + this.lblPinsEquipped.AutoSize = true; + this.lblPinsEquipped.Location = new System.Drawing.Point(290, 10); + this.lblPinsEquipped.Name = "lblPinsEquipped"; + this.lblPinsEquipped.Size = new System.Drawing.Size(82, 13); + this.lblPinsEquipped.TabIndex = 6; + this.lblPinsEquipped.Text = "Pins Equipped:"; + + // lblPinsLatest + this.lblPinsLatest.AutoSize = true; + this.lblPinsLatest.Location = new System.Drawing.Point(430, 10); + this.lblPinsLatest.Name = "lblPinsLatest"; + this.lblPinsLatest.Size = new System.Drawing.Size(65, 13); + this.lblPinsLatest.TabIndex = 7; + this.lblPinsLatest.Text = "Pins Latest:"; + + // cblstPinsSeen + this.cblstPinsSeen.FormattingEnabled = true; + this.cblstPinsSeen.Location = new System.Drawing.Point(10, 30); + this.cblstPinsSeen.Name = "cblstPinsSeen"; + this.cblstPinsSeen.Size = new System.Drawing.Size(130, 364); + this.cblstPinsSeen.TabIndex = 0; + + // cblstPinsOnShelf + this.cblstPinsOnShelf.FormattingEnabled = true; + this.cblstPinsOnShelf.Location = new System.Drawing.Point(150, 30); + this.cblstPinsOnShelf.Name = "cblstPinsOnShelf"; + this.cblstPinsOnShelf.Size = new System.Drawing.Size(130, 364); + this.cblstPinsOnShelf.TabIndex = 1; + + // cblstPinsEquipped + this.cblstPinsEquipped.FormattingEnabled = true; + this.cblstPinsEquipped.Location = new System.Drawing.Point(290, 30); + this.cblstPinsEquipped.Name = "cblstPinsEquipped"; + this.cblstPinsEquipped.Size = new System.Drawing.Size(130, 364); + this.cblstPinsEquipped.TabIndex = 2; + + // cblstPinsLatest + this.cblstPinsLatest.FormattingEnabled = true; + this.cblstPinsLatest.Location = new System.Drawing.Point(430, 30); + this.cblstPinsLatest.Name = "cblstPinsLatest"; + this.cblstPinsLatest.Size = new System.Drawing.Size(120, 364); + this.cblstPinsLatest.TabIndex = 3; this.tabControlMain.Controls.Add(this.tabInventory); this.tabControlMain.Controls.Add(this.tabPets); this.tabControlMain.Controls.Add(this.tabSkills); @@ -5879,6 +5966,15 @@ private void InitializeComponent() #endregion private System.Windows.Forms.TabControl tabControlMain; + private System.Windows.Forms.TabPage tabPins; + private System.Windows.Forms.CheckedListBox cblstPinsSeen; + private System.Windows.Forms.CheckedListBox cblstPinsOnShelf; + private System.Windows.Forms.CheckedListBox cblstPinsEquipped; + private System.Windows.Forms.CheckedListBox cblstPinsLatest; + private System.Windows.Forms.Label lblPinsSeen; + private System.Windows.Forms.Label lblPinsOnShelf; + private System.Windows.Forms.Label lblPinsEquipped; + private System.Windows.Forms.Label lblPinsLatest; private System.Windows.Forms.TabPage tabQuickslots; private System.Windows.Forms.MenuStrip msMenu; private System.Windows.Forms.ToolStripMenuItem fileToolStripMenuItem; diff --git a/SoG_Savegame_Editor/Forms/FrmMain.cs b/SoG_Savegame_Editor/Forms/FrmMain.cs index 93eaee6..f17416b 100644 --- a/SoG_Savegame_Editor/Forms/FrmMain.cs +++ b/SoG_Savegame_Editor/Forms/FrmMain.cs @@ -72,7 +72,7 @@ private void LoadSaveGame() PopulateFields(); } - //TODO: Check out if there is a way to show the items in the designer + //TODO: Check out if there is a way to show the items in the designer private void InitElements() // Designer Items { int iQuickslotYpos = 262; @@ -139,6 +139,17 @@ private void InitFields() cbShoes.DataSource = FilterItems(items, "Shoes_"); cbAccessory1.DataSource = FilterItems(items, "Accessory_"); cbAccessory2.DataSource = FilterItems(items, "Accessory_"); + + // Add event handlers to mark items as seen when equipped + cbHat.SelectedIndexChanged += EquipmentComboBox_SelectedIndexChanged; + cbFacegear.SelectedIndexChanged += EquipmentComboBox_SelectedIndexChanged; + cbWeapon.SelectedIndexChanged += EquipmentComboBox_SelectedIndexChanged; + cbShield.SelectedIndexChanged += EquipmentComboBox_SelectedIndexChanged; + cbArmor.SelectedIndexChanged += EquipmentComboBox_SelectedIndexChanged; + cbShoes.SelectedIndexChanged += EquipmentComboBox_SelectedIndexChanged; + cbAccessory1.SelectedIndexChanged += EquipmentComboBox_SelectedIndexChanged; + cbAccessory2.SelectedIndexChanged += EquipmentComboBox_SelectedIndexChanged; + cbStyleHat.DataSource = FilterItems(items, "Hat_"); cbStyleFacegear.DataSource = FilterItems(items, "Facegear_"); @@ -262,6 +273,10 @@ private void InitFields() cblstItemsSeen.DataSource = System.Enum.GetNames(typeof(SogItem)); cblstItemsCrafted.DataSource = System.Enum.GetNames(typeof(SogItem)); cblstFishCaught.DataSource = System.Enum.GetNames(typeof(SogFish)); + cblstPinsSeen.DataSource = System.Enum.GetNames(typeof(SogPin)); + cblstPinsOnShelf.DataSource = System.Enum.GetNames(typeof(SogPin)); + cblstPinsEquipped.DataSource = System.Enum.GetNames(typeof(SogPin)); + cblstPinsLatest.DataSource = System.Enum.GetNames(typeof(SogPin)); } private void PopulateFields() @@ -328,7 +343,7 @@ private void PopulateFields() item.Plusses, item.Position ); - } + } // KilledEnemies for (int i = 0; i != playerObject.KilledEnemiesCount; i++) @@ -344,7 +359,7 @@ private void PopulateFields() lstEnemiesKilled.Items.Add(vKilledEnemy); } - numGold.Value = playerObject.Cash; + numGold.Value = playerObject.Cash; numLevel.Value = playerObject.Level; numEXPcurrent.Value = playerObject.ExpCurrent; @@ -450,12 +465,70 @@ private void PopulateFields() bool playerHasCaughtFish = playerObject.HasCaughtFish((SogItem)System.Enum.Parse(typeof(SogItem), cblstFishCaught.Items[i].ToString())); cblstFishCaught.SetItemChecked(i, playerHasCaughtFish); } + + for (int i = 0; i < cblstPinsSeen.Items.Count; i++) + { + bool playerHasPin = playerObject.PinsSeen?.Contains((SogPin)System.Enum.Parse(typeof(SogPin), cblstPinsSeen.Items[i].ToString())) ?? false; + cblstPinsSeen.SetItemChecked(i, playerHasPin); + } + + for (int i = 0; i < cblstPinsOnShelf.Items.Count; i++) + { + bool playerHasPin = playerObject.PinsOnShelf?.Contains((SogPin)System.Enum.Parse(typeof(SogPin), cblstPinsOnShelf.Items[i].ToString())) ?? false; + cblstPinsOnShelf.SetItemChecked(i, playerHasPin); + } + + for (int i = 0; i < cblstPinsEquipped.Items.Count; i++) + { + bool playerHasPin = playerObject.PinsEquipped?.Contains((SogPin)System.Enum.Parse(typeof(SogPin), cblstPinsEquipped.Items[i].ToString())) ?? false; + cblstPinsEquipped.SetItemChecked(i, playerHasPin); + } + + for (int i = 0; i < cblstPinsLatest.Items.Count; i++) + { + bool playerHasPin = playerObject.PinsLatest?.Contains((SogPin)System.Enum.Parse(typeof(SogPin), cblstPinsLatest.Items[i].ToString())) ?? false; + cblstPinsLatest.SetItemChecked(i, playerHasPin); + } } private void GetDataFromFields() { playerObject.Nickname = txtNickname.Text; + // Update equipped items from combo boxes + if (!string.IsNullOrEmpty(cbHat.Text) && cbHat.Text != "Null") + { + playerObject.Equip.Hat = (SogItem)System.Enum.Parse(typeof(SogItem), cbHat.Text); + } + if (!string.IsNullOrEmpty(cbFacegear.Text) && cbFacegear.Text != "Null") + { + playerObject.Equip.Facegear = (SogItem)System.Enum.Parse(typeof(SogItem), cbFacegear.Text); + } + if (!string.IsNullOrEmpty(cbWeapon.Text) && cbWeapon.Text != "Null") + { + playerObject.Equip.Weapon = (SogItem)System.Enum.Parse(typeof(SogItem), cbWeapon.Text); + } + if (!string.IsNullOrEmpty(cbShield.Text) && cbShield.Text != "Null") + { + playerObject.Equip.Shield = (SogItem)System.Enum.Parse(typeof(SogItem), cbShield.Text); + } + if (!string.IsNullOrEmpty(cbArmor.Text) && cbArmor.Text != "Null") + { + playerObject.Equip.Armor = (SogItem)System.Enum.Parse(typeof(SogItem), cbArmor.Text); + } + if (!string.IsNullOrEmpty(cbShoes.Text) && cbShoes.Text != "Null") + { + playerObject.Equip.Shoes = (SogItem)System.Enum.Parse(typeof(SogItem), cbShoes.Text); + } + if (!string.IsNullOrEmpty(cbAccessory1.Text) && cbAccessory1.Text != "Null") + { + playerObject.Equip.Accessory1 = (SogItem)System.Enum.Parse(typeof(SogItem), cbAccessory1.Text); + } + if (!string.IsNullOrEmpty(cbAccessory2.Text) && cbAccessory2.Text != "Null") + { + playerObject.Equip.Accessory2 = (SogItem)System.Enum.Parse(typeof(SogItem), cbAccessory2.Text); + } + // set the potion for all potions playerObject.Potions.Clear(); if (cbPotion1.Enabled == true) @@ -623,9 +696,9 @@ private void GetDataFromFields() var cardId = (SogEnemy)System.Enum.Parse(typeof(SogEnemy), row.Cells["Card"].Value.ToString()); playerObject.Cards.Add( new KeyValuePair( - new Card { - CardID = cardId - }, + new Card { + CardID = cardId + }, (ushort)cardCount ) ); @@ -743,6 +816,50 @@ private void GetDataFromFields() ); } } + + playerObject.PinsSeen?.Clear(); + playerObject.PinsSeen = new List(); + for (int i = 0; i != cblstPinsSeen.Items.Count; i++) + { + if (cblstPinsSeen.GetItemChecked(i)) + { + playerObject.PinsSeen.Add((SogPin)System.Enum.Parse(typeof(SogPin), cblstPinsSeen.Items[i].ToString())); + } + } + playerObject.PinsSeenCount = (ushort)playerObject.PinsSeen.Count; + + playerObject.PinsOnShelf?.Clear(); + playerObject.PinsOnShelf = new List(); + for (int i = 0; i != cblstPinsOnShelf.Items.Count; i++) + { + if (cblstPinsOnShelf.GetItemChecked(i)) + { + playerObject.PinsOnShelf.Add((SogPin)System.Enum.Parse(typeof(SogPin), cblstPinsOnShelf.Items[i].ToString())); + } + } + playerObject.PinsOnShelfCount = (byte)playerObject.PinsOnShelf.Count; + + playerObject.PinsEquipped?.Clear(); + playerObject.PinsEquipped = new List(); + for (int i = 0; i != cblstPinsEquipped.Items.Count; i++) + { + if (cblstPinsEquipped.GetItemChecked(i)) + { + playerObject.PinsEquipped.Add((SogPin)System.Enum.Parse(typeof(SogPin), cblstPinsEquipped.Items[i].ToString())); + } + } + playerObject.PinsEquippedCount = (byte)playerObject.PinsEquipped.Count; + + playerObject.PinsLatest?.Clear(); + playerObject.PinsLatest = new List(); + for (int i = 0; i != cblstPinsLatest.Items.Count; i++) + { + if (cblstPinsLatest.GetItemChecked(i)) + { + playerObject.PinsLatest.Add((SogPin)System.Enum.Parse(typeof(SogPin), cblstPinsLatest.Items[i].ToString())); + } + } + playerObject.PinsLatestCount = (ushort)playerObject.PinsLatest.Count; } private (NumericUpDown Field, SogSkill SkillID)[] getSkillMappings() @@ -862,7 +979,7 @@ private void SaveToolStripMenuItem_Click(object sender, EventArgs e) sFilename = saveFileDialog1.FileName; if (!File.Exists(sFilename)) { - FileStream fileStream = File.Create(sFilename); + FileStream fileStream = File.Create(sFilename); fileStream.Close(); } @@ -1324,12 +1441,12 @@ private void cblstFlags_ItemCheck(object sender, ItemCheckEventArgs e) cblstFlagsChecked.Items.Add(cblstFlags.Items[e.Index]); cblstFlagsChecked.SetItemChecked(cblstFlagsChecked.Items.Count - 1, true); } - } + } else if (e.NewValue == CheckState.Unchecked) { cblstFlagsChecked.Items.RemoveAt(cblstFlagsChecked.Items.IndexOf(cblstFlags.Items[e.Index])); } - + } private void cblstFlagsChecked_ItemCheck(object sender, ItemCheckEventArgs e) @@ -1391,7 +1508,7 @@ private void btnAddItem_Click(object sender, EventArgs e) maxPos = pos; } } - } + } int plusses = (int)numPlusses.Value; @@ -1423,10 +1540,58 @@ private void btnAddItem_Click(object sender, EventArgs e) item.GetItemName(), item.Count, item.Plusses, - item.Position + item.Position ); } + /// + /// Event handler for equipment combo boxes that automatically marks items as seen when equipped + /// + private void EquipmentComboBox_SelectedIndexChanged(object sender, EventArgs e) + { + if (sender is ComboBox comboBox && !string.IsNullOrEmpty(comboBox.Text) && comboBox.Text != "Null") + { + try + { + SogItem itemId = (SogItem)System.Enum.Parse(typeof(SogItem), comboBox.Text); + MarkItemAsSeen(itemId); + } + catch (ArgumentException) + { + // Invalid item name, ignore + } + } + } + + /// + /// Marks an item as seen in the ItemsSeen checklist + /// + /// The item to mark as seen + private void MarkItemAsSeen(SogItem itemId) + { + if (playerObject == null || cblstItemsSeen == null) + return; + + // Find the item in the checklist + string itemName = itemId.ToString(); + int itemIndex = -1; + + for (int i = 0; i < cblstItemsSeen.Items.Count; i++) + { + if (cblstItemsSeen.Items[i].ToString() == itemName) + { + itemIndex = i; + break; + } + } + + // If found and not already checked, check it + if (itemIndex >= 0 && !cblstItemsSeen.GetItemChecked(itemIndex)) + { + cblstItemsSeen.SetItemChecked(itemIndex, true); + } + } + private void btnSkinColor_Click(object sender, EventArgs e) { txtConsole.AppendText(Text + "\r\nSkin color changing is not supported yet. Please open an issue on Github if you want this feature, because I was too lazy to implement it yet."); @@ -1439,4 +1604,4 @@ public class CardViewModel public string Card { get; set; } public int CardCount { get; set; } } -} \ No newline at end of file +}