Ram Search - Implement redo button. Enable/Disable Undo & Redo buttons when applicable

This commit is contained in:
andres.delikat 2011-09-14 23:36:36 +00:00
parent 49fb822bec
commit 7cfdad7bd0
3 changed files with 38 additions and 5 deletions

View File

@ -794,7 +794,6 @@
// RedotoolStripButton2
//
this.RedotoolStripButton2.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this.RedotoolStripButton2.Enabled = false;
this.RedotoolStripButton2.Image = global::BizHawk.MultiClient.Properties.Resources.redo;
this.RedotoolStripButton2.ImageTransparentColor = System.Drawing.Color.Magenta;
this.RedotoolStripButton2.Name = "RedotoolStripButton2";

View File

@ -28,6 +28,7 @@ namespace BizHawk.MultiClient
List<Watch> undoList = new List<Watch>();
List<Watch> weededList = new List<Watch>(); //When addresses are weeded out, the new list goes here, before going into searchList
List<Watch> prevList = new List<Watch>();
List<Watch> redoList = new List<Watch>();
private bool IsAWeededList = false; //For deciding whether the weeded list is relevant (0 size could mean all were removed in a legit preview
List<ToolStripMenuItem> domainMenuItems = new List<ToolStripMenuItem>();
MemoryDomain Domain = new MemoryDomain("NULL", 1, Endian.Little, addr => 0, (a, v) => { });
@ -94,6 +95,8 @@ namespace BizHawk.MultiClient
private void RamSearch_Load(object sender, EventArgs e)
{
ClearUndo();
ClearRedo();
LoadConfigSettings();
StartNewSearch();
SetMemoryDomainMenu();
@ -360,10 +363,11 @@ namespace BizHawk.MultiClient
private void StartNewSearch()
{
ClearUndo();
ClearRedo();
weededList.Clear();
IsAWeededList = false;
searchList.Clear();
undoList.Clear();
SetPlatformAndMemoryDomainLabel();
int count = 0;
int divisor = 1;
@ -515,6 +519,7 @@ namespace BizHawk.MultiClient
undoList.Clear();
for (int x = 0; x < searchList.Count; x++)
undoList.Add(new Watch(searchList[x]));
UndotoolStripButton.Enabled = true;
}
private void DoUndo()
@ -522,16 +527,43 @@ namespace BizHawk.MultiClient
if (undoList.Count > 0)
{
OutputLabel.Text = MakeAddressString(undoList.Count - searchList.Count) + " restored";
redoList = new List<Watch>(searchList);
searchList = new List<Watch>(undoList);
prevList = new List<Watch>(undoList);
undoList.Clear();
ClearUndo();
RedotoolStripButton2.Enabled = true;
DisplaySearchList();
//OutputLabel.Text = "Undo: s" + searchList.Count.ToString() + " u" +
// undoList.Count.ToString() + " r" + redoList.Count.ToString();
}
}
private void ClearUndo()
{
undoList.Clear();
UndotoolStripButton.Enabled = false;
}
private void ClearRedo()
{
redoList.Clear();
RedotoolStripButton2.Enabled = false;
}
private void DoRedo()
{
//TODO
if (redoList.Count > 0)
{
OutputLabel.Text = MakeAddressString(searchList.Count - redoList.Count) + " removed";
undoList = new List<Watch>(searchList);
searchList = new List<Watch>(redoList);
prevList = new List<Watch>(redoList);
ClearRedo();
UndotoolStripButton.Enabled = true;
DisplaySearchList();
//OutputLabel.Text = "Redo: s" + searchList.Count.ToString() + " u" +
// undoList.Count.ToString() + " r" + redoList.Count.ToString();
}
}
private void UndotoolStripButton_Click(object sender, EventArgs e)

View File

@ -76,7 +76,9 @@
<ItemGroup>
<Compile Include="AudioExtractor.cs" />
<Compile Include="DiscoHawk.cs" />
<Compile Include="DiscoHawkDialog.cs" />
<Compile Include="DiscoHawkDialog.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="DiscoHawkDialog.Designer.cs">
<DependentUpon>DiscoHawkDialog.cs</DependentUpon>
</Compile>