Mesen-X/GUI.NET/Config/PreferenceInfo.cs

74 lines
2.6 KiB
C#
Raw Normal View History

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;
using Microsoft.Win32;
namespace Mesen.GUI.Config
{
public class PreferenceInfo
{
public bool SingleInstance = true;
public bool PauseWhenInBackground = false;
public bool AllowBackgroundInput = false;
public bool AutoLoadIpsPatches = true;
public bool AllowInvalidInput = false;
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;
2016-01-31 14:03:12 -05:00
public bool AssociateNesFiles = false;
public bool AssociateFdsFiles = false;
public bool AssociateMmoFiles = false;
public bool AssociateMstFiles = false;
public bool PauseOnMovieEnd = true;
public bool UseAlternativeMmc3Irq = false;
public PreferenceInfo()
{
}
2016-01-31 14:03:12 -05:00
static private void UpdateFileAssociation(string extension, bool associate)
{
2016-01-31 14:03:12 -05:00
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\"");
2016-01-31 14:03:12 -05:00
Registry.SetValue(key, null, "Mesen");
} else {
//Unregister Mesen if Mesen was registered for .nes files
2016-01-31 14:03:12 -05:00
object regKey = Registry.GetValue(key, null, "");
if(regKey != null && regKey.Equals("Mesen")) {
2016-01-31 14:03:12 -05:00
Registry.SetValue(key, null, "");
}
}
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);
InteropEmu.SetFlag(EmulationFlags.Mmc3IrqAltBehavior, preferenceInfo.UseAlternativeMmc3Irq);
InteropEmu.SetFlag(EmulationFlags.AllowInvalidInput, preferenceInfo.AllowInvalidInput);
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);
InteropEmu.SetFlag(EmulationFlags.PauseOnMovieEnd, preferenceInfo.PauseOnMovieEnd);
InteropEmu.SetFlag(EmulationFlags.AllowBackgroundInput, preferenceInfo.AllowBackgroundInput);
InteropEmu.SetFlag(EmulationFlags.PauseWhenInBackground, preferenceInfo.PauseWhenInBackground);
}
}
}