From fc64b61366f755ca3978e1486febb74302d173e8 Mon Sep 17 00:00:00 2001 From: avan Date: Mon, 12 Feb 2024 02:03:11 +0800 Subject: [PATCH] Fixed the issue of abnormal occurrences when editing Pointer-type Cheats in the main window. Fixed the issue where saving as JSON in the main window without entering ON and OFF values would result in an error. --- PS4CheaterNeo/Main.cs | 4 +-- PS4CheaterNeo/NewAddress.cs | 34 +++++++++++------------- PS4CheaterNeo/Properties/AssemblyInfo.cs | 4 +-- README.md | 2 +- 4 files changed, 21 insertions(+), 23 deletions(-) diff --git a/PS4CheaterNeo/Main.cs b/PS4CheaterNeo/Main.cs index d45952a..cfaedf2 100644 --- a/PS4CheaterNeo/Main.cs +++ b/PS4CheaterNeo/Main.cs @@ -663,7 +663,7 @@ private int ParseCheatMC4(StreamReader reader) decXml = HttpUtility.HtmlDecode(decXml); decXml = Regex.Unescape(decXml); Console.WriteLine(decXml); - count = ParseCheatSHN(decXml); + count = ParseCheatSHN(decXml); } return count; } @@ -881,7 +881,7 @@ private void SaveCheatJson() on = ScanTool.BytesToString(scanType, bytes, true, on.StartsWith("-")); on = ScanTool.ReverseHexString(on); } - string off = row.Cells[(int)ChertCol.CheatListOff].ToString(); + string off = string.IsNullOrWhiteSpace((string)row.Cells[(int)ChertCol.CheatListOff]) ? on : row.Cells[(int)ChertCol.CheatListOff].ToString(); if (Regex.Match(cheatDesc, @"(.*) *__ *\[ *on: *([0-9a-zA-Z]+) *off: *([0-9a-zA-Z]+)") is Match m1 && m1.Success) { //Attempt to restore off value from desc cheatDesc = m1.Groups[1].Value; diff --git a/PS4CheaterNeo/NewAddress.cs b/PS4CheaterNeo/NewAddress.cs index b413f1a..c70a4af 100644 --- a/PS4CheaterNeo/NewAddress.cs +++ b/PS4CheaterNeo/NewAddress.cs @@ -107,7 +107,14 @@ public NewAddress(Main mainForm, Section addrSection, Section baseSection, ulong IsPointer = pointerOffsets != null; AddressBox.Text = Address.ToString("X"); - ScanTypeBox.SelectedIndex = ScanTypeBox.FindStringExact(CheatType.GetDescription()); + foreach (ScanType filterEnum in (ScanType[])Enum.GetValues(typeof(ScanType))) + { + if (filterEnum == ScanType.Group) continue; + string scanTypeStr = filterEnum.GetDescription(); + ComboItem item = new ComboItem(scanTypeStr, filterEnum); + ScanTypeBox.Items.Add(item); + if (filterEnum == CheatType) ScanTypeBox.SelectedItem = item; + } ValueBox.Text = Value; LockBox.Checked = IsLock; DescriptionBox.Text = Descriptioin; @@ -185,22 +192,12 @@ public void ApplyUI(LanguageJson langJson) private void NewAddress_Load(object sender, EventArgs e) { - foreach (ScanType filterEnum in (ScanType[])Enum.GetValues(typeof(ScanType))) - { - if (filterEnum == ScanType.Group) continue; - string scanTypeStr = filterEnum.GetDescription(); - ComboItem item = new ComboItem(scanTypeStr, filterEnum); - ScanTypeBox.Items.Add(item); - if (filterEnum == CheatType) ScanTypeBox.SelectedItem = item; - } + if (PointerOffsets == null || PointerOffsets.Count <= 0) return; - if (PointerOffsets != null && PointerOffsets.Count > 0) + foreach (long offset in PointerOffsets) { - foreach (long offset in PointerOffsets) - { - AddOffsetBtn.PerformClick(); - TableLayoutBottomBox.Controls[TableLayoutBottomBox.Controls.Count - 1].Text = offset.ToString("X"); - } + AddOffsetBtn.PerformClick(); + TableLayoutBottomBox.Controls[TableLayoutBottomBox.Controls.Count - 1].Text = offset.ToString("X"); } } @@ -341,8 +338,7 @@ private void SetOffsetBoxs(bool isAdd) Margin = new Padding(3, 6, 3, 3), ReadOnly = true, BorderStyle = BorderStyle.None, - }; - PointerOffsets.Add(0); + }; TableLayoutBottomBox.RowCount += 1; TableLayoutBottomBox.RowStyles.Add(new RowStyle(SizeType.Percent, 100F)); TableLayoutBottomBox.Controls.Add(textBox, 0, TableLayoutBottomBox.Controls.Count); @@ -377,6 +373,7 @@ private void ScanTypeBox_SelectedIndexChanged(object sender, EventArgs e) ScanTypeBox.SelectedIndex = ScanTypeBox.FindStringExact(CheatType.GetDescription()); return; } + else if (CheatType == ScanType.Hex && newCheatType == ScanType.Hex) return; else if (newCheatType == ScanType.String_) return; try @@ -438,7 +435,8 @@ private void RefreshPointerChecker_Tick(object sender, EventArgs e) if (BaseSection == null) break; - PointerOffsets[idx] = address; + if (TableLayoutBottomBox.Controls.Count > PointerOffsets.Count) PointerOffsets.Add(address); + else PointerOffsets[idx] = address; if (idx != TableLayoutBottomBox.Controls.Count - 1) { diff --git a/PS4CheaterNeo/Properties/AssemblyInfo.cs b/PS4CheaterNeo/Properties/AssemblyInfo.cs index 9cfb515..0106c14 100644 --- a/PS4CheaterNeo/Properties/AssemblyInfo.cs +++ b/PS4CheaterNeo/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.2.2")] -[assembly: AssemblyFileVersion("1.0.2.2")] +[assembly: AssemblyVersion("1.0.2.3")] +[assembly: AssemblyFileVersion("1.0.2.3")] diff --git a/README.md b/README.md index 8303c79..c63a45b 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ PS4CheaterNeo is a program to find game cheat codes, and it is based on [`ps4debug`](https://github.com/jogolden/ps4debug) and [`.Net Framework 4.8`](https://support.microsoft.com/en-us/topic/microsoft-net-framework-4-8-offline-installer-for-windows-9d23f658-3b97-68ab-d013-aa3c3e7495e0). -Currently in `version 1.0.2.2` +Currently in `version 1.0.2.3` ## Table of Contents