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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 85 - (show annotations) (download)
Tue Jun 19 03:38:40 2012 UTC (8 years, 4 months ago) by william
File size: 3485 byte(s)
reintegrate pctitlelaunching branch:
+ add support for launching standalone games categorized under a specific platform (ie. PC) that does not need to have an emulator launched
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, IEmuConfig EMUConfig)
22 {
23 IRomConfig config = null;
24 config = new RomConfig(rom_file, EMUConfig);
25 return config;
26 }
27 #region private class RomConfig : IRomConfig
28 private class RomConfig : IRomConfig
29 {
30 public RomConfig(string rom_file, IEmuConfig EMUConfig)
31 {
32 FileInfo fi = new FileInfo(rom_file);
33 this.RomFile =fi.FullName;
34 this.RomTitle = EMUConfig.GameTitle == "" ? fi.Name : EMUConfig.GameTitle;
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
40
41 if (EMUConfig.GameImage != string.Empty)
42 {
43 FileInfo fi_gameimage = new FileInfo(EMUConfig.GameImage);
44 if (fi_gameimage.Exists) { this.RomImage = Image.FromFile(fi_gameimage.FullName); }
45 else
46 {
47 FileInfo t = new FileInfo(EMUConfig.ConfigPath);
48 string path = t.FullName.Replace(t.Name, "").Replace(t.Extension, "");
49 string image_path = string.Format(@"{0}{1}", path, fi_gameimage.Name);
50 FileInfo x = new FileInfo(image_path);
51 if (x.Exists) { this.RomImage = Image.FromFile(x.FullName); }
52 else
53 {
54 if (EMUConfig.GameExe != string.Empty)
55 {
56 FileInfo fi_gamexe = new FileInfo(EMUConfig.GameExe);
57 path = fi_gamexe.FullName.Replace(fi_gamexe.Name, "").Replace(fi_gamexe.Extension, "");
58 image_path = string.Format(@"{0}{1}", path, fi_gameimage.Name);
59 x = new FileInfo(image_path);
60 if (x.Exists) { this.RomImage = Image.FromFile(x.FullName); }
61 }
62 }
63 }
64 }
65
66
67 //string config_dir = fi.Directory.Parent.FullName;
68 //Config = EmuConfigLoader.Load(config_dir);
69 Config = EMUConfig;
70 }
71 #region IRomConfig Members
72 public string RomFile { get; private set; }
73 public string RomTitle { get; private set; }
74 public Image RomImage { get; private set; }
75 public IEmuConfig Config { get; private set; }
76 #endregion
77 }
78 #endregion
79 }
80
81
82 }

  ViewVC Help
Powered by ViewVC 1.1.22