20 |
string EmuRomPath { get; set; } |
string EmuRomPath { get; set; } |
21 |
} |
} |
22 |
|
|
23 |
|
|
24 |
|
|
25 |
public static class EmuConfigLoader |
public static class EmuConfigLoader |
26 |
{ |
{ |
27 |
private const string EMU_CONFIG = "emu.config"; // if this file signifies the emulator configuration |
private const string EMU_CONFIG = "emu.config"; // if this file signifies the emulator configuration |
28 |
|
#region load |
29 |
public static IEmuConfig Load(string rom_path) { return Load(string.Empty, rom_path); } |
public static IEmuConfig Load(string rom_path) { return Load(string.Empty, rom_path); } |
30 |
public static IEmuConfig Load(string config_path, string rom_path) |
public static IEmuConfig Load(string config_path, string rom_path) |
31 |
{ |
{ |
93 |
else { logger.WriteLine("Could not find EMU Config File: {0}", config_path); } |
else { logger.WriteLine("Could not find EMU Config File: {0}", config_path); } |
94 |
return config; |
return config; |
95 |
} |
} |
96 |
|
#endregion |
97 |
|
#region parse emu options |
98 |
|
public static string GetEMUOptions(IRomConfig config) |
99 |
|
{ |
100 |
|
EMUOptions EMUOptions = new EMUOptions(config); |
101 |
|
return EMUOptions.Options; |
102 |
|
} |
103 |
|
#endregion |
104 |
|
#region private class EMUOptions |
105 |
|
private class EMUOptions |
106 |
|
{ |
107 |
|
private Dictionary<string, string> options_dict = new Dictionary<string, string>(); |
108 |
|
public EMUOptions(IRomConfig config) |
109 |
|
{ |
110 |
|
init_dict(config); |
111 |
|
string options = config.Config.EmuOptions; |
112 |
|
string real_options = options; |
113 |
|
foreach (KeyValuePair<string, string> pair in options_dict) { if (options.ToLower().Contains(pair.Key.ToLower())) { real_options = real_options.ToLower().Replace(pair.Key.ToLower(), pair.Value); } } |
114 |
|
Options = real_options; |
115 |
|
} |
116 |
|
private void init_dict(IRomConfig config) |
117 |
|
{ |
118 |
|
options_dict.Add("%ROM_FILE%", config.RomFile); |
119 |
|
options_dict.Add("%ROM_PATH%", config.Config.EmuRomPath); |
120 |
|
} |
121 |
|
public const string ROM_FILE = "%ROM_FILE%"; |
122 |
|
public string Options { get; set; } |
123 |
|
} |
124 |
|
#endregion |
125 |
|
|
126 |
#region private class EmuConfig : IEmuConfig |
#region private class EmuConfig : IEmuConfig |
127 |
private class EmuConfig : IEmuConfig |
private class EmuConfig : IEmuConfig |
128 |
{ |
{ |