Undo savestate context menu item implemented
This commit is contained in:
parent
3fc7e6c95f
commit
6711995c5b
|
@ -767,11 +767,6 @@ namespace BizHawk.MultiClient
|
|||
}
|
||||
}
|
||||
|
||||
private void undoSavestateToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
//TODO
|
||||
}
|
||||
|
||||
private void screenshotToolStripMenuItem1_Click(object sender, EventArgs e)
|
||||
{
|
||||
TakeScreenshot();
|
||||
|
@ -878,9 +873,22 @@ namespace BizHawk.MultiClient
|
|||
else
|
||||
contextMenuStrip1.Items[7].Enabled = true;
|
||||
|
||||
string path = Global.Game.SaveStatePrefix + "." + "QuickSave" + SaveSlot.ToString() + ".State.bak";
|
||||
var file = new FileInfo(path);
|
||||
if (file.Exists == true)
|
||||
{
|
||||
contextMenuStrip1.Items[13].Enabled = true;
|
||||
contextMenuStrip1.Items[13].Text = "Undo Save to slot " + SaveSlot.ToString();
|
||||
contextMenuStrip1.Items[13].Image = BizHawk.MultiClient.Properties.Resources.undo;
|
||||
}
|
||||
else
|
||||
{
|
||||
contextMenuStrip1.Items[13].Enabled = false;
|
||||
contextMenuStrip1.Items[13].Text = "Undo Savestate";
|
||||
contextMenuStrip1.Items[13].Image = BizHawk.MultiClient.Properties.Resources.undo;
|
||||
}
|
||||
|
||||
//TODO:
|
||||
contextMenuStrip1.Items[13].Enabled = false;
|
||||
//contextMenuStrip1.Items[13].Enabled = false;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1296,5 +1304,12 @@ namespace BizHawk.MultiClient
|
|||
{
|
||||
Global.Config.BackupSavestates ^= true;
|
||||
}
|
||||
|
||||
private void undoSavestateToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
string path = Global.Game.SaveStatePrefix + "." + "QuickSave" + SaveSlot.ToString() + ".State";
|
||||
SwapBackupSavestate(path);
|
||||
Global.RenderPanel.AddMessage("Save slot " + SaveSlot.ToString() + " restored.");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2178,5 +2178,24 @@ namespace BizHawk.MultiClient
|
|||
AVIStatusLabel.Image = BizHawk.MultiClient.Properties.Resources.Blank;
|
||||
AVIStatusLabel.ToolTipText = "";
|
||||
}
|
||||
|
||||
private void SwapBackupSavestate(string path)
|
||||
{
|
||||
//Takes the .state and .bak files and swaps them
|
||||
var state = new FileInfo(path);
|
||||
var backup = new FileInfo(path + ".bak");
|
||||
var temp = new FileInfo(path + ".bak.tmp");
|
||||
|
||||
if (state.Exists == false) return;
|
||||
if (backup.Exists == false) return;
|
||||
if (temp.Exists == true) temp.Delete();
|
||||
|
||||
backup.CopyTo(path + ".bak.tmp");
|
||||
backup.Delete();
|
||||
state.CopyTo(path + ".bak");
|
||||
state.Delete();
|
||||
temp.CopyTo(path);
|
||||
temp.Delete();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue