comparison api/Factories/Xml/WarFoundryXmlFactory.cs @ 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
comparison
equal deleted inserted replaced
50:bb6b993b98bf 51:b271a2252758
282 LoadCategoriesForSystem(system, extraData); 282 LoadCategoriesForSystem(system, extraData);
283 XmlElement statsElem = SelectSingleElement(extraData, "/system:system/system:sysStatsList"); 283 XmlElement statsElem = SelectSingleElement(extraData, "/system:system/system:sysStatsList");
284 string defaultStatsID = statsElem.GetAttribute("defaultStats"); 284 string defaultStatsID = statsElem.GetAttribute("defaultStats");
285 LoadSystemStatsForSystem(system, extraData); 285 LoadSystemStatsForSystem(system, extraData);
286 system.StandardSystemStatsID = defaultStatsID; 286 system.StandardSystemStatsID = defaultStatsID;
287 XmlElement systemElement = SelectSingleElement(extraData, "/system:system");
288 system.WarnOnError = XmlTools.GetBoolValueFromAttribute(systemElement, "warn");
289 system.AllowAllies = XmlTools.GetBoolValueFromAttribute(systemElement, "allowAllies");
287 LogNotifier.DebugFormat(GetType(), "Completed loading of GameSystem with ID {0}", system.ID); 290 LogNotifier.DebugFormat(GetType(), "Completed loading of GameSystem with ID {0}", system.ID);
288 LogNotifier.DebugFormat(GetType(), "GameSystem with ID {0} default stats: {1}", system.ID, system.StandardSystemStatsID); 291 LogNotifier.DebugFormat(GetType(), "GameSystem with ID {0} default stats: {1}", system.ID, system.StandardSystemStatsID);
289 system.SetAsFullyLoaded(); 292 system.SetAsFullyLoaded();
290 } 293 }
291 294
307 return canLoad; 310 return canLoad;
308 } 311 }
309 312
310 private void LoadCategoriesForSystem(GameSystem system, XmlNode elem) 313 private void LoadCategoriesForSystem(GameSystem system, XmlNode elem)
311 { 314 {
312 WarFoundryObject tempObj;
313
314 foreach (XmlElement cat in SelectNodes(elem, "/system:system/system:categories/cat:cat")) 315 foreach (XmlElement cat in SelectNodes(elem, "/system:system/system:categories/cat:cat"))
315 { 316 {
316 system.AddCategory(CreateCategoryFromElement(cat)); 317 system.AddCategory(CreateCategoryFromElement(cat));
317 } 318 }
318 } 319 }
352 return new SystemStats(id, slots.ToArray()); 353 return new SystemStats(id, slots.ToArray());
353 } 354 }
354 355
355 public void CompleteLoading(Race race) 356 public void CompleteLoading(Race race)
356 { 357 {
357 if (!CanCompleteLoading(system)) 358 if (!CanCompleteLoading(race))
358 { 359 {
359 return; 360 return;
360 } 361 }
361 362
362 race.SetAsLoading(); 363 race.SetAsLoading();
363
364 XmlDocument extraData = GetExtraData(race); 364 XmlDocument extraData = GetExtraData(race);
365 365
366 foreach (XmlElement node in SelectNodes(extraData, "/race:race/race:units/race:unit")) 366 foreach (XmlElement node in SelectNodes(extraData, "/race:race/race:units/race:unit"))
367 { 367 {
368 UnitType type = CreateUnitTypeFromElement(node, race, race.GameSystem); 368 UnitType type = CreateUnitTypeFromElement(node, race, race.GameSystem);