1 |
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 |
public static IRomConfig Load(string rom_file) |
22 |
{ |
23 |
IRomConfig config = null; |
24 |
config = new RomConfig(rom_file); |
25 |
return config; |
26 |
} |
27 |
#region private class RomConfig : IRomConfig |
28 |
private class RomConfig : IRomConfig |
29 |
{ |
30 |
public RomConfig(string rom_file) |
31 |
{ |
32 |
FileInfo fi = new FileInfo(rom_file); |
33 |
this.RomFile =fi.FullName; |
34 |
this.RomTitle = fi.Name.Replace(fi.Extension,""); |
35 |
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 |
string config_dir = fi.Directory.Parent.FullName; |
40 |
Config = EmuConfigLoader.Load(config_dir); |
41 |
} |
42 |
#region IRomConfig Members |
43 |
public string RomFile { get; private set; } |
44 |
public string RomTitle { get; private set; } |
45 |
public Image RomImage { get; private set; } |
46 |
public IEmuConfig Config { get; private set; } |
47 |
#endregion |
48 |
} |
49 |
#endregion |
50 |
} |
51 |
|
52 |
|
53 |
} |