Added FDS/MMO file association support

This commit is contained in:
Souryo 2016-01-31 14:03:12 -05:00
parent 28a29b536f
commit 70e9e7650d
4 changed files with 38 additions and 19 deletions

View file

@ -17,32 +17,46 @@ namespace Mesen.GUI.Config
public bool PauseWhenInBackground = false;
public bool AllowBackgroundInput = false;
public bool AutoLoadIpsPatches = true;
public bool AssociateNesFiles = false;
public bool AllowInvalidInput = false;
public bool RemoveSpriteLimit = false;
public bool FdsAutoLoadDisk = true;
public bool FdsFastForwardOnLoad = false;
public bool AssociateNesFiles = false;
public bool AssociateFdsFiles = false;
public bool AssociateMmoFiles = false;
public bool AssociateMstFiles = false;
public bool UseAlternativeMmc3Irq = false;
public PreferenceInfo()
{
}
static private void UpdateFileAssociation(string extension, bool associate)
{
string key = @"HKEY_CURRENT_USER\Software\Classes\." + extension;
if(associate) {
Registry.SetValue(@"HKEY_CURRENT_USER\Software\Classes\Mesen\shell\open\command", null, Application.ExecutablePath + " \"%1\"");
Registry.SetValue(key, null, "Mesen");
} else {
//Unregister Mesen if Mesen was registered for .nes files
object regKey = Registry.GetValue(key, null, "");
if(regKey != null && regKey.Equals("Mesen")) {
Registry.SetValue(key, null, "");
}
}
}
static public void ApplyConfig()
{
PreferenceInfo preferenceInfo = ConfigManager.Config.PreferenceInfo;
if(preferenceInfo.AssociateNesFiles) {
Registry.SetValue(@"HKEY_CURRENT_USER\Software\Classes\Mesen\shell\open\command", null, Application.ExecutablePath + " \"%1\"");
Registry.SetValue(@"HKEY_CURRENT_USER\Software\Classes\.nes", null, "Mesen");
} else {
//Unregister Mesen if Mesen was registered for .nes files
object regKey = Registry.GetValue(@"HKEY_CURRENT_USER\Software\Classes\.nes", null, "");
if(regKey != null && regKey.Equals("Mesen")) {
Registry.SetValue(@"HKEY_CURRENT_USER\Software\Classes\.nes", null, "");
}
}
UpdateFileAssociation("nes", preferenceInfo.AssociateNesFiles);
UpdateFileAssociation("fds", preferenceInfo.AssociateFdsFiles);
UpdateFileAssociation("mmo", preferenceInfo.AssociateMmoFiles);
UpdateFileAssociation("mst", preferenceInfo.AssociateMstFiles);
InteropEmu.SetFlag(EmulationFlags.Mmc3IrqAltBehavior, preferenceInfo.UseAlternativeMmc3Irq);
InteropEmu.SetFlag(EmulationFlags.AllowInvalidInput, preferenceInfo.AllowInvalidInput);

View file

@ -228,7 +228,6 @@
// chkFdsFormat
//
this.chkFdsFormat.AutoSize = true;
this.chkFdsFormat.Enabled = false;
this.chkFdsFormat.Location = new System.Drawing.Point(3, 26);
this.chkFdsFormat.Name = "chkFdsFormat";
this.chkFdsFormat.Size = new System.Drawing.Size(162, 17);
@ -239,7 +238,6 @@
// chkMmoFormat
//
this.chkMmoFormat.AutoSize = true;
this.chkMmoFormat.Enabled = false;
this.chkMmoFormat.Location = new System.Drawing.Point(190, 3);
this.chkMmoFormat.Name = "chkMmoFormat";
this.chkMmoFormat.Size = new System.Drawing.Size(133, 17);

View file

@ -22,6 +22,9 @@ namespace Mesen.GUI.Forms.Config
AddBinding("SingleInstance", chkSingleInstance);
AddBinding("AutoLoadIpsPatches", chkAutoLoadIps);
AddBinding("AssociateNesFiles", chkNesFormat);
AddBinding("AssociateFdsFiles", chkFdsFormat);
AddBinding("AssociateMmoFiles", chkMmoFormat);
AddBinding("AssociateMstFiles", chkMstFormat);
AddBinding("UseAlternativeMmc3Irq", chkUseAlternativeMmc3Irq);
AddBinding("AllowInvalidInput", chkAllowInvalidInput);

View file

@ -39,7 +39,7 @@ namespace Mesen.GUI.Forms
public void ProcessCommandLineArguments(string[] args)
{
if(args.Length > 0 && File.Exists(args[0])) {
this.LoadROM(args[0]);
this.LoadFile(args[0]);
}
}
@ -231,10 +231,14 @@ namespace Mesen.GUI.Forms
private void LoadFile(string filename)
{
if(Path.GetExtension(filename).ToLowerInvariant() == ".ips") {
LoadIpsFile(filename);
} else {
LoadROM(filename, ConfigManager.Config.PreferenceInfo.AutoLoadIpsPatches);
if(File.Exists(filename)) {
if(Path.GetExtension(filename).ToLowerInvariant() == ".ips") {
LoadIpsFile(filename);
} else if(Path.GetExtension(filename).ToLowerInvariant() == ".mmo") {
InteropEmu.MoviePlay(filename);
} else {
LoadROM(filename, ConfigManager.Config.PreferenceInfo.AutoLoadIpsPatches);
}
}
}