/[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/08/23 04:47:35	126
+++ trunk/EmuXPortal/Api/EmuConfig.cs	2014/08/04 05:01:23	170
@@ -84,9 +84,23 @@
             public IEmuConfig Create(logger log, string rom_path) { return this.Create(log, string.Empty, rom_path); }
             public IEmuConfig Create(logger log, string config_path, string rom_path)
             {
-                EmuRomPath = rom_path;
-                if (config_path == "") { config_path = string.Format(@"{0}\{1}", rom_path, EMU_CONFIG); }
-
+                if (rom_path == "")
+                {
+                    if (config_path != "")
+                    {
+                        EmuRomPath = config_path.Replace(EMU_CONFIG, "").TrimEnd(new char[] { '\\' });
+                    }
+                    else
+                    {
+                        EmuRomPath = Config.RomPath;
+                    }
+                }
+                else { EmuRomPath = rom_path; }
+                if (config_path == "")
+                {
+                    config_path = string.Format(@"{0}\{1}", EmuRomPath, EMU_CONFIG);
+                }
+             
                 // read the actual config emu.config
                 FileInfo fi = new FileInfo(config_path);
                 if (fi.Exists)
@@ -129,7 +143,7 @@
                                             if (reader.IsStartElement())
                                             {
                                                 string platform_image = reader.ReadElementContentAsString();
-                                                PlatformImage = (platform_image == "") ? null : Image.FromFile(string.Format(@"{0}\{1}", rom_path, platform_image));
+                                                PlatformImage = (platform_image == "") ? null : Image.FromFile(string.Format(@"{0}\{1}", EmuRomPath, platform_image));
                                                 string str_platform_image = (platform_image == "") ? "DefaultPlatformImage" : platform_image;
                                                 log.WriteLine("\t\tPLATFORMIMAGE={0}", str_platform_image);
                                             }
@@ -203,7 +217,7 @@
                                                 //EmuOptions = (external_configs_path == "") ? EmuOptions : value;
                                                 log.WriteLine("\tEXTERNALCONFIGSPATH={0}", external_configs_path);
                                                 DirectoryInfo ext_path = new DirectoryInfo(external_configs_path);
-                                                string ext_rom_path = string.Format(@"{0}\{1}", rom_path, external_configs_path);
+                                                string ext_rom_path = string.Format(@"{0}\{1}", EmuRomPath, external_configs_path);
                                                 // try the path in romroot
                                                 if (!ext_path.Exists) { ext_path = new DirectoryInfo(ext_rom_path); }
                                                 if (ext_path.Exists)
@@ -216,7 +230,7 @@
                                                         external_config_files.Sort(); // sort the files (they should already be sorted alphabetically by GetFiles())
                                                     foreach (string file in external_config_files)
                                                     {
-                                                        IEmuConfig config = EmuConfigLoader.Load(log, file, rom_path);
+                                                        IEmuConfig config = EmuConfigLoader.Load(log, file, EmuRomPath);
                                                         if (config != null)
                                                             externalconfigs.Add(config);
                                                     }

 

  ViewVC Help
Powered by ViewVC 1.1.22