Start movie subtitle system
This commit is contained in:
parent
70dc87a971
commit
61e82793e9
|
@ -155,6 +155,8 @@
|
||||||
<Compile Include="movie\MovieHeader.cs" />
|
<Compile Include="movie\MovieHeader.cs" />
|
||||||
<Compile Include="movie\MovieLog.cs" />
|
<Compile Include="movie\MovieLog.cs" />
|
||||||
<Compile Include="movie\MultitrackRecording.cs" />
|
<Compile Include="movie\MultitrackRecording.cs" />
|
||||||
|
<Compile Include="movie\Subtitle.cs" />
|
||||||
|
<Compile Include="movie\SubtitleList.cs" />
|
||||||
<Compile Include="MruStack.cs" />
|
<Compile Include="MruStack.cs" />
|
||||||
<Compile Include="NameStateForm.cs">
|
<Compile Include="NameStateForm.cs">
|
||||||
<SubType>Form</SubType>
|
<SubType>Form</SubType>
|
||||||
|
|
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Drawing;
|
||||||
|
|
||||||
namespace BizHawk.MultiClient
|
namespace BizHawk.MultiClient
|
||||||
{
|
{
|
||||||
|
@ -11,6 +12,7 @@ namespace BizHawk.MultiClient
|
||||||
{
|
{
|
||||||
private MovieHeader Header = new MovieHeader();
|
private MovieHeader Header = new MovieHeader();
|
||||||
private MovieLog Log = new MovieLog();
|
private MovieLog Log = new MovieLog();
|
||||||
|
private SubtitleList Subtitles = new SubtitleList();
|
||||||
|
|
||||||
private bool IsText = true;
|
private bool IsText = true;
|
||||||
private string Filename;
|
private string Filename;
|
||||||
|
@ -23,8 +25,15 @@ namespace BizHawk.MultiClient
|
||||||
public int lastLog;
|
public int lastLog;
|
||||||
public int rerecordCount;
|
public int rerecordCount;
|
||||||
|
|
||||||
//TODO:
|
public string GetSubtitle(int frame)
|
||||||
//Author field, needs to be passed in play dialog
|
{
|
||||||
|
return Subtitles.GetSubtitle(frame);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Point GetSutitlePoint(int frame)
|
||||||
|
{
|
||||||
|
return Subtitles.GetSubtitlePoint(frame);
|
||||||
|
}
|
||||||
|
|
||||||
public Movie(string filename, MOVIEMODE m)
|
public Movie(string filename, MOVIEMODE m)
|
||||||
{
|
{
|
||||||
|
@ -247,6 +256,10 @@ namespace BizHawk.MultiClient
|
||||||
str = ParseHeader(str, MovieHeader.AUTHOR);
|
str = ParseHeader(str, MovieHeader.AUTHOR);
|
||||||
Header.AddHeaderLine(MovieHeader.AUTHOR, str);
|
Header.AddHeaderLine(MovieHeader.AUTHOR, str);
|
||||||
}
|
}
|
||||||
|
else if (str.StartsWith("subtitle") || str.StartsWith("sub"))
|
||||||
|
{
|
||||||
|
Subtitles.AddSubtitle(str);
|
||||||
|
}
|
||||||
else if (str[0] == '|')
|
else if (str[0] == '|')
|
||||||
{
|
{
|
||||||
Log.AddFrame(str);
|
Log.AddFrame(str);
|
||||||
|
|
|
@ -0,0 +1,34 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace BizHawk.MultiClient
|
||||||
|
{
|
||||||
|
class Subtitle
|
||||||
|
{
|
||||||
|
public string Message;
|
||||||
|
public int Frame;
|
||||||
|
public int X;
|
||||||
|
public int Y;
|
||||||
|
public int Duration;
|
||||||
|
|
||||||
|
public Subtitle()
|
||||||
|
{
|
||||||
|
Message = "";
|
||||||
|
X = 0;
|
||||||
|
Y = 0;
|
||||||
|
Duration = 0;
|
||||||
|
Frame = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Subtitle(string message, int x, int y, int dur, int frame)
|
||||||
|
{
|
||||||
|
Message = message;
|
||||||
|
Frame = frame;
|
||||||
|
X = x;
|
||||||
|
Y = y;
|
||||||
|
Duration = dur;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,70 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Drawing;
|
||||||
|
|
||||||
|
namespace BizHawk.MultiClient
|
||||||
|
{
|
||||||
|
class SubtitleList
|
||||||
|
{
|
||||||
|
private List<Subtitle> subs = new List<Subtitle>();
|
||||||
|
|
||||||
|
public SubtitleList()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Manages the logic of what subtitle should be displayed on any given frame based on frame & duration
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="frame"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public string GetSubtitle(int frame)
|
||||||
|
{
|
||||||
|
if (subs.Count == 0) return "";
|
||||||
|
|
||||||
|
for (int x = 0; x < subs.Count; x++)
|
||||||
|
{
|
||||||
|
if (subs[x].Frame + subs[x].Duration >= frame)
|
||||||
|
return subs[x].Message;
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
public Point GetSubtitlePoint(int frame)
|
||||||
|
{
|
||||||
|
Point p = new Point(0, 0);
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <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)
|
||||||
|
{
|
||||||
|
if (subtitleStr.Length == 0) return false;
|
||||||
|
|
||||||
|
Subtitle s = new Subtitle();
|
||||||
|
|
||||||
|
int x = subtitleStr.IndexOf(' ');
|
||||||
|
if (x <= 0) return false;
|
||||||
|
|
||||||
|
string str = subtitleStr.Substring(x, subtitleStr.Length - x);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
s.Frame = Int16.Parse(str);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
x = str.IndexOf(' ');
|
||||||
|
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue