annotate API/Factories/AbstractNonNativeFileExtensionWarFoundryFactory.cs @ 485:8160d1f8243c

Re #418: Build WarFoundry for Android PoC * Make Mono for Android version of .csproj file
author IBBoard <dev@ibboard.co.uk>
date Sat, 14 Jul 2012 15:26:46 +0100
parents 1ed2f3ab5e35
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
337
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
1 // This file (AbstractNonNativeFileExtensionWarFoundryFactory.cs) is a part of the IBBoard.WarFoundry.API project and is copyright 2007, 2008, 2009 IBBoard.
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
2 //
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
3 // The file and the library/program it is in are licensed and distributed, without warranty, under the GNU Affero GPL license, either version 3 of the License or (at your option) any later version. Please see COPYING for more information and the full license.
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
4 using System;
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
5 using System.Collections.Generic;
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
6 using System.IO;
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
7 using IBBoard.WarFoundry.API.Objects;
482
1ed2f3ab5e35 Re #419: Remove assumptions of a file-based install
IBBoard <dev@ibboard.co.uk>
parents: 463
diff changeset
8 using IBBoard.WarFoundry.API.Loading;
337
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
9
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
10 namespace IBBoard.WarFoundry.API.Factories
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
11 {
482
1ed2f3ab5e35 Re #419: Remove assumptions of a file-based install
IBBoard <dev@ibboard.co.uk>
parents: 463
diff changeset
12 public abstract class AbstractNonNativeFileExtensionWarFoundryFactory : AbstractNonNativeWarFoundryFactory<ILoadableObject>
337
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
13 {
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
14 protected abstract string ArmyFileExtension { get; }
463
cbeee87dc2d3 Re #58: Remove LogNotifier from API
IBBoard <dev@ibboard.co.uk>
parents: 337
diff changeset
15
337
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
16 protected abstract string RaceFileExtension { get; }
463
cbeee87dc2d3 Re #58: Remove LogNotifier from API
IBBoard <dev@ibboard.co.uk>
parents: 337
diff changeset
17
337
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
18 protected abstract string GameSystemFileExtension { get; }
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
19
482
1ed2f3ab5e35 Re #419: Remove assumptions of a file-based install
IBBoard <dev@ibboard.co.uk>
parents: 463
diff changeset
20 protected override bool CheckCanHandleFileFormat(ILoadableObject file)
337
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
21 {
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
22 return CheckCanHandleFileAsArmy(file) || CheckCanHandleFileAsRace(file) || CheckCanHandleFileAsGameSystem(file);
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
23 }
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
24
482
1ed2f3ab5e35 Re #419: Remove assumptions of a file-based install
IBBoard <dev@ibboard.co.uk>
parents: 463
diff changeset
25 protected override bool CheckCanHandleFileAsArmy(ILoadableObject file)
337
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
26 {
463
cbeee87dc2d3 Re #58: Remove LogNotifier from API
IBBoard <dev@ibboard.co.uk>
parents: 337
diff changeset
27 return ArmyFileExtension != null && file.Name.ToLower().EndsWith(ArmyFileExtension);
337
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
28 }
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
29
482
1ed2f3ab5e35 Re #419: Remove assumptions of a file-based install
IBBoard <dev@ibboard.co.uk>
parents: 463
diff changeset
30 protected override bool CheckCanHandleFileAsRace(ILoadableObject file)
337
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
31 {
463
cbeee87dc2d3 Re #58: Remove LogNotifier from API
IBBoard <dev@ibboard.co.uk>
parents: 337
diff changeset
32 return RaceFileExtension != null && file.Name.ToLower().EndsWith(RaceFileExtension);
337
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
33 }
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
34
482
1ed2f3ab5e35 Re #419: Remove assumptions of a file-based install
IBBoard <dev@ibboard.co.uk>
parents: 463
diff changeset
35 protected override bool CheckCanHandleFileAsGameSystem(ILoadableObject file)
337
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
36 {
463
cbeee87dc2d3 Re #58: Remove LogNotifier from API
IBBoard <dev@ibboard.co.uk>
parents: 337
diff changeset
37 return GameSystemFileExtension != null && file.Name.ToLower().EndsWith(GameSystemFileExtension);
337
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
38 }
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
39
482
1ed2f3ab5e35 Re #419: Remove assumptions of a file-based install
IBBoard <dev@ibboard.co.uk>
parents: 463
diff changeset
40 protected override ILoadableObject GetFileAsSupportedType(ILoadableObject file)
337
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
41 {
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
42 return file;
463
cbeee87dc2d3 Re #58: Remove LogNotifier from API
IBBoard <dev@ibboard.co.uk>
parents: 337
diff changeset
43 }
337
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
44
482
1ed2f3ab5e35 Re #419: Remove assumptions of a file-based install
IBBoard <dev@ibboard.co.uk>
parents: 463
diff changeset
45 protected abstract Army CreateArmyFromFile(ILoadableObject file);
463
cbeee87dc2d3 Re #58: Remove LogNotifier from API
IBBoard <dev@ibboard.co.uk>
parents: 337
diff changeset
46
482
1ed2f3ab5e35 Re #419: Remove assumptions of a file-based install
IBBoard <dev@ibboard.co.uk>
parents: 463
diff changeset
47 protected abstract Race CreateRaceFromFile(ILoadableObject file);
463
cbeee87dc2d3 Re #58: Remove LogNotifier from API
IBBoard <dev@ibboard.co.uk>
parents: 337
diff changeset
48
482
1ed2f3ab5e35 Re #419: Remove assumptions of a file-based install
IBBoard <dev@ibboard.co.uk>
parents: 463
diff changeset
49 protected abstract GameSystem CreateGameSystemFromFile(ILoadableObject file);
337
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
50
482
1ed2f3ab5e35 Re #419: Remove assumptions of a file-based install
IBBoard <dev@ibboard.co.uk>
parents: 463
diff changeset
51 protected override ICollection<IWarFoundryObject> DoCreateObjectsFromFile(ILoadableObject file)
337
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
52 {
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
53 IWarFoundryObject obj = null;
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
54
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
55 if (CheckCanHandleFileAsGameSystem(file))
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
56 {
463
cbeee87dc2d3 Re #58: Remove LogNotifier from API
IBBoard <dev@ibboard.co.uk>
parents: 337
diff changeset
57 GameSystem gameSystem = CreateGameSystemFromFile(file);
337
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
58 OnGameSystemLoaded(gameSystem);
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
59 obj = gameSystem;
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
60 }
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
61 else if (CheckCanHandleFileAsRace(file))
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
62 {
463
cbeee87dc2d3 Re #58: Remove LogNotifier from API
IBBoard <dev@ibboard.co.uk>
parents: 337
diff changeset
63 Race race = CreateRaceFromFile(file);
337
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
64 OnRaceLoaded(race);
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
65 obj = race;
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
66 }
463
cbeee87dc2d3 Re #58: Remove LogNotifier from API
IBBoard <dev@ibboard.co.uk>
parents: 337
diff changeset
67 else //Must have been an army file
337
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
68 {
463
cbeee87dc2d3 Re #58: Remove LogNotifier from API
IBBoard <dev@ibboard.co.uk>
parents: 337
diff changeset
69 Army army = CreateArmyFromFile(file);
337
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
70 OnArmyLoaded(army);
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
71 obj = army;
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
72 }
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
73
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
74 ICollection<IWarFoundryObject> objects = new List<IWarFoundryObject>();
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
75
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
76 if (obj != null)
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
77 {
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
78 objects.Add(obj);
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
79 }
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
80
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
81 return objects;
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
82 }
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
83 }
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
84 }