Movie - movie SubtitleList object into the Header object
This commit is contained in:
parent
29a0fa49f8
commit
a8b355c7d2
|
@ -91,9 +91,9 @@ namespace BizHawk.Client.Common
|
|||
|
||||
string GetInput(int frame); // Should be a property of a Record object
|
||||
|
||||
MovieHeader Header { get; } // Don't expose this!!!
|
||||
MovieHeader Header { get; } // Expose IMovieHEader instead
|
||||
MovieLog LogDump { get; } // Don't expose this!!!
|
||||
SubtitleList Subtitles { get; } // Don't expose this!!!
|
||||
//SubtitleList Subtitles { get; } // Don't expose this!!!
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
|
|
@ -22,7 +22,6 @@ namespace BizHawk.Client.Common
|
|||
public Movie(bool startsFromSavestate = false)
|
||||
{
|
||||
Header = new MovieHeader();
|
||||
Subtitles = new SubtitleList();
|
||||
Filename = String.Empty;
|
||||
_preloadFramecount = 0;
|
||||
StartsFromSavestate = startsFromSavestate;
|
||||
|
@ -36,8 +35,7 @@ namespace BizHawk.Client.Common
|
|||
|
||||
#region Properties
|
||||
public MovieHeader Header { get; private set; }
|
||||
public SubtitleList Subtitles { get; private set; }
|
||||
|
||||
|
||||
public bool MakeBackup { get; set; }
|
||||
public string Filename { get; set; }
|
||||
public bool IsCountingRerecords { get; set; }
|
||||
|
@ -293,7 +291,7 @@ namespace BizHawk.Client.Common
|
|||
|
||||
if (str.StartsWith("subtitle") || str.StartsWith("sub"))
|
||||
{
|
||||
Subtitles.AddFromString(str);
|
||||
Header.Subtitles.AddFromString(str);
|
||||
}
|
||||
else if (str[0] == '|')
|
||||
{
|
||||
|
@ -751,20 +749,17 @@ namespace BizHawk.Client.Common
|
|||
|
||||
private void WriteText(Stream stream)
|
||||
{
|
||||
using (StreamWriter sw = new StreamWriter(stream))
|
||||
using (var sw = new StreamWriter(stream))
|
||||
{
|
||||
sw.Write(Header.ToString());
|
||||
|
||||
//TODO: clean this up
|
||||
// TODO: clean this up
|
||||
if (_loopOffset.HasValue)
|
||||
{
|
||||
sw.WriteLine("LoopOffset " + _loopOffset.ToString());
|
||||
}
|
||||
|
||||
foreach (var subtitle in Subtitles)
|
||||
{
|
||||
sw.WriteLine(subtitle.ToString());
|
||||
}
|
||||
sw.Write(Header.Subtitles.ToString());
|
||||
|
||||
for (int i = 0; i < _log.Length; i++)
|
||||
{
|
||||
|
@ -836,7 +831,7 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
else if (str.StartsWith("subtitle") || str.StartsWith("sub"))
|
||||
{
|
||||
Subtitles.AddFromString(str);
|
||||
Header.Subtitles.AddFromString(str);
|
||||
}
|
||||
else if (Header.AddHeaderFromLine(str))
|
||||
{
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
|
@ -18,6 +19,10 @@ namespace BizHawk.Client.Common
|
|||
|
||||
public Dictionary<string, string> BoardProperties = new Dictionary<string, string>();
|
||||
|
||||
public SubtitleList Subtitles { get; private set; }
|
||||
|
||||
#region Header Constants
|
||||
|
||||
public const string EMULATIONVERSION = "emuVersion";
|
||||
public const string MOVIEVERSION = "MovieVersion";
|
||||
public const string PLATFORM = "Platform";
|
||||
|
@ -46,21 +51,23 @@ namespace BizHawk.Client.Common
|
|||
//Board properties
|
||||
public const string BOARDPROPERTIES = "BoardProperty";
|
||||
|
||||
#endregion
|
||||
|
||||
public static string MovieVersion = "BizHawk v0.0.1";
|
||||
|
||||
public static string MakeGUID()
|
||||
{
|
||||
return System.Guid.NewGuid().ToString();
|
||||
return Guid.NewGuid().ToString();
|
||||
}
|
||||
|
||||
public MovieHeader() //All required fields will be set to default values
|
||||
{
|
||||
|
||||
Subtitles = new SubtitleList();
|
||||
HeaderParams.Add(EMULATIONVERSION, VersionInfo.GetEmuVersion());
|
||||
HeaderParams.Add(MOVIEVERSION, MovieVersion);
|
||||
HeaderParams.Add(PLATFORM, "");
|
||||
HeaderParams.Add(GAMENAME, "");
|
||||
HeaderParams.Add(AUTHOR, "");
|
||||
HeaderParams.Add(PLATFORM, String.Empty);
|
||||
HeaderParams.Add(GAMENAME, String.Empty);
|
||||
HeaderParams.Add(AUTHOR, String.Empty);
|
||||
HeaderParams.Add(RERECORDS, "0");
|
||||
HeaderParams.Add(GUID, MakeGUID());
|
||||
}
|
||||
|
|
|
@ -279,7 +279,7 @@ namespace BizHawk.Client.Common
|
|||
length = line.Substring(first + 1, second - first - 1);
|
||||
}
|
||||
string message = line.Substring(second + 1).Trim();
|
||||
m.Subtitles.AddFromString("subtitle " + frame + " 0 0 " + length + " FFFFFFFF " + message);
|
||||
m.Header.Subtitles.AddFromString("subtitle " + frame + " 0 0 " + length + " FFFFFFFF " + message);
|
||||
}
|
||||
return m;
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace BizHawk.Client.Common
|
||||
{
|
||||
|
@ -12,6 +13,13 @@ namespace BizHawk.Client.Common
|
|||
return this.Where(t => frame >= t.Frame && frame <= t.Frame + t.Duration);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
ForEach(subtitle => sb.AppendLine(subtitle.ToString()));
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
public bool AddFromString(string subtitleStr)
|
||||
{
|
||||
if (!String.IsNullOrWhiteSpace(subtitleStr))
|
||||
|
|
|
@ -628,7 +628,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
if (Global.MovieSession.Movie.IsActive && Global.Config.DisplaySubtitles)
|
||||
{
|
||||
var subList = Global.MovieSession.Movie.Subtitles.GetSubtitles(Global.Emulator.Frame).ToList();
|
||||
var subList = Global.MovieSession.Movie.Header.Subtitles.GetSubtitles(Global.Emulator.Frame).ToList();
|
||||
|
||||
for (int i = 0; i < subList.Count; i++)
|
||||
{
|
||||
|
|
|
@ -1850,14 +1850,15 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private void AddSubtitleContextMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
//TODO: rethink this?
|
||||
var subForm = new SubtitleMaker();
|
||||
subForm.DisableFrame();
|
||||
|
||||
int index = -1;
|
||||
var sub = new Subtitle();
|
||||
for (int x = 0; x < Global.MovieSession.Movie.Subtitles.Count; x++)
|
||||
for (int x = 0; x < Global.MovieSession.Movie.Header.Subtitles.Count; x++)
|
||||
{
|
||||
sub = Global.MovieSession.Movie.Subtitles[x];
|
||||
sub = Global.MovieSession.Movie.Header.Subtitles[x];
|
||||
if (Global.Emulator.Frame == sub.Frame)
|
||||
{
|
||||
index = x;
|
||||
|
@ -1876,10 +1877,10 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
if (index >= 0)
|
||||
{
|
||||
Global.MovieSession.Movie.Subtitles.RemoveAt(index);
|
||||
Global.MovieSession.Movie.Header.Subtitles.RemoveAt(index);
|
||||
}
|
||||
|
||||
Global.MovieSession.Movie.Subtitles.Add(subForm.Sub);
|
||||
Global.MovieSession.Movie.Header.Subtitles.Add(subForm.Sub);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -51,30 +51,30 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
if (!ReadOnly)
|
||||
{
|
||||
_selectedMovie.Subtitles.Clear();
|
||||
for (int x = 0; x < SubGrid.Rows.Count - 1; x++)
|
||||
_selectedMovie.Header.Subtitles.Clear();
|
||||
for (int i = 0; i < SubGrid.Rows.Count - 1; i++)
|
||||
{
|
||||
var s = new Subtitle();
|
||||
|
||||
var c = SubGrid.Rows[x].Cells[0];
|
||||
var c = SubGrid.Rows[i].Cells[0];
|
||||
try { s.Frame = int.Parse(c.Value.ToString()); }
|
||||
catch { ShowError(x, 0); return; }
|
||||
c = SubGrid.Rows[x].Cells[1];
|
||||
catch { ShowError(i, 0); return; }
|
||||
c = SubGrid.Rows[i].Cells[1];
|
||||
try { s.X = int.Parse(c.Value.ToString()); }
|
||||
catch { ShowError(x, 1); return; }
|
||||
c = SubGrid.Rows[x].Cells[2];
|
||||
catch { ShowError(i, 1); return; }
|
||||
c = SubGrid.Rows[i].Cells[2];
|
||||
try { s.Y = int.Parse(c.Value.ToString()); }
|
||||
catch { ShowError(x, 2); return; }
|
||||
c = SubGrid.Rows[x].Cells[3];
|
||||
catch { ShowError(i, 2); return; }
|
||||
c = SubGrid.Rows[i].Cells[3];
|
||||
try { s.Duration = int.Parse(c.Value.ToString()); }
|
||||
catch { ShowError(x, 3); return; }
|
||||
c = SubGrid.Rows[x].Cells[4];
|
||||
catch { ShowError(i, 3); return; }
|
||||
c = SubGrid.Rows[i].Cells[4];
|
||||
try { s.Color = uint.Parse(c.Value.ToString(), NumberStyles.HexNumber); }
|
||||
catch { ShowError(x, 4); return; }
|
||||
try { c = SubGrid.Rows[x].Cells[5]; }
|
||||
catch { ShowError(x, 5); return; }
|
||||
catch { ShowError(i, 4); return; }
|
||||
try { c = SubGrid.Rows[i].Cells[5]; }
|
||||
catch { ShowError(i, 5); return; }
|
||||
s.Message = c.Value.ToString();
|
||||
_selectedMovie.Subtitles.Add(s);
|
||||
_selectedMovie.Header.Subtitles.Add(s);
|
||||
}
|
||||
_selectedMovie.Save();
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
_selectedMovie = m;
|
||||
var subs = new SubtitleList();
|
||||
subs.AddRange(m.Subtitles);
|
||||
subs.AddRange(m.Header.Subtitles);
|
||||
|
||||
for (int x = 0; x < subs.Count; x++)
|
||||
{
|
||||
|
@ -150,7 +150,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
c = SubGrid.Rows[index].Cells[5];
|
||||
try { s.Message = c.Value.ToString(); }
|
||||
catch { }
|
||||
_selectedMovie.Subtitles.Add(s);
|
||||
_selectedMovie.Header.Subtitles.Add(s);
|
||||
|
||||
return s;
|
||||
}
|
||||
|
|
|
@ -382,7 +382,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
DetailsView.Items.Add(FramesItem);
|
||||
|
||||
CommentsBtn.Enabled = _movieList[firstIndex].Header.Comments.Any();
|
||||
SubtitlesBtn.Enabled = _movieList[firstIndex].Subtitles.Any();
|
||||
SubtitlesBtn.Enabled = _movieList[firstIndex].Header.Subtitles.Any();
|
||||
}
|
||||
|
||||
private void button1_Click(object sender, EventArgs e)
|
||||
|
|
Loading…
Reference in New Issue