mirror of
https://github.com/libretro/Mesen.git
synced 2025-02-03 23:46:15 +00:00
UI: Apply cheats automatically when in the cheat list (and revert if window is closed)
This commit is contained in:
parent
327e4773a8
commit
89a8b26fa1
@ -65,10 +65,15 @@ namespace Mesen.GUI.Config
|
||||
|
||||
public static void ApplyCheats()
|
||||
{
|
||||
if(!ConfigManager.Config.DisableAllCheats) {
|
||||
ApplyCheats(ConfigManager.Config.Cheats, ConfigManager.Config.DisableAllCheats);
|
||||
}
|
||||
|
||||
public static void ApplyCheats(List<CheatInfo> cheatList, bool disableCheats)
|
||||
{
|
||||
if(!disableCheats) {
|
||||
string crc = InteropEmu.GetRomInfo().GetPrgCrcString();
|
||||
|
||||
InteropCheatInfo[] cheats = ConfigManager.Config.Cheats.Where(c => c.GameCrc == crc && c.Enabled).Select(cheat => cheat.ToInterop()).ToArray();
|
||||
InteropCheatInfo[] cheats = cheatList.Where(c => c.GameCrc == crc && c.Enabled).Select(cheat => cheat.ToInterop()).ToArray();
|
||||
InteropEmu.SetCheats(cheats, (UInt32)cheats.Length);
|
||||
|
||||
if(cheats.Length > 0) {
|
||||
|
@ -26,15 +26,7 @@ namespace Mesen.GUI.Forms
|
||||
_validateTimer.Start();
|
||||
}
|
||||
}
|
||||
|
||||
public new bool ShowInTaskbar
|
||||
{
|
||||
set
|
||||
{
|
||||
base.ShowInTaskbar = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected override void OnLoad(EventArgs e)
|
||||
{
|
||||
base.OnLoad(e);
|
||||
|
4
GUI.NET/Forms/Cheats/frmCheatList.Designer.cs
generated
4
GUI.NET/Forms/Cheats/frmCheatList.Designer.cs
generated
@ -210,7 +210,6 @@ namespace Mesen.GUI.Forms.Cheats
|
||||
this.lstCheats.TabIndex = 1;
|
||||
this.lstCheats.UseCompatibleStateImageBehavior = false;
|
||||
this.lstCheats.View = System.Windows.Forms.View.Details;
|
||||
this.lstCheats.ItemChecked += new System.Windows.Forms.ItemCheckedEventHandler(this.lstCheats_ItemChecked);
|
||||
this.lstCheats.SelectedIndexChanged += new System.EventHandler(this.lstCheats_SelectedIndexChanged);
|
||||
this.lstCheats.DoubleClick += new System.EventHandler(this.lstCheats_DoubleClick);
|
||||
//
|
||||
@ -233,7 +232,7 @@ namespace Mesen.GUI.Forms.Cheats
|
||||
this.mnuDeleteCheat,
|
||||
this.mnuExportSelectedCheats});
|
||||
this.contextMenuCheats.Name = "contextMenuCheats";
|
||||
this.contextMenuCheats.Size = new System.Drawing.Size(160, 92);
|
||||
this.contextMenuCheats.Size = new System.Drawing.Size(160, 70);
|
||||
//
|
||||
// mnuAddCheat
|
||||
//
|
||||
@ -416,6 +415,7 @@ namespace Mesen.GUI.Forms.Cheats
|
||||
this.chkDisableCheats.TabIndex = 3;
|
||||
this.chkDisableCheats.Text = "Disable all cheats";
|
||||
this.chkDisableCheats.UseVisualStyleBackColor = true;
|
||||
this.chkDisableCheats.CheckedChanged += new System.EventHandler(this.chkDisableCheats_CheckedChanged);
|
||||
//
|
||||
// frmCheatList
|
||||
//
|
||||
|
@ -125,8 +125,10 @@ namespace Mesen.GUI.Forms.Cheats
|
||||
|
||||
private void UpdateCheatList()
|
||||
{
|
||||
lstCheats.Sorting = SortOrder.Ascending;
|
||||
lstCheats.BeginUpdate();
|
||||
lstCheats.Sorting = SortOrder.None;
|
||||
lstCheats.Items.Clear();
|
||||
lstCheats.ItemChecked -= lstCheats_ItemChecked;
|
||||
if(_selectedItem != null) {
|
||||
string crc32 = _selectedItem.Crc;
|
||||
foreach(CheatInfo cheat in _cheats) {
|
||||
@ -138,6 +140,9 @@ namespace Mesen.GUI.Forms.Cheats
|
||||
}
|
||||
}
|
||||
}
|
||||
lstCheats.Sorting = SortOrder.Ascending;
|
||||
lstCheats.ItemChecked += lstCheats_ItemChecked;
|
||||
lstCheats.EndUpdate();
|
||||
}
|
||||
|
||||
private void lstGameList_SelectedIndexChanged(object sender, EventArgs e)
|
||||
@ -172,6 +177,7 @@ namespace Mesen.GUI.Forms.Cheats
|
||||
frmCheat frm = new frmCheat((CheatInfo)lstCheats.SelectedItems[0].Tag);
|
||||
if(frm.ShowDialog() == DialogResult.OK) {
|
||||
UpdateGameList();
|
||||
CheatInfo.ApplyCheats(_cheats, chkDisableCheats.Checked);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -180,6 +186,7 @@ namespace Mesen.GUI.Forms.Cheats
|
||||
{
|
||||
if(e.Item.Tag is CheatInfo) {
|
||||
((CheatInfo)e.Item.Tag).Enabled = e.Item.Checked;
|
||||
CheatInfo.ApplyCheats(_cheats, chkDisableCheats.Checked);
|
||||
}
|
||||
}
|
||||
|
||||
@ -191,11 +198,14 @@ namespace Mesen.GUI.Forms.Cheats
|
||||
|
||||
private void DeleteSelectedCheats()
|
||||
{
|
||||
foreach(ListViewItem item in lstCheats.SelectedItems) {
|
||||
CheatInfo cheat = item.Tag as CheatInfo;
|
||||
_cheats.Remove(cheat);
|
||||
if(lstCheats.SelectedItems.Count > 0) {
|
||||
foreach(ListViewItem item in lstCheats.SelectedItems) {
|
||||
CheatInfo cheat = item.Tag as CheatInfo;
|
||||
_cheats.Remove(cheat);
|
||||
}
|
||||
CheatInfo.ApplyCheats(_cheats, chkDisableCheats.Checked);
|
||||
UpdateGameList();
|
||||
}
|
||||
UpdateGameList();
|
||||
}
|
||||
|
||||
private void btnDeleteCheat_Click(object sender, EventArgs e)
|
||||
@ -209,6 +219,7 @@ namespace Mesen.GUI.Forms.Cheats
|
||||
CheatInfo cheat = ((ListViewItem)item).Tag as CheatInfo;
|
||||
_cheats.Remove(cheat);
|
||||
}
|
||||
CheatInfo.ApplyCheats(_cheats, chkDisableCheats.Checked);
|
||||
UpdateGameList();
|
||||
}
|
||||
|
||||
@ -230,6 +241,7 @@ namespace Mesen.GUI.Forms.Cheats
|
||||
frm.FormClosing += (o, evt) => {
|
||||
if(frm.DialogResult == DialogResult.OK && frm.ImportedCheats != null) {
|
||||
AddCheats(frm.ImportedCheats);
|
||||
CheatInfo.ApplyCheats(_cheats, chkDisableCheats.Checked);
|
||||
}
|
||||
};
|
||||
frm.ShowDialog(sender, this);
|
||||
@ -250,6 +262,7 @@ namespace Mesen.GUI.Forms.Cheats
|
||||
}
|
||||
|
||||
UpdateGameList(cheats[0].GameCrc);
|
||||
CheatInfo.ApplyCheats(_cheats, chkDisableCheats.Checked);
|
||||
}
|
||||
}
|
||||
|
||||
@ -298,6 +311,11 @@ namespace Mesen.GUI.Forms.Cheats
|
||||
{
|
||||
btnExport.ShowDropDown();
|
||||
}
|
||||
|
||||
private void chkDisableCheats_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
CheatInfo.ApplyCheats(_cheats, chkDisableCheats.Checked);
|
||||
}
|
||||
}
|
||||
|
||||
public class GameInfo : ListViewItem
|
||||
|
@ -87,9 +87,7 @@ namespace Mesen.GUI.Forms
|
||||
_cheatListWindow = new frmCheatList();
|
||||
_cheatListWindow.Show(sender, this);
|
||||
_cheatListWindow.FormClosed += (s, evt) => {
|
||||
if(_cheatListWindow.DialogResult == DialogResult.OK) {
|
||||
CheatInfo.ApplyCheats();
|
||||
}
|
||||
CheatInfo.ApplyCheats();
|
||||
_cheatListWindow = null;
|
||||
};
|
||||
} else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user