Checking in some movie class progress. Basic file saving done. Progress on file loading.
This commit is contained in:
parent
3173d3b16d
commit
a5dc7e90b3
|
@ -124,8 +124,11 @@ namespace BizHawk.MultiClient
|
|||
|
||||
private void playMovieToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
PlayMovie p = new PlayMovie();
|
||||
p.ShowDialog();
|
||||
//PlayMovie p = new PlayMovie();
|
||||
//p.ShowDialog();
|
||||
|
||||
//Hacky testing
|
||||
InputLog.WriteMovie();
|
||||
}
|
||||
|
||||
private void stopMovieToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
|
|
|
@ -19,7 +19,10 @@ namespace BizHawk.MultiClient
|
|||
private Control renderTarget;
|
||||
private RetainedViewportPanel retainedPanel;
|
||||
private string CurrentlyOpenRom;
|
||||
|
||||
|
||||
//TODO: adelikat: can this be the official file extension?
|
||||
Movie InputLog = new Movie("log.tas"); //This movie is always recording while user is playing
|
||||
|
||||
//the currently selected savestate slot
|
||||
private int SaveSlot = 0;
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
|
||||
namespace BizHawk.MultiClient
|
||||
{
|
||||
|
@ -10,19 +11,108 @@ namespace BizHawk.MultiClient
|
|||
private MovieHeader Header = new MovieHeader();
|
||||
private MovieLog Log = new MovieLog();
|
||||
|
||||
public Movie()
|
||||
{
|
||||
private bool IsText = true;
|
||||
private string Filename;
|
||||
|
||||
public Movie(string filename)
|
||||
{
|
||||
Filename = filename; //TODO: Validate that file is writable
|
||||
Log.AddFrame("|........|0|");
|
||||
}
|
||||
|
||||
public void AddMovieRecord()
|
||||
{
|
||||
|
||||
//TODO: validate input
|
||||
//Format into string acceptable by MovieLog
|
||||
}
|
||||
|
||||
public void WriteMovie()
|
||||
{
|
||||
if (IsText)
|
||||
WriteText();
|
||||
else
|
||||
WriteBinary();
|
||||
}
|
||||
|
||||
private void WriteText()
|
||||
{
|
||||
var file = new FileInfo(Filename);
|
||||
|
||||
int length = Log.GetMovieLength();
|
||||
string str = "";
|
||||
|
||||
using (StreamWriter sw = new StreamWriter(Filename))
|
||||
{
|
||||
foreach (KeyValuePair<string, string> kvp in Header.GetHeaderInfo())
|
||||
{
|
||||
str += kvp.Key + " " + kvp.Value + "\n";
|
||||
}
|
||||
|
||||
|
||||
for (int x = 0; x < length; x++)
|
||||
{
|
||||
str += Log.GetFrame(x) + "\n";
|
||||
}
|
||||
sw.WriteLine(str);
|
||||
}
|
||||
}
|
||||
|
||||
private void WriteBinary()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private bool LoadText()
|
||||
{
|
||||
var file = new FileInfo(Filename);
|
||||
using (StreamReader sr = file.OpenText())
|
||||
{
|
||||
string str = "";
|
||||
|
||||
while ((str = sr.ReadLine()) != null)
|
||||
{
|
||||
if (str.Contains(MovieHeader.EMULATIONVERSION))
|
||||
{
|
||||
|
||||
}
|
||||
else if (str.Contains(MovieHeader.MOVIEVERSION))
|
||||
{
|
||||
|
||||
}
|
||||
else if (str.Contains(MovieHeader.PLATFORM))
|
||||
{
|
||||
|
||||
}
|
||||
else if (str.Contains(MovieHeader.GAMENAME))
|
||||
{
|
||||
|
||||
}
|
||||
else if (str[0] == '|')
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
//Something has gone wrong here!
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
private bool LoadBinary()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool LoadMovie()
|
||||
{
|
||||
var file = new FileInfo(Filename);
|
||||
if (file.Exists == false) return false; //TODO: methods like writemovie will fail, some internal flag needs to prevent this
|
||||
//TODO: must determine if file is text or binary
|
||||
return LoadText();
|
||||
}
|
||||
|
||||
public int GetMovieLength()
|
||||
|
|
|
@ -16,12 +16,17 @@ namespace BizHawk.MultiClient
|
|||
|
||||
Dictionary<string, string> HeaderParams = new Dictionary<string, string>(); //Platform specific options go here
|
||||
|
||||
public const string EMULATIONVERSION = "EmulationVersion";
|
||||
public const string MOVIEVERSION = "MovieVersion";
|
||||
public const string PLATFORM = "Platform";
|
||||
public const string GAMENAME = "GameName";
|
||||
|
||||
public MovieHeader() //All required fields will be set to default values
|
||||
{
|
||||
HeaderParams.Add("EmulationVersion", "v1.0.0");
|
||||
HeaderParams.Add("MovieVersion", "v1.0.0");
|
||||
HeaderParams.Add("Platform", "");
|
||||
HeaderParams.Add("GameName", "");
|
||||
HeaderParams.Add(EMULATIONVERSION, "v1.0.0");
|
||||
HeaderParams.Add(MOVIEVERSION, "v1.0.0");
|
||||
HeaderParams.Add(PLATFORM, "");
|
||||
HeaderParams.Add(GAMENAME, "");
|
||||
}
|
||||
|
||||
public MovieHeader(string EmulatorVersion, string MovieVersion, string Platform, string GameName)
|
||||
|
|
|
@ -21,5 +21,18 @@ namespace BizHawk.MultiClient
|
|||
{
|
||||
return MovieRecords.Count;
|
||||
}
|
||||
|
||||
public void AddFrame(string frame)
|
||||
{
|
||||
MovieRecords.Add(frame); //Validate the format? Or shoudl the Movie class be resonible for formatting?
|
||||
}
|
||||
|
||||
public string GetFrame(int frameCount) //Frame count is 0 based here, should it be?
|
||||
{
|
||||
if (frameCount >= 0)
|
||||
return MovieRecords[frameCount];
|
||||
else
|
||||
return ""; //TODO: throw an exception?
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ namespace BizHawk.MultiClient
|
|||
{
|
||||
public partial class RamWatchNewWatch : Form
|
||||
{
|
||||
//TODO: better input validation - Like Ram Search
|
||||
public Watch watch = new Watch();
|
||||
public bool userSelected = false;
|
||||
public bool customSetup = false;
|
||||
|
|
Loading…
Reference in New Issue