2011-06-26 14:36:41 +00:00
using System ;
using System.Collections.Generic ;
using System.Linq ;
using System.Text ;
using System.Drawing ;
namespace BizHawk.MultiClient
{
2011-06-26 16:39:48 +00:00
public class SubtitleList
2011-06-26 14:36:41 +00:00
{
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 + + )
{
2011-06-26 16:39:48 +00:00
if ( frame > = subs [ x ] . Frame & & frame < = subs [ x ] . Frame + subs [ x ] . Duration )
2011-06-26 14:36:41 +00:00
return subs [ x ] . Message ;
}
return "" ;
}
2011-06-26 16:39:48 +00:00
//TODO
2011-06-26 14:36:41 +00:00
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 ;
2011-06-26 16:39:48 +00:00
string str = subtitleStr . Substring ( x + 1 , subtitleStr . Length - x - 1 ) ;
string frame = str . Substring ( 0 , str . IndexOf ( ' ' ) ) ;
2011-06-26 14:36:41 +00:00
try
{
2011-06-26 16:39:48 +00:00
s . Frame = Int16 . Parse ( frame ) ;
2011-06-26 14:36:41 +00:00
}
catch
{
return false ;
}
2011-06-26 16:39:48 +00:00
//TODO: actually attempt to parse these things and supply with default values if they don't exist
s . X = 0 ;
s . Y = 0 ;
s . Duration = 120 ;
s . Message = str ;
s . Color = 0xFFFFFFFF ;
subs . Add ( s ) ;
2011-06-26 14:36:41 +00:00
return true ;
}
}
}