Mercurial > repos > IBBoard.WarFoundry.GUI.GTK
diff UIControl/AbstractBaseEquipmentUIControl.cs @ 98:fac0636ae13b
Re #308: Make GTK# UI translatable
* Make undo/redo menus translate on language change
* Organise English language file
* Resolve warnings by adding in dialogs that use translated strings when equipment amounts are out of range
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sun, 02 Jan 2011 21:03:15 +0000 |
parents | 4b82515586ac |
children |
line wrap: on
line diff
--- a/UIControl/AbstractBaseEquipmentUIControl.cs Sun Jan 02 15:50:29 2011 +0000 +++ b/UIControl/AbstractBaseEquipmentUIControl.cs Sun Jan 02 21:03:15 2011 +0000 @@ -21,7 +21,7 @@ protected int minNumber, maxNumber; protected bool isRatioAmount; protected double equipmentAmount; - + public AbstractBaseEquipmentUIControl(Unit unit, CommandStack commandStack) { this.unit = unit; @@ -56,12 +56,12 @@ { //Do nothing } - + protected void HandleUnitEquipmentAmountChanged() { SetUnitEquipmentValuesFromUI(); } - + protected void SetUnitEquipmentLimits(UnitEquipmentItem equip) { ui.IgnoreWidgets(); @@ -90,7 +90,7 @@ ui.ListenToWidgets(); } - + protected void SetUnitEquipmentValuesFromEquipment(UnitEquipmentItem equip) { isRatioAmount = UnitEquipmentUtil.GetEquipmentAmountIsRatio(unit, equip); @@ -119,7 +119,7 @@ SetUnitEquipmentValues(); } - + private void SetUnitEquipmentValues() { ui.IgnoreWidgets(); @@ -144,7 +144,7 @@ { 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); + ShowMessage(percentageTooLarge, percentageTooLargeTitle); equipAmount = maxPercentage; } else @@ -153,7 +153,7 @@ { 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); + ShowMessage(percentageTooSmall, percentageTooSmallTitle); equipAmount = minPercentage; } @@ -168,13 +168,22 @@ return Math.Min(Math.Max(calcedAmount, minNumber), maxNumber); } + private void ShowMessage(string message, string title) + { + Gtk.MessageDialog dialog = new Gtk.MessageDialog(null, Gtk.DialogFlags.Modal, Gtk.MessageType.Warning, Gtk.ButtonsType.Ok, false, message); + dialog.Title = title; + dialog.Run(); + dialog.Hide(); + dialog.Dispose(); + } + 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); + ShowMessage(amountTooLarge, amountTooLargeTitle); equipAmount = maxNumber; } else @@ -183,7 +192,7 @@ { 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); + ShowMessage(amountTooSmall, amountTooSmallTitle); equipAmount = minNumber; } @@ -221,7 +230,7 @@ int maxNumber = UnitEquipmentUtil.GetMaxEquipmentCount(unit, equip); return Math.Max(0, maxNumber); } - + protected int GetMinNumericLimit(UnitEquipmentItem equip) { int minNumber = UnitEquipmentUtil.GetMinEquipmentCount(unit, equip); @@ -248,7 +257,7 @@ { return Math.Round(percent, 1); } - + public void Show() { SetupUI();