UI: Added configuration wizard + portable mode support

This commit is contained in:
Sour 2019-03-15 16:19:42 -04:00
parent a8d9b77c98
commit 9af57723ec
14 changed files with 1359 additions and 43 deletions

View file

@ -275,10 +275,9 @@ namespace Mesen.GUI.Config
public static void ResetSettings()
{
//TODO
//DefaultKeyMappingType defaultMappings = Config.InputInfo.DefaultMapping;
DefaultKeyMappingType defaultMappings = Config.DefaultKeyMappings;
_dirtyConfig = new Configuration();
//Config.InputInfo.DefaultMapping = defaultMappings;
Config.DefaultKeyMappings = defaultMappings;
Config.InitializeDefaults();
ApplyChanges();
Config.ApplyConfig();

View file

@ -26,6 +26,7 @@ namespace Mesen.GUI.Config
public Point WindowLocation;
public Size WindowSize;
public bool NeedInputReinit = true;
public DefaultKeyMappingType DefaultKeyMappings = DefaultKeyMappingType.None;
public Configuration()
{
@ -73,7 +74,7 @@ namespace Mesen.GUI.Config
{
Preferences.InitializeDefaultShortcuts();
if(NeedInputReinit) {
Input.InitializeDefaults();
Input.InitializeDefaults(DefaultKeyMappings);
NeedInputReinit = false;
}
ConfigManager.ApplyChanges();

View file

@ -34,45 +34,41 @@ namespace Mesen.GUI.Config
{
if(Controllers.Length != 5) {
Controllers = new ControllerConfig[5];
InitializeDefaults();
}
ConfigApi.SetInputConfig(this);
}
public void InitializeDefaults()
public void InitializeDefaults(DefaultKeyMappingType defaultMappings)
{
KeyMapping m1 = new KeyMapping();
m1.Up = InputApi.GetKeyCode("Pad1 Up");
m1.Down = InputApi.GetKeyCode("Pad1 Down");
m1.Left = InputApi.GetKeyCode("Pad1 Left");
m1.Right = InputApi.GetKeyCode("Pad1 Right");
m1.A = InputApi.GetKeyCode("Pad1 B");
m1.B = InputApi.GetKeyCode("Pad1 A");
m1.X = InputApi.GetKeyCode("Pad1 Y");
m1.Y = InputApi.GetKeyCode("Pad1 X");
m1.L = InputApi.GetKeyCode("Pad1 L1");
m1.R = InputApi.GetKeyCode("Pad1 R1");
m1.Select = InputApi.GetKeyCode("Pad1 Back");
m1.Start = InputApi.GetKeyCode("Pad1 Start");
KeyMapping m2 = new KeyMapping();
m2.Up = InputApi.GetKeyCode("Up Arrow");
m2.Down = InputApi.GetKeyCode("Down Arrow");
m2.Left = InputApi.GetKeyCode("Left Arrow");
m2.Right = InputApi.GetKeyCode("Right Arrow");
m2.A = InputApi.GetKeyCode("Z");
m2.B = InputApi.GetKeyCode("X");
m2.X = InputApi.GetKeyCode("S");
m2.Y = InputApi.GetKeyCode("A");
m2.L = InputApi.GetKeyCode("Q");
m2.R = InputApi.GetKeyCode("W");
m2.Select = InputApi.GetKeyCode("E");
m2.Start = InputApi.GetKeyCode("D");
KeyPresets presets = new KeyPresets();
List<KeyMapping> mappings = new List<KeyMapping>();
if(defaultMappings.HasFlag(DefaultKeyMappingType.Xbox)) {
mappings.Add(presets.XboxLayout1);
}
if(defaultMappings.HasFlag(DefaultKeyMappingType.Ps4)) {
mappings.Add(presets.Ps4Layout1);
}
if(defaultMappings.HasFlag(DefaultKeyMappingType.WasdKeys)) {
mappings.Add(presets.WasdLayout);
}
if(defaultMappings.HasFlag(DefaultKeyMappingType.ArrowKeys)) {
mappings.Add(presets.ArrowLayout);
}
Controllers[0].Type = ControllerType.SnesController;
Controllers[0].Keys.TurboSpeed = 2;
Controllers[0].Keys.Mapping1 = m1;
Controllers[0].Keys.Mapping2 = m2;
if(mappings.Count > 0) {
Controllers[0].Keys.Mapping1 = mappings[0];
if(mappings.Count > 1) {
Controllers[0].Keys.Mapping2 = mappings[1];
if(mappings.Count > 2) {
Controllers[0].Keys.Mapping3 = mappings[2];
if(mappings.Count > 3) {
Controllers[0].Keys.Mapping4 = mappings[3];
}
}
}
}
}
}

View file

@ -13,7 +13,7 @@ namespace Mesen.GUI.Config
public class RecentItems
{
private const int MaxRecentFiles = 10;
public List<RecentItem> Items;
public List<RecentItem> Items = new List<RecentItem>();
public void AddRecentFile(ResourcePath romFile, ResourcePath? patchFile)
{

View file

@ -0,0 +1,86 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Mesen.GUI.Forms.Config
{
public partial class frmCopyFiles : Form
{
private volatile int _fileCount = -1;
private volatile int _filesCopied = 0;
private List<string> _sourceFiles = new List<string>();
private List<string> _targetFiles = new List<string>();
public Exception Exception { get; set; }
public frmCopyFiles(string source, string target)
{
InitializeComponent();
tmrProgress.Start();
Task.Run(() => {
GetFilesToCopy(source, target, _sourceFiles, _targetFiles);
_fileCount = _sourceFiles.Count;
for(int i = 0; i < _sourceFiles.Count; i++) {
try {
File.Copy(_sourceFiles[i], _targetFiles[i], true);
} catch(Exception ex) {
Exception = ex;
break;
}
_filesCopied++;
}
});
}
private void GetFilesToCopy(string source, string target, List<string> sourceFiles, List<string> targetFiles)
{
if(!Directory.Exists(target)) {
Directory.CreateDirectory(target);
}
foreach(string file in Directory.GetFiles(source)) {
if(Path.GetExtension(file).ToLower() != ".exe" && Path.GetExtension(file).ToLower() != ".dll") {
sourceFiles.Add(file);
targetFiles.Add(Path.Combine(target, Path.GetFileName(file)));
}
}
foreach(string subdir in Directory.GetDirectories(source)) {
GetFilesToCopy(subdir, Path.Combine(target, Path.GetDirectoryName(subdir)), sourceFiles, targetFiles);
}
}
protected override void OnFormClosing(FormClosingEventArgs e)
{
if(_filesCopied < _fileCount && Exception == null) {
e.Cancel = true;
}
base.OnFormClosing(e);
}
private void tmrProgress_Tick(object sender, EventArgs e)
{
if(_fileCount >= 0) {
pbProgress.Maximum = _fileCount + 1;
pbProgress.Value = _filesCopied + 1;
pbProgress.Value = _filesCopied;
if(_sourceFiles.Count > _filesCopied) {
lblTarget.Text = Path.GetFileName(_sourceFiles[_filesCopied]);
}
if(_filesCopied >= _fileCount || Exception != null) {
tmrProgress.Stop();
this.Close();
}
}
}
}
}

114
UI/Forms/Config/frmCopyFiles.designer.cs generated Normal file
View file

@ -0,0 +1,114 @@
namespace Mesen.GUI.Forms.Config
{
partial class frmCopyFiles
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if(disposing && (components != null)) {
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
this.pbProgress = new System.Windows.Forms.ProgressBar();
this.lblCopying = new System.Windows.Forms.Label();
this.lblTarget = new System.Windows.Forms.Label();
this.tmrProgress = new System.Windows.Forms.Timer(this.components);
this.tableLayoutPanel1.SuspendLayout();
this.SuspendLayout();
//
// tableLayoutPanel1
//
this.tableLayoutPanel1.ColumnCount = 2;
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel1.Controls.Add(this.lblTarget, 1, 0);
this.tableLayoutPanel1.Controls.Add(this.pbProgress, 0, 1);
this.tableLayoutPanel1.Controls.Add(this.lblCopying, 0, 0);
this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0);
this.tableLayoutPanel1.Name = "tableLayoutPanel1";
this.tableLayoutPanel1.RowCount = 2;
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanel1.Size = new System.Drawing.Size(268, 64);
this.tableLayoutPanel1.TabIndex = 0;
//
// pbProgress
//
this.tableLayoutPanel1.SetColumnSpan(this.pbProgress, 2);
this.pbProgress.Dock = System.Windows.Forms.DockStyle.Fill;
this.pbProgress.Location = new System.Drawing.Point(3, 38);
this.pbProgress.Name = "pbProgress";
this.pbProgress.Size = new System.Drawing.Size(262, 23);
this.pbProgress.TabIndex = 0;
//
// lblCopying
//
this.lblCopying.Anchor = System.Windows.Forms.AnchorStyles.Left;
this.lblCopying.AutoSize = true;
this.lblCopying.Location = new System.Drawing.Point(3, 11);
this.lblCopying.Name = "lblCopying";
this.lblCopying.Size = new System.Drawing.Size(48, 13);
this.lblCopying.TabIndex = 1;
this.lblCopying.Text = "Copying:";
//
// lblTarget
//
this.lblTarget.Anchor = System.Windows.Forms.AnchorStyles.Left;
this.lblTarget.AutoSize = true;
this.lblTarget.Location = new System.Drawing.Point(57, 11);
this.lblTarget.Name = "lblTarget";
this.lblTarget.Size = new System.Drawing.Size(19, 13);
this.lblTarget.TabIndex = 2;
this.lblTarget.Text = "....";
//
// tmrProgress
//
this.tmrProgress.Tick += new System.EventHandler(this.tmrProgress_Tick);
//
// frmCopyFiles
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(268, 64);
this.ControlBox = false;
this.Controls.Add(this.tableLayoutPanel1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
this.Name = "frmCopyFiles";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Please wait...";
this.tableLayoutPanel1.ResumeLayout(false);
this.tableLayoutPanel1.PerformLayout();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1;
private System.Windows.Forms.Label lblTarget;
private System.Windows.Forms.ProgressBar pbProgress;
private System.Windows.Forms.Label lblCopying;
private System.Windows.Forms.Timer tmrProgress;
}
}

View file

@ -0,0 +1,123 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="tmrProgress.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>

View file

@ -1,4 +1,5 @@
using Mesen.GUI.Config;
using Mesen.GUI.Utilities;
using System;
using System.Collections.Generic;
using System.ComponentModel;
@ -121,5 +122,70 @@ namespace Mesen.GUI.Forms.Config
{
UpdateLocationText();
}
protected override void OnFormClosing(FormClosingEventArgs e)
{
if(this.DialogResult == DialogResult.OK) {
if(!ValidateFolderSettings()) {
e.Cancel = true;
return;
}
if(radStorageDocuments.Checked != (ConfigManager.HomeFolder == ConfigManager.DefaultDocumentsFolder)) {
//Need to copy files and display confirmation
string targetFolder = radStorageDocuments.Checked ? ConfigManager.DefaultDocumentsFolder : ConfigManager.DefaultPortableFolder;
if(MesenMsgBox.Show("CopyMesenDataPrompt", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, ConfigManager.HomeFolder, targetFolder) == DialogResult.OK) {
try {
FolderHelper.MigrateData(ConfigManager.HomeFolder, targetFolder, this);
} catch(Exception ex) {
MesenMsgBox.Show("UnexpectedError", MessageBoxButtons.OK, MessageBoxIcon.Error, ex.ToString());
e.Cancel = true;
}
} else {
e.Cancel = true;
return;
}
}
} else {
base.OnFormClosing(e);
}
}
private bool ValidateFolderSettings()
{
bool result = true;
List<string> invalidFolders = new List<string>();
try {
if(chkGameOverride.Checked && !FolderHelper.CheckFolderPermissions(psGame.Text, false)) {
invalidFolders.Add(chkGameOverride.Text.Replace(":", "").Trim());
}
if(chkAviOverride.Checked && !FolderHelper.CheckFolderPermissions(psAvi.Text)) {
invalidFolders.Add(chkAviOverride.Text.Replace(":", "").Trim());
}
if(chkMoviesOverride.Checked && !FolderHelper.CheckFolderPermissions(psMovies.Text)) {
invalidFolders.Add(chkMoviesOverride.Text.Replace(":", "").Trim());
}
if(chkSaveDataOverride.Checked && !FolderHelper.CheckFolderPermissions(psSaveData.Text)) {
invalidFolders.Add(chkSaveDataOverride.Text.Replace(":", "").Trim());
}
if(chkSaveStatesOverride.Checked && !FolderHelper.CheckFolderPermissions(psSaveStates.Text)) {
invalidFolders.Add(chkSaveStatesOverride.Text.Replace(":", "").Trim());
}
if(chkScreenshotsOverride.Checked && !FolderHelper.CheckFolderPermissions(psScreenshots.Text)) {
invalidFolders.Add(chkScreenshotsOverride.Text.Replace(":", "").Trim());
}
if(chkWaveOverride.Checked && !FolderHelper.CheckFolderPermissions(psWave.Text)) {
invalidFolders.Add(chkWaveOverride.Text.Replace(":", "").Trim());
}
result = invalidFolders.Count == 0;
} catch {
result = false;
}
if(!result) {
MesenMsgBox.Show("InvalidPaths", MessageBoxButtons.OK, MessageBoxIcon.Error, string.Join(Environment.NewLine, invalidFolders));
}
return result;
}
}
}

161
UI/Forms/frmConfigWizard.cs Normal file
View file

@ -0,0 +1,161 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Text;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Mesen.GUI.Config;
namespace Mesen.GUI.Forms
{
public partial class frmConfigWizard : Form
{
public frmConfigWizard()
{
InitializeComponent();
this.Icon = Properties.Resources.MesenIcon;
}
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
lblLocation.Text = ConfigManager.DefaultDocumentsFolder;
lblLocation.ForeColor = Color.Blue;
lblCancel.ForeColor = Color.Blue;
ResourceHelper.ApplyResources(this);
}
private void InitializeConfig()
{
ConfigManager.CreateConfig(radStoragePortable.Checked);
DefaultKeyMappingType mappingType = DefaultKeyMappingType.None;
if(chkXbox.Checked) {
mappingType |= DefaultKeyMappingType.Xbox;
}
if(chkPs4.Checked) {
mappingType |= DefaultKeyMappingType.Ps4;
}
if(chkWasd.Checked) {
mappingType |= DefaultKeyMappingType.WasdKeys;
}
if(chkArrows.Checked) {
mappingType |= DefaultKeyMappingType.ArrowKeys;
}
ConfigManager.Config.DefaultKeyMappings = mappingType;
ConfigManager.ApplyChanges();
ConfigManager.SaveConfig();
if(chkCreateShortcut.Checked) {
this.CreateShortcut();
}
}
private void CreateShortcut()
{
if(Program.IsMono) {
string shortcutFile = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "mesen-s.desktop");
FileAssociationHelper.CreateShortcutFile(shortcutFile);
Process.Start("chmod", "775 " + shortcutFile);
} else {
Type t = Type.GetTypeFromCLSID(new Guid("72C24DD5-D70A-438B-8A42-98424B88AFB8"));
dynamic shell = Activator.CreateInstance(t);
try {
string linkPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory), "Mesen-S.lnk");
var lnk = shell.CreateShortcut(linkPath);
try {
lnk.TargetPath = Assembly.GetEntryAssembly().Location;
lnk.IconLocation = Assembly.GetEntryAssembly().Location + ", 0";
lnk.Save();
} finally {
Marshal.FinalReleaseComObject(lnk);
}
} finally {
Marshal.FinalReleaseComObject(shell);
}
}
}
private void picXbox_Click(object sender, EventArgs e)
{
chkXbox.Checked = !chkXbox.Checked;
}
private void picPs4_Click(object sender, EventArgs e)
{
chkPs4.Checked = !chkPs4.Checked;
}
private void picWasd_Click(object sender, EventArgs e)
{
chkWasd.Checked = !chkWasd.Checked;
if(chkWasd.Checked) {
chkArrows.Checked = false;
}
}
private void picArrows_Click(object sender, EventArgs e)
{
chkArrows.Checked = !chkArrows.Checked;
if(chkArrows.Checked) {
chkWasd.Checked = false;
}
}
private void chkWasd_CheckedChanged(object sender, EventArgs e)
{
if(chkWasd.Checked) {
chkArrows.Checked = false;
}
}
private void chkArrows_CheckedChanged(object sender, EventArgs e)
{
if(chkArrows.Checked) {
chkWasd.Checked = false;
}
}
private void btnOk_Click(object sender, EventArgs e)
{
string targetFolder = radStoragePortable.Checked ? ConfigManager.DefaultPortableFolder : ConfigManager.DefaultDocumentsFolder;
string testFile = Path.Combine(targetFolder, "test.txt");
try {
if(!Directory.Exists(targetFolder)) {
Directory.CreateDirectory(targetFolder);
}
File.WriteAllText(testFile, "test");
File.Delete(testFile);
this.InitializeConfig();
this.Close();
} catch(Exception ex) {
MesenMsgBox.Show("CannotWriteToFolder", MessageBoxButtons.OK, MessageBoxIcon.Error, ex.ToString());
}
}
private void lblCancel_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void radStoragePortable_CheckedChanged(object sender, EventArgs e)
{
lblLocation.Text = ConfigManager.DefaultPortableFolder;
}
private void radStorageDocuments_CheckedChanged(object sender, EventArgs e)
{
lblLocation.Text = ConfigManager.DefaultDocumentsFolder;
}
}
}

573
UI/Forms/frmConfigWizard.designer.cs generated Normal file
View file

@ -0,0 +1,573 @@
namespace Mesen.GUI.Forms
{
partial class frmConfigWizard
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if(disposing && (components != null)) {
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.panel1 = new System.Windows.Forms.Panel();
this.panel2 = new System.Windows.Forms.Panel();
this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
this.lblMiscOptions = new System.Windows.Forms.Label();
this.picLogo = new System.Windows.Forms.PictureBox();
this.lblStorageLocation = new System.Windows.Forms.Label();
this.lblMesen = new System.Windows.Forms.Label();
this.lblConfigWizard = new System.Windows.Forms.Label();
this.lblInputMappings = new System.Windows.Forms.Label();
this.tableLayoutPanel3 = new System.Windows.Forms.TableLayoutPanel();
this.chkArrows = new System.Windows.Forms.CheckBox();
this.chkWasd = new System.Windows.Forms.CheckBox();
this.chkPs4 = new System.Windows.Forms.CheckBox();
this.picPs4 = new System.Windows.Forms.PictureBox();
this.picXbox = new System.Windows.Forms.PictureBox();
this.picWasd = new System.Windows.Forms.PictureBox();
this.picArrows = new System.Windows.Forms.PictureBox();
this.chkXbox = new System.Windows.Forms.CheckBox();
this.lblInputHint = new System.Windows.Forms.Label();
this.panel3 = new System.Windows.Forms.Panel();
this.tableLayoutPanel4 = new System.Windows.Forms.TableLayoutPanel();
this.radStorageDocuments = new System.Windows.Forms.RadioButton();
this.radStoragePortable = new System.Windows.Forms.RadioButton();
this.lblStorageHint = new System.Windows.Forms.Label();
this.btnOk = new System.Windows.Forms.Button();
this.lblInitialSetup = new System.Windows.Forms.Label();
this.chkCreateShortcut = new System.Windows.Forms.CheckBox();
this.lblCancel = new System.Windows.Forms.Label();
this.tableLayoutPanel2 = new System.Windows.Forms.TableLayoutPanel();
this.lblLocation = new System.Windows.Forms.Label();
this.lblDataLocation = new System.Windows.Forms.Label();
this.panel1.SuspendLayout();
this.panel2.SuspendLayout();
this.tableLayoutPanel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.picLogo)).BeginInit();
this.tableLayoutPanel3.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.picPs4)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.picXbox)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.picWasd)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.picArrows)).BeginInit();
this.panel3.SuspendLayout();
this.tableLayoutPanel4.SuspendLayout();
this.tableLayoutPanel2.SuspendLayout();
this.SuspendLayout();
//
// panel1
//
this.panel1.BackColor = System.Drawing.SystemColors.ActiveBorder;
this.panel1.Controls.Add(this.panel2);
this.panel1.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel1.Location = new System.Drawing.Point(0, 0);
this.panel1.Name = "panel1";
this.panel1.Padding = new System.Windows.Forms.Padding(3);
this.panel1.Size = new System.Drawing.Size(420, 484);
this.panel1.TabIndex = 0;
//
// panel2
//
this.panel2.BackColor = System.Drawing.SystemColors.Window;
this.panel2.Controls.Add(this.tableLayoutPanel1);
this.panel2.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel2.Location = new System.Drawing.Point(3, 3);
this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(414, 478);
this.panel2.TabIndex = 0;
//
// tableLayoutPanel1
//
this.tableLayoutPanel1.ColumnCount = 2;
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
this.tableLayoutPanel1.Controls.Add(this.lblMiscOptions, 0, 10);
this.tableLayoutPanel1.Controls.Add(this.picLogo, 1, 0);
this.tableLayoutPanel1.Controls.Add(this.lblStorageLocation, 0, 3);
this.tableLayoutPanel1.Controls.Add(this.lblMesen, 0, 0);
this.tableLayoutPanel1.Controls.Add(this.lblConfigWizard, 0, 1);
this.tableLayoutPanel1.Controls.Add(this.lblInputMappings, 0, 7);
this.tableLayoutPanel1.Controls.Add(this.tableLayoutPanel3, 0, 9);
this.tableLayoutPanel1.Controls.Add(this.lblInputHint, 0, 8);
this.tableLayoutPanel1.Controls.Add(this.panel3, 0, 5);
this.tableLayoutPanel1.Controls.Add(this.lblStorageHint, 0, 4);
this.tableLayoutPanel1.Controls.Add(this.btnOk, 1, 13);
this.tableLayoutPanel1.Controls.Add(this.lblInitialSetup, 0, 2);
this.tableLayoutPanel1.Controls.Add(this.chkCreateShortcut, 0, 11);
this.tableLayoutPanel1.Controls.Add(this.lblCancel, 0, 13);
this.tableLayoutPanel1.Controls.Add(this.tableLayoutPanel2, 0, 6);
this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0);
this.tableLayoutPanel1.Name = "tableLayoutPanel1";
this.tableLayoutPanel1.Padding = new System.Windows.Forms.Padding(10);
this.tableLayoutPanel1.RowCount = 14;
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 26F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 46F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 35F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 45F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 28F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanel1.Size = new System.Drawing.Size(414, 478);
this.tableLayoutPanel1.TabIndex = 0;
//
// lblMiscOptions
//
this.lblMiscOptions.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.lblMiscOptions.AutoSize = true;
this.tableLayoutPanel1.SetColumnSpan(this.lblMiscOptions, 2);
this.lblMiscOptions.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Underline, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lblMiscOptions.ForeColor = System.Drawing.SystemColors.WindowFrame;
this.lblMiscOptions.Location = new System.Drawing.Point(10, 396);
this.lblMiscOptions.Margin = new System.Windows.Forms.Padding(0, 0, 3, 0);
this.lblMiscOptions.Name = "lblMiscOptions";
this.lblMiscOptions.Size = new System.Drawing.Size(72, 13);
this.lblMiscOptions.TabIndex = 34;
this.lblMiscOptions.Text = "Other Options";
//
// picLogo
//
this.picLogo.Anchor = System.Windows.Forms.AnchorStyles.Right;
this.picLogo.Image = global::Mesen.GUI.Properties.Resources.MesenSIcon;
this.picLogo.Location = new System.Drawing.Point(337, 14);
this.picLogo.Name = "picLogo";
this.tableLayoutPanel1.SetRowSpan(this.picLogo, 2);
this.picLogo.Size = new System.Drawing.Size(64, 64);
this.picLogo.TabIndex = 0;
this.picLogo.TabStop = false;
//
// lblStorageLocation
//
this.lblStorageLocation.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.lblStorageLocation.AutoSize = true;
this.tableLayoutPanel1.SetColumnSpan(this.lblStorageLocation, 2);
this.lblStorageLocation.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Underline, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lblStorageLocation.ForeColor = System.Drawing.SystemColors.WindowFrame;
this.lblStorageLocation.Location = new System.Drawing.Point(10, 124);
this.lblStorageLocation.Margin = new System.Windows.Forms.Padding(0, 0, 3, 0);
this.lblStorageLocation.Name = "lblStorageLocation";
this.lblStorageLocation.Size = new System.Drawing.Size(114, 13);
this.lblStorageLocation.TabIndex = 24;
this.lblStorageLocation.Text = "Data Storage Location";
//
// lblMesen
//
this.lblMesen.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.lblMesen.AutoSize = true;
this.lblMesen.Location = new System.Drawing.Point(13, 23);
this.lblMesen.Name = "lblMesen";
this.lblMesen.Size = new System.Drawing.Size(131, 13);
this.lblMesen.TabIndex = 1;
this.lblMesen.Text = "Mesen-S - SNES Emulator";
//
// lblConfigWizard
//
this.lblConfigWizard.AutoSize = true;
this.lblConfigWizard.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lblConfigWizard.Location = new System.Drawing.Point(13, 36);
this.lblConfigWizard.Name = "lblConfigWizard";
this.lblConfigWizard.Size = new System.Drawing.Size(184, 24);
this.lblConfigWizard.TabIndex = 1;
this.lblConfigWizard.Text = "Configuration Wizard";
//
// lblInputMappings
//
this.lblInputMappings.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.lblInputMappings.AutoSize = true;
this.tableLayoutPanel1.SetColumnSpan(this.lblInputMappings, 2);
this.lblInputMappings.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Underline, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lblInputMappings.ForeColor = System.Drawing.SystemColors.WindowFrame;
this.lblInputMappings.Location = new System.Drawing.Point(10, 252);
this.lblInputMappings.Margin = new System.Windows.Forms.Padding(0, 0, 3, 0);
this.lblInputMappings.Name = "lblInputMappings";
this.lblInputMappings.Size = new System.Drawing.Size(80, 13);
this.lblInputMappings.TabIndex = 25;
this.lblInputMappings.Text = "Input Mappings";
//
// tableLayoutPanel3
//
this.tableLayoutPanel3.ColumnCount = 4;
this.tableLayoutPanel1.SetColumnSpan(this.tableLayoutPanel3, 2);
this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 25F));
this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 25F));
this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 25F));
this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 25F));
this.tableLayoutPanel3.Controls.Add(this.chkArrows, 3, 1);
this.tableLayoutPanel3.Controls.Add(this.chkWasd, 2, 1);
this.tableLayoutPanel3.Controls.Add(this.chkPs4, 1, 1);
this.tableLayoutPanel3.Controls.Add(this.picPs4, 1, 0);
this.tableLayoutPanel3.Controls.Add(this.picXbox, 0, 0);
this.tableLayoutPanel3.Controls.Add(this.picWasd, 2, 0);
this.tableLayoutPanel3.Controls.Add(this.picArrows, 3, 0);
this.tableLayoutPanel3.Controls.Add(this.chkXbox, 0, 1);
this.tableLayoutPanel3.Dock = System.Windows.Forms.DockStyle.Fill;
this.tableLayoutPanel3.Location = new System.Drawing.Point(13, 288);
this.tableLayoutPanel3.Name = "tableLayoutPanel3";
this.tableLayoutPanel3.RowCount = 2;
this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanel3.Size = new System.Drawing.Size(388, 90);
this.tableLayoutPanel3.TabIndex = 28;
//
// chkArrows
//
this.chkArrows.AutoSize = true;
this.chkArrows.CheckAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.chkArrows.Checked = true;
this.chkArrows.CheckState = System.Windows.Forms.CheckState.Checked;
this.chkArrows.Dock = System.Windows.Forms.DockStyle.Fill;
this.chkArrows.Location = new System.Drawing.Point(294, 73);
this.chkArrows.Name = "chkArrows";
this.chkArrows.Size = new System.Drawing.Size(91, 14);
this.chkArrows.TabIndex = 33;
this.chkArrows.UseVisualStyleBackColor = true;
this.chkArrows.CheckedChanged += new System.EventHandler(this.chkArrows_CheckedChanged);
//
// chkWasd
//
this.chkWasd.AutoSize = true;
this.chkWasd.CheckAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.chkWasd.Dock = System.Windows.Forms.DockStyle.Fill;
this.chkWasd.Location = new System.Drawing.Point(197, 73);
this.chkWasd.Name = "chkWasd";
this.chkWasd.Size = new System.Drawing.Size(91, 14);
this.chkWasd.TabIndex = 32;
this.chkWasd.UseVisualStyleBackColor = true;
this.chkWasd.CheckedChanged += new System.EventHandler(this.chkWasd_CheckedChanged);
//
// chkPs4
//
this.chkPs4.AutoSize = true;
this.chkPs4.CheckAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.chkPs4.Dock = System.Windows.Forms.DockStyle.Fill;
this.chkPs4.Location = new System.Drawing.Point(100, 73);
this.chkPs4.Name = "chkPs4";
this.chkPs4.Size = new System.Drawing.Size(91, 14);
this.chkPs4.TabIndex = 31;
this.chkPs4.UseVisualStyleBackColor = true;
//
// picPs4
//
this.picPs4.Cursor = System.Windows.Forms.Cursors.Hand;
this.picPs4.Dock = System.Windows.Forms.DockStyle.Fill;
this.picPs4.Image = global::Mesen.GUI.Properties.Resources.PsIcon;
this.picPs4.Location = new System.Drawing.Point(100, 3);
this.picPs4.Name = "picPs4";
this.picPs4.Size = new System.Drawing.Size(91, 64);
this.picPs4.SizeMode = System.Windows.Forms.PictureBoxSizeMode.CenterImage;
this.picPs4.TabIndex = 26;
this.picPs4.TabStop = false;
this.picPs4.Click += new System.EventHandler(this.picPs4_Click);
//
// picXbox
//
this.picXbox.Cursor = System.Windows.Forms.Cursors.Hand;
this.picXbox.Dock = System.Windows.Forms.DockStyle.Fill;
this.picXbox.Image = global::Mesen.GUI.Properties.Resources.XbIcon;
this.picXbox.Location = new System.Drawing.Point(3, 3);
this.picXbox.Name = "picXbox";
this.picXbox.Size = new System.Drawing.Size(91, 64);
this.picXbox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.CenterImage;
this.picXbox.TabIndex = 27;
this.picXbox.TabStop = false;
this.picXbox.Click += new System.EventHandler(this.picXbox_Click);
//
// picWasd
//
this.picWasd.Cursor = System.Windows.Forms.Cursors.Hand;
this.picWasd.Dock = System.Windows.Forms.DockStyle.Fill;
this.picWasd.Image = global::Mesen.GUI.Properties.Resources.WasdKeys;
this.picWasd.Location = new System.Drawing.Point(197, 3);
this.picWasd.Name = "picWasd";
this.picWasd.Size = new System.Drawing.Size(91, 64);
this.picWasd.SizeMode = System.Windows.Forms.PictureBoxSizeMode.CenterImage;
this.picWasd.TabIndex = 28;
this.picWasd.TabStop = false;
this.picWasd.Click += new System.EventHandler(this.picWasd_Click);
//
// picArrows
//
this.picArrows.Cursor = System.Windows.Forms.Cursors.Hand;
this.picArrows.Dock = System.Windows.Forms.DockStyle.Fill;
this.picArrows.Image = global::Mesen.GUI.Properties.Resources.ArrowKeys;
this.picArrows.Location = new System.Drawing.Point(294, 3);
this.picArrows.Name = "picArrows";
this.picArrows.Size = new System.Drawing.Size(91, 64);
this.picArrows.SizeMode = System.Windows.Forms.PictureBoxSizeMode.CenterImage;
this.picArrows.TabIndex = 29;
this.picArrows.TabStop = false;
this.picArrows.Click += new System.EventHandler(this.picArrows_Click);
//
// chkXbox
//
this.chkXbox.AutoSize = true;
this.chkXbox.CheckAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.chkXbox.Checked = true;
this.chkXbox.CheckState = System.Windows.Forms.CheckState.Checked;
this.chkXbox.Dock = System.Windows.Forms.DockStyle.Fill;
this.chkXbox.Location = new System.Drawing.Point(3, 73);
this.chkXbox.Name = "chkXbox";
this.chkXbox.Size = new System.Drawing.Size(91, 14);
this.chkXbox.TabIndex = 30;
this.chkXbox.UseVisualStyleBackColor = true;
//
// lblInputHint
//
this.lblInputHint.Anchor = System.Windows.Forms.AnchorStyles.Left;
this.lblInputHint.AutoSize = true;
this.tableLayoutPanel1.SetColumnSpan(this.lblInputHint, 2);
this.lblInputHint.Location = new System.Drawing.Point(13, 268);
this.lblInputHint.Name = "lblInputHint";
this.lblInputHint.Size = new System.Drawing.Size(177, 13);
this.lblInputHint.TabIndex = 29;
this.lblInputHint.Text = "Select your preferred input methods:";
//
// panel3
//
this.tableLayoutPanel1.SetColumnSpan(this.panel3, 2);
this.panel3.Controls.Add(this.tableLayoutPanel4);
this.panel3.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel3.Location = new System.Drawing.Point(10, 157);
this.panel3.Margin = new System.Windows.Forms.Padding(0);
this.panel3.Name = "panel3";
this.panel3.Padding = new System.Windows.Forms.Padding(8, 0, 0, 0);
this.panel3.Size = new System.Drawing.Size(394, 50);
this.panel3.TabIndex = 30;
//
// tableLayoutPanel4
//
this.tableLayoutPanel4.ColumnCount = 1;
this.tableLayoutPanel4.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel4.Controls.Add(this.radStorageDocuments, 0, 0);
this.tableLayoutPanel4.Controls.Add(this.radStoragePortable, 0, 1);
this.tableLayoutPanel4.Dock = System.Windows.Forms.DockStyle.Fill;
this.tableLayoutPanel4.Location = new System.Drawing.Point(8, 0);
this.tableLayoutPanel4.Name = "tableLayoutPanel4";
this.tableLayoutPanel4.RowCount = 2;
this.tableLayoutPanel4.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
this.tableLayoutPanel4.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
this.tableLayoutPanel4.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
this.tableLayoutPanel4.Size = new System.Drawing.Size(386, 50);
this.tableLayoutPanel4.TabIndex = 0;
//
// radStorageDocuments
//
this.radStorageDocuments.AutoSize = true;
this.radStorageDocuments.Checked = true;
this.radStorageDocuments.Cursor = System.Windows.Forms.Cursors.Hand;
this.radStorageDocuments.Dock = System.Windows.Forms.DockStyle.Fill;
this.radStorageDocuments.Location = new System.Drawing.Point(3, 3);
this.radStorageDocuments.Name = "radStorageDocuments";
this.radStorageDocuments.Size = new System.Drawing.Size(380, 19);
this.radStorageDocuments.TabIndex = 0;
this.radStorageDocuments.TabStop = true;
this.radStorageDocuments.Text = "Store the data in my user profile";
this.radStorageDocuments.UseVisualStyleBackColor = true;
this.radStorageDocuments.CheckedChanged += new System.EventHandler(this.radStorageDocuments_CheckedChanged);
//
// radStoragePortable
//
this.radStoragePortable.AutoSize = true;
this.radStoragePortable.Cursor = System.Windows.Forms.Cursors.Hand;
this.radStoragePortable.Dock = System.Windows.Forms.DockStyle.Fill;
this.radStoragePortable.Location = new System.Drawing.Point(3, 28);
this.radStoragePortable.Name = "radStoragePortable";
this.radStoragePortable.Size = new System.Drawing.Size(380, 19);
this.radStoragePortable.TabIndex = 1;
this.radStoragePortable.Text = "Store the data in the same folder as the application";
this.radStoragePortable.UseVisualStyleBackColor = true;
this.radStoragePortable.CheckedChanged += new System.EventHandler(this.radStoragePortable_CheckedChanged);
//
// lblStorageHint
//
this.lblStorageHint.Anchor = System.Windows.Forms.AnchorStyles.Left;
this.lblStorageHint.AutoSize = true;
this.tableLayoutPanel1.SetColumnSpan(this.lblStorageHint, 2);
this.lblStorageHint.Location = new System.Drawing.Point(13, 140);
this.lblStorageHint.Name = "lblStorageHint";
this.lblStorageHint.Size = new System.Drawing.Size(232, 13);
this.lblStorageHint.TabIndex = 31;
this.lblStorageHint.Text = "Select where you want to store Mesen-S\'s data:";
//
// btnOk
//
this.btnOk.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.btnOk.AutoSize = true;
this.btnOk.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.btnOk.BackColor = System.Drawing.SystemColors.Control;
this.btnOk.Cursor = System.Windows.Forms.Cursors.Hand;
this.btnOk.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnOk.Location = new System.Drawing.Point(333, 440);
this.btnOk.Name = "btnOk";
this.btnOk.Size = new System.Drawing.Size(68, 25);
this.btnOk.TabIndex = 32;
this.btnOk.Text = "CONFIRM";
this.btnOk.UseVisualStyleBackColor = false;
this.btnOk.Click += new System.EventHandler(this.btnOk_Click);
//
// lblInitialSetup
//
this.lblInitialSetup.Anchor = System.Windows.Forms.AnchorStyles.Left;
this.lblInitialSetup.AutoSize = true;
this.tableLayoutPanel1.SetColumnSpan(this.lblInitialSetup, 2);
this.lblInitialSetup.Location = new System.Drawing.Point(13, 93);
this.lblInitialSetup.Name = "lblInitialSetup";
this.lblInitialSetup.Size = new System.Drawing.Size(272, 13);
this.lblInitialSetup.TabIndex = 33;
this.lblInitialSetup.Text = "Please take a moment to perform Mesen-S\'s initial setup.";
//
// chkCreateShortcut
//
this.chkCreateShortcut.AutoSize = true;
this.chkCreateShortcut.Checked = true;
this.chkCreateShortcut.CheckState = System.Windows.Forms.CheckState.Checked;
this.tableLayoutPanel1.SetColumnSpan(this.chkCreateShortcut, 2);
this.chkCreateShortcut.Cursor = System.Windows.Forms.Cursors.Hand;
this.chkCreateShortcut.Location = new System.Drawing.Point(21, 415);
this.chkCreateShortcut.Margin = new System.Windows.Forms.Padding(11, 6, 3, 3);
this.chkCreateShortcut.Name = "chkCreateShortcut";
this.chkCreateShortcut.Size = new System.Drawing.Size(179, 17);
this.chkCreateShortcut.TabIndex = 35;
this.chkCreateShortcut.Text = "Create a shortcut on my desktop";
this.chkCreateShortcut.UseVisualStyleBackColor = true;
//
// lblCancel
//
this.lblCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.lblCancel.AutoSize = true;
this.lblCancel.Cursor = System.Windows.Forms.Cursors.Hand;
this.lblCancel.ForeColor = System.Drawing.Color.Blue;
this.lblCancel.Location = new System.Drawing.Point(13, 455);
this.lblCancel.Name = "lblCancel";
this.lblCancel.Size = new System.Drawing.Size(40, 13);
this.lblCancel.TabIndex = 36;
this.lblCancel.Text = "Cancel";
this.lblCancel.Click += new System.EventHandler(this.lblCancel_Click);
//
// tableLayoutPanel2
//
this.tableLayoutPanel2.ColumnCount = 2;
this.tableLayoutPanel1.SetColumnSpan(this.tableLayoutPanel2, 2);
this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel2.Controls.Add(this.lblLocation, 1, 0);
this.tableLayoutPanel2.Controls.Add(this.lblDataLocation, 0, 0);
this.tableLayoutPanel2.Dock = System.Windows.Forms.DockStyle.Fill;
this.tableLayoutPanel2.Location = new System.Drawing.Point(13, 210);
this.tableLayoutPanel2.Name = "tableLayoutPanel2";
this.tableLayoutPanel2.Padding = new System.Windows.Forms.Padding(0, 5, 0, 0);
this.tableLayoutPanel2.RowCount = 1;
this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel2.Size = new System.Drawing.Size(388, 39);
this.tableLayoutPanel2.TabIndex = 38;
//
// lblLocation
//
this.lblLocation.AutoSize = true;
this.lblLocation.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lblLocation.ForeColor = System.Drawing.SystemColors.ControlText;
this.lblLocation.Location = new System.Drawing.Point(48, 5);
this.lblLocation.Name = "lblLocation";
this.lblLocation.Size = new System.Drawing.Size(19, 13);
this.lblLocation.TabIndex = 1;
this.lblLocation.Text = "....";
//
// lblDataLocation
//
this.lblDataLocation.AutoSize = true;
this.lblDataLocation.Location = new System.Drawing.Point(3, 5);
this.lblDataLocation.Name = "lblDataLocation";
this.lblDataLocation.Size = new System.Drawing.Size(39, 13);
this.lblDataLocation.TabIndex = 0;
this.lblDataLocation.Text = "Folder:";
//
// frmConfigWizard
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.SystemColors.Window;
this.ClientSize = new System.Drawing.Size(420, 484);
this.Controls.Add(this.panel1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.Name = "frmConfigWizard";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Mesen - Configuration";
this.panel1.ResumeLayout(false);
this.panel2.ResumeLayout(false);
this.tableLayoutPanel1.ResumeLayout(false);
this.tableLayoutPanel1.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.picLogo)).EndInit();
this.tableLayoutPanel3.ResumeLayout(false);
this.tableLayoutPanel3.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.picPs4)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.picXbox)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.picWasd)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.picArrows)).EndInit();
this.panel3.ResumeLayout(false);
this.tableLayoutPanel4.ResumeLayout(false);
this.tableLayoutPanel4.PerformLayout();
this.tableLayoutPanel2.ResumeLayout(false);
this.tableLayoutPanel2.PerformLayout();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.Panel panel2;
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1;
private System.Windows.Forms.PictureBox picLogo;
private System.Windows.Forms.Label lblMesen;
private System.Windows.Forms.Label lblConfigWizard;
private System.Windows.Forms.Label lblStorageLocation;
private System.Windows.Forms.Label lblInputMappings;
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel3;
private System.Windows.Forms.PictureBox picPs4;
private System.Windows.Forms.PictureBox picXbox;
private System.Windows.Forms.PictureBox picWasd;
private System.Windows.Forms.PictureBox picArrows;
private System.Windows.Forms.Label lblInputHint;
private System.Windows.Forms.Panel panel3;
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel4;
private System.Windows.Forms.RadioButton radStorageDocuments;
private System.Windows.Forms.RadioButton radStoragePortable;
private System.Windows.Forms.Label lblStorageHint;
private System.Windows.Forms.Button btnOk;
private System.Windows.Forms.Label lblInitialSetup;
private System.Windows.Forms.Label lblMiscOptions;
private System.Windows.Forms.CheckBox chkCreateShortcut;
private System.Windows.Forms.Label lblCancel;
private System.Windows.Forms.Label lblDataLocation;
private System.Windows.Forms.Label lblLocation;
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel2;
private System.Windows.Forms.CheckBox chkArrows;
private System.Windows.Forms.CheckBox chkWasd;
private System.Windows.Forms.CheckBox chkPs4;
private System.Windows.Forms.CheckBox chkXbox;
}
}

View file

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View file

@ -62,7 +62,7 @@ namespace Mesen.GUI
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
/*if(ConfigManager.GetConfigFile() == null) {
if(ConfigManager.GetConfigFile() == null) {
//Show config wizard
ResourceHelper.LoadResources(Language.SystemDefault);
Application.Run(new frmConfigWizard());
@ -71,9 +71,7 @@ namespace Mesen.GUI
Application.Exit();
return;
}
}*/
ConfigManager.GetConfigFile();
ConfigManager.CreateConfig(false);
}
Directory.CreateDirectory(ConfigManager.HomeFolder);
Directory.SetCurrentDirectory(ConfigManager.HomeFolder);
try {
@ -91,7 +89,7 @@ namespace Mesen.GUI
case Language.Portuguese: message = "Microsoft .NET Framework 4.5 não foi encontrado. Por favor, baixe a versão mais recente de .NET Framework do site da Microsoft e tente novamente."; break;
case Language.Chinese: message = "找不到 Microsoft .NET Framework 4.5,请访问 Microsoft 官网下载安装之后再试。"; break;
}
MessageBox.Show(message + Environment.NewLine + Environment.NewLine + e.ToString(), "Mesen", MessageBoxButtons.OK, MessageBoxIcon.Error);
MessageBox.Show(message + Environment.NewLine + Environment.NewLine + e.ToString(), "Mesen-S", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
} catch(Exception e) {
string message = "An unexpected error has occurred.\n\nError details:\n{0}";
@ -104,7 +102,7 @@ namespace Mesen.GUI
case Language.Portuguese: message = "Houve um erro inesperado.&#xA;&#xA;Detalhes do erro:&#xA;{0}"; break;
case Language.Chinese: message = "发生意外错误。\n\n详情:\n{0}"; break;
}
MessageBox.Show(string.Format(message, e.ToString()), "Mesen", MessageBoxButtons.OK, MessageBoxIcon.Error);
MessageBox.Show(string.Format(message, e.ToString()), "Mesen-S", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
if(!RuntimeChecker.TestDll()) {

View file

@ -518,6 +518,12 @@
<Compile Include="Forms\Config\Controllers\frmControllerConfig.designer.cs">
<DependentUpon>frmControllerConfig.cs</DependentUpon>
</Compile>
<Compile Include="Forms\Config\frmCopyFiles.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Forms\Config\frmCopyFiles.designer.cs">
<DependentUpon>frmCopyFiles.cs</DependentUpon>
</Compile>
<Compile Include="Forms\Config\frmInputConfig.cs">
<SubType>Form</SubType>
</Compile>
@ -556,6 +562,12 @@
<Compile Include="Forms\frmAbout.designer.cs">
<DependentUpon>frmAbout.cs</DependentUpon>
</Compile>
<Compile Include="Forms\frmConfigWizard.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Forms\frmConfigWizard.designer.cs">
<DependentUpon>frmConfigWizard.cs</DependentUpon>
</Compile>
<Compile Include="Forms\frmFullscreenRenderer.cs">
<SubType>Form</SubType>
</Compile>
@ -615,6 +627,7 @@
<Compile Include="SingleInstance.cs" />
<Compile Include="Utilities\ArchiveHelper.cs" />
<Compile Include="Utilities\CommandLineHelper.cs" />
<Compile Include="Utilities\FolderHelper.cs" />
<Compile Include="Utilities\HexConverter.cs" />
<Compile Include="Utilities\Md5Helper.cs" />
<Compile Include="Updates\UpdateHelper.cs" />
@ -735,6 +748,9 @@
<EmbeddedResource Include="Forms\Config\Controllers\frmControllerConfig.resx">
<DependentUpon>frmControllerConfig.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Forms\Config\frmCopyFiles.resx">
<DependentUpon>frmCopyFiles.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Forms\Config\frmInputConfig.resx">
<DependentUpon>frmInputConfig.cs</DependentUpon>
</EmbeddedResource>
@ -753,6 +769,9 @@
<EmbeddedResource Include="Forms\frmAbout.resx">
<DependentUpon>frmAbout.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Forms\frmConfigWizard.resx">
<DependentUpon>frmConfigWizard.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Forms\Tools\frmLogWindow.resx">
<DependentUpon>frmLogWindow.cs</DependentUpon>
</EmbeddedResource>

View file

@ -0,0 +1,60 @@
using Mesen.GUI.Config;
using Mesen.GUI.Forms.Config;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Mesen.GUI.Utilities
{
public static class FolderHelper
{
public static bool CheckFolderPermissions(string folder, bool checkWritePermission = true)
{
if(!Directory.Exists(folder)) {
try {
if(string.IsNullOrWhiteSpace(folder)) {
return false;
}
Directory.CreateDirectory(folder);
} catch {
return false;
}
}
if(checkWritePermission) {
try {
File.WriteAllText(Path.Combine(folder, "test.txt"), "");
File.Delete(Path.Combine(folder, "test.txt"));
} catch {
return false;
}
}
return true;
}
public static bool MigrateData(string source, string target, Form parent)
{
using(frmCopyFiles frm = new frmCopyFiles(source, target)) {
frm.ShowDialog(parent);
if(frm.Exception != null) {
throw frm.Exception;
}
}
if(File.Exists(Path.Combine(source, "settings.backup.xml"))) {
File.Delete(Path.Combine(source, "settings.backup.xml"));
}
File.Move(Path.Combine(source, "settings.xml"), Path.Combine(source, "settings.backup.xml"));
ConfigManager.InitHomeFolder();
ConfigManager.SaveConfig();
ConfigManager.RestartMesen(true);
Application.Exit();
return true;
}
}
}