From fe9d8ed88197a00269e2d69d812408b078a31e45 Mon Sep 17 00:00:00 2001 From: adelikat Date: Fri, 1 Nov 2013 15:35:30 +0000 Subject: [PATCH] refactor - move readonly flag from MainForm.cs to Global.cs --- BizHawk.Client.Common/Global.cs | 1 + BizHawk.MultiClient/MainForm.Events.cs | 10 +++---- BizHawk.MultiClient/MainForm.Movie.cs | 30 +++++++++---------- BizHawk.MultiClient/MainForm.cs | 12 ++++---- BizHawk.MultiClient/movie/EditCommentsForm.cs | 5 ++-- BizHawk.MultiClient/movie/PlayMovie.cs | 12 ++++---- .../Lua/Libraries/EmuLuaLibrary.Movie.cs | 2 +- BizHawk.MultiClient/tools/TAStudio.cs | 2 +- 8 files changed, 37 insertions(+), 37 deletions(-) diff --git a/BizHawk.Client.Common/Global.cs b/BizHawk.Client.Common/Global.cs index 3639435b61..6445ad772c 100644 --- a/BizHawk.Client.Common/Global.cs +++ b/BizHawk.Client.Common/Global.cs @@ -18,6 +18,7 @@ namespace BizHawk.Client.Common /// public static MultitrackRewiringControllerAdapter MultitrackRewiringControllerAdapter = new MultitrackRewiringControllerAdapter(); public static MovieSession MovieSession = new MovieSession(); + public static bool ReadOnly = true; //Global Movie Read only setting /// /// whether throttling is force-disabled by use of fast forward diff --git a/BizHawk.MultiClient/MainForm.Events.cs b/BizHawk.MultiClient/MainForm.Events.cs index 1f5f74efb4..4c2a9bc788 100644 --- a/BizHawk.MultiClient/MainForm.Events.cs +++ b/BizHawk.MultiClient/MainForm.Events.cs @@ -230,7 +230,7 @@ namespace BizHawk.MultiClient = SaveMovieMenuItem.Enabled = Global.MovieSession.Movie.IsActive; - ReadonlyMenuItem.Checked = ReadOnly; + ReadonlyMenuItem.Checked = Global.ReadOnly; BindSavestatesToMoviesMenuItem.Checked = Global.Config.BindSavestatesToMovies; AutomaticallyBackupMoviesMenuItem.Checked = Global.Config.EnableBackupMovies; FullMovieLoadstatesMenuItem.Checked = Global.Config.VBAStyleMovieLoadState; @@ -1815,7 +1815,7 @@ namespace BizHawk.MultiClient StopNoSaveContextMenuItem.Visible = Global.MovieSession.Movie.IsActive && Global.MovieSession.Movie.HasChanges; - AddSubtitleContextMenuItem.Visible = !IsNullEmulator() && Global.MovieSession.Movie.IsActive && ReadOnly; + AddSubtitleContextMenuItem.Visible = !IsNullEmulator() && Global.MovieSession.Movie.IsActive && Global.ReadOnly; ConfigContextMenuItem.Visible = InFullscreen; @@ -1828,7 +1828,7 @@ namespace BizHawk.MultiClient if (Global.MovieSession.Movie.IsActive) { - if (ReadOnly) + if (Global.ReadOnly) { ViewSubtitlesContextMenuItem.Text = "View Subtitles"; ViewCommentsContextMenuItem.Text = "View Comments"; @@ -1909,7 +1909,7 @@ namespace BizHawk.MultiClient { if (Global.MovieSession.Movie.IsActive) { - EditSubtitlesForm form = new EditSubtitlesForm { ReadOnly = ReadOnly }; + EditSubtitlesForm form = new EditSubtitlesForm { ReadOnly = Global.ReadOnly }; form.GetMovie(Global.MovieSession.Movie); form.ShowDialog(); } @@ -1954,7 +1954,7 @@ namespace BizHawk.MultiClient { if (Global.MovieSession.Movie.IsActive) { - EditCommentsForm form = new EditCommentsForm { ReadOnly = ReadOnly }; + EditCommentsForm form = new EditCommentsForm(); form.GetMovie(Global.MovieSession.Movie); form.ShowDialog(); } diff --git a/BizHawk.MultiClient/MainForm.Movie.cs b/BizHawk.MultiClient/MainForm.Movie.cs index 887415e1ab..3af297fb6d 100644 --- a/BizHawk.MultiClient/MainForm.Movie.cs +++ b/BizHawk.MultiClient/MainForm.Movie.cs @@ -8,8 +8,6 @@ namespace BizHawk.MultiClient { partial class MainForm { - public bool ReadOnly = true; //Global Movie Read only setting - public void ClearFrame() { if (Global.MovieSession.Movie.IsPlaying) @@ -48,7 +46,7 @@ namespace BizHawk.MultiClient { GlobalWinF.MainForm.ClearSaveRAM(); Global.MovieSession.Movie.StartRecording(); - ReadOnly = false; + Global.ReadOnly = false; } else { @@ -124,7 +122,7 @@ namespace BizHawk.MultiClient Global.MovieSession.Movie.StartPlayback(); SetMainformMovieInfo(); GlobalWinF.OSD.AddMessage("Replaying movie file in read-only mode"); - GlobalWinF.MainForm.ReadOnly = true; + Global.ReadOnly = true; } } @@ -150,7 +148,7 @@ namespace BizHawk.MultiClient GlobalWinF.OSD.AddMessage(Path.GetFileName(Global.MovieSession.Movie.Filename) + " written to disk."); } GlobalWinF.OSD.AddMessage(message); - GlobalWinF.MainForm.ReadOnly = true; + Global.ReadOnly = true; SetMainformMovieInfo(); } } @@ -183,7 +181,7 @@ namespace BizHawk.MultiClient else if (Global.MovieSession.Movie.IsRecording) { - if (ReadOnly) + if (Global.ReadOnly) { var result = Global.MovieSession.Movie.CheckTimeLines(reader, OnlyGUID: false, IgnoreGuidMismatch: false, ErrorMessage: out ErrorMSG); if (result == Movie.LoadStateResult.Pass) @@ -276,9 +274,9 @@ namespace BizHawk.MultiClient else if (Global.MovieSession.Movie.IsPlaying && !Global.MovieSession.Movie.IsFinished) { - if (ReadOnly) + if (Global.ReadOnly) { - var result = Global.MovieSession.Movie.CheckTimeLines(reader, OnlyGUID: !ReadOnly, IgnoreGuidMismatch: false, ErrorMessage: out ErrorMSG); + var result = Global.MovieSession.Movie.CheckTimeLines(reader, OnlyGUID: !Global.ReadOnly, IgnoreGuidMismatch: false, ErrorMessage: out ErrorMSG); if (result == Movie.LoadStateResult.Pass) { //Frame loop automatically handles the rewinding effect based on Global.Emulator.Frame so nothing else is needed here @@ -293,7 +291,7 @@ namespace BizHawk.MultiClient MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dresult == DialogResult.Yes) { - var newresult = Global.MovieSession.Movie.CheckTimeLines(reader, OnlyGUID: !ReadOnly, IgnoreGuidMismatch: true, ErrorMessage: out ErrorMSG); + var newresult = Global.MovieSession.Movie.CheckTimeLines(reader, OnlyGUID: !Global.ReadOnly, IgnoreGuidMismatch: true, ErrorMessage: out ErrorMSG); if (newresult == Movie.LoadStateResult.Pass) { return true; @@ -318,7 +316,7 @@ namespace BizHawk.MultiClient } else { - var result = Global.MovieSession.Movie.CheckTimeLines(reader, OnlyGUID: !ReadOnly, IgnoreGuidMismatch: false, ErrorMessage: out ErrorMSG); + var result = Global.MovieSession.Movie.CheckTimeLines(reader, OnlyGUID: !Global.ReadOnly, IgnoreGuidMismatch: false, ErrorMessage: out ErrorMSG); if (result == Movie.LoadStateResult.Pass) { Global.MovieSession.Movie.SwitchToRecord(); @@ -337,7 +335,7 @@ namespace BizHawk.MultiClient MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dresult == DialogResult.Yes) { - var newresult = Global.MovieSession.Movie.CheckTimeLines(reader, OnlyGUID: !ReadOnly, IgnoreGuidMismatch: true, ErrorMessage: out ErrorMSG); + var newresult = Global.MovieSession.Movie.CheckTimeLines(reader, OnlyGUID: !Global.ReadOnly, IgnoreGuidMismatch: true, ErrorMessage: out ErrorMSG); if (newresult == Movie.LoadStateResult.Pass) { Global.MovieSession.Movie.SwitchToRecord(); @@ -368,9 +366,9 @@ namespace BizHawk.MultiClient } else if (Global.MovieSession.Movie.IsFinished) { - if (ReadOnly) + if (Global.ReadOnly) { - var result = Global.MovieSession.Movie.CheckTimeLines(reader, OnlyGUID: !ReadOnly, IgnoreGuidMismatch: false, ErrorMessage: out ErrorMSG); + var result = Global.MovieSession.Movie.CheckTimeLines(reader, OnlyGUID: !Global.ReadOnly, IgnoreGuidMismatch: false, ErrorMessage: out ErrorMSG); if (result != Movie.LoadStateResult.Pass) { if (result == Movie.LoadStateResult.GuidMismatch) @@ -380,7 +378,7 @@ namespace BizHawk.MultiClient MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dresult == DialogResult.Yes) { - var newresult = Global.MovieSession.Movie.CheckTimeLines(reader, OnlyGUID: !ReadOnly, IgnoreGuidMismatch: true, ErrorMessage: out ErrorMSG); + var newresult = Global.MovieSession.Movie.CheckTimeLines(reader, OnlyGUID: !Global.ReadOnly, IgnoreGuidMismatch: true, ErrorMessage: out ErrorMSG); if (newresult == Movie.LoadStateResult.Pass) { Global.MovieSession.Movie.SwitchToPlay(); @@ -416,7 +414,7 @@ namespace BizHawk.MultiClient } else { - var result = Global.MovieSession.Movie.CheckTimeLines(reader, OnlyGUID: !ReadOnly, IgnoreGuidMismatch: false, ErrorMessage: out ErrorMSG); + var result = Global.MovieSession.Movie.CheckTimeLines(reader, OnlyGUID: !Global.ReadOnly, IgnoreGuidMismatch: false, ErrorMessage: out ErrorMSG); if (result == Movie.LoadStateResult.Pass) { GlobalWinF.MainForm.ClearSaveRAM(); @@ -436,7 +434,7 @@ namespace BizHawk.MultiClient MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dresult == DialogResult.Yes) { - var newresult = Global.MovieSession.Movie.CheckTimeLines(reader, OnlyGUID: !ReadOnly, IgnoreGuidMismatch: true, ErrorMessage: out ErrorMSG); + var newresult = Global.MovieSession.Movie.CheckTimeLines(reader, OnlyGUID: !Global.ReadOnly, IgnoreGuidMismatch: true, ErrorMessage: out ErrorMSG); if (newresult == Movie.LoadStateResult.Pass) { GlobalWinF.MainForm.ClearSaveRAM(); diff --git a/BizHawk.MultiClient/MainForm.cs b/BizHawk.MultiClient/MainForm.cs index 457b897025..23cf5b8b90 100644 --- a/BizHawk.MultiClient/MainForm.cs +++ b/BizHawk.MultiClient/MainForm.cs @@ -316,7 +316,7 @@ namespace BizHawk.MultiClient else { Movie m = new Movie(cmdMovie, GlobalWinF.MainForm.GetEmuVersion()); - ReadOnly = true; + Global.ReadOnly = true; // if user is dumping and didnt supply dump length, make it as long as the loaded movie if (autoDumpLength == 0) { @@ -775,7 +775,7 @@ namespace BizHawk.MultiClient } else { - ReadOnly = true; + Global.ReadOnly = true; StartNewMovie(m, false); } } @@ -3454,8 +3454,8 @@ namespace BizHawk.MultiClient { if (Global.MovieSession.Movie.IsActive) { - ReadOnly ^= true; - if (ReadOnly) + Global.ReadOnly ^= true; + if (Global.ReadOnly) { GlobalWinF.OSD.AddMessage("Movie read-only mode"); } @@ -3473,8 +3473,8 @@ namespace BizHawk.MultiClient public void SetReadOnly(bool read_only) { - ReadOnly = read_only; - if (ReadOnly) + Global.ReadOnly = read_only; + if (Global.ReadOnly) { GlobalWinF.OSD.AddMessage("Movie read-only mode"); } diff --git a/BizHawk.MultiClient/movie/EditCommentsForm.cs b/BizHawk.MultiClient/movie/EditCommentsForm.cs index d5b563a911..67b4182344 100644 --- a/BizHawk.MultiClient/movie/EditCommentsForm.cs +++ b/BizHawk.MultiClient/movie/EditCommentsForm.cs @@ -7,7 +7,6 @@ namespace BizHawk.MultiClient { public partial class EditCommentsForm : Form { - public bool ReadOnly; private Movie selectedMovie; public EditCommentsForm() @@ -17,7 +16,7 @@ namespace BizHawk.MultiClient private void EditCommentsForm_Load(object sender, EventArgs e) { - if (ReadOnly) + if (Global.ReadOnly) { CommentGrid.Columns[0].ReadOnly = true; Text = "View Comments"; @@ -40,7 +39,7 @@ namespace BizHawk.MultiClient private void OK_Click(object sender, EventArgs e) { - if (!ReadOnly) + if (!Global.ReadOnly) { selectedMovie.Header.Comments.Clear(); for (int x = 0; x < CommentGrid.Rows.Count - 1; x++) diff --git a/BizHawk.MultiClient/movie/PlayMovie.cs b/BizHawk.MultiClient/movie/PlayMovie.cs index 0185165b96..788d9efb88 100644 --- a/BizHawk.MultiClient/movie/PlayMovie.cs +++ b/BizHawk.MultiClient/movie/PlayMovie.cs @@ -74,7 +74,7 @@ namespace BizHawk.MultiClient private void OK_Click(object sender, EventArgs e) { - GlobalWinF.MainForm.ReadOnly = ReadOnlyCheckBox.Checked; + Global.ReadOnly = ReadOnlyCheckBox.Checked; Run(); Close(); } @@ -356,7 +356,7 @@ namespace BizHawk.MultiClient private void MovieView_SelectedIndexChanged(object sender, EventArgs e) { - toolTip1.SetToolTip(DetailsView, ""); + toolTip1.SetToolTip(DetailsView, String.Empty); DetailsView.Items.Clear(); if (MovieView.SelectedIndices.Count < 1) { @@ -431,9 +431,9 @@ namespace BizHawk.MultiClient { ListView.SelectedIndexCollection indexes = MovieView.SelectedIndices; if (indexes.Count == 0) return; - EditCommentsForm c = new EditCommentsForm {ReadOnly = true}; - c.GetMovie(MovieList[MovieView.SelectedIndices[0]]); - c.Show(); + EditCommentsForm form = new EditCommentsForm(); + form.GetMovie(MovieList[MovieView.SelectedIndices[0]]); + form.Show(); } private void button2_Click(object sender, EventArgs e) @@ -462,7 +462,9 @@ namespace BizHawk.MultiClient foreach (string path in filePaths) { if (Path.GetExtension(path) == "." + Global.Config.MovieExtension) + { AddMovieToList(path, true); + } } } diff --git a/BizHawk.MultiClient/tools/Lua/Libraries/EmuLuaLibrary.Movie.cs b/BizHawk.MultiClient/tools/Lua/Libraries/EmuLuaLibrary.Movie.cs index a50dd1dc1a..5fc9d440cb 100644 --- a/BizHawk.MultiClient/tools/Lua/Libraries/EmuLuaLibrary.Movie.cs +++ b/BizHawk.MultiClient/tools/Lua/Libraries/EmuLuaLibrary.Movie.cs @@ -59,7 +59,7 @@ namespace BizHawk.MultiClient public static bool movie_getreadonly() { - return GlobalWinF.MainForm.ReadOnly; + return Global.ReadOnly; } public static bool movie_getrerecordcounting() diff --git a/BizHawk.MultiClient/tools/TAStudio.cs b/BizHawk.MultiClient/tools/TAStudio.cs index 251563dfd7..82ff771225 100644 --- a/BizHawk.MultiClient/tools/TAStudio.cs +++ b/BizHawk.MultiClient/tools/TAStudio.cs @@ -171,7 +171,7 @@ namespace BizHawk.MultiClient if (Global.MovieSession.Movie.IsActive) { Global.MovieSession.Movie.StateCapturing = true; - ReadOnlyCheckBox.Checked = GlobalWinF.MainForm.ReadOnly; + ReadOnlyCheckBox.Checked = Global.ReadOnly; } else {