changeset 144:721891008b5c

Fixes #22: Add functionality to get failed file loads and reason * Add event for file load start and end - end event has list of failures as parameter
author IBBoard <dev@ibboard.co.uk>
date Mon, 21 Sep 2009 18:58:50 +0000
parents 7f13ffcb8765
children 57517f472ab5
files api/WarFoundryLoader.cs
diffstat 1 files changed, 13 insertions(+), 4 deletions(-) [+]
line diff
     1.1 --- a/api/WarFoundryLoader.cs	Sat Sep 19 19:42:53 2009 +0000
     1.2 +++ b/api/WarFoundryLoader.cs	Mon Sep 21 18:58:50 2009 +0000
     1.3 @@ -40,8 +40,11 @@
     1.4  		private Dictionary<string, GameSystem> systemsTable;
     1.5  		private Dictionary<string, Dictionary<string, Dictionary<string, Race>>> racesTable; //Keys are: System, Race, SubRace
     1.6  		private Dictionary<IWarFoundryFactory, SimpleSet<IWarFoundryObject>> loadedObjects;
     1.7 +		public delegate void FileLoadingCompleteDelegate(List<FileLoadFailure> failures);
     1.8 +		public event MethodInvoker FileLoadingStarted;
     1.9 +		public event FileLoadingCompleteDelegate FileLoadingFinished;
    1.10  		
    1.11 -		protected WarFoundryLoader()
    1.12 +		private WarFoundryLoader()
    1.13  		{
    1.14  			directories = new List<DirectoryInfo>();
    1.15  			factories = new List<INativeWarFoundryFactory>();
    1.16 @@ -148,12 +151,18 @@
    1.17  			List<FileLoadFailure> failedLoads = FillLoadableFiles(loadableRaces, loadableGameSystems);
    1.18  			failedLoads.AddRange(LoadGameSystems(loadableGameSystems));
    1.19  			failedLoads.AddRange(LoadRaces(loadableRaces));
    1.20 -
    1.21 -			LogNotifier.Debug(GetType(), failedLoads.Count + " failed file loads");
    1.22 -			
    1.23 +			OnFileLoadingFinished(failedLoads);
    1.24  			return failedLoads;
    1.25  		}
    1.26  		
    1.27 +		private void OnFileLoadingFinished(List<FileLoadFailure> failures)
    1.28 +		{
    1.29 +			if (FileLoadingFinished!=null)
    1.30 +			{
    1.31 +				FileLoadingFinished(failures);
    1.32 +			}
    1.33 +		}
    1.34 +		
    1.35  		protected void PrepareForFileLoad()
    1.36  		{
    1.37  			//Just set up blank dictionaries for now - may try different and more complex handling in future