Mercurial > repos > IBDev-IBBoard.WarFoundry.API
changeset 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 | 1ed2f3ab5e35 |
children | aa0d18816cf8 |
files | API/WarFoundryHacks.cs IBBoard.WarFoundry.API.csproj |
diffstat | 2 files changed, 8 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/API/WarFoundryHacks.cs Sat Jul 07 21:01:32 2012 +0100 +++ b/API/WarFoundryHacks.cs Wed Jul 11 20:39:34 2012 +0100 @@ -8,6 +8,8 @@ using IBBoard.WarFoundry.API.Factories.Xml; using IBBoard.WarFoundry.API.Savers; using IBBoard.WarFoundry.API.Savers.Xml; +using IBBoard.WarFoundry.API.Loading; +using System.Reflection; namespace IBBoard.WarFoundry.API { @@ -18,8 +20,10 @@ { public static void Initialise() { - //Set default data path - should be a preference - //WarFoundryLoader.GetDefault().AddLoadDirectory(new DirectoryInfo(Path.Combine(Constants.ExecutablePath, "data"))); + //Load embedded files from resource + Assembly assm = Assembly.GetExecutingAssembly(); + LoadableObjectSourceResourceSet resSet = new LoadableObjectSourceResourceSet(assm, "IBBoard.WarFoundry.data.Empire.race", "IBBoard.WarFoundry.data.SampleSystem.system"); + WarFoundryLoader.GetDefault().AddLoadSource(resSet); //Make sure we have at least one loader - should be controlled by plugins WarFoundryLoader.GetDefault().RegisterFactory(WarFoundryXmlFactory.GetFactory()); //Make sure we have a way to save files - should be controlled by plugins
--- a/IBBoard.WarFoundry.API.csproj Sat Jul 07 21:01:32 2012 +0100 +++ b/IBBoard.WarFoundry.API.csproj Wed Jul 11 20:39:34 2012 +0100 @@ -148,12 +148,6 @@ <Compile Include="API\Commands\EditArmyCommand.cs" /> <Compile Include="API\Factories\Requirement\UnitRequiresNoMoreThanNOfUnitTypeRequirementFactory.cs" /> <Compile Include="API\WarFoundryHacks.cs" /> - <None Include="data\Empire.race"> - <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> - </None> - <None Include="data\SampleSystem.system"> - <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> - </None> <Compile Include="API\Factories\Requirement\UnitRequiresNUnitsForMUnitsRequirementFactory.cs" /> <Compile Include="API\Objects\Requirement\UnitRequiresNUnitsForMUnitsRequirement.cs" /> <Compile Include="API\Objects\Requirement\RequiresNUnitsForMObjectsRequirement.cs" /> @@ -233,5 +227,7 @@ <EmbeddedResource Include="schemas\xhtml-symbol.ent"> <Gettext-ScanForTranslations>False</Gettext-ScanForTranslations> </EmbeddedResource> + <EmbeddedResource Include="data\Empire.race" /> + <EmbeddedResource Include="data\SampleSystem.system" /> </ItemGroup> </Project> \ No newline at end of file