remove Time from IMovie and instead implement the logic in PlatformFrameRates

This commit is contained in:
adelikat 2014-06-29 00:57:33 +00:00
parent 055e88fea3
commit 6fce0bcad6
5 changed files with 38 additions and 84 deletions

View File

@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
namespace BizHawk.Client.Common
{
@ -56,5 +57,37 @@ namespace BizHawk.Client.Common
return 60.0;
}
}
public TimeSpan MovieTime(IMovie movie)
{
var dblseconds = GetSeconds(movie);
var seconds = (int)(dblseconds % 60);
var days = seconds / 86400;
var hours = seconds / 3600;
var minutes = (seconds / 60) % 60;
var milliseconds = (int)((dblseconds - seconds) * 1000);
return new TimeSpan(days, hours, minutes, seconds, milliseconds);
}
private double Fps(IMovie movie)
{
var system = movie.HeaderEntries[HeaderKeys.PLATFORM];
var pal = movie.HeaderEntries.ContainsKey(HeaderKeys.PAL) &&
movie.HeaderEntries[HeaderKeys.PAL] == "1";
return this[system, pal];
}
private double GetSeconds(IMovie movie)
{
double frames = movie.InputLogLength;
if (frames < 1)
{
return 0;
}
return frames / Fps(movie);
}
}
}

View File

@ -60,32 +60,6 @@ namespace BizHawk.Client.Common
}
}
private double Fps
{
get
{
var system = Header[HeaderKeys.PLATFORM];
var pal = Header.ContainsKey(HeaderKeys.PAL) &&
Header[HeaderKeys.PAL] == "1";
return _frameRates[system, pal];
}
}
public TimeSpan Time
{
get
{
var dblseconds = GetSeconds(_log.Count);
var seconds = (int)(dblseconds % 60);
var days = seconds / 86400;
var hours = seconds / 3600;
var minutes = (seconds / 60) % 60;
var milliseconds = (int)((dblseconds - seconds) * 1000);
return new TimeSpan(days, hours, minutes, seconds, milliseconds);
}
}
public int InputLogLength
{
get { return _log.Count; }
@ -205,18 +179,6 @@ namespace BizHawk.Client.Common
#endregion
private double GetSeconds(int frameCount)
{
double frames = frameCount;
if (frames < 1)
{
return 0;
}
return frames / Fps;
}
private void SetFrameAt(int frameNum, string frame)
{
if (_log.Count > frameNum)

View File

@ -73,32 +73,6 @@ namespace BizHawk.Client.Common
get { return _changes; }
}
private double Fps
{
get
{
var system = Header[HeaderKeys.PLATFORM];
var pal = Header.ContainsKey(HeaderKeys.PAL) &&
Header[HeaderKeys.PAL] == "1";
return _frameRates[system, pal];
}
}
public TimeSpan Time
{
get
{
var dblseconds = GetSeconds(Loaded ? _log.Count : _preloadFramecount);
var seconds = (int)(dblseconds % 60);
var days = seconds / 86400;
var hours = seconds / 3600;
var minutes = (seconds / 60) % 60;
var milliseconds = (int)((dblseconds - seconds) * 1000);
return new TimeSpan(days, hours, minutes, seconds, milliseconds);
}
}
#endregion
#region Public Log Editing
@ -221,18 +195,6 @@ namespace BizHawk.Client.Common
#endregion
private double GetSeconds(int frameCount)
{
double frames = frameCount;
if (frames < 1)
{
return 0;
}
return frames / Fps;
}
private void SetFrameAt(int frameNum, string frame)
{
if (_log.Count > frameNum)

View File

@ -30,11 +30,6 @@ namespace BizHawk.Client.Common
/// </summary>
double FrameCount { get; }
/// <summary>
/// Gets the time calculation based on FrameCount and Fps
/// </summary>
TimeSpan Time { get; }
/// <summary>
/// Gets the actual length of the input log, should only be used by code that iterates or needs a real length
/// </summary>

View File

@ -14,6 +14,8 @@ namespace BizHawk.Client.EmuHawk
{
public partial class PlayMovie : Form
{
private readonly PlatformFrameRates PlatformFrameRates = new PlatformFrameRates();
private List<IMovie> _movieList = new List<IMovie>();
private bool _sortReverse;
private string _sortedCol;
@ -61,7 +63,7 @@ namespace BizHawk.Client.EmuHawk
if (column == 3) // Time
{
text = _movieList[index].Time.ToString(@"hh\:mm\:ss\.fff");
text = PlatformFrameRates.MovieTime(_movieList[index]).ToString(@"hh\:mm\:ss\.fff");
}
}
@ -319,7 +321,7 @@ namespace BizHawk.Client.EmuHawk
.Append(_movieList[index].Filename).Append('\t')
.Append(_movieList[index].SystemID).Append('\t')
.Append(_movieList[index].GameName).Append('\t')
.Append(_movieList[index].Time.ToString(@"hh\:mm\:ss\.fff"))
.Append(PlatformFrameRates.MovieTime(_movieList[index]).ToString(@"hh\:mm\:ss\.fff"))
.AppendLine();
Clipboard.SetDataObject(copyStr.ToString());