Skip to content

Commit

Permalink
Added support for "Invert checked Hidden" and "Disable checked Hidden"
Browse files Browse the repository at this point in the history
in the right-click context menu of the SectionView in the Query window.

Disable checked Hidden:
Executing "Disable checked Hidden" will set the Valid of the checked Hidden sections to Disable, and update the settings written to the Hidden configuration file at the "path to PS4CheaterNeo\sections\[GAME_ID].conf" path.
To revert, manual editing of the conf file is required, changing the Valid of the Hidden sections from False to True.
Note: The Query window needs to Refresh Processes to incorporate the new Hidden conf settings.
  • Loading branch information
avan06 committed Feb 18, 2024
1 parent 1b740f1 commit f73cde6
Show file tree
Hide file tree
Showing 17 changed files with 272 additions and 130 deletions.
18 changes: 13 additions & 5 deletions PS4CheaterNeo/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,11 @@ public void ParseLanguageJson()
string codes = Properties.Settings.Default.UILanguage.Value.ToString();
string path = "languages\\LanguageFile_" + codes + ".json";

if (!File.Exists(path)) return;
if (!File.Exists(path))
{
path = "languages\\LanguageFile_" + LanguageCodes.English.ToString() + ".json";
if (!File.Exists(path)) return;
}

using (StreamReader sr = new StreamReader(path))
using (Stream stream = sr.BaseStream)
Expand Down Expand Up @@ -875,7 +879,8 @@ private void SaveCheatJson()
string cheatDesc = row.Cells[(int)ChertCol.CheatListDesc].ToString();
ScanType scanType = this.ParseFromDescription<ScanType>(row.Cells[(int)ChertCol.CheatListType].ToString());
string on = row.Cells[(int)ChertCol.CheatListValue].ToString();
if (scanType != ScanType.Hex)
if (!string.IsNullOrWhiteSpace((string)row.Cells[(int)ChertCol.CheatListOn])) on = row.Cells[(int)ChertCol.CheatListOn].ToString();
else if (scanType != ScanType.Hex)
{
byte[] bytes = ScanTool.ValueStringToByte(scanType, on);
on = ScanTool.BytesToString(scanType, bytes, true, on.StartsWith("-"));
Expand All @@ -887,6 +892,7 @@ private void SaveCheatJson()
cheatDesc = m1.Groups[1].Value;
off = m1.Groups[3].Value;
}
//When opening JSON or SHN files, if cheats have the same description, they will automatically be numbered. When saving the file, the automatically added numbers will be removed.
cheatDesc = Regex.Replace(cheatDesc, @"_\d+$", "");

if (modBak != null && modBak.Name == cheatDesc) cheatJson.Mods[cheatJson.Mods.Count - 1].Memory.Add(new CheatJson.Memory(offsetAddr.ToString("X"), on, off));
Expand Down Expand Up @@ -936,7 +942,8 @@ private void SaveCheatShn()
string cheatDesc = row.Cells[(int)ChertCol.CheatListDesc].ToString();
ScanType scanType = this.ParseFromDescription<ScanType>(row.Cells[(int)ChertCol.CheatListType].ToString());
string on = row.Cells[(int)ChertCol.CheatListValue].ToString();
if (scanType != ScanType.Hex)
if (!string.IsNullOrWhiteSpace((string)row.Cells[(int)ChertCol.CheatListOn])) on = row.Cells[(int)ChertCol.CheatListOn].ToString();
else if (scanType != ScanType.Hex)
{
byte[] bytes = ScanTool.ValueStringToByte(scanType, on);
on = ScanTool.BytesToString(scanType, bytes, true, on.StartsWith("-"));
Expand All @@ -948,8 +955,9 @@ private void SaveCheatShn()
cheatDesc = m1.Groups[1].Value;
off = m1.Groups[3].Value;
}
on = Regex.Replace(on, @"(\w\w)(?=\w)", @"$1-");
off = Regex.Replace(off, @"(\w\w)(?=\w)", @"$1-");
on = Regex.Replace(on, @"(\w\w)(?=\w)", @"$1-"); //Separate Hex values with "-"
off = Regex.Replace(off, @"(\w\w)(?=\w)", @"$1-"); //Separate Hex values with "-"
//When opening JSON or SHN files, if cheats have the same description, they will automatically be numbered. When saving the file, the automatically added numbers will be removed.
cheatDesc = Regex.Replace(cheatDesc, @"_\d+$", "");

if (cheatBak != null && cheatBak.Text == cheatDesc) cheatTrainer.Cheats[cheatTrainer.Cheats.Count - 1].Cheatlines.Add(new CheatTrainer.Cheatline(offsetAddr.ToString("X"), section.SN, on, off));
Expand Down
4 changes: 2 additions & 2 deletions PS4CheaterNeo/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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.5")]
[assembly: AssemblyFileVersion("1.0.2.5")]
[assembly: AssemblyVersion("1.0.2.6")]
[assembly: AssemblyFileVersion("1.0.2.6")]
203 changes: 118 additions & 85 deletions PS4CheaterNeo/Query.Designer.cs

Large diffs are not rendered by default.

88 changes: 73 additions & 15 deletions PS4CheaterNeo/Query.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,19 +104,21 @@ public void ApplyUI(LanguageJson langJson)
SectionViewOffset.Text = langJson.QueryForm.SectionViewOffset;
SectionViewEnd.Text = langJson.QueryForm.SectionViewEnd;

SectionViewHexEditor.Text = langJson.QueryForm.SectionViewHexEditor;
SectionViewCheck.Text = langJson.QueryForm.SectionViewCheck;
SectionViewCheckAll.Text = langJson.QueryForm.SectionViewCheckAll;
SectionViewUnCheckAll.Text = langJson.QueryForm.SectionViewUnCheckAll;
SectionViewInvertChecked.Text = langJson.QueryForm.SectionViewInvertChecked;
SectionViewCheckContains.Text = langJson.QueryForm.SectionViewCheckContains;
SectionViewUnCheckContains.Text = langJson.QueryForm.SectionViewUnCheckContains;
SectionViewCheckProt.Text = langJson.QueryForm.SectionViewCheckProt;
SectionViewUnCheckProt.Text = langJson.QueryForm.SectionViewUnCheckProt;
SectionViewCheckAllHidden.Text = langJson.QueryForm.SectionViewCheckAllHidden;
SectionViewUnCheckAllHidden.Text = langJson.QueryForm.SectionViewUnCheckAllHidden;
SectionViewDump.Text = langJson.QueryForm.SectionViewDump;
SectionViewImport.Text = langJson.QueryForm.SectionViewImport;
SectionViewHexEditor.Text = langJson.QueryForm.SectionViewHexEditor;
SectionViewCheck.Text = langJson.QueryForm.SectionViewCheck;
SectionViewCheckAll.Text = langJson.QueryForm.SectionViewCheckAll;
SectionViewUnCheckAll.Text = langJson.QueryForm.SectionViewUnCheckAll;
SectionViewInvertChecked.Text = langJson.QueryForm.SectionViewInvertChecked;
SectionViewCheckContains.Text = langJson.QueryForm.SectionViewCheckContains;
SectionViewUnCheckContains.Text = langJson.QueryForm.SectionViewUnCheckContains;
SectionViewCheckProt.Text = langJson.QueryForm.SectionViewCheckProt;
SectionViewUnCheckProt.Text = langJson.QueryForm.SectionViewUnCheckProt;
SectionViewCheckAllHidden.Text = langJson.QueryForm.SectionViewCheckAllHidden;
SectionViewUnCheckAllHidden.Text = langJson.QueryForm.SectionViewUnCheckAllHidden;
SectionViewInvertCheckedHidden.Text = langJson.QueryForm.SectionViewInvertCheckedHidden;
SectionViewDisableCheckedHidden.Text = langJson.QueryForm.SectionViewDisableCheckedHidden;
SectionViewDump.Text = langJson.QueryForm.SectionViewDump;
SectionViewImport.Text = langJson.QueryForm.SectionViewImport;

AddrMinLabel.Text = langJson.QueryForm.AddrMinLabel;
AddrMaxLabel.Text = langJson.QueryForm.AddrMaxLabel;
Expand Down Expand Up @@ -284,8 +286,8 @@ private void ProcessesBox_SelectedIndexChanged(object sender, EventArgs e)
{
try
{
SectionViewCheckAllHidden.Visible = SectionViewDetectHiddenSection;
SectionViewUnCheckAllHidden.Visible = SectionViewDetectHiddenSection;
SectionViewHiddens.Visible = SectionViewDetectHiddenSection;
SectionViewDisableCheckedHidden.Visible = WriteHiddenSectionConf;

SectionView.BeginUpdate();
SectionView.VirtualListSize = 0;
Expand Down Expand Up @@ -2036,6 +2038,62 @@ private void SectionViewProtection(bool isProt)
ToolStripMsg.Text = string.Format("Total section: {0}, Selected section: {1}, Search size: {2}MB", sectionItems.Count, sectionTool.TotalSelected, sectionTool.TotalMemorySize / (1024 * 1024));
SectionView.EndUpdate();
}

private void SectionViewInvertCheckedHidden_Click(object sender, EventArgs e)
{
if (sectionItems.Count == 0) return;

SectionView.BeginUpdate();
for (int idx = 0; idx < sectionItems.Count; ++idx)
{
ListViewItem item = sectionItems[idx];
uint sid = uint.Parse(item.SubItems[(int)SectionCol.SectionViewSID].Text);
string name = item.SubItems[(int)SectionCol.SectionViewName].Text;
if (!name.Contains("Hidden")) continue;

item.Checked = !item.Checked;
SectionCheckUpdate(item.Checked, sid);
}
if (AddrMinBox.Tag != null) AddrMinBox.Text = ((ulong)AddrMinBox.Tag).ToString("X");
if (AddrMaxBox.Tag != null) AddrMaxBox.Text = ((ulong)AddrMaxBox.Tag).ToString("X");
ToolStripMsg.Text = string.Format("Total section: {0}, Selected section: {1}, Search size: {2}MB", sectionItems.Count, sectionTool.TotalSelected, sectionTool.TotalMemorySize / (1024 * 1024));
SectionView.EndUpdate();
}

private void SectionViewDisableCheckedHidden_Click(object sender, EventArgs e)
{
if (sectionItems.Count == 0) return;
if (MessageBox.Show(mainForm.langJson != null ? mainForm.langJson.QueryForm.SectionViewDisableCheckedHiddenWarning : "Warning", "Disable checked Hidden", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes) return;

mainForm.InitGameInfo();
mainForm.InitLocalHiddenSections();
if (mainForm.LocalHiddenSections.Count == 0)
{
MessageBox.Show(string.Format("Hidden Sections data (sections{0}{1}.conf) was not found locally. \nYou need to enable the \"WriteHiddenSectionConf\" option and \nrestart the Query window to initialize the configuration file.", Path.DirectorySeparatorChar, mainForm.GameID), "Scan", MessageBoxButtons.OK);
return;
}

SectionView.BeginUpdate();
for (int idx = 0; idx < sectionItems.Count; ++idx)
{
ListViewItem item = sectionItems[idx];
uint sid = uint.Parse(item.SubItems[(int)SectionCol.SectionViewSID].Text);
string name = item.SubItems[(int)SectionCol.SectionViewName].Text;
if (!name.Contains("Hidden") || !item.Checked) continue;

if (mainForm.LocalHiddenSections.TryGetValue(sid, out (ulong Start, ulong End, bool Valid, byte Prot, string Name) localHiddenSection))
{
localHiddenSection.Valid = false;
mainForm.LocalHiddenSections[sid] = localHiddenSection;
}
item.Checked = false;
SectionCheckUpdate(item.Checked, sid, true);
}
mainForm.UpdateLocalHiddenSections();
ToolStripMsg.Text = string.Format("Total section: {0}, Selected section: {1}, Search size: {2}MB", sectionItems.Count, sectionTool.TotalSelected, sectionTool.TotalMemorySize / (1024 * 1024));
SectionView.EndUpdate();

}
#endregion

#region ResultViewMenu
Expand Down
32 changes: 16 additions & 16 deletions PS4CheaterNeo/Query.resx
Original file line number Diff line number Diff line change
Expand Up @@ -127,22 +127,6 @@
<value>17, 17</value>
</metadata>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="SplitContainer2.SplitterButtonBitmap" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO
vAAADrwBlbxySQAAAGdJREFUOE9jIAa8f/9e4OvXrwFQLmkApPnbt28XXr9+/f/79+8JUGHiAExza2vr
/+Tk5P8kGYKs2cnJ6b+vr+//K1euEGfASNQMAhQbAAKjhmACZENITsowADOELM0wADIEe3ZmYAAA/e0P
NJCgSVgAAAAASUVORK5CYII=
</value>
</data>
<data name="SplitContainer1.SplitterButtonBitmap" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO
vAAADrwBlbxySQAAAGdJREFUOE9jIAa8f/9e4OvXrwFQLmkApPnbt28XXr9+/f/79+8JUGHiAExza2vr
/+Tk5P8kGYKs2cnJ6b+vr+//K1euEGfASNQMAhQbAAKjhmACZENITsowADOELM0wADIEe3ZmYAAA/e0P
NJCgSVgAAAAASUVORK5CYII=
</value>
</data>
<data name="PauseBtn.BackgroundImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO
Expand Down Expand Up @@ -192,6 +176,22 @@
3P9mFVVgtriCvC4EPVEFh94ThpfOuPhAtNHmwZIgVEHytFSW9plskRsMlhDxMPwC/ozns7RxRaITCfGj
BEQKONTYyAM8+F9JjYDDjVEkvwScKJJAAUeVNKU2vM2PuC0ioQKOJ1ncK0E333h40i3J/CngeJKgYQ4A
7Qc/8U6/HCfp8gAAAABJRU5ErkJggg==
</value>
</data>
<data name="SplitContainer2.SplitterButtonBitmap" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO
vAAADrwBlbxySQAAAGdJREFUOE9jIAa8f/9e4OvXrwFQLmkApPnbt28XXr9+/f/79+8JUGHiAExza2vr
/+Tk5P8kGYKs2cnJ6b+vr+//K1euEGfASNQMAhQbAAKjhmACZENITsowADOELM0wADIEe3ZmYAAA/e0P
NJCgSVgAAAAASUVORK5CYII=
</value>
</data>
<data name="SplitContainer1.SplitterButtonBitmap" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO
vAAADrwBlbxySQAAAGdJREFUOE9jIAa8f/9e4OvXrwFQLmkApPnbt28XXr9+/f/79+8JUGHiAExza2vr
/+Tk5P8kGYKs2cnJ6b+vr+//K1euEGfASNQMAhQbAAKjhmACZENITsowADOELM0wADIEe3ZmYAAA/e0P
NJCgSVgAAAAASUVORK5CYII=
</value>
</data>
<metadata name="SlowMotionTimer.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
Expand Down
9 changes: 9 additions & 0 deletions PS4CheaterNeo/common/LanguageJson.cs
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,15 @@ public partial class QueryForm
[System.Runtime.Serialization.DataMemberAttribute()]
public string SectionViewUnCheckAllHidden;

[System.Runtime.Serialization.DataMemberAttribute()]
public string SectionViewInvertCheckedHidden;

[System.Runtime.Serialization.DataMemberAttribute()]
public string SectionViewDisableCheckedHidden;

[System.Runtime.Serialization.DataMemberAttribute()]
public string SectionViewDisableCheckedHiddenWarning;

[System.Runtime.Serialization.DataMemberAttribute()]
public string SectionViewDump;

Expand Down
3 changes: 3 additions & 0 deletions PS4CheaterNeo/languages/LanguageFile_Chinese.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@
"SectionViewUnCheckProt": "勾選非Prot:",
"SectionViewCheckAllHidden": "勾選Hidden",
"SectionViewUnCheckAllHidden": "勾選非Hidden",
"SectionViewInvertCheckedHidden": "反轉勾選Hidden",
"SectionViewDisableCheckedHidden": "停用勾選的Hidden",
"SectionViewDisableCheckedHiddenWarning": "警告! \n\n執行\"停用勾選的Hidden\"會將已勾選的Hidden sections的Valid設置為Disable,並將設定更新寫入至\"path to PS4CheaterNeo\\sections\\[GAME_ID].conf\"路徑的Hidden設定檔案。\n\n若要復原需要手動編輯conf檔案,將Hidden sections的Valid由False改為True。\n\n是否繼續執行? \n\n注: Query視窗需要Refresh Processes才會帶入新的Hidden conf設定",
"SectionViewDump": "傾印",
"SectionViewImport": "匯入",

Expand Down
13 changes: 8 additions & 5 deletions PS4CheaterNeo/languages/LanguageFile_English.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,18 @@

"SectionViewHexEditor": "Hex Editor",
"SectionViewCheck": "Check",
"SectionViewCheckAll": "Check All",
"SectionViewUnCheckAll": "Un-Check All",
"SectionViewInvertChecked": "Invert Checked",
"SectionViewCheckAll": "Check all",
"SectionViewUnCheckAll": "Un-Check all",
"SectionViewInvertChecked": "Invert checked",
"SectionViewCheckContains": "Check that contains:",
"SectionViewUnCheckContains": "Un-Check that contains:",
"SectionViewCheckProt": "Check that has prot:",
"SectionViewUnCheckProt": "Un-Check that has prot:",
"SectionViewCheckAllHidden": "Check All Hidden",
"SectionViewUnCheckAllHidden": "Un-Check All Hidden",
"SectionViewCheckAllHidden": "Check all Hidden",
"SectionViewUnCheckAllHidden": "Un-Check all Hidden",
"SectionViewInvertCheckedHidden": "Invert checked Hidden",
"SectionViewDisableCheckedHidden": "Disable checked Hidden",
"SectionViewDisableCheckedHiddenWarning": "Warning! \n\nExecuting \"Disable checked Hidden\" will set the Valid of the checked Hidden sections to Disable, and update the settings written to the Hidden configuration file at the \"path to PS4CheaterNeo\\sections\\[GAME_ID].conf\" path. \n\nTo revert, manual editing of the conf file is required, changing the Valid of the Hidden sections from False to True. \n\nDo you want to continue executing? \n\nNote: The Query window needs to Refresh Processes to incorporate the new Hidden conf settings.",
"SectionViewDump": "Dump",
"SectionViewImport": "Import",

Expand Down
3 changes: 3 additions & 0 deletions PS4CheaterNeo/languages/LanguageFile_French.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@
"SectionViewUnCheckProt": "Décocher ceux qui ont le prot:",
"SectionViewCheckAllHidden": "Tout cocher (caché)",
"SectionViewUnCheckAllHidden": "Tout décocher (caché)",
"SectionViewInvertCheckedHidden": "Inverser les éléments masqués cochés",
"SectionViewDisableCheckedHidden": "Désactiver les éléments masqués cochés",
"SectionViewDisableCheckedHiddenWarning": "Attention ! \n\nL'exécution de \"Désactiver les sections cachées cochées\" définira la validité des sections cachées cochées sur Désactiver, et mettra à jour les paramètres écrits dans le fichier de configuration caché situé dans le chemin \"path to PS4CheaterNeo\\sections\\[GAME_ID].conf\". \n\nPour revenir en arrière, une édition manuelle du fichier de configuration est nécessaire, en changeant la validité des sections cachées de Faux à Vrai. \n\nVoulez-vous continuer l'exécution ? \n\nRemarque : La fenêtre de requête doit actualiser les processus pour incorporer les nouveaux paramètres de configuration cachés.",
"SectionViewDump": "Extraction",
"SectionViewImport": "Importer",

Expand Down
3 changes: 3 additions & 0 deletions PS4CheaterNeo/languages/LanguageFile_German.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@
"SectionViewUnCheckProt": "Nicht überprüfen, dass es Prot hat:",
"SectionViewCheckAllHidden": "Alle versteckten überprüfen",
"SectionViewUnCheckAllHidden": "Alle versteckten nicht überprüfen",
"SectionViewInvertCheckedHidden": "Ausgewählte versteckte Elemente umkehren",
"SectionViewDisableCheckedHidden": "Ausgewählte versteckte Elemente deaktivieren",
"SectionViewDisableCheckedHiddenWarning": "Warnung! \n\nDie Ausführung von \"Ausgewählte versteckte deaktivieren\" setzt die Gültigkeit der ausgewählten versteckten Abschnitte auf Deaktiviert und aktualisiert die Einstellungen, die in der versteckten Konfigurationsdatei im Pfad \"path to PS4CheaterNeo\\sections\\[GAME_ID].conf\" geschrieben wurden. \n\nZurückkehren erfordert manuelles Bearbeiten der Konfigurationsdatei, indem die Gültigkeit der versteckten Abschnitte von Falsch auf Wahr geändert wird. \n\nMöchten Sie mit der Ausführung fortsetzen? \n\nHinweis: Das Abfragefenster muss die Prozesse aktualisieren, um die neuen versteckten Konfigurationseinstellungen zu übernehmen.",
"SectionViewDump": "Dump",
"SectionViewImport": "Importieren",

Expand Down
Loading

0 comments on commit f73cde6

Please sign in to comment.