This commit is contained in:
alyosha-tas 2019-12-17 17:41:50 -05:00
commit 3f326109d6
8 changed files with 67 additions and 79 deletions

View File

@ -93,7 +93,7 @@ namespace BizHawk.Client.EmuHawk
this.buttonCopy.TabIndex = 3;
this.buttonCopy.Text = "Copy Sel.";
this.buttonCopy.UseVisualStyleBackColor = true;
this.buttonCopy.Click += new System.EventHandler(this.buttonCopy_Click);
this.buttonCopy.Click += new System.EventHandler(this.ButtonCopy_Click);
//
// buttonCopyAll
//
@ -103,7 +103,7 @@ namespace BizHawk.Client.EmuHawk
this.buttonCopyAll.TabIndex = 4;
this.buttonCopyAll.Text = "Copy All";
this.buttonCopyAll.UseVisualStyleBackColor = true;
this.buttonCopyAll.Click += new System.EventHandler(this.buttonCopyAll_Click);
this.buttonCopyAll.Click += new System.EventHandler(this.ButtonCopyAll_Click);
//
// AddToGameDbBtn
//
@ -133,9 +133,9 @@ namespace BizHawk.Client.EmuHawk
this.virtualListView1.UseCompatibleStateImageBehavior = false;
this.virtualListView1.View = System.Windows.Forms.View.Details;
this.virtualListView1.VirtualMode = true;
this.virtualListView1.RetrieveVirtualItem += new RetrieveVirtualItemEventHandler(this.virtualListView1_QueryItemText);
this.virtualListView1.ClientSizeChanged += new System.EventHandler(this.virtualListView1_ClientSizeChanged);
this.virtualListView1.KeyDown += new System.Windows.Forms.KeyEventHandler(this.virtualListView1_KeyDown);
this.virtualListView1.RetrieveVirtualItem += new RetrieveVirtualItemEventHandler(this.ListView_QueryItemText);
this.virtualListView1.ClientSizeChanged += new System.EventHandler(this.ListView_ClientSizeChanged);
this.virtualListView1.KeyDown += new System.Windows.Forms.KeyEventHandler(this.ListView_KeyDown);
//
// LogWindow
//

View File

@ -17,7 +17,7 @@ namespace BizHawk.Client.EmuHawk
{
//TODO: only show add to game db when this is a Rom details dialog
//Let user decide what type (instead of always adding it as a good dump)
private readonly List<string> Lines = new List<string>();
private readonly List<string> _lines = new List<string>();
public LogWindow()
{
@ -29,21 +29,22 @@ namespace BizHawk.Client.EmuHawk
LogConsole.notifyLogWindowClosing();
SaveConfigSettings();
};
virtualListView1_ClientSizeChanged(null, null);
ListView_ClientSizeChanged(null, null);
}
public static void ShowReport(string title, string report, IWin32Window parent)
{
using (var dlg = new LogWindow())
using var dlg = new LogWindow();
var ss = report.Split('\n');
foreach (var s in ss)
{
var ss = report.Split('\n');
foreach (var s in ss)
dlg.Lines.Add(s.TrimEnd('\r'));
dlg.virtualListView1.VirtualListSize = ss.Length;
dlg.Text = title;
dlg.btnClear.Visible = false;
dlg.ShowDialog(parent);
dlg._lines.Add(s.TrimEnd('\r'));
}
dlg.virtualListView1.VirtualListSize = ss.Length;
dlg.Text = title;
dlg.btnClear.Visible = false;
dlg.ShowDialog(parent);
}
public void Append(string str)
@ -53,7 +54,7 @@ namespace BizHawk.Client.EmuHawk
{
if (!string.IsNullOrWhiteSpace(s))
{
Lines.Add(s.TrimEnd('\r'));
_lines.Add(s.TrimEnd('\r'));
virtualListView1.VirtualListSize++;
}
}
@ -61,7 +62,7 @@ namespace BizHawk.Client.EmuHawk
private void btnClear_Click(object sender, EventArgs e)
{
Lines.Clear();
_lines.Clear();
virtualListView1.VirtualListSize = 0;
virtualListView1.SelectedIndices.Clear();
}
@ -98,42 +99,42 @@ namespace BizHawk.Client.EmuHawk
}
}
private void virtualListView1_QueryItemText(object sender, RetrieveVirtualItemEventArgs e)
private void ListView_QueryItemText(object sender, RetrieveVirtualItemEventArgs e)
{
e.Item = new ListViewItem(Lines[e.ItemIndex]);
e.Item = new ListViewItem(_lines[e.ItemIndex]);
}
private void virtualListView1_ClientSizeChanged(object sender, EventArgs e)
private void ListView_ClientSizeChanged(object sender, EventArgs e)
{
virtualListView1.Columns[0].Width = virtualListView1.ClientSize.Width;
}
private void buttonCopy_Click(object sender, EventArgs e)
{
var sb = new StringBuilder();
foreach (int i in virtualListView1.SelectedIndices)
sb.AppendLine(Lines[i]);
if (sb.Length > 0)
Clipboard.SetText(sb.ToString(), TextDataFormat.Text);
}
private void buttonCopyAll_Click(object sender, EventArgs e)
{
var sb = new StringBuilder();
foreach (var s in Lines)
sb.AppendLine(s);
if (sb.Length > 0)
Clipboard.SetText(sb.ToString(), TextDataFormat.Text);
}
private void virtualListView1_KeyDown(object sender, KeyEventArgs e)
private void ListView_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.C && e.Control && !e.Alt && !e.Shift)
{
buttonCopy_Click(null, null);
ButtonCopy_Click(null, null);
}
}
private void ButtonCopy_Click(object sender, EventArgs e)
{
var sb = new StringBuilder();
foreach (int i in virtualListView1.SelectedIndices)
sb.AppendLine(_lines[i]);
if (sb.Length > 0)
Clipboard.SetText(sb.ToString(), TextDataFormat.Text);
}
private void ButtonCopyAll_Click(object sender, EventArgs e)
{
var sb = new StringBuilder();
foreach (var s in _lines)
sb.AppendLine(s);
if (sb.Length > 0)
Clipboard.SetText(sb.ToString(), TextDataFormat.Text);
}
private void HideShowGameDbButton()
{
AddToGameDbBtn.Visible = Global.Emulator.CanGenerateGameDBEntries()

View File

@ -542,7 +542,6 @@
this.MainformMenu.Text = "menuStrip1";
this.MainformMenu.MenuActivate += new System.EventHandler(this.MainformMenu_MenuActivate);
this.MainformMenu.MenuDeactivate += new System.EventHandler(this.MainformMenu_MenuDeactivate);
this.MainformMenu.Leave += new System.EventHandler(this.MainformMenu_Leave);
//
// FileSubMenu
//

View File

@ -489,13 +489,13 @@ namespace BizHawk.Client.EmuHawk
// Inaccurate core but allow the user to continue anyway
}
using var form = new RecordMovie(Emulator);
using var form = new RecordMovie(this, Emulator);
form.ShowDialog();
}
private void PlayMovieMenuItem_Click(object sender, EventArgs e)
{
using var form = new PlayMovie();
using var form = new PlayMovie(this);
form.ShowDialog();
}
@ -2930,11 +2930,7 @@ namespace BizHawk.Client.EmuHawk
OpenRomContextMenuItem.Visible = Emulator.IsNull() || _inFullscreen;
bool showMenuVisible = _inFullscreen;
if (!MainMenuStrip.Visible)
{
showMenuVisible = true; // need to always be able to restore this as an emergency measure
}
bool showMenuVisible = _inFullscreen || !MainMenuStrip.Visible; // need to always be able to restore this as an emergency measure
if (_argParser._chromeless)
{
@ -3366,10 +3362,6 @@ namespace BizHawk.Client.EmuHawk
base.OnClosed(e);
}
private void MainformMenu_Leave(object sender, EventArgs e)
{
}
private void MainformMenu_MenuActivate(object sender, EventArgs e)
{
HandlePlatformMenus();

View File

@ -15,6 +15,7 @@ namespace BizHawk.Client.EmuHawk
{
public partial class PlayMovie : Form
{
private readonly MainForm _mainForm;
private readonly PlatformFrameRates _platformFrameRates = new PlatformFrameRates();
private List<IMovie> _movieList = new List<IMovie>();
@ -24,8 +25,9 @@ namespace BizHawk.Client.EmuHawk
private bool _sortDetailsReverse;
private string _sortedDetailsCol;
public PlayMovie()
public PlayMovie(MainForm mainForm)
{
_mainForm = mainForm;
InitializeComponent();
MovieView.RetrieveVirtualItem += MovieView_QueryItemText;
MovieView.VirtualMode = true;
@ -59,7 +61,7 @@ namespace BizHawk.Client.EmuHawk
var indices = MovieView.SelectedIndices;
if (indices.Count > 0) // Import file if necessary
{
GlobalWin.MainForm.StartNewMovie(_movieList[MovieView.SelectedIndices[0]], false);
_mainForm.StartNewMovie(_movieList[MovieView.SelectedIndices[0]], false);
}
}
@ -607,7 +609,7 @@ namespace BizHawk.Client.EmuHawk
if (StopOnFrameCheckbox.Checked &&
(StopOnFrameTextBox.ToRawInt().HasValue || LastFrameCheckbox.Checked))
{
GlobalWin.MainForm.PauseOnFrame = LastFrameCheckbox.Checked
_mainForm.PauseOnFrame = LastFrameCheckbox.Checked
? Global.MovieSession.Movie.InputLogLength
: StopOnFrameTextBox.ToRawInt();
}

View File

@ -12,16 +12,17 @@ using BizHawk.Client.EmuHawk.WinFormExtensions;
namespace BizHawk.Client.EmuHawk
{
// TODO - Allow relative paths in record textbox
// TODO - Allow relative paths in record TextBox
public partial class RecordMovie : Form
{
private readonly MainForm _mainForm;
private readonly IEmulator _emulator;
public RecordMovie(IEmulator core)
public RecordMovie(MainForm mainForm, IEmulator core)
{
InitializeComponent();
_mainForm = mainForm;
_emulator = core;
InitializeComponent();
if (!_emulator.HasSavestates())
{
@ -126,7 +127,7 @@ namespace BizHawk.Client.EmuHawk
movieToRecord.PopulateWithDefaultHeaderValues(AuthorBox.Text);
movieToRecord.Save();
GlobalWin.MainForm.StartNewMovie(movieToRecord, true);
_mainForm.StartNewMovie(movieToRecord, true);
Global.Config.UseDefaultAuthor = DefaultAuthorCheckBox.Checked;
if (DefaultAuthorCheckBox.Checked)

View File

@ -27,11 +27,7 @@ namespace BizHawk.Client.EmuHawk
public string Message
{
get
{
return PromptLabel.Text;
}
get => PromptLabel.Text;
set
{
PromptLabel.Text = value ?? "";
@ -41,14 +37,11 @@ namespace BizHawk.Client.EmuHawk
public string InitialValue
{
get { return PromptBox.Text; }
set { PromptBox.Text = value ?? ""; }
get => PromptBox.Text;
set => PromptBox.Text = value ?? "";
}
public string PromptText
{
get { return PromptBox.Text ?? ""; }
}
public string PromptText => PromptBox.Text ?? "";
private void InputPrompt_Load(object sender, EventArgs e)
{

View File

@ -174,7 +174,7 @@ namespace BizHawk.Client.EmuHawk
.Select(kvp => kvp.Key);
var customSettings = Global.Config.CustomToolSettings
.Where(list => list.Value.Any(kvp => kvp.Value is ToolDialogSettings && ((ToolDialogSettings)kvp.Value).AutoLoad))
.Where(list => list.Value.Any(kvp => kvp.Value is ToolDialogSettings settings && settings.AutoLoad))
.Select(kvp => kvp.Key);
var typeNames = genericSettings.Concat(customSettings);
@ -194,7 +194,7 @@ namespace BizHawk.Client.EmuHawk
}
}
private static void RefreshSettings(Form form, ToolStripItemCollection menu, ToolDialogSettings settings, int idx)
private void RefreshSettings(Form form, ToolStripItemCollection menu, ToolDialogSettings settings, int idx)
{
((ToolStripMenuItem)menu[idx + 0]).Checked = settings.SaveWindowPosition;
((ToolStripMenuItem)menu[idx + 1]).Checked = settings.TopMost;
@ -204,7 +204,7 @@ namespace BizHawk.Client.EmuHawk
form.TopMost = settings.TopMost;
// do we need to do this OnShown() as well?
form.Owner = settings.FloatingWindow ? null : GlobalWin.MainForm;
form.Owner = settings.FloatingWindow ? null : _owner;
}
private void AttachSettingHooks(IToolFormAutoConfig tool, ToolDialogSettings settings)
@ -492,7 +492,7 @@ namespace BizHawk.Client.EmuHawk
public void Restart()
{
// If Cheat tool is loaded, restarting will restart the list too anyway
if (!GlobalWin.Tools.Has<Cheats>())
if (!Has<Cheats>())
{
Global.CheatList.NewList(GenerateDefaultCheatFilename(), autosave: true);
}
@ -689,7 +689,7 @@ namespace BizHawk.Client.EmuHawk
LuaConsole.ResumeScripts(true);
}
GlobalWin.Tools.UpdateAfter();
UpdateAfter();
if (Has<LuaConsole>())
{
@ -803,7 +803,7 @@ namespace BizHawk.Client.EmuHawk
get
{
// prevent nasty silent corruption
if (!GlobalWin.Tools.IsLoaded<TAStudio>())
if (!IsLoaded<TAStudio>())
{
System.Diagnostics.Debug.Fail("TAStudio does not exist!");
}
@ -841,9 +841,9 @@ namespace BizHawk.Client.EmuHawk
public void LoadGameGenieEc()
{
if (GlobalWin.Tools.IsAvailable<GameShark>())
if (IsAvailable<GameShark>())
{
GlobalWin.Tools.Load<GameShark>();
Load<GameShark>();
}
}