changeset 165:dc13cef2bc2b

Re #420: Saved army does not save "contained" structure * Make sure GTK# UI loads nesting correctly
author IBBoard <dev@ibboard.co.uk>
date Sat, 01 Sep 2012 15:29:15 +0100
parents 219340630150
children ef94bed818e1
files FrmMainWindow.cs
diffstat 1 files changed, 14 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/FrmMainWindow.cs	Wed Aug 08 20:53:54 2012 +0100
+++ b/FrmMainWindow.cs	Sat Sep 01 15:29:15 2012 +0100
@@ -337,7 +337,6 @@
 			TreeIter targetIter = TreeIter.Zero;
 			TreeIter iter;
 			model.GetIterFirst(out iter);
-			bool found = false;
 
 			do
 			{
@@ -649,14 +648,26 @@
 					logger.DebugFormat("Append category {0}", cat.Name);
 					iter = store.AppendValues(cat);
 
-					foreach (WFObjects.Unit unit in cat.GetUnits())
+					foreach (WFObjects.Unit unit in cat.GetMainUnits())
 					{
-						store.AppendValues(iter, unit);
+						AddUnitToTree(store, iter, unit);
 					}
 				}
 
 				logger.Debug("Finished loading tree categories");
 			}
+
+			treeUnits.ExpandAll();
+		}
+
+		private void AddUnitToTree(TreeStore store, TreeIter parentIter, WFObjects.Unit unit)
+		{
+			TreeIter unitIter = store.AppendValues(parentIter, unit);
+			
+			foreach (WFObjects.Unit childUnit in unit.ContainedUnits)
+			{
+				AddUnitToTree(store, unitIter, childUnit);
+			}
 		}
 
 		private void DisableCategoryButtons()