diff --git a/src/BizHawk.Client.EmuHawk/MainForm.Events.cs b/src/BizHawk.Client.EmuHawk/MainForm.Events.cs index a8ae3bc9bd..f9d017028b 100644 --- a/src/BizHawk.Client.EmuHawk/MainForm.Events.cs +++ b/src/BizHawk.Client.EmuHawk/MainForm.Events.cs @@ -2573,8 +2573,7 @@ namespace BizHawk.Client.EmuHawk { if (MovieSession.Movie.IsActive()) { - using var form = new EditCommentsForm(); - form.GetMovie(MovieSession.Movie); + using var form = new EditCommentsForm(MovieSession.Movie, MovieSession.ReadOnly); form.ShowDialog(); } } diff --git a/src/BizHawk.Client.EmuHawk/movie/EditCommentsForm.cs b/src/BizHawk.Client.EmuHawk/movie/EditCommentsForm.cs index 7a30b89909..80807d7ddb 100644 --- a/src/BizHawk.Client.EmuHawk/movie/EditCommentsForm.cs +++ b/src/BizHawk.Client.EmuHawk/movie/EditCommentsForm.cs @@ -2,29 +2,40 @@ using System.ComponentModel; using System.Linq; using System.Windows.Forms; - using BizHawk.Client.Common; namespace BizHawk.Client.EmuHawk { public partial class EditCommentsForm : Form { - private IMovie _selectedMovie; + private readonly IMovie _movie; + private readonly bool _readOnly; private string _lastHeaderClicked; private bool _sortReverse; - public EditCommentsForm() + public EditCommentsForm(IMovie movie, bool readOnly) { - InitializeComponent(); + _movie = movie; + _readOnly = readOnly; _lastHeaderClicked = ""; _sortReverse = false; - } - public bool ForceReadWrite { get; set; } + InitializeComponent(); + } private void EditCommentsForm_Load(object sender, EventArgs e) { - if (!ForceReadWrite && GlobalWin.MovieSession.ReadOnly) + if (_movie.Comments.Any()) + { + for (int i = 0; i < _movie.Comments.Count; i++) + { + CommentGrid.Rows.Add(); + var c = CommentGrid.Rows[i].Cells[0]; + c.Value = _movie.Comments[i]; + } + } + + if (_readOnly) { CommentGrid.Columns[0].ReadOnly = true; Text = "View Comments"; @@ -39,30 +50,14 @@ namespace BizHawk.Client.EmuHawk private void Save() { - _selectedMovie.Comments.Clear(); + _movie.Comments.Clear(); for (int i = 0; i < CommentGrid.Rows.Count - 1; i++) { var c = CommentGrid.Rows[i].Cells[0]; - _selectedMovie.Comments.Add(c.Value.ToString()); + _movie.Comments.Add(c.Value.ToString()); } - _selectedMovie.Save(); - } - - public void GetMovie(IMovie m) - { - _selectedMovie = m; - if (!m.Comments.Any()) - { - return; - } - - for (int i = 0; i < m.Comments.Count; i++) - { - CommentGrid.Rows.Add(); - var c = CommentGrid.Rows[i].Cells[0]; - c.Value = m.Comments[i]; - } + _movie.Save(); } private void Cancel_Click(object sender, EventArgs e) diff --git a/src/BizHawk.Client.EmuHawk/movie/PlayMovie.cs b/src/BizHawk.Client.EmuHawk/movie/PlayMovie.cs index e541188967..195ed359cb 100644 --- a/src/BizHawk.Client.EmuHawk/movie/PlayMovie.cs +++ b/src/BizHawk.Client.EmuHawk/movie/PlayMovie.cs @@ -518,8 +518,7 @@ namespace BizHawk.Client.EmuHawk var indices = MovieView.SelectedIndices; if (indices.Count > 0) { - var form = new EditCommentsForm(); - form.GetMovie(_movieList[MovieView.SelectedIndices[0]]); + var form = new EditCommentsForm(_movieList[MovieView.SelectedIndices[0]], _movieSession.ReadOnly); form.Show(); } } diff --git a/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.MenuItems.cs b/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.MenuItems.cs index 3f663c2c0e..81630f4b16 100644 --- a/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.MenuItems.cs +++ b/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.MenuItems.cs @@ -993,9 +993,7 @@ namespace BizHawk.Client.EmuHawk private void CommentsMenuItem_Click(object sender, EventArgs e) { - var form = new EditCommentsForm(); - form.GetMovie(CurrentTasMovie); - form.ForceReadWrite = true; + var form = new EditCommentsForm(CurrentTasMovie, true); form.Show(); }