Mercurial > repos > IBBoard.WarFoundry.GUI.GTK
diff UIControl/AbstractBaseEquipmentUIControl.cs @ 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 | 100626381159 |
children | 4b82515586ac |
line wrap: on
line diff
--- 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(); } }