forked from TASEmulators/BizHawk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSavestateManager.cs
83 lines (70 loc) · 1.42 KB
/
SavestateManager.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
using System.IO;
using BizHawk.Client.Common;
namespace BizHawk.MultiClient
{
class SavestateManager
{
private readonly bool[] slots = new bool[10];
private readonly bool[] redo = new bool[10];
public SavestateManager()
{
Update();
}
public void Update()
{
if (Global.Game == null || Global.Emulator == null)
{
for (int x = 0; x < 10; x++)
slots[x] = false;
return;
}
for (int x = 0; x < 10; x++)
{
string path = PathManager.SaveStatePrefix(Global.Game) + "." + "QuickSave" + x + ".State";
var file = new FileInfo(path);
if (file.Directory != null && file.Directory.Exists == false)
file.Directory.Create();
slots[x] = file.Exists;
}
}
public bool HasSavestateSlots()
{
Update();
for (int x = 0; x < 10; x++)
{
if (slots[x]) return true;
}
return false;
}
public bool HasSlot(int slot)
{
if (slot < 0 || slot > 10) return false;
Update();
return slots[slot];
}
public void ClearRedoList()
{
for (int x = 0; x < 10; x++)
{
redo[x] = false;
}
}
public void ToggleRedo(int slot)
{
if (slot < 0 || slot > 9)
return;
redo[slot] ^= true;
}
public bool IsRedo(int slot)
{
if (slot < 0 || slot > 9)
return false;
return redo[slot];
}
public void Clear()
{
ClearRedoList();
Update();
}
}
}