/[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	2014/08/04 11:35:06	199
+++ trunk/EmuXPortal/Api/EmuConfig.cs	2014/08/04 12:39:13	200
@@ -84,6 +84,7 @@
             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)
             {
+                IEmuConfig parent_rom = null;
                 if (rom_path == "")
                 {
                     if (config_path != "")
@@ -100,7 +101,36 @@
                 {
                     config_path = string.Format(@"{0}\{1}", EmuRomPath, EMU_CONFIG);
                 }
-             
+
+
+                if (rom_path == "")
+                {
+                    FileInfo emu_config = new FileInfo(string.Format(@"{0}\{1}", new FileInfo(config_path).Directory, EMU_CONFIG));
+                    //if (emu_config.Exists)
+                    //{
+                    //    EmuRomPath = emu_config.Directory.FullName;
+                    //}
+                    while (!emu_config.Exists)
+                    {
+                        try
+                        {
+                            emu_config = new FileInfo(string.Format(@"{0}\{1}", emu_config.Directory.Parent.FullName, EMU_CONFIG));                           
+                        }
+                        catch (Exception)
+                        {
+                            break;
+                        }
+                    }
+                    if (emu_config.Exists)
+                    {
+                        EmuRomPath = emu_config.Directory.FullName;
+                        // load the rom config
+                        parent_rom = EmuConfigLoader.Load(log, emu_config.FullName, EmuRomPath);
+                    }
+
+                    
+                }
+
                 // read the actual config emu.config
                 FileInfo fi = new FileInfo(config_path);
                 if (fi.Exists)
@@ -262,6 +292,23 @@
                 }
                 else { log.WriteLine("Could not find EMU Config File: {0}", config_path); }
 
+                if (parent_rom != null)
+                {
+                    if (parent_rom.HasExternalConfigs)
+                    {
+                        foreach (var rom in parent_rom.ExternalConfigs)
+                        {
+                            if (rom.ConfigPath == config_path)
+                            {
+                                this.PlatformNameShort = parent_rom.PlatformNameShort;
+                                this.PlatformNameLong = parent_rom.PlatformNameLong;
+                                break;
+                            }
+                        }
+                        
+                    }
+                }
+
                 return this;
             }
 
@@ -276,11 +323,9 @@
             public EmuConfig(logger log, string PlatformNameShort, string PlatformNameLong, string PlatformImage, string Extenstions, string EmuPath) : this(log, PlatformNameShort, PlatformNameLong, PlatformImage, Extenstions, EmuPath, "") { }
             public EmuConfig(logger log, string PlatformNameShort, string PlatformNameLong, string PlatformImage, string Extenstions, string EmuPath, string EmuOptions)
             {
-                //if (string.IsNullOrEmpty(EmuRomPath))
-                //{
-                //    if (Debugger.IsAttached)
-                //        Debugger.Break();
-                //}
+                
+                
+
                 this.PlatformNameShort = PlatformNameShort;
                 this.PlatformNameLong = PlatformNameLong;
                 this.PlatformImage = (PlatformImage == "") ? Properties.Resources.DefaultPlatformImage : Image.FromFile(PlatformImage);

 

  ViewVC Help
Powered by ViewVC 1.1.22