comparison FrmNewUnit.cs @ 199:f9ef9b2db496

Re #343: Show unit requirement failures * Add missing translation for dialog * Add first pass of showing messages when adding units (needs reworking due to space limitations)
author IBBoard <dev@ibboard.co.uk>
date Sun, 01 May 2011 19:31:26 +0000
parents 137ec6d45280
children 8021cc097ec8
comparison
equal deleted inserted replaced
198:417d3f75a752 199:f9ef9b2db496
1 // This file (FrmNewUnit.cs) is a part of the IBBoard.WarFoundry.GUI.WinForms project and is copyright 2007, 2008, 2009 IBBoard. 1 // This file (FrmNewUnit.cs) is a part of the IBBoard.WarFoundry.GUI.WinForms project and is copyright 2007, 2008, 2009 IBBoard.
2 // 2 //
3 // 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. 3 // 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.
4 4
5 using System; 5 using System;
6 using System.Collections.Generic;
6 using System.Drawing; 7 using System.Drawing;
7 using System.ComponentModel; 8 using System.ComponentModel;
8 using System.Windows.Forms; 9 using System.Windows.Forms;
9 using IBBoard; 10 using IBBoard;
10 using IBBoard.Lang; 11 using IBBoard.Lang;
197 private void setSelectUnitEnabledVal() 198 private void setSelectUnitEnabledVal()
198 { 199 {
199 if (lstUnits.SelectedIndex>-1) 200 if (lstUnits.SelectedIndex>-1)
200 { 201 {
201 bttnSelectUnit.Enabled = true; 202 bttnSelectUnit.Enabled = true;
202 lblNewUnitWarning.Visible = !Validates.AsOkay(RequirementHandler.AllowsAdding(SelectedUnit, army)); 203 ICollection<string> failureMessages;
204 lblNewUnitWarning.Visible = !Validates.AsOkay(RequirementHandler.AllowsAdding(SelectedUnit, army, out failureMessages));
203 lblWarningIcon.Visible = lblNewUnitWarning.Visible; 205 lblWarningIcon.Visible = lblNewUnitWarning.Visible;
204 206
205 if (lblNewUnitWarning.Visible) 207 if (lblNewUnitWarning.Visible)
206 { 208 {
207 //lblNewUnitWarning.Text = army.GetFailedAddRequirement(units[lstUnits.SelectedIndex]).Description; 209 lblNewUnitWarning.Text = String.Join("\n", new List<string>(failureMessages).ToArray());
208 //FIXME: Add failed requirement text
209 } 210 }
210 } 211 }
211 else 212 else
212 { 213 {
213 bttnSelectUnit.Enabled = false; 214 bttnSelectUnit.Enabled = false;