changeset 200:d084446348f5 default-army-size

RRe #97: Default army size issues
author snowblizz
date Wed, 01 Dec 2010 20:00:07 +0000
parents 00ffe6109ca5
children ec2b73de16ba
files FrmNewArmy.cs IBBoard.WarFoundry.GUI.WinForms.csproj
diffstat 2 files changed, 44 insertions(+), 13 deletions(-) [+]
line diff
     1.1 --- a/FrmNewArmy.cs	Tue Nov 02 20:28:00 2010 +0000
     1.2 +++ b/FrmNewArmy.cs	Wed Dec 01 20:00:07 2010 +0000
     1.3 @@ -19,7 +19,8 @@
     1.4  	/// Summary description for FrmNewArmy.
     1.5  	/// </summary>
     1.6  	public class FrmNewArmy : IBBForm
     1.7 -	{
     1.8 +    {
     1.9 +        private static int SYSTEM_DEFAULT_ARMY_SIZE = 1000; 
    1.10  		private IContainer components;
    1.11  		private IBBoard.Windows.Forms.IBBButton bttnCancel;
    1.12  		private IBBoard.Windows.Forms.IBBLabel lblRaceList;
    1.13 @@ -35,6 +36,7 @@
    1.14  		private GameSystem system;
    1.15  		private Race race;
    1.16  		private string armyName;
    1.17 +        public bool isDefaultArmyName;
    1.18  		private ToolTip gameSystemToolTip;
    1.19  		private int maxPoints;
    1.20  
    1.21 @@ -209,11 +211,12 @@
    1.22  			this.armySize.TabIndex = 11;
    1.23  			this.armySize.ThousandsSeparator = true;
    1.24  			this.armySize.Value = new decimal(new int[] {
    1.25 -            2000,
    1.26 +            SYSTEM_DEFAULT_ARMY_SIZE,
    1.27              0,
    1.28              0,
    1.29              0});
    1.30 -			//
    1.31 +            this.armySize.ValueChanged += new System.EventHandler(this.armySize_ValueChanged);
    1.32 +            //
    1.33  			// gameSystems
    1.34  			//
    1.35  			this.gameSystems.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    1.36 @@ -307,38 +310,65 @@
    1.37  			maxPoints = (int) armySize.Value;
    1.38  		}
    1.39  
    1.40 -		private GameSystem GetSelectedGameSystem()
    1.41 +        private void armySize_ValueChanged(object sender, System.EventArgs e)
    1.42 +		{
    1.43 +            if (txtArmyName.Enabled && isDefaultArmyName)
    1.44 +            {
    1.45 +                setTxtArmyNameVal();
    1.46 +            }
    1.47 +		}
    1.48 +        
    1.49 +        private GameSystem GetSelectedGameSystem()
    1.50  		{
    1.51  			return (GameSystem) gameSystems.SelectedItem;
    1.52  		}
    1.53  
    1.54  		private void txtArmyName_TextChanged(object sender, System.EventArgs e)
    1.55  		{
    1.56 -			setSelectRaceEnabledVal();
    1.57 +			isDefaultArmyName = false ;
    1.58 +            setSelectRaceEnabledVal();
    1.59  		}
    1.60  
    1.61  		private void setSelectRaceEnabledVal()
    1.62 -		{
    1.63 +        {
    1.64  			bttnSelectRace.Enabled = (lstRaces.SelectedIndex>-1 && txtArmyName.Text.Trim()!="" && armySize.Value > 0);
    1.65  		}
    1.66  
    1.67 -		private void lstRaces_SelectedIndexChanged(object sender, System.EventArgs e)
    1.68 +        private void setTxtArmyNameVal()
    1.69 +        {
    1.70 +            txtArmyName.Text = String.Format(race.ArmyDefaultName, Translation.GetTranslation("armySizePts", "{0}pt", armySize.Value));
    1.71 +            isDefaultArmyName = true;
    1.72 +        }
    1.73 +
    1.74 +        private void lstRaces_SelectedIndexChanged(object sender, System.EventArgs e)
    1.75  		{
    1.76  			setSelectRaceEnabledVal();
    1.77  			bool raceSelected = lstRaces.SelectedItem != null;
    1.78  			txtArmyName.Enabled = raceSelected;
    1.79  			armySize.Enabled = raceSelected;
    1.80  			race = (Race)lstRaces.SelectedItem;
    1.81 -			txtArmyName.Text = String.Format(race.ArmyDefaultName, Translation.GetTranslation("armySizePts", "{0}pt", armySize.Value));
    1.82 +            setTxtArmyNameVal();
    1.83  		}
    1.84  
    1.85  		private void gameSystems_SelectedValueChanged(object sender, EventArgs e)
    1.86  		{
    1.87 -			GameSystem selected = GetSelectedGameSystem();
    1.88 -			lstRaces.Items.Clear();
    1.89 +			
    1.90 +            GameSystem selected = GetSelectedGameSystem();
    1.91 +			txtArmyName.Text = "";
    1.92 +            txtArmyName.Enabled = false;
    1.93 +            lstRaces.Items.Clear();
    1.94 +            
    1.95 + 
    1.96 +			if (selected != null)
    1.97 +            {
    1.98  
    1.99 -			if (selected != null)
   1.100 -			{
   1.101 +                if (selected.SystemArmyDefaultSize != 1)
   1.102 +                {
   1.103 +                    System.Diagnostics.Debug.WriteLine("defaultSize:" + selected.SystemArmyDefaultSize);
   1.104 +                    System.Diagnostics.Debug.WriteLine("system:" + selected.ID);
   1.105 +                armySize.Value = (decimal) selected.SystemArmyDefaultSize;//}
   1.106 +                }
   1.107 +                
   1.108  				SetRaces(selected);
   1.109  
   1.110  				if (lstRaces.Items.Count == 1)
   1.111 @@ -348,6 +378,8 @@
   1.112  			}
   1.113  
   1.114  			lstRaces.Enabled = lstRaces.Items.Count > 0;
   1.115 +            
   1.116 +            
   1.117  		}
   1.118  	}
   1.119  }
     2.1 --- a/IBBoard.WarFoundry.GUI.WinForms.csproj	Tue Nov 02 20:28:00 2010 +0000
     2.2 +++ b/IBBoard.WarFoundry.GUI.WinForms.csproj	Wed Dec 01 20:00:07 2010 +0000
     2.3 @@ -115,7 +115,6 @@
     2.4      <Content Include="icons\document-new.png" />
     2.5      <Content Include="icons\document-open.png" />
     2.6      <Content Include="icons\document-save.png" />
     2.7 -    <None Include="app.config" />
     2.8      <None Include="icons\edit-redo.png" />
     2.9      <None Include="icons\edit-undo.png" />
    2.10      <Content Include="icons\list-add.png" />