Refactor movie writing code. MovieHeader, MovieLog, and SubtitleList all have their own write methods now instead of the Movie object doing all of the work. Conceptually these 3 objects should be autonomous and the Movie object is simply an object that manages a collection of these objects.
This commit is contained in:
parent
10faa8a55f
commit
68d0ff94eb
|
@ -186,25 +186,9 @@ namespace BizHawk.MultiClient
|
|||
|
||||
using (StreamWriter sw = new StreamWriter(file))
|
||||
{
|
||||
foreach (KeyValuePair<string, string> kvp in Header.HeaderParams)
|
||||
{
|
||||
sw.WriteLine(kvp.Key + " " + kvp.Value);
|
||||
}
|
||||
|
||||
for (int x = 0; x < Header.Comments.Count; x++)
|
||||
{
|
||||
sw.WriteLine(Header.Comments[x]);
|
||||
}
|
||||
|
||||
for (int x = 0; x < Subtitles.Count(); x++)
|
||||
{
|
||||
sw.WriteLine(Subtitles.GetSubtitleText(x));
|
||||
}
|
||||
|
||||
for (int x = 0; x < length; x++)
|
||||
{
|
||||
sw.WriteLine(Log.GetFrame(x));
|
||||
}
|
||||
Header.WriteText(sw);
|
||||
Subtitles.WriteText(sw);
|
||||
Log.WriteText(sw);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
|
||||
namespace BizHawk.MultiClient
|
||||
{
|
||||
|
@ -93,5 +94,18 @@ namespace BizHawk.MultiClient
|
|||
{
|
||||
HeaderParams[key] = value;
|
||||
}
|
||||
|
||||
public void WriteText(StreamWriter sw)
|
||||
{
|
||||
foreach (KeyValuePair<string, string> kvp in HeaderParams)
|
||||
{
|
||||
sw.WriteLine(kvp.Key + " " + kvp.Value);
|
||||
}
|
||||
|
||||
for (int x = 0; x < Comments.Count; x++)
|
||||
{
|
||||
sw.WriteLine(Comments[x]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,72 +2,82 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
|
||||
namespace BizHawk.MultiClient
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the controller key presses of a movie
|
||||
/// </summary>
|
||||
public class MovieLog
|
||||
{
|
||||
//TODO: Insert(int frame) not useful for convenctional tasing but TAStudio will want it
|
||||
/// <summary>
|
||||
/// Represents the controller key presses of a movie
|
||||
/// </summary>
|
||||
public class MovieLog
|
||||
{
|
||||
//TODO: Insert(int frame) not useful for convenctional tasing but TAStudio will want it
|
||||
|
||||
List<string> MovieRecords = new List<string>();
|
||||
|
||||
public MovieLog()
|
||||
{
|
||||
//Should this class initialize with an empty string to MovieRecords so that first frame is index 1?
|
||||
//MovieRecords.Add("");
|
||||
}
|
||||
List<string> MovieRecords = new List<string>();
|
||||
|
||||
public int Length()
|
||||
{
|
||||
return MovieRecords.Count;
|
||||
}
|
||||
public MovieLog()
|
||||
{
|
||||
//Should this class initialize with an empty string to MovieRecords so that first frame is index 1?
|
||||
//MovieRecords.Add("");
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
MovieRecords.Clear();
|
||||
}
|
||||
public int Length()
|
||||
{
|
||||
return MovieRecords.Count;
|
||||
}
|
||||
|
||||
public int GetMovieLength()
|
||||
{
|
||||
return MovieRecords.Count;
|
||||
}
|
||||
public void Clear()
|
||||
{
|
||||
MovieRecords.Clear();
|
||||
}
|
||||
|
||||
public void AddFrame(string frame)
|
||||
{
|
||||
MovieRecords.Add(frame);
|
||||
}
|
||||
public int GetMovieLength()
|
||||
{
|
||||
return MovieRecords.Count;
|
||||
}
|
||||
|
||||
public void AddFrame(string frame)
|
||||
{
|
||||
MovieRecords.Add(frame);
|
||||
}
|
||||
public void SetFrameAt(int frameNum, string frame)
|
||||
{
|
||||
if (MovieRecords.Count > frameNum)
|
||||
MovieRecords[frameNum] = frame;
|
||||
else
|
||||
MovieRecords.Insert(frameNum, frame);
|
||||
}
|
||||
public void AddFrameAt(string frame, int frameNum)
|
||||
{
|
||||
MovieRecords.Insert(frameNum, frame);
|
||||
}
|
||||
{
|
||||
if (MovieRecords.Count > frameNum)
|
||||
MovieRecords[frameNum] = frame;
|
||||
else
|
||||
MovieRecords.Insert(frameNum, frame);
|
||||
}
|
||||
public void AddFrameAt(string frame, int frameNum)
|
||||
{
|
||||
MovieRecords.Insert(frameNum, frame);
|
||||
}
|
||||
|
||||
public void Truncate(int frame)
|
||||
{
|
||||
if (frame >= 0 && frame < Length())
|
||||
{ MovieRecords.RemoveRange(frame,Length() - frame); }
|
||||
}
|
||||
public void Truncate(int frame)
|
||||
{
|
||||
if (frame >= 0 && frame < Length())
|
||||
{ MovieRecords.RemoveRange(frame, Length() - frame); }
|
||||
}
|
||||
|
||||
public string GetFrame(int frameCount) //Frame count is 0 based here, should it be?
|
||||
{
|
||||
if (frameCount >= 0)
|
||||
{
|
||||
if (frameCount < MovieRecords.Count)
|
||||
return MovieRecords[frameCount];
|
||||
else
|
||||
return "";
|
||||
}
|
||||
else
|
||||
return ""; //TODO: throw an exception?
|
||||
}
|
||||
}
|
||||
public string GetFrame(int frameCount) //Frame count is 0 based here, should it be?
|
||||
{
|
||||
if (frameCount >= 0)
|
||||
{
|
||||
if (frameCount < MovieRecords.Count)
|
||||
return MovieRecords[frameCount];
|
||||
else
|
||||
return "";
|
||||
}
|
||||
else
|
||||
return ""; //TODO: throw an exception?
|
||||
}
|
||||
|
||||
public void WriteText(StreamWriter sw)
|
||||
{
|
||||
int length = GetMovieLength();
|
||||
for (int x = 0; x < length; x++)
|
||||
{
|
||||
sw.WriteLine(GetFrame(x));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
|||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
|
||||
namespace BizHawk.MultiClient
|
||||
{
|
||||
|
@ -202,5 +203,14 @@ namespace BizHawk.MultiClient
|
|||
|
||||
subs.RemoveAt(index);
|
||||
}
|
||||
|
||||
public void WriteText(StreamWriter sw)
|
||||
{
|
||||
int length = subs.Count;
|
||||
for (int x = 0; x < length; x++)
|
||||
{
|
||||
sw.WriteLine(GetSubtitleText(x));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue