Mercurial > repos > snowblizz-super-API-ideas
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 wrap: on
line diff
--- a/api/WarFoundryLoader.cs Sat Sep 19 19:42:53 2009 +0000 +++ b/api/WarFoundryLoader.cs Mon Sep 21 18:58:50 2009 +0000 @@ -40,8 +40,11 @@ private Dictionary<string, GameSystem> systemsTable; private Dictionary<string, Dictionary<string, Dictionary<string, Race>>> racesTable; //Keys are: System, Race, SubRace private Dictionary<IWarFoundryFactory, SimpleSet<IWarFoundryObject>> loadedObjects; + public delegate void FileLoadingCompleteDelegate(List<FileLoadFailure> failures); + public event MethodInvoker FileLoadingStarted; + public event FileLoadingCompleteDelegate FileLoadingFinished; - protected WarFoundryLoader() + private WarFoundryLoader() { directories = new List<DirectoryInfo>(); factories = new List<INativeWarFoundryFactory>(); @@ -148,12 +151,18 @@ List<FileLoadFailure> failedLoads = FillLoadableFiles(loadableRaces, loadableGameSystems); failedLoads.AddRange(LoadGameSystems(loadableGameSystems)); failedLoads.AddRange(LoadRaces(loadableRaces)); - - LogNotifier.Debug(GetType(), failedLoads.Count + " failed file loads"); - + OnFileLoadingFinished(failedLoads); return failedLoads; } + private void OnFileLoadingFinished(List<FileLoadFailure> failures) + { + if (FileLoadingFinished!=null) + { + FileLoadingFinished(failures); + } + } + protected void PrepareForFileLoad() { //Just set up blank dictionaries for now - may try different and more complex handling in future