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 };
}
subForm.sub = sub;
subForm.Sub = sub;
if (subForm.ShowDialog() == DialogResult.OK)
{
@ -1883,7 +1883,7 @@ namespace BizHawk.Client.EmuHawk
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.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using BizHawk.Client.Common;
@ -21,20 +15,32 @@ namespace BizHawk.Client.EmuHawk
private void AutofireConfig_Load(object sender, EventArgs e)
{
if (Global.Config.AutofireOn < OnNumeric.Minimum)
{
OnNumeric.Value = OnNumeric.Minimum;
}
else if (Global.Config.AutofireOn > OnNumeric.Maximum)
{
OnNumeric.Value = OnNumeric.Maximum;
}
else
{
OnNumeric.Value = Global.Config.AutofireOn;
}
if (Global.Config.AutofireOff < OffNumeric.Minimum)
{
OffNumeric.Value = OffNumeric.Minimum;
}
else if (Global.Config.AutofireOff > OffNumeric.Maximum)
{
OffNumeric.Value = OffNumeric.Maximum;
}
else
{
OffNumeric.Value = Global.Config.AutofireOff;
}
LagFrameCheck.Checked = Global.Config.AutofireLagFrames;
LagFrameCheck.Checked = Global.Config.AutofireLagFrames;
}
private void Ok_Click(object sender, EventArgs e)
@ -45,13 +51,13 @@ namespace BizHawk.Client.EmuHawk
Global.AutofireStickyXORAdapter.SetOnOffPatternFromConfig();
GlobalWin.OSD.AddMessage("Autofire settings saved");
this.Close();
Close();
}
private void Cancel_Click(object sender, EventArgs e)
{
GlobalWin.OSD.AddMessage("Autofire config aborted");
this.Close();
Close();
}
}
}

View File

@ -54,36 +54,39 @@ namespace BizHawk.Client.EmuHawk
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 acp;
return new AnalogBindPanel(settings, buttons) { Dock = DockStyle.Fill };
}
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;
if (!settingsblock.TryGetValue(ControllerName, out settings))
if (!settingsblock.TryGetValue(controllerName, out settings))
{
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
foreach (string button in ControllerButtons)
foreach (var button in controllerButtons)
{
if (!settings.Keys.Contains(button))
settings[button] = defaultvalue;
}
if (settings.Keys.Count == 0)
{
return;
}
// 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++)
{
buckets[i] = new List<string>();
}
foreach (string button in settings.Keys)
foreach (var button in settings.Keys)
{
int i;
for (i = 1; i <= MAXPLAYERS; i++)
@ -118,29 +121,21 @@ namespace BizHawk.Client.EmuHawk
}
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("Keyboard");
}
else
{
tt.TabPages.Add("Console");
}
tt.TabPages.Add(Global.Emulator.SystemId == "C64" ? "Keyboard" : "Console");
tt.TabPages[pageidx].Controls.Add(createpanel(settings, buckets[0], tt.Size));
}
}
}
private readonly ControllerDefinition the_definition;
private readonly ControllerDefinition _theDefinition;
public ControllerConfig(ControllerDefinition def)
: this()
{
the_definition = def;
_theDefinition = def;
SuspendLayout();
LoadPanels(Global.Config);
Text = def.Name + " Configuration";
checkBoxUDLR.Checked = Global.Config.AllowUD_LR;
checkBoxAutoTab.Checked = Global.Config.InputConfigAutoTab;
@ -154,13 +149,13 @@ namespace BizHawk.Client.EmuHawk
ResumeLayout();
}
private void LoadPanels(Dictionary<string, Dictionary<string, string>> normal,
Dictionary<string, Dictionary<string, string>> autofire,
Dictionary<string, Dictionary<string, Config.AnalogBind>> analog)
private void LoadPanels(IDictionary<string, Dictionary<string, string>> normal,
IDictionary<string, Dictionary<string, string>> autofire,
IDictionary<string, Dictionary<string, Config.AnalogBind>> analog)
{
LoadToPanel(tabPage1, the_definition.Name, the_definition.BoolButtons, normal, "", CreateNormalPanel);
LoadToPanel(tabPage2, the_definition.Name, the_definition.BoolButtons, autofire, "", CreateNormalPanel);
LoadToPanel(tabPage3, the_definition.Name, the_definition.FloatControls, analog, new Config.AnalogBind("", 1.0f, 0.1f), CreateAnalogPanel);
LoadToPanel(tabPage1, _theDefinition.Name, _theDefinition.BoolButtons, normal, "", CreateNormalPanel);
LoadToPanel(tabPage2, _theDefinition.Name, _theDefinition.BoolButtons, autofire, "", CreateNormalPanel);
LoadToPanel(tabPage3, _theDefinition.Name, _theDefinition.FloatControls, analog, new Config.AnalogBind("", 1.0f, 0.1f), CreateAnalogPanel);
if (tabPage3.Controls.Count == 0)
{
@ -178,20 +173,22 @@ namespace BizHawk.Client.EmuHawk
LoadPanels(c.AllTrollers, c.AllTrollersAutoFire, c.AllTrollersAnalog);
}
void SetControllerPicture(string ControlName)
void SetControllerPicture(string controlName)
{
Bitmap bmp;
if (!ControllerImages.TryGetValue(ControlName, out bmp))
if (!ControllerImages.TryGetValue(controlName, out bmp))
{
bmp = Properties.Resources.Help;
}
pictureBox1.Image = bmp;
pictureBox1.Size = bmp.Size;
tableLayoutPanel1.ColumnStyles[1].Width = bmp.Width;
//Uberhack
if (ControlName == "Commodore 64 Controller")
if (controlName == "Commodore 64 Controller")
{
PictureBox pictureBox2 = new PictureBox
var pictureBox2 = new PictureBox
{
Image = Properties.Resources.C64Keyboard,
Size = Properties.Resources.C64Keyboard.Size
@ -213,27 +210,33 @@ namespace BizHawk.Client.EmuHawk
static void SetAutoTab(Control c, bool value)
{
if (c is ControllerConfigPanel)
{
(c as ControllerConfigPanel).SetAutoTab(value);
}
else if (c is AnalogBindPanel)
{
// TODO
}
else if (c.HasChildren)
{
foreach (Control cc in c.Controls)
{
SetAutoTab(cc, value);
}
}
}
void Save()
{
ActOnControlCollection<ControllerConfigPanel>(tabPage1, c => c.Save(Global.Config.AllTrollers[the_definition.Name]));
ActOnControlCollection<ControllerConfigPanel>(tabPage2, c => c.Save(Global.Config.AllTrollersAutoFire[the_definition.Name]));
ActOnControlCollection<AnalogBindPanel>(tabPage3, c => c.Save(Global.Config.AllTrollersAnalog[the_definition.Name]));
ActOnControlCollection<ControllerConfigPanel>(tabPage1, c => c.Save(Global.Config.AllTrollers[_theDefinition.Name]));
ActOnControlCollection<ControllerConfigPanel>(tabPage2, c => c.Save(Global.Config.AllTrollersAutoFire[_theDefinition.Name]));
ActOnControlCollection<AnalogBindPanel>(tabPage3, c => c.Save(Global.Config.AllTrollersAnalog[_theDefinition.Name]));
}
void SaveToDefaults(ControlDefaults cd)
{
ActOnControlCollection<ControllerConfigPanel>(tabPage1, c => c.Save(cd.AllTrollers[the_definition.Name]));
ActOnControlCollection<ControllerConfigPanel>(tabPage2, c => c.Save(cd.AllTrollersAutoFire[the_definition.Name]));
ActOnControlCollection<AnalogBindPanel>(tabPage3, c => c.Save(cd.AllTrollersAnalog[the_definition.Name]));
ActOnControlCollection<ControllerConfigPanel>(tabPage1, c => c.Save(cd.AllTrollers[_theDefinition.Name]));
ActOnControlCollection<ControllerConfigPanel>(tabPage2, c => c.Save(cd.AllTrollersAutoFire[_theDefinition.Name]));
ActOnControlCollection<AnalogBindPanel>(tabPage3, c => c.Save(cd.AllTrollersAnalog[_theDefinition.Name]));
}
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)
{
Text = _theDefinition.Name + " Configuration";
}
private TabControl GetTabControl(IEnumerable controls)
private static TabControl GetTabControl(IEnumerable controls)
{
if (controls != null)
{
@ -294,10 +297,10 @@ namespace BizHawk.Client.EmuHawk
{
tabControl1.SuspendLayout();
string wasTabbedMain = tabControl1.SelectedTab.Name;
TabControl tb1 = GetTabControl(tabPage1.Controls);
TabControl tb2 = GetTabControl(tabPage2.Controls);
TabControl tb3 = GetTabControl(tabPage3.Controls);
var wasTabbedMain = tabControl1.SelectedTab.Name;
var tb1 = GetTabControl(tabPage1.Controls);
var tb2 = GetTabControl(tabPage2.Controls);
var tb3 = GetTabControl(tabPage3.Controls);
int? wasTabbedPage1 = null;
int? wasTabbedPage2 = null;
int? wasTabbedPage3 = null;
@ -313,7 +316,7 @@ namespace BizHawk.Client.EmuHawk
// load panels directly from the default config.
// this means that the changes are NOT committed. so "Cancel" works right and you
// still have to hit OK at the end.
ControlDefaults cd = new ControlDefaults();
var cd = new ControlDefaults();
cd = ConfigService.Load(Config.ControlDefaultPath, cd);
LoadPanels(cd);
@ -321,7 +324,7 @@ namespace BizHawk.Client.EmuHawk
if (wasTabbedPage1.HasValue)
{
TabControl newTb1 = GetTabControl(tabPage1.Controls);
var newTb1 = GetTabControl(tabPage1.Controls);
if (newTb1 != null)
{
newTb1.SelectTab(wasTabbedPage1.Value);
@ -330,7 +333,7 @@ namespace BizHawk.Client.EmuHawk
if (wasTabbedPage2.HasValue)
{
TabControl newTb2 = GetTabControl(tabPage2.Controls);
var newTb2 = GetTabControl(tabPage2.Controls);
if (newTb2 != null)
{
newTb2.SelectTab(wasTabbedPage2.Value);
@ -339,7 +342,7 @@ namespace BizHawk.Client.EmuHawk
if (wasTabbedPage3.HasValue)
{
TabControl newTb3 = GetTabControl(tabPage3.Controls);
var newTb3 = GetTabControl(tabPage3.Controls);
if (newTb3 != null)
{
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);
if (result == DialogResult.Yes)
{
ControlDefaults cd = new ControlDefaults();
var cd = new ControlDefaults();
cd = ConfigService.Load(Config.ControlDefaultPath, cd);
cd.AllTrollers[the_definition.Name] = new Dictionary<string, string>();
cd.AllTrollersAutoFire[the_definition.Name] = new Dictionary<string, string>();
cd.AllTrollersAnalog[the_definition.Name] = new Dictionary<string, Config.AnalogBind>();
cd.AllTrollers[_theDefinition.Name] = new Dictionary<string, string>();
cd.AllTrollersAutoFire[_theDefinition.Name] = new Dictionary<string, string>();
cd.AllTrollersAnalog[_theDefinition.Name] = new Dictionary<string, Config.AnalogBind>();
SaveToDefaults(cd);

View File

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

File diff suppressed because it is too large Load Diff

View File

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

View File

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

View File

@ -1,10 +1,4 @@
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;
namespace BizHawk.Client.EmuHawk

View File

@ -1,10 +1,4 @@
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 BizHawk.Client.Common;
@ -38,7 +32,9 @@ namespace BizHawk.Client.EmuHawk
{
listBoxSoundDevices.Items.Add(d);
if (d == Global.Config.SoundDevice)
{
listBoxSoundDevices.SelectedItem = d;
}
}
}
@ -53,13 +49,13 @@ namespace BizHawk.Client.EmuHawk
GlobalWin.Sound.UpdateSoundSettings();
GlobalWin.Sound.StartSound();
GlobalWin.OSD.AddMessage("Sound settings saved");
this.Close();
Close();
}
private void Cancel_Click(object sender, EventArgs e)
{
GlobalWin.OSD.AddMessage("Sound config aborted");
this.Close();
Close();
}
private void trackBar1_Scroll(object sender, EventArgs e)
@ -79,18 +75,10 @@ namespace BizHawk.Client.EmuHawk
private void UpdateSoundDialog()
{
if (SoundOnCheckBox.Checked)
{
SoundVolGroup.Enabled = true;
MuteFrameAdvance.Enabled = true;
ThrottlecheckBox.Enabled = true;
}
else
{
SoundVolGroup.Enabled = false;
MuteFrameAdvance.Enabled = false;
ThrottlecheckBox.Enabled = false;
}
SoundVolGroup.Enabled =
MuteFrameAdvance.Enabled =
ThrottlecheckBox.Enabled =
SoundOnCheckBox.Checked;
}
}
}

View File

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

View File

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

View File

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

View File

@ -28,167 +28,168 @@
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(RecordMovie));
this.Cancel = new System.Windows.Forms.Button();
this.OK = new System.Windows.Forms.Button();
this.Browse = new System.Windows.Forms.Button();
this.RecordBox = new System.Windows.Forms.TextBox();
this.StartFromCombo = new System.Windows.Forms.ComboBox();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.DefaultAuthorCheckBox = new System.Windows.Forms.CheckBox();
this.AuthorBox = new System.Windows.Forms.TextBox();
this.label3 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.groupBox1.SuspendLayout();
this.SuspendLayout();
//
// Cancel
//
this.Cancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.Cancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.Cancel.Location = new System.Drawing.Point(391, 139);
this.Cancel.Name = "Cancel";
this.Cancel.Size = new System.Drawing.Size(75, 23);
this.Cancel.TabIndex = 1;
this.Cancel.Text = "&Cancel";
this.Cancel.UseVisualStyleBackColor = true;
this.Cancel.Click += new System.EventHandler(this.Cancel_Click);
//
// OK
//
this.OK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.OK.Location = new System.Drawing.Point(310, 139);
this.OK.Name = "OK";
this.OK.Size = new System.Drawing.Size(75, 23);
this.OK.TabIndex = 0;
this.OK.Text = "&Ok";
this.OK.UseVisualStyleBackColor = true;
this.OK.Click += new System.EventHandler(this.OK_Click);
//
// Browse
//
this.Browse.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.Browse.Image = global::BizHawk.Client.EmuHawk.Properties.Resources.OpenFile;
this.Browse.Location = new System.Drawing.Point(423, 13);
this.Browse.Name = "Browse";
this.Browse.Size = new System.Drawing.Size(25, 23);
this.Browse.TabIndex = 1;
this.Browse.UseVisualStyleBackColor = true;
this.Browse.Click += new System.EventHandler(this.button1_Click);
//
// RecordBox
//
this.RecordBox.AllowDrop = true;
this.RecordBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(RecordMovie));
this.Cancel = new System.Windows.Forms.Button();
this.OK = new System.Windows.Forms.Button();
this.Browse = new System.Windows.Forms.Button();
this.RecordBox = new System.Windows.Forms.TextBox();
this.StartFromCombo = new System.Windows.Forms.ComboBox();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.DefaultAuthorCheckBox = new System.Windows.Forms.CheckBox();
this.AuthorBox = new System.Windows.Forms.TextBox();
this.label3 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.groupBox1.SuspendLayout();
this.SuspendLayout();
//
// Cancel
//
this.Cancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.Cancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.Cancel.Location = new System.Drawing.Point(391, 139);
this.Cancel.Name = "Cancel";
this.Cancel.Size = new System.Drawing.Size(75, 23);
this.Cancel.TabIndex = 1;
this.Cancel.Text = "&Cancel";
this.Cancel.UseVisualStyleBackColor = true;
this.Cancel.Click += new System.EventHandler(this.Cancel_Click);
//
// OK
//
this.OK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.OK.Location = new System.Drawing.Point(310, 139);
this.OK.Name = "OK";
this.OK.Size = new System.Drawing.Size(75, 23);
this.OK.TabIndex = 0;
this.OK.Text = "&Ok";
this.OK.UseVisualStyleBackColor = true;
this.OK.Click += new System.EventHandler(this.OK_Click);
//
// Browse
//
this.Browse.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.Browse.Image = global::BizHawk.Client.EmuHawk.Properties.Resources.OpenFile;
this.Browse.Location = new System.Drawing.Point(423, 13);
this.Browse.Name = "Browse";
this.Browse.Size = new System.Drawing.Size(25, 23);
this.Browse.TabIndex = 1;
this.Browse.UseVisualStyleBackColor = true;
this.Browse.Click += new System.EventHandler(this.button1_Click);
//
// RecordBox
//
this.RecordBox.AllowDrop = true;
this.RecordBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.RecordBox.Location = new System.Drawing.Point(83, 13);
this.RecordBox.Name = "RecordBox";
this.RecordBox.Size = new System.Drawing.Size(334, 20);
this.RecordBox.TabIndex = 0;
this.RecordBox.DragDrop += new System.Windows.Forms.DragEventHandler(this.RecordBox_DragDrop);
this.RecordBox.DragEnter += new System.Windows.Forms.DragEventHandler(this.RecordBox_DragEnter);
//
// StartFromCombo
//
this.StartFromCombo.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.StartFromCombo.FormattingEnabled = true;
this.StartFromCombo.Items.AddRange(new object[] {
this.RecordBox.Location = new System.Drawing.Point(83, 13);
this.RecordBox.Name = "RecordBox";
this.RecordBox.Size = new System.Drawing.Size(334, 20);
this.RecordBox.TabIndex = 0;
this.RecordBox.DragDrop += new System.Windows.Forms.DragEventHandler(this.RecordBox_DragDrop);
this.RecordBox.DragEnter += new System.Windows.Forms.DragEventHandler(this.RecordBox_DragEnter);
//
// StartFromCombo
//
this.StartFromCombo.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.StartFromCombo.FormattingEnabled = true;
this.StartFromCombo.Items.AddRange(new object[] {
"Power-On",
"Now"});
this.StartFromCombo.Location = new System.Drawing.Point(83, 65);
this.StartFromCombo.MaxDropDownItems = 32;
this.StartFromCombo.Name = "StartFromCombo";
this.StartFromCombo.Size = new System.Drawing.Size(152, 21);
this.StartFromCombo.TabIndex = 3;
//
// groupBox1
//
this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
this.StartFromCombo.Location = new System.Drawing.Point(83, 65);
this.StartFromCombo.MaxDropDownItems = 32;
this.StartFromCombo.Name = "StartFromCombo";
this.StartFromCombo.Size = new System.Drawing.Size(152, 21);
this.StartFromCombo.TabIndex = 3;
//
// groupBox1
//
this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.groupBox1.Controls.Add(this.DefaultAuthorCheckBox);
this.groupBox1.Controls.Add(this.AuthorBox);
this.groupBox1.Controls.Add(this.StartFromCombo);
this.groupBox1.Controls.Add(this.Browse);
this.groupBox1.Controls.Add(this.label3);
this.groupBox1.Controls.Add(this.label2);
this.groupBox1.Controls.Add(this.label1);
this.groupBox1.Controls.Add(this.RecordBox);
this.groupBox1.Location = new System.Drawing.Point(12, 12);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(454, 112);
this.groupBox1.TabIndex = 0;
this.groupBox1.TabStop = false;
//
// DefaultAuthorCheckBox
//
this.DefaultAuthorCheckBox.Anchor = System.Windows.Forms.AnchorStyles.Right;
this.DefaultAuthorCheckBox.AutoSize = true;
this.DefaultAuthorCheckBox.Location = new System.Drawing.Point(327, 64);
this.DefaultAuthorCheckBox.Name = "DefaultAuthorCheckBox";
this.DefaultAuthorCheckBox.Size = new System.Drawing.Size(121, 17);
this.DefaultAuthorCheckBox.TabIndex = 6;
this.DefaultAuthorCheckBox.Text = "Make default author";
this.DefaultAuthorCheckBox.UseVisualStyleBackColor = true;
//
// AuthorBox
//
this.AuthorBox.AllowDrop = true;
this.AuthorBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
this.groupBox1.Controls.Add(this.DefaultAuthorCheckBox);
this.groupBox1.Controls.Add(this.AuthorBox);
this.groupBox1.Controls.Add(this.StartFromCombo);
this.groupBox1.Controls.Add(this.Browse);
this.groupBox1.Controls.Add(this.label3);
this.groupBox1.Controls.Add(this.label2);
this.groupBox1.Controls.Add(this.label1);
this.groupBox1.Controls.Add(this.RecordBox);
this.groupBox1.Location = new System.Drawing.Point(12, 12);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(454, 112);
this.groupBox1.TabIndex = 0;
this.groupBox1.TabStop = false;
//
// DefaultAuthorCheckBox
//
this.DefaultAuthorCheckBox.Anchor = System.Windows.Forms.AnchorStyles.Right;
this.DefaultAuthorCheckBox.AutoSize = true;
this.DefaultAuthorCheckBox.Location = new System.Drawing.Point(327, 64);
this.DefaultAuthorCheckBox.Name = "DefaultAuthorCheckBox";
this.DefaultAuthorCheckBox.Size = new System.Drawing.Size(121, 17);
this.DefaultAuthorCheckBox.TabIndex = 6;
this.DefaultAuthorCheckBox.Text = "Make default author";
this.DefaultAuthorCheckBox.UseVisualStyleBackColor = true;
//
// AuthorBox
//
this.AuthorBox.AllowDrop = true;
this.AuthorBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.AuthorBox.Location = new System.Drawing.Point(83, 39);
this.AuthorBox.Name = "AuthorBox";
this.AuthorBox.Size = new System.Drawing.Size(365, 20);
this.AuthorBox.TabIndex = 2;
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(36, 41);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(41, 13);
this.label3.TabIndex = 2;
this.label3.Text = "Author:";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(6, 68);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(71, 13);
this.label2.TabIndex = 5;
this.label2.Text = "Record From:";
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(51, 16);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(26, 13);
this.label1.TabIndex = 4;
this.label1.Text = "File:";
//
// RecordMovie
//
this.AcceptButton = this.OK;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CancelButton = this.Cancel;
this.ClientSize = new System.Drawing.Size(478, 163);
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.OK);
this.Controls.Add(this.Cancel);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MaximizeBox = false;
this.MaximumSize = new System.Drawing.Size(1440, 201);
this.MinimizeBox = false;
this.Name = "RecordMovie";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Record Movie";
this.Load += new System.EventHandler(this.RecordMovie_Load);
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
this.ResumeLayout(false);
this.AuthorBox.Location = new System.Drawing.Point(83, 39);
this.AuthorBox.Name = "AuthorBox";
this.AuthorBox.Size = new System.Drawing.Size(365, 20);
this.AuthorBox.TabIndex = 2;
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(36, 41);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(41, 13);
this.label3.TabIndex = 2;
this.label3.Text = "Author:";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(6, 68);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(71, 13);
this.label2.TabIndex = 5;
this.label2.Text = "Record From:";
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(51, 16);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(26, 13);
this.label1.TabIndex = 4;
this.label1.Text = "File:";
//
// RecordMovie
//
this.AcceptButton = this.OK;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CancelButton = this.Cancel;
this.ClientSize = new System.Drawing.Size(478, 163);
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.OK);
this.Controls.Add(this.Cancel);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MaximizeBox = false;
this.MaximumSize = new System.Drawing.Size(1440, 201);
this.MinimizeBox = false;
this.MinimumSize = new System.Drawing.Size(425, 201);
this.Name = "RecordMovie";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Record Movie";
this.Load += new System.EventHandler(this.RecordMovie_Load);
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
this.ResumeLayout(false);
}

View File

@ -18,7 +18,7 @@ namespace BizHawk.Client.EmuHawk
//TODO
//Allow relative paths in record textbox
Movie MovieToRecord;
private Movie _movieToRecord;
public RecordMovie()
{
@ -28,105 +28,116 @@ namespace BizHawk.Client.EmuHawk
private string MakePath()
{
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[0] != Path.DirectorySeparatorChar)
{
path = path.Insert(0, Path.DirectorySeparatorChar.ToString());
}
path = PathManager.MakeAbsolutePath(Global.Config.PathEntries.MoviesPath, null) + path;
if (path[path.Length - 4] != '.') //If no file extension, add movie extension
{
path += "." + Global.Config.MovieExtension;
}
return path;
}
else
{
return path;
}
}
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)
{
var result = MessageBox.Show(path + " already exists, overwrite?", "Confirm overwrite", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
if (result == DialogResult.Cancel)
{
return;
}
}
MovieToRecord = new Movie(path);
_movieToRecord = new Movie(path);
//Header
MovieToRecord.Header.SetHeaderLine(MovieHeader.AUTHOR, AuthorBox.Text);
MovieToRecord.Header.SetHeaderLine(MovieHeader.EMULATIONVERSION, VersionInfo.GetEmuVersion());
MovieToRecord.Header.SetHeaderLine(MovieHeader.MOVIEVERSION, MovieHeader.MovieVersion);
MovieToRecord.Header.SetHeaderLine(MovieHeader.GUID, MovieHeader.MakeGUID());
MovieToRecord.Header.SetHeaderLine(MovieHeader.PLATFORM, Global.Game.System);
_movieToRecord.Header.SetHeaderLine(MovieHeader.AUTHOR, AuthorBox.Text);
_movieToRecord.Header.SetHeaderLine(MovieHeader.EMULATIONVERSION, VersionInfo.GetEmuVersion());
_movieToRecord.Header.SetHeaderLine(MovieHeader.MOVIEVERSION, MovieHeader.MovieVersion);
_movieToRecord.Header.SetHeaderLine(MovieHeader.GUID, MovieHeader.MakeGUID());
_movieToRecord.Header.SetHeaderLine(MovieHeader.PLATFORM, Global.Game.System);
if (Global.Game != null)
{
MovieToRecord.Header.SetHeaderLine(MovieHeader.GAMENAME, PathManager.FilesystemSafeName(Global.Game));
MovieToRecord.Header.SetHeaderLine(MovieHeader.SHA1, Global.Game.Hash);
_movieToRecord.Header.SetHeaderLine(MovieHeader.GAMENAME, PathManager.FilesystemSafeName(Global.Game));
_movieToRecord.Header.SetHeaderLine(MovieHeader.SHA1, Global.Game.Hash);
if (Global.Game.FirmwareHash != null)
MovieToRecord.Header.SetHeaderLine(MovieHeader.FIRMWARESHA1, Global.Game.FirmwareHash);
{
_movieToRecord.Header.SetHeaderLine(MovieHeader.FIRMWARESHA1, Global.Game.FirmwareHash);
}
}
else
{
MovieToRecord.Header.SetHeaderLine(MovieHeader.GAMENAME, "NULL");
_movieToRecord.Header.SetHeaderLine(MovieHeader.GAMENAME, "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)
{
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_FORCEDMG, Global.Config.GB_ForceDMG.ToString());
_movieToRecord.Header.SetHeaderLine(MovieHeader.GB_GBA_IN_CGB, Global.Config.GB_GBACGB.ToString());
}
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)
{
MovieToRecord.Header.SetHeaderLine(MovieHeader.PAL, "1");
_movieToRecord.Header.SetHeaderLine(MovieHeader.PAL, "1");
}
}
else if (Global.Emulator is SMS)
{
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)
{
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)
{
MovieToRecord.Header.SetHeaderLine(MovieHeader.SKIPBIOS, Global.Config.ColecoSkipBiosIntro.ToString());
_movieToRecord.Header.SetHeaderLine(MovieHeader.SKIPBIOS, Global.Config.ColecoSkipBiosIntro.ToString());
}
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")
{
var rice_settings = Global.Config.RicePlugin.GetPluginSettings();
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")
@ -134,41 +145,38 @@ namespace BizHawk.Client.EmuHawk
var glide_settings = Global.Config.GlidePlugin.GetPluginSettings();
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)
{
MovieToRecord.Header.SetHeaderLine(MovieHeader.PAL, "1");
_movieToRecord.Header.SetHeaderLine(MovieHeader.PAL, "1");
}
}
if (StartFromCombo.SelectedItem.ToString() == "Now")
{
MovieToRecord.StartsFromSavestate = true;
_movieToRecord.StartsFromSavestate = true;
var temppath = path;
var writer = new StreamWriter(temppath);
Global.Emulator.SaveStateText(writer);
writer.Close();
var file = new FileInfo(temppath);
using (StreamReader sr = file.OpenText())
using (var sr = file.OpenText())
{
string str;
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;
if (DefaultAuthorCheckBox.Checked)
@ -191,26 +199,23 @@ namespace BizHawk.Client.EmuHawk
private void button1_Click(object sender, EventArgs e)
{
string filename = "";
SaveFileDialog sfd = new SaveFileDialog
var filename = String.Empty;
var sfd = new SaveFileDialog
{
InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.PathEntries.MoviesPath, null),
DefaultExt = "." + Global.Config.MovieExtension,
FileName = RecordBox.Text,
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;
GlobalWin.Sound.StopSound();
var result = sfd.ShowDialog();
GlobalWin.Sound.StartSound();
if (result == DialogResult.OK)
{
filename = sfd.FileName;
}
if ("" != filename)
if (result == DialogResult.OK
&& !String.IsNullOrWhiteSpace(sfd.FileName))
{
RecordBox.Text = filename;
}
@ -218,13 +223,15 @@ namespace BizHawk.Client.EmuHawk
private void RecordMovie_Load(object sender, EventArgs e)
{
string name = PathManager.FilesystemSafeName(Global.Game);
var name = PathManager.FilesystemSafeName(Global.Game);
name = Path.GetFileNameWithoutExtension(name);
RecordBox.Text = name;
StartFromCombo.SelectedIndex = 0;
DefaultAuthorCheckBox.Checked = Global.Config.UseDefaultAuthor;
if (Global.Config.UseDefaultAuthor)
{
AuthorBox.Text = Global.Config.DefaultAuthor;
}
}
private void RecordBox_DragEnter(object sender, DragEventArgs e)
@ -234,7 +241,7 @@ namespace BizHawk.Client.EmuHawk
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];
}
}

View File

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