comparison API/WarFoundryHacks.cs @ 483:4d6c92744254

Re #419: Remove assumptions of a file-based install * Embed sample files as resources * Load the sample files as a "hack"
author IBBoard <dev@ibboard.co.uk>
date Wed, 11 Jul 2012 20:39:34 +0100
parents 81f32062c9fa
children e35fc85eda2b
comparison
equal deleted inserted replaced
482:1ed2f3ab5e35 483:4d6c92744254
6 using IBBoard; 6 using IBBoard;
7 using IBBoard.WarFoundry.API.Factories.Requirement; 7 using IBBoard.WarFoundry.API.Factories.Requirement;
8 using IBBoard.WarFoundry.API.Factories.Xml; 8 using IBBoard.WarFoundry.API.Factories.Xml;
9 using IBBoard.WarFoundry.API.Savers; 9 using IBBoard.WarFoundry.API.Savers;
10 using IBBoard.WarFoundry.API.Savers.Xml; 10 using IBBoard.WarFoundry.API.Savers.Xml;
11 using IBBoard.WarFoundry.API.Loading;
12 using System.Reflection;
11 13
12 namespace IBBoard.WarFoundry.API 14 namespace IBBoard.WarFoundry.API
13 { 15 {
14 /// <summary> 16 /// <summary>
15 /// A collection of hacks and work-arounds to make things work correctly. 17 /// A collection of hacks and work-arounds to make things work correctly.
16 /// </summary> 18 /// </summary>
17 public class WarFoundryHacks 19 public class WarFoundryHacks
18 { 20 {
19 public static void Initialise() 21 public static void Initialise()
20 { 22 {
21 //Set default data path - should be a preference 23 //Load embedded files from resource
22 //WarFoundryLoader.GetDefault().AddLoadDirectory(new DirectoryInfo(Path.Combine(Constants.ExecutablePath, "data"))); 24 Assembly assm = Assembly.GetExecutingAssembly();
25 LoadableObjectSourceResourceSet resSet = new LoadableObjectSourceResourceSet(assm, "IBBoard.WarFoundry.data.Empire.race", "IBBoard.WarFoundry.data.SampleSystem.system");
26 WarFoundryLoader.GetDefault().AddLoadSource(resSet);
23 //Make sure we have at least one loader - should be controlled by plugins 27 //Make sure we have at least one loader - should be controlled by plugins
24 WarFoundryLoader.GetDefault().RegisterFactory(WarFoundryXmlFactory.GetFactory()); 28 WarFoundryLoader.GetDefault().RegisterFactory(WarFoundryXmlFactory.GetFactory());
25 //Make sure we have a way to save files - should be controlled by plugins 29 //Make sure we have a way to save files - should be controlled by plugins
26 WarFoundrySaver.SetFileSaver(new WarFoundryXmlFileSaver()); 30 WarFoundrySaver.SetFileSaver(new WarFoundryXmlFileSaver());
27 //Make sure we have the requirement factories - should be controlled by plugins 31 //Make sure we have the requirement factories - should be controlled by plugins