5 |
using System.Drawing; |
using System.Drawing; |
6 |
using System.IO; |
using System.IO; |
7 |
using EmuXPortal.Logging; |
using EmuXPortal.Logging; |
8 |
|
using System.Xml; |
9 |
|
|
10 |
namespace EmuXPortal.Api |
namespace EmuXPortal.Api |
11 |
{ |
{ |
36 |
if (fi.Exists) |
if (fi.Exists) |
37 |
{ |
{ |
38 |
logger.WriteLine("Found EMU Config File: {0}", config_path); |
logger.WriteLine("Found EMU Config File: {0}", config_path); |
39 |
|
logger.WriteLine("\tLoading Config: {0}", config_path); |
40 |
|
//bool loaded = false; |
41 |
|
try |
42 |
|
{ |
43 |
|
using (FileStream fs = new FileStream(config_path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) |
44 |
|
{ |
45 |
|
using (XmlReader reader = XmlReader.Create(fs)) |
46 |
|
{ |
47 |
|
reader.ReadToFollowing("PLATFORMNAMESHORT"); |
48 |
|
config.PlatformNameShort = reader.ReadElementContentAsString(); |
49 |
|
logger.WriteLine("\tPLATFORMNAMESHORT={0}", config.PlatformNameShort); |
50 |
|
|
51 |
|
reader.ReadToFollowing("PLATFORMNAMELONG"); |
52 |
|
config.PlatformNameLong = reader.ReadElementContentAsString(); |
53 |
|
logger.WriteLine("\tPLATFORMNAMELONG={0}", config.PlatformNameLong); |
54 |
|
|
55 |
|
reader.ReadToFollowing("PLATFORMIMAGE"); |
56 |
|
string platform_image = reader.ReadElementContentAsString(); |
57 |
|
|
58 |
|
config.PlatformImage = (platform_image == "") ? Properties.Resources.DefaultPlatformImage : Image.FromFile(string.Format(@"{0}\{1}",rom_path,platform_image)); |
59 |
|
string str_platform_image = (platform_image == "") ? "DefaultPlatformImage" : platform_image; |
60 |
|
logger.WriteLine("\tPLATFORMIMAGE={0}", str_platform_image); |
61 |
|
|
62 |
|
reader.ReadToFollowing("EXTENSIONS"); |
63 |
|
config.Extenstions = reader.ReadElementContentAsString(); |
64 |
|
logger.WriteLine("\tEXTENSIONS={0}", config.Extenstions); |
65 |
|
|
66 |
|
reader.ReadToFollowing("EMULATORPATH"); |
67 |
|
config.EmuPath = reader.ReadElementContentAsString(); |
68 |
|
logger.WriteLine("\tEMULATORPATH={0}", config.EmuPath); |
69 |
|
|
70 |
|
reader.ReadToFollowing("EMULATOROPTIONS"); |
71 |
|
config.EmuOptions = reader.ReadElementContentAsString(); |
72 |
|
logger.WriteLine("\tEMULATOROPTIONS={0}", config.EmuOptions); |
73 |
|
} |
74 |
|
} |
75 |
|
logger.WriteLine("\tLoaded Config: {0}", config_path); |
76 |
|
//loaded = true; |
77 |
|
} |
78 |
|
catch(Exception ex) |
79 |
|
{ |
80 |
|
logger.WriteLine("\tFailed to Load Config: {0}", config_path); |
81 |
|
Console.WriteLine(ex.ToString()); |
82 |
|
logger.WriteLine("Error: {0}", ex.ToString()); |
83 |
|
//loaded = false; |
84 |
|
} |
85 |
} |
} |
86 |
else |
else { logger.WriteLine("Could not find EMU Config File: {0}", config_path); } |
|
{ |
|
|
logger.WriteLine("Could not find EMU Config File: {0}", config_path); |
|
|
} |
|
87 |
return config; |
return config; |
88 |
} |
} |
89 |
#region private class EmuConfig : IEmuConfig |
#region private class EmuConfig : IEmuConfig |
122 |
return Unknown_Platform; |
return Unknown_Platform; |
123 |
} |
} |
124 |
} |
} |
125 |
private set { _PlatformNameShort = value; } |
set { _PlatformNameShort = value; } |
126 |
} |
} |
127 |
private string _PlatformNameLong; |
private string _PlatformNameLong; |
128 |
public string PlatformNameLong |
public string PlatformNameLong |
140 |
return Unknown_Platform; |
return Unknown_Platform; |
141 |
} |
} |
142 |
} |
} |
143 |
private set { _PlatformNameLong = value; } |
set { _PlatformNameLong = value; } |
144 |
} |
} |
145 |
public Image PlatformImage { get; private set; } |
public Image PlatformImage { get; set; } |
146 |
public string Extenstions { get; private set; } |
public string Extenstions { get; set; } |
147 |
public string EmuPath { get; private set; } |
public string EmuPath { get; set; } |
148 |
public string EmuOptions { get; private set; } |
public string EmuOptions { get; set; } |
149 |
public string EmuRomPath { get; set; } |
public string EmuRomPath { get; set; } |
150 |
#endregion |
#endregion |
151 |
} |
} |