changeset 64:e3fe48c4d794

Re #60: Add UI to add/remove/edit weapons in GTK * Add most of basic "edit" interface, based on "add" interface TODO: * Set initial values * Warn when setting to 0
author IBBoard <dev@ibboard.co.uk>
date Thu, 02 Sep 2010 20:12:21 +0000
parents c2d79b4209e3
children 77448375d2f9
files FrmEditEquipment.cs FrmMainWindow.cs IBBoard.WarFoundry.GUI.GTK.csproj UIControl/AddEquipmentUIControl.cs UIControl/EditEquipmentUIControl.cs UIControl/Interfaces/IEditEquipmentUI.cs Widgets/UnitDisplayWidget.cs gtk-gui/IBBoard.WarFoundry.GTK.Widgets.UnitDisplayWidget.cs gtk-gui/IBBoard.WarFoundry.GUI.GTK.FrmEditEquipment.cs gtk-gui/gui.stetic
diffstat 10 files changed, 1050 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/FrmEditEquipment.cs	Thu Sep 02 20:12:21 2010 +0000
@@ -0,0 +1,204 @@
+//  This file (FrmEditEquipment.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.WarFoundry.GUI.GTK.UIControl.Interfaces;
+using IBBoard.WarFoundry.API.Objects;
+using Gtk;
+using IBBoard.WarFoundry.GUI.GTK.Util;
+using IBBoard.GtkSharp;
+using log4net.Repository.Hierarchy;
+using log4net;
+namespace IBBoard.WarFoundry.GUI.GTK
+{
+	public partial class FrmEditEquipment : Dialog, IEditEquipmentUI
+	{
+		private static ILog log = LogManager.GetLogger(typeof(FrmAddEquipment));
+		
+		public event SingleArgMethodInvoker<UnitEquipmentItem> UnitEquipmentItemChoiceChanged;
+		public event MethodInvoker UnitEquipmentAmountTypeChanged;
+		public event MethodInvoker UnitEquipmentAmountChanged;
+		
+		private bool limitsEnabled = false;
+		private bool ratioLimited = false;
+		
+		public FrmEditEquipment()
+		{
+			this.Build();
+			TreeViewColumn equipColumn = new TreeViewColumn();
+			equipColumn.Title = "Equipment";
+			CellRendererText equipCell = new CellRendererText();
+			equipColumn.PackStart(equipCell, true);
+			equipColumn.SetCellDataFunc(equipCell, GtkWarFoundryUtil.RenderWarFoundryObjectName);	
+		}
+		
+		private void OnUnitEquipmentAmountChanged()
+		{
+			if (UnitEquipmentAmountChanged != null)
+			{
+				UnitEquipmentAmountChanged();
+			}
+		}
+		
+		private void OnUnitEquipmentAmountTypeChanged()
+		{
+			if (UnitEquipmentAmountChanged != null)
+			{
+				UnitEquipmentAmountTypeChanged();
+			}
+		}
+
+		public void SetUnitEquipmentLimits(bool isRatioLimit, double minPercent, double maxPercent, int minNumber, int maxNumber)
+		{
+			log.DebugFormat("IsRatio? {0}. Limits: {1}->{2}, {3}%->{4}%", isRatioLimit, minNumber, maxNumber, minPercent, maxPercent);
+			ratioLimited = isRatioLimit;
+			numericAmount.SetRange(minNumber, maxNumber);
+			percentageAmount.SetRange(minPercent, maxPercent);
+			
+			if (isRatioLimit)
+			{
+				if (minPercent == 100)
+				{
+					rbEquipAll.Active = true;
+				}
+				else
+				{
+					rbEquipPercent.Active = true;
+				}
+			}
+			else
+			{
+				rbEquipNumeric.Active = true;
+			}
+		}
+
+		public void SetUnitEquipmentLimitsEnabled(bool isEnabled)
+		{
+			SetNumericAmountEnabledState(isEnabled);
+			SetPercentageAmountEnabledState(isEnabled);
+		}
+
+		public bool ShowControl()
+		{
+			int result = Run();
+			bool okayClicked = (result == (int)ResponseType.Ok);
+			this.Hide();
+			return okayClicked;
+		}
+		
+		protected virtual void CancelButtonClicked(object sender, System.EventArgs e)
+		{
+			log.Debug("Cancel clicked");
+			Respond(ResponseType.Cancel);
+		}	
+		
+		protected virtual void OkayButtonClicked(object sender, System.EventArgs e)
+		{
+			log.Debug("Okay clicked");
+			Respond(ResponseType.Ok);
+		}		
+		
+		public void SetOkayEnabledState (bool enabled)
+		{
+			buttonOk.Sensitive = enabled;
+		}
+				
+		protected virtual void SpinButtonValueChanged (object sender, System.EventArgs e)
+		{
+			OnUnitEquipmentAmountChanged();
+		}		
+		
+		protected virtual void RadioButtonClicked(object sender, System.EventArgs e)
+		{
+			OnUnitEquipmentAmountTypeChanged();
+		}
+		
+		public void SetNumericAmountEnabledState (bool enabled)
+		{
+			rbEquipNumeric.Sensitive = enabled;
+			numericAmount.Sensitive = enabled;
+		}		
+		
+		public void SetPercentageAmountEnabledState(bool enabled)
+		{
+			if (enabled)
+			{
+				double minPercentage = GetMinPercentage();
+				rbEquipPercent.Sensitive = minPercentage != 100;
+				percentageAmount.Sensitive = minPercentage != 100;
+				double maxPercentage = GetMaxPercentage();
+				rbEquipAll.Sensitive = ratioLimited && maxPercentage == 100;
+				lblEquipAll.Sensitive = ratioLimited && maxPercentage == 100;
+			}
+			else
+			{
+				rbEquipPercent.Sensitive = false;
+				percentageAmount.Sensitive = false;
+				rbEquipAll.Sensitive = false;
+				lblEquipAll.Sensitive = false;
+			}
+		}
+
+		private double GetMaxPercentage()
+		{
+			double min, max;
+			percentageAmount.GetRange(out min, out max);
+			return max;
+		}
+
+		private double GetMinPercentage()
+		{
+			double min, max;
+			percentageAmount.GetRange(out min, out max);
+			return min;
+		}		
+		
+		public bool IsRatioEquipmentAmount
+		{
+			get
+			{
+				return !rbEquipNumeric.Active;
+			}
+		}
+		
+		
+		public int EquipmentNumericAmount
+		{
+			get
+			{
+				return (int)numericAmount.Value;
+			}
+			
+			set
+			{
+				numericAmount.Value = value;
+			}
+		}
+		
+		
+		public double EquipmentPercentageAmount
+		{
+			get
+			{
+				double percent;
+				
+				if (rbEquipAll.Active)
+				{
+					percent = 100;
+				}
+				else
+				{
+					percent = percentageAmount.Value;
+				}
+				
+				return percent;
+			}
+			
+			set
+			{
+				percentageAmount.Value = value;
+			}
+		}
+	}
+}
+
--- a/FrmMainWindow.cs	Mon Aug 30 19:44:35 2010 +0000
+++ b/FrmMainWindow.cs	Thu Sep 02 20:12:21 2010 +0000
@@ -94,6 +94,8 @@
 			LogManager.GetLogger(typeof(FrmMainWindow)).Fatal(msg, ex);
 			MessageDialog dialog = new MessageDialog(null, DialogFlags.Modal, MessageType.Error, ButtonsType.Ok, false, "An unhandled exception occurred. Please check the log for more details.");
 			dialog.Run();
+			dialog.Hide();
+			dialog.Dispose();
 		}
 		
 		private static string GetStackTrace(Exception ex)
--- a/IBBoard.WarFoundry.GUI.GTK.csproj	Mon Aug 30 19:44:35 2010 +0000
+++ b/IBBoard.WarFoundry.GUI.GTK.csproj	Thu Sep 02 20:12:21 2010 +0000
@@ -55,6 +55,10 @@
     <Compile Include="FrmAddEquipment.cs" />
     <Compile Include="gtk-gui\IBBoard.WarFoundry.GUI.GTK.FrmAddEquipment.cs" />
     <Compile Include="Util\GtkWarFoundryUtil.cs" />
+    <Compile Include="UIControl\EditEquipmentUIControl.cs" />
+    <Compile Include="UIControl\Interfaces\IEditEquipmentUI.cs" />
+    <Compile Include="gtk-gui\IBBoard.WarFoundry.GUI.GTK.FrmEditEquipment.cs" />
+    <Compile Include="FrmEditEquipment.cs" />
   </ItemGroup>
   <ItemGroup>
     <Content Include="App.png" />
--- a/UIControl/AddEquipmentUIControl.cs	Mon Aug 30 19:44:35 2010 +0000
+++ b/UIControl/AddEquipmentUIControl.cs	Thu Sep 02 20:12:21 2010 +0000
@@ -1,4 +1,4 @@
-//  This file (AddEquipmentUI.cs) is a part of the IBBoard.WarFoundry.GUI.GTK project and is copyright 2010 IBBoard
+//  This file (AddEquipmentUIControl.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;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/UIControl/EditEquipmentUIControl.cs	Thu Sep 02 20:12:21 2010 +0000
@@ -0,0 +1,205 @@
+//  This file (EditEquipmentUIControl.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.API.Util;
+using IBBoard.WarFoundry.GUI.GTK.UIControl.Interfaces;
+using IBBoard.WarFoundry.API.Commands;
+using CustomMath = IBBoard.CustomMath;
+using IBBoard.Lang;
+using IBBoard.WarFoundry.GUI.GTK;
+namespace IBBoard.WarFoundry.GUI.GTK.UIControl
+{
+	public class EditEquipmentUIControl
+	{
+		private CommandStack commandStack;
+		private IEditEquipmentUI ui;
+		private Unit unit;
+		private UnitEquipmentItem equipItem;
+		private double minPercentage, maxPercentage;
+		private int minNumber, maxNumber;
+		private bool isRatioAmount;
+		private double equipmentAmount;
+		
+		
+		public EditEquipmentUIControl(Unit unit, UnitEquipmentItem item, CommandStack commandStack)
+		{
+			this.unit = unit;
+			this.commandStack = commandStack;
+			this.equipItem = item;
+			SetupUI();
+		}
+		
+		private void SetupUI()
+		{
+			CreateEquipmentUI();
+			ui.SetOkayEnabledState(false);
+			isRatioAmount = UnitEquipmentUtil.IsEquipmentRatioLimited(unit, equipItem);
+			maxPercentage = GetMaxPercentageLimit(equipItem);
+			minPercentage = GetMinPercentageLimit(equipItem);
+			maxNumber = GetMaxNumericLimit(equipItem);
+			minNumber = GetMinNumericLimit(equipItem);
+			
+			ui.SetUnitEquipmentLimits(isRatioAmount, minPercentage, maxPercentage, minNumber, maxNumber);
+			ui.SetUnitEquipmentLimitsEnabled(true);
+			ui.SetOkayEnabledState(HasNonZeroEquipmentAmount());
+			SetEquipmentAmountControlEnabledStates();
+			
+			//TODO: Set initial values
+			
+			ui.UnitEquipmentAmountChanged += HandleUnitEquipmentAmountChanged;
+			ui.UnitEquipmentAmountTypeChanged += HandleUnitEquipmentAmountChanged;
+		}
+
+		private void HandleUnitEquipmentAmountChanged()
+		{
+			ui.SetOkayEnabledState(equipItem != null && HasNonZeroEquipmentAmount());
+			isRatioAmount = ui.IsRatioEquipmentAmount;
+			
+			if (isRatioAmount)
+			{
+				double equipmentAmount = ui.EquipmentPercentageAmount;
+				SetEquipmentAmountsFromPercentage(equipmentAmount);
+			}
+			else
+			{
+				int equipmentIntAmount = ui.EquipmentNumericAmount;
+				equipmentAmount = equipmentIntAmount;
+				SetEquipmentAmountsFromNumber(equipmentIntAmount);
+			}
+		}
+		
+		private void SetEquipmentAmountsFromPercentage(double equipAmount)
+		{			
+			if (equipAmount > maxPercentage)
+			{
+				string percentageTooLarge = Translation.GetTranslation("equipPercentageTooLarge", "the current percentage ({0}%) was larger than the maximum for the equipment item ({1}%) - the maximum value will be used instead", equipAmount, maxPercentage);
+				string percentageTooLargeTitle = Translation.GetTranslation("equipPercentageTooLargeTitle", "equipment percentage too large");
+				//				MessageBox.Show(ParentForm, percentageTooLarge, percentageTooLargeTitle);
+				equipAmount = maxPercentage;
+			}
+			else 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;
+			}
+			
+			ui.EquipmentNumericAmount = CalculateNumericValueFromPercentage(equipAmount);
+			ui.EquipmentPercentageAmount = equipAmount;
+		}
+		
+		private int CalculateNumericValueFromPercentage(double percent)
+		{
+			int calcedAmount = (int)CustomMath.IBBMath.Round((unit.Size * (percent / 100.0)), equipItem.RoundNumberUp);
+			return Math.Min(Math.Max(calcedAmount, minNumber), maxNumber);
+		}
+
+		private void SetEquipmentAmountsFromNumber(int equipAmount)
+		{			
+			if (equipAmount > maxNumber)
+			{
+				string amountTooLarge = Translation.GetTranslation("equipNumberTooLarge", "the current amount ({0}) was larger than the maximum for the equipment item ({1}) - the maximum value will be used instead", equipAmount, maxNumber);
+				string amountTooLargeTitle = Translation.GetTranslation("equipNumberTooLargeTitle", "equipment amount too large");
+				//MessageBox.Show(ParentForm, amountTooLarge, amountTooLargeTitle);
+				equipAmount = maxNumber;
+			}
+			else 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;
+			}
+			
+			ui.EquipmentPercentageAmount = CalcualtePercentageValueFromNumber(equipAmount);
+			ui.EquipmentNumericAmount = equipAmount;
+		}
+		
+		private double CalcualtePercentageValueFromNumber(int number)
+		{
+			double calcedAmount = RoundPercentage(CustomMath.IBBMath.Percentage(number, unit.Size));
+			return Math.Min(Math.Max(calcedAmount, minPercentage), maxPercentage);
+		}
+
+		//TODO Make abstract
+		protected void CreateEquipmentUI()
+		{
+			ui = new FrmEditEquipment();
+		}
+
+		private void SetEquipmentAmountControlEnabledStates()
+		{
+			ui.SetNumericAmountEnabledState(!isRatioAmount);
+			ui.SetPercentageAmountEnabledState(true);
+		}
+
+		private double GetMaxPercentageLimit(UnitEquipmentItem equip)
+		{
+			double maxPercent = RoundPercentage(UnitEquipmentUtil.GetMaxEquipmentPercentage(unit, equip));
+			return Math.Max(0, maxPercent);
+		}
+		
+		private double GetMinPercentageLimit(UnitEquipmentItem equip)
+		{
+			double minPercent = RoundPercentage(UnitEquipmentUtil.GetMinEquipmentPercentage(unit, equip));
+			return Math.Max(0, minPercent);
+		}
+		
+		private int GetMaxNumericLimit(UnitEquipmentItem equip)
+		{
+			int maxNumber = UnitEquipmentUtil.GetMaxEquipmentCount(unit, equip);
+			return Math.Max(0, maxNumber);
+		}
+		private int GetMinNumericLimit(UnitEquipmentItem equip)
+		{
+			int minNumber = UnitEquipmentUtil.GetMinEquipmentCount(unit, equip);
+			return Math.Max(0, minNumber);
+		}
+
+		private bool HasNonZeroEquipmentAmount()
+		{
+			bool nonZero;
+			
+			if (isRatioAmount)
+			{
+				nonZero = (ui.EquipmentPercentageAmount > 0);
+			}
+
+			else
+			{
+				nonZero = (ui.EquipmentNumericAmount > 0);
+			}
+			
+			return nonZero;
+		}
+
+		private double RoundPercentage(double percent)
+		{
+			return Math.Round(percent, 1);
+		}
+
+		public void Show()
+		{
+			bool okayed = ui.ShowControl();
+			
+			if (okayed)
+			{			
+				if (isRatioAmount)
+				{
+					commandStack.Execute(new SetUnitEquipmentRatioAmountCommand(unit, equipItem, equipmentAmount));
+				}
+				else
+				{
+					commandStack.Execute(new SetUnitEquipmentNumericAmountCommand(unit, equipItem, (int)equipmentAmount));
+				}
+			}
+			
+			ui.Dispose();
+		}
+	}
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/UIControl/Interfaces/IEditEquipmentUI.cs	Thu Sep 02 20:12:21 2010 +0000
@@ -0,0 +1,110 @@
+//  This file (IEditEquipmentUI.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.WarFoundry.API.Objects;
+namespace IBBoard.WarFoundry.GUI.GTK.UIControl.Interfaces
+{
+	/// <summary>
+	/// The interface that UI components should implement to represent "Edit Equipment" dialogs or system equivalents (e.g. console areas or HTML fragments)
+	/// </summary>
+	public interface IEditEquipmentUI : IDisposable
+	{		
+		/// <summary>
+		/// Occurs when the unit equipment amount type changes (e.g. percentage to numeric)
+		/// </summary>
+		event MethodInvoker UnitEquipmentAmountTypeChanged;
+		
+		/// <summary>
+		/// Occurs when the unit equipment amount changes
+		/// </summary>
+		event MethodInvoker UnitEquipmentAmountChanged;
+				
+		/// <summary>
+		/// Sets the limits for the currently selected equipment item
+		/// </summary>
+		/// <param name='isRatioLimit'>
+		/// <code>True</code> if the current limit is a ratio limit, else <code>false</code> for absolute limits
+		/// </param>
+		/// <param name='minPercent'>
+		/// The minimum limit as a percentage
+		/// </param>
+		/// <param name='maxPercent'>
+		/// The maximum limit as a percentage
+		/// </param>
+		/// <param name='minNumber'>
+		/// The minimum number as an absolute figure
+		/// </param>
+		/// <param name='maxNumber'>
+		/// The maximum number as an absolute figure
+		/// </param>
+		void SetUnitEquipmentLimits(bool isRatioLimit, double minPercent, double maxPercent, int minNumber, int maxNumber);
+		
+		/// <summary>
+		/// Sets whether the unit equipment limit UI components should be enabled and able to accept input. This will 
+		/// generally pass the values on to the <see cref="SetNumericAmountEnabledState(bool)"/> and
+		/// <see cref="SetPercentageAmountEnabledState(bool)"/> methods and is included for convenience
+		/// </summary>
+		/// <param name='isEnabled'>
+		/// <code>True</code> if the UI components should accept input, else <code>false</code>
+		/// </param>
+		void SetUnitEquipmentLimitsEnabled(bool isEnabled);
+		
+		/// <summary>
+		/// Shows the control and awaits a user action (close or okay)
+		/// </summary>
+		/// <returns>
+		/// <code>true</code> if the control was closed with "Okay", else <code>false</code>
+		/// </returns>
+		bool ShowControl();
+				
+		/// <summary>
+		/// Gets a value indicating whether the equipment amount is a ratio or an absolute number.
+		/// </summary>
+		/// <value>
+		/// <c>true</c> if the selected amount is a ratio type (percentage or "all"); otherwise, <c>false</c>.
+		/// </value>
+		bool IsRatioEquipmentAmount { get; }
+		
+		/// <summary>
+		/// Gets and sets the numeric amount for the current equipment amount. This number is meaningless if <see cref="IsRatioEquipmentAmount"/> is <code>true</code>
+		/// </summary>
+		/// <value>
+		/// The absolue number of items taken.
+		/// </value>
+		int EquipmentNumericAmount { get; set; }
+
+		/// <summary>
+		/// Gets and sets the percentage amount for the current equipment amount. This number is meaningless if <see cref="IsRatioEquipmentAmount"/> is <code>false</code>
+		/// </summary>
+		/// <value>
+		/// The number of items taken as a percentage of the unit size.
+		/// </value>
+		double EquipmentPercentageAmount { get; set; }
+	
+		/// <summary>
+		/// Sets the state of the Okay button.
+		/// </summary>
+		/// <param name='enabled'>
+		/// <code>true</code> to enable the button, else <code>false</code>
+		/// </param>
+		void SetOkayEnabledState(bool enabled);
+		
+		/// <summary>
+		/// Sets the state of the numeric equipment amount control.
+		/// </summary>
+		/// <param name='enabled'>
+		/// <code>true</code> to enable the control, else <code>false</code>
+		/// </param>
+		void SetNumericAmountEnabledState(bool enabled);
+		
+		/// <summary>
+		/// Sets the state of the percentage equipment amount control.
+		/// </summary>
+		/// <param name='enabled'>
+		/// <code>true</code> to enable the control, else <code>false</code>
+		/// </param>
+		void SetPercentageAmountEnabledState(bool enabled);
+	}
+}
+
--- a/Widgets/UnitDisplayWidget.cs	Mon Aug 30 19:44:35 2010 +0000
+++ b/Widgets/UnitDisplayWidget.cs	Thu Sep 02 20:12:21 2010 +0000
@@ -272,5 +272,19 @@
 				stack.Execute(cmd);
 			}
 		}		
+		
+		protected virtual void HandleEditButtonClicked(object sender, System.EventArgs e)
+		{
+			UnitEquipmentItem item = GetSelectedEquipmentItem();
+			log.Debug("Edit " + item);
+			
+			if (item != null)
+			{
+				EditEquipmentUIControl editEquipment = new EditEquipmentUIControl(unit, item, stack);
+				editEquipment.Show();
+			}
+		}
+		
+		
 	}
 }
--- a/gtk-gui/IBBoard.WarFoundry.GTK.Widgets.UnitDisplayWidget.cs	Mon Aug 30 19:44:35 2010 +0000
+++ b/gtk-gui/IBBoard.WarFoundry.GTK.Widgets.UnitDisplayWidget.cs	Thu Sep 02 20:12:21 2010 +0000
@@ -239,6 +239,7 @@
 			this.unitSize.FocusOutEvent += new global::Gtk.FocusOutEventHandler(this.OnUnitSizeFocusOut);
 			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.bttnRemoveEquipment.Clicked += new global::System.EventHandler(this.HandleRemoveButtonActivated);
 		}
 	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gtk-gui/IBBoard.WarFoundry.GUI.GTK.FrmEditEquipment.cs	Thu Sep 02 20:12:21 2010 +0000
@@ -0,0 +1,214 @@
+
+// This file has been generated by the GUI designer. Do not modify.
+namespace IBBoard.WarFoundry.GUI.GTK
+{
+	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;
+
+		protected virtual void Build()
+		{
+			global::Stetic.Gui.Initialize(this);
+			// Widget IBBoard.WarFoundry.GUI.GTK.FrmEditEquipment
+			this.Name = "IBBoard.WarFoundry.GUI.GTK.FrmEditEquipment";
+			this.WindowPosition = ((global::Gtk.WindowPosition)(4));
+			// Internal child IBBoard.WarFoundry.GUI.GTK.FrmEditEquipment.VBox
+			global::Gtk.VBox w1 = this.VBox;
+			w1.Name = "dialog1_VBox";
+			w1.BorderWidth = ((uint)(2));
+			// Container child dialog1_VBox.Gtk.Box+BoxChild
+			this.table1 = new global::Gtk.Table(((uint)(1)), ((uint)(2)), false);
+			this.table1.Name = "table1";
+			this.table1.RowSpacing = ((uint)(6));
+			this.table1.ColumnSpacing = ((uint)(6));
+			// Container child table1.Gtk.Table+TableChild
+			this.hbox2 = new global::Gtk.HBox();
+			this.hbox2.Name = "hbox2";
+			this.hbox2.Spacing = 6;
+			// Container child hbox2.Gtk.Box+BoxChild
+			this.table2 = new global::Gtk.Table(((uint)(3)), ((uint)(3)), false);
+			this.table2.Name = "table2";
+			this.table2.RowSpacing = ((uint)(6));
+			this.table2.ColumnSpacing = ((uint)(6));
+			// Container child table2.Gtk.Table+TableChild
+			this.lblEquipAll = new global::Gtk.Label();
+			this.lblEquipAll.Name = "lblEquipAll";
+			this.lblEquipAll.LabelProp = global::Mono.Unix.Catalog.GetString("equip all");
+			this.table2.Add(this.lblEquipAll);
+			global::Gtk.Table.TableChild w2 = ((global::Gtk.Table.TableChild)(this.table2[this.lblEquipAll]));
+			w2.TopAttach = ((uint)(2));
+			w2.BottomAttach = ((uint)(3));
+			w2.LeftAttach = ((uint)(1));
+			w2.RightAttach = ((uint)(2));
+			w2.YOptions = ((global::Gtk.AttachOptions)(4));
+			// Container child table2.Gtk.Table+TableChild
+			this.lblPercent = new global::Gtk.Label();
+			this.lblPercent.Name = "lblPercent";
+			this.lblPercent.LabelProp = global::Mono.Unix.Catalog.GetString("%");
+			this.table2.Add(this.lblPercent);
+			global::Gtk.Table.TableChild w3 = ((global::Gtk.Table.TableChild)(this.table2[this.lblPercent]));
+			w3.TopAttach = ((uint)(1));
+			w3.BottomAttach = ((uint)(2));
+			w3.LeftAttach = ((uint)(2));
+			w3.RightAttach = ((uint)(3));
+			w3.XOptions = ((global::Gtk.AttachOptions)(4));
+			w3.YOptions = ((global::Gtk.AttachOptions)(4));
+			// Container child table2.Gtk.Table+TableChild
+			this.numericAmount = new global::Gtk.SpinButton(0, 100, 1);
+			this.numericAmount.CanFocus = true;
+			this.numericAmount.Name = "numericAmount";
+			this.numericAmount.Adjustment.PageIncrement = 10;
+			this.numericAmount.ClimbRate = 1;
+			this.numericAmount.Numeric = true;
+			this.table2.Add(this.numericAmount);
+			global::Gtk.Table.TableChild w4 = ((global::Gtk.Table.TableChild)(this.table2[this.numericAmount]));
+			w4.LeftAttach = ((uint)(1));
+			w4.RightAttach = ((uint)(2));
+			w4.XOptions = ((global::Gtk.AttachOptions)(0));
+			w4.YOptions = ((global::Gtk.AttachOptions)(4));
+			// Container child table2.Gtk.Table+TableChild
+			this.percentageAmount = new global::Gtk.SpinButton(0, 100, 1);
+			this.percentageAmount.CanFocus = true;
+			this.percentageAmount.Name = "percentageAmount";
+			this.percentageAmount.Adjustment.PageIncrement = 10;
+			this.percentageAmount.ClimbRate = 1;
+			this.percentageAmount.Digits = ((uint)(1));
+			this.percentageAmount.Numeric = true;
+			this.table2.Add(this.percentageAmount);
+			global::Gtk.Table.TableChild w5 = ((global::Gtk.Table.TableChild)(this.table2[this.percentageAmount]));
+			w5.TopAttach = ((uint)(1));
+			w5.BottomAttach = ((uint)(2));
+			w5.LeftAttach = ((uint)(1));
+			w5.RightAttach = ((uint)(2));
+			w5.XOptions = ((global::Gtk.AttachOptions)(0));
+			w5.YOptions = ((global::Gtk.AttachOptions)(4));
+			// Container child table2.Gtk.Table+TableChild
+			this.rbEquipAll = new global::Gtk.RadioButton("");
+			this.rbEquipAll.CanFocus = true;
+			this.rbEquipAll.Name = "rbEquipAll";
+			this.rbEquipAll.DrawIndicator = true;
+			this.rbEquipAll.UseUnderline = true;
+			this.rbEquipAll.Group = new global::GLib.SList(global::System.IntPtr.Zero);
+			this.table2.Add(this.rbEquipAll);
+			global::Gtk.Table.TableChild w6 = ((global::Gtk.Table.TableChild)(this.table2[this.rbEquipAll]));
+			w6.TopAttach = ((uint)(2));
+			w6.BottomAttach = ((uint)(3));
+			w6.XOptions = ((global::Gtk.AttachOptions)(4));
+			w6.YOptions = ((global::Gtk.AttachOptions)(4));
+			// Container child table2.Gtk.Table+TableChild
+			this.rbEquipNumeric = new global::Gtk.RadioButton("");
+			this.rbEquipNumeric.CanFocus = true;
+			this.rbEquipNumeric.Name = "rbEquipNumeric";
+			this.rbEquipNumeric.DrawIndicator = true;
+			this.rbEquipNumeric.UseUnderline = true;
+			this.rbEquipNumeric.Group = this.rbEquipAll.Group;
+			this.table2.Add(this.rbEquipNumeric);
+			global::Gtk.Table.TableChild w7 = ((global::Gtk.Table.TableChild)(this.table2[this.rbEquipNumeric]));
+			w7.XOptions = ((global::Gtk.AttachOptions)(4));
+			w7.YOptions = ((global::Gtk.AttachOptions)(4));
+			// Container child table2.Gtk.Table+TableChild
+			this.rbEquipPercent = new global::Gtk.RadioButton("");
+			this.rbEquipPercent.CanFocus = true;
+			this.rbEquipPercent.Name = "rbEquipPercent";
+			this.rbEquipPercent.DrawIndicator = true;
+			this.rbEquipPercent.UseUnderline = true;
+			this.rbEquipPercent.Group = this.rbEquipAll.Group;
+			this.table2.Add(this.rbEquipPercent);
+			global::Gtk.Table.TableChild w8 = ((global::Gtk.Table.TableChild)(this.table2[this.rbEquipPercent]));
+			w8.TopAttach = ((uint)(1));
+			w8.BottomAttach = ((uint)(2));
+			w8.XOptions = ((global::Gtk.AttachOptions)(4));
+			w8.YOptions = ((global::Gtk.AttachOptions)(4));
+			this.hbox2.Add(this.table2);
+			global::Gtk.Box.BoxChild w9 = ((global::Gtk.Box.BoxChild)(this.hbox2[this.table2]));
+			w9.Position = 0;
+			w9.Expand = false;
+			w9.Fill = false;
+			this.table1.Add(this.hbox2);
+			global::Gtk.Table.TableChild w10 = ((global::Gtk.Table.TableChild)(this.table1[this.hbox2]));
+			w10.LeftAttach = ((uint)(1));
+			w10.RightAttach = ((uint)(2));
+			w10.YOptions = ((global::Gtk.AttachOptions)(4));
+			// Container child table1.Gtk.Table+TableChild
+			this.lblEquipAmount = new global::Gtk.Label();
+			this.lblEquipAmount.Name = "lblEquipAmount";
+			this.lblEquipAmount.LabelProp = global::Mono.Unix.Catalog.GetString("amount:");
+			this.table1.Add(this.lblEquipAmount);
+			global::Gtk.Table.TableChild w11 = ((global::Gtk.Table.TableChild)(this.table1[this.lblEquipAmount]));
+			w11.XOptions = ((global::Gtk.AttachOptions)(4));
+			w11.YOptions = ((global::Gtk.AttachOptions)(4));
+			w1.Add(this.table1);
+			global::Gtk.Box.BoxChild w12 = ((global::Gtk.Box.BoxChild)(w1[this.table1]));
+			w12.Position = 0;
+			w12.Expand = false;
+			w12.Fill = false;
+			// Internal child IBBoard.WarFoundry.GUI.GTK.FrmEditEquipment.ActionArea
+			global::Gtk.HButtonBox w13 = this.ActionArea;
+			w13.Name = "dialog1_ActionArea";
+			w13.Spacing = 10;
+			w13.BorderWidth = ((uint)(5));
+			w13.LayoutStyle = ((global::Gtk.ButtonBoxStyle)(4));
+			// Container child dialog1_ActionArea.Gtk.ButtonBox+ButtonBoxChild
+			this.buttonCancel = new global::Gtk.Button();
+			this.buttonCancel.CanDefault = true;
+			this.buttonCancel.CanFocus = true;
+			this.buttonCancel.Name = "buttonCancel";
+			this.buttonCancel.UseStock = true;
+			this.buttonCancel.UseUnderline = true;
+			this.buttonCancel.Label = "gtk-cancel";
+			this.AddActionWidget(this.buttonCancel, -6);
+			global::Gtk.ButtonBox.ButtonBoxChild w14 = ((global::Gtk.ButtonBox.ButtonBoxChild)(w13[this.buttonCancel]));
+			w14.Expand = false;
+			w14.Fill = false;
+			// Container child dialog1_ActionArea.Gtk.ButtonBox+ButtonBoxChild
+			this.buttonOk = new global::Gtk.Button();
+			this.buttonOk.CanDefault = true;
+			this.buttonOk.CanFocus = true;
+			this.buttonOk.Name = "buttonOk";
+			this.buttonOk.UseStock = true;
+			this.buttonOk.UseUnderline = true;
+			this.buttonOk.Label = "gtk-ok";
+			this.AddActionWidget(this.buttonOk, -5);
+			global::Gtk.ButtonBox.ButtonBoxChild w15 = ((global::Gtk.ButtonBox.ButtonBoxChild)(w13[this.buttonOk]));
+			w15.Position = 1;
+			w15.Expand = false;
+			w15.Fill = false;
+			if ((this.Child != null))
+			{
+				this.Child.ShowAll();
+			}
+			this.DefaultWidth = 280;
+			this.DefaultHeight = 175;
+			this.Show();
+			this.rbEquipNumeric.Clicked += new global::System.EventHandler(this.RadioButtonClicked);
+			this.percentageAmount.ValueChanged += new global::System.EventHandler(this.SpinButtonValueChanged);
+			this.numericAmount.ValueChanged += new global::System.EventHandler(this.SpinButtonValueChanged);
+			this.buttonCancel.Clicked += new global::System.EventHandler(this.CancelButtonClicked);
+			this.buttonOk.Clicked += new global::System.EventHandler(this.OkayButtonClicked);
+		}
+	}
+}
--- a/gtk-gui/gui.stetic	Mon Aug 30 19:44:35 2010 +0000
+++ b/gtk-gui/gui.stetic	Thu Sep 02 20:12:21 2010 +0000
@@ -899,6 +899,7 @@
                     <property name="Type">TextOnly</property>
                     <property name="Label" translatable="yes">Edit</property>
                     <property name="UseUnderline">True</property>
+                    <signal name="Clicked" handler="HandleEditButtonClicked" />
                   </widget>
                   <packing>
                     <property name="Position">1</property>
@@ -1123,7 +1124,6 @@
                         <property name="MemberName" />
                         <property name="CanFocus">True</property>
                         <property name="Label" translatable="yes" />
-                        <property name="Active">True</property>
                         <property name="DrawIndicator">True</property>
                         <property name="HasLabel">True</property>
                         <property name="UseUnderline">True</property>
@@ -1308,4 +1308,298 @@
       </widget>
     </child>
   </widget>
+  <widget class="Gtk.Dialog" id="IBBoard.WarFoundry.GUI.GTK.FrmEditEquipment" design-size="280 175">
+    <property name="MemberName" />
+    <property name="WindowPosition">CenterOnParent</property>
+    <property name="Buttons">2</property>
+    <property name="HelpButton">False</property>
+    <child internal-child="VBox">
+      <widget class="Gtk.VBox" id="dialog1_VBox">
+        <property name="MemberName" />
+        <property name="BorderWidth">2</property>
+        <child>
+          <widget class="Gtk.Table" id="table1">
+            <property name="MemberName" />
+            <property name="NColumns">2</property>
+            <property name="RowSpacing">6</property>
+            <property name="ColumnSpacing">6</property>
+            <child>
+              <widget class="Gtk.HBox" id="hbox2">
+                <property name="MemberName" />
+                <property name="Spacing">6</property>
+                <child>
+                  <widget class="Gtk.Table" id="table2">
+                    <property name="MemberName" />
+                    <property name="NRows">3</property>
+                    <property name="NColumns">3</property>
+                    <property name="RowSpacing">6</property>
+                    <property name="ColumnSpacing">6</property>
+                    <child>
+                      <placeholder />
+                    </child>
+                    <child>
+                      <placeholder />
+                    </child>
+                    <child>
+                      <widget class="Gtk.Label" id="lblEquipAll">
+                        <property name="MemberName" />
+                        <property name="LabelProp" translatable="yes">equip all</property>
+                      </widget>
+                      <packing>
+                        <property name="TopAttach">2</property>
+                        <property name="BottomAttach">3</property>
+                        <property name="LeftAttach">1</property>
+                        <property name="RightAttach">2</property>
+                        <property name="AutoSize">False</property>
+                        <property name="YOptions">Fill</property>
+                        <property name="XExpand">True</property>
+                        <property name="XFill">True</property>
+                        <property name="XShrink">False</property>
+                        <property name="YExpand">False</property>
+                        <property name="YFill">True</property>
+                        <property name="YShrink">False</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <widget class="Gtk.Label" id="lblPercent">
+                        <property name="MemberName" />
+                        <property name="LabelProp" translatable="yes">%</property>
+                      </widget>
+                      <packing>
+                        <property name="TopAttach">1</property>
+                        <property name="BottomAttach">2</property>
+                        <property name="LeftAttach">2</property>
+                        <property name="RightAttach">3</property>
+                        <property name="AutoSize">True</property>
+                        <property name="XOptions">Fill</property>
+                        <property name="YOptions">Fill</property>
+                        <property name="XExpand">False</property>
+                        <property name="XFill">True</property>
+                        <property name="XShrink">False</property>
+                        <property name="YExpand">False</property>
+                        <property name="YFill">True</property>
+                        <property name="YShrink">False</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <widget class="Gtk.SpinButton" id="numericAmount">
+                        <property name="MemberName" />
+                        <property name="CanFocus">True</property>
+                        <property name="Upper">100</property>
+                        <property name="PageIncrement">10</property>
+                        <property name="StepIncrement">1</property>
+                        <property name="ClimbRate">1</property>
+                        <property name="Numeric">True</property>
+                        <signal name="ValueChanged" handler="SpinButtonValueChanged" />
+                      </widget>
+                      <packing>
+                        <property name="LeftAttach">1</property>
+                        <property name="RightAttach">2</property>
+                        <property name="AutoSize">False</property>
+                        <property name="XOptions">0</property>
+                        <property name="YOptions">Fill</property>
+                        <property name="XExpand">False</property>
+                        <property name="XFill">False</property>
+                        <property name="XShrink">False</property>
+                        <property name="YExpand">False</property>
+                        <property name="YFill">True</property>
+                        <property name="YShrink">False</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <widget class="Gtk.SpinButton" id="percentageAmount">
+                        <property name="MemberName" />
+                        <property name="CanFocus">True</property>
+                        <property name="Upper">100</property>
+                        <property name="PageIncrement">10</property>
+                        <property name="StepIncrement">1</property>
+                        <property name="ClimbRate">1</property>
+                        <property name="Digits">1</property>
+                        <property name="Numeric">True</property>
+                        <signal name="ValueChanged" handler="SpinButtonValueChanged" />
+                      </widget>
+                      <packing>
+                        <property name="TopAttach">1</property>
+                        <property name="BottomAttach">2</property>
+                        <property name="LeftAttach">1</property>
+                        <property name="RightAttach">2</property>
+                        <property name="AutoSize">False</property>
+                        <property name="XOptions">0</property>
+                        <property name="YOptions">Fill</property>
+                        <property name="XExpand">False</property>
+                        <property name="XFill">False</property>
+                        <property name="XShrink">False</property>
+                        <property name="YExpand">False</property>
+                        <property name="YFill">True</property>
+                        <property name="YShrink">False</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <widget class="Gtk.RadioButton" id="rbEquipAll">
+                        <property name="MemberName" />
+                        <property name="CanFocus">True</property>
+                        <property name="Label" translatable="yes" />
+                        <property name="DrawIndicator">True</property>
+                        <property name="HasLabel">True</property>
+                        <property name="UseUnderline">True</property>
+                        <property name="Group">group1</property>
+                      </widget>
+                      <packing>
+                        <property name="TopAttach">2</property>
+                        <property name="BottomAttach">3</property>
+                        <property name="AutoSize">True</property>
+                        <property name="XOptions">Fill</property>
+                        <property name="YOptions">Fill</property>
+                        <property name="XExpand">False</property>
+                        <property name="XFill">True</property>
+                        <property name="XShrink">False</property>
+                        <property name="YExpand">False</property>
+                        <property name="YFill">True</property>
+                        <property name="YShrink">False</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <widget class="Gtk.RadioButton" id="rbEquipNumeric">
+                        <property name="MemberName" />
+                        <property name="CanFocus">True</property>
+                        <property name="Label" translatable="yes" />
+                        <property name="DrawIndicator">True</property>
+                        <property name="HasLabel">True</property>
+                        <property name="UseUnderline">True</property>
+                        <property name="Group">group1</property>
+                        <signal name="Clicked" handler="RadioButtonClicked" />
+                      </widget>
+                      <packing>
+                        <property name="AutoSize">False</property>
+                        <property name="XOptions">Fill</property>
+                        <property name="YOptions">Fill</property>
+                        <property name="XExpand">False</property>
+                        <property name="XFill">True</property>
+                        <property name="XShrink">False</property>
+                        <property name="YExpand">False</property>
+                        <property name="YFill">True</property>
+                        <property name="YShrink">False</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <widget class="Gtk.RadioButton" id="rbEquipPercent">
+                        <property name="MemberName" />
+                        <property name="CanFocus">True</property>
+                        <property name="Label" translatable="yes" />
+                        <property name="DrawIndicator">True</property>
+                        <property name="HasLabel">True</property>
+                        <property name="UseUnderline">True</property>
+                        <property name="Group">group1</property>
+                      </widget>
+                      <packing>
+                        <property name="TopAttach">1</property>
+                        <property name="BottomAttach">2</property>
+                        <property name="AutoSize">True</property>
+                        <property name="XOptions">Fill</property>
+                        <property name="YOptions">Fill</property>
+                        <property name="XExpand">False</property>
+                        <property name="XFill">True</property>
+                        <property name="XShrink">False</property>
+                        <property name="YExpand">False</property>
+                        <property name="YFill">True</property>
+                        <property name="YShrink">False</property>
+                      </packing>
+                    </child>
+                  </widget>
+                  <packing>
+                    <property name="Position">0</property>
+                    <property name="AutoSize">True</property>
+                    <property name="Expand">False</property>
+                    <property name="Fill">False</property>
+                  </packing>
+                </child>
+                <child>
+                  <placeholder />
+                </child>
+              </widget>
+              <packing>
+                <property name="LeftAttach">1</property>
+                <property name="RightAttach">2</property>
+                <property name="AutoSize">True</property>
+                <property name="YOptions">Fill</property>
+                <property name="XExpand">True</property>
+                <property name="XFill">True</property>
+                <property name="XShrink">False</property>
+                <property name="YExpand">False</property>
+                <property name="YFill">True</property>
+                <property name="YShrink">False</property>
+              </packing>
+            </child>
+            <child>
+              <widget class="Gtk.Label" id="lblEquipAmount">
+                <property name="MemberName" />
+                <property name="LabelProp" translatable="yes">amount:</property>
+              </widget>
+              <packing>
+                <property name="AutoSize">True</property>
+                <property name="XOptions">Fill</property>
+                <property name="YOptions">Fill</property>
+                <property name="XExpand">False</property>
+                <property name="XFill">True</property>
+                <property name="XShrink">False</property>
+                <property name="YExpand">False</property>
+                <property name="YFill">True</property>
+                <property name="YShrink">False</property>
+              </packing>
+            </child>
+          </widget>
+          <packing>
+            <property name="Position">0</property>
+            <property name="AutoSize">True</property>
+            <property name="Expand">False</property>
+            <property name="Fill">False</property>
+          </packing>
+        </child>
+      </widget>
+    </child>
+    <child internal-child="ActionArea">
+      <widget class="Gtk.HButtonBox" id="dialog1_ActionArea">
+        <property name="MemberName" />
+        <property name="Spacing">10</property>
+        <property name="BorderWidth">5</property>
+        <property name="Size">2</property>
+        <property name="LayoutStyle">End</property>
+        <child>
+          <widget class="Gtk.Button" id="buttonCancel">
+            <property name="MemberName" />
+            <property name="CanDefault">True</property>
+            <property name="CanFocus">True</property>
+            <property name="UseStock">True</property>
+            <property name="Type">StockItem</property>
+            <property name="StockId">gtk-cancel</property>
+            <property name="ResponseId">-6</property>
+            <signal name="Clicked" handler="CancelButtonClicked" />
+            <property name="label">gtk-cancel</property>
+          </widget>
+          <packing>
+            <property name="Expand">False</property>
+            <property name="Fill">False</property>
+          </packing>
+        </child>
+        <child>
+          <widget class="Gtk.Button" id="buttonOk">
+            <property name="MemberName" />
+            <property name="CanDefault">True</property>
+            <property name="CanFocus">True</property>
+            <property name="UseStock">True</property>
+            <property name="Type">StockItem</property>
+            <property name="StockId">gtk-ok</property>
+            <property name="ResponseId">-5</property>
+            <signal name="Clicked" handler="OkayButtonClicked" />
+            <property name="label">gtk-ok</property>
+          </widget>
+          <packing>
+            <property name="Position">1</property>
+            <property name="Expand">False</property>
+            <property name="Fill">False</property>
+          </packing>
+        </child>
+      </widget>
+    </child>
+  </widget>
 </stetic-interface>
\ No newline at end of file