Mercurial > repos > IBBoard.WarFoundry.GUI.GTK
comparison FrmNewUnit.cs @ 110:76b73f15d07e
Re #344: Show unit requirement failures
* First pass using new Requirement objects on FrmNewUnit - needs more testing and styling
* Remove old references from main window until we get a replacement
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Mon, 01 Aug 2011 20:22:48 +0000 |
parents | b4416ca69153 |
children | f23e5b40ca9d |
comparison
equal
deleted
inserted
replaced
109:4ae69806bb2d | 110:76b73f15d07e |
---|---|
5 using System; | 5 using System; |
6 using System.Collections.Generic; | 6 using System.Collections.Generic; |
7 using Gtk; | 7 using Gtk; |
8 using IBBoard.GtkSharp.Translatable; | 8 using IBBoard.GtkSharp.Translatable; |
9 using IBBoard.WarFoundry.API.Objects; | 9 using IBBoard.WarFoundry.API.Objects; |
10 using IBBoard.WarFoundry.API.Requirements; | |
11 using log4net; | 10 using log4net; |
12 using IBBoard.Lang; | 11 using IBBoard.Lang; |
12 using IBBoard.WarFoundry.API.Objects.Requirement; | |
13 using System.Text; | |
13 | 14 |
14 namespace IBBoard.WarFoundry.GUI.GTK | 15 namespace IBBoard.WarFoundry.GUI.GTK |
15 { | 16 { |
16 public partial class FrmNewUnit : TranslatableDialog | 17 public partial class FrmNewUnit : TranslatableDialog |
17 { | 18 { |
102 UnitType type = GetSelectedUnitType(); | 103 UnitType type = GetSelectedUnitType(); |
103 | 104 |
104 if (type != null) | 105 if (type != null) |
105 { | 106 { |
106 bttnCreate.Sensitive = true; | 107 bttnCreate.Sensitive = true; |
107 List<FailedUnitRequirement> fails = unitArmy.CanAddUnitType(type); | 108 ICollection<string> failureMessages; |
108 lblNewUnitWarning.Visible = (fails != null); | 109 Validation result = RequirementHandler.AllowsAdding(type, unitArmy, out failureMessages); |
110 bool validationFailed = !Validates.AsOkay(result); | |
111 lblNewUnitWarning.Visible = validationFailed; | |
109 | 112 |
110 if (fails.Count > 0) | 113 if (validationFailed) |
111 { | 114 { |
112 //FIXME: currently only show the first error | 115 StringBuilder sb = new StringBuilder(); |
113 lblNewUnitWarning.Text = fails[0].Description; | 116 |
117 foreach (string msg in failureMessages) | |
118 { | |
119 sb.AppendLine(msg); | |
120 } | |
121 | |
122 lblNewUnitWarning.Text = sb.ToString(); | |
114 } | 123 } |
115 } | 124 } |
116 else | 125 else |
117 { | 126 { |
118 bttnCreate.Sensitive = false; | 127 bttnCreate.Sensitive = false; |