cleanup movie forms
This commit is contained in:
parent
5fa5674260
commit
1239149af5
|
@ -7,15 +7,8 @@ namespace BizHawk.Client.EmuHawk
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class MovieDetails
|
public class MovieDetails
|
||||||
{
|
{
|
||||||
public string Keys { get; set; }
|
public string Keys { get; set; } = "";
|
||||||
public string Values { get; set; }
|
public string Values { get; set; } = "";
|
||||||
public Color BackgroundColor { get; set; }
|
public Color BackgroundColor { get; set; } = Color.White;
|
||||||
|
|
||||||
public MovieDetails()
|
|
||||||
{
|
|
||||||
Keys = "";
|
|
||||||
Values = "";
|
|
||||||
BackgroundColor = Color.White;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
{
|
{
|
||||||
public partial class PlayMovie : Form
|
public partial class PlayMovie : Form
|
||||||
{
|
{
|
||||||
private readonly PlatformFrameRates PlatformFrameRates = new PlatformFrameRates();
|
private readonly PlatformFrameRates _platformFrameRates = new PlatformFrameRates();
|
||||||
|
|
||||||
private List<IMovie> _movieList = new List<IMovie>();
|
private List<IMovie> _movieList = new List<IMovie>();
|
||||||
private bool _sortReverse;
|
private bool _sortReverse;
|
||||||
|
@ -51,7 +51,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
e.Item = new ListViewItem(entry.Filename);
|
e.Item = new ListViewItem(entry.Filename);
|
||||||
e.Item.SubItems.Add(entry.SystemID);
|
e.Item.SubItems.Add(entry.SystemID);
|
||||||
e.Item.SubItems.Add(entry.GameName);
|
e.Item.SubItems.Add(entry.GameName);
|
||||||
e.Item.SubItems.Add(PlatformFrameRates.MovieTime(entry).ToString(@"hh\:mm\:ss\.fff"));
|
e.Item.SubItems.Add(_platformFrameRates.MovieTime(entry).ToString(@"hh\:mm\:ss\.fff"));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Run()
|
private void Run()
|
||||||
|
@ -65,38 +65,36 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
private int? AddMovieToList(string filename, bool force)
|
private int? AddMovieToList(string filename, bool force)
|
||||||
{
|
{
|
||||||
using (var file = new HawkFile(filename))
|
using var file = new HawkFile(filename);
|
||||||
|
if (!file.Exists)
|
||||||
{
|
{
|
||||||
if (!file.Exists)
|
return null;
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
var movie = PreLoadMovieFile(file, force);
|
|
||||||
if (movie == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
int? index;
|
|
||||||
lock (_movieList)
|
|
||||||
{
|
|
||||||
// need to check IsDuplicateOf within the lock
|
|
||||||
index = IsDuplicateOf(filename);
|
|
||||||
if (index.HasValue)
|
|
||||||
{
|
|
||||||
return index;
|
|
||||||
}
|
|
||||||
|
|
||||||
_movieList.Add(movie);
|
|
||||||
index = _movieList.Count - 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
_sortReverse = false;
|
|
||||||
_sortedCol = "";
|
|
||||||
|
|
||||||
return index;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var movie = PreLoadMovieFile(file, force);
|
||||||
|
if (movie == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
int? index;
|
||||||
|
lock (_movieList)
|
||||||
|
{
|
||||||
|
// need to check IsDuplicateOf within the lock
|
||||||
|
index = IsDuplicateOf(filename);
|
||||||
|
if (index.HasValue)
|
||||||
|
{
|
||||||
|
return index;
|
||||||
|
}
|
||||||
|
|
||||||
|
_movieList.Add(movie);
|
||||||
|
index = _movieList.Count - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
_sortReverse = false;
|
||||||
|
_sortedCol = "";
|
||||||
|
|
||||||
|
return index;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int? IsDuplicateOf(string filename)
|
private int? IsDuplicateOf(string filename)
|
||||||
|
@ -177,7 +175,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
{
|
{
|
||||||
foreach (var ext in MovieService.MovieExtensions)
|
foreach (var ext in MovieService.MovieExtensions)
|
||||||
{
|
{
|
||||||
if (Path.GetExtension(_movieList[indices[i]].Filename).ToUpper() == $".{ext}")
|
if (Path.GetExtension(_movieList[indices[i]].Filename)?.ToUpper() == $".{ext}")
|
||||||
{
|
{
|
||||||
tas.Add(i);
|
tas.Add(i);
|
||||||
}
|
}
|
||||||
|
@ -233,7 +231,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
var dpTodo = new Queue<string>();
|
var dpTodo = new Queue<string>();
|
||||||
var fpTodo = new List<string>();
|
var fpTodo = new List<string>();
|
||||||
dpTodo.Enqueue(directory);
|
dpTodo.Enqueue(directory);
|
||||||
Dictionary<string, int> ordinals = new Dictionary<string, int>();
|
var ordinals = new Dictionary<string, int>();
|
||||||
|
|
||||||
while (dpTodo.Count > 0)
|
while (dpTodo.Count > 0)
|
||||||
{
|
{
|
||||||
|
@ -242,9 +240,9 @@ namespace BizHawk.Client.EmuHawk
|
||||||
// enqueue subdirectories if appropriate
|
// enqueue subdirectories if appropriate
|
||||||
if (Global.Config.PlayMovie_IncludeSubdir)
|
if (Global.Config.PlayMovie_IncludeSubdir)
|
||||||
{
|
{
|
||||||
foreach (var subdir in Directory.GetDirectories(dp))
|
foreach (var subDir in Directory.GetDirectories(dp))
|
||||||
{
|
{
|
||||||
dpTodo.Enqueue(subdir);
|
dpTodo.Enqueue(subDir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -290,7 +288,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
{
|
{
|
||||||
var filePaths = (string[])e.Data.GetData(DataFormats.FileDrop);
|
var filePaths = (string[])e.Data.GetData(DataFormats.FileDrop);
|
||||||
|
|
||||||
foreach (var path in filePaths.Where(path => MovieService.MovieExtensions.Contains(Path.GetExtension(path).Replace(".", ""))))
|
foreach (var path in filePaths.Where(path => MovieService.MovieExtensions.Contains(Path.GetExtension(path)?.Replace(".", ""))))
|
||||||
{
|
{
|
||||||
AddMovieToList(path, force: true);
|
AddMovieToList(path, force: true);
|
||||||
}
|
}
|
||||||
|
@ -312,9 +310,10 @@ namespace BizHawk.Client.EmuHawk
|
||||||
.Append(_movieList[index].Filename).Append('\t')
|
.Append(_movieList[index].Filename).Append('\t')
|
||||||
.Append(_movieList[index].SystemID).Append('\t')
|
.Append(_movieList[index].SystemID).Append('\t')
|
||||||
.Append(_movieList[index].GameName).Append('\t')
|
.Append(_movieList[index].GameName).Append('\t')
|
||||||
.Append(PlatformFrameRates.MovieTime(_movieList[index]).ToString(@"hh\:mm\:ss\.fff"))
|
.Append(_platformFrameRates.MovieTime(_movieList[index]).ToString(@"hh\:mm\:ss\.fff"))
|
||||||
.AppendLine();
|
.AppendLine();
|
||||||
}
|
}
|
||||||
|
|
||||||
Clipboard.SetDataObject(copyStr.ToString());
|
Clipboard.SetDataObject(copyStr.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -394,8 +393,6 @@ namespace BizHawk.Client.EmuHawk
|
||||||
var item = new ListViewItem(kvp.Key);
|
var item = new ListViewItem(kvp.Key);
|
||||||
item.SubItems.Add(kvp.Value);
|
item.SubItems.Add(kvp.Value);
|
||||||
|
|
||||||
bool add = true;
|
|
||||||
|
|
||||||
switch (kvp.Key)
|
switch (kvp.Key)
|
||||||
{
|
{
|
||||||
case HeaderKeys.SHA1:
|
case HeaderKeys.SHA1:
|
||||||
|
@ -417,7 +414,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
// the problem is that for GameGear and SG100, those mismatch, resulting in false positive here
|
// the problem is that for GameGear and SG100, those mismatch, resulting in false positive here
|
||||||
// I have a patch to make GG and SG appear as platforms in movie header (issue #1246)
|
// I have a patch to make GG and SG appear as platforms in movie header (issue #1246)
|
||||||
// but even with it, for all the old movies, this false positive would have to be worked around anyway
|
// but even with it, for all the old movies, this false positive would have to be worked around anyway
|
||||||
// TODO: actually check header flags like "IsGGMode" and "IsSegaCDMode" (those are never parsed by bizhawk)
|
// TODO: actually check header flags like "IsGGMode" and "IsSegaCDMode" (those are never parsed by BizHawk)
|
||||||
if (kvp.Value != Global.Emulator.SystemId)
|
if (kvp.Value != Global.Emulator.SystemId)
|
||||||
{
|
{
|
||||||
item.BackColor = Color.Pink;
|
item.BackColor = Color.Pink;
|
||||||
|
@ -425,17 +422,16 @@ namespace BizHawk.Client.EmuHawk
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(add)
|
DetailsView.Items.Add(item);
|
||||||
DetailsView.Items.Add(item);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var FpsItem = new ListViewItem("Fps");
|
var fpsItem = new ListViewItem("Fps");
|
||||||
FpsItem.SubItems.Add($"{Fps(_movieList[firstIndex]):0.#######}");
|
fpsItem.SubItems.Add($"{Fps(_movieList[firstIndex]):0.#######}");
|
||||||
DetailsView.Items.Add(FpsItem);
|
DetailsView.Items.Add(fpsItem);
|
||||||
|
|
||||||
var FramesItem = new ListViewItem("Frames");
|
var framesItem = new ListViewItem("Frames");
|
||||||
FramesItem.SubItems.Add(_movieList[firstIndex].FrameCount.ToString());
|
framesItem.SubItems.Add(_movieList[firstIndex].FrameCount.ToString());
|
||||||
DetailsView.Items.Add(FramesItem);
|
DetailsView.Items.Add(framesItem);
|
||||||
CommentsBtn.Enabled = _movieList[firstIndex].Comments.Any();
|
CommentsBtn.Enabled = _movieList[firstIndex].Comments.Any();
|
||||||
SubtitlesBtn.Enabled = _movieList[firstIndex].Subtitles.Any();
|
SubtitlesBtn.Enabled = _movieList[firstIndex].Subtitles.Any();
|
||||||
}
|
}
|
||||||
|
@ -443,8 +439,8 @@ namespace BizHawk.Client.EmuHawk
|
||||||
public double Fps(IMovie movie)
|
public double Fps(IMovie movie)
|
||||||
{
|
{
|
||||||
var system = movie.HeaderEntries[HeaderKeys.PLATFORM];
|
var system = movie.HeaderEntries[HeaderKeys.PLATFORM];
|
||||||
var pal = movie.HeaderEntries.ContainsKey(HeaderKeys.PAL) &&
|
var pal = movie.HeaderEntries.ContainsKey(HeaderKeys.PAL)
|
||||||
movie.HeaderEntries[HeaderKeys.PAL] == "1";
|
&& movie.HeaderEntries[HeaderKeys.PAL] == "1";
|
||||||
|
|
||||||
return new PlatformFrameRates()[system, pal];
|
return new PlatformFrameRates()[system, pal];
|
||||||
|
|
||||||
|
@ -611,14 +607,9 @@ namespace BizHawk.Client.EmuHawk
|
||||||
if (StopOnFrameCheckbox.Checked &&
|
if (StopOnFrameCheckbox.Checked &&
|
||||||
(StopOnFrameTextBox.ToRawInt().HasValue || LastFrameCheckbox.Checked))
|
(StopOnFrameTextBox.ToRawInt().HasValue || LastFrameCheckbox.Checked))
|
||||||
{
|
{
|
||||||
if (LastFrameCheckbox.Checked)
|
GlobalWin.MainForm.PauseOnFrame = LastFrameCheckbox.Checked
|
||||||
{
|
? Global.MovieSession.Movie.InputLogLength
|
||||||
GlobalWin.MainForm.PauseOnFrame = Global.MovieSession.Movie.InputLogLength;
|
: StopOnFrameTextBox.ToRawInt();
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
GlobalWin.MainForm.PauseOnFrame = StopOnFrameTextBox.ToRawInt();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Close();
|
Close();
|
||||||
|
@ -631,7 +622,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
private bool _programmaticallyChangingStopFrameCheckbox = false;
|
private bool _programmaticallyChangingStopFrameCheckbox;
|
||||||
private void StopOnFrameCheckbox_CheckedChanged(object sender, EventArgs e)
|
private void StopOnFrameCheckbox_CheckedChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (!_programmaticallyChangingStopFrameCheckbox)
|
if (!_programmaticallyChangingStopFrameCheckbox)
|
||||||
|
@ -649,7 +640,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
private void LastFrameCheckbox_CheckedChanged(object sender, EventArgs e)
|
private void LastFrameCheckbox_CheckedChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (LastFrameCheckbox.Checked == true)
|
if (LastFrameCheckbox.Checked)
|
||||||
{
|
{
|
||||||
_programmaticallyChangingStopFrameCheckbox = true;
|
_programmaticallyChangingStopFrameCheckbox = true;
|
||||||
StopOnFrameCheckbox.Checked = true;
|
StopOnFrameCheckbox.Checked = true;
|
||||||
|
|
|
@ -3,7 +3,6 @@ using System.IO;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
using BizHawk.Common.ReflectionExtensions;
|
|
||||||
using BizHawk.Emulation.Common;
|
using BizHawk.Emulation.Common;
|
||||||
using BizHawk.Emulation.Common.IEmulatorExtensions;
|
using BizHawk.Emulation.Common.IEmulatorExtensions;
|
||||||
using BizHawk.Client.Common;
|
using BizHawk.Client.Common;
|
||||||
|
@ -16,15 +15,15 @@ namespace BizHawk.Client.EmuHawk
|
||||||
// TODO - Allow relative paths in record textbox
|
// TODO - Allow relative paths in record textbox
|
||||||
public partial class RecordMovie : Form
|
public partial class RecordMovie : Form
|
||||||
{
|
{
|
||||||
private IEmulator Emulator;
|
private readonly IEmulator _emulator;
|
||||||
|
|
||||||
public RecordMovie(IEmulator core)
|
public RecordMovie(IEmulator core)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
Emulator = core;
|
_emulator = core;
|
||||||
|
|
||||||
if (!Emulator.HasSavestates())
|
if (!_emulator.HasSavestates())
|
||||||
{
|
{
|
||||||
StartFromCombo.Items.Remove(
|
StartFromCombo.Items.Remove(
|
||||||
StartFromCombo.Items
|
StartFromCombo.Items
|
||||||
|
@ -33,7 +32,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
.ToLower() == "now"));
|
.ToLower() == "now"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Emulator.HasSaveRam())
|
if (!_emulator.HasSaveRam())
|
||||||
{
|
{
|
||||||
StartFromCombo.Items.Remove(
|
StartFromCombo.Items.Remove(
|
||||||
StartFromCombo.Items
|
StartFromCombo.Items
|
||||||
|
@ -92,9 +91,9 @@ namespace BizHawk.Client.EmuHawk
|
||||||
Directory.CreateDirectory(fileInfo.DirectoryName);
|
Directory.CreateDirectory(fileInfo.DirectoryName);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (StartFromCombo.SelectedItem.ToString() == "Now" && Emulator.HasSavestates())
|
if (StartFromCombo.SelectedItem.ToString() == "Now" && _emulator.HasSavestates())
|
||||||
{
|
{
|
||||||
var core = Emulator.AsStatable();
|
var core = _emulator.AsStatable();
|
||||||
|
|
||||||
movieToRecord.StartsFromSavestate = true;
|
movieToRecord.StartsFromSavestate = true;
|
||||||
movieToRecord.StartsFromSaveRam = false;
|
movieToRecord.StartsFromSaveRam = false;
|
||||||
|
@ -105,27 +104,21 @@ namespace BizHawk.Client.EmuHawk
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
using (var sw = new StringWriter())
|
using var sw = new StringWriter();
|
||||||
{
|
core.SaveStateText(sw);
|
||||||
core.SaveStateText(sw);
|
movieToRecord.TextSavestate = sw.ToString();
|
||||||
movieToRecord.TextSavestate = sw.ToString();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: do we want to support optionally not saving this?
|
// TODO: do we want to support optionally not saving this?
|
||||||
if (true)
|
movieToRecord.SavestateFramebuffer = new int[0];
|
||||||
|
if (_emulator.HasVideoProvider())
|
||||||
{
|
{
|
||||||
// hack: some IMovies eat the framebuffer, so don't bother with them
|
movieToRecord.SavestateFramebuffer = (int[])_emulator.AsVideoProvider().GetVideoBuffer().Clone();
|
||||||
movieToRecord.SavestateFramebuffer = new int[0];
|
|
||||||
if (movieToRecord.SavestateFramebuffer != null && Emulator.HasVideoProvider())
|
|
||||||
{
|
|
||||||
movieToRecord.SavestateFramebuffer = (int[])Emulator.AsVideoProvider().GetVideoBuffer().Clone();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (StartFromCombo.SelectedItem.ToString() == "SaveRam" && Emulator.HasSaveRam())
|
else if (StartFromCombo.SelectedItem.ToString() == "SaveRam" && _emulator.HasSaveRam())
|
||||||
{
|
{
|
||||||
var core = Emulator.AsSaveRam();
|
var core = _emulator.AsSaveRam();
|
||||||
movieToRecord.StartsFromSavestate = false;
|
movieToRecord.StartsFromSavestate = false;
|
||||||
movieToRecord.StartsFromSaveRam = true;
|
movieToRecord.StartsFromSaveRam = true;
|
||||||
movieToRecord.SaveRam = core.CloneSaveRam();
|
movieToRecord.SaveRam = core.CloneSaveRam();
|
||||||
|
@ -155,7 +148,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
}
|
}
|
||||||
|
|
||||||
private void BrowseBtn_Click(object sender, EventArgs e)
|
private void BrowseBtn_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
string movieFolderPath = PathManager.MakeAbsolutePath(Global.Config.PathEntries.MoviesPathFragment, null);
|
string movieFolderPath = PathManager.MakeAbsolutePath(Global.Config.PathEntries.MoviesPathFragment, null);
|
||||||
|
|
||||||
// Create movie folder if it doesn't already exist
|
// Create movie folder if it doesn't already exist
|
||||||
|
@ -168,9 +161,8 @@ namespace BizHawk.Client.EmuHawk
|
||||||
}
|
}
|
||||||
catch (Exception movieDirException)
|
catch (Exception movieDirException)
|
||||||
{
|
{
|
||||||
if (movieDirException is IOException ||
|
if (movieDirException is IOException
|
||||||
movieDirException is UnauthorizedAccessException ||
|
|| movieDirException is UnauthorizedAccessException)
|
||||||
movieDirException is PathTooLongException)
|
|
||||||
{
|
{
|
||||||
//TO DO : Pass error to user?
|
//TO DO : Pass error to user?
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
{
|
{
|
||||||
public partial class SubtitleMaker : Form
|
public partial class SubtitleMaker : Form
|
||||||
{
|
{
|
||||||
public Subtitle Sub = new Subtitle();
|
public Subtitle Sub { get; set; } = new Subtitle();
|
||||||
|
|
||||||
public SubtitleMaker()
|
public SubtitleMaker()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue