Save slot system in status bar, shows which slots have a file associated with them, which slot is currently selected, and clicking loads the state

This commit is contained in:
andres.delikat 2011-07-01 01:28:25 +00:00
parent b5ecda4f3e
commit 2b661b52ba
6 changed files with 252 additions and 21 deletions

View File

@ -266,6 +266,7 @@
<Compile Include="RecordMovie.Designer.cs">
<DependentUpon>RecordMovie.cs</DependentUpon>
</Compile>
<Compile Include="SavestateManager.cs" />
<Compile Include="Throttle.cs" />
<Compile Include="config\HotkeyWindow.cs">
<SubType>Form</SubType>

View File

@ -199,11 +199,22 @@
this.helpToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.helpToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
this.aboutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.statusStrip1 = new System.Windows.Forms.StatusStrip();
this.StatusSlot0 = new System.Windows.Forms.StatusStrip();
this.DumpError = new System.Windows.Forms.ToolStripDropDownButton();
this.EmuStatus = new System.Windows.Forms.ToolStripStatusLabel();
this.PlayRecordStatus = new System.Windows.Forms.ToolStripDropDownButton();
this.PauseStrip = new System.Windows.Forms.ToolStripDropDownButton();
this.toolStripStatusLabel1 = new System.Windows.Forms.ToolStripStatusLabel();
this.StatusSlot1 = new System.Windows.Forms.ToolStripStatusLabel();
this.StatusSlot2 = new System.Windows.Forms.ToolStripStatusLabel();
this.StatusSlot3 = new System.Windows.Forms.ToolStripStatusLabel();
this.StatusSlot4 = new System.Windows.Forms.ToolStripStatusLabel();
this.StatusSlot5 = new System.Windows.Forms.ToolStripStatusLabel();
this.StatusSlot6 = new System.Windows.Forms.ToolStripStatusLabel();
this.StatusSlot7 = new System.Windows.Forms.ToolStripStatusLabel();
this.StatusSlot8 = new System.Windows.Forms.ToolStripStatusLabel();
this.StatusSlot9 = new System.Windows.Forms.ToolStripStatusLabel();
this.StatusSlot10 = new System.Windows.Forms.ToolStripStatusLabel();
this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components);
this.openRomToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
this.loadLastROMToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
@ -221,7 +232,7 @@
this.screenshotToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
this.closeROMToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
this.menuStrip1.SuspendLayout();
this.statusStrip1.SuspendLayout();
this.StatusSlot0.SuspendLayout();
this.contextMenuStrip1.SuspendLayout();
this.SuspendLayout();
//
@ -1575,19 +1586,30 @@
this.aboutToolStripMenuItem.Text = "&About";
this.aboutToolStripMenuItem.Click += new System.EventHandler(this.aboutToolStripMenuItem_Click);
//
// statusStrip1
// StatusSlot0
//
this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.StatusSlot0.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.DumpError,
this.EmuStatus,
this.PlayRecordStatus,
this.PauseStrip});
this.statusStrip1.Location = new System.Drawing.Point(0, 386);
this.statusStrip1.Name = "statusStrip1";
this.statusStrip1.Size = new System.Drawing.Size(470, 22);
this.statusStrip1.SizingGrip = false;
this.statusStrip1.TabIndex = 1;
this.statusStrip1.Text = "statusStrip1";
this.PauseStrip,
this.toolStripStatusLabel1,
this.StatusSlot1,
this.StatusSlot2,
this.StatusSlot3,
this.StatusSlot4,
this.StatusSlot5,
this.StatusSlot6,
this.StatusSlot7,
this.StatusSlot8,
this.StatusSlot9,
this.StatusSlot10});
this.StatusSlot0.Location = new System.Drawing.Point(0, 386);
this.StatusSlot0.Name = "StatusSlot0";
this.StatusSlot0.Size = new System.Drawing.Size(470, 22);
this.StatusSlot0.SizingGrip = false;
this.StatusSlot0.TabIndex = 1;
this.StatusSlot0.Text = "0";
//
// DumpError
//
@ -1626,6 +1648,83 @@
this.PauseStrip.Text = "toolStripDropDownButton1";
this.PauseStrip.ToolTipText = "Emulator is paused";
//
// toolStripStatusLabel1
//
this.toolStripStatusLabel1.BackColor = System.Drawing.SystemColors.Control;
this.toolStripStatusLabel1.Name = "toolStripStatusLabel1";
this.toolStripStatusLabel1.Size = new System.Drawing.Size(56, 17);
this.toolStripStatusLabel1.Text = "Save slots";
//
// StatusSlot1
//
this.StatusSlot1.Name = "StatusSlot1";
this.StatusSlot1.Size = new System.Drawing.Size(13, 17);
this.StatusSlot1.Text = "1";
this.StatusSlot1.Click += new System.EventHandler(this.StatusSlot1_Click);
//
// StatusSlot2
//
this.StatusSlot2.Name = "StatusSlot2";
this.StatusSlot2.Size = new System.Drawing.Size(13, 17);
this.StatusSlot2.Text = "2";
this.StatusSlot2.Click += new System.EventHandler(this.StatusSlot2_Click);
//
// StatusSlot3
//
this.StatusSlot3.Name = "StatusSlot3";
this.StatusSlot3.Size = new System.Drawing.Size(13, 17);
this.StatusSlot3.Text = "3";
this.StatusSlot3.Click += new System.EventHandler(this.StatusSlot3_Click);
//
// StatusSlot4
//
this.StatusSlot4.Name = "StatusSlot4";
this.StatusSlot4.Size = new System.Drawing.Size(13, 17);
this.StatusSlot4.Text = "4";
this.StatusSlot4.Click += new System.EventHandler(this.StatusSlot4_Click);
//
// StatusSlot5
//
this.StatusSlot5.Name = "StatusSlot5";
this.StatusSlot5.Size = new System.Drawing.Size(13, 17);
this.StatusSlot5.Text = "5";
this.StatusSlot5.Click += new System.EventHandler(this.StatusSlot5_Click);
//
// StatusSlot6
//
this.StatusSlot6.Name = "StatusSlot6";
this.StatusSlot6.Size = new System.Drawing.Size(13, 17);
this.StatusSlot6.Text = "6";
this.StatusSlot6.Click += new System.EventHandler(this.StatusSlot6_Click);
//
// StatusSlot7
//
this.StatusSlot7.Name = "StatusSlot7";
this.StatusSlot7.Size = new System.Drawing.Size(13, 17);
this.StatusSlot7.Text = "7";
this.StatusSlot7.Click += new System.EventHandler(this.StatusSlot7_Click);
//
// StatusSlot8
//
this.StatusSlot8.Name = "StatusSlot8";
this.StatusSlot8.Size = new System.Drawing.Size(13, 17);
this.StatusSlot8.Text = "8";
this.StatusSlot8.Click += new System.EventHandler(this.StatusSlot8_Click);
//
// StatusSlot9
//
this.StatusSlot9.Name = "StatusSlot9";
this.StatusSlot9.Size = new System.Drawing.Size(13, 17);
this.StatusSlot9.Text = "9";
this.StatusSlot9.Click += new System.EventHandler(this.StatusSlot9_Click);
//
// StatusSlot10
//
this.StatusSlot10.Name = "StatusSlot10";
this.StatusSlot10.Size = new System.Drawing.Size(13, 17);
this.StatusSlot10.Text = "0";
this.StatusSlot10.Click += new System.EventHandler(this.StatusSlot10_Click);
//
// contextMenuStrip1
//
this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
@ -1757,7 +1856,7 @@
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 14F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(470, 408);
this.Controls.Add(this.statusStrip1);
this.Controls.Add(this.StatusSlot0);
this.Controls.Add(this.menuStrip1);
this.Font = new System.Drawing.Font("Arial", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
@ -1773,8 +1872,8 @@
this.Activated += new System.EventHandler(this.MainForm_Activated);
this.menuStrip1.ResumeLayout(false);
this.menuStrip1.PerformLayout();
this.statusStrip1.ResumeLayout(false);
this.statusStrip1.PerformLayout();
this.StatusSlot0.ResumeLayout(false);
this.StatusSlot0.PerformLayout();
this.contextMenuStrip1.ResumeLayout(false);
this.ResumeLayout(false);
this.PerformLayout();
@ -1920,7 +2019,7 @@
private System.Windows.Forms.ToolStripMenuItem toolBoxToolStripMenuItem;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator12;
private System.Windows.Forms.ToolStripMenuItem switchToFullscreenToolStripMenuItem;
private System.Windows.Forms.StatusStrip statusStrip1;
private System.Windows.Forms.StatusStrip StatusSlot0;
private System.Windows.Forms.ToolStripStatusLabel EmuStatus;
private System.Windows.Forms.ToolStripMenuItem messagesToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem tI83ToolStripMenuItem;
@ -1973,6 +2072,17 @@
private MenuStripEx menuStrip1;
private System.Windows.Forms.ToolStripMenuItem gBToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem debuggerToolStripMenuItem1;
private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel1;
private System.Windows.Forms.ToolStripStatusLabel StatusSlot1;
private System.Windows.Forms.ToolStripStatusLabel StatusSlot2;
private System.Windows.Forms.ToolStripStatusLabel StatusSlot3;
private System.Windows.Forms.ToolStripStatusLabel StatusSlot4;
private System.Windows.Forms.ToolStripStatusLabel StatusSlot5;
private System.Windows.Forms.ToolStripStatusLabel StatusSlot6;
private System.Windows.Forms.ToolStripStatusLabel StatusSlot7;
private System.Windows.Forms.ToolStripStatusLabel StatusSlot8;
private System.Windows.Forms.ToolStripStatusLabel StatusSlot9;
private System.Windows.Forms.ToolStripStatusLabel StatusSlot10;
}
}

View File

@ -192,60 +192,70 @@ namespace BizHawk.MultiClient
private void selectSlot1ToolStripMenuItem_Click(object sender, EventArgs e)
{
SaveSlot = 1;
UpdateStatusSlots();
SaveSlotSelectedMessage();
}
private void selectSlot2ToolStripMenuItem_Click(object sender, EventArgs e)
{
SaveSlot = 2;
UpdateStatusSlots();
SaveSlotSelectedMessage();
}
private void selectSlot3ToolStripMenuItem_Click(object sender, EventArgs e)
{
SaveSlot = 3;
UpdateStatusSlots();
SaveSlotSelectedMessage();
}
private void selectSlot4ToolStripMenuItem_Click(object sender, EventArgs e)
{
SaveSlot = 4;
UpdateStatusSlots();
SaveSlotSelectedMessage();
}
private void selectSlot5ToolStripMenuItem_Click(object sender, EventArgs e)
{
SaveSlot = 5;
UpdateStatusSlots();
SaveSlotSelectedMessage();
}
private void selectSlot6ToolStripMenuItem_Click(object sender, EventArgs e)
{
SaveSlot = 6;
UpdateStatusSlots();
SaveSlotSelectedMessage();
}
private void selectSlot7ToolStripMenuItem_Click(object sender, EventArgs e)
{
SaveSlot = 7;
UpdateStatusSlots();
SaveSlotSelectedMessage();
}
private void selectSlot8ToolStripMenuItem_Click(object sender, EventArgs e)
{
SaveSlot = 8;
UpdateStatusSlots();
SaveSlotSelectedMessage();
}
private void selectSlot9ToolStripMenuItem_Click(object sender, EventArgs e)
{
SaveSlot = 9;
UpdateStatusSlots();
SaveSlotSelectedMessage();
}
private void selectSlot10ToolStripMenuItem_Click(object sender, EventArgs e)
{
SaveSlot = 0;
UpdateStatusSlots();
SaveSlotSelectedMessage();
}
@ -694,7 +704,7 @@ namespace BizHawk.MultiClient
displayStatusBarToolStripMenuItem.Checked = Global.Config.DisplayStatusBar;
if (!InFullscreen)
{
statusStrip1.Visible = Global.Config.DisplayStatusBar;
StatusSlot0.Visible = Global.Config.DisplayStatusBar;
PerformLayout();
FrameBufferResized();
}

View File

@ -20,6 +20,7 @@ namespace BizHawk.MultiClient
private Control renderTarget;
private RetainedViewportPanel retainedPanel;
public string CurrentlyOpenRom;
SavestateManager StateSlots = new SavestateManager();
//Movie variables
public Movie InputLog = new Movie("", MOVIEMODE.INACTIVE);
@ -68,7 +69,7 @@ namespace BizHawk.MultiClient
public MainForm(string[] args)
{
InitializeComponent();
UpdateStatusSlots();
//in order to allow late construction of this database, we hook up a delegate here to dearchive the data and provide it on demand
//we could background thread this later instead if we wanted to be real clever
NES.BootGodDB.GetDatabaseBytes = () =>
@ -210,7 +211,7 @@ namespace BizHawk.MultiClient
this.Location = new Point(Global.Config.MainWndx, Global.Config.MainWndy);
if (Global.Config.DisplayStatusBar == false)
statusStrip1.Visible = false;
StatusSlot0.Visible = false;
else
displayStatusBarToolStripMenuItem.Checked = true;
@ -909,6 +910,7 @@ namespace BizHawk.MultiClient
Cheats1.Restart();
CurrentlyOpenRom = file.CanonicalFullPath;
HandlePlatformMenus();
UpdateStatusSlots();
return true;
}
}
@ -1025,6 +1027,7 @@ namespace BizHawk.MultiClient
{
SaveSlot = i;
SaveSlotSelectedMessage();
UpdateStatusSlots();
Global.ClientControls.UnpressButton("SelectSlot" + i.ToString());
}
}
@ -1454,6 +1457,7 @@ namespace BizHawk.MultiClient
HandleMovieSaveState(writer);
writer.Close();
Global.RenderPanel.AddMessage("Saved state: " + name);
UpdateStatusSlots();
}
private void SaveStateAs()
@ -1476,6 +1480,7 @@ namespace BizHawk.MultiClient
HandleMovieSaveState(writer);
writer.Close();
Global.RenderPanel.AddMessage(sfd.FileName + " saved");
UpdateStatusSlots();
}
private void HandleMovieLoadState(StreamReader reader)
@ -1921,7 +1926,7 @@ namespace BizHawk.MultiClient
FormBorderStyle = FormBorderStyle.None;
WindowState = FormWindowState.Maximized;
MainMenuStrip.Visible = false;
statusStrip1.Visible = false;
StatusSlot0.Visible = false;
PerformLayout();
Global.RenderPanel.Resized = true;
InFullscreen = true;
@ -1931,7 +1936,7 @@ namespace BizHawk.MultiClient
FormBorderStyle = FormBorderStyle.FixedSingle;
WindowState = FormWindowState.Normal;
MainMenuStrip.Visible = true;
statusStrip1.Visible = Global.Config.DisplayStatusBar;
StatusSlot0.Visible = Global.Config.DisplayStatusBar;
Location = WindowedLocation;
PerformLayout();
FrameBufferResized();
@ -2044,6 +2049,7 @@ namespace BizHawk.MultiClient
Cheats1.Restart();
Text = "BizHawk";
HandlePlatformMenus();
UpdateStatusSlots();
}
private void frameSkipToolStripMenuItem_DropDownOpened(object sender, EventArgs e)
@ -2338,5 +2344,54 @@ namespace BizHawk.MultiClient
if (Global.Emulator.ControllerDefinition.BoolButtons.Contains("Reset"))
Global.ActiveController.ForceButton("Reset");
}
public void UpdateStatusSlots()
{
StateSlots.Update();
StatusSlot1.Enabled = StateSlots.HasSlot(1);
StatusSlot2.Enabled = StateSlots.HasSlot(2);
StatusSlot3.Enabled = StateSlots.HasSlot(3);
StatusSlot4.Enabled = StateSlots.HasSlot(4);
StatusSlot5.Enabled = StateSlots.HasSlot(5);
StatusSlot6.Enabled = StateSlots.HasSlot(6);
StatusSlot7.Enabled = StateSlots.HasSlot(7);
StatusSlot8.Enabled = StateSlots.HasSlot(8);
StatusSlot9.Enabled = StateSlots.HasSlot(9);
StatusSlot10.Enabled = StateSlots.HasSlot(0);
StatusSlot1.BackColor = SystemColors.Control;
StatusSlot2.BackColor = SystemColors.Control;
StatusSlot3.BackColor = SystemColors.Control;
StatusSlot4.BackColor = SystemColors.Control;
StatusSlot5.BackColor = SystemColors.Control;
StatusSlot6.BackColor = SystemColors.Control;
StatusSlot7.BackColor = SystemColors.Control;
StatusSlot8.BackColor = SystemColors.Control;
StatusSlot9.BackColor = SystemColors.Control;
StatusSlot10.BackColor = SystemColors.Control;
if (SaveSlot == 0) StatusSlot10.BackColor = SystemColors.ControlLightLight;
if (SaveSlot == 1) StatusSlot1.BackColor = SystemColors.ControlLightLight;
if (SaveSlot == 2) StatusSlot2.BackColor = SystemColors.ControlLightLight;
if (SaveSlot == 3) StatusSlot3.BackColor = SystemColors.ControlLightLight;
if (SaveSlot == 4) StatusSlot4.BackColor = SystemColors.ControlLightLight;
if (SaveSlot == 5) StatusSlot5.BackColor = SystemColors.ControlLightLight;
if (SaveSlot == 6) StatusSlot6.BackColor = SystemColors.ControlLightLight;
if (SaveSlot == 7) StatusSlot7.BackColor = SystemColors.ControlLightLight;
if (SaveSlot == 8) StatusSlot8.BackColor = SystemColors.ControlLightLight;
if (SaveSlot == 9) StatusSlot9.BackColor = SystemColors.ControlLightLight;
}
private void StatusSlot1_Click(object sender, EventArgs e) { LoadState("QuickSave1"); }
private void StatusSlot2_Click(object sender, EventArgs e) { LoadState("QuickSave2"); }
private void StatusSlot3_Click(object sender, EventArgs e) { LoadState("QuickSave3"); }
private void StatusSlot4_Click(object sender, EventArgs e) { LoadState("QuickSave4"); }
private void StatusSlot5_Click(object sender, EventArgs e) { LoadState("QuickSave5"); }
private void StatusSlot6_Click(object sender, EventArgs e) { LoadState("QuickSave6"); }
private void StatusSlot7_Click(object sender, EventArgs e) { LoadState("QuickSave7"); }
private void StatusSlot8_Click(object sender, EventArgs e) { LoadState("QuickSave8"); }
private void StatusSlot9_Click(object sender, EventArgs e) { LoadState("QuickSave9"); }
private void StatusSlot10_Click(object sender, EventArgs e) { LoadState("QuickSave0"); }
}
}

View File

@ -120,7 +120,7 @@
<metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="statusStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<metadata name="StatusSlot0.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>126, 17</value>
</metadata>
<metadata name="contextMenuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">

View File

@ -0,0 +1,55 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace BizHawk.MultiClient
{
class SavestateManager
{
private bool[] slots = new bool[10];
public SavestateManager()
{
Update();
}
public void Update()
{
string path;
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++)
{
path = Global.Game.SaveStatePrefix + "." + "QuickSave" + x + ".State";
var file = new FileInfo(path);
if (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];
}
}
}