Some code cleanup on Mainform, also moved all the mainform movie functions to their own file

This commit is contained in:
andres.delikat 2011-07-22 01:14:13 +00:00
parent bc2293a482
commit f4d02ff49e
4 changed files with 103 additions and 89 deletions

View File

@ -146,6 +146,9 @@
<Compile Include="LogWindow.Designer.cs"> <Compile Include="LogWindow.Designer.cs">
<DependentUpon>LogWindow.cs</DependentUpon> <DependentUpon>LogWindow.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="MainForm.Movie.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="movie\EditCommentsForm.cs"> <Compile Include="movie\EditCommentsForm.cs">
<SubType>Form</SubType> <SubType>Form</SubType>
</Compile> </Compile>

View File

@ -0,0 +1,97 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.IO;
using System.Windows.Forms;
namespace BizHawk.MultiClient
{
partial class MainForm
{
public bool ReadOnly = true; //Global Movie Read only setting
public Movie UserMovie = new Movie();
public void StartNewMovie(Movie m, bool record)
{
UserMovie = m;
LoadRom(Global.MainForm.CurrentlyOpenRom);
UserMovie.LoadMovie();
Global.Config.RecentMovies.Add(m.Filename);
if (record)
{
UserMovie.StartNewRecording();
ReadOnly = false;
}
else
{
UserMovie.StartPlayback();
}
SetMainformMovieInfo();
}
public void SetMainformMovieInfo()
{
if (UserMovie.Mode == MOVIEMODE.PLAY || UserMovie.Mode == MOVIEMODE.FINISHED)
{
Text = DisplayNameForSystem(Global.Game.System) + " - " + Global.Game.Name + " - " + Path.GetFileName(UserMovie.Filename);
PlayRecordStatus.Image = BizHawk.MultiClient.Properties.Resources.Play;
PlayRecordStatus.ToolTipText = "Movie is in playback mode";
}
else if (UserMovie.Mode == MOVIEMODE.RECORD)
{
Text = DisplayNameForSystem(Global.Game.System) + " - " + Global.Game.Name + " - " + Path.GetFileName(UserMovie.Filename);
PlayRecordStatus.Image = BizHawk.MultiClient.Properties.Resources.RecordHS;
PlayRecordStatus.ToolTipText = "Movie is in record mode";
}
else
{
Text = DisplayNameForSystem(Global.Game.System) + " - " + Global.Game.Name;
PlayRecordStatus.Image = BizHawk.MultiClient.Properties.Resources.Blank;
PlayRecordStatus.ToolTipText = "";
}
}
/*TODO: remove this or make usermovie private*/
public Movie GetActiveMovie()
{
if (UserMovie.Mode != MOVIEMODE.INACTIVE)
return UserMovie;
else
return null;
}
public bool MovieActive()
{
if (UserMovie.Mode != MOVIEMODE.INACTIVE)
return true;
else
return false;
}
private void PlayMovie()
{
PlayMovie p = new PlayMovie();
DialogResult d = p.ShowDialog();
}
private void RecordMovie()
{
RecordMovie r = new RecordMovie();
r.ShowDialog();
}
public void PlayMovieFromBeginning()
{
if (UserMovie.Mode != MOVIEMODE.INACTIVE)
{
LoadRom(CurrentlyOpenRom);
UserMovie.StartPlayback();
SetMainformMovieInfo();
}
}
}
}

View File

@ -22,15 +22,11 @@ namespace BizHawk.MultiClient
private RetainedViewportPanel retainedPanel; private RetainedViewportPanel retainedPanel;
public string CurrentlyOpenRom; public string CurrentlyOpenRom;
SavestateManager StateSlots = new SavestateManager(); SavestateManager StateSlots = new SavestateManager();
//Movie variables
public Movie UserMovie = new Movie();
public bool PressFrameAdvance = false; public bool PressFrameAdvance = false;
public bool PressRewind = false; public bool PressRewind = false;
public bool ReadOnly = true; //Global Movie Read only setting
//avi/wav state //avi/wav state
AviWriter CurrAviWriter = null; AviWriter CurrAviWriter = null;
@ -77,8 +73,7 @@ namespace BizHawk.MultiClient
displayLogWindowToolStripMenuItem.Checked = true; displayLogWindowToolStripMenuItem.Checked = true;
} }
UpdateStatusSlots();
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 //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 //we could background thread this later instead if we wanted to be real clever
NES.BootGodDB.GetDatabaseBytes = () => NES.BootGodDB.GetDatabaseBytes = () =>
@ -2309,87 +2304,6 @@ namespace BizHawk.MultiClient
ToggleReadOnly(); ToggleReadOnly();
} }
public void SetMainformMovieInfo()
{
if (UserMovie.Mode == MOVIEMODE.PLAY || UserMovie.Mode == MOVIEMODE.FINISHED)
{
Text = DisplayNameForSystem(Global.Game.System) + " - " + Global.Game.Name + " - " + Path.GetFileName(UserMovie.Filename);
PlayRecordStatus.Image = BizHawk.MultiClient.Properties.Resources.Play;
PlayRecordStatus.ToolTipText = "Movie is in playback mode";
}
else if (UserMovie.Mode == MOVIEMODE.RECORD)
{
Text = DisplayNameForSystem(Global.Game.System) + " - " + Global.Game.Name + " - " + Path.GetFileName(UserMovie.Filename);
PlayRecordStatus.Image = BizHawk.MultiClient.Properties.Resources.RecordHS;
PlayRecordStatus.ToolTipText = "Movie is in record mode";
}
else
{
Text = DisplayNameForSystem(Global.Game.System) + " - " + Global.Game.Name;
PlayRecordStatus.Image = BizHawk.MultiClient.Properties.Resources.Blank;
PlayRecordStatus.ToolTipText = "";
}
}
public void StartNewMovie(Movie m, bool record)
{
UserMovie = m;
LoadRom(Global.MainForm.CurrentlyOpenRom);
UserMovie.LoadMovie();
Global.Config.RecentMovies.Add(m.Filename);
if (record)
{
UserMovie.StartNewRecording();
ReadOnly = false;
}
else
{
UserMovie.StartPlayback();
}
SetMainformMovieInfo();
}
/*TODO: remove this or make usermovie private*/
public Movie GetActiveMovie()
{
if (UserMovie.Mode != MOVIEMODE.INACTIVE)
return UserMovie;
else
return null;
}
public bool MovieActive()
{
if (UserMovie.Mode != MOVIEMODE.INACTIVE)
return true;
else
return false;
}
private void PlayMovie()
{
PlayMovie p = new PlayMovie();
DialogResult d = p.ShowDialog();
}
private void RecordMovie()
{
RecordMovie r = new RecordMovie();
r.ShowDialog();
}
public void PlayMovieFromBeginning()
{
if (UserMovie.Mode != MOVIEMODE.INACTIVE)
{
LoadRom(CurrentlyOpenRom);
UserMovie.StartPlayback();
SetMainformMovieInfo();
}
}
public void LoadRamWatch() public void LoadRamWatch()
{ {
if (!RamWatch1.IsHandleCreated || RamWatch1.IsDisposed) if (!RamWatch1.IsHandleCreated || RamWatch1.IsDisposed)

View File

@ -495,7 +495,7 @@ namespace BizHawk.MultiClient
if (Global.MainForm.UserMovie.Mode != MOVIEMODE.INACTIVE) if (Global.MainForm.UserMovie.Mode != MOVIEMODE.INACTIVE)
{ {
tmp += "Rerecord Count: "; tmp += "Rerecord Count: ";
tmp += Global.MainForm.GetActiveMovie().Rerecords.ToString(); tmp += Global.MainForm.UserMovie.Rerecords.ToString();
} }
return tmp; return tmp;
} }