Add Subtitle Form - fix bug where Y wasn't being saved. SubtitleList - refactor to inherit List<Subtitle> and extend with the 2 useful methods it has beyond basic List functionality.
This commit is contained in:
parent
48ffc8b9fb
commit
d864929ad4
|
@ -324,7 +324,7 @@ namespace BizHawk.Client.Common
|
|||
|
||||
if (str.StartsWith("subtitle") || str.StartsWith("sub"))
|
||||
{
|
||||
Subtitles.AddSubtitle(str);
|
||||
Subtitles.AddFromString(str);
|
||||
}
|
||||
else if (str[0] == '|')
|
||||
{
|
||||
|
@ -867,7 +867,7 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
else if (str.StartsWith("subtitle") || str.StartsWith("sub"))
|
||||
{
|
||||
Subtitles.AddSubtitle(str);
|
||||
Subtitles.AddFromString(str);
|
||||
}
|
||||
else if (Header.AddHeaderFromLine(str))
|
||||
{
|
||||
|
|
|
@ -278,7 +278,7 @@ namespace BizHawk.Client.Common
|
|||
length = line.Substring(first + 1, second - first - 1);
|
||||
}
|
||||
string message = line.Substring(second + 1).Trim();
|
||||
m.Subtitles.AddSubtitle("subtitle " + frame + " 0 0 " + length + " FFFFFFFF " + message);
|
||||
m.Subtitles.AddFromString("subtitle " + frame + " 0 0 " + length + " FFFFFFFF " + message);
|
||||
}
|
||||
return m;
|
||||
}
|
||||
|
|
|
@ -8,54 +8,14 @@ using System.IO;
|
|||
|
||||
namespace BizHawk.Client.Common
|
||||
{
|
||||
public class SubtitleList : IEnumerable<Subtitle>
|
||||
public class SubtitleList : List<Subtitle>
|
||||
{
|
||||
private readonly List<Subtitle> _subtitles = new List<Subtitle>();
|
||||
|
||||
public SubtitleList() { }
|
||||
|
||||
public SubtitleList(IEnumerable<Subtitle> subtitles)
|
||||
{
|
||||
foreach (var subtitle in subtitles)
|
||||
{
|
||||
_subtitles.Add(new Subtitle(subtitle)); //TODO: Multiclient.EditSubtitlesForm needs a deep copy here, refactor it so that it doesn't
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerator<Subtitle> GetEnumerator()
|
||||
{
|
||||
return _subtitles.GetEnumerator();
|
||||
}
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator()
|
||||
{
|
||||
return GetEnumerator();
|
||||
}
|
||||
|
||||
public Subtitle this[int index]
|
||||
{
|
||||
get
|
||||
{
|
||||
return _subtitles[index];
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<Subtitle> GetSubtitles(int frame)
|
||||
{
|
||||
return _subtitles.Where(t => frame >= t.Frame && frame <= t.Frame + t.Duration);
|
||||
return this.Where(t => frame >= t.Frame && frame <= t.Frame + t.Duration);
|
||||
}
|
||||
|
||||
public int Count
|
||||
{
|
||||
get { return _subtitles.Count; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attempts to parse string for necessary subtitle information, required is a frame and a message, space delminated, the word subtitle assumed to be first
|
||||
/// </summary>
|
||||
/// <param name="subtitleStr"></param>
|
||||
/// <returns></returns>
|
||||
public bool AddSubtitle(string subtitleStr)
|
||||
public bool AddFromString(string subtitleStr)
|
||||
{
|
||||
if (!String.IsNullOrWhiteSpace(subtitleStr))
|
||||
{
|
||||
|
@ -70,7 +30,7 @@ namespace BizHawk.Client.Common
|
|||
message += subparts[i] + ' ';
|
||||
}
|
||||
|
||||
_subtitles.Add(new Subtitle()
|
||||
Add(new Subtitle()
|
||||
{
|
||||
Frame = int.Parse(subparts[1]),
|
||||
X = int.Parse(subparts[2]),
|
||||
|
@ -92,22 +52,5 @@ namespace BizHawk.Client.Common
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void AddSubtitle(Subtitle subtitle)
|
||||
{
|
||||
_subtitles.Add(subtitle);
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
_subtitles.Clear();
|
||||
}
|
||||
|
||||
public void RemoveAt(int index)
|
||||
{
|
||||
if (index >= _subtitles.Count) return;
|
||||
|
||||
_subtitles.RemoveAt(index);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1946,7 +1946,7 @@ namespace BizHawk.MultiClient
|
|||
Global.MovieSession.Movie.Subtitles.RemoveAt(index);
|
||||
}
|
||||
|
||||
Global.MovieSession.Movie.Subtitles.AddSubtitle(subForm.sub);
|
||||
Global.MovieSession.Movie.Subtitles.Add(subForm.sub);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -77,7 +77,7 @@ namespace BizHawk.MultiClient
|
|||
try { c = SubGrid.Rows[x].Cells[5]; }
|
||||
catch { ShowError(x, 5); return; }
|
||||
s.Message = c.Value.ToString();
|
||||
selectedMovie.Subtitles.AddSubtitle(s);
|
||||
selectedMovie.Subtitles.Add(s);
|
||||
}
|
||||
selectedMovie.WriteMovie();
|
||||
}
|
||||
|
@ -87,7 +87,8 @@ namespace BizHawk.MultiClient
|
|||
public void GetMovie(Movie m)
|
||||
{
|
||||
selectedMovie = m;
|
||||
SubtitleList subs = new SubtitleList(m.Subtitles);
|
||||
SubtitleList subs = new SubtitleList();
|
||||
subs.AddRange(m.Subtitles);
|
||||
|
||||
for (int x = 0; x < subs.Count; x++)
|
||||
{
|
||||
|
@ -152,7 +153,7 @@ namespace BizHawk.MultiClient
|
|||
c = SubGrid.Rows[index].Cells[5];
|
||||
try { s.Message = c.Value.ToString(); }
|
||||
catch { }
|
||||
selectedMovie.Subtitles.AddSubtitle(s);
|
||||
selectedMovie.Subtitles.Add(s);
|
||||
|
||||
return s;
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@ namespace BizHawk.MultiClient
|
|||
sub.Frame = (int)FrameNumeric.Value;
|
||||
sub.Message = Message.Text;
|
||||
sub.X = (int)XNumeric.Value;
|
||||
sub.Y = (int)YNumeric.Value;
|
||||
sub.Duration = (int)DurationNumeric.Value;
|
||||
sub.Color = (uint)colorDialog1.Color.ToArgb();
|
||||
DialogResult = DialogResult.OK;
|
||||
|
|
Loading…
Reference in New Issue