Add a Freeze/Unfreeze option to recent menus

This commit is contained in:
adelikat 2014-08-02 22:49:27 +00:00
parent ae233f623e
commit a65e4a2be7
2 changed files with 32 additions and 12 deletions

View File

@ -20,6 +20,11 @@ namespace BizHawk.Client.Common
public int MAX_RECENT_FILES { get; set; }
public bool AutoLoad { get; set; }
/// <summary>
/// If true, the list can not change, or be cleared
/// </summary>
public bool Frozen { get; set; }
[JsonIgnore]
public bool Empty
{
@ -65,11 +70,16 @@ namespace BizHawk.Client.Common
}
public void Clear()
{
if (!Frozen)
{
recentlist.Clear();
}
}
public void Add(string newFile)
{
if (!Frozen)
{
Remove(newFile);
recentlist.Insert(0, newFile);
@ -79,8 +89,11 @@ namespace BizHawk.Client.Common
recentlist.Remove(recentlist.Last());
}
}
}
public bool Remove(string newFile)
{
if (!Frozen)
{
var removed = false;
foreach (var recent in recentlist.ToList())
@ -95,6 +108,9 @@ namespace BizHawk.Client.Common
return removed;
}
return false;
}
public List<string> GetRecentListTruncated(int length)
{
return recentlist.Select(t => t.Substring(0, length)).ToList();

View File

@ -36,6 +36,10 @@ namespace BizHawk.Client.EmuHawk.ToolExtensions
clearitem.Click += (o, ev) => recent.Clear();
items.Add(clearitem);
var freezeitem = new ToolStripMenuItem { Text = recent.Frozen ? "&Unfreeze" : "&Freeze" };
freezeitem.Click += (o, ev) => recent.Frozen ^= true;
items.Add(freezeitem);
if (autoload)
{
var auto = new ToolStripMenuItem { Text = "&Autoload", Checked = recent.AutoLoad };