Mercurial > repos > snowblizz-super-API-ideas
changeset 51:b271a2252758
Re #50 - Fully load XML files
* Load remaining GameSystem attributes
* Add "AllowAllies" property to GameSystem class
* Add "is loading" methods to "staged loading" interface
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sat, 28 Mar 2009 21:00:35 +0000 |
parents | bb6b993b98bf |
children | 64ef178c18aa |
files | api/Factories/Xml/WarFoundryXmlFactory.cs api/Objects/GameSystem.cs api/Objects/IWarFoundryStagedLoadObject.cs |
diffstat | 3 files changed, 22 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/api/Factories/Xml/WarFoundryXmlFactory.cs Sat Mar 28 20:51:06 2009 +0000 +++ b/api/Factories/Xml/WarFoundryXmlFactory.cs Sat Mar 28 21:00:35 2009 +0000 @@ -284,6 +284,9 @@ string defaultStatsID = statsElem.GetAttribute("defaultStats"); LoadSystemStatsForSystem(system, extraData); system.StandardSystemStatsID = defaultStatsID; + XmlElement systemElement = SelectSingleElement(extraData, "/system:system"); + system.WarnOnError = XmlTools.GetBoolValueFromAttribute(systemElement, "warn"); + system.AllowAllies = XmlTools.GetBoolValueFromAttribute(systemElement, "allowAllies"); LogNotifier.DebugFormat(GetType(), "Completed loading of GameSystem with ID {0}", system.ID); LogNotifier.DebugFormat(GetType(), "GameSystem with ID {0} default stats: {1}", system.ID, system.StandardSystemStatsID); system.SetAsFullyLoaded(); @@ -309,8 +312,6 @@ private void LoadCategoriesForSystem(GameSystem system, XmlNode elem) { - WarFoundryObject tempObj; - foreach (XmlElement cat in SelectNodes(elem, "/system:system/system:categories/cat:cat")) { system.AddCategory(CreateCategoryFromElement(cat)); @@ -354,13 +355,12 @@ public void CompleteLoading(Race race) { - if (!CanCompleteLoading(system)) + if (!CanCompleteLoading(race)) { return; } - race.SetAsLoading(); - + race.SetAsLoading(); XmlDocument extraData = GetExtraData(race); foreach (XmlElement node in SelectNodes(extraData, "/race:race/race:units/race:unit"))
--- a/api/Objects/GameSystem.cs Sat Mar 28 20:51:06 2009 +0000 +++ b/api/Objects/GameSystem.cs Sat Mar 28 21:00:35 2009 +0000 @@ -17,7 +17,8 @@ /// </summary> public class GameSystem : WarFoundryStagedLoadingObject { - private bool warnOnError; + private bool warnOnError; + private bool allowAllies; private Dictionary<string, Category> categories = new Dictionary<string,Category>(); private Dictionary<string, SystemStats> stats = new Dictionary<string,SystemStats>(); private string defaultStats; @@ -26,14 +27,12 @@ { stats = new Dictionary<string,SystemStats>(); } - - /*public void CompleteLoading(Category[] cats, Dictionary<string, SystemStats> sysStats, string defaultStatsID) + + public bool AllowAllies { - categories = cats; - stats = new SystemStatsSet(sysStats); - defaultStats = defaultStatsID; - base.CompleteLoading(); - }*/ + get { return allowAllies; } + set { allowAllies = value; } + } public void AddCategory(Category cat) {
--- a/api/Objects/IWarFoundryStagedLoadObject.cs Sat Mar 28 20:51:06 2009 +0000 +++ b/api/Objects/IWarFoundryStagedLoadObject.cs Sat Mar 28 21:00:35 2009 +0000 @@ -26,9 +26,19 @@ /// </value> bool IsFullyLoaded { get; } + /// <value> + /// Returns <code>true</code> if the object is in the process of being fully loaded with all data, else returns <code>false</code> + /// </value> + bool IsLoading { get; } + /// <summary> /// Marks the object as fully loaded so that no more load checking is required. /// </summary> void SetAsFullyLoaded(); + + /// <summary> + /// Markes the object as being in the process of being fully loaded. + /// </summary> + void SetAsLoading(); } }