changeset 69:3b4a646b4054

Re #60: Add UI to add/remove/edit weapons in GTK * Fix errors in replace dialog (move UI setup to just before we show) Also: * Fix missing refresh of army tree on equipment/points value change
author IBBoard <dev@ibboard.co.uk>
date Sat, 06 Nov 2010 11:44:26 +0000
parents 7028e24b67ec
children 4b82515586ac
files FrmMainWindow.cs UIControl/AbstractBaseEquipmentUIControl.cs UIControl/ReplaceEquipmentUIControl.cs gtk-gui/IBBoard.WarFoundry.GTK.Widgets.UnitDisplayWidget.cs gtk-gui/IBBoard.WarFoundry.GUI.GTK.FrmAddEquipment.cs gtk-gui/IBBoard.WarFoundry.GUI.GTK.FrmEditEquipment.cs
diffstat 6 files changed, 149 insertions(+), 152 deletions(-) [+]
line wrap: on
line diff
--- a/FrmMainWindow.cs	Wed Nov 03 21:02:54 2010 +0000
+++ b/FrmMainWindow.cs	Sat Nov 06 11:44:26 2010 +0000
@@ -35,23 +35,18 @@
 	{
 		private static readonly string AppTitle = "WarFoundry";
 		private const int CATEGORY_BUTTON_SEPARATOR_INDEX = 6;
-
 		private Preferences preferences;
 		private ILog logger = LogManager.GetLogger(typeof(FrmMainWindow));
-
 		private CommandStack commandStack;
 		private Dictionary<ToolButton, Category> categoryMap = new Dictionary<ToolButton, Category>();
 		private Dictionary<WFObjects.Unit, UnitDisplayWidget> unitToWidgetMap = new Dictionary<WFObjects.Unit,UnitDisplayWidget>();
-
 		private ObjectAddDelegate UnitAddedMethod;
 		private ObjectRemoveDelegate UnitRemovedMethod;
 		private DoubleValChangedDelegate PointsValueChangedMethod;
 		private FailedUnitRequirementDelegate FailedUnitRequirementMethod;
 		private StringValChangedDelegate UnitNameChangedMethod;
-
 		private GameSystem system;
 		private string loadedArmyPath;
-
 		private MenuToolButton undoMenuButton, redoMenuButton;
 
 		public static void Main(string[] args)
@@ -65,7 +60,7 @@
 				Application.Run();
 				LogManager.GetLogger(typeof(FrmMainWindow)).Debug("Application ended");
 			}
-			catch(Exception ex)
+			catch (Exception ex)
 			{
 				HandleUnhandledException(ex);
 			}
@@ -82,7 +77,7 @@
 			}
 			else
 			{
-				ex = new Exception("GLib returned unexpected exception object type "+obj.GetType());
+				ex = new Exception("GLib returned unexpected exception object type " + obj.GetType());
 			}
 			
 			HandleUnhandledException(ex);
@@ -104,7 +99,7 @@
 			
 			if (ex != null)
 			{
-				message  = "Caused by: " + ex.GetType().FullName + Environment.NewLine + ex.StackTrace + Environment.NewLine ;
+				message = "Caused by: " + ex.GetType().FullName + Environment.NewLine + ex.StackTrace + Environment.NewLine ;
 			}
 			
 			return message;
@@ -130,15 +125,15 @@
 			undoMenuButton.TooltipText = "Undo";
 			undoMenuButton.Clicked += undoTBButtonActivated;
 			toolbar.Insert(undoMenuButton, CATEGORY_BUTTON_SEPARATOR_INDEX);
-			toolbar.Remove(toolbar.Children[CATEGORY_BUTTON_SEPARATOR_INDEX-1]);
-			toolbar.Remove(toolbar.Children[CATEGORY_BUTTON_SEPARATOR_INDEX-2]);
+			toolbar.Remove(toolbar.Children[CATEGORY_BUTTON_SEPARATOR_INDEX - 1]);
+			toolbar.Remove(toolbar.Children[CATEGORY_BUTTON_SEPARATOR_INDEX - 2]);
 			toolbar.ShowAll();
 
 			Title = AppTitle;
-			TreeViewColumn mainColumn = new TreeViewColumn ();
+			TreeViewColumn mainColumn = new TreeViewColumn();
 			mainColumn.Title = "Army Categories";
-			CellRendererText mainCell = new CellRendererText ();
-			mainColumn.PackStart (mainCell, true);
+			CellRendererText mainCell = new CellRendererText();
+			mainColumn.PackStart(mainCell, true);
 			treeUnits.AppendColumn(mainColumn);
 			mainColumn.SetCellDataFunc(mainCell, new TreeCellDataFunc(RenderCategoryTreeObjectName));
 			treeUnits.Model = new TreeStore(typeof(WarFoundryObject));
@@ -161,10 +156,10 @@
 
 			logger.Debug("Initialising");
 			commandStack = new CommandStack();
-			commandStack.CommandStackUpdated+=new MethodInvoker(commandStack_CommandStackUpdated);
-			WarFoundryCore.GameSystemChanged+= new GameSystemChangedDelegate(OnGameSystemChanged);
-			WarFoundryCore.ArmyChanged+= new ArmyChangedDelegate(OnArmyChanged);
-			Destroyed+= new EventHandler(OnWindowDestroyed);
+			commandStack.CommandStackUpdated += new MethodInvoker(commandStack_CommandStackUpdated);
+			WarFoundryCore.GameSystemChanged += new GameSystemChangedDelegate(OnGameSystemChanged);
+			WarFoundryCore.ArmyChanged += new ArmyChangedDelegate(OnArmyChanged);
+			Destroyed += new EventHandler(OnWindowDestroyed);
 			//TODO: Translate and subscribe to other events
 			UnitAddedMethod = new ObjectAddDelegate(OnUnitAdded);
 			UnitRemovedMethod = new ObjectRemoveDelegate(OnUnitRemoved);
@@ -201,10 +196,14 @@
 							WarFoundryCore.CurrentArmy = (Army)loadedObject;
 							logger.InfoFormat("Loaded army from {0}", file.FullName);
 						}
-						else if (loadedObject is GameSystem)
+						else
 						{
-							WarFoundryCore.CurrentGameSystem = (GameSystem)loadedObject;
-							logger.InfoFormat("Loaded game system from {0}", file.FullName);
+							if (loadedObject is GameSystem)
+							{
+								WarFoundryCore.CurrentGameSystem = (GameSystem)loadedObject;
+								logger.InfoFormat("Loaded game system from {0}", file.FullName);
+							}
+
 						}
 					}
 				}
@@ -218,12 +217,12 @@
 			{
 				string gameSystemID = Preferences.GetStringProperty("currSystem");
 
-				if (gameSystemID!=null && !"".Equals(gameSystemID))
+				if (gameSystemID != null && !"".Equals(gameSystemID))
 				{
 					logger.Debug("Attempting to load current game system from properties");
 					GameSystem sys = WarFoundryLoader.GetDefault().GetGameSystem(gameSystemID);
 
-					if (sys!=null)
+					if (sys != null)
 					{
 						WarFoundryCore.CurrentGameSystem = sys;
 						logger.InfoFormat("Loaded game system {0} from properties", gameSystemID);
@@ -232,9 +231,9 @@
 			}
 		}
 
-		private void FileLoadingFinished (List<FileLoadFailure> failures)
+		private void FileLoadingFinished(List<FileLoadFailure> failures)
 		{
-			foreach(FileLoadFailure failure in failures)
+			foreach (FileLoadFailure failure in failures)
 			{
 				logger.Warn("Failed to load " + failure.FailedFile.FullName + ": " + failure.Message);
 			}
@@ -260,11 +259,15 @@
 
 				(cell as CellRendererText).Text = name;
 			}
-			else if (o is WFObjects.Unit)
+			else
 			{
-				WFObjects.Unit u = (WFObjects.Unit)o;
-				string name = Translation.GetTranslation("unitTreeCatName", "{0} - {1}pts", u.Name, u.Points);
-				(cell as CellRendererText).Text = name;
+				if (o is WFObjects.Unit)
+				{
+					WFObjects.Unit u = (WFObjects.Unit)o;
+					string name = Translation.GetTranslation("unitTreeCatName", "{0} - {1}pts", u.Name, u.Points);
+					(cell as CellRendererText).Text = name;
+				}
+
 			}
 		}
 
@@ -277,24 +280,31 @@
 		private void OnUnitNameChanged(WarFoundryObject val, string oldValue, string newValue)
 		{
 			WFObjects.Unit unit = (WFObjects.Unit)val;
+			logger.DebugFormat("Unit name changed for {0} - now called {1}", unit.ID, unit.Name);
 			UnitDisplayWidget widget;
 			unitToWidgetMap.TryGetValue(unit, out widget);
-			logger.DebugFormat("Unit name changed for {0} - now called {1}", unit.ID, unit.Name);
+			
+			if (widget != null)
+			{
+				unitsNotebook.SetTabLabel(widget, NotebookUtil.CreateNotebookTabLabelWithClose(unitsNotebook, widget, unit.Name));
+			}
+			
 			treeUnits.QueueDraw();
-
-			if (widget!=null)
-			{
-				unitsNotebook.SetTabLabel(widget, NotebookUtil.CreateNotebookTabLabelWithClose(unitsNotebook, widget, newValue));
-			}
 		}
 
 		private void OnUnitAdded(WarFoundryObject val)
 		{
 			WFObjects.Unit unit = (WFObjects.Unit)val;
-			unit.NameChanged+= UnitNameChangedMethod;
+			unit.NameChanged += UnitNameChangedMethod;
+			unit.PointsValueChanged += HandleUnitPointsValueChanged;
 			AddUnitToTree(unit);
 		}
 
+		private void HandleUnitPointsValueChanged(WarFoundryObject obj, double oldValue, double newValue)
+		{			
+			treeUnits.QueueDraw();
+		}
+
 		private void AddUnitToTree(WFObjects.Unit unit)
 		{
 			TreeStore model = (TreeStore)treeUnits.Model;
@@ -323,7 +333,7 @@
 		private void OnUnitRemoved(WarFoundryObject obj)
 		{
 			WFObjects.Unit unit = (WFObjects.Unit)obj;
-			unit.NameChanged-= UnitNameChangedMethod;
+			unit.NameChanged -= UnitNameChangedMethod;
 			RemoveUnitFromTree(unit);
 			RemoveUnitTab(unit);
 		}
@@ -402,9 +412,9 @@
 			get { return WarFoundryFactoryFactory.GetFactoryFactory().GetFactory(Constants.ExecutablePath, factoryType); }
 		}*/
 
-		protected void OnDeleteEvent (object sender, DeleteEventArgs a)
+		protected void OnDeleteEvent(object sender, DeleteEventArgs a)
 		{
-			Application.Quit ();
+			Application.Quit();
 			a.RetVal = true;
 		}
 
@@ -476,17 +486,21 @@
 
 		private void SetAppTitle()
 		{
-			if (WarFoundryCore.CurrentArmy!=null)
+			if (WarFoundryCore.CurrentArmy != null)
 			{
 				Title = AppTitle + " - " + WarFoundryCore.CurrentGameSystem.Name + " - " + WarFoundryCore.CurrentArmy.Name;
 			}
-			else if (WarFoundryCore.CurrentGameSystem!=null)
-			{
-				Title = AppTitle + " - " + WarFoundryCore.CurrentGameSystem.Name;
-			}
 			else
 			{
-				Title = AppTitle;
+				if (WarFoundryCore.CurrentGameSystem != null)
+				{
+					Title = AppTitle + " - " + WarFoundryCore.CurrentGameSystem.Name;
+				}
+				else
+				{
+					Title = AppTitle;
+				}
+
 			}
 		}
 
@@ -496,7 +510,7 @@
 			SetAppTitle();
 			RemoveCategoryButtons();
 
-			if (system!=null)
+			if (system != null)
 			{
 				AddCategoryButtons(system.Categories);
 			}
@@ -564,7 +578,7 @@
 			store.Clear();
 			TreeIter iter;
 
-			if (army!=null)
+			if (army != null)
 			{
 				logger.Debug("Loading in categories to tree");
 
@@ -596,7 +610,7 @@
 		private void SetCategoryButtonsSensitive(bool state)
 		{
 			int toolbarButtonCount = toolbar.Children.Length - 1;
-			logger.Debug("Last button index: "+toolbarButtonCount);
+			logger.Debug("Last button index: " + toolbarButtonCount);
 
 			for (int i = toolbarButtonCount; i > CATEGORY_BUTTON_SEPARATOR_INDEX; i--)
 			{
@@ -619,7 +633,7 @@
 
 		private void AddCategoryButtons(Category[] cats)
 		{
-			if (cats!=null && cats.Length > 0)
+			if (cats != null && cats.Length > 0)
 			{
 				logger.DebugFormat("Toolbar button count: {0}. Adding {1} categories.", toolbar.Children.Length, cats.Length);
 
@@ -627,15 +641,15 @@
 				{
 					ToolButton button = new ToolButton("gtk-add");
 					button.Label = cat.Name;
-					button.TooltipText = "Add unit from "+cat.Name;
+					button.TooltipText = "Add unit from " + cat.Name;
 					//TODO: See if we can associate data in some way, the same as we can with SWF. For now we just use the map.
 					categoryMap.Add(button, cat);
-					button.Clicked+= new System.EventHandler(OnAddUnitActivated);
+					button.Clicked += new System.EventHandler(OnAddUnitActivated);
 					toolbar.Insert(button, -1);
 				}
 			}
 
-			toolbar.Children[CATEGORY_BUTTON_SEPARATOR_INDEX].Visible = cats!=null && cats.Length>0;
+			toolbar.Children[CATEGORY_BUTTON_SEPARATOR_INDEX].Visible = cats != null && cats.Length > 0;
 
 			toolbar.ShowAll();
 		}
@@ -825,7 +839,7 @@
 		{
 			bool success = false;
 
-			if (loadedArmyPath!=null)
+			if (loadedArmyPath != null)
 			{
 				success = SaveArmyToPath(WarFoundryCore.CurrentArmy, loadedArmyPath);
 			}
@@ -858,7 +872,7 @@
 		{
 			bool success = false;
 			
-			if (filePath!=null)
+			if (filePath != null)
 			{
 				if (WarFoundrySaver.GetSaver().Save(WarFoundryCore.CurrentArmy, filePath))
 				{
@@ -870,7 +884,7 @@
 				}
 				else
 				{
-					MessageDialog dialog = new MessageDialog(this, DialogFlags.Modal, MessageType.Error, ButtonsType.Ok, "Failed to save file to "+filePath);
+					MessageDialog dialog = new MessageDialog(this, DialogFlags.Modal, MessageType.Error, ButtonsType.Ok, "Failed to save file to " + filePath);
 					dialog.Title = "Army save failed";
 					dialog.Run();
 					dialog.Hide();
@@ -902,15 +916,19 @@
 						//If they cancel the save as then assume they don't want to close
 						canClose = SaveCurrentArmyOrSaveAs();
 					}
-					else if (dr == ResponseType.No)
-					{
-						//They don't care about their changes
-						canClose = true;
-					}
 					else
 					{
+						if (dr == ResponseType.No)
+						{
+						//They don't care about their changes
+							canClose = true;
+						}
+						else
+						{
 						//Assume cancel or close with the X button
-						canClose = false;
+							canClose = false;
+						}
+
 					}
 				}
 				else
@@ -959,27 +977,27 @@
 			newArmy.Destroy();
 		}
 
-		protected virtual void undoTBButtonActivated (object sender, System.EventArgs e)
+		protected virtual void undoTBButtonActivated(object sender, System.EventArgs e)
 		{
 			CommandStack.Undo();
 		}
 
-		protected virtual void redoTBButtonActivated (object sender, System.EventArgs e)
+		protected virtual void redoTBButtonActivated(object sender, System.EventArgs e)
 		{
 			CommandStack.Redo();
 		}
 
-		protected virtual void saveTBButtonActivated (object sender, System.EventArgs e)
+		protected virtual void saveTBButtonActivated(object sender, System.EventArgs e)
 		{
 			SaveCurrentArmyOrSaveAs();
 		}
 
-		protected virtual void openTBButtonActivated (object sender, System.EventArgs e)
+		protected virtual void openTBButtonActivated(object sender, System.EventArgs e)
 		{
 			OpenArmy();
 		}
 
-		protected virtual void newTBButtonActivated (object sender, System.EventArgs e)
+		protected virtual void newTBButtonActivated(object sender, System.EventArgs e)
 		{
 			CreateNewArmy();
 		}
@@ -1018,7 +1036,7 @@
 			}
 		}
 
-		protected virtual void OnMiExportAsBasicHtmlActivated (object sender, System.EventArgs e)
+		protected virtual void OnMiExportAsBasicHtmlActivated(object sender, System.EventArgs e)
 		{
 			FileChooserDialog fileDialog = new FileChooserDialog("Export army", this, FileChooserAction.Save, "Cancel", ResponseType.Cancel, "Export", ResponseType.Accept);
 			FileFilter filter = new FileFilter();
@@ -1044,7 +1062,7 @@
 			}
 		}
 
-		protected virtual void OnTreeUnitsPopupMenu (object o, Gtk.PopupMenuArgs args)
+		protected virtual void OnTreeUnitsPopupMenu(object o, Gtk.PopupMenuArgs args)
 		{
 			object selectedItem = TreeUtils.GetSelectedItem(treeUnits);
 
@@ -1053,7 +1071,7 @@
 				Menu menu = new Menu();
 				ImageMenuItem delete = new ImageMenuItem("Remove unit");
 				delete.Image = new Gtk.Image(Stock.Delete, IconSize.Menu);
-				delete.Activated+= new EventHandler(OnUnitDelete);
+				delete.Activated += new EventHandler(OnUnitDelete);
 				delete.Data["unit"] = selectedItem;
 				menu.Append(delete);
 				menu.ShowAll();
@@ -1068,6 +1086,7 @@
 		}
 
 		[GLib.ConnectBefore]
+
 		protected virtual void UnitTreeButtonPressed(object o, Gtk.ButtonPressEventArgs args)
 		{
 			TreePath path;
--- a/UIControl/AbstractBaseEquipmentUIControl.cs	Wed Nov 03 21:02:54 2010 +0000
+++ b/UIControl/AbstractBaseEquipmentUIControl.cs	Sat Nov 06 11:44:26 2010 +0000
@@ -1,12 +1,14 @@
 //  This file (AbstractBaseEquipmentUIControl.cs) is a part of the IBBoard.WarFoundry.GUI.GTK project and is copyright 2010 IBBoard
 // 
 //  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.
+
 using System;
 using IBBoard.Commands;
 using IBBoard.WarFoundry.API.Objects;
 using IBBoard.WarFoundry.GUI.GTK.UIControl.Interfaces;
 using IBBoard.Lang;
 using IBBoard.WarFoundry.API.Util;
+
 namespace IBBoard.WarFoundry.GUI.GTK.UIControl
 {
 	public abstract class AbstractBaseEquipmentUIControl<UI_TYPE> where UI_TYPE : IBaseEquipmentUI
@@ -24,7 +26,6 @@
 		{
 			this.unit = unit;
 			this.commandStack = commandStack;
-			SetupUI();
 		}
 
 		private void SetupUI()
@@ -43,11 +44,13 @@
 		/// <returns>
 		/// the UI component to display to the user
 		/// </returns>
+
 		protected abstract UI_TYPE CreateEquipmentUI();
 		
 		/// <summary>
 		/// Completes any additional user interface setup.
 		/// </summary>
+
 		protected virtual void CompleteUISetup()
 		{
 			//Do nothing
@@ -61,6 +64,7 @@
 		/// <summary>
 		/// Sets the unit equipment values on the UI
 		/// </summary>
+
 		protected void SetUnitEquipmentValues()
 		{
 			ui.SetOkayEnabledState(HasNonZeroEquipmentAmount());
@@ -71,7 +75,6 @@
 				equipmentAmount = ui.EquipmentPercentageAmount;
 				SetEquipmentAmountsFromPercentage(equipmentAmount);
 			}
-
 			else
 			{
 				int equipmentIntAmount = ui.EquipmentNumericAmount;
@@ -89,15 +92,17 @@
 				//				MessageBox.Show(ParentForm, percentageTooLarge, percentageTooLargeTitle);
 				equipAmount = maxPercentage;
 			}
-
-			else if (equipAmount < minPercentage)
+			else
 			{
-				string percentageTooSmall = Translation.GetTranslation("equipPercentageTooSmall", "the current percentage ({0}%) was smaller than the minimum for the equipment item ({1}%) - the minimum value will be used instead", equipAmount, minPercentage);
-				string percentageTooSmallTitle = Translation.GetTranslation("equipPercentageTooSmallTitle", "equipment percentage too small");
+				if (equipAmount < minPercentage)
+				{
+					string percentageTooSmall = Translation.GetTranslation("equipPercentageTooSmall", "the current percentage ({0}%) was smaller than the minimum for the equipment item ({1}%) - the minimum value will be used instead", equipAmount, minPercentage);
+					string percentageTooSmallTitle = Translation.GetTranslation("equipPercentageTooSmallTitle", "equipment percentage too small");
 				//				MessageBox.Show(ParentForm, percentageTooSmall, percentageTooSmallTitle);
-				equipAmount = minPercentage;
-			}
-			
+					equipAmount = minPercentage;
+				}
+
+			}			
 			ui.EquipmentNumericAmount = CalculateNumericValueFromPercentage(equipAmount);
 			ui.EquipmentPercentageAmount = equipAmount;
 		}
@@ -117,15 +122,17 @@
 				//MessageBox.Show(ParentForm, amountTooLarge, amountTooLargeTitle);
 				equipAmount = maxNumber;
 			}
-
-			else if (equipAmount < minNumber)
+			else
 			{
-				string amountTooSmall = Translation.GetTranslation("equipNumberTooSmall", "the current amount ({0}) was smaller than the minimum for the equipment item ({1}) - the minimum value will be used instead", equipAmount, minNumber);
-				string amountTooSmallTitle = Translation.GetTranslation("equipNumberTooSmallTitle", "equipment amount too small");
+				if (equipAmount < minNumber)
+				{
+					string amountTooSmall = Translation.GetTranslation("equipNumberTooSmall", "the current amount ({0}) was smaller than the minimum for the equipment item ({1}) - the minimum value will be used instead", equipAmount, minNumber);
+					string amountTooSmallTitle = Translation.GetTranslation("equipNumberTooSmallTitle", "equipment amount too small");
 				//MessageBox.Show(ParentForm, amountTooSmall, amountTooSmallTitle);
-				equipAmount = minNumber;
-			}
-			
+					equipAmount = minNumber;
+				}
+
+			}			
 			ui.EquipmentPercentageAmount = CalcualtePercentageValueFromNumber(equipAmount);
 			ui.EquipmentNumericAmount = equipAmount;
 		}
@@ -174,8 +181,6 @@
 			{
 				nonZero = (ui.EquipmentPercentageAmount > 0);
 			}
-
-			
 			else
 			{
 				nonZero = (ui.EquipmentNumericAmount > 0);
@@ -191,6 +196,7 @@
 		
 		public void Show()
 		{			
+			SetupUI();
 			bool okayed = ui.ShowControl();
 			
 			if (okayed)
@@ -204,6 +210,7 @@
 		/// <summary>
 		/// Does the processing required for the control when the "OK" button was clicked
 		/// </summary>
+
 		protected abstract void DoProcessing();
 	}
 }
--- a/UIControl/ReplaceEquipmentUIControl.cs	Wed Nov 03 21:02:54 2010 +0000
+++ b/UIControl/ReplaceEquipmentUIControl.cs	Sat Nov 06 11:44:26 2010 +0000
@@ -33,8 +33,8 @@
 			string[] mutexGroups = origItem.MutexGroups;
 			UnitEquipmentItem[] mutexItems = unitType.GetEquipmentItemsByExclusionGroups(mutexGroups);
 			UnitEquipmentItem[] currentEquipment = unit.GetEquipment();
-			UnitEquipmentItem[] items = Arrays.Subtract(mutexItems, currentEquipment);
-			ui.SetUnitEquipmentItems(items);
+			UnitEquipmentItem[] allowedItems = Arrays.Subtract(mutexItems, currentEquipment);
+			ui.SetUnitEquipmentItems(allowedItems);
 			ui.UnitEquipmentItemChoiceChanged += HandleUiUnitEquipmentItemChoiceChanged;
 		}
 
--- a/gtk-gui/IBBoard.WarFoundry.GTK.Widgets.UnitDisplayWidget.cs	Wed Nov 03 21:02:54 2010 +0000
+++ b/gtk-gui/IBBoard.WarFoundry.GTK.Widgets.UnitDisplayWidget.cs	Sat Nov 06 11:44:26 2010 +0000
@@ -5,45 +5,26 @@
 	public partial class UnitDisplayWidget
 	{
 		private global::Gtk.VBox vbox1;
-
-		private global::Gtk.HBox hbox1;
-
-		private global::Gtk.Entry unitName;
-
-		private global::Gtk.SpinButton unitSize;
-
-		private global::Gtk.ScrolledWindow GtkScrolledWindow;
-
-		private global::Gtk.NodeView unitStats;
-
-		private global::Gtk.HSeparator hseparator1;
-
-		private global::Gtk.HBox hbox2;
-
-		private global::Gtk.Table table1;
-
-		private global::Gtk.Label equipmentLabel;
-
-		private global::Gtk.ScrolledWindow GtkScrolledWindow2;
-
-		private global::Gtk.NodeView equipmentList;
-
-		private global::Gtk.ScrolledWindow GtkScrolledWindow3;
-
-		private global::Gtk.TextView notesView;
-
-		private global::Gtk.Label lblNotes;
-
-		private global::Gtk.VBox vbox3;
-
-		private global::Gtk.Button bttnAddEquipment;
-
-		private global::Gtk.Button bttnEditEquipment;
-
-		private global::Gtk.Button bttnReplaceEquipment;
-
-		private global::Gtk.Button bttnRemoveEquipment;
-
+				private global::Gtk.HBox hbox1;
+				private global::Gtk.Entry unitName;
+				private global::Gtk.SpinButton unitSize;
+				private global::Gtk.ScrolledWindow GtkScrolledWindow;
+				private global::Gtk.NodeView unitStats;
+				private global::Gtk.HSeparator hseparator1;
+				private global::Gtk.HBox hbox2;
+				private global::Gtk.Table table1;
+				private global::Gtk.Label equipmentLabel;
+				private global::Gtk.ScrolledWindow GtkScrolledWindow2;
+				private global::Gtk.NodeView equipmentList;
+				private global::Gtk.ScrolledWindow GtkScrolledWindow3;
+				private global::Gtk.TextView notesView;
+				private global::Gtk.Label lblNotes;
+				private global::Gtk.VBox vbox3;
+				private global::Gtk.Button bttnAddEquipment;
+				private global::Gtk.Button bttnEditEquipment;
+				private global::Gtk.Button bttnReplaceEquipment;
+				private global::Gtk.Button bttnRemoveEquipment;
+		
 		protected virtual void Build()
 		{
 			global::Stetic.Gui.Initialize(this);
@@ -240,6 +221,7 @@
 			this.unitSize.KeyPressEvent += new global::Gtk.KeyPressEventHandler(this.OnUnitSizeKeyPress);
 			this.bttnAddEquipment.Clicked += new global::System.EventHandler(this.OnBttnAddEquipmentClicked);
 			this.bttnEditEquipment.Clicked += new global::System.EventHandler(this.HandleEditButtonClicked);
+			this.bttnReplaceEquipment.Clicked += new global::System.EventHandler(this.HandleReplaceButtonClicked);
 			this.bttnRemoveEquipment.Clicked += new global::System.EventHandler(this.HandleRemoveButtonActivated);
 		}
 	}
--- a/gtk-gui/IBBoard.WarFoundry.GUI.GTK.FrmAddEquipment.cs	Wed Nov 03 21:02:54 2010 +0000
+++ b/gtk-gui/IBBoard.WarFoundry.GUI.GTK.FrmAddEquipment.cs	Sat Nov 06 11:44:26 2010 +0000
@@ -120,6 +120,7 @@
 			this.rbEquipAll = new global::Gtk.RadioButton("");
 			this.rbEquipAll.CanFocus = true;
 			this.rbEquipAll.Name = "rbEquipAll";
+			this.rbEquipAll.Active = true;
 			this.rbEquipAll.DrawIndicator = true;
 			this.rbEquipAll.UseUnderline = true;
 			this.rbEquipAll.Group = new global::GLib.SList(global::System.IntPtr.Zero);
--- a/gtk-gui/IBBoard.WarFoundry.GUI.GTK.FrmEditEquipment.cs	Wed Nov 03 21:02:54 2010 +0000
+++ b/gtk-gui/IBBoard.WarFoundry.GUI.GTK.FrmEditEquipment.cs	Sat Nov 06 11:44:26 2010 +0000
@@ -5,31 +5,19 @@
 	public partial class FrmEditEquipment
 	{
 		private global::Gtk.Table table1;
-
-		private global::Gtk.HBox hbox2;
-
-		private global::Gtk.Table table2;
-
-		private global::Gtk.Label lblEquipAll;
-
-		private global::Gtk.Label lblPercent;
-
-		private global::Gtk.SpinButton numericAmount;
-
-		private global::Gtk.SpinButton percentageAmount;
-
-		private global::Gtk.RadioButton rbEquipAll;
-
-		private global::Gtk.RadioButton rbEquipNumeric;
-
-		private global::Gtk.RadioButton rbEquipPercent;
-
-		private global::Gtk.Label lblEquipAmount;
-
-		private global::Gtk.Button buttonCancel;
-
-		private global::Gtk.Button buttonOk;
-
+				private global::Gtk.HBox hbox2;
+				private global::Gtk.Table table2;
+				private global::Gtk.Label lblEquipAll;
+				private global::Gtk.Label lblPercent;
+				private global::Gtk.SpinButton numericAmount;
+				private global::Gtk.SpinButton percentageAmount;
+				private global::Gtk.RadioButton rbEquipAll;
+				private global::Gtk.RadioButton rbEquipNumeric;
+				private global::Gtk.RadioButton rbEquipPercent;
+				private global::Gtk.Label lblEquipAmount;
+				private global::Gtk.Button buttonCancel;
+				private global::Gtk.Button buttonOk;
+		
 		protected virtual void Build()
 		{
 			global::Stetic.Gui.Initialize(this);