mirror of
https://github.com/SourMesen/Mesen.git
synced 2025-04-02 10:52:48 -04:00
Config: Added version, removed unused flag, fixed crash when xml file is invalid at startup
This commit is contained in:
parent
63d2c2f9d3
commit
cbe8db4524
1 changed files with 10 additions and 4 deletions
|
@ -12,6 +12,7 @@ namespace Mesen.GUI.Config
|
||||||
{
|
{
|
||||||
private const int MaxRecentFiles = 10;
|
private const int MaxRecentFiles = 10;
|
||||||
|
|
||||||
|
public string MesenVersion;
|
||||||
public PreferenceInfo PreferenceInfo;
|
public PreferenceInfo PreferenceInfo;
|
||||||
public AudioInfo AudioInfo;
|
public AudioInfo AudioInfo;
|
||||||
public VideoInfo VideoInfo;
|
public VideoInfo VideoInfo;
|
||||||
|
@ -19,7 +20,6 @@ namespace Mesen.GUI.Config
|
||||||
public List<string> RecentFiles;
|
public List<string> RecentFiles;
|
||||||
public List<CheatInfo> Cheats;
|
public List<CheatInfo> Cheats;
|
||||||
public bool ShowOnlyCheatsForCurrentGame;
|
public bool ShowOnlyCheatsForCurrentGame;
|
||||||
public bool AutoLoadIpsPatches;
|
|
||||||
public NesModel Region;
|
public NesModel Region;
|
||||||
public ClientConnectionInfo ClientConnectionInfo;
|
public ClientConnectionInfo ClientConnectionInfo;
|
||||||
public ServerInfo ServerInfo;
|
public ServerInfo ServerInfo;
|
||||||
|
@ -27,6 +27,7 @@ namespace Mesen.GUI.Config
|
||||||
|
|
||||||
public Configuration()
|
public Configuration()
|
||||||
{
|
{
|
||||||
|
MesenVersion = InteropEmu.GetMesenVersion();
|
||||||
Profile = new PlayerProfile();
|
Profile = new PlayerProfile();
|
||||||
ClientConnectionInfo = new ClientConnectionInfo();
|
ClientConnectionInfo = new ClientConnectionInfo();
|
||||||
ServerInfo = new ServerInfo();
|
ServerInfo = new ServerInfo();
|
||||||
|
@ -68,9 +69,14 @@ namespace Mesen.GUI.Config
|
||||||
public static Configuration Deserialize(string configFile)
|
public static Configuration Deserialize(string configFile)
|
||||||
{
|
{
|
||||||
Configuration config;
|
Configuration config;
|
||||||
XmlSerializer xmlSerializer = new XmlSerializer(typeof(Configuration));
|
|
||||||
using(TextReader textReader = new StreamReader(configFile)) {
|
try {
|
||||||
config = (Configuration)xmlSerializer.Deserialize(textReader);
|
XmlSerializer xmlSerializer = new XmlSerializer(typeof(Configuration));
|
||||||
|
using(TextReader textReader = new StreamReader(configFile)) {
|
||||||
|
config = (Configuration)xmlSerializer.Deserialize(textReader);
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
config = new Configuration();
|
||||||
}
|
}
|
||||||
|
|
||||||
config.InitializeDefaults();
|
config.InitializeDefaults();
|
||||||
|
|
Loading…
Add table
Reference in a new issue