2013-04-15 02:14:14 +00:00
|
|
|
|
using System.IO;
|
2011-07-01 01:28:25 +00:00
|
|
|
|
|
2013-10-27 07:54:00 +00:00
|
|
|
|
namespace BizHawk.Client.Common
|
2011-07-01 01:28:25 +00:00
|
|
|
|
{
|
2013-11-01 19:55:03 +00:00
|
|
|
|
public class SaveSlotManager
|
2011-07-01 01:28:25 +00:00
|
|
|
|
{
|
2013-04-15 02:14:14 +00:00
|
|
|
|
private readonly bool[] slots = new bool[10];
|
|
|
|
|
private readonly bool[] redo = new bool[10];
|
2011-07-01 01:28:25 +00:00
|
|
|
|
|
2013-11-01 19:55:03 +00:00
|
|
|
|
public SaveSlotManager()
|
2011-07-01 01:28:25 +00:00
|
|
|
|
{
|
|
|
|
|
Update();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Update()
|
|
|
|
|
{
|
2013-10-20 18:02:43 +00:00
|
|
|
|
if (Global.Game == null || Global.Emulator == null)
|
2011-07-01 01:28:25 +00:00
|
|
|
|
{
|
2013-11-01 19:55:03 +00:00
|
|
|
|
for (int i = 0; i < 10; i++)
|
|
|
|
|
{
|
|
|
|
|
slots[i] = false;
|
|
|
|
|
}
|
2011-07-01 01:28:25 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
2013-11-01 19:55:03 +00:00
|
|
|
|
for (int i = 0; i < 10; i++)
|
2011-07-01 01:28:25 +00:00
|
|
|
|
{
|
2013-11-01 19:55:03 +00:00
|
|
|
|
var file = new FileInfo(
|
|
|
|
|
PathManager.SaveStatePrefix(Global.Game) + "." + "QuickSave" + i + ".State"
|
|
|
|
|
);
|
2013-04-15 02:14:14 +00:00
|
|
|
|
if (file.Directory != null && file.Directory.Exists == false)
|
2013-11-01 19:55:03 +00:00
|
|
|
|
{
|
2011-07-01 01:28:25 +00:00
|
|
|
|
file.Directory.Create();
|
2013-11-01 19:55:03 +00:00
|
|
|
|
}
|
|
|
|
|
slots[i] = file.Exists;
|
2011-07-01 01:28:25 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-27 07:54:00 +00:00
|
|
|
|
public bool HasSavestateSlots
|
2011-07-01 01:28:25 +00:00
|
|
|
|
{
|
2013-10-27 07:54:00 +00:00
|
|
|
|
get
|
2011-07-01 01:28:25 +00:00
|
|
|
|
{
|
2013-10-27 07:54:00 +00:00
|
|
|
|
Update();
|
2013-11-01 19:55:03 +00:00
|
|
|
|
for (int i = 0; i < 10; i++)
|
2013-10-27 07:54:00 +00:00
|
|
|
|
{
|
2013-11-01 19:55:03 +00:00
|
|
|
|
if (slots[i]) return true;
|
2013-10-27 07:54:00 +00:00
|
|
|
|
}
|
|
|
|
|
return false;
|
2011-07-01 01:28:25 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool HasSlot(int slot)
|
|
|
|
|
{
|
2013-11-03 02:51:21 +00:00
|
|
|
|
if (Global.Emulator is NullEmulator)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-01 19:55:03 +00:00
|
|
|
|
if (slot < 0 || slot > 10)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2011-07-01 01:28:25 +00:00
|
|
|
|
|
|
|
|
|
Update();
|
|
|
|
|
return slots[slot];
|
|
|
|
|
}
|
2011-07-31 23:25:00 +00:00
|
|
|
|
|
|
|
|
|
public void ClearRedoList()
|
|
|
|
|
{
|
2013-11-01 19:55:03 +00:00
|
|
|
|
for (int i = 0; i < 10; i++)
|
2011-07-31 23:25:00 +00:00
|
|
|
|
{
|
2013-11-01 19:55:03 +00:00
|
|
|
|
redo[i] = false;
|
2011-07-31 23:25:00 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void ToggleRedo(int slot)
|
|
|
|
|
{
|
|
|
|
|
if (slot < 0 || slot > 9)
|
2013-11-01 19:55:03 +00:00
|
|
|
|
{
|
2011-07-31 23:25:00 +00:00
|
|
|
|
return;
|
2013-11-01 19:55:03 +00:00
|
|
|
|
}
|
2011-07-31 23:25:00 +00:00
|
|
|
|
|
|
|
|
|
redo[slot] ^= true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool IsRedo(int slot)
|
|
|
|
|
{
|
|
|
|
|
if (slot < 0 || slot > 9)
|
2013-11-01 19:55:03 +00:00
|
|
|
|
{
|
2011-07-31 23:25:00 +00:00
|
|
|
|
return false;
|
2013-11-01 19:55:03 +00:00
|
|
|
|
}
|
2011-07-31 23:25:00 +00:00
|
|
|
|
|
|
|
|
|
return redo[slot];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Clear()
|
|
|
|
|
{
|
|
|
|
|
ClearRedoList();
|
|
|
|
|
Update();
|
|
|
|
|
}
|
2011-07-01 01:28:25 +00:00
|
|
|
|
}
|
|
|
|
|
}
|