/[EmuXPortal]/trunk/EmuXPortal/Api/EmuConfig.cs
ViewVC logotype

Diff of /trunk/EmuXPortal/Api/EmuConfig.cs

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

--- trunk/EmuXPortal/Api/EmuConfig.cs	2012/04/04 02:39:20	22
+++ trunk/EmuXPortal/Api/EmuConfig.cs	2012/04/04 03:09:19	23
@@ -20,10 +20,12 @@
         string EmuRomPath { get; set; }
     }
 
+   
 
     public static class EmuConfigLoader
     {
         private const string EMU_CONFIG = "emu.config"; // if this file signifies the emulator configuration
+        #region load
         public static IEmuConfig Load(string rom_path) { return Load(string.Empty, rom_path); }
         public static IEmuConfig Load(string config_path, string rom_path)
         {
@@ -91,6 +93,36 @@
             else { logger.WriteLine("Could not find EMU Config File: {0}", config_path); }
             return config;
         }
+        #endregion
+        #region parse emu options
+        public static string GetEMUOptions(IRomConfig config)
+        {
+            EMUOptions EMUOptions = new EMUOptions(config);
+            return EMUOptions.Options;
+        }
+        #endregion
+        #region private class EMUOptions
+        private class EMUOptions
+        {
+            private Dictionary<string, string> options_dict = new Dictionary<string, string>();
+            public EMUOptions(IRomConfig config)
+            {
+                init_dict(config);
+                string options = config.Config.EmuOptions;
+                string real_options = options;
+                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); } }
+                Options = real_options;
+            }
+            private void init_dict(IRomConfig config)
+            {
+                options_dict.Add("%ROM_FILE%", config.RomFile);
+                options_dict.Add("%ROM_PATH%", config.Config.EmuRomPath);
+            }
+            public const string ROM_FILE = "%ROM_FILE%";
+            public string Options { get; set; }
+        }
+        #endregion
+
         #region private class EmuConfig : IEmuConfig
         private class EmuConfig : IEmuConfig
         {

 

  ViewVC Help
Powered by ViewVC 1.1.22