Ram Search - limit to 5 undo levels
This commit is contained in:
parent
2abd8c8dd1
commit
2a12b59250
|
@ -8,8 +8,11 @@ namespace BizHawk.Common
|
|||
private List<List<T>> _history = new List<List<T>>();
|
||||
private int _curPos; // 1-based
|
||||
|
||||
public int MaxUndoLevels { get; set; }
|
||||
|
||||
public UndoHistory(bool enabled)
|
||||
{
|
||||
MaxUndoLevels = 5;
|
||||
Enabled = enabled;
|
||||
}
|
||||
|
||||
|
@ -54,6 +57,15 @@ namespace BizHawk.Common
|
|||
}
|
||||
}
|
||||
|
||||
// TODO: don't assume we are one over, since MaxUndoLevels is public, it could be set to a small number after a large list has occured
|
||||
if (_history.Count > MaxUndoLevels)
|
||||
{
|
||||
foreach (var item in _history.Take(_history.Count - MaxUndoLevels))
|
||||
{
|
||||
_history.Remove(item);
|
||||
}
|
||||
}
|
||||
|
||||
_history.Add(newState.ToList());
|
||||
_curPos = _history.Count;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue