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

Annotation of /trunk/EmuXPortal/Api/RomConfig.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 29 - (hide annotations) (download)
Wed Apr 4 04:13:17 2012 UTC (8 years, 6 months ago) by william
File size: 1964 byte(s)
+ speed up rom parsing by passing in the EMUConfig (rather than re-generating it each time)

1 william 17 using System;
2     using System.Collections.Generic;
3     using System.Linq;
4     using System.Text;
5     using System.Drawing;
6     using System.IO;
7    
8     namespace EmuXPortal.Api
9     {
10     public interface IRomConfig
11     {
12     string RomFile { get; }
13     string RomTitle { get; }
14     Image RomImage { get; }
15     IEmuConfig Config { get; }
16     }
17    
18     public static class RomLoader
19     {
20     private const string EMU_CONFIG = "emu.config"; // if this file signifies the emulator configuration
21 william 29 public static IRomConfig Load(string rom_file, IEmuConfig EMUConfig)
22 william 17 {
23     IRomConfig config = null;
24 william 29 config = new RomConfig(rom_file, EMUConfig);
25 william 17 return config;
26     }
27     #region private class RomConfig : IRomConfig
28     private class RomConfig : IRomConfig
29     {
30 william 29 public RomConfig(string rom_file, IEmuConfig EMUConfig)
31 william 17 {
32     FileInfo fi = new FileInfo(rom_file);
33     this.RomFile =fi.FullName;
34 william 27 this.RomTitle = fi.Name;
35 william 17 string rom_img = "";
36     // load image
37     if (File.Exists(string.Format("{0}.jpg", fi.FullName.Replace(fi.Extension, "")))) { rom_img = string.Format("{0}.jpg", fi.FullName.Replace(fi.Extension, "")); }
38     this.RomImage = (rom_img == "") ? Properties.Resources.DefaultGameImage : Image.FromFile(rom_img);
39 william 29 //string config_dir = fi.Directory.Parent.FullName;
40     //Config = EmuConfigLoader.Load(config_dir);
41     Config = EMUConfig;
42 william 17 }
43     #region IRomConfig Members
44     public string RomFile { get; private set; }
45     public string RomTitle { get; private set; }
46     public Image RomImage { get; private set; }
47     public IEmuConfig Config { get; private set; }
48     #endregion
49     }
50     #endregion
51     }
52    
53    
54     }

  ViewVC Help
Powered by ViewVC 1.1.22