changeset 188:bbf391b31b3e

Re #98: Default army size papercut Updated Winforms to use the default army size.
author snowblizz
date Sun, 12 Dec 2010 15:37:07 +0000
parents 3a561c3751f5
children cb86380cbf61
files FrmNewArmy.cs
diffstat 1 files changed, 30 insertions(+), 8 deletions(-) [+]
line diff
     1.1 --- a/FrmNewArmy.cs	Sun Nov 21 21:51:28 2010 +0000
     1.2 +++ b/FrmNewArmy.cs	Sun Dec 12 15:37:07 2010 +0000
     1.3 @@ -20,6 +20,7 @@
     1.4  	/// </summary>
     1.5  	public class FrmNewArmy : IBBForm
     1.6  	{
     1.7 +
     1.8  		private IContainer components;
     1.9  		private IBBoard.Windows.Forms.IBBButton bttnCancel;
    1.10  		private IBBoard.Windows.Forms.IBBLabel lblRaceList;
    1.11 @@ -35,6 +36,7 @@
    1.12  		private GameSystem system;
    1.13  		private Race race;
    1.14  		private string armyName;
    1.15 +        public bool isDefaultArmyName;
    1.16  		private ToolTip gameSystemToolTip;
    1.17  		private int maxPoints;
    1.18  
    1.19 @@ -213,7 +215,8 @@
    1.20              0,
    1.21              0,
    1.22              0});
    1.23 -			//
    1.24 +            this.armySize.ValueChanged += new System.EventHandler(this.armySize_ValueChanged);
    1.25 +            //
    1.26  			// gameSystems
    1.27  			//
    1.28  			this.gameSystems.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    1.29 @@ -307,14 +310,23 @@
    1.30  			maxPoints = (int) armySize.Value;
    1.31  		}
    1.32  
    1.33 -		private GameSystem GetSelectedGameSystem()
    1.34 +        private void armySize_ValueChanged(object sender, System.EventArgs e)
    1.35 +		{
    1.36 +            if (txtArmyName.Enabled && isDefaultArmyName)
    1.37 +            {
    1.38 +                setTxtArmyNameVal();
    1.39 +            }
    1.40 +		}
    1.41 +        
    1.42 +        private GameSystem GetSelectedGameSystem()
    1.43  		{
    1.44  			return (GameSystem) gameSystems.SelectedItem;
    1.45  		}
    1.46  
    1.47  		private void txtArmyName_TextChanged(object sender, System.EventArgs e)
    1.48  		{
    1.49 -			setSelectRaceEnabledVal();
    1.50 +			isDefaultArmyName = false ;
    1.51 +            setSelectRaceEnabledVal();
    1.52  		}
    1.53  
    1.54  		private void setSelectRaceEnabledVal()
    1.55 @@ -322,21 +334,31 @@
    1.56  			bttnSelectRace.Enabled = (lstRaces.SelectedIndex>-1 && txtArmyName.Text.Trim()!="" && armySize.Value > 0);
    1.57  		}
    1.58  
    1.59 -		private void lstRaces_SelectedIndexChanged(object sender, System.EventArgs e)
    1.60 +        private void setTxtArmyNameVal()
    1.61 +        {
    1.62 +            txtArmyName.Text = String.Format(race.ArmyDefaultName, Translation.GetTranslation("armySizePts", "{0}pt", armySize.Value));
    1.63 +            isDefaultArmyName = true;
    1.64 +        }
    1.65 +
    1.66 +        private void lstRaces_SelectedIndexChanged(object sender, System.EventArgs e)
    1.67  		{
    1.68  			setSelectRaceEnabledVal();
    1.69  			bool raceSelected = lstRaces.SelectedItem != null;
    1.70  			txtArmyName.Enabled = raceSelected;
    1.71  			armySize.Enabled = raceSelected;
    1.72  			race = (Race)lstRaces.SelectedItem;
    1.73 -			txtArmyName.Text = race.Name + " " + String.Format(race.ArmyDefaultName, Translation.GetTranslation("armySizePts", "{0}pt", armySize.Value));
    1.74 +            setTxtArmyNameVal();
    1.75  		}
    1.76  
    1.77  		private void gameSystems_SelectedValueChanged(object sender, EventArgs e)
    1.78  		{
    1.79 -			GameSystem selected = GetSelectedGameSystem();
    1.80 -			lstRaces.Items.Clear();
    1.81 -
    1.82 +			
    1.83 +            GameSystem selected = GetSelectedGameSystem();
    1.84 +			txtArmyName.Text = "";
    1.85 +            txtArmyName.Enabled = false;
    1.86 +            lstRaces.Items.Clear();
    1.87 +            armySize.Value = (decimal)selected.SystemArmyDefaultSize;
    1.88 + 
    1.89  			if (selected != null)
    1.90  			{
    1.91  				SetRaces(selected);