From 505a8baab48b9e00d5ebd7a0821896232aba6a71 Mon Sep 17 00:00:00 2001 From: "andres.delikat" Date: Mon, 4 Jul 2011 18:04:56 +0000 Subject: [PATCH] Subtitles - finish parsing all parameters, make render panel use all parameters but color (for now) --- BizHawk.MultiClient/RenderPanel.cs | 10 +++--- BizHawk.MultiClient/movie/SubtitleList.cs | 43 +++++++++++++++++++++-- 2 files changed, 45 insertions(+), 8 deletions(-) diff --git a/BizHawk.MultiClient/RenderPanel.cs b/BizHawk.MultiClient/RenderPanel.cs index 870c1b29a1..1733764e4d 100644 --- a/BizHawk.MultiClient/RenderPanel.cs +++ b/BizHawk.MultiClient/RenderPanel.cs @@ -419,11 +419,11 @@ namespace BizHawk.MultiClient } //TODO: read subtitle positioning, implement multiple subtitles at once feature - MessageFont.DrawString(null, Global.MainForm.UserMovie.Subtitles.GetSubtitle(Global.Emulator.Frame), 0 + 1, - 0 + 1, new Color4(Color.Black)); - MessageFont.DrawString(null, Global.MainForm.UserMovie.Subtitles.GetSubtitle(Global.Emulator.Frame), 0 , - 0, new Color4(Color.White)); - + Subtitle s = new Subtitle(Global.MainForm.UserMovie.Subtitles.GetSubtitle(Global.Emulator.Frame)); + MessageFont.DrawString(null, s.Message, s.X + 1, + s.Y + 1, new Color4(Color.Black)); + MessageFont.DrawString(null, s.Message, s.X, + s.Y, new Color4(Color.White));//Color.FromArgb((int)s.Color)); } private string MakeFrameCounter() diff --git a/BizHawk.MultiClient/movie/SubtitleList.cs b/BizHawk.MultiClient/movie/SubtitleList.cs index 4c47a7c4ed..451a13c116 100644 --- a/BizHawk.MultiClient/movie/SubtitleList.cs +++ b/BizHawk.MultiClient/movie/SubtitleList.cs @@ -57,7 +57,7 @@ namespace BizHawk.MultiClient /// /// /// - public string GetSubtitle(int frame) + public string GetSubtitleMessage(int frame) { if (subs.Count == 0) return ""; @@ -69,6 +69,18 @@ namespace BizHawk.MultiClient return ""; } + public Subtitle GetSubtitle(int frame) + { + if (subs.Count == 0) return new Subtitle(); + + for (int x = 0; x < subs.Count; x++) + { + if (frame >= subs[x].Frame && frame <= subs[x].Frame + subs[x].Duration) + return subs[x]; + } + return new Subtitle(); + } + public int Count() { return subs.Count; @@ -141,9 +153,34 @@ namespace BizHawk.MultiClient return false; } - s.Duration = 120; + x = str.IndexOf(' '); + if (x <= 0) return false; + string Duration = str.Substring(0, x); + str = str.Substring(x + 1, str.Length - x - 1); + try + { + s.Duration = int.Parse(Duration); + } + catch + { + return false; + } + + //TODO: parse hex! + x = str.IndexOf(' '); + if (x <= 0) return false; + string Color = str.Substring(0, x); + str = str.Substring(x + 1, str.Length - x - 1); + try + { + s.Color = uint.Parse(Color); + } + catch + { + return false; + } + s.Message = str; - s.Color = 0xFFFFFFFF; subs.Add(s); return true;