AVI cleanup - gray of menu items when appropriate, use default filename, and AVI Path config, add on screen messages, fix crash on Null emulator capture (snow is awesome yo), other misc things

This commit is contained in:
andres.delikat 2011-07-11 23:26:20 +00:00
parent e6202bdea1
commit bd71909f38
4 changed files with 138 additions and 98 deletions

View File

@ -18,8 +18,10 @@ namespace BizHawk
public NullEmulator()
{
var domains = new List<MemoryDomain>(1);
domains.Add(new MemoryDomain("Main RAM", 1, Endian.Little, addr=>0, (a,v)=> { }));
domains.Add(new MemoryDomain("Main RAM", 1, Endian.Little, addr => 0, (a, v) => { }));
memoryDomains = domains.AsReadOnly();
CoreOutputComm = new CoreOutputComm();
CoreInputComm = new CoreInputComm();
}
public void LoadGame(IGame game) { }
public void FrameAdvance(bool render)

View File

@ -258,7 +258,7 @@
this.menuStrip1.LayoutStyle = System.Windows.Forms.ToolStripLayoutStyle.Flow;
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
this.menuStrip1.Name = "menuStrip1";
this.menuStrip1.Size = new System.Drawing.Size(470, 40);
this.menuStrip1.Size = new System.Drawing.Size(470, 21);
this.menuStrip1.TabIndex = 0;
this.menuStrip1.Text = "menuStrip1";
this.menuStrip1.MenuDeactivate += new System.EventHandler(this.menuStrip1_MenuDeactivate);
@ -805,9 +805,11 @@
this.aVIWAVToolStripMenuItem.Name = "aVIWAVToolStripMenuItem";
this.aVIWAVToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
this.aVIWAVToolStripMenuItem.Text = "AVI/WAV";
this.aVIWAVToolStripMenuItem.DropDownOpened += new System.EventHandler(this.aVIWAVToolStripMenuItem_DropDownOpened);
//
// recordAVIToolStripMenuItem
//
this.recordAVIToolStripMenuItem.Image = global::BizHawk.MultiClient.Properties.Resources.RecordHS;
this.recordAVIToolStripMenuItem.Name = "recordAVIToolStripMenuItem";
this.recordAVIToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
this.recordAVIToolStripMenuItem.Text = "Record AVI";
@ -815,6 +817,7 @@
//
// stopAVIToolStripMenuItem
//
this.stopAVIToolStripMenuItem.Image = global::BizHawk.MultiClient.Properties.Resources.Stop;
this.stopAVIToolStripMenuItem.Name = "stopAVIToolStripMenuItem";
this.stopAVIToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
this.stopAVIToolStripMenuItem.Text = "Stop AVI";

View File

@ -10,39 +10,12 @@ namespace BizHawk.MultiClient
{
private void recordAVIToolStripMenuItem_Click(object sender, EventArgs e)
{
var sfd = new SaveFileDialog();
//TODO adelikat (dunno how to do the paths correctly)
sfd.FileName = Path.Combine(Global.Config.AVIPath, "game.avi");
if (sfd.ShowDialog() == DialogResult.Cancel)
return;
//TODO - cores should be able to specify exact values for these instead of relying on this to calculate them
int fps = (int)(Global.Emulator.CoreOutputComm.VsyncRate * 0x01000000);
AviWriter aw = new AviWriter();
try
{
aw.SetMovieParameters(fps, 0x01000000);
aw.SetVideoParameters(Global.Emulator.VideoProvider.BufferWidth, Global.Emulator.VideoProvider.BufferHeight);
aw.SetAudioParameters(44100, 2, 16);
aw.OpenFile(sfd.FileName);
var token = aw.AcquireVideoCodecToken(Global.MainForm.Handle);
aw.SetVideoCodecToken(token);
aw.OpenStreams();
//commit the avi writing last, in case there were any errors earlier
CurrAviWriter = aw;
}
catch
{
aw.Dispose();
throw;
}
RecordAVI();
}
private void stopAVIToolStripMenuItem_Click(object sender, EventArgs e)
{
CurrAviWriter.CloseFile();
CurrAviWriter = null;
StopAVI();
}
private void DumpStatus_Click(object sender, EventArgs e)
@ -961,5 +934,29 @@ namespace BizHawk.MultiClient
else
LogConsole.HideConsole();
}
private void PauseStrip_Click(object sender, EventArgs e)
{
TogglePause();
}
private void displaySubtitlesToolStripMenuItem_Click(object sender, EventArgs e)
{
Global.Config.DisplaySubtitles ^= true;
}
private void aVIWAVToolStripMenuItem_DropDownOpened(object sender, EventArgs e)
{
if (CurrAviWriter == null)
{
recordAVIToolStripMenuItem.Enabled = true;
stopAVIToolStripMenuItem.Enabled = false;
}
else
{
recordAVIToolStripMenuItem.Enabled = false;
stopAVIToolStripMenuItem.Enabled = true;
}
}
}
}

View File

@ -2550,19 +2550,57 @@ namespace BizHawk.MultiClient
c.ShowDialog();
}
private void PauseStrip_Click(object sender, EventArgs e)
public void RecordAVI()
{
TogglePause();
var sfd = new SaveFileDialog();
if (!(Global.Emulator is NullEmulator))
{
sfd.FileName = Global.Game.FilesystemSafeName;
sfd.InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.AVIPath, "");
}
else
{
sfd.FileName = "NULL";
sfd.InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.AVIPath, "");
}
sfd.Filter = "AVI (*.avi)|*.avi|All Files|*.*";
Global.Sound.StopSound();
var result = sfd.ShowDialog();
Global.Sound.StartSound();
if (result == DialogResult.Cancel)
return;
//TODO - cores should be able to specify exact values for these instead of relying on this to calculate them
int fps = (int)(Global.Emulator.CoreOutputComm.VsyncRate * 0x01000000);
AviWriter aw = new AviWriter();
try
{
aw.SetMovieParameters(fps, 0x01000000);
aw.SetVideoParameters(Global.Emulator.VideoProvider.BufferWidth, Global.Emulator.VideoProvider.BufferHeight);
aw.SetAudioParameters(44100, 2, 16);
aw.OpenFile(sfd.FileName);
var token = aw.AcquireVideoCodecToken(Global.MainForm.Handle);
aw.SetVideoCodecToken(token);
aw.OpenStreams();
//commit the avi writing last, in case there were any errors earlier
CurrAviWriter = aw;
Global.RenderPanel.AddMessage("AVI capture started");
}
catch
{
Global.RenderPanel.AddMessage("AVI capture failed!");
aw.Dispose();
throw;
}
}
private void displaySubtitlesToolStripMenuItem_Click(object sender, EventArgs e)
public void StopAVI()
{
Global.Config.DisplaySubtitles ^= true;
CurrAviWriter.CloseFile();
CurrAviWriter = null;
Global.RenderPanel.AddMessage("AVI capture stopped");
}
}
}