changeset 15:3a347947ecea

Updates to Categories and Stat Lines Categories Adjusted some things behind the scenes. Stat Lines Added functionality of already existing buttons.
author Tsudico
date Wed, 22 Dec 2010 18:35:52 -0600
parents 26f7f6d2b4f8
children 489d36b167a6
files FrmSystem.Designer.cs FrmSystem.cs
diffstat 2 files changed, 104 insertions(+), 87 deletions(-) [+]
line diff
     1.1 --- a/FrmSystem.Designer.cs	Sat Dec 18 21:04:51 2010 -0600
     1.2 +++ b/FrmSystem.Designer.cs	Wed Dec 22 18:35:52 2010 -0600
     1.3 @@ -680,6 +680,7 @@
     1.4  			// 
     1.5  			// txtStatName
     1.6  			// 
     1.7 +			this.txtStatName.Enabled = false;
     1.8  			this.txtStatName.Location = new System.Drawing.Point(368, 120);
     1.9  			this.txtStatName.Name = "txtStatName";
    1.10  			this.txtStatName.Size = new System.Drawing.Size(126, 20);
    1.11 @@ -804,6 +805,7 @@
    1.12  			this.btnStatsAdd.TabIndex = 7;
    1.13  			this.btnStatsAdd.Text = "Add";
    1.14  			this.btnStatsAdd.UseVisualStyleBackColor = true;
    1.15 +			this.btnStatsAdd.Click += new System.EventHandler(this.btnStatsAdd_Click);
    1.16  			// 
    1.17  			// FrmSystem
    1.18  			// 
     2.1 --- a/FrmSystem.cs	Sat Dec 18 21:04:51 2010 -0600
     2.2 +++ b/FrmSystem.cs	Wed Dec 22 18:35:52 2010 -0600
     2.3 @@ -75,6 +75,37 @@
     2.4  			}
     2.5  		}
     2.6  		
     2.7 +		private bool UpdateSystemStats
     2.8 +		{
     2.9 +			get
    2.10 +			{
    2.11 +				if(currentStats == null)
    2.12 +				{
    2.13 +					return false;
    2.14 +				}
    2.15 +				if(currentStats.ID != this.txtStatLineID.Text)
    2.16 +				{
    2.17 +					return true;
    2.18 +				}
    2.19 +				if(currentStats.SlotCount != this.listCategories.Items.Count)
    2.20 +				{
    2.21 +					return true;
    2.22 +				}
    2.23 +				if(system.GetSystemStatsForID(currentStats.ID).SlotCount != currentStats.SlotCount)
    2.24 +				{
    2.25 +					return true;
    2.26 +				}
    2.27 +				for(int i = 0; i < currentStats.SlotCount; i++)
    2.28 +				{
    2.29 +					if(system.GetSystemStatsForID(currentStats.ID).StatSlots[i].Name == currentStats.StatSlots[i].Name)
    2.30 +					{
    2.31 +						return true;
    2.32 +					}
    2.33 +				}
    2.34 +				return false;
    2.35 +			}
    2.36 +		}
    2.37 +		
    2.38  		public FrmSystem(IBBoard.WarFoundry.API.Objects.GameSystem loadSystem)
    2.39  		{
    2.40  			InitializeComponent();
    2.41 @@ -140,6 +171,16 @@
    2.42  			currentCategory = null;
    2.43  		}
    2.44  		
    2.45 +		private void clearStatLine()
    2.46 +		{
    2.47 +			this.txtStatName.Clear();
    2.48 +			this.txtStatLineID.Clear();
    2.49 +			this.listStatNames.Items.Clear();
    2.50 +			this.lviewStatPreview.Columns.Clear();
    2.51 +			this.lviewStatPreview.Items.Clear();
    2.52 +			currentStats = null;
    2.53 +		}
    2.54 +		
    2.55  		private void updateCategoryList()
    2.56  		{
    2.57  			if (system.Categories.Length > 0)
    2.58 @@ -178,10 +219,10 @@
    2.59  		
    2.60  		private void updateStatLinePreview(IBBoard.WarFoundry.API.Objects.SystemStats stats)
    2.61  		{
    2.62 +			this.lviewStatPreview.Items.Clear();
    2.63 +			this.lviewStatPreview.Columns.Clear();
    2.64  			if(stats.SlotCount > 0)
    2.65  			{
    2.66 -				this.lviewStatPreview.Items.Clear();
    2.67 -				this.lviewStatPreview.Columns.Clear();
    2.68  				for(int i = 0; i < stats.SlotCount; i++)
    2.69  				{
    2.70  					System.Windows.Forms.ColumnHeader column = new ColumnHeader();
    2.71 @@ -193,13 +234,14 @@
    2.72  				this.lviewStatPreview.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
    2.73  				this.lviewStatPreview.Items.Add(" ");
    2.74  			}
    2.75 +			this.btnStatLineApply.Enabled = this.UpdateSystemStats;
    2.76  		}
    2.77  		
    2.78  		private void updateStatNames(IBBoard.WarFoundry.API.Objects.SystemStats stats)
    2.79  		{
    2.80 +			this.listStatNames.Items.Clear();
    2.81  			if (stats.SlotCount > 0)
    2.82  			{
    2.83 -				this.listStatNames.Items.Clear();
    2.84  				for (int i = 0; i < stats.SlotCount; i++)
    2.85  				{
    2.86  					this.listStatNames.Items.Add(stats.StatSlots[i].Name);
    2.87 @@ -222,7 +264,7 @@
    2.88  			currentCategory = null;
    2.89  			foreach (IBBoard.WarFoundry.API.Objects.Category cat in system.Categories)
    2.90  			{
    2.91 -				if (cat.Name == this.listCategories.SelectedItem)
    2.92 +				if (cat.Name == (string)this.listCategories.SelectedItem)
    2.93  				{
    2.94  					currentCategory = cat;
    2.95  					this.txtCategoryName.Text = currentCategory.Name;
    2.96 @@ -239,7 +281,7 @@
    2.97  						this.numPointMin.Enabled = false;
    2.98  					}
    2.99  					if (currentCategory.MaximumPoints > 0
   2.100 -						&& currentCategory.MaximumPoints < this.numPercentMax.Maximum)
   2.101 +						&& currentCategory.MaximumPoints < this.numPointMax.Maximum)
   2.102  					{
   2.103  						this.numPointMax.Value = currentCategory.MaximumPoints;
   2.104  						this.cbPointMax.Checked = true;
   2.105 @@ -327,7 +369,7 @@
   2.106  		{
   2.107  			foreach(IBBoard.WarFoundry.API.Objects.Category cat in system.Categories)
   2.108  			{
   2.109 -				if(cat.Name == this.listCategories.SelectedItem)
   2.110 +				if(cat.Name == (string)this.listCategories.SelectedItem)
   2.111  				{
   2.112  					system.RemoveCategory(cat.ID);
   2.113  					this.listCategories.ClearSelected();
   2.114 @@ -394,14 +436,8 @@
   2.115  
   2.116  		private void txtCategoryName_TextChanged(object sender, EventArgs e)
   2.117  		{
   2.118 -			if (this.UpdateCategory)
   2.119 -			{
   2.120 -				this.btnCategoryApply.Enabled = true;
   2.121 -			}
   2.122 -			else
   2.123 -			{
   2.124 -				this.btnCategoryApply.Enabled = false;
   2.125 -			}
   2.126 +			this.btnCategoryApply.Enabled = this.UpdateCategory;
   2.127 +			
   2.128  			if(this.txtCategoryName.Text != string.Empty && this.txtCategoryID.Text != string.Empty)
   2.129  			{
   2.130  				this.btnCategoryAdd.Enabled = true;
   2.131 @@ -414,14 +450,7 @@
   2.132  
   2.133  		private void txtCategoryID_TextChanged(object sender, EventArgs e)
   2.134  		{
   2.135 -			if (this.UpdateCategory)
   2.136 -			{
   2.137 -				this.btnCategoryApply.Enabled = true;
   2.138 -			}
   2.139 -			else
   2.140 -			{
   2.141 -				this.btnCategoryApply.Enabled = false;
   2.142 -			}
   2.143 +			this.btnCategoryApply.Enabled = this.UpdateCategory;
   2.144  		}
   2.145  
   2.146  		private void btnGenerateCatID_Click(object sender, EventArgs e)
   2.147 @@ -439,14 +468,7 @@
   2.148  			{
   2.149  				this.numPointMin.Enabled = false;
   2.150  			}
   2.151 -			if(this.UpdateCategory)
   2.152 -			{
   2.153 -				this.btnCategoryApply.Enabled = true;
   2.154 -			}
   2.155 -			else
   2.156 -			{
   2.157 -				this.btnCategoryApply.Enabled = false;
   2.158 -			}
   2.159 +			this.btnCategoryApply.Enabled = this.UpdateCategory;
   2.160  		}
   2.161  
   2.162  		private void cbPointMax_CheckedChanged(object sender, EventArgs e)
   2.163 @@ -459,14 +481,7 @@
   2.164  			{
   2.165  				this.numPointMax.Enabled = false;
   2.166  			}
   2.167 -			if (this.UpdateCategory)
   2.168 -			{
   2.169 -				this.btnCategoryApply.Enabled = true;
   2.170 -			}
   2.171 -			else
   2.172 -			{
   2.173 -				this.btnCategoryApply.Enabled = false;
   2.174 -			}
   2.175 +			this.btnCategoryApply.Enabled = this.UpdateCategory;
   2.176  		}
   2.177  
   2.178  		private void cbPercentMin_CheckedChanged(object sender, EventArgs e)
   2.179 @@ -479,14 +494,7 @@
   2.180  			{
   2.181  				this.numPercentMin.Enabled = false;
   2.182  			}
   2.183 -			if (this.UpdateCategory)
   2.184 -			{
   2.185 -				this.btnCategoryApply.Enabled = true;
   2.186 -			}
   2.187 -			else
   2.188 -			{
   2.189 -				this.btnCategoryApply.Enabled = false;
   2.190 -			}
   2.191 +			this.btnCategoryApply.Enabled = this.UpdateCategory;
   2.192  		}
   2.193  
   2.194  		private void cbPercentMax_CheckedChanged(object sender, EventArgs e)
   2.195 @@ -499,62 +507,27 @@
   2.196  			{
   2.197  				this.numPercentMax.Enabled = false;
   2.198  			}
   2.199 -			if (this.UpdateCategory)
   2.200 -			{
   2.201 -				this.btnCategoryApply.Enabled = true;
   2.202 -			}
   2.203 -			else
   2.204 -			{
   2.205 -				this.btnCategoryApply.Enabled = false;
   2.206 -			}
   2.207 +			this.btnCategoryApply.Enabled = this.UpdateCategory;
   2.208  		}
   2.209  
   2.210  		private void numPointMin_ValueChanged(object sender, EventArgs e)
   2.211  		{
   2.212 -			if (this.UpdateCategory)
   2.213 -			{
   2.214 -				this.btnCategoryApply.Enabled = true;
   2.215 -			}
   2.216 -			else
   2.217 -			{
   2.218 -				this.btnCategoryApply.Enabled = false;
   2.219 -			}
   2.220 +			this.btnCategoryApply.Enabled = this.UpdateCategory;
   2.221  		}
   2.222  
   2.223  		private void numPointMax_ValueChanged(object sender, EventArgs e)
   2.224  		{
   2.225 -			if (this.UpdateCategory)
   2.226 -			{
   2.227 -				this.btnCategoryApply.Enabled = true;
   2.228 -			}
   2.229 -			else
   2.230 -			{
   2.231 -				this.btnCategoryApply.Enabled = false;
   2.232 -			}
   2.233 +			this.btnCategoryApply.Enabled = this.UpdateCategory;
   2.234  		}
   2.235  
   2.236  		private void numPercentMin_ValueChanged(object sender, EventArgs e)
   2.237  		{
   2.238 -			if (this.UpdateCategory)
   2.239 -			{
   2.240 -				this.btnCategoryApply.Enabled = true;
   2.241 -			}
   2.242 -			else
   2.243 -			{
   2.244 -				this.btnCategoryApply.Enabled = false;
   2.245 -			}
   2.246 +			this.btnCategoryApply.Enabled = this.UpdateCategory;
   2.247  		}
   2.248  
   2.249  		private void numPercentMax_ValueChanged(object sender, EventArgs e)
   2.250  		{
   2.251 -			if (this.UpdateCategory)
   2.252 -			{
   2.253 -				this.btnCategoryApply.Enabled = true;
   2.254 -			}
   2.255 -			else
   2.256 -			{
   2.257 -				this.btnCategoryApply.Enabled = false;
   2.258 -			}
   2.259 +			this.btnCategoryApply.Enabled = this.UpdateCategory;
   2.260  		}
   2.261  
   2.262  		private void btnCategoryApply_Click(object sender, EventArgs e)
   2.263 @@ -612,7 +585,11 @@
   2.264  				{
   2.265  					if(stat.ID == item.Text)
   2.266  					{
   2.267 -						currentStats = stat;
   2.268 +						currentStats = new IBBoard.WarFoundry.API.Objects.SystemStats(stat.ID);
   2.269 +						foreach(IBBoard.WarFoundry.API.Objects.StatSlot slot in stat.StatSlots)
   2.270 +						{
   2.271 +							currentStats.AddStatSlot(slot.Name);
   2.272 +						}
   2.273  						if(currentStats.ID.Equals(system.StandardSystemStatsID))
   2.274  						{
   2.275  							this.btnStatsDefault.Enabled = false;
   2.276 @@ -622,11 +599,32 @@
   2.277  							this.btnStatsDefault.Enabled = true;
   2.278  						}
   2.279  						this.txtStatLineID.Text = currentStats.ID;
   2.280 +						this.txtStatName.Enabled = true;
   2.281  						updateStatNames(currentStats);
   2.282  						updateStatLinePreview(currentStats);
   2.283  					}
   2.284  				}
   2.285  			}
   2.286 +			if(this.txtStatLineID.Text == string.Empty)
   2.287 +			{
   2.288 +				this.txtStatName.Enabled = false;
   2.289 +			}
   2.290 +		}
   2.291 +
   2.292 +		private void btnStatsAdd_Click(object sender, EventArgs e)
   2.293 +		{
   2.294 +			if(this.txtStatLineID.Text == string.Empty)
   2.295 +			{
   2.296 +				MessageBox.Show("You must enter an ID!", "Create Stat Line Error");
   2.297 +				return;
   2.298 +			}
   2.299 +			if (currentStats == null)
   2.300 +			{
   2.301 +				currentStats = new IBBoard.WarFoundry.API.Objects.SystemStats(this.txtStatLineID.Text);
   2.302 +			}
   2.303 +			system.AddSystemStats(currentStats);
   2.304 +			clearStatLine();
   2.305 +			updateSystemStatsList();
   2.306  		}
   2.307  
   2.308  		private void btnStatsRemove_Click(object sender, EventArgs e)
   2.309 @@ -647,10 +645,13 @@
   2.310  			if(this.txtStatLineID.Text != string.Empty)
   2.311  			{
   2.312  				this.btnStatsAdd.Enabled = true;
   2.313 +				this.txtStatName.Enabled = true;
   2.314  			}
   2.315  			else
   2.316  			{
   2.317  				this.btnStatsAdd.Enabled = false;
   2.318 +				this.txtStatName.Enabled = false;
   2.319 +				this.btnStatListAdd.Enabled = false;
   2.320  			}
   2.321  		}
   2.322  
   2.323 @@ -668,10 +669,23 @@
   2.324  
   2.325  		private void btnStatListAdd_Click(object sender, EventArgs e)
   2.326  		{
   2.327 +			if(currentStats == null)
   2.328 +			{
   2.329 +				if(this.txtStatLineID.Text != string.Empty)
   2.330 +				{
   2.331 +					currentStats = new IBBoard.WarFoundry.API.Objects.SystemStats(this.txtStatLineID.Text);				
   2.332 +				}
   2.333 +				else
   2.334 +				{
   2.335 +					MessageBox.Show("You must first define an ID for the stat line.", "No ID Error");
   2.336 +					return;
   2.337 +				}
   2.338 +			}
   2.339  			if(this.txtStatName.Text != string.Empty)
   2.340  			{
   2.341  				currentStats.AddStatSlot(this.txtStatName.Text);
   2.342  			}
   2.343 +			this.txtStatName.Clear();
   2.344  			updateStatNames(currentStats);
   2.345  			updateStatLinePreview(currentStats);
   2.346  		}
   2.347 @@ -772,6 +786,7 @@
   2.348  		private void btnStatLineApply_Click(object sender, EventArgs e)
   2.349  		{
   2.350  			system.SetSystemStats(currentStats);
   2.351 +			clearStatLine();
   2.352  		}
   2.353  	}
   2.354  }