Various code cleanups on some config dialogs

This commit is contained in:
adelikat 2013-11-28 01:33:38 +00:00
parent ad39eb36f4
commit e6d85a4087
15 changed files with 1363 additions and 1466 deletions

View File

@ -1874,7 +1874,7 @@ namespace BizHawk.Client.EmuHawk
sub = new Subtitle { Frame = Global.Emulator.Frame }; sub = new Subtitle { Frame = Global.Emulator.Frame };
} }
subForm.sub = sub; subForm.Sub = sub;
if (subForm.ShowDialog() == DialogResult.OK) if (subForm.ShowDialog() == DialogResult.OK)
{ {
@ -1883,7 +1883,7 @@ namespace BizHawk.Client.EmuHawk
Global.MovieSession.Movie.Subtitles.RemoveAt(index); Global.MovieSession.Movie.Subtitles.RemoveAt(index);
} }
Global.MovieSession.Movie.Subtitles.Add(subForm.sub); Global.MovieSession.Movie.Subtitles.Add(subForm.Sub);
} }
} }

View File

@ -1,10 +1,4 @@
using System; using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms; using System.Windows.Forms;
using BizHawk.Client.Common; using BizHawk.Client.Common;
@ -21,18 +15,30 @@ namespace BizHawk.Client.EmuHawk
private void AutofireConfig_Load(object sender, EventArgs e) private void AutofireConfig_Load(object sender, EventArgs e)
{ {
if (Global.Config.AutofireOn < OnNumeric.Minimum) if (Global.Config.AutofireOn < OnNumeric.Minimum)
{
OnNumeric.Value = OnNumeric.Minimum; OnNumeric.Value = OnNumeric.Minimum;
}
else if (Global.Config.AutofireOn > OnNumeric.Maximum) else if (Global.Config.AutofireOn > OnNumeric.Maximum)
{
OnNumeric.Value = OnNumeric.Maximum; OnNumeric.Value = OnNumeric.Maximum;
}
else else
{
OnNumeric.Value = Global.Config.AutofireOn; OnNumeric.Value = Global.Config.AutofireOn;
}
if (Global.Config.AutofireOff < OffNumeric.Minimum) if (Global.Config.AutofireOff < OffNumeric.Minimum)
{
OffNumeric.Value = OffNumeric.Minimum; OffNumeric.Value = OffNumeric.Minimum;
}
else if (Global.Config.AutofireOff > OffNumeric.Maximum) else if (Global.Config.AutofireOff > OffNumeric.Maximum)
{
OffNumeric.Value = OffNumeric.Maximum; OffNumeric.Value = OffNumeric.Maximum;
}
else else
{
OffNumeric.Value = Global.Config.AutofireOff; OffNumeric.Value = Global.Config.AutofireOff;
}
LagFrameCheck.Checked = Global.Config.AutofireLagFrames; LagFrameCheck.Checked = Global.Config.AutofireLagFrames;
} }
@ -45,13 +51,13 @@ namespace BizHawk.Client.EmuHawk
Global.AutofireStickyXORAdapter.SetOnOffPatternFromConfig(); Global.AutofireStickyXORAdapter.SetOnOffPatternFromConfig();
GlobalWin.OSD.AddMessage("Autofire settings saved"); GlobalWin.OSD.AddMessage("Autofire settings saved");
this.Close(); Close();
} }
private void Cancel_Click(object sender, EventArgs e) private void Cancel_Click(object sender, EventArgs e)
{ {
GlobalWin.OSD.AddMessage("Autofire config aborted"); GlobalWin.OSD.AddMessage("Autofire config aborted");
this.Close(); Close();
} }
} }
} }

View File

@ -54,36 +54,39 @@ namespace BizHawk.Client.EmuHawk
return cp; return cp;
} }
private Control CreateAnalogPanel(Dictionary<string, Config.AnalogBind> settings, List<string> buttons, Size size) private static Control CreateAnalogPanel(Dictionary<string, Config.AnalogBind> settings, List<string> buttons, Size size)
{ {
var acp = new AnalogBindPanel(settings, buttons) { Dock = DockStyle.Fill }; return new AnalogBindPanel(settings, buttons) { Dock = DockStyle.Fill };
return acp;
} }
static void LoadToPanel<T>(Control dest, string ControllerName, IEnumerable<string> ControllerButtons, Dictionary<string, Dictionary<string, T>> settingsblock, T defaultvalue, PanelCreator<T> createpanel) static void LoadToPanel<T>(Control dest, string controllerName, IEnumerable<string> controllerButtons, IDictionary<string, Dictionary<string, T>> settingsblock, T defaultvalue, PanelCreator<T> createpanel)
{ {
Dictionary<string, T> settings; Dictionary<string, T> settings;
if (!settingsblock.TryGetValue(ControllerName, out settings)) if (!settingsblock.TryGetValue(controllerName, out settings))
{ {
settings = new Dictionary<string, T>(); settings = new Dictionary<string, T>();
settingsblock[ControllerName] = settings; settingsblock[controllerName] = settings;
} }
// check to make sure that the settings object has all of the appropriate boolbuttons // check to make sure that the settings object has all of the appropriate boolbuttons
foreach (string button in ControllerButtons) foreach (var button in controllerButtons)
{ {
if (!settings.Keys.Contains(button)) if (!settings.Keys.Contains(button))
settings[button] = defaultvalue; settings[button] = defaultvalue;
} }
if (settings.Keys.Count == 0) if (settings.Keys.Count == 0)
{
return; return;
}
// split the list of all settings into buckets by player number // split the list of all settings into buckets by player number
List<string>[] buckets = new List<string>[MAXPLAYERS + 1]; var buckets = new List<string>[MAXPLAYERS + 1];
for (int i = 0; i < buckets.Length; i++) for (int i = 0; i < buckets.Length; i++)
{
buckets[i] = new List<string>(); buckets[i] = new List<string>();
}
foreach (string button in settings.Keys) foreach (var button in settings.Keys)
{ {
int i; int i;
for (i = 1; i <= MAXPLAYERS; i++) for (i = 1; i <= MAXPLAYERS; i++)
@ -118,29 +121,21 @@ namespace BizHawk.Client.EmuHawk
} }
if (buckets[0].Count > 0) if (buckets[0].Count > 0)
{ {
if (Global.Emulator.SystemId == "C64") //This is a kludge, if there starts to be more exceptions to this pattern, we will need a more robust solution tt.TabPages.Add(Global.Emulator.SystemId == "C64" ? "Keyboard" : "Console");
{
tt.TabPages.Add("Keyboard");
}
else
{
tt.TabPages.Add("Console");
}
tt.TabPages[pageidx].Controls.Add(createpanel(settings, buckets[0], tt.Size)); tt.TabPages[pageidx].Controls.Add(createpanel(settings, buckets[0], tt.Size));
} }
} }
} }
private readonly ControllerDefinition the_definition; private readonly ControllerDefinition _theDefinition;
public ControllerConfig(ControllerDefinition def) public ControllerConfig(ControllerDefinition def)
: this() : this()
{ {
the_definition = def; _theDefinition = def;
SuspendLayout(); SuspendLayout();
LoadPanels(Global.Config); LoadPanels(Global.Config);
Text = def.Name + " Configuration";
checkBoxUDLR.Checked = Global.Config.AllowUD_LR; checkBoxUDLR.Checked = Global.Config.AllowUD_LR;
checkBoxAutoTab.Checked = Global.Config.InputConfigAutoTab; checkBoxAutoTab.Checked = Global.Config.InputConfigAutoTab;
@ -154,13 +149,13 @@ namespace BizHawk.Client.EmuHawk
ResumeLayout(); ResumeLayout();
} }
private void LoadPanels(Dictionary<string, Dictionary<string, string>> normal, private void LoadPanels(IDictionary<string, Dictionary<string, string>> normal,
Dictionary<string, Dictionary<string, string>> autofire, IDictionary<string, Dictionary<string, string>> autofire,
Dictionary<string, Dictionary<string, Config.AnalogBind>> analog) IDictionary<string, Dictionary<string, Config.AnalogBind>> analog)
{ {
LoadToPanel(tabPage1, the_definition.Name, the_definition.BoolButtons, normal, "", CreateNormalPanel); LoadToPanel(tabPage1, _theDefinition.Name, _theDefinition.BoolButtons, normal, "", CreateNormalPanel);
LoadToPanel(tabPage2, the_definition.Name, the_definition.BoolButtons, autofire, "", CreateNormalPanel); LoadToPanel(tabPage2, _theDefinition.Name, _theDefinition.BoolButtons, autofire, "", CreateNormalPanel);
LoadToPanel(tabPage3, the_definition.Name, the_definition.FloatControls, analog, new Config.AnalogBind("", 1.0f, 0.1f), CreateAnalogPanel); LoadToPanel(tabPage3, _theDefinition.Name, _theDefinition.FloatControls, analog, new Config.AnalogBind("", 1.0f, 0.1f), CreateAnalogPanel);
if (tabPage3.Controls.Count == 0) if (tabPage3.Controls.Count == 0)
{ {
@ -178,20 +173,22 @@ namespace BizHawk.Client.EmuHawk
LoadPanels(c.AllTrollers, c.AllTrollersAutoFire, c.AllTrollersAnalog); LoadPanels(c.AllTrollers, c.AllTrollersAutoFire, c.AllTrollersAnalog);
} }
void SetControllerPicture(string ControlName) void SetControllerPicture(string controlName)
{ {
Bitmap bmp; Bitmap bmp;
if (!ControllerImages.TryGetValue(ControlName, out bmp)) if (!ControllerImages.TryGetValue(controlName, out bmp))
{
bmp = Properties.Resources.Help; bmp = Properties.Resources.Help;
}
pictureBox1.Image = bmp; pictureBox1.Image = bmp;
pictureBox1.Size = bmp.Size; pictureBox1.Size = bmp.Size;
tableLayoutPanel1.ColumnStyles[1].Width = bmp.Width; tableLayoutPanel1.ColumnStyles[1].Width = bmp.Width;
//Uberhack //Uberhack
if (ControlName == "Commodore 64 Controller") if (controlName == "Commodore 64 Controller")
{ {
PictureBox pictureBox2 = new PictureBox var pictureBox2 = new PictureBox
{ {
Image = Properties.Resources.C64Keyboard, Image = Properties.Resources.C64Keyboard,
Size = Properties.Resources.C64Keyboard.Size Size = Properties.Resources.C64Keyboard.Size
@ -213,27 +210,33 @@ namespace BizHawk.Client.EmuHawk
static void SetAutoTab(Control c, bool value) static void SetAutoTab(Control c, bool value)
{ {
if (c is ControllerConfigPanel) if (c is ControllerConfigPanel)
{
(c as ControllerConfigPanel).SetAutoTab(value); (c as ControllerConfigPanel).SetAutoTab(value);
}
else if (c is AnalogBindPanel) else if (c is AnalogBindPanel)
{ {
// TODO // TODO
} }
else if (c.HasChildren) else if (c.HasChildren)
{
foreach (Control cc in c.Controls) foreach (Control cc in c.Controls)
{
SetAutoTab(cc, value); SetAutoTab(cc, value);
} }
}
}
void Save() void Save()
{ {
ActOnControlCollection<ControllerConfigPanel>(tabPage1, c => c.Save(Global.Config.AllTrollers[the_definition.Name])); ActOnControlCollection<ControllerConfigPanel>(tabPage1, c => c.Save(Global.Config.AllTrollers[_theDefinition.Name]));
ActOnControlCollection<ControllerConfigPanel>(tabPage2, c => c.Save(Global.Config.AllTrollersAutoFire[the_definition.Name])); ActOnControlCollection<ControllerConfigPanel>(tabPage2, c => c.Save(Global.Config.AllTrollersAutoFire[_theDefinition.Name]));
ActOnControlCollection<AnalogBindPanel>(tabPage3, c => c.Save(Global.Config.AllTrollersAnalog[the_definition.Name])); ActOnControlCollection<AnalogBindPanel>(tabPage3, c => c.Save(Global.Config.AllTrollersAnalog[_theDefinition.Name]));
} }
void SaveToDefaults(ControlDefaults cd) void SaveToDefaults(ControlDefaults cd)
{ {
ActOnControlCollection<ControllerConfigPanel>(tabPage1, c => c.Save(cd.AllTrollers[the_definition.Name])); ActOnControlCollection<ControllerConfigPanel>(tabPage1, c => c.Save(cd.AllTrollers[_theDefinition.Name]));
ActOnControlCollection<ControllerConfigPanel>(tabPage2, c => c.Save(cd.AllTrollersAutoFire[the_definition.Name])); ActOnControlCollection<ControllerConfigPanel>(tabPage2, c => c.Save(cd.AllTrollersAutoFire[_theDefinition.Name]));
ActOnControlCollection<AnalogBindPanel>(tabPage3, c => c.Save(cd.AllTrollersAnalog[the_definition.Name])); ActOnControlCollection<AnalogBindPanel>(tabPage3, c => c.Save(cd.AllTrollersAnalog[_theDefinition.Name]));
} }
static void ActOnControlCollection<T>(Control c, Action<T> proc) static void ActOnControlCollection<T>(Control c, Action<T> proc)
@ -275,10 +278,10 @@ namespace BizHawk.Client.EmuHawk
private void NewControllerConfig_Load(object sender, EventArgs e) private void NewControllerConfig_Load(object sender, EventArgs e)
{ {
Text = _theDefinition.Name + " Configuration";
} }
private TabControl GetTabControl(IEnumerable controls) private static TabControl GetTabControl(IEnumerable controls)
{ {
if (controls != null) if (controls != null)
{ {
@ -294,10 +297,10 @@ namespace BizHawk.Client.EmuHawk
{ {
tabControl1.SuspendLayout(); tabControl1.SuspendLayout();
string wasTabbedMain = tabControl1.SelectedTab.Name; var wasTabbedMain = tabControl1.SelectedTab.Name;
TabControl tb1 = GetTabControl(tabPage1.Controls); var tb1 = GetTabControl(tabPage1.Controls);
TabControl tb2 = GetTabControl(tabPage2.Controls); var tb2 = GetTabControl(tabPage2.Controls);
TabControl tb3 = GetTabControl(tabPage3.Controls); var tb3 = GetTabControl(tabPage3.Controls);
int? wasTabbedPage1 = null; int? wasTabbedPage1 = null;
int? wasTabbedPage2 = null; int? wasTabbedPage2 = null;
int? wasTabbedPage3 = null; int? wasTabbedPage3 = null;
@ -313,7 +316,7 @@ namespace BizHawk.Client.EmuHawk
// load panels directly from the default config. // load panels directly from the default config.
// this means that the changes are NOT committed. so "Cancel" works right and you // this means that the changes are NOT committed. so "Cancel" works right and you
// still have to hit OK at the end. // still have to hit OK at the end.
ControlDefaults cd = new ControlDefaults(); var cd = new ControlDefaults();
cd = ConfigService.Load(Config.ControlDefaultPath, cd); cd = ConfigService.Load(Config.ControlDefaultPath, cd);
LoadPanels(cd); LoadPanels(cd);
@ -321,7 +324,7 @@ namespace BizHawk.Client.EmuHawk
if (wasTabbedPage1.HasValue) if (wasTabbedPage1.HasValue)
{ {
TabControl newTb1 = GetTabControl(tabPage1.Controls); var newTb1 = GetTabControl(tabPage1.Controls);
if (newTb1 != null) if (newTb1 != null)
{ {
newTb1.SelectTab(wasTabbedPage1.Value); newTb1.SelectTab(wasTabbedPage1.Value);
@ -330,7 +333,7 @@ namespace BizHawk.Client.EmuHawk
if (wasTabbedPage2.HasValue) if (wasTabbedPage2.HasValue)
{ {
TabControl newTb2 = GetTabControl(tabPage2.Controls); var newTb2 = GetTabControl(tabPage2.Controls);
if (newTb2 != null) if (newTb2 != null)
{ {
newTb2.SelectTab(wasTabbedPage2.Value); newTb2.SelectTab(wasTabbedPage2.Value);
@ -339,7 +342,7 @@ namespace BizHawk.Client.EmuHawk
if (wasTabbedPage3.HasValue) if (wasTabbedPage3.HasValue)
{ {
TabControl newTb3 = GetTabControl(tabPage3.Controls); var newTb3 = GetTabControl(tabPage3.Controls);
if (newTb3 != null) if (newTb3 != null)
{ {
newTb3.SelectTab(wasTabbedPage3.Value); newTb3.SelectTab(wasTabbedPage3.Value);
@ -354,11 +357,11 @@ namespace BizHawk.Client.EmuHawk
var result = MessageBox.Show(this, "OK to overwrite defaults for current control scheme?", "Save Defaults", MessageBoxButtons.YesNo); var result = MessageBox.Show(this, "OK to overwrite defaults for current control scheme?", "Save Defaults", MessageBoxButtons.YesNo);
if (result == DialogResult.Yes) if (result == DialogResult.Yes)
{ {
ControlDefaults cd = new ControlDefaults(); var cd = new ControlDefaults();
cd = ConfigService.Load(Config.ControlDefaultPath, cd); cd = ConfigService.Load(Config.ControlDefaultPath, cd);
cd.AllTrollers[the_definition.Name] = new Dictionary<string, string>(); cd.AllTrollers[_theDefinition.Name] = new Dictionary<string, string>();
cd.AllTrollersAutoFire[the_definition.Name] = new Dictionary<string, string>(); cd.AllTrollersAutoFire[_theDefinition.Name] = new Dictionary<string, string>();
cd.AllTrollersAnalog[the_definition.Name] = new Dictionary<string, Config.AnalogBind>(); cd.AllTrollersAnalog[_theDefinition.Name] = new Dictionary<string, Config.AnalogBind>();
SaveToDefaults(cd); SaveToDefaults(cd);

View File

@ -1,10 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing; using System.Drawing;
using System.Linq; using System.Linq;
using System.Text;
using System.Windows.Forms; using System.Windows.Forms;
using BizHawk.Client.Common; using BizHawk.Client.Common;
@ -20,7 +17,7 @@ namespace BizHawk.Client.EmuHawk
private void NewHotkeyWindow_Load(object sender, EventArgs e) private void NewHotkeyWindow_Load(object sender, EventArgs e)
{ {
AutoCompleteStringCollection source = new AutoCompleteStringCollection(); var source = new AutoCompleteStringCollection();
source.AddRange(Global.Config.HotkeyBindings.Select(x => x.DisplayName).ToArray()); source.AddRange(Global.Config.HotkeyBindings.Select(x => x.DisplayName).ToArray());
SearchBox.AutoCompleteCustomSource = source; SearchBox.AutoCompleteCustomSource = source;
@ -59,21 +56,21 @@ namespace BizHawk.Client.EmuHawk
{ {
Global.Config.HotkeyConfigAutoTab = AutoTabCheckBox.Checked; Global.Config.HotkeyConfigAutoTab = AutoTabCheckBox.Checked;
foreach (InputWidget w in _inputWidgets) foreach (var w in InputWidgets)
{ {
var b = Global.Config.HotkeyBindings.FirstOrDefault(x => x.DisplayName == w.WidgetName); var b = Global.Config.HotkeyBindings.FirstOrDefault(x => x.DisplayName == w.WidgetName);
b.Bindings = w.Text; b.Bindings = w.Text;
} }
} }
private List<InputWidget> _inputWidgets private IEnumerable<InputWidget> InputWidgets
{ {
get get
{ {
List<InputWidget> widgets = new List<InputWidget>(); var widgets = new List<InputWidget>();
for (int x = 0; x < HotkeyTabControl.TabPages.Count; x++) for (var x = 0; x < HotkeyTabControl.TabPages.Count; x++)
{ {
for (int y = 0; y < HotkeyTabControl.TabPages[x].Controls.Count; y++) for (var y = 0; y < HotkeyTabControl.TabPages[x].Controls.Count; y++)
{ {
if (HotkeyTabControl.TabPages[x].Controls[y] is InputWidget) if (HotkeyTabControl.TabPages[x].Controls[y] is InputWidget)
{ {
@ -90,35 +87,33 @@ namespace BizHawk.Client.EmuHawk
HotkeyTabControl.TabPages.Clear(); HotkeyTabControl.TabPages.Clear();
//Buckets //Buckets
List<string> Tabs = Global.Config.HotkeyBindings.Select(x => x.TabGroup).Distinct().ToList(); var Tabs = Global.Config.HotkeyBindings.Select(x => x.TabGroup).Distinct().ToList();
foreach (string tab in Tabs) var _y = 14;
var _x = 6;
foreach (var tab in Tabs)
{ {
TabPage tb = new TabPage(); var tb = new TabPage {Name = tab, Text = tab};
tb.Name = tab;
tb.Text = tab;
var bindings = Global.Config.HotkeyBindings.Where(x => x.TabGroup == tab).OrderBy(x => x.Ordinal).ThenBy(x => x.DisplayName).ToList(); var bindings = Global.Config.HotkeyBindings.Where(x => x.TabGroup == tab).OrderBy(x => x.Ordinal).ThenBy(x => x.DisplayName).ToList();
int _x = 6; const int iwOffsetX = 110;
int _y = 14; const int iwOffsetY = -4;
int iw_offset_x = 110; const int iwWidth = 120;
int iw_offset_y = -4;
int iw_width = 120;
foreach (var b in bindings) foreach (var b in bindings)
{ {
Label l = new Label() var l = new Label
{ {
Text = b.DisplayName, Text = b.DisplayName,
Location = new Point(_x, _y), Location = new Point(_x, _y),
Width = iw_offset_x - 2, Width = iwOffsetX - 2,
}; };
InputWidget w = new InputWidget() var w = new InputWidget
{ {
Bindings = b.Bindings, Bindings = b.Bindings,
Location = new Point(_x + iw_offset_x, _y + iw_offset_y), Location = new Point(_x + iwOffsetX, _y + iwOffsetY),
AutoTab = AutoTabCheckBox.Checked, AutoTab = AutoTabCheckBox.Checked,
Width = iw_width, Width = iwWidth,
WidgetName = b.DisplayName, WidgetName = b.DisplayName,
}; };
@ -128,7 +123,7 @@ namespace BizHawk.Client.EmuHawk
_y += 24; _y += 24;
if (_y > HotkeyTabControl.Height - 35) if (_y > HotkeyTabControl.Height - 35)
{ {
_x += iw_offset_x + iw_width + 10; _x += iwOffsetX + iwWidth + 10;
_y = 14; _y = 14;
} }
} }
@ -139,16 +134,16 @@ namespace BizHawk.Client.EmuHawk
private void Defaults() private void Defaults()
{ {
foreach (InputWidget w in _inputWidgets) foreach (var w in InputWidgets)
{ {
var b = Global.Config.HotkeyBindings.FirstOrDefault(x => x.DisplayName == w.WidgetName); var b = Global.Config.HotkeyBindings.FirstOrDefault(x => x.DisplayName == w.WidgetName);
w.Text = b.DefaultBinding; if (b != null) w.Text = b.DefaultBinding;
} }
} }
private void SetAutoTab() private void SetAutoTab()
{ {
foreach (InputWidget w in _inputWidgets) foreach (var w in InputWidgets)
{ {
w.AutoTab = AutoTabCheckBox.Checked; w.AutoTab = AutoTabCheckBox.Checked;
} }
@ -163,16 +158,13 @@ namespace BizHawk.Client.EmuHawk
{ {
if (HotkeyTabControl.SelectedTab != null) if (HotkeyTabControl.SelectedTab != null)
{ {
foreach (Control c in HotkeyTabControl.SelectedTab.Controls) foreach (var c in HotkeyTabControl.SelectedTab.Controls.OfType<InputWidget>())
{ {
if (c is InputWidget) c.Focus();
{
(c as InputWidget).Focus();
return; return;
} }
} }
} }
}
private void SearchBox_KeyDown(object sender, KeyEventArgs e) private void SearchBox_KeyDown(object sender, KeyEventArgs e)
{ {
@ -180,14 +172,12 @@ namespace BizHawk.Client.EmuHawk
if (!e.Control && !e.Alt && !e.Shift && if (!e.Control && !e.Alt && !e.Shift &&
(e.KeyCode == Keys.Enter || e.KeyCode == Keys.Tab)) (e.KeyCode == Keys.Enter || e.KeyCode == Keys.Tab))
{ {
string user_selection = SearchBox.Text;
var b = Global.Config.HotkeyBindings.FirstOrDefault(x => x.DisplayName == SearchBox.Text); var b = Global.Config.HotkeyBindings.FirstOrDefault(x => x.DisplayName == SearchBox.Text);
//Found //Found
if (b != null) if (b != null)
{ {
InputWidget w = _inputWidgets.FirstOrDefault(x => x.WidgetName == b.DisplayName); var w = InputWidgets.FirstOrDefault(x => x.WidgetName == b.DisplayName);
if (w != null) if (w != null)
{ {
HotkeyTabControl.SelectTab((w.Parent as TabPage)); HotkeyTabControl.SelectTab((w.Parent as TabPage));

View File

@ -143,7 +143,7 @@
this.AutoholdRadio.TabStop = true; this.AutoholdRadio.TabStop = true;
this.AutoholdRadio.Text = "Autohold"; this.AutoholdRadio.Text = "Autohold";
this.AutoholdRadio.UseVisualStyleBackColor = true; this.AutoholdRadio.UseVisualStyleBackColor = true;
this.AutoholdRadio.CheckedChanged += new System.EventHandler(this.AutoholdRadio_CheckedChanged); this.AutoholdRadio.CheckedChanged += new System.EventHandler(this.MessageTypeRadio_CheckedChanged);
// //
// MultitrackLabel // MultitrackLabel
// //
@ -165,7 +165,7 @@
this.MultitrackRadio.TabStop = true; this.MultitrackRadio.TabStop = true;
this.MultitrackRadio.Text = "Multitrack"; this.MultitrackRadio.Text = "Multitrack";
this.MultitrackRadio.UseVisualStyleBackColor = true; this.MultitrackRadio.UseVisualStyleBackColor = true;
this.MultitrackRadio.CheckedChanged += new System.EventHandler(this.MultitrackRadio_CheckedChanged); this.MultitrackRadio.CheckedChanged += new System.EventHandler(this.MessageTypeRadio_CheckedChanged);
// //
// RerecLabel // RerecLabel
// //
@ -186,7 +186,7 @@
this.RerecordsRadio.TabIndex = 10; this.RerecordsRadio.TabIndex = 10;
this.RerecordsRadio.Text = "Rerecords"; this.RerecordsRadio.Text = "Rerecords";
this.RerecordsRadio.UseVisualStyleBackColor = true; this.RerecordsRadio.UseVisualStyleBackColor = true;
this.RerecordsRadio.CheckedChanged += new System.EventHandler(this.MessagesRadio_CheckedChanged); this.RerecordsRadio.CheckedChanged += new System.EventHandler(this.MessageTypeRadio_CheckedChanged);
// //
// MessLabel // MessLabel
// //
@ -247,7 +247,7 @@
this.MessagesRadio.TabIndex = 4; this.MessagesRadio.TabIndex = 4;
this.MessagesRadio.Text = "Messages"; this.MessagesRadio.Text = "Messages";
this.MessagesRadio.UseVisualStyleBackColor = true; this.MessagesRadio.UseVisualStyleBackColor = true;
this.MessagesRadio.CheckedChanged += new System.EventHandler(this.MessagesRadio_CheckedChanged); this.MessagesRadio.CheckedChanged += new System.EventHandler(this.MessageTypeRadio_CheckedChanged);
// //
// InputDisplayRadio // InputDisplayRadio
// //
@ -258,7 +258,7 @@
this.InputDisplayRadio.TabIndex = 3; this.InputDisplayRadio.TabIndex = 3;
this.InputDisplayRadio.Text = "Input Display"; this.InputDisplayRadio.Text = "Input Display";
this.InputDisplayRadio.UseVisualStyleBackColor = true; this.InputDisplayRadio.UseVisualStyleBackColor = true;
this.InputDisplayRadio.CheckedChanged += new System.EventHandler(this.InputDisplayRadio_CheckedChanged); this.InputDisplayRadio.CheckedChanged += new System.EventHandler(this.MessageTypeRadio_CheckedChanged);
// //
// LagCounterRadio // LagCounterRadio
// //
@ -269,7 +269,7 @@
this.LagCounterRadio.TabIndex = 2; this.LagCounterRadio.TabIndex = 2;
this.LagCounterRadio.Text = "Lag Counter"; this.LagCounterRadio.Text = "Lag Counter";
this.LagCounterRadio.UseVisualStyleBackColor = true; this.LagCounterRadio.UseVisualStyleBackColor = true;
this.LagCounterRadio.CheckedChanged += new System.EventHandler(this.LagCounterRadio_CheckedChanged); this.LagCounterRadio.CheckedChanged += new System.EventHandler(this.MessageTypeRadio_CheckedChanged);
// //
// FrameCounterRadio // FrameCounterRadio
// //
@ -280,7 +280,7 @@
this.FrameCounterRadio.TabIndex = 1; this.FrameCounterRadio.TabIndex = 1;
this.FrameCounterRadio.Text = "Frame counter"; this.FrameCounterRadio.Text = "Frame counter";
this.FrameCounterRadio.UseVisualStyleBackColor = true; this.FrameCounterRadio.UseVisualStyleBackColor = true;
this.FrameCounterRadio.CheckedChanged += new System.EventHandler(this.FrameCounterRadio_CheckedChanged); this.FrameCounterRadio.CheckedChanged += new System.EventHandler(this.MessageTypeRadio_CheckedChanged);
// //
// FPSRadio // FPSRadio
// //
@ -293,7 +293,7 @@
this.FPSRadio.TabStop = true; this.FPSRadio.TabStop = true;
this.FPSRadio.Text = "Fps"; this.FPSRadio.Text = "Fps";
this.FPSRadio.UseVisualStyleBackColor = true; this.FPSRadio.UseVisualStyleBackColor = true;
this.FPSRadio.CheckedChanged += new System.EventHandler(this.FPSRadio_CheckedChanged); this.FPSRadio.CheckedChanged += new System.EventHandler(this.MessageTypeRadio_CheckedChanged);
// //
// groupBox2 // groupBox2
// //

View File

@ -1,10 +1,5 @@
using System; using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing; using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms; using System.Windows.Forms;
using BizHawk.Client.Common; using BizHawk.Client.Common;
@ -13,43 +8,41 @@ namespace BizHawk.Client.EmuHawk
{ {
public partial class MessageConfig : Form public partial class MessageConfig : Form
{ {
int DispFPSx = Global.Config.DispFPSx; private int _dispFpSx = Global.Config.DispFPSx;
int DispFPSy = Global.Config.DispFPSy; private int _dispFpSy = Global.Config.DispFPSy;
int DispFrameCx = Global.Config.DispFrameCx; private int _dispFrameCx = Global.Config.DispFrameCx;
int DispFrameCy = Global.Config.DispFrameCy; private int _dispFrameCy = Global.Config.DispFrameCy;
int DispLagx = Global.Config.DispLagx; private int _dispLagx = Global.Config.DispLagx;
int DispLagy = Global.Config.DispLagy; private int _dispLagy = Global.Config.DispLagy;
int DispInpx = Global.Config.DispInpx; private int _dispInpx = Global.Config.DispInpx;
int DispInpy = Global.Config.DispInpy; private int _dispInpy = Global.Config.DispInpy;
int DispRerecx = Global.Config.DispRecx; private int _lastInputColor = Global.Config.LastInputColor;
int DispRerecy = Global.Config.DispRecy; private int _dispRecx = Global.Config.DispRecx;
int LastInputColor = Global.Config.LastInputColor; private int _dispRecy = Global.Config.DispRecy;
int DispRecx = Global.Config.DispRecx; private int _dispMultix = Global.Config.DispMultix;
int DispRecy = Global.Config.DispRecy; private int _dispMultiy = Global.Config.DispMultiy;
int DispMultix = Global.Config.DispMultix; private int _dispMessagex = Global.Config.DispMessagex;
int DispMultiy = Global.Config.DispMultiy; private int _dispMessagey = Global.Config.DispMessagey;
int DispMessagex = Global.Config.DispMessagex; private int _dispAutoholdx = Global.Config.DispAutoholdx;
int DispMessagey = Global.Config.DispMessagey; private int _dispAutoholdy = Global.Config.DispAutoholdy;
int DispAutoholdx = Global.Config.DispAutoholdx;
int DispAutoholdy = Global.Config.DispAutoholdy;
int MessageColor = Global.Config.MessagesColor; private int _messageColor = Global.Config.MessagesColor;
int AlertColor = Global.Config.AlertMessageColor; private int _alertColor = Global.Config.AlertMessageColor;
int MovieInput = Global.Config.MovieInput; private int _movieInput = Global.Config.MovieInput;
int DispFPSanchor = Global.Config.DispFPSanchor; private int _dispFpSanchor = Global.Config.DispFPSanchor;
int DispFrameanchor = Global.Config.DispFrameanchor; private int _dispFrameanchor = Global.Config.DispFrameanchor;
int DispLaganchor = Global.Config.DispLaganchor; private int _dispLaganchor = Global.Config.DispLaganchor;
int DispInputanchor = Global.Config.DispInpanchor; private int _dispInputanchor = Global.Config.DispInpanchor;
int DispRecanchor = Global.Config.DispRecanchor; private int _dispRecanchor = Global.Config.DispRecanchor;
int DispMultiAnchor = Global.Config.DispMultianchor; private int _dispMultiAnchor = Global.Config.DispMultianchor;
int DispMessageAnchor = Global.Config.DispMessageanchor; private int _dispMessageAnchor = Global.Config.DispMessageanchor;
int DispAutoholdAnchor = Global.Config.DispAutoholdanchor; private int _dispAutoholdAnchor = Global.Config.DispAutoholdanchor;
public Brush brush = Brushes.Black; private readonly Brush _brush = Brushes.Black;
int px = 0; private int _px;
int py = 0; private int _py;
bool mousedown = false; private bool _mousedown;
public MessageConfig() public MessageConfig()
{ {
@ -59,10 +52,10 @@ namespace BizHawk.Client.EmuHawk
private void MessageConfig_Load(object sender, EventArgs e) private void MessageConfig_Load(object sender, EventArgs e)
{ {
SetMaxXY(); SetMaxXY();
MessageColorDialog.Color = Color.FromArgb(MessageColor); MessageColorDialog.Color = Color.FromArgb(_messageColor);
AlertColorDialog.Color = Color.FromArgb(AlertColor); AlertColorDialog.Color = Color.FromArgb(_alertColor);
LInputColorDialog.Color = Color.FromArgb(LastInputColor); LInputColorDialog.Color = Color.FromArgb(_lastInputColor);
MovieInputColorDialog.Color = Color.FromArgb(MovieInput); MovieInputColorDialog.Color = Color.FromArgb(_movieInput);
SetColorBox(); SetColorBox();
SetPositionInfo(); SetPositionInfo();
StackMessagesCheckbox.Checked = Global.Config.StackOSDMessages; StackMessagesCheckbox.Checked = Global.Config.StackOSDMessages;
@ -76,30 +69,34 @@ namespace BizHawk.Client.EmuHawk
int width; int width;
if (Global.Emulator.VideoProvider.BufferWidth > 128) if (Global.Emulator.VideoProvider.BufferWidth > 128)
{
width = Global.Emulator.VideoProvider.BufferWidth + 44; width = Global.Emulator.VideoProvider.BufferWidth + 44;
}
else else
{
width = 128 + 44; width = 128 + 44;
}
PositionGroupBox.Size = new Size(width, Global.Emulator.VideoProvider.BufferHeight + 52); PositionGroupBox.Size = new Size(width, Global.Emulator.VideoProvider.BufferHeight + 52);
} }
private void SetColorBox() private void SetColorBox()
{ {
MessageColor = MessageColorDialog.Color.ToArgb(); _messageColor = MessageColorDialog.Color.ToArgb();
ColorPanel.BackColor = MessageColorDialog.Color; ColorPanel.BackColor = MessageColorDialog.Color;
ColorText.Text = String.Format("{0:X8}", MessageColor); ColorText.Text = String.Format("{0:X8}", _messageColor);
AlertColor = AlertColorDialog.Color.ToArgb(); _alertColor = AlertColorDialog.Color.ToArgb();
AlertColorPanel.BackColor = AlertColorDialog.Color; AlertColorPanel.BackColor = AlertColorDialog.Color;
AlertColorText.Text = String.Format("{0:X8}", AlertColor); AlertColorText.Text = String.Format("{0:X8}", _alertColor);
LastInputColor = LInputColorDialog.Color.ToArgb(); _lastInputColor = LInputColorDialog.Color.ToArgb();
LInputColorPanel.BackColor = LInputColorDialog.Color; LInputColorPanel.BackColor = LInputColorDialog.Color;
LInputText.Text = String.Format("{0:X8}", LastInputColor); LInputText.Text = String.Format("{0:X8}", _lastInputColor);
MovieInput = MovieInputColorDialog.Color.ToArgb(); _movieInput = MovieInputColorDialog.Color.ToArgb();
MovieInputColor.BackColor = MovieInputColorDialog.Color; MovieInputColor.BackColor = MovieInputColorDialog.Color;
MovieInputText.Text = String.Format("{0:X8}", MovieInput); MovieInputText.Text = String.Format("{0:X8}", _movieInput);
} }
private void SetAnchorRadio(int anchor) private void SetAnchorRadio(int anchor)
@ -122,67 +119,67 @@ namespace BizHawk.Client.EmuHawk
{ {
if (FPSRadio.Checked) if (FPSRadio.Checked)
{ {
XNumeric.Value = DispFPSx; XNumeric.Value = _dispFpSx;
YNumeric.Value = DispFPSy; YNumeric.Value = _dispFpSy;
px = DispFPSx; _px = _dispFpSx;
py = DispFPSy; _py = _dispFpSy;
SetAnchorRadio(DispFPSanchor); SetAnchorRadio(_dispFpSanchor);
} }
else if (FrameCounterRadio.Checked) else if (FrameCounterRadio.Checked)
{ {
XNumeric.Value = DispFrameCx; XNumeric.Value = _dispFrameCx;
YNumeric.Value = DispFrameCy; YNumeric.Value = _dispFrameCy;
px = DispFrameCx; _px = _dispFrameCx;
py = DispFrameCy; _py = _dispFrameCy;
SetAnchorRadio(DispFrameanchor); SetAnchorRadio(_dispFrameanchor);
} }
else if (LagCounterRadio.Checked) else if (LagCounterRadio.Checked)
{ {
XNumeric.Value = DispLagx; XNumeric.Value = _dispLagx;
YNumeric.Value = DispLagy; YNumeric.Value = _dispLagy;
px = DispLagx; _px = _dispLagx;
py = DispLagy; _py = _dispLagy;
SetAnchorRadio(DispLaganchor); SetAnchorRadio(_dispLaganchor);
} }
else if (InputDisplayRadio.Checked) else if (InputDisplayRadio.Checked)
{ {
XNumeric.Value = DispInpx; XNumeric.Value = _dispInpx;
XNumeric.Value = DispInpy; XNumeric.Value = _dispInpy;
px = DispInpx; _px = _dispInpx;
py = DispInpy; _py = _dispInpy;
SetAnchorRadio(DispInputanchor); SetAnchorRadio(_dispInputanchor);
} }
else if (MessagesRadio.Checked) else if (MessagesRadio.Checked)
{ {
XNumeric.Value = DispMessagex; XNumeric.Value = _dispMessagex;
YNumeric.Value = DispMessagey; YNumeric.Value = _dispMessagey;
px = DispMessagex; _px = _dispMessagex;
py = DispMessagey; _py = _dispMessagey;
SetAnchorRadio(DispMessageAnchor); SetAnchorRadio(_dispMessageAnchor);
} }
else if (RerecordsRadio.Checked) else if (RerecordsRadio.Checked)
{ {
XNumeric.Value = DispRecx; XNumeric.Value = _dispRecx;
YNumeric.Value = DispRecy; YNumeric.Value = _dispRecy;
px = DispRecx; _px = _dispRecx;
py = DispRecy; _py = _dispRecy;
SetAnchorRadio(DispRecanchor); SetAnchorRadio(_dispRecanchor);
} }
else if (MultitrackRadio.Checked) else if (MultitrackRadio.Checked)
{ {
XNumeric.Value = DispMultix; XNumeric.Value = _dispMultix;
YNumeric.Value = DispMultiy; YNumeric.Value = _dispMultiy;
px = DispMultix; _px = _dispMultix;
py = DispMultiy; _py = _dispMultiy;
SetAnchorRadio(DispMultiAnchor); SetAnchorRadio(_dispMultiAnchor);
} }
else if (AutoholdRadio.Checked) else if (AutoholdRadio.Checked)
{ {
XNumeric.Value = DispAutoholdx; XNumeric.Value = _dispAutoholdx;
YNumeric.Value = DispAutoholdy; YNumeric.Value = _dispAutoholdy;
px = DispAutoholdx; _px = _dispAutoholdx;
py = DispAutoholdy; _py = _dispAutoholdy;
SetAnchorRadio(DispAutoholdAnchor); SetAnchorRadio(_dispAutoholdAnchor);
} }
PositionPanel.Refresh(); PositionPanel.Refresh();
@ -193,35 +190,35 @@ namespace BizHawk.Client.EmuHawk
private void SaveSettings() private void SaveSettings()
{ {
Global.Config.DispFPSx = DispFPSx; Global.Config.DispFPSx = _dispFpSx;
Global.Config.DispFPSy = DispFPSy; Global.Config.DispFPSy = _dispFpSy;
Global.Config.DispFrameCx = DispFrameCx; Global.Config.DispFrameCx = _dispFrameCx;
Global.Config.DispFrameCy = DispFrameCy; Global.Config.DispFrameCy = _dispFrameCy;
Global.Config.DispLagx = DispLagx; Global.Config.DispLagx = _dispLagx;
Global.Config.DispLagy = DispLagy; Global.Config.DispLagy = _dispLagy;
Global.Config.DispInpx = DispInpx; Global.Config.DispInpx = _dispInpx;
Global.Config.DispInpy = DispInpy; Global.Config.DispInpy = _dispInpy;
Global.Config.DispRecx = DispRecx; Global.Config.DispRecx = _dispRecx;
Global.Config.DispRecy = DispRecy; Global.Config.DispRecy = _dispRecy;
Global.Config.DispMultix = DispMultix; Global.Config.DispMultix = _dispMultix;
Global.Config.DispMultiy = DispMultiy; Global.Config.DispMultiy = _dispMultiy;
Global.Config.DispMessagex = DispMessagex; Global.Config.DispMessagex = _dispMessagex;
Global.Config.DispMessagey = DispMessagey; Global.Config.DispMessagey = _dispMessagey;
Global.Config.DispAutoholdx = DispAutoholdx; Global.Config.DispAutoholdx = _dispAutoholdx;
Global.Config.DispAutoholdy = DispAutoholdy; Global.Config.DispAutoholdy = _dispAutoholdy;
Global.Config.MessagesColor = MessageColor; Global.Config.MessagesColor = _messageColor;
Global.Config.AlertMessageColor = AlertColor; Global.Config.AlertMessageColor = _alertColor;
Global.Config.LastInputColor = LastInputColor; Global.Config.LastInputColor = _lastInputColor;
Global.Config.MovieInput = MovieInput; Global.Config.MovieInput = _movieInput;
Global.Config.DispFPSanchor = DispFPSanchor; Global.Config.DispFPSanchor = _dispFpSanchor;
Global.Config.DispFrameanchor = DispFrameanchor; Global.Config.DispFrameanchor = _dispFrameanchor;
Global.Config.DispLaganchor = DispLaganchor; Global.Config.DispLaganchor = _dispLaganchor;
Global.Config.DispInpanchor = DispInputanchor; Global.Config.DispInpanchor = _dispInputanchor;
Global.Config.DispRecanchor = DispRecanchor; Global.Config.DispRecanchor = _dispRecanchor;
Global.Config.DispMultianchor = DispMultiAnchor; Global.Config.DispMultianchor = _dispMultiAnchor;
Global.Config.DispMessageanchor = DispMessageAnchor; Global.Config.DispMessageanchor = _dispMessageAnchor;
Global.Config.DispAutoholdanchor = DispAutoholdAnchor; Global.Config.DispAutoholdanchor = _dispAutoholdAnchor;
Global.Config.StackOSDMessages = StackMessagesCheckbox.Checked; Global.Config.StackOSDMessages = StackMessagesCheckbox.Checked;
} }
@ -230,59 +227,24 @@ namespace BizHawk.Client.EmuHawk
{ {
SaveSettings(); SaveSettings();
GlobalWin.OSD.AddMessage("Message settings saved"); GlobalWin.OSD.AddMessage("Message settings saved");
this.Close(); Close();
} }
private void FPSRadio_CheckedChanged(object sender, EventArgs e) private void MessageTypeRadio_CheckedChanged(object sender, EventArgs e)
{
SetPositionInfo();
}
private void FrameCounterRadio_CheckedChanged(object sender, EventArgs e)
{
SetPositionInfo();
}
private void LagCounterRadio_CheckedChanged(object sender, EventArgs e)
{
SetPositionInfo();
}
private void InputDisplayRadio_CheckedChanged(object sender, EventArgs e)
{
SetPositionInfo();
}
private void MessagesRadio_CheckedChanged(object sender, EventArgs e)
{
SetPositionInfo();
}
private void RerecordsRadio_CheckedChanged(object sender, EventArgs e)
{
SetPositionInfo();
}
private void MultitrackRadio_CheckedChanged(object sender, EventArgs e)
{
SetPositionInfo();
}
private void AutoholdRadio_CheckedChanged(object sender, EventArgs e)
{ {
SetPositionInfo(); SetPositionInfo();
} }
private void XNumericChange() private void XNumericChange()
{ {
px = (int)XNumeric.Value; _px = (int)XNumeric.Value;
SetPositionLabels(); SetPositionLabels();
PositionPanel.Refresh(); PositionPanel.Refresh();
} }
private void YNumericChange() private void YNumericChange()
{ {
py = (int)YNumeric.Value; _py = (int)YNumeric.Value;
SetPositionLabels(); SetPositionLabels();
PositionPanel.Refresh(); PositionPanel.Refresh();
} }
@ -290,17 +252,17 @@ namespace BizHawk.Client.EmuHawk
private void Cancel_Click(object sender, EventArgs e) private void Cancel_Click(object sender, EventArgs e)
{ {
GlobalWin.OSD.AddMessage("Message config aborted"); GlobalWin.OSD.AddMessage("Message config aborted");
this.Close(); Close();
} }
private void PositionPanel_MouseEnter(object sender, EventArgs e) private void PositionPanel_MouseEnter(object sender, EventArgs e)
{ {
this.Cursor = Cursors.Hand; Cursor = Cursors.Hand;
} }
private void PositionPanel_MouseLeave(object sender, EventArgs e) private void PositionPanel_MouseLeave(object sender, EventArgs e)
{ {
this.Cursor = Cursors.Default; Cursor = Cursors.Default;
} }
private void PositionPanel_Paint(object sender, PaintEventArgs e) private void PositionPanel_Paint(object sender, PaintEventArgs e)
@ -310,43 +272,42 @@ namespace BizHawk.Client.EmuHawk
if (TL.Checked) if (TL.Checked)
{ {
x = px; x = _px;
y = py; y = _py;
} }
else if (TR.Checked) else if (TR.Checked)
{ {
x = (int)XNumeric.Maximum - px; x = (int)XNumeric.Maximum - _px;
y = py; y = _py;
} }
else if (BL.Checked) else if (BL.Checked)
{ {
x = px; x = _px;
y = (int)YNumeric.Maximum - py; y = (int)YNumeric.Maximum - _py;
} }
else if (BR.Checked) else if (BR.Checked)
{ {
x = (int)XNumeric.Maximum - px; x = (int)XNumeric.Maximum - _px;
y = (int)YNumeric.Maximum - py; y = (int)YNumeric.Maximum - _py;
} }
Pen p = new Pen(brush); var p = new Pen(_brush);
e.Graphics.DrawLine(p, new Point(x, y), new Point(x + 8, y + 8)); e.Graphics.DrawLine(p, new Point(x, y), new Point(x + 8, y + 8));
e.Graphics.DrawLine(p, new Point(x + 8, y), new Point(x, y + 8)); e.Graphics.DrawLine(p, new Point(x + 8, y), new Point(x, y + 8));
Rectangle rect = new Rectangle(x, y, 8, 8); e.Graphics.DrawRectangle(p, new Rectangle(x, y, 8, 8));
e.Graphics.DrawRectangle(p, rect);
} }
private void PositionPanel_MouseDown(object sender, MouseEventArgs e) private void PositionPanel_MouseDown(object sender, MouseEventArgs e)
{ {
this.Cursor = Cursors.Arrow; Cursor = Cursors.Arrow;
mousedown = true; _mousedown = true;
SetNewPosition(e.X, e.Y); SetNewPosition(e.X, e.Y);
} }
private void PositionPanel_MouseUp(object sender, MouseEventArgs e) private void PositionPanel_MouseUp(object sender, MouseEventArgs e)
{ {
this.Cursor = Cursors.Hand; Cursor = Cursors.Hand;
mousedown = false; _mousedown = false;
} }
private void SetNewPosition(int mx, int my) private void SetNewPosition(int mx, int my)
@ -377,10 +338,8 @@ namespace BizHawk.Client.EmuHawk
XNumeric.Value = mx; XNumeric.Value = mx;
YNumeric.Value = my; YNumeric.Value = my;
px = mx; _px = mx;
py = my; _py = my;
PositionPanel.Refresh(); PositionPanel.Refresh();
SetPositionLabels(); SetPositionLabels();
@ -388,7 +347,7 @@ namespace BizHawk.Client.EmuHawk
private void PositionPanel_MouseMove(object sender, MouseEventArgs e) private void PositionPanel_MouseMove(object sender, MouseEventArgs e)
{ {
if (mousedown) if (_mousedown)
{ {
SetNewPosition(e.X, e.Y); SetNewPosition(e.X, e.Y);
} }
@ -398,53 +357,53 @@ namespace BizHawk.Client.EmuHawk
{ {
if (FPSRadio.Checked) if (FPSRadio.Checked)
{ {
DispFPSx = px; _dispFpSx = _px;
DispFPSy = py; _dispFpSy = _py;
} }
else if (FrameCounterRadio.Checked) else if (FrameCounterRadio.Checked)
{ {
DispFrameCx = px; _dispFrameCx = _px;
DispFrameCy = py; _dispFrameCy = _py;
} }
else if (LagCounterRadio.Checked) else if (LagCounterRadio.Checked)
{ {
DispLagx = px; _dispLagx = _px;
DispLagy = py; _dispLagy = _py;
} }
else if (InputDisplayRadio.Checked) else if (InputDisplayRadio.Checked)
{ {
DispInpx = px; _dispInpx = _px;
DispInpy = py; _dispInpy = _py;
} }
else if (RerecordsRadio.Checked) else if (RerecordsRadio.Checked)
{ {
DispRecx = px; _dispRecx = _px;
DispRecy = py; _dispRecy = _py;
} }
else if (MultitrackRadio.Checked) else if (MultitrackRadio.Checked)
{ {
DispMultix = px; _dispMultix = _px;
DispMultiy = py; _dispMultiy = _py;
} }
else if (MessagesRadio.Checked) else if (MessagesRadio.Checked)
{ {
DispMessagex = px; _dispMessagex = _px;
DispMessagey = py; _dispMessagey = _py;
} }
else if (AutoholdRadio.Checked) else if (AutoholdRadio.Checked)
{ {
DispAutoholdx = px; _dispAutoholdx = _px;
DispAutoholdy = py; _dispAutoholdy = _py;
} }
FpsPosLabel.Text = DispFPSx.ToString() + ", " + DispFPSy.ToString(); FpsPosLabel.Text = _dispFpSx + ", " + _dispFpSy;
FCLabel.Text = DispFrameCx.ToString() + ", " + DispFrameCy.ToString(); FCLabel.Text = _dispFrameCx + ", " + _dispFrameCy;
LagLabel.Text = DispLagx.ToString() + ", " + DispLagy.ToString(); LagLabel.Text = _dispLagx + ", " + _dispLagy;
InpLabel.Text = DispInpx.ToString() + ", " + DispInpy.ToString(); InpLabel.Text = _dispInpx + ", " + _dispInpy;
RerecLabel.Text = DispRecx.ToString() + ", " + DispRecy.ToString(); RerecLabel.Text = _dispRecx + ", " + _dispRecy;
MultitrackLabel.Text = DispMultix.ToString() + ", " + DispMultiy.ToString(); MultitrackLabel.Text = _dispMultix + ", " + _dispMultiy;
MessLabel.Text = DispMessagex.ToString() + ", " + DispMessagey.ToString(); MessLabel.Text = _dispMessagex + ", " + _dispMessagey;
AutoholdLabel.Text = DispAutoholdx.ToString() + ", " + DispAutoholdy.ToString(); AutoholdLabel.Text = _dispAutoholdx + ", " + _dispAutoholdy;
} }
private void ResetDefaultsButton_Click(object sender, EventArgs e) private void ResetDefaultsButton_Click(object sender, EventArgs e)
@ -471,15 +430,15 @@ namespace BizHawk.Client.EmuHawk
Global.Config.LastInputColor = -23296; Global.Config.LastInputColor = -23296;
Global.Config.MovieInput = -8355712; Global.Config.MovieInput = -8355712;
MessageColor = Global.Config.MessagesColor; _messageColor = Global.Config.MessagesColor;
AlertColor = Global.Config.AlertMessageColor; _alertColor = Global.Config.AlertMessageColor;
LastInputColor = Global.Config.LastInputColor; _lastInputColor = Global.Config.LastInputColor;
MovieInput = Global.Config.MovieInput; _movieInput = Global.Config.MovieInput;
MessageColorDialog.Color = Color.FromArgb(MessageColor); MessageColorDialog.Color = Color.FromArgb(_messageColor);
AlertColorDialog.Color = Color.FromArgb(AlertColor); AlertColorDialog.Color = Color.FromArgb(_alertColor);
LInputColorDialog.Color = Color.FromArgb(LastInputColor); LInputColorDialog.Color = Color.FromArgb(_lastInputColor);
MovieInputColorDialog.Color = Color.FromArgb(MovieInput); MovieInputColorDialog.Color = Color.FromArgb(_movieInput);
Global.Config.DispFPSanchor = 0; Global.Config.DispFPSanchor = 0;
Global.Config.DispFrameanchor = 0; Global.Config.DispFrameanchor = 0;
@ -490,31 +449,31 @@ namespace BizHawk.Client.EmuHawk
Global.Config.DispMessageanchor = 2; Global.Config.DispMessageanchor = 2;
Global.Config.DispAutoholdanchor = 1; Global.Config.DispAutoholdanchor = 1;
DispFPSx = Global.Config.DispFPSx; _dispFpSx = Global.Config.DispFPSx;
DispFPSy = Global.Config.DispFPSy; _dispFpSy = Global.Config.DispFPSy;
DispFrameCx = Global.Config.DispFrameCx; _dispFrameCx = Global.Config.DispFrameCx;
DispFrameCy = Global.Config.DispFrameCy; _dispFrameCy = Global.Config.DispFrameCy;
DispLagx = Global.Config.DispLagx; _dispLagx = Global.Config.DispLagx;
DispLagy = Global.Config.DispLagy; _dispLagy = Global.Config.DispLagy;
DispInpx = Global.Config.DispInpx; _dispInpx = Global.Config.DispInpx;
DispInpy = Global.Config.DispInpy; _dispInpy = Global.Config.DispInpy;
DispRecx = Global.Config.DispRecx; _dispRecx = Global.Config.DispRecx;
DispRecy = Global.Config.DispRecy; _dispRecy = Global.Config.DispRecy;
DispMultix = Global.Config.DispMultix; _dispMultix = Global.Config.DispMultix;
DispMultiy = Global.Config.DispMultiy; _dispMultiy = Global.Config.DispMultiy;
DispMessagex = Global.Config.DispMessagex; _dispMessagex = Global.Config.DispMessagex;
DispMessagey = Global.Config.DispMessagey; _dispMessagey = Global.Config.DispMessagey;
DispAutoholdx = Global.Config.DispAutoholdx; _dispAutoholdx = Global.Config.DispAutoholdx;
DispAutoholdy = Global.Config.DispAutoholdy; _dispAutoholdy = Global.Config.DispAutoholdy;
DispFPSanchor = Global.Config.DispFPSanchor; _dispFpSanchor = Global.Config.DispFPSanchor;
DispFrameanchor = Global.Config.DispFrameanchor; _dispFrameanchor = Global.Config.DispFrameanchor;
DispLaganchor = Global.Config.DispLaganchor; _dispLaganchor = Global.Config.DispLaganchor;
DispInputanchor = Global.Config.DispInpanchor; _dispInputanchor = Global.Config.DispInpanchor;
DispRecanchor = Global.Config.DispRecanchor; _dispRecanchor = Global.Config.DispRecanchor;
DispMultiAnchor = Global.Config.DispMultianchor; _dispMultiAnchor = Global.Config.DispMultianchor;
DispMessageAnchor = Global.Config.DispMessageanchor; _dispMessageAnchor = Global.Config.DispMessageanchor;
DispAutoholdAnchor = Global.Config.DispAutoholdanchor; _dispAutoholdAnchor = Global.Config.DispAutoholdanchor;
SetMaxXY(); SetMaxXY();
SetColorBox(); SetColorBox();
@ -527,35 +486,35 @@ namespace BizHawk.Client.EmuHawk
{ {
if (FPSRadio.Checked) if (FPSRadio.Checked)
{ {
DispFPSanchor = value; _dispFpSanchor = value;
} }
else if (FrameCounterRadio.Checked) else if (FrameCounterRadio.Checked)
{ {
DispFrameanchor = value; _dispFrameanchor = value;
} }
else if (LagCounterRadio.Checked) else if (LagCounterRadio.Checked)
{ {
DispLaganchor = value; _dispLaganchor = value;
} }
else if (InputDisplayRadio.Checked) else if (InputDisplayRadio.Checked)
{ {
DispInputanchor = value; _dispInputanchor = value;
} }
else if (MessagesRadio.Checked) else if (MessagesRadio.Checked)
{ {
DispMessageAnchor = value; _dispMessageAnchor = value;
} }
else if (RerecordsRadio.Checked) else if (RerecordsRadio.Checked)
{ {
DispRecanchor = value; _dispRecanchor = value;
} }
else if (MultitrackRadio.Checked) else if (MultitrackRadio.Checked)
{ {
DispMultiAnchor = value; _dispMultiAnchor = value;
} }
else if (AutoholdRadio.Checked) else if (AutoholdRadio.Checked)
{ {
DispAutoholdAnchor = value; _dispAutoholdAnchor = value;
} }
} }

View File

@ -15,20 +15,18 @@ namespace BizHawk.Client.EmuHawk
private void LockDownCores() private void LockDownCores()
{ {
if (!VersionInfo.INTERIM) if (VersionInfo.INTERIM) return;
{
string[] coresToHide = { "PSX", "GBA", "INTV", "C64", "GEN" }; string[] coresToHide = { "PSX", "GBA", "INTV", "C64", "GEN" };
foreach (string core in coresToHide) foreach (var core in coresToHide)
{ {
PathTabControl.TabPages.Remove( PathTabControl.TabPages.Remove(
AllTabPages.FirstOrDefault(x => x.Name == core) ?? new TabPage() AllTabPages.FirstOrDefault(x => x.Name == core) ?? new TabPage()
); );
} }
} }
}
private AutoCompleteStringCollection AutoCompleteOptions private static AutoCompleteStringCollection AutoCompleteOptions
{ {
get get
{ {
@ -88,25 +86,18 @@ namespace BizHawk.Client.EmuHawk
private TabPage FindTabByName(string name) private TabPage FindTabByName(string name)
{ {
IEnumerable<TabPage> query = from p in PathTabControl.TabPages.OfType<TabPage>() select p; return PathTabControl.TabPages
var tab = query.FirstOrDefault(x => x.Name.ToUpper().Contains(name.ToUpper())); .OfType<TabPage>()
if (tab == null) .FirstOrDefault(x => x.Name.ToUpper().Contains(name.ToUpper()))
{ ?? new TabPage();
return new TabPage();
}
else
{
return tab;
}
} }
private void StartTabPages() private void StartTabPages()
{ {
PathTabControl.TabPages.Clear(); PathTabControl.TabPages.Clear();
//Separate by system var systems = Global.Config.PathEntries.Select(x => x.SystemDisplayName).Distinct().ToList();
List<string> systems = Global.Config.PathEntries.Select(x => x.SystemDisplayName).Distinct().ToList();
systems.Sort(); systems.Sort();
foreach (string systemDisplayName in systems) foreach (var systemDisplayName in systems)
{ {
PathTabControl.TabPages.Add(new TabPage PathTabControl.TabPages.Add(new TabPage
{ {
@ -124,13 +115,13 @@ namespace BizHawk.Client.EmuHawk
const int buttonWidth = 26; const int buttonWidth = 26;
int widgetOffset = textboxWidth + 15; int widgetOffset = textboxWidth + 15;
const int rowHeight = 30; const int rowHeight = 30;
List<PathEntry> paths = Global.Config.PathEntries.Where(x => x.System == tabPage.Name).OrderBy(x => x.Ordinal).ThenBy(x => x.Type).ToList(); var paths = Global.Config.PathEntries.Where(x => x.System == tabPage.Name).OrderBy(x => x.Ordinal).ThenBy(x => x.Type).ToList();
int ypos = 14; int ypos = 14;
foreach (var path in paths) foreach (var path in paths)
{ {
TextBox box = new TextBox var box = new TextBox
{ {
Text = path.Path, Text = path.Path,
Location = new Point(xpos, ypos), Location = new Point(xpos, ypos),
@ -143,7 +134,7 @@ namespace BizHawk.Client.EmuHawk
AutoCompleteSource = AutoCompleteSource.CustomSource, AutoCompleteSource = AutoCompleteSource.CustomSource,
}; };
Button btn = new Button var btn = new Button
{ {
Text = String.Empty, Text = String.Empty,
Image = Properties.Resources.OpenFile, Image = Properties.Resources.OpenFile,
@ -153,15 +144,15 @@ namespace BizHawk.Client.EmuHawk
Anchor = AnchorStyles.Top | AnchorStyles.Right, Anchor = AnchorStyles.Top | AnchorStyles.Right,
}; };
TextBox tempBox = box; var tempBox = box;
string tempPath = path.Type; var tempPath = path.Type;
string tempSystem = path.System; var tempSystem = path.System;
btn.Click += delegate btn.Click += delegate
{ {
BrowseFolder(tempBox, tempPath, tempSystem); BrowseFolder(tempBox, tempPath, tempSystem);
}; };
Label label = new Label var label = new Label
{ {
Text = path.Type, Text = path.Type,
Location = new Point(widgetOffset + buttonWidth + padding, ypos + 4), Location = new Point(widgetOffset + buttonWidth + padding, ypos + 4),
@ -177,17 +168,17 @@ namespace BizHawk.Client.EmuHawk
ypos += rowHeight; ypos += rowHeight;
} }
string sys = tabPage.Name; var sys = tabPage.Name;
if (tabPage.Name == "PCE") //Hack if (tabPage.Name == "PCE") //Hack
{ {
sys = "PCECD"; sys = "PCECD";
} }
bool hasFirmwares = FirmwaresConfig.SystemGroupNames.Any(x => x.Key == sys); var hasFirmwares = FirmwaresConfig.SystemGroupNames.Any(x => x.Key == sys);
if (hasFirmwares) if (hasFirmwares)
{ {
Button firmwareButton = new Button var firmwareButton = new Button
{ {
Name = sys, Name = sys,
Text = "&Firmware", Text = "&Firmware",
@ -196,7 +187,7 @@ namespace BizHawk.Client.EmuHawk
}; };
firmwareButton.Click += delegate firmwareButton.Click += delegate
{ {
FirmwaresConfig f = new FirmwaresConfig { TargetSystem = sys }; var f = new FirmwaresConfig { TargetSystem = sys };
f.ShowDialog(); f.ShowDialog();
}; };
@ -211,15 +202,15 @@ namespace BizHawk.Client.EmuHawk
PathTabControl.TabPages.Clear(); PathTabControl.TabPages.Clear();
//Separate by system //Separate by system
List<string> systems = Global.Config.PathEntries.Select(x => x.SystemDisplayName).Distinct().ToList(); var systems = Global.Config.PathEntries.Select(x => x.SystemDisplayName).Distinct().ToList();
systems.Sort(); systems.Sort();
//Hacky way to put global first //Hacky way to put global first
string global = systems.FirstOrDefault(x => x == "Global"); var global = systems.FirstOrDefault(x => x == "Global");
systems.Remove(global); systems.Remove(global);
systems.Insert(0, global); systems.Insert(0, global);
List<TabPage> tabPages = new List<TabPage>(systems.Count); var tabPages = new List<TabPage>(systems.Count);
const int _x = 6; const int _x = 6;
const int textboxWidth = 70; const int textboxWidth = 70;
@ -228,20 +219,20 @@ namespace BizHawk.Client.EmuHawk
const int widgetOffset = 85; const int widgetOffset = 85;
const int rowHeight = 30; const int rowHeight = 30;
foreach (string systemDisplayName in systems) foreach (var systemDisplayName in systems)
{ {
string systemId = Global.Config.PathEntries.FirstOrDefault(x => x.SystemDisplayName == systemDisplayName).System; var systemId = Global.Config.PathEntries.FirstOrDefault(x => x.SystemDisplayName == systemDisplayName).System;
TabPage t = new TabPage var t = new TabPage
{ {
Text = systemDisplayName, Text = systemDisplayName,
Name = systemId, Name = systemId,
}; };
List<PathEntry> paths = pathCollection.Where(x => x.System == systemId).OrderBy(x => x.Ordinal).ThenBy(x => x.Type).ToList(); var paths = pathCollection.Where(x => x.System == systemId).OrderBy(x => x.Ordinal).ThenBy(x => x.Type).ToList();
int _y = 14; var _y = 14;
foreach (var path in paths) foreach (var path in paths)
{ {
TextBox box = new TextBox var box = new TextBox
{ {
Text = path.Path, Text = path.Path,
Location = new Point(_x, _y), Location = new Point(_x, _y),
@ -254,7 +245,7 @@ namespace BizHawk.Client.EmuHawk
AutoCompleteSource = AutoCompleteSource.CustomSource, AutoCompleteSource = AutoCompleteSource.CustomSource,
}; };
Button btn = new Button var btn = new Button
{ {
Text = String.Empty, Text = String.Empty,
Image = Properties.Resources.OpenFile, Image = Properties.Resources.OpenFile,
@ -264,15 +255,15 @@ namespace BizHawk.Client.EmuHawk
Anchor = AnchorStyles.Top | AnchorStyles.Right, Anchor = AnchorStyles.Top | AnchorStyles.Right,
}; };
TextBox tempBox = box; var tempBox = box;
string tempPath = path.Type; var tempPath = path.Type;
string tempSystem = path.System; var tempSystem = path.System;
btn.Click += delegate btn.Click += delegate
{ {
BrowseFolder(tempBox, tempPath, tempSystem); BrowseFolder(tempBox, tempPath, tempSystem);
}; };
Label label = new Label var label = new Label
{ {
Text = path.Type, Text = path.Type,
Location = new Point(widgetOffset + buttonWidth + padding, _y + 4), Location = new Point(widgetOffset + buttonWidth + padding, _y + 4),
@ -288,17 +279,17 @@ namespace BizHawk.Client.EmuHawk
_y += rowHeight; _y += rowHeight;
} }
string sys = systemDisplayName; var sys = systemDisplayName;
if (systemDisplayName == "PCE") //Hack if (systemDisplayName == "PCE") //Hack
{ {
sys = "PCECD"; sys = "PCECD";
} }
bool hasFirmwares = FirmwaresConfig.SystemGroupNames.Any(x => x.Key == sys); var hasFirmwares = FirmwaresConfig.SystemGroupNames.Any(x => x.Key == sys);
if (hasFirmwares) if (hasFirmwares)
{ {
Button firmwareButton = new Button var firmwareButton = new Button
{ {
Name = sys, Name = sys,
Text = "&Firmware", Text = "&Firmware",
@ -307,7 +298,7 @@ namespace BizHawk.Client.EmuHawk
}; };
firmwareButton.Click += delegate firmwareButton.Click += delegate
{ {
FirmwaresConfig f = new FirmwaresConfig {TargetSystem = sys}; var f = new FirmwaresConfig {TargetSystem = sys};
f.ShowDialog(); f.ShowDialog();
}; };
@ -333,7 +324,7 @@ namespace BizHawk.Client.EmuHawk
Description = "Set the directory for " + name, Description = "Set the directory for " + name,
SelectedPath = PathManager.MakeAbsolutePath(box.Text, system) SelectedPath = PathManager.MakeAbsolutePath(box.Text, system)
}; };
DialogResult result = f.ShowDialog(); var result = f.ShowDialog();
if (result == DialogResult.OK) if (result == DialogResult.OK)
{ {
box.Text = PathManager.TryMakeRelative(f.SelectedPath, system); box.Text = PathManager.TryMakeRelative(f.SelectedPath, system);
@ -345,9 +336,9 @@ namespace BizHawk.Client.EmuHawk
Global.Config.UseRecentForROMs = RecentForROMs.Checked; Global.Config.UseRecentForROMs = RecentForROMs.Checked;
Global.Config.PathEntries["Global", "Base"].Path = BasePathBox.Text; Global.Config.PathEntries["Global", "Base"].Path = BasePathBox.Text;
foreach (TextBox t in AllPathBoxes) foreach (var t in AllPathBoxes)
{ {
PathEntry path_entry = Global.Config.PathEntries.FirstOrDefault(x => x.System == t.Parent.Name && x.Type == t.Name); var path_entry = Global.Config.PathEntries.FirstOrDefault(x => x.System == t.Parent.Name && x.Type == t.Name);
path_entry.Path = t.Text; path_entry.Path = t.Text;
} }
} }
@ -359,7 +350,7 @@ namespace BizHawk.Client.EmuHawk
Description = "Set the directory for the base global path", Description = "Set the directory for the base global path",
SelectedPath = PathManager.MakeAbsolutePath(BasePathBox.Text, null) SelectedPath = PathManager.MakeAbsolutePath(BasePathBox.Text, null)
}; };
DialogResult result = f.ShowDialog(); var result = f.ShowDialog();
if (result == DialogResult.OK) if (result == DialogResult.OK)
{ {
BasePathBox.Text = f.SelectedPath; BasePathBox.Text = f.SelectedPath;
@ -378,8 +369,8 @@ namespace BizHawk.Client.EmuHawk
private void DoRomToggle() private void DoRomToggle()
{ {
List<Control> pcontrols = AllPathControls.Where(x => x.Name == "ROM").ToList(); var pcontrols = AllPathControls.Where(x => x.Name == "ROM").ToList();
foreach (Control c in pcontrols) foreach (var c in pcontrols)
{ {
c.Enabled = !RecentForROMs.Checked; c.Enabled = !RecentForROMs.Checked;
} }
@ -389,10 +380,10 @@ namespace BizHawk.Client.EmuHawk
{ {
get get
{ {
List<TextBox> _AllPathBoxes = new List<TextBox>(); var _AllPathBoxes = new List<TextBox>();
foreach (TabPage tp in PathTabControl.TabPages) foreach (TabPage tp in PathTabControl.TabPages)
{ {
IEnumerable<TextBox> boxes = from b in tp.Controls.OfType<TextBox>() select b; var boxes = tp.Controls.OfType<TextBox>();
_AllPathBoxes.AddRange(boxes); _AllPathBoxes.AddRange(boxes);
} }
return _AllPathBoxes; return _AllPathBoxes;
@ -403,10 +394,10 @@ namespace BizHawk.Client.EmuHawk
{ {
get get
{ {
List<Control> _AllPathControls = new List<Control>(); var _AllPathControls = new List<Control>();
foreach (TabPage tp in PathTabControl.TabPages) foreach (TabPage tp in PathTabControl.TabPages)
{ {
IEnumerable<Control> control = from c in tp.Controls.OfType<Control>() select c; var control = tp.Controls.OfType<Control>();
_AllPathControls.AddRange(control); _AllPathControls.AddRange(control);
} }
return _AllPathControls; return _AllPathControls;
@ -415,10 +406,7 @@ namespace BizHawk.Client.EmuHawk
private IEnumerable<TabPage> AllTabPages private IEnumerable<TabPage> AllTabPages
{ {
get get { return PathTabControl.TabPages.Cast<TabPage>(); }
{
return PathTabControl.TabPages.Cast<TabPage>().ToList();
}
} }
private void DefaultsBtn_Click(object sender, EventArgs e) private void DefaultsBtn_Click(object sender, EventArgs e)

View File

@ -1,10 +1,4 @@
using System; using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms; using System.Windows.Forms;
namespace BizHawk.Client.EmuHawk namespace BizHawk.Client.EmuHawk

View File

@ -1,10 +1,4 @@
using System; using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms; using System.Windows.Forms;
using BizHawk.Client.Common; using BizHawk.Client.Common;
@ -38,9 +32,11 @@ namespace BizHawk.Client.EmuHawk
{ {
listBoxSoundDevices.Items.Add(d); listBoxSoundDevices.Items.Add(d);
if (d == Global.Config.SoundDevice) if (d == Global.Config.SoundDevice)
{
listBoxSoundDevices.SelectedItem = d; listBoxSoundDevices.SelectedItem = d;
} }
} }
}
private void OK_Click(object sender, EventArgs e) private void OK_Click(object sender, EventArgs e)
{ {
@ -53,13 +49,13 @@ namespace BizHawk.Client.EmuHawk
GlobalWin.Sound.UpdateSoundSettings(); GlobalWin.Sound.UpdateSoundSettings();
GlobalWin.Sound.StartSound(); GlobalWin.Sound.StartSound();
GlobalWin.OSD.AddMessage("Sound settings saved"); GlobalWin.OSD.AddMessage("Sound settings saved");
this.Close(); Close();
} }
private void Cancel_Click(object sender, EventArgs e) private void Cancel_Click(object sender, EventArgs e)
{ {
GlobalWin.OSD.AddMessage("Sound config aborted"); GlobalWin.OSD.AddMessage("Sound config aborted");
this.Close(); Close();
} }
private void trackBar1_Scroll(object sender, EventArgs e) private void trackBar1_Scroll(object sender, EventArgs e)
@ -79,18 +75,10 @@ namespace BizHawk.Client.EmuHawk
private void UpdateSoundDialog() private void UpdateSoundDialog()
{ {
if (SoundOnCheckBox.Checked) SoundVolGroup.Enabled =
{ MuteFrameAdvance.Enabled =
SoundVolGroup.Enabled = true; ThrottlecheckBox.Enabled =
MuteFrameAdvance.Enabled = true; SoundOnCheckBox.Checked;
ThrottlecheckBox.Enabled = true;
}
else
{
SoundVolGroup.Enabled = false;
MuteFrameAdvance.Enabled = false;
ThrottlecheckBox.Enabled = false;
}
} }
} }
} }

View File

@ -7,7 +7,7 @@ namespace BizHawk.Client.EmuHawk
{ {
public partial class EditCommentsForm : Form public partial class EditCommentsForm : Form
{ {
private IMovie selectedMovie; private IMovie _selectedMovie;
public EditCommentsForm() public EditCommentsForm()
{ {
@ -24,11 +24,8 @@ namespace BizHawk.Client.EmuHawk
if (CommentGrid.Rows.Count > 8) if (CommentGrid.Rows.Count > 8)
{ {
int x = Height + ((CommentGrid.Rows.Count - 8) * 21); var x = Height + ((CommentGrid.Rows.Count - 8) * 21);
if (x < 600) Height = x < 600 ? x : 600;
Height = x;
else
Height = 600;
} }
} }
@ -41,30 +38,31 @@ namespace BizHawk.Client.EmuHawk
{ {
if (!Global.ReadOnly) if (!Global.ReadOnly)
{ {
selectedMovie.Header.Comments.Clear(); _selectedMovie.Header.Comments.Clear();
for (int x = 0; x < CommentGrid.Rows.Count - 1; x++) for (int i = 0; i < CommentGrid.Rows.Count - 1; i++)
{ {
DataGridViewCell c = CommentGrid.Rows[x].Cells[0]; var c = CommentGrid.Rows[i].Cells[0];
selectedMovie.Header.Comments.Add("comment " + c.Value); _selectedMovie.Header.Comments.Add("comment " + c.Value);
} }
selectedMovie.Save(); _selectedMovie.Save();
} }
Close(); Close();
} }
public void GetMovie(IMovie m) public void GetMovie(IMovie m)
{ {
selectedMovie = m; _selectedMovie = m;
if (m.Header.Comments.Count == 0) return; if (m.Header.Comments.Count == 0) return;
for (int x = 0; x < m.Header.Comments.Count; x++) for (int i = 0; i < m.Header.Comments.Count; i++)
{ {
string str = m.Header.Comments[x]; var str = m.Header.Comments[i];
if (str.Length >= 7 && str.Substring(0, 7) == "comment") if (str.Length >= 7 && str.Substring(0, 7) == "comment")
{
str = str.Remove(0, 7); str = str.Remove(0, 7);
}
CommentGrid.Rows.Add(); CommentGrid.Rows.Add();
DataGridViewCell c = CommentGrid.Rows[x].Cells[0]; var c = CommentGrid.Rows[i].Cells[0];
c.Value = str; c.Value = str;
} }
} }

View File

@ -10,7 +10,7 @@ namespace BizHawk.Client.EmuHawk
public partial class EditSubtitlesForm : Form public partial class EditSubtitlesForm : Form
{ {
public bool ReadOnly; public bool ReadOnly;
private IMovie selectedMovie; private IMovie _selectedMovie;
public EditSubtitlesForm() public EditSubtitlesForm()
{ {
@ -29,11 +29,8 @@ namespace BizHawk.Client.EmuHawk
if (SubGrid.Rows.Count > 8) if (SubGrid.Rows.Count > 8)
{ {
int x = Height + ((SubGrid.Rows.Count - 8) * 21); var x = Height + ((SubGrid.Rows.Count - 8) * 21);
if (x < 600) Height = x < 600 ? x : 600;
Height = x;
else
Height = 600;
} }
} }
@ -44,9 +41,9 @@ namespace BizHawk.Client.EmuHawk
private void ShowError(int row, int column) private void ShowError(int row, int column)
{ {
DataGridViewCell c = SubGrid.Rows[row].Cells[column]; var c = SubGrid.Rows[row].Cells[column];
string error = "Unable to parse value: " + c.Value; var error = "Unable to parse value: " + c.Value;
string caption = "Parse Error Row " + row.ToString() + " Column " + column.ToString(); var caption = "Parse Error Row " + row + " Column " + column;
MessageBox.Show(error, caption, MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show(error, caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
} }
@ -54,12 +51,12 @@ namespace BizHawk.Client.EmuHawk
{ {
if (!ReadOnly) if (!ReadOnly)
{ {
selectedMovie.Subtitles.Clear(); _selectedMovie.Subtitles.Clear();
for (int x = 0; x < SubGrid.Rows.Count - 1; x++) for (int x = 0; x < SubGrid.Rows.Count - 1; x++)
{ {
Subtitle s = new Subtitle(); var s = new Subtitle();
DataGridViewCell c = SubGrid.Rows[x].Cells[0]; var c = SubGrid.Rows[x].Cells[0];
try { s.Frame = int.Parse(c.Value.ToString()); } try { s.Frame = int.Parse(c.Value.ToString()); }
catch { ShowError(x, 0); return; } catch { ShowError(x, 0); return; }
c = SubGrid.Rows[x].Cells[1]; c = SubGrid.Rows[x].Cells[1];
@ -77,24 +74,24 @@ namespace BizHawk.Client.EmuHawk
try { c = SubGrid.Rows[x].Cells[5]; } try { c = SubGrid.Rows[x].Cells[5]; }
catch { ShowError(x, 5); return; } catch { ShowError(x, 5); return; }
s.Message = c.Value.ToString(); s.Message = c.Value.ToString();
selectedMovie.Subtitles.Add(s); _selectedMovie.Subtitles.Add(s);
} }
selectedMovie.Save(); _selectedMovie.Save();
} }
Close(); Close();
} }
public void GetMovie(IMovie m) public void GetMovie(IMovie m)
{ {
selectedMovie = m; _selectedMovie = m;
SubtitleList subs = new SubtitleList(); var subs = new SubtitleList();
subs.AddRange(m.Subtitles); subs.AddRange(m.Subtitles);
for (int x = 0; x < subs.Count; x++) for (int x = 0; x < subs.Count; x++)
{ {
Subtitle s = subs[x]; var s = subs[x];
SubGrid.Rows.Add(); SubGrid.Rows.Add();
DataGridViewCell c = SubGrid.Rows[x].Cells[0]; var c = SubGrid.Rows[x].Cells[0];
c.Value = s.Frame; c.Value = s.Frame;
c = SubGrid.Rows[x].Cells[1]; c = SubGrid.Rows[x].Cells[1];
c.Value = s.X; c.Value = s.X;
@ -113,7 +110,7 @@ namespace BizHawk.Client.EmuHawk
private void ChangeRow(Subtitle s, int index) private void ChangeRow(Subtitle s, int index)
{ {
if (index >= SubGrid.Rows.Count) return; if (index >= SubGrid.Rows.Count) return;
DataGridViewCell c = SubGrid.Rows[index].Cells[0]; var c = SubGrid.Rows[index].Cells[0];
c.Value = s.Frame; c.Value = s.Frame;
c = SubGrid.Rows[index].Cells[1]; c = SubGrid.Rows[index].Cells[1];
c.Value = s.X; c.Value = s.X;
@ -132,8 +129,8 @@ namespace BizHawk.Client.EmuHawk
{ {
if (index >= SubGrid.Rows.Count) return new Subtitle(); if (index >= SubGrid.Rows.Count) return new Subtitle();
Subtitle s = new Subtitle(); var s = new Subtitle();
DataGridViewCell c = SubGrid.Rows[index].Cells[0]; var c = SubGrid.Rows[index].Cells[0];
//Empty catch because it should default to subtitle default value //Empty catch because it should default to subtitle default value
try { s.Frame = int.Parse(c.Value.ToString()); } try { s.Frame = int.Parse(c.Value.ToString()); }
@ -153,7 +150,7 @@ namespace BizHawk.Client.EmuHawk
c = SubGrid.Rows[index].Cells[5]; c = SubGrid.Rows[index].Cells[5];
try { s.Message = c.Value.ToString(); } try { s.Message = c.Value.ToString(); }
catch { } catch { }
selectedMovie.Subtitles.Add(s); _selectedMovie.Subtitles.Add(s);
return s; return s;
} }
@ -161,15 +158,12 @@ namespace BizHawk.Client.EmuHawk
private void SubGrid_MouseDoubleClick(object sender, MouseEventArgs e) private void SubGrid_MouseDoubleClick(object sender, MouseEventArgs e)
{ {
if (ReadOnly) return; if (ReadOnly) return;
DataGridViewSelectedRowCollection c = SubGrid.SelectedRows; var c = SubGrid.SelectedRows;
if (c.Count == 0) return; if (c.Count == 0) return;
SubtitleMaker s = new SubtitleMaker(); var s = new SubtitleMaker {Sub = GetRow(c[0].Index)};
s.sub = GetRow(c[0].Index);
if (s.ShowDialog() == DialogResult.OK) if (s.ShowDialog() == DialogResult.OK)
{ {
ChangeRow(s.sub, SubGrid.SelectedRows[0].Index); ChangeRow(s.Sub, SubGrid.SelectedRows[0].Index);
//if (SubGrid.Rows.Count == SubGrid.SelectedRows[0].Index + 1)
// SubGrid.Rows.Add(); //Why does this case ChangeRow to edit the new changed row?
} }
} }
} }

View File

@ -21,7 +21,6 @@ namespace BizHawk.Client.EmuHawk
{ {
InitializeComponent(); InitializeComponent();
MovieView.QueryItemText += MovieView_QueryItemText; MovieView.QueryItemText += MovieView_QueryItemText;
MovieView.QueryItemBkColor += MovieView_QueryItemBkColor;
MovieView.VirtualMode = true; MovieView.VirtualMode = true;
_sortReverse = false; _sortReverse = false;
_sortedCol = String.Empty; _sortedCol = String.Empty;
@ -48,11 +47,6 @@ namespace BizHawk.Client.EmuHawk
} }
} }
private void MovieView_QueryItemBkColor(int index, int column, ref Color color)
{
}
private void Cancel_Click(object sender, EventArgs e) private void Cancel_Click(object sender, EventArgs e)
{ {
Close(); Close();
@ -60,8 +54,8 @@ namespace BizHawk.Client.EmuHawk
private void Run() private void Run()
{ {
ListView.SelectedIndexCollection indexes = MovieView.SelectedIndices; var indices = MovieView.SelectedIndices;
if (indexes.Count > 0) //Import file if necessary if (indices.Count > 0) //Import file if necessary
{ {
GlobalWin.MainForm.StartNewMovie(_movieList[MovieView.SelectedIndices[0]], false); GlobalWin.MainForm.StartNewMovie(_movieList[MovieView.SelectedIndices[0]], false);
} }
@ -76,8 +70,8 @@ namespace BizHawk.Client.EmuHawk
private void BrowseMovies_Click(object sender, EventArgs e) private void BrowseMovies_Click(object sender, EventArgs e)
{ {
OpenFileDialog ofd = new OpenFileDialog { InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.PathEntries.MoviesPath, null) }; var ofd = new OpenFileDialog { InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.PathEntries.MoviesPath, null) };
string filter = "Movie Files (*." + Global.Config.MovieExtension + ")|*." + Global.Config.MovieExtension + "|Savestates|*.state|All Files|*.*"; var filter = "Movie Files (*." + Global.Config.MovieExtension + ")|*." + Global.Config.MovieExtension + "|Savestates|*.state|All Files|*.*";
ofd.Filter = filter; ofd.Filter = filter;
GlobalWin.Sound.StopSound(); GlobalWin.Sound.StopSound();
@ -87,26 +81,29 @@ namespace BizHawk.Client.EmuHawk
{ {
var file = new FileInfo(ofd.FileName); var file = new FileInfo(ofd.FileName);
if (!file.Exists) if (!file.Exists)
{
return; return;
}
else else
{ {
if (file.Extension.ToUpper() == "STATE") if (file.Extension.ToUpper() == "STATE")
{ {
Movie movie = new Movie(file.FullName); var movie = new Movie(file.FullName);
movie.Load(); //State files will have to load everything unfortunately movie.Load(); //State files will have to load everything unfortunately
if (movie.Frames == 0) if (movie.Frames == 0)
{ {
MessageBox.Show("No input log detected in this savestate, aborting", "Can not load file", MessageBoxButtons.OK, MessageBoxIcon.Hand); MessageBox.Show("No input log detected in this savestate, aborting", "Can not load file", MessageBoxButtons.OK,
MessageBoxIcon.Hand);
return; return;
} }
} }
int x = AddMovieToList(ofd.FileName, true); int? index = AddMovieToList(ofd.FileName, true);
if (x > 0) if (index.HasValue)
{ {
MovieView.SelectedIndices.Clear(); MovieView.SelectedIndices.Clear();
MovieView.setSelection(x); MovieView.setSelection(index.Value);
MovieView.SelectItem(x, true); MovieView.SelectItem(index.Value, true);
} }
} }
} }
@ -118,10 +115,9 @@ namespace BizHawk.Client.EmuHawk
{ {
if (file.Exists) if (file.Exists)
{ {
int x = IsDuplicate(filename); if (!IsDuplicateOf(filename).HasValue)
if (x == 0)
{ {
Movie movie = new Movie(file.CanonicalFullPath); var movie = new Movie(file.CanonicalFullPath);
movie.Load(); //State files will have to load everything unfortunately movie.Load(); //State files will have to load everything unfortunately
if (movie.Frames > 0) if (movie.Frames > 0)
{ {
@ -134,16 +130,18 @@ 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 0; {
return null;
}
else else
{ {
int x = IsDuplicate(filename); int? index = IsDuplicateOf(filename);
if (x == 0) if (!index.HasValue)
{ {
PreLoadMovieFile(file, force); PreLoadMovieFile(file, force);
MovieView.ItemCount = _movieList.Count; MovieView.ItemCount = _movieList.Count;
@ -151,29 +149,29 @@ namespace BizHawk.Client.EmuHawk
_sortReverse = false; _sortReverse = false;
_sortedCol = String.Empty; _sortedCol = String.Empty;
x = _movieList.Count - 1; index = _movieList.Count - 1;
} }
return x; return index;
} }
} }
} }
private int IsDuplicate(string filename) private int? IsDuplicateOf(string filename)
{ {
for (int x = 0; x < _movieList.Count; x++) for (int i = 0; i < _movieList.Count; i++)
{ {
if (_movieList[x].Filename == filename) if (_movieList[i].Filename == filename)
{ {
return x; return i;
} }
} }
return 0; return null;
} }
private void PreLoadMovieFile(HawkFile hf, bool force) private void PreLoadMovieFile(HawkFile hf, bool force)
{ {
Movie movie = new Movie(hf.CanonicalFullPath); var movie = new Movie(hf.CanonicalFullPath);
movie.PreLoadText(hf); movie.PreLoadText(hf);
if (hf.Extension == ".FM2") if (hf.Extension == ".FM2")
{ {
@ -199,42 +197,37 @@ namespace BizHawk.Client.EmuHawk
private void UpdateMovieCount() private void UpdateMovieCount()
{ {
int x = _movieList.Count; MovieCount.Text = _movieList.Count + " movie"
if (x == 1) + (_movieList.Count != 1 ? "s" : String.Empty);
{
MovieCount.Text = x.ToString() + " movie";
}
else
{
MovieCount.Text = x.ToString() + " movies";
}
} }
private void PreHighlightMovie() private void PreHighlightMovie()
{ {
if (Global.Game == null) return; if (Global.Game == null) return;
List<int> Indexes = new List<int>(); var Indices = new List<int>();
//Pull out matching names //Pull out matching names
for (int x = 0; x < _movieList.Count; x++) for (int i = 0; i < _movieList.Count; i++)
{ {
if (PathManager.FilesystemSafeName(Global.Game) == _movieList[x].GameName) if (PathManager.FilesystemSafeName(Global.Game) == _movieList[i].GameName)
Indexes.Add(x); {
Indices.Add(i);
} }
if (Indexes.Count == 0) return; }
if (Indexes.Count == 1) if (Indices.Count == 0) return;
if (Indices.Count == 1)
{ {
HighlightMovie(Indexes[0]); HighlightMovie(Indices[0]);
return; return;
} }
//Prefer tas files //Prefer tas files
List<int> TAS = new List<int>(); var TAS = new List<int>();
for (int x = 0; x < Indexes.Count; x++) for (int i = 0; i < Indices.Count; i++)
{ {
if (Path.GetExtension(_movieList[Indexes[x]].Filename).ToUpper() == "." + Global.Config.MovieExtension) if (Path.GetExtension(_movieList[Indices[i]].Filename).ToUpper() == "." + Global.Config.MovieExtension)
{ {
TAS.Add(x); TAS.Add(i);
} }
} }
@ -245,20 +238,20 @@ namespace BizHawk.Client.EmuHawk
} }
else if (TAS.Count > 1) else if (TAS.Count > 1)
{ {
Indexes = new List<int>(TAS); Indices = new List<int>(TAS);
} }
//Final tie breaker - Last used file //Final tie breaker - Last used file
FileInfo f = new FileInfo(_movieList[Indexes[0]].Filename); var file = new FileInfo(_movieList[Indices[0]].Filename);
DateTime t = f.LastAccessTime; var time = file.LastAccessTime;
int mostRecent = Indexes[0]; int mostRecent = Indices.First();
for (int x = 1; x < Indexes.Count; x++) for (int i = 1; i < Indices.Count; i++)
{ {
f = new FileInfo(_movieList[Indexes[0]].Filename); file = new FileInfo(_movieList[Indices[0]].Filename);
if (f.LastAccessTime > t) if (file.LastAccessTime > time)
{ {
t = f.LastAccessTime; time = file.LastAccessTime;
mostRecent = Indexes[x]; mostRecent = Indices[i];
} }
} }
@ -285,57 +278,35 @@ namespace BizHawk.Client.EmuHawk
{ {
ClearList(); ClearList();
string d = PathManager.MakeAbsolutePath(Global.Config.PathEntries.MoviesPath, null); var directory = PathManager.MakeAbsolutePath(Global.Config.PathEntries.MoviesPath, null);
if (!Directory.Exists(d)) if (!Directory.Exists(directory))
{ {
Directory.CreateDirectory(d); Directory.CreateDirectory(directory);
} }
foreach (string f in Directory.GetFiles(d, "*." + Global.Config.MovieExtension)) Directory.GetFiles(directory, "*." + Global.Config.MovieExtension)
{ .ToList()
AddMovieToList(f, false); .ForEach(file => AddMovieToList(file, force: false));
}
if (Global.Config.MovieExtension != "*.tas")
{
foreach (string f in Directory.GetFiles(d, "*.tas"))
{
AddMovieToList(f, false);
}
}
else if (Global.Config.MovieExtension != "*.bkm")
{
foreach (string f in Directory.GetFiles(d, "*.bkm"))
{
AddMovieToList(f, false);
}
}
if (Global.Config.PlayMovie_ShowStateFiles) if (Global.Config.PlayMovie_ShowStateFiles)
{ {
foreach (string f in Directory.GetFiles(d, "*.state")) Directory.GetFiles(directory, "*.state")
{ .ToList()
AddStateToList(f); .ForEach(file => AddStateToList(file));
}
} }
if (Global.Config.PlayMovie_IncludeSubdir) if (Global.Config.PlayMovie_IncludeSubdir)
{ {
string[] subs = Directory.GetDirectories(d); var subs = Directory.GetDirectories(directory);
foreach (string dir in subs) foreach (var dir in subs)
{ {
foreach (string f in Directory.GetFiles(dir, "*." + Global.Config.MovieExtension)) Directory.GetFiles(dir, "*." + Global.Config.MovieExtension)
{ .ToList()
AddMovieToList(f, false); .ForEach(file => AddMovieToList(file, force: false));
}
if (Global.Config.PlayMovie_ShowStateFiles) Directory.GetFiles(dir, "*.state")
{ .ToList()
foreach (string f in Directory.GetFiles(d, "*.state")) .ForEach(file => AddStateToList(file));
{
AddStateToList(f);
}
}
} }
} }
} }
@ -363,13 +334,13 @@ namespace BizHawk.Client.EmuHawk
OK.Enabled = true; OK.Enabled = true;
} }
int x = MovieView.SelectedIndices[0]; int firstIndex = MovieView.SelectedIndices[0];
MovieView.ensureVisible(x); MovieView.ensureVisible(firstIndex);
Dictionary<string, string> h = _movieList[x].Header.HeaderParams; var headers = _movieList[firstIndex].Header.HeaderParams;
foreach (var kvp in h) foreach (var kvp in headers)
{ {
ListViewItem item = new ListViewItem(kvp.Key); var item = new ListViewItem(kvp.Key);
item.SubItems.Add(kvp.Value); item.SubItems.Add(kvp.Value);
switch (kvp.Key) switch (kvp.Key)
@ -405,23 +376,23 @@ namespace BizHawk.Client.EmuHawk
} }
var FpsItem = new ListViewItem("Fps"); var FpsItem = new ListViewItem("Fps");
FpsItem.SubItems.Add(String.Format("{0:0.#######}", _movieList[x].Fps)); FpsItem.SubItems.Add(String.Format("{0:0.#######}", _movieList[firstIndex].Fps));
DetailsView.Items.Add(FpsItem); DetailsView.Items.Add(FpsItem);
var FramesItem = new ListViewItem("Frames"); var FramesItem = new ListViewItem("Frames");
FramesItem.SubItems.Add(_movieList[x].RawFrames.ToString()); FramesItem.SubItems.Add(_movieList[firstIndex].RawFrames.ToString());
DetailsView.Items.Add(FramesItem); DetailsView.Items.Add(FramesItem);
CommentsBtn.Enabled = _movieList[x].Header.Comments.Count > 0; CommentsBtn.Enabled = _movieList[firstIndex].Header.Comments.Any();
SubtitlesBtn.Enabled = _movieList[x].Subtitles.Count > 0; SubtitlesBtn.Enabled = _movieList[firstIndex].Subtitles.Any();
} }
private void button1_Click(object sender, EventArgs e) private void button1_Click(object sender, EventArgs e)
{ {
ListView.SelectedIndexCollection indexes = MovieView.SelectedIndices; var indices = MovieView.SelectedIndices;
if (indexes.Count > 0) if (indices.Count > 0)
{ {
EditCommentsForm form = new EditCommentsForm(); var form = new EditCommentsForm();
form.GetMovie(_movieList[MovieView.SelectedIndices[0]]); form.GetMovie(_movieList[MovieView.SelectedIndices[0]]);
form.Show(); form.Show();
} }
@ -429,10 +400,10 @@ namespace BizHawk.Client.EmuHawk
private void button2_Click(object sender, EventArgs e) private void button2_Click(object sender, EventArgs e)
{ {
ListView.SelectedIndexCollection indexes = MovieView.SelectedIndices; var indices = MovieView.SelectedIndices;
if (indexes.Count > 0) if (indices.Count > 0)
{ {
EditSubtitlesForm s = new EditSubtitlesForm { ReadOnly = true }; var s = new EditSubtitlesForm { ReadOnly = true };
s.GetMovie(_movieList[MovieView.SelectedIndices[0]]); s.GetMovie(_movieList[MovieView.SelectedIndices[0]]);
s.Show(); s.Show();
} }
@ -451,14 +422,12 @@ namespace BizHawk.Client.EmuHawk
private void MovieView_DragDrop(object sender, DragEventArgs e) private void MovieView_DragDrop(object sender, DragEventArgs e)
{ {
string[] filePaths = (string[])e.Data.GetData(DataFormats.FileDrop); var filePaths = (string[])e.Data.GetData(DataFormats.FileDrop);
foreach (string path in filePaths)
{ filePaths
if (Path.GetExtension(path) == "." + Global.Config.MovieExtension) .Where(path => Path.GetExtension(path) == "." + Global.Config.MovieExtension)
{ .ToList()
AddMovieToList(path, true); .ForEach(path => AddMovieToList(path, force: true));
}
}
} }
private void MovieView_ColumnClick(object sender, ColumnClickEventArgs e) private void MovieView_ColumnClick(object sender, ColumnClickEventArgs e)
@ -468,7 +437,7 @@ namespace BizHawk.Client.EmuHawk
private void OrderColumn(int columnToOrder) private void OrderColumn(int columnToOrder)
{ {
string columnName = MovieView.Columns[columnToOrder].Text; var columnName = MovieView.Columns[columnToOrder].Text;
if (_sortedCol != columnName) if (_sortedCol != columnName)
{ {
_sortReverse = false; _sortReverse = false;
@ -594,10 +563,10 @@ namespace BizHawk.Client.EmuHawk
{ {
if (e.Control && e.KeyCode == Keys.C) if (e.Control && e.KeyCode == Keys.C)
{ {
ListView.SelectedIndexCollection indexes = MovieView.SelectedIndices; var indexes = MovieView.SelectedIndices;
if (indexes.Count > 0) if (indexes.Count > 0)
{ {
StringBuilder copyStr = new StringBuilder(); var copyStr = new StringBuilder();
foreach (int index in indexes) foreach (int index in indexes)
{ {
copyStr copyStr

View File

@ -182,6 +182,7 @@
this.MaximizeBox = false; this.MaximizeBox = false;
this.MaximumSize = new System.Drawing.Size(1440, 201); this.MaximumSize = new System.Drawing.Size(1440, 201);
this.MinimizeBox = false; this.MinimizeBox = false;
this.MinimumSize = new System.Drawing.Size(425, 201);
this.Name = "RecordMovie"; this.Name = "RecordMovie";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Record Movie"; this.Text = "Record Movie";

View File

@ -18,7 +18,7 @@ namespace BizHawk.Client.EmuHawk
//TODO //TODO
//Allow relative paths in record textbox //Allow relative paths in record textbox
Movie MovieToRecord; private Movie _movieToRecord;
public RecordMovie() public RecordMovie()
{ {
@ -28,105 +28,116 @@ namespace BizHawk.Client.EmuHawk
private string MakePath() private string MakePath()
{ {
if (RecordBox.Text.Length == 0) if (RecordBox.Text.Length == 0)
return ""; {
string path = RecordBox.Text; return String.Empty;
}
var path = RecordBox.Text;
if (path.LastIndexOf(Path.DirectorySeparatorChar) == -1) if (path.LastIndexOf(Path.DirectorySeparatorChar) == -1)
{ {
if (path[0] != Path.DirectorySeparatorChar) if (path[0] != Path.DirectorySeparatorChar)
{
path = path.Insert(0, Path.DirectorySeparatorChar.ToString()); path = path.Insert(0, Path.DirectorySeparatorChar.ToString());
}
path = PathManager.MakeAbsolutePath(Global.Config.PathEntries.MoviesPath, null) + path; path = PathManager.MakeAbsolutePath(Global.Config.PathEntries.MoviesPath, null) + path;
if (path[path.Length - 4] != '.') //If no file extension, add movie extension if (path[path.Length - 4] != '.') //If no file extension, add movie extension
{
path += "." + Global.Config.MovieExtension; path += "." + Global.Config.MovieExtension;
}
return path; return path;
} }
else else
{
return path; return path;
} }
}
private void OK_Click(object sender, EventArgs e) private void OK_Click(object sender, EventArgs e)
{ {
string path = MakePath(); var path = MakePath();
if (path.Length > 0) if (!String.IsNullOrWhiteSpace(path))
{ {
FileInfo test = new FileInfo(path); var test = new FileInfo(path);
if (test.Exists) if (test.Exists)
{ {
var result = MessageBox.Show(path + " already exists, overwrite?", "Confirm overwrite", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning); var result = MessageBox.Show(path + " already exists, overwrite?", "Confirm overwrite", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
if (result == DialogResult.Cancel) if (result == DialogResult.Cancel)
{
return; return;
} }
}
_movieToRecord = new Movie(path);
MovieToRecord = new Movie(path);
//Header //Header
MovieToRecord.Header.SetHeaderLine(MovieHeader.AUTHOR, AuthorBox.Text); _movieToRecord.Header.SetHeaderLine(MovieHeader.AUTHOR, AuthorBox.Text);
MovieToRecord.Header.SetHeaderLine(MovieHeader.EMULATIONVERSION, VersionInfo.GetEmuVersion()); _movieToRecord.Header.SetHeaderLine(MovieHeader.EMULATIONVERSION, VersionInfo.GetEmuVersion());
MovieToRecord.Header.SetHeaderLine(MovieHeader.MOVIEVERSION, MovieHeader.MovieVersion); _movieToRecord.Header.SetHeaderLine(MovieHeader.MOVIEVERSION, MovieHeader.MovieVersion);
MovieToRecord.Header.SetHeaderLine(MovieHeader.GUID, MovieHeader.MakeGUID()); _movieToRecord.Header.SetHeaderLine(MovieHeader.GUID, MovieHeader.MakeGUID());
MovieToRecord.Header.SetHeaderLine(MovieHeader.PLATFORM, Global.Game.System); _movieToRecord.Header.SetHeaderLine(MovieHeader.PLATFORM, Global.Game.System);
if (Global.Game != null) if (Global.Game != null)
{ {
MovieToRecord.Header.SetHeaderLine(MovieHeader.GAMENAME, PathManager.FilesystemSafeName(Global.Game)); _movieToRecord.Header.SetHeaderLine(MovieHeader.GAMENAME, PathManager.FilesystemSafeName(Global.Game));
MovieToRecord.Header.SetHeaderLine(MovieHeader.SHA1, Global.Game.Hash); _movieToRecord.Header.SetHeaderLine(MovieHeader.SHA1, Global.Game.Hash);
if (Global.Game.FirmwareHash != null) if (Global.Game.FirmwareHash != null)
MovieToRecord.Header.SetHeaderLine(MovieHeader.FIRMWARESHA1, Global.Game.FirmwareHash); {
_movieToRecord.Header.SetHeaderLine(MovieHeader.FIRMWARESHA1, Global.Game.FirmwareHash);
}
} }
else else
{ {
MovieToRecord.Header.SetHeaderLine(MovieHeader.GAMENAME, "NULL"); _movieToRecord.Header.SetHeaderLine(MovieHeader.GAMENAME, "NULL");
} }
if (Global.Emulator.BoardName != null) if (Global.Emulator.BoardName != null)
{ {
MovieToRecord.Header.SetHeaderLine(MovieHeader.BOARDNAME, Global.Emulator.BoardName); _movieToRecord.Header.SetHeaderLine(MovieHeader.BOARDNAME, Global.Emulator.BoardName);
} }
if (Global.Emulator is Gameboy) if (Global.Emulator is Gameboy)
{ {
MovieToRecord.Header.SetHeaderLine(MovieHeader.GB_FORCEDMG, Global.Config.GB_ForceDMG.ToString()); _movieToRecord.Header.SetHeaderLine(MovieHeader.GB_FORCEDMG, Global.Config.GB_ForceDMG.ToString());
MovieToRecord.Header.SetHeaderLine(MovieHeader.GB_GBA_IN_CGB, Global.Config.GB_GBACGB.ToString()); _movieToRecord.Header.SetHeaderLine(MovieHeader.GB_GBA_IN_CGB, Global.Config.GB_GBACGB.ToString());
} }
if (Global.Emulator is LibsnesCore) if (Global.Emulator is LibsnesCore)
{ {
MovieToRecord.Header.SetHeaderLine(MovieHeader.SGB, ((Global.Emulator) as LibsnesCore).IsSGB.ToString()); _movieToRecord.Header.SetHeaderLine(MovieHeader.SGB, ((Global.Emulator) as LibsnesCore).IsSGB.ToString());
if ((Global.Emulator as LibsnesCore).DisplayType == DisplayType.PAL) if ((Global.Emulator as LibsnesCore).DisplayType == DisplayType.PAL)
{ {
MovieToRecord.Header.SetHeaderLine(MovieHeader.PAL, "1"); _movieToRecord.Header.SetHeaderLine(MovieHeader.PAL, "1");
} }
} }
else if (Global.Emulator is SMS) else if (Global.Emulator is SMS)
{ {
if ((Global.Emulator as SMS).DisplayType == DisplayType.PAL) if ((Global.Emulator as SMS).DisplayType == DisplayType.PAL)
{ {
MovieToRecord.Header.SetHeaderLine(MovieHeader.PAL, "1"); _movieToRecord.Header.SetHeaderLine(MovieHeader.PAL, "1");
} }
} }
else if (Global.Emulator is NES) else if (Global.Emulator is NES)
{ {
if ((Global.Emulator as NES).DisplayType == DisplayType.PAL) if ((Global.Emulator as NES).DisplayType == DisplayType.PAL)
{ {
MovieToRecord.Header.SetHeaderLine(MovieHeader.PAL, "1"); _movieToRecord.Header.SetHeaderLine(MovieHeader.PAL, "1");
} }
} }
else if (Global.Emulator is ColecoVision) else if (Global.Emulator is ColecoVision)
{ {
MovieToRecord.Header.SetHeaderLine(MovieHeader.SKIPBIOS, Global.Config.ColecoSkipBiosIntro.ToString()); _movieToRecord.Header.SetHeaderLine(MovieHeader.SKIPBIOS, Global.Config.ColecoSkipBiosIntro.ToString());
} }
else if (Global.Emulator is N64) else if (Global.Emulator is N64)
{ {
MovieToRecord.Header.SetHeaderLine(MovieHeader.VIDEOPLUGIN, Global.Config.N64VidPlugin); _movieToRecord.Header.SetHeaderLine(MovieHeader.VIDEOPLUGIN, Global.Config.N64VidPlugin);
if (Global.Config.N64VidPlugin == "Rice") if (Global.Config.N64VidPlugin == "Rice")
{ {
var rice_settings = Global.Config.RicePlugin.GetPluginSettings(); var rice_settings = Global.Config.RicePlugin.GetPluginSettings();
foreach(var setting in rice_settings) foreach(var setting in rice_settings)
{ {
MovieToRecord.Header.SetHeaderLine(setting.Key, setting.Value.ToString()); _movieToRecord.Header.SetHeaderLine(setting.Key, setting.Value.ToString());
} }
} }
else if (Global.Config.N64VidPlugin == "Glide64") else if (Global.Config.N64VidPlugin == "Glide64")
@ -134,41 +145,38 @@ namespace BizHawk.Client.EmuHawk
var glide_settings = Global.Config.GlidePlugin.GetPluginSettings(); var glide_settings = Global.Config.GlidePlugin.GetPluginSettings();
foreach (var setting in glide_settings) foreach (var setting in glide_settings)
{ {
MovieToRecord.Header.SetHeaderLine(setting.Key, setting.Value.ToString()); _movieToRecord.Header.SetHeaderLine(setting.Key, setting.Value.ToString());
} }
} }
if ((Global.Emulator as N64).DisplayType == DisplayType.PAL) if ((Global.Emulator as N64).DisplayType == DisplayType.PAL)
{ {
MovieToRecord.Header.SetHeaderLine(MovieHeader.PAL, "1"); _movieToRecord.Header.SetHeaderLine(MovieHeader.PAL, "1");
} }
} }
if (StartFromCombo.SelectedItem.ToString() == "Now") if (StartFromCombo.SelectedItem.ToString() == "Now")
{ {
MovieToRecord.StartsFromSavestate = true; _movieToRecord.StartsFromSavestate = true;
var temppath = path; var temppath = path;
var writer = new StreamWriter(temppath); var writer = new StreamWriter(temppath);
Global.Emulator.SaveStateText(writer); Global.Emulator.SaveStateText(writer);
writer.Close(); writer.Close();
var file = new FileInfo(temppath); var file = new FileInfo(temppath);
using (StreamReader sr = file.OpenText()) using (var sr = file.OpenText())
{ {
string str; string str;
while ((str = sr.ReadLine()) != null) while ((str = sr.ReadLine()) != null)
{ {
if (str == "") if (!String.IsNullOrWhiteSpace(str))
{ {
continue; _movieToRecord.Header.Comments.Add(str);
}
else
MovieToRecord.Header.Comments.Add(str);
} }
} }
} }
GlobalWin.MainForm.StartNewMovie(MovieToRecord, true); }
GlobalWin.MainForm.StartNewMovie(_movieToRecord, true);
Global.Config.UseDefaultAuthor = DefaultAuthorCheckBox.Checked; Global.Config.UseDefaultAuthor = DefaultAuthorCheckBox.Checked;
if (DefaultAuthorCheckBox.Checked) if (DefaultAuthorCheckBox.Checked)
@ -191,26 +199,23 @@ namespace BizHawk.Client.EmuHawk
private void button1_Click(object sender, EventArgs e) private void button1_Click(object sender, EventArgs e)
{ {
string filename = ""; var filename = String.Empty;
SaveFileDialog sfd = new SaveFileDialog var sfd = new SaveFileDialog
{ {
InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.PathEntries.MoviesPath, null), InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.PathEntries.MoviesPath, null),
DefaultExt = "." + Global.Config.MovieExtension, DefaultExt = "." + Global.Config.MovieExtension,
FileName = RecordBox.Text, FileName = RecordBox.Text,
OverwritePrompt = false OverwritePrompt = false
}; };
string filter = "Movie Files (*." + Global.Config.MovieExtension + ")|*." + Global.Config.MovieExtension + "|Savestates|*.state|All Files|*.*"; var filter = "Movie Files (*." + Global.Config.MovieExtension + ")|*." + Global.Config.MovieExtension + "|Savestates|*.state|All Files|*.*";
sfd.Filter = filter; sfd.Filter = filter;
GlobalWin.Sound.StopSound(); GlobalWin.Sound.StopSound();
var result = sfd.ShowDialog(); var result = sfd.ShowDialog();
GlobalWin.Sound.StartSound(); GlobalWin.Sound.StartSound();
if (result == DialogResult.OK)
{
filename = sfd.FileName;
}
if ("" != filename) if (result == DialogResult.OK
&& !String.IsNullOrWhiteSpace(sfd.FileName))
{ {
RecordBox.Text = filename; RecordBox.Text = filename;
} }
@ -218,14 +223,16 @@ namespace BizHawk.Client.EmuHawk
private void RecordMovie_Load(object sender, EventArgs e) private void RecordMovie_Load(object sender, EventArgs e)
{ {
string name = PathManager.FilesystemSafeName(Global.Game); var name = PathManager.FilesystemSafeName(Global.Game);
name = Path.GetFileNameWithoutExtension(name); name = Path.GetFileNameWithoutExtension(name);
RecordBox.Text = name; RecordBox.Text = name;
StartFromCombo.SelectedIndex = 0; StartFromCombo.SelectedIndex = 0;
DefaultAuthorCheckBox.Checked = Global.Config.UseDefaultAuthor; DefaultAuthorCheckBox.Checked = Global.Config.UseDefaultAuthor;
if (Global.Config.UseDefaultAuthor) if (Global.Config.UseDefaultAuthor)
{
AuthorBox.Text = Global.Config.DefaultAuthor; AuthorBox.Text = Global.Config.DefaultAuthor;
} }
}
private void RecordBox_DragEnter(object sender, DragEventArgs e) private void RecordBox_DragEnter(object sender, DragEventArgs e)
{ {
@ -234,7 +241,7 @@ namespace BizHawk.Client.EmuHawk
private void RecordBox_DragDrop(object sender, DragEventArgs e) private void RecordBox_DragDrop(object sender, DragEventArgs e)
{ {
string[] filePaths = (string[])e.Data.GetData(DataFormats.FileDrop); var filePaths = (string[])e.Data.GetData(DataFormats.FileDrop);
RecordBox.Text = filePaths[0]; RecordBox.Text = filePaths[0];
} }
} }

View File

@ -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 = new Subtitle();
public SubtitleMaker() public SubtitleMaker()
{ {
@ -27,24 +27,24 @@ namespace BizHawk.Client.EmuHawk
private void OK_Click(object sender, EventArgs e) private void OK_Click(object sender, EventArgs e)
{ {
sub.Frame = (int)FrameNumeric.Value; Sub.Frame = (int)FrameNumeric.Value;
sub.Message = Message.Text; Sub.Message = Message.Text;
sub.X = (int)XNumeric.Value; Sub.X = (int)XNumeric.Value;
sub.Y = (int)YNumeric.Value; Sub.Y = (int)YNumeric.Value;
sub.Duration = (int)DurationNumeric.Value; Sub.Duration = (int)DurationNumeric.Value;
sub.Color = (uint)colorDialog1.Color.ToArgb(); Sub.Color = (uint)colorDialog1.Color.ToArgb();
DialogResult = DialogResult.OK; DialogResult = DialogResult.OK;
Close(); Close();
} }
private void SubtitleMaker_Load(object sender, EventArgs e) private void SubtitleMaker_Load(object sender, EventArgs e)
{ {
FrameNumeric.Value = sub.Frame; FrameNumeric.Value = Sub.Frame;
Message.Text = sub.Message; Message.Text = Sub.Message;
XNumeric.Value = sub.X; XNumeric.Value = Sub.X;
YNumeric.Value = sub.Y; YNumeric.Value = Sub.Y;
DurationNumeric.Value = sub.Duration; DurationNumeric.Value = Sub.Duration;
colorDialog1.Color = Color.FromArgb((int)sub.Color); colorDialog1.Color = Color.FromArgb((int)Sub.Color);
ColorPanel.BackColor = colorDialog1.Color; ColorPanel.BackColor = colorDialog1.Color;
Message.Focus(); Message.Focus();
} }