Mercurial > repos > IBDev-IBBoard.WarFoundry.GUI.GTK
changeset 70:4b82515586ac
Re #60: Add UI to add/remove/edit weapons in GTK
* Fix widget enabling/disabling (sometimes enabling ratio input for numeric limit)
* Correct behaviour of Edit dialog (setting wrong value on edit)
* Add setting of limits based on specific equipment item to base dialog controller
* Make sure that we catch all radio button click events from Edit dialog
* Add ability to ignore and listen to widgets to make sure that changes don't cascade
TODO: See if code can be tidied up and common classes created
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sat, 06 Nov 2010 17:03:13 +0000 |
parents | 3b4a646b4054 |
children | 91354245218a |
files | FrmAddEquipment.cs FrmEditEquipment.cs FrmReplaceEquipment.cs UIControl/AbstractBaseEquipmentUIControl.cs UIControl/AddEquipmentUIControl.cs UIControl/EditEquipmentUIControl.cs UIControl/Interfaces/IBaseEquipmentUI.cs UIControl/Interfaces/IEditEquipmentUI.cs UIControl/ReplaceEquipmentUIControl.cs gtk-gui/IBBoard.WarFoundry.GUI.GTK.FrmAddEquipment.cs gtk-gui/IBBoard.WarFoundry.GUI.GTK.FrmEditEquipment.cs gtk-gui/gui.stetic |
diffstat | 12 files changed, 225 insertions(+), 106 deletions(-) [+] |
line wrap: on
line diff
--- a/FrmAddEquipment.cs Sat Nov 06 11:44:26 2010 +0000 +++ b/FrmAddEquipment.cs Sat Nov 06 17:03:13 2010 +0000 @@ -1,6 +1,7 @@ // This file (FrmAddEquipment.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; @@ -9,6 +10,7 @@ using IBBoard.GtkSharp; using log4net.Repository.Hierarchy; using log4net; + namespace IBBoard.WarFoundry.GUI.GTK { public partial class FrmAddEquipment : Dialog, IAddEquipmentUI @@ -16,11 +18,11 @@ 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; + private bool isRatioLimited; public FrmAddEquipment() { @@ -52,7 +54,7 @@ protected void OnSelectionChanged(object o, EventArgs e) { - if (UnitEquipmentItemChoiceChanged!=null) + if (UnitEquipmentItemChoiceChanged != null) { UnitEquipmentItemChoiceChanged(SelectedUnitEquipmentItem); } @@ -73,7 +75,6 @@ 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); @@ -92,6 +93,8 @@ { rbEquipNumeric.Active = true; } + + isRatioLimited = isRatioLimit; } public void SetUnitEquipmentLimitsEnabled(bool isEnabled) @@ -120,12 +123,12 @@ Respond(ResponseType.Ok); } - public void SetOkayEnabledState (bool enabled) + public void SetOkayEnabledState(bool enabled) { buttonOk.Sensitive = enabled; } - protected virtual void SpinButtonValueChanged (object sender, System.EventArgs e) + protected virtual void SpinButtonValueChanged(object sender, System.EventArgs e) { OnUnitEquipmentAmountChanged(); } @@ -135,10 +138,11 @@ OnUnitEquipmentAmountTypeChanged(); } - public void SetNumericAmountEnabledState (bool enabled) + public void SetNumericAmountEnabledState(bool enabled) { - rbEquipNumeric.Sensitive = enabled; - numericAmount.Sensitive = enabled; + double minPercent = GetMinPercentage(); + rbEquipNumeric.Sensitive = enabled && !(isRatioLimited && minPercent == 100); + numericAmount.Sensitive = rbEquipNumeric.Sensitive; } public void SetPercentageAmountEnabledState(bool enabled) @@ -146,11 +150,11 @@ 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; + rbEquipPercent.Sensitive = isRatioLimited && minPercentage != 100; + percentageAmount.Sensitive = rbEquipPercent.Sensitive; + double maxPercentage = GetMaxPercentage(); + rbEquipAll.Sensitive = isRatioLimited && maxPercentage == 100; + lblEquipAll.Sensitive = rbEquipAll.Sensitive; } else { @@ -175,6 +179,26 @@ return min; } + public void ListenToWidgets() + { + rbEquipAll.Clicked += RadioButtonClicked; + rbEquipNumeric.Clicked += RadioButtonClicked; + rbEquipPercent.Clicked += RadioButtonClicked; + numericAmount.ValueChanged += SpinButtonValueChanged; + percentageAmount.ValueChanged += SpinButtonValueChanged; + lstEquipment.Selection.Changed += OnSelectionChanged; + } + + public void IgnoreWidgets() + { + rbEquipAll.Clicked -= RadioButtonClicked; + rbEquipNumeric.Clicked -= RadioButtonClicked; + rbEquipPercent.Clicked -= RadioButtonClicked; + numericAmount.ValueChanged -= SpinButtonValueChanged; + percentageAmount.ValueChanged -= SpinButtonValueChanged; + lstEquipment.Selection.Changed -= OnSelectionChanged; + } + public UnitEquipmentItem SelectedUnitEquipmentItem { get @@ -183,7 +207,6 @@ } } - public bool IsRatioEquipmentAmount { get @@ -192,7 +215,6 @@ } } - public int EquipmentNumericAmount { get @@ -206,7 +228,6 @@ } } - public double EquipmentPercentageAmount { get
--- a/FrmEditEquipment.cs Sat Nov 06 11:44:26 2010 +0000 +++ b/FrmEditEquipment.cs Sat Nov 06 17:03:13 2010 +0000 @@ -1,6 +1,7 @@ // 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; @@ -9,6 +10,7 @@ using IBBoard.GtkSharp; using log4net.Repository.Hierarchy; using log4net; + namespace IBBoard.WarFoundry.GUI.GTK { public partial class FrmEditEquipment : Dialog, IEditEquipmentUI @@ -16,12 +18,12 @@ 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; - + private bool isRatioLimited; + public FrmEditEquipment() { this.Build(); @@ -32,6 +34,24 @@ equipColumn.SetCellDataFunc(equipCell, GtkWarFoundryUtil.RenderWarFoundryObjectName); } + public void ListenToWidgets() + { + rbEquipAll.Clicked += RadioButtonClicked; + rbEquipNumeric.Clicked += RadioButtonClicked; + rbEquipPercent.Clicked += RadioButtonClicked; + numericAmount.ValueChanged += SpinButtonValueChanged; + percentageAmount.ValueChanged += SpinButtonValueChanged; + } + + public void IgnoreWidgets() + { + rbEquipAll.Clicked -= RadioButtonClicked; + rbEquipNumeric.Clicked -= RadioButtonClicked; + rbEquipPercent.Clicked -= RadioButtonClicked; + numericAmount.ValueChanged -= SpinButtonValueChanged; + percentageAmount.ValueChanged -= SpinButtonValueChanged; + } + private void OnUnitEquipmentAmountChanged() { if (UnitEquipmentAmountChanged != null) @@ -51,13 +71,17 @@ 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) + percentageAmount.SetRange(minPercent, maxPercent); + SetEquipmentAmountType(isRatioLimit); + isRatioLimited = isRatioLimit; + } + + public void SetEquipmentAmountType(bool isRatioAmount) + { + if (isRatioAmount) { - if (minPercent == 100) + if (percentageAmount.Value == 100) { rbEquipAll.Active = true; } @@ -98,12 +122,12 @@ Respond(ResponseType.Ok); } - public void SetOkayEnabledState (bool enabled) + public void SetOkayEnabledState(bool enabled) { buttonOk.Sensitive = enabled; } - protected virtual void SpinButtonValueChanged (object sender, System.EventArgs e) + protected virtual void SpinButtonValueChanged(object sender, System.EventArgs e) { OnUnitEquipmentAmountChanged(); } @@ -113,10 +137,11 @@ OnUnitEquipmentAmountTypeChanged(); } - public void SetNumericAmountEnabledState (bool enabled) + public void SetNumericAmountEnabledState(bool enabled) { - rbEquipNumeric.Sensitive = enabled; - numericAmount.Sensitive = enabled; + double minPercent = GetMinPercentage(); + rbEquipNumeric.Sensitive = enabled && !(isRatioLimited && minPercent == 100); + numericAmount.Sensitive = rbEquipNumeric.Sensitive; } public void SetPercentageAmountEnabledState(bool enabled) @@ -124,11 +149,11 @@ 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; + rbEquipPercent.Sensitive = isRatioLimited && minPercentage != 100; + percentageAmount.Sensitive = rbEquipPercent.Sensitive; + double maxPercentage = GetMaxPercentage(); + rbEquipAll.Sensitive = isRatioLimited && maxPercentage == 100; + lblEquipAll.Sensitive = rbEquipAll.Sensitive; } else { @@ -161,7 +186,6 @@ } } - public int EquipmentNumericAmount { get @@ -175,7 +199,6 @@ } } - public double EquipmentPercentageAmount { get
--- a/FrmReplaceEquipment.cs Sat Nov 06 11:44:26 2010 +0000 +++ b/FrmReplaceEquipment.cs Sat Nov 06 17:03:13 2010 +0000 @@ -22,8 +22,7 @@ public event MethodInvoker UnitEquipmentAmountTypeChanged; public event MethodInvoker UnitEquipmentAmountChanged; - private bool limitsEnabled = false; - private bool ratioLimited = false; + private bool isRatioLimited; public FrmReplaceEquipment() { @@ -37,6 +36,26 @@ lstEquipment.AppendColumn(equipColumn); } + public void ListenToWidgets() + { + rbEquipAll.Clicked += RadioButtonClicked; + rbEquipNumeric.Clicked += RadioButtonClicked; + rbEquipPercent.Clicked += RadioButtonClicked; + numericAmount.ValueChanged += SpinButtonValueChanged; + percentageAmount.ValueChanged += SpinButtonValueChanged; + lstEquipment.Selection.Changed += OnSelectionChanged; + } + + public void IgnoreWidgets() + { + rbEquipAll.Clicked -= RadioButtonClicked; + rbEquipNumeric.Clicked -= RadioButtonClicked; + rbEquipPercent.Clicked -= RadioButtonClicked; + numericAmount.ValueChanged -= SpinButtonValueChanged; + percentageAmount.ValueChanged -= SpinButtonValueChanged; + lstEquipment.Selection.Changed -= OnSelectionChanged; + } + private void OnUnitEquipmentAmountChanged() { if (UnitEquipmentAmountChanged != null) @@ -76,9 +95,9 @@ 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); + isRatioLimited = isRatioLimit; if (isRatioLimit) { @@ -140,8 +159,9 @@ public void SetNumericAmountEnabledState(bool enabled) { - rbEquipNumeric.Sensitive = enabled; - numericAmount.Sensitive = enabled; + double minPercent = GetMinPercentage(); + rbEquipNumeric.Sensitive = enabled && !(isRatioLimited && minPercent == 100); + numericAmount.Sensitive = rbEquipNumeric.Sensitive; } public void SetPercentageAmountEnabledState(bool enabled) @@ -149,11 +169,11 @@ 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; + rbEquipPercent.Sensitive = isRatioLimited && minPercentage != 100; + percentageAmount.Sensitive = rbEquipPercent.Sensitive; + double maxPercentage = GetMaxPercentage(); + rbEquipAll.Sensitive = isRatioLimited && maxPercentage == 100; + lblEquipAll.Sensitive = rbEquipAll.Sensitive; } else { @@ -186,7 +206,7 @@ } } - public bool IsRatioEquipmentAmount + public bool IsRatioEquipmentAmount { get { @@ -194,7 +214,7 @@ } } - public int EquipmentNumericAmount + public int EquipmentNumericAmount { get { @@ -207,7 +227,7 @@ } } - public double EquipmentPercentageAmount + public double EquipmentPercentageAmount { get {
--- a/UIControl/AbstractBaseEquipmentUIControl.cs Sat Nov 06 11:44:26 2010 +0000 +++ b/UIControl/AbstractBaseEquipmentUIControl.cs Sat Nov 06 17:03:13 2010 +0000 @@ -33,9 +33,10 @@ ui = CreateEquipmentUI(); ui.SetUnitEquipmentLimitsEnabled(false); ui.SetOkayEnabledState(false); - ui.UnitEquipmentAmountChanged += SetUnitEquipmentValues; - ui.UnitEquipmentAmountTypeChanged += SetUnitEquipmentValues; CompleteUISetup(); + ui.UnitEquipmentAmountChanged += HandleUnitEquipmentAmountChanged; + ui.UnitEquipmentAmountTypeChanged += HandleUnitEquipmentAmountChanged; + ui.ListenToWidgets(); } /// <summary> @@ -58,29 +59,83 @@ protected void HandleUnitEquipmentAmountChanged() { - SetUnitEquipmentValues(); + SetUnitEquipmentValuesFromUI(); } + protected void SetUnitEquipmentLimits(UnitEquipmentItem equip) + { + ui.IgnoreWidgets(); + + if (equip != null) + { + bool equipIsRatioLimit = UnitEquipmentUtil.IsEquipmentRatioLimited(unit, equip); + maxPercentage = GetMaxPercentageLimit(equip); + minPercentage = GetMinPercentageLimit(equip); + maxNumber = GetMaxNumericLimit(equip); + minNumber = GetMinNumericLimit(equip); + + ui.SetUnitEquipmentLimits(equipIsRatioLimit, minPercentage, maxPercentage, minNumber, maxNumber); + ui.SetUnitEquipmentLimitsEnabled(true); + ui.SetOkayEnabledState(HasNonZeroEquipmentAmount()); + SetEquipmentAmountControlEnabledStates(); + } + else + { + maxPercentage = minPercentage = 0; + maxNumber = minNumber = 0; + ui.SetUnitEquipmentLimits(false, minPercentage, maxPercentage, minNumber, maxNumber); + ui.SetUnitEquipmentLimitsEnabled(false); + ui.SetOkayEnabledState(false); + } + + ui.ListenToWidgets(); + } + + protected void SetUnitEquipmentValuesFromEquipment(UnitEquipmentItem equip) + { + isRatioAmount = UnitEquipmentUtil.GetEquipmentAmountIsRatio(unit, equip); + equipmentAmount = UnitEquipmentUtil.GetEquipmentAmount(unit, equip); + SetUnitEquipmentValues(); + SetEquipmentAmountControlEnabledStates(); + } + /// <summary> /// Sets the unit equipment values on the UI /// </summary> - protected void SetUnitEquipmentValues() - { - ui.SetOkayEnabledState(HasNonZeroEquipmentAmount()); + protected void SetUnitEquipmentValuesFromUI() + { isRatioAmount = ui.IsRatioEquipmentAmount; if (isRatioAmount) { equipmentAmount = ui.EquipmentPercentageAmount; - SetEquipmentAmountsFromPercentage(equipmentAmount); } else { int equipmentIntAmount = ui.EquipmentNumericAmount; equipmentAmount = equipmentIntAmount; + } + + SetUnitEquipmentValues(); + } + + private void SetUnitEquipmentValues() + { + ui.IgnoreWidgets(); + + if (isRatioAmount) + { + SetEquipmentAmountsFromPercentage(equipmentAmount); + } + else + { + int equipmentIntAmount = (int)equipmentAmount; SetEquipmentAmountsFromNumber(equipmentIntAmount); } + + ui.SetOkayEnabledState(equipmentAmount != 0); + ui.ListenToWidgets(); } private void SetEquipmentAmountsFromPercentage(double equipAmount)
--- a/UIControl/AddEquipmentUIControl.cs Sat Nov 06 11:44:26 2010 +0000 +++ b/UIControl/AddEquipmentUIControl.cs Sat Nov 06 17:03:13 2010 +0000 @@ -19,6 +19,7 @@ } //TODO Make abstract + protected override IAddEquipmentUI CreateEquipmentUI() { return new FrmAddEquipment(); @@ -34,28 +35,7 @@ private void HandleUiUnitEquipmentItemChoiceChanged(UnitEquipmentItem equip) { equipItem = equip; - - if (equip != null) - { - bool equipIsRatioLimit = UnitEquipmentUtil.IsEquipmentRatioLimited(unit, equip); - maxPercentage = GetMaxPercentageLimit(equip); - minPercentage = GetMinPercentageLimit(equip); - maxNumber = GetMaxNumericLimit(equip); - minNumber = GetMinNumericLimit(equip); - - ui.SetUnitEquipmentLimits(equipIsRatioLimit, minPercentage, maxPercentage, minNumber, maxNumber); - ui.SetUnitEquipmentLimitsEnabled(true); - ui.SetOkayEnabledState(HasNonZeroEquipmentAmount()); - SetEquipmentAmountControlEnabledStates(); - } - else - { - maxPercentage = minPercentage = 0; - maxNumber = minNumber = 0; - ui.SetUnitEquipmentLimits(false, minPercentage, maxPercentage, minNumber, maxNumber); - ui.SetUnitEquipmentLimitsEnabled(false); - ui.SetOkayEnabledState(false); - } + SetUnitEquipmentLimits(equip); } protected override void DoProcessing()
--- a/UIControl/EditEquipmentUIControl.cs Sat Nov 06 11:44:26 2010 +0000 +++ b/UIControl/EditEquipmentUIControl.cs Sat Nov 06 17:03:13 2010 +0000 @@ -1,6 +1,7 @@ // 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; @@ -10,6 +11,7 @@ using CustomMath = IBBoard.CustomMath; using IBBoard.Lang; using IBBoard.WarFoundry.GUI.GTK; + namespace IBBoard.WarFoundry.GUI.GTK.UIControl { public class EditEquipmentUIControl : AbstractBaseEquipmentUIControl<IEditEquipmentUI> @@ -20,6 +22,7 @@ } //TODO Make abstract + protected override IEditEquipmentUI CreateEquipmentUI() { return new FrmEditEquipment(); @@ -27,7 +30,9 @@ protected override void CompleteUISetup() { - SetUnitEquipmentValues(); + SetUnitEquipmentLimits(equipItem); + SetUnitEquipmentValuesFromEquipment(equipItem); + ui.SetEquipmentAmountType(UnitEquipmentUtil.GetEquipmentAmountIsRatio(unit, equipItem)); } protected override void DoProcessing()
--- a/UIControl/Interfaces/IBaseEquipmentUI.cs Sat Nov 06 11:44:26 2010 +0000 +++ b/UIControl/Interfaces/IBaseEquipmentUI.cs Sat Nov 06 17:03:13 2010 +0000 @@ -1,7 +1,9 @@ // This file (IBaseEquipmentUI.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; + namespace IBBoard.WarFoundry.GUI.GTK.UIControl.Interfaces { /// <summary> @@ -17,7 +19,20 @@ /// <summary> /// Occurs when the unit equipment amount changes /// </summary> + event MethodInvoker UnitEquipmentAmountChanged; + + /// <summary> + /// Causes the UI to listen to its widgets and fire events + /// </summary> + + void ListenToWidgets(); + + /// <summary> + /// Causes the UI to ignore the widgets so that changes do not fire events + /// </summary> + + void IgnoreWidgets(); /// <summary> /// Sets the limits for the currently selected equipment item @@ -37,6 +52,7 @@ /// <param name='maxNumber'> /// The maximum number as an absolute figure /// </param> + void SetUnitEquipmentLimits(bool isRatioLimit, double minPercent, double maxPercent, int minNumber, int maxNumber); /// <summary> @@ -47,6 +63,7 @@ /// <param name='isEnabled'> /// <code>True</code> if the UI components should accept input, else <code>false</code> /// </param> + void SetUnitEquipmentLimitsEnabled(bool isEnabled); /// <summary> @@ -55,6 +72,7 @@ /// <returns> /// <code>true</code> if the control was closed with "Okay", else <code>false</code> /// </returns> + bool ShowControl(); /// <summary> @@ -63,6 +81,7 @@ /// <value> /// <c>true</c> if the selected amount is a ratio type (percentage or "all"); otherwise, <c>false</c>. /// </value> + bool IsRatioEquipmentAmount { get; @@ -74,6 +93,7 @@ /// <value> /// The absolue number of items taken. /// </value> + int EquipmentNumericAmount { get; @@ -86,6 +106,7 @@ /// <value> /// The number of items taken as a percentage of the unit size. /// </value> + double EquipmentPercentageAmount { get; @@ -98,6 +119,7 @@ /// <param name='enabled'> /// <code>true</code> to enable the button, else <code>false</code> /// </param> + void SetOkayEnabledState(bool enabled); /// <summary> @@ -106,6 +128,7 @@ /// <param name='enabled'> /// <code>true</code> to enable the control, else <code>false</code> /// </param> + void SetNumericAmountEnabledState(bool enabled); /// <summary> @@ -114,6 +137,7 @@ /// <param name='enabled'> /// <code>true</code> to enable the control, else <code>false</code> /// </param> + void SetPercentageAmountEnabledState(bool enabled); } }
--- a/UIControl/Interfaces/IEditEquipmentUI.cs Sat Nov 06 11:44:26 2010 +0000 +++ b/UIControl/Interfaces/IEditEquipmentUI.cs Sat Nov 06 17:03:13 2010 +0000 @@ -1,8 +1,10 @@ // 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> @@ -10,7 +12,13 @@ /// </summary> public interface IEditEquipmentUI : IBaseEquipmentUI { - //Marker interface + /// <summary> + /// Sets the type of the equipment amount. + /// </summary> + /// <param name='isRatioLimit'> + /// <code>True</code> for ratio selection amounts, else <code>false</code> for numeric amounts + /// </param> + void SetEquipmentAmountType(bool isRatioLimit); } }
--- a/UIControl/ReplaceEquipmentUIControl.cs Sat Nov 06 11:44:26 2010 +0000 +++ b/UIControl/ReplaceEquipmentUIControl.cs Sat Nov 06 17:03:13 2010 +0000 @@ -41,28 +41,7 @@ private void HandleUiUnitEquipmentItemChoiceChanged(UnitEquipmentItem equip) { equipItem = equip; - - if (equip != null) - { - bool equipIsRatioLimit = UnitEquipmentUtil.IsEquipmentRatioLimited(unit, equip); - maxPercentage = GetMaxPercentageLimit(equip); - minPercentage = GetMinPercentageLimit(equip); - maxNumber = GetMaxNumericLimit(equip); - minNumber = GetMinNumericLimit(equip); - - ui.SetUnitEquipmentLimits(equipIsRatioLimit, minPercentage, maxPercentage, minNumber, maxNumber); - ui.SetUnitEquipmentLimitsEnabled(true); - ui.SetOkayEnabledState(HasNonZeroEquipmentAmount()); - SetEquipmentAmountControlEnabledStates(); - } - else - { - maxPercentage = minPercentage = 0; - maxNumber = minNumber = 0; - ui.SetUnitEquipmentLimits(false, minPercentage, maxPercentage, minNumber, maxNumber); - ui.SetUnitEquipmentLimitsEnabled(false); - ui.SetOkayEnabledState(false); - } + SetUnitEquipmentLimits(equip); } protected override void DoProcessing()
--- a/gtk-gui/IBBoard.WarFoundry.GUI.GTK.FrmAddEquipment.cs Sat Nov 06 11:44:26 2010 +0000 +++ b/gtk-gui/IBBoard.WarFoundry.GUI.GTK.FrmAddEquipment.cs Sat Nov 06 17:03:13 2010 +0000 @@ -120,7 +120,6 @@ 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 Sat Nov 06 11:44:26 2010 +0000 +++ b/gtk-gui/IBBoard.WarFoundry.GUI.GTK.FrmEditEquipment.cs Sat Nov 06 17:03:13 2010 +0000 @@ -196,7 +196,9 @@ this.DefaultWidth = 280; this.DefaultHeight = 175; this.Show(); + this.rbEquipPercent.Clicked += new global::System.EventHandler(this.RadioButtonClicked); this.rbEquipNumeric.Clicked += new global::System.EventHandler(this.RadioButtonClicked); + this.rbEquipAll.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);
--- a/gtk-gui/gui.stetic Sat Nov 06 11:44:26 2010 +0000 +++ b/gtk-gui/gui.stetic Sat Nov 06 17:03:13 2010 +0000 @@ -1448,10 +1448,12 @@ <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> <property name="Group">group1</property> + <signal name="Clicked" handler="RadioButtonClicked" /> </widget> <packing> <property name="TopAttach">2</property> @@ -1499,6 +1501,7 @@ <property name="HasLabel">True</property> <property name="UseUnderline">True</property> <property name="Group">group1</property> + <signal name="Clicked" handler="RadioButtonClicked" /> </widget> <packing> <property name="TopAttach">1</property>