BizHawk/BizHawk.Client.EmuHawk/tools/Cheats/Cheats.cs

830 lines
20 KiB
C#
Raw Normal View History

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
2013-10-02 15:09:49 +00:00
using System.IO;
using System.Linq;
using System.Windows.Forms;
using BizHawk.Emulation.Common;
using BizHawk.Emulation.Common.IEmulatorExtensions;
using BizHawk.Emulation.Cores.Nintendo.SNES;
using BizHawk.Emulation.Cores.Sega.Genesis;
using BizHawk.Client.Common;
using BizHawk.Client.EmuHawk.ToolExtensions;
using BizHawk.Client.EmuHawk.WinFormExtensions;
namespace BizHawk.Client.EmuHawk
{
2013-11-02 20:48:24 +00:00
public partial class Cheats : Form, IToolForm
{
2014-12-15 03:19:23 +00:00
[RequiredService]
private IMemoryDomains Core { get; set; }
[RequiredService] // TODO: use of this property should be factored out
private IEmulator Emu { get; set; }
[ConfigPersist]
public CheatsSettings Settings { get; set; }
public class CheatsSettings : ToolDialogSettings
{
public CheatsSettings()
{
Columns = new ColumnList
{
new Column { Name = "NamesColumn", Visible = true, Index = 0, Width = 128 },
new Column { Name = "AddressColumn", Visible = true, Index = 1, Width = 60 },
new Column { Name = "ValueColumn", Visible = true, Index = 2, Width = 59 },
new Column { Name = "CompareColumn", Visible = true, Index = 3, Width = 59 },
new Column { Name = "OnColumn", Visible = false, Index = 4, Width = 28 },
new Column { Name = "DomainColumn", Visible = true, Index = 5, Width = 55 },
new Column { Name = "SizeColumn", Visible = true, Index = 6, Width = 55 },
new Column { Name = "EndianColumn", Visible = false, Index = 7, Width = 55 },
new Column { Name = "DisplayTypeColumn", Visible = false, Index = 8, Width = 55 }
};
}
public ColumnList Columns { get; set; }
}
private const string NAME = "NamesColumn";
private const string ADDRESS = "AddressColumn";
private const string VALUE = "ValueColumn";
private const string COMPARE = "CompareColumn";
private const string ON = "OnColumn";
private const string DOMAIN = "DomainColumn";
private const string SIZE = "SizeColumn";
private const string ENDIAN = "EndianColumn";
private const string TYPE = "DisplayTypeColumn";
2013-11-25 00:55:56 +00:00
private int _defaultWidth;
private int _defaultHeight;
2014-01-30 15:51:07 +00:00
private string _sortedColumn = string.Empty;
2013-11-25 00:55:56 +00:00
private bool _sortReverse;
2013-11-02 20:48:24 +00:00
public bool UpdateBefore { get { return false; } }
2013-10-06 20:02:34 +00:00
public Cheats()
{
InitializeComponent();
Settings = new CheatsSettings();
Closing += (o, e) =>
{
if (AskSaveChanges())
{
SaveConfigSettings();
}
else
{
e.Cancel = true;
}
};
2013-10-04 01:35:58 +00:00
CheatListView.QueryItemText += CheatListView_QueryItemText;
CheatListView.QueryItemBkColor += CheatListView_QueryItemBkColor;
CheatListView.VirtualMode = true;
2014-01-30 15:51:07 +00:00
_sortedColumn = string.Empty;
_sortReverse = false;
}
public void UpdateValues()
{
// Do nothing
}
public void FastUpdate()
{
// Do nothing
}
public void Restart()
{
2014-12-13 22:57:51 +00:00
CheatEditor.Core = Core;
StartNewList();
}
/// <summary>
/// Tools that want to refresh the cheats list should call this, not UpdateValues
/// </summary>
public void UpdateDialog()
2013-10-02 15:09:49 +00:00
{
CheatListView.ItemCount = Global.CheatList.Count;
2013-11-25 02:08:45 +00:00
TotalLabel.Text = Global.CheatList.CheatCount
+ (Global.CheatList.CheatCount == 1 ? " cheat " : " cheats ")
2013-11-25 02:08:45 +00:00
+ Global.CheatList.ActiveCount + " active";
2013-10-02 15:09:49 +00:00
}
public void LoadFileFromRecent(string path)
{
var askResult = !Global.CheatList.Changes || AskSaveChanges();
if (askResult)
2013-10-02 15:09:49 +00:00
{
var loadResult = Global.CheatList.Load(path, append: false);
if (!loadResult)
2013-10-02 15:09:49 +00:00
{
Global.Config.RecentWatches.HandleLoadError(path);
2013-10-02 15:09:49 +00:00
}
else
{
Global.Config.RecentWatches.Add(path);
UpdateDialog();
UpdateMessageLabel();
2013-10-02 15:09:49 +00:00
}
}
}
private void UpdateMessageLabel(bool saved = false)
{
MessageLabel.Text = saved
? Path.GetFileName(Global.CheatList.CurrentFileName) + " saved."
2014-01-30 15:51:07 +00:00
: Path.GetFileName(Global.CheatList.CurrentFileName) + (Global.CheatList.Changes ? " *" : string.Empty);
}
public bool AskSaveChanges()
2013-10-02 15:09:49 +00:00
{
if (Global.CheatList.Changes)
2013-10-02 15:09:49 +00:00
{
GlobalWin.Sound.StopSound();
2013-11-25 02:08:45 +00:00
var result = MessageBox.Show("Save Changes?", "Cheats", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button3);
GlobalWin.Sound.StartSound();
2013-10-02 15:09:49 +00:00
if (result == DialogResult.Yes)
{
Global.CheatList.Save();
2013-10-02 15:09:49 +00:00
}
else if (result == DialogResult.No)
{
Global.CheatList.Changes = false;
2013-10-02 15:09:49 +00:00
return true;
}
else if (result == DialogResult.Cancel)
{
return false;
}
}
return true;
}
2013-11-25 02:08:45 +00:00
private void LoadFile(FileSystemInfo file, bool append)
2013-10-03 15:27:51 +00:00
{
if (file != null)
{
2013-11-25 02:08:45 +00:00
var result = true;
if (Global.CheatList.Changes)
2013-10-03 15:27:51 +00:00
{
result = AskSaveChanges();
2013-10-03 15:27:51 +00:00
}
if (result)
{
Global.CheatList.Load(file.FullName, append);
UpdateDialog();
UpdateMessageLabel();
Global.Config.RecentCheats.Add(Global.CheatList.CurrentFileName);
2013-10-03 15:27:51 +00:00
}
}
}
2013-11-25 02:08:45 +00:00
private static bool SaveAs()
{
var file = ToolHelpers.GetCheatSaveFileFromUser(Global.CheatList.CurrentFileName);
2013-11-25 02:08:45 +00:00
return file != null && Global.CheatList.SaveFile(file.FullName);
}
2014-12-13 22:57:51 +00:00
private void Cheats_Load(object sender, EventArgs e)
{
TopMost = Settings.TopMost;
2014-12-13 22:57:51 +00:00
CheatEditor.Core = Core;
LoadConfigSettings();
ToggleGameGenieButton();
CheatEditor.SetAddEvent(AddCheat);
CheatEditor.SetEditEvent(EditCheat);
UpdateDialog();
}
private void ToggleGameGenieButton()
{
GameGenieToolbarSeparator.Visible =
LoadGameGenieToolbarItem.Visible =
(Emu.SystemId == "NES")
|| (Emu.SystemId == "GEN" && VersionInfo.DeveloperBuild)
|| (Emu.SystemId == "GB")
|| (Global.Game.System == "GG")
|| (Emu is LibsnesCore);
}
private void AddCheat()
{
Global.CheatList.Add(CheatEditor.Cheat);
UpdateDialog();
UpdateMessageLabel();
2013-10-02 15:09:49 +00:00
}
private void EditCheat()
{
Global.CheatList.Remove(CheatEditor.OriginalCheat);
AddCheat();
}
2013-10-04 01:35:58 +00:00
public void SaveConfigSettings()
{
SaveColumnInfo();
Settings.Wndx = Location.X;
Settings.Wndy = Location.Y;
Settings.Width = Right - Left;
Settings.Height = Bottom - Top;
2013-10-04 01:35:58 +00:00
}
private void LoadConfigSettings()
{
_defaultWidth = Size.Width;
2013-11-25 00:55:56 +00:00
_defaultHeight = Size.Height;
if (Settings.UseWindowPosition)
{
Location = Settings.WindowPosition;
}
if (Settings.UseWindowSize)
{
Size = Settings.WindowSize;
}
LoadColumnInfo();
}
private void LoadColumnInfo()
{
CheatListView.Columns.Clear();
foreach (var column in Settings.Columns)
{
CheatListView.AddColumn(column);
}
ColumnPositions();
}
private void ColumnPositions()
{
foreach (ColumnHeader column in CheatListView.Columns)
{
var index = Settings.Columns[column.Name].Index;
if (index < CheatListView.Columns.Count)
{
column.DisplayIndex = Settings.Columns[column.Name].Index;
}
else
{
column.DisplayIndex = CheatListView.Columns.Count - 1;
}
}
}
private void SaveColumnInfo()
{
foreach (ColumnHeader column in CheatListView.Columns)
{
Settings.Columns[column.Name].Index = column.DisplayIndex;
Settings.Columns[column.Name].Width = column.Width;
}
}
private void DoColumnToggle(string column)
{
Settings.Columns[column].Visible ^= true;
SaveColumnInfo();
LoadColumnInfo();
}
2013-10-04 01:35:58 +00:00
private void CheatListView_QueryItemText(int index, int column, out string text)
{
2014-01-30 15:51:07 +00:00
text = string.Empty;
if (index >= Global.CheatList.Count || Global.CheatList[index].IsSeparator)
2013-10-04 01:35:58 +00:00
{
return;
}
2013-11-25 02:08:45 +00:00
var columnName = CheatListView.Columns[column].Name;
switch (columnName)
{
case NAME:
text = Global.CheatList[index].Name;
break;
case ADDRESS:
text = Global.CheatList[index].AddressStr;
break;
case VALUE:
text = Global.CheatList[index].ValueStr;
break;
case COMPARE:
text = Global.CheatList[index].CompareStr;
break;
case ON:
2014-01-30 15:51:07 +00:00
text = Global.CheatList[index].Enabled ? "*" : string.Empty;
break;
case DOMAIN:
text = Global.CheatList[index].Domain.Name;
break;
2013-10-05 03:40:36 +00:00
case SIZE:
text = Global.CheatList[index].Size.ToString();
2013-10-05 03:40:36 +00:00
break;
case ENDIAN:
2013-11-25 00:55:56 +00:00
text = (Global.CheatList[index].BigEndian ?? false) ? "Big" : "Little";
2013-10-05 03:40:36 +00:00
break;
case TYPE:
text = Watch.DisplayTypeToString(Global.CheatList[index].Type);
2013-10-05 03:40:36 +00:00
break;
}
2013-10-04 01:35:58 +00:00
}
private void CheatListView_QueryItemBkColor(int index, int column, ref Color color)
{
if (index < Global.CheatList.Count)
2013-10-04 01:35:58 +00:00
{
if (Global.CheatList[index].IsSeparator)
2013-10-04 01:35:58 +00:00
{
color = BackColor;
2013-10-04 01:35:58 +00:00
}
else if (Global.CheatList[index].Enabled)
2013-10-04 01:35:58 +00:00
{
color = Color.LightCyan;
}
}
}
2013-11-25 00:55:56 +00:00
private IEnumerable<int> SelectedIndices
{
2013-11-25 02:08:45 +00:00
get { return CheatListView.SelectedIndices.Cast<int>(); }
}
2013-10-05 03:40:36 +00:00
2013-11-25 00:55:56 +00:00
private IEnumerable<Cheat> SelectedItems
{
2013-11-25 00:55:56 +00:00
get { return SelectedIndices.Select(index => Global.CheatList[index]); }
}
2013-11-25 00:55:56 +00:00
private IEnumerable<Cheat> SelectedCheats
{
2013-11-25 02:08:45 +00:00
get { return SelectedItems.Where(x => !x.IsSeparator); }
2013-10-04 01:35:58 +00:00
}
private void DoSelectedIndexChange()
{
if (!CheatListView.SelectAllInProgress)
{
if (SelectedCheats.Any())
{
var cheat = SelectedCheats.First();
CheatEditor.SetCheat(cheat);
CheatGroupBox.Text = "Editing Cheat " + cheat.Name + " - " + cheat.AddressStr;
}
else
{
CheatEditor.ClearForm();
CheatGroupBox.Text = "New Cheat";
}
}
}
private void StartNewList()
{
var result = !Global.CheatList.Changes || AskSaveChanges();
2014-01-01 15:56:47 +00:00
if (result)
{
Global.CheatList.NewList(ToolManager.GenerateDefaultCheatFilename());
UpdateDialog();
UpdateMessageLabel();
ToggleGameGenieButton();
}
}
private void NewList()
{
var result = !Global.CheatList.Changes || AskSaveChanges();
if (result)
{
StartNewList();
}
}
2014-01-30 15:51:07 +00:00
private void RefreshFloatingWindowControl()
{
Owner = Settings.FloatingWindow ? null : GlobalWin.MainForm;
2014-01-30 15:51:07 +00:00
}
2013-10-02 15:09:49 +00:00
#region Events
#region File
private void FileSubMenu_DropDownOpened(object sender, EventArgs e)
{
SaveMenuItem.Enabled = Global.CheatList.Changes;
2013-10-02 15:09:49 +00:00
}
2013-10-05 03:40:36 +00:00
private void RecentSubMenu_DropDownOpened(object sender, EventArgs e)
{
RecentSubMenu.DropDownItems.Clear();
RecentSubMenu.DropDownItems.AddRange(
Global.Config.RecentCheats.RecentMenu(LoadFileFromRecent));
2013-10-05 03:40:36 +00:00
}
private void NewMenuItem_Click(object sender, EventArgs e)
{
NewList();
2013-10-05 03:40:36 +00:00
}
private void OpenMenuItem_Click(object sender, EventArgs e)
{
2013-11-25 02:08:45 +00:00
var append = sender == AppendMenuItem;
LoadFile(ToolHelpers.GetCheatFileFromUser(Global.CheatList.CurrentFileName), append);
2013-10-05 03:40:36 +00:00
}
private void SaveMenuItem_Click(object sender, EventArgs e)
{
if (Global.CheatList.Changes)
{
if (Global.CheatList.Save())
{
UpdateMessageLabel(saved: true);
}
}
else
{
SaveAsMenuItem_Click(sender, e);
}
}
private void SaveAsMenuItem_Click(object sender, EventArgs e)
{
if (SaveAs())
{
UpdateMessageLabel(saved: true);
}
}
2013-10-02 15:09:49 +00:00
private void ExitMenuItem_Click(object sender, EventArgs e)
{
Close();
}
#endregion
#region Cheats
private void CheatsSubMenu_DropDownOpened(object sender, EventArgs e)
{
RemoveCheatMenuItem.Enabled =
MoveUpMenuItem.Enabled =
MoveDownMenuItem.Enabled =
ToggleMenuItem.Enabled =
SelectedIndices.Any();
DisableAllCheatsMenuItem.Enabled = Global.CheatList.ActiveCount > 0;
GameGenieSeparator.Visible =
OpenGameGenieEncoderDecoderMenuItem.Visible =
(Emu.SystemId == "NES")
|| (Emu is Genesis)
|| (Emu.SystemId == "GB")
|| (Global.Game.System == "GG")
|| (Emu is LibsnesCore);
}
private void RemoveCheatMenuItem_Click(object sender, EventArgs e)
{
var items = SelectedItems.ToList();
if (items.Any())
{
foreach (var item in items)
{
Global.CheatList.Remove(item);
}
CheatListView.SelectedIndices.Clear();
UpdateDialog();
}
}
2013-10-02 15:09:49 +00:00
private void InsertSeparatorMenuItem_Click(object sender, EventArgs e)
{
if (SelectedIndices.Any())
{
Global.CheatList.Insert(SelectedIndices.Max(), Cheat.Separator);
}
else
{
Global.CheatList.Add(Cheat.Separator);
}
UpdateDialog();
UpdateMessageLabel();
}
private void MoveUpMenuItem_Click(object sender, EventArgs e)
{
var indices = SelectedIndices.ToList();
if (indices.Count == 0 || indices[0] == 0)
{
return;
}
foreach (var index in indices)
{
var cheat = Global.CheatList[index];
Global.CheatList.Remove(cheat);
Global.CheatList.Insert(index - 1, cheat);
}
var newindices = indices.Select(t => t - 1).ToList();
CheatListView.SelectedIndices.Clear();
foreach (var newi in newindices)
{
CheatListView.SelectItem(newi, true);
}
UpdateMessageLabel();
UpdateDialog();
}
private void MoveDownMenuItem_Click(object sender, EventArgs e)
{
var indices = SelectedIndices.ToList();
if (indices.Count == 0 || indices.Last() == Global.CheatList.Count - 1)
{
return;
}
for (var i = indices.Count - 1; i >= 0; i--)
{
var cheat = Global.CheatList[indices[i]];
Global.CheatList.Remove(cheat);
Global.CheatList.Insert(indices[i] + 1, cheat);
}
UpdateMessageLabel();
var newindices = indices.Select(t => t + 1).ToList();
CheatListView.SelectedIndices.Clear();
foreach (var newi in newindices)
{
CheatListView.SelectItem(newi, true);
}
UpdateDialog();
}
private void SelectAllMenuItem_Click(object sender, EventArgs e)
{
CheatListView.SelectAll();
}
private void ToggleMenuItem_Click(object sender, EventArgs e)
{
SelectedCheats.ToList().ForEach(x => x.Toggle());
}
private void DisableAllCheatsMenuItem_Click(object sender, EventArgs e)
{
Global.CheatList.DisableAll();
}
private void OpenGameGenieEncoderDecoderMenuItem_Click(object sender, EventArgs e)
{
GlobalWin.Tools.LoadGameGenieEc();
}
2013-10-02 15:09:49 +00:00
#endregion
#region Options
private void OptionsSubMenu_DropDownOpened(object sender, EventArgs e)
{
AlwaysLoadCheatsMenuItem.Checked = Global.Config.LoadCheatFileByGame;
AutoSaveCheatsMenuItem.Checked = Global.Config.CheatsAutoSaveOnClose;
2013-10-05 03:40:36 +00:00
DisableCheatsOnLoadMenuItem.Checked = Global.Config.DisableCheatsOnLoad;
AutoloadMenuItem.Checked = Global.Config.RecentCheats.AutoLoad;
SaveWindowPositionMenuItem.Checked = Settings.SaveWindowPosition;
AlwaysOnTopMenuItem.Checked = Settings.TopMost;
FloatingWindowMenuItem.Checked = Settings.FloatingWindow;
2013-10-05 03:40:36 +00:00
}
private void AlwaysLoadCheatsMenuItem_Click(object sender, EventArgs e)
{
Global.Config.LoadCheatFileByGame ^= true;
}
private void AutoSaveCheatsMenuItem_Click(object sender, EventArgs e)
{
Global.Config.CheatsAutoSaveOnClose ^= true;
}
2013-10-05 03:40:36 +00:00
private void CheatsOnOffLoadMenuItem_Click(object sender, EventArgs e)
{
Global.Config.DisableCheatsOnLoad ^= true;
}
2013-10-05 03:40:36 +00:00
private void AutoloadMenuItem_Click(object sender, EventArgs e)
{
Global.Config.RecentCheats.AutoLoad ^= true;
}
2013-10-02 15:09:49 +00:00
private void SaveWindowPositionMenuItem_Click(object sender, EventArgs e)
{
Settings.SaveWindowPosition ^= true;
}
private void AlwaysOnTopMenuItem_Click(object sender, EventArgs e)
{
Settings.TopMost ^= true;
2014-01-30 15:51:07 +00:00
}
private void FloatingWindowMenuItem_Click(object sender, EventArgs e)
{
Settings.FloatingWindow ^= true;
2014-01-30 15:51:07 +00:00
RefreshFloatingWindowControl();
2013-10-02 15:09:49 +00:00
}
2013-10-05 03:40:36 +00:00
private void RestoreWindowSizeMenuItem_Click(object sender, EventArgs e)
{
2013-11-25 00:55:56 +00:00
Size = new Size(_defaultWidth, _defaultHeight);
Settings = new CheatsSettings();
2013-10-05 03:40:36 +00:00
Global.Config.DisableCheatsOnLoad = false;
Global.Config.LoadCheatFileByGame = true;
Global.Config.CheatsAutoSaveOnClose = true;
2013-10-05 03:40:36 +00:00
2014-01-30 15:51:07 +00:00
RefreshFloatingWindowControl();
ColumnPositions();
LoadColumnInfo();
2013-10-05 03:40:36 +00:00
}
2013-10-02 15:09:49 +00:00
#endregion
#region Columns
private void ColumnsSubMenu_DropDownOpened(object sender, EventArgs e)
{
ShowNameMenuItem.Checked = Settings.Columns[NAME].Visible;
ShowAddressMenuItem.Checked = Settings.Columns[ADDRESS].Visible;
ShowValueMenuItem.Checked = Settings.Columns[VALUE].Visible;
ShowCompareMenuItem.Checked = Settings.Columns[COMPARE].Visible;
ShowOnMenuItem.Checked = Settings.Columns[ON].Visible;
ShowDomainMenuItem.Checked = Settings.Columns[DOMAIN].Visible;
ShowSizeMenuItem.Checked = Settings.Columns[SIZE].Visible;
ShowEndianMenuItem.Checked = Settings.Columns[ENDIAN].Visible;
ShowDisplayTypeMenuItem.Checked = Settings.Columns[TYPE].Visible;
2013-10-05 03:40:36 +00:00
}
private void ShowNameMenuItem_Click(object sender, EventArgs e)
{
DoColumnToggle(NAME);
}
private void ShowAddressMenuItem_Click(object sender, EventArgs e)
{
DoColumnToggle(ADDRESS);
}
private void ShowValueMenuItem_Click(object sender, EventArgs e)
{
DoColumnToggle(VALUE);
}
private void ShowCompareMenuItem_Click(object sender, EventArgs e)
{
DoColumnToggle(COMPARE);
}
2013-10-02 15:09:49 +00:00
2013-10-05 03:40:36 +00:00
private void ShowOnMenuItem_Click(object sender, EventArgs e)
{
DoColumnToggle(ON);
}
private void ShowDomainMenuItem_Click(object sender, EventArgs e)
{
DoColumnToggle(DOMAIN);
}
private void ShowSizeMenuItem_Click(object sender, EventArgs e)
{
DoColumnToggle(SIZE);
}
private void ShowEndianMenuItem_Click(object sender, EventArgs e)
{
DoColumnToggle(ENDIAN);
}
private void ShowDisplayTypeMenuItem_Click(object sender, EventArgs e)
{
DoColumnToggle(TYPE);
2013-10-02 15:09:49 +00:00
}
#endregion
2013-10-05 21:37:01 +00:00
#region ListView and Dialog Events
private void CheatListView_Click(object sender, EventArgs e)
{
DoSelectedIndexChange();
}
private void CheatListView_DoubleClick(object sender, EventArgs e)
{
ToggleMenuItem_Click(sender, e);
}
private void CheatListView_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Delete && !e.Control && !e.Alt && !e.Shift)
{
RemoveCheatMenuItem_Click(sender, e);
}
else if (e.KeyCode == Keys.A && e.Control && !e.Alt && !e.Shift)
{
SelectAllMenuItem_Click(null, null);
}
}
private void CheatListView_SelectedIndexChanged(object sender, EventArgs e)
{
DoSelectedIndexChange();
}
2013-10-05 21:37:01 +00:00
private void CheatListView_ColumnClick(object sender, ColumnClickEventArgs e)
{
var column = CheatListView.Columns[e.Column];
if (column.Name != _sortedColumn)
{
_sortReverse = false;
}
Global.CheatList.Sort(column.Name, _sortReverse);
2013-10-05 21:37:01 +00:00
_sortedColumn = column.Name;
_sortReverse ^= true;
UpdateDialog();
2013-10-05 21:37:01 +00:00
}
private void NewCheatForm_DragDrop(object sender, DragEventArgs e)
{
2013-11-25 02:08:45 +00:00
var filePaths = (string[])e.Data.GetData(DataFormats.FileDrop);
if (Path.GetExtension(filePaths[0]) == ".cht")
{
LoadFile(new FileInfo(filePaths[0]), append: false);
UpdateDialog();
UpdateMessageLabel();
}
}
private void NewCheatForm_DragEnter(object sender, DragEventArgs e)
{
e.Effect = e.Data.GetDataPresent(DataFormats.FileDrop) ? DragDropEffects.Copy : DragDropEffects.None;
}
private void CheatsContextMenu_Opening(object sender, CancelEventArgs e)
{
ToggleContextMenuItem.Enabled =
RemoveContextMenuItem.Enabled =
SelectedCheats.Any();
DisableAllContextMenuItem.Enabled = Global.CheatList.ActiveCount > 0;
}
private void ViewInHexEditorContextMenuItem_Click(object sender, EventArgs e)
{
var selected = SelectedCheats.ToList();
if (selected.Any())
{
GlobalWin.Tools.Load<HexEditor>();
if (selected.Select(x => x.Domain).Distinct().Count() > 1)
{
ToolHelpers.ViewInHexEditor(selected[0].Domain, new List<int> { selected.First().Address ?? 0 }, selected.First().Size);
}
else
{
ToolHelpers.ViewInHexEditor(selected.First().Domain, selected.Select(x => x.Address ?? 0), selected.First().Size);
}
}
}
2014-01-30 15:51:07 +00:00
protected override void OnShown(EventArgs e)
{
RefreshFloatingWindowControl();
base.OnShown(e);
}
#endregion
2013-10-02 15:09:49 +00:00
#endregion
}
}