2015-07-03 00:12:02 -04:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
using Mesen.GUI.Config;
|
|
|
|
|
|
|
|
|
|
namespace Mesen.GUI.Forms.Cheats
|
|
|
|
|
{
|
|
|
|
|
public partial class frmCheatList : BaseConfigForm
|
|
|
|
|
{
|
|
|
|
|
public frmCheatList()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
2015-07-05 19:05:33 -04:00
|
|
|
|
|
|
|
|
|
chkCurrentGameOnly.Checked = ConfigManager.Config.ShowOnlyCheatsForCurrentGame;
|
|
|
|
|
if(!chkCurrentGameOnly.Checked) {
|
|
|
|
|
UpdateCheatList();
|
|
|
|
|
}
|
2015-07-03 00:12:02 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnLoad(EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
base.OnLoad(e);
|
|
|
|
|
Location = new Point(Owner.Location.X + (Owner.Width - Width) / 2, Owner.Location.Y + (Owner.Height - Height) / 2);
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-05 19:05:33 -04:00
|
|
|
|
protected override void UpdateConfig()
|
|
|
|
|
{
|
|
|
|
|
ConfigManager.Config.ShowOnlyCheatsForCurrentGame = chkCurrentGameOnly.Checked;
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-03 00:12:02 -04:00
|
|
|
|
private void UpdateCheatList()
|
|
|
|
|
{
|
2016-06-17 20:53:05 -04:00
|
|
|
|
string crc32 = InteropEmu.GetRomInfo().GetCrcString();
|
2015-07-03 00:12:02 -04:00
|
|
|
|
lstCheats.Items.Clear();
|
|
|
|
|
foreach(CheatInfo cheat in ConfigManager.Config.Cheats) {
|
2016-06-17 20:53:05 -04:00
|
|
|
|
if(!chkCurrentGameOnly.Checked || cheat.GameCrc == crc32) {
|
2015-07-05 19:05:33 -04:00
|
|
|
|
ListViewItem item = lstCheats.Items.Add(cheat.GameName);
|
|
|
|
|
item.SubItems.AddRange(new string[] { cheat.CheatName, cheat.ToString() });
|
|
|
|
|
item.Tag = cheat;
|
|
|
|
|
item.Checked = cheat.Enabled;
|
|
|
|
|
}
|
2015-07-03 00:12:02 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void mnuAddCheat_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2015-07-05 19:05:33 -04:00
|
|
|
|
CheatInfo newCheat = new CheatInfo();
|
|
|
|
|
frmCheat frm = new frmCheat(newCheat);
|
|
|
|
|
if(frm.ShowDialog() == DialogResult.OK) {
|
|
|
|
|
ConfigManager.Config.Cheats.Add(newCheat);
|
2015-07-03 00:12:02 -04:00
|
|
|
|
UpdateCheatList();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void lstCheats_DoubleClick(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if(lstCheats.SelectedItems.Count == 1) {
|
|
|
|
|
frmCheat frm = new frmCheat((CheatInfo)lstCheats.SelectedItems[0].Tag);
|
2015-07-05 19:05:33 -04:00
|
|
|
|
if(frm.ShowDialog() == DialogResult.OK) {
|
2015-07-03 00:12:02 -04:00
|
|
|
|
UpdateCheatList();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void lstCheats_ItemChecked(object sender, ItemCheckedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if(e.Item.Tag is CheatInfo) {
|
|
|
|
|
((CheatInfo)e.Item.Tag).Enabled = e.Item.Checked;
|
|
|
|
|
}
|
|
|
|
|
}
|
2015-07-05 19:05:33 -04:00
|
|
|
|
|
|
|
|
|
private void chkCurrentGameOnly_CheckedChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
UpdateCheatList();
|
|
|
|
|
}
|
2016-02-19 13:05:04 -05:00
|
|
|
|
|
|
|
|
|
private void lstCheats_SelectedIndexChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
bool enableDelete = lstCheats.SelectedItems.Count > 0;
|
|
|
|
|
mnuDeleteCheat.Enabled = enableDelete;
|
|
|
|
|
btnDeleteCheat.Enabled = enableDelete;
|
|
|
|
|
}
|
2015-07-03 00:12:02 -04:00
|
|
|
|
}
|
|
|
|
|
}
|