2015-12-27 22:05:45 -05:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.Drawing.Imaging;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Windows.Forms;
|
2016-02-19 13:05:04 -05:00
|
|
|
|
using Mesen.GUI.Forms;
|
2015-12-27 22:05:45 -05:00
|
|
|
|
using Microsoft.Win32;
|
|
|
|
|
|
|
|
|
|
namespace Mesen.GUI.Config
|
|
|
|
|
{
|
|
|
|
|
public class PreferenceInfo
|
|
|
|
|
{
|
2016-02-19 13:05:04 -05:00
|
|
|
|
public Language DisplayLanguage = Language.SystemDefault;
|
|
|
|
|
|
2015-12-27 22:05:45 -05:00
|
|
|
|
public bool SingleInstance = true;
|
2016-01-31 13:53:17 -05:00
|
|
|
|
public bool PauseWhenInBackground = false;
|
|
|
|
|
public bool AllowBackgroundInput = false;
|
2015-12-27 22:05:45 -05:00
|
|
|
|
public bool AutoLoadIpsPatches = true;
|
2016-01-14 19:52:28 -05:00
|
|
|
|
public bool AllowInvalidInput = false;
|
2016-01-14 22:20:50 -05:00
|
|
|
|
public bool RemoveSpriteLimit = false;
|
2016-01-31 14:03:12 -05:00
|
|
|
|
|
2016-01-28 20:47:16 -05:00
|
|
|
|
public bool FdsAutoLoadDisk = true;
|
|
|
|
|
public bool FdsFastForwardOnLoad = false;
|
2015-12-27 22:05:45 -05:00
|
|
|
|
|
2016-01-31 14:03:12 -05:00
|
|
|
|
public bool AssociateNesFiles = false;
|
|
|
|
|
public bool AssociateFdsFiles = false;
|
|
|
|
|
public bool AssociateMmoFiles = false;
|
|
|
|
|
public bool AssociateMstFiles = false;
|
2016-06-25 20:46:54 -04:00
|
|
|
|
public bool AssociateNsfFiles = false;
|
|
|
|
|
public bool AssociateNsfeFiles = false;
|
2016-08-14 20:12:50 -04:00
|
|
|
|
public bool AssociateUnfFiles = false;
|
2016-06-25 20:46:54 -04:00
|
|
|
|
|
|
|
|
|
public bool NsfDisableApuIrqs = true;
|
|
|
|
|
public bool NsfMoveToNextTrackAfterTime = true;
|
|
|
|
|
public Int32 NsfMoveToNextTrackTime = 120;
|
|
|
|
|
public bool NsfAutoDetectSilence = true;
|
|
|
|
|
public Int32 NsfAutoDetectSilenceDelay = 3000;
|
2016-01-31 14:03:12 -05:00
|
|
|
|
|
2016-01-31 14:28:31 -05:00
|
|
|
|
public bool PauseOnMovieEnd = true;
|
2016-02-08 23:23:31 -05:00
|
|
|
|
public bool AutomaticallyCheckForUpdates = true;
|
2016-01-31 14:28:31 -05:00
|
|
|
|
|
2016-01-06 23:10:29 -05:00
|
|
|
|
public bool UseAlternativeMmc3Irq = false;
|
|
|
|
|
|
2016-05-22 14:43:07 -04:00
|
|
|
|
public bool CloudSaveIntegration = false;
|
|
|
|
|
public DateTime CloudLastSync = DateTime.MinValue;
|
|
|
|
|
|
2016-06-15 21:59:34 -04:00
|
|
|
|
public bool DisableGameDatabase = false;
|
|
|
|
|
|
2015-12-27 22:05:45 -05:00
|
|
|
|
public PreferenceInfo()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2016-01-31 14:03:12 -05:00
|
|
|
|
static private void UpdateFileAssociation(string extension, bool associate)
|
2015-12-27 22:05:45 -05:00
|
|
|
|
{
|
2016-01-31 14:03:12 -05:00
|
|
|
|
string key = @"HKEY_CURRENT_USER\Software\Classes\." + extension;
|
|
|
|
|
if(associate) {
|
2015-12-27 22:05:45 -05:00
|
|
|
|
Registry.SetValue(@"HKEY_CURRENT_USER\Software\Classes\Mesen\shell\open\command", null, Application.ExecutablePath + " \"%1\"");
|
2016-01-31 14:03:12 -05:00
|
|
|
|
Registry.SetValue(key, null, "Mesen");
|
2015-12-27 22:05:45 -05:00
|
|
|
|
} else {
|
|
|
|
|
//Unregister Mesen if Mesen was registered for .nes files
|
2016-01-31 14:03:12 -05:00
|
|
|
|
object regKey = Registry.GetValue(key, null, "");
|
2016-01-16 12:29:17 -05:00
|
|
|
|
if(regKey != null && regKey.Equals("Mesen")) {
|
2016-01-31 14:03:12 -05:00
|
|
|
|
Registry.SetValue(key, null, "");
|
2015-12-27 22:05:45 -05:00
|
|
|
|
}
|
|
|
|
|
}
|
2016-01-31 14:03:12 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static public void ApplyConfig()
|
|
|
|
|
{
|
|
|
|
|
PreferenceInfo preferenceInfo = ConfigManager.Config.PreferenceInfo;
|
|
|
|
|
|
|
|
|
|
UpdateFileAssociation("nes", preferenceInfo.AssociateNesFiles);
|
|
|
|
|
UpdateFileAssociation("fds", preferenceInfo.AssociateFdsFiles);
|
|
|
|
|
UpdateFileAssociation("mmo", preferenceInfo.AssociateMmoFiles);
|
|
|
|
|
UpdateFileAssociation("mst", preferenceInfo.AssociateMstFiles);
|
2016-06-25 20:46:54 -04:00
|
|
|
|
UpdateFileAssociation("nsf", preferenceInfo.AssociateNsfFiles);
|
|
|
|
|
UpdateFileAssociation("nsfe", preferenceInfo.AssociateNsfeFiles);
|
2016-08-14 20:12:50 -04:00
|
|
|
|
UpdateFileAssociation("unf", preferenceInfo.AssociateUnfFiles);
|
2016-01-06 23:10:29 -05:00
|
|
|
|
|
|
|
|
|
InteropEmu.SetFlag(EmulationFlags.Mmc3IrqAltBehavior, preferenceInfo.UseAlternativeMmc3Irq);
|
2016-01-14 19:52:28 -05:00
|
|
|
|
InteropEmu.SetFlag(EmulationFlags.AllowInvalidInput, preferenceInfo.AllowInvalidInput);
|
2016-01-14 22:20:50 -05:00
|
|
|
|
InteropEmu.SetFlag(EmulationFlags.RemoveSpriteLimit, preferenceInfo.RemoveSpriteLimit);
|
2016-01-28 20:47:16 -05:00
|
|
|
|
InteropEmu.SetFlag(EmulationFlags.FdsAutoLoadDisk, preferenceInfo.FdsAutoLoadDisk);
|
|
|
|
|
InteropEmu.SetFlag(EmulationFlags.FdsFastForwardOnLoad, preferenceInfo.FdsFastForwardOnLoad);
|
2016-01-31 14:28:31 -05:00
|
|
|
|
InteropEmu.SetFlag(EmulationFlags.PauseOnMovieEnd, preferenceInfo.PauseOnMovieEnd);
|
2016-01-31 13:53:17 -05:00
|
|
|
|
InteropEmu.SetFlag(EmulationFlags.AllowBackgroundInput, preferenceInfo.AllowBackgroundInput);
|
|
|
|
|
InteropEmu.SetFlag(EmulationFlags.PauseWhenInBackground, preferenceInfo.PauseWhenInBackground);
|
2016-06-15 21:59:34 -04:00
|
|
|
|
InteropEmu.SetFlag(EmulationFlags.DisableGameDatabase, preferenceInfo.DisableGameDatabase);
|
2016-06-25 20:46:54 -04:00
|
|
|
|
|
|
|
|
|
InteropEmu.NsfSetNsfConfig(preferenceInfo.NsfAutoDetectSilence ? preferenceInfo.NsfAutoDetectSilenceDelay : 0, preferenceInfo.NsfMoveToNextTrackAfterTime ? preferenceInfo.NsfMoveToNextTrackTime : -1, preferenceInfo.NsfDisableApuIrqs);
|
2015-12-27 22:05:45 -05:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|