TAStudio: Fixed displayed maximum state capacity.

Clear states to stay within the new limit when settings are changed.
This commit is contained in:
Suuper 2015-08-15 10:07:56 -05:00
parent 3cbea04448
commit d6e3553449
3 changed files with 20 additions and 4 deletions

View File

@ -68,8 +68,8 @@ namespace BizHawk.Client.Common
if (!IsOnDisk)
return;
var key = ID.ToString();
var ret = _manager.ndbdatabase.FetchAll(key);
string key = ID.ToString();
_state = _manager.ndbdatabase.FetchAll(key);
_manager.ndbdatabase.Release(key);
}
public void Dispose()
@ -144,7 +144,7 @@ namespace BizHawk.Client.Common
return -2;
}
public string statePath
private string statePath
{
get
{
@ -313,6 +313,9 @@ namespace BizHawk.Client.Common
if (Used > Settings.Cap)
{
if (DiskUsed > (ulong)Settings.DiskCapacitymb * 1024uL * 1024uL)
MaybeRemoveState();
int lastMemState = -1;
do { lastMemState++; } while (States[accessed[lastMemState]] == null);
MoveStateToDisk(accessed[lastMemState]);
@ -528,6 +531,16 @@ namespace BizHawk.Client.Common
ndbdatabase.Clear();
}
/// <summary>
/// Deletes/moves states to follow the state storage size limits.
/// Used after changing the settings.
/// </summary>
public void LimitStateCount()
{
while (Used + DiskUsed > Settings.CapTotal)
MaybeRemoveState();
}
// TODO: save/load BranchStates
public void Save(BinaryWriter bw)
{

View File

@ -48,7 +48,9 @@ namespace BizHawk.Client.EmuHawk
private int MaxStatesInCapacity
{
get { return (int)Math.Floor((MemCapacityNumeric.Value + DiskCapacityNumeric.Value) / _stateSizeMb); }
get { return (int)Math.Floor(MemCapacityNumeric.Value / _stateSizeMb)
+ (int)Math.Floor(DiskCapacityNumeric.Value / _stateSizeMb);
}
}
private void OkBtn_Click(object sender, EventArgs e)

View File

@ -748,6 +748,7 @@ namespace BizHawk.Client.EmuHawk
Location = this.ChildPointToScreen(TasView),
Statable = this.StatableEmulator
}.Show();
CurrentTasMovie.TasStateManager.
UpdateChangesIndicator();
}