private void buildingsList_SelectedIndexChanged(object sender, EventArgs e) { selectedBuilding = null; var acc = getSelectedAcc(); var vill = getSelectedVillage(); var indicies = buildingsList.SelectedIndices; if (indicies.Count > 0) { selectedBuilding = vill.Build.Buildings[indicies[0]]; } //buildlevelupdown if (selectedBuilding != null) { buildLevelUpDown.Value = selectedBuilding.Level + 1; } //construct new building buildTypeComboBox.Items.Clear(); if (selectedBuilding == null) { return; } if (selectedBuilding.Type == Classificator.BuildingEnum.Site) { buildTypeComboBox.Enabled = true; for (int i = 5; i <= 45; i++) { if (BuildingHelper.BuildingRequirementsAreMet((Classificator.BuildingEnum)i, vill, acc.AccInfo.Tribe ?? Classificator.TribeEnum.Natars)) { buildTypeComboBox.Items.Add(((Classificator.BuildingEnum)i).ToString()); } } if (buildTypeComboBox.Items.Count > 0) { buildTypeComboBox.SelectedIndex = 0; } } else { buildTypeComboBox.Enabled = false; } }
private void buildingsList_SelectedIndexChanged(object sender, EventArgs e) { selectedBuilding = null; var acc = GetSelectedAcc(); var vill = GetSelectedVillage(); var indicies = buildingsList.SelectedIndices; if (0 < indicies.Count) { selectedBuilding = vill.Build.Buildings[indicies[0]]; } else { return; } // Check if there is already a building planner for that id var planedBuilding = vill.Build.Tasks.LastOrDefault(x => x.BuildingId == selectedBuilding.Id); // Building level selector if (selectedBuilding.Type != BuildingEnum.Site) { buildLevelUpDown.Value = selectedBuilding.Level + 1; } else if (planedBuilding != null) { buildLevelUpDown.Value = planedBuilding.Level + 1; } else { buildLevelUpDown.Value = 1; } //construct new building buildTypeComboBox.Items.Clear(); buildTypeComboBox.Enabled = false; if (selectedBuilding.Type == BuildingEnum.Site) { if (planedBuilding != null) { buildTypeComboBox.Items.Add(planedBuilding.Building.ToString()); buildTypeComboBox.SelectedIndex = 0; return; } buildTypeComboBox.Enabled = true; for (int i = 5; i <= 45; i++) { if (BuildingHelper.BuildingRequirementsAreMet((BuildingEnum)i, vill, acc.AccInfo.Tribe ?? TribeEnum.Natars)) { buildTypeComboBox.Items.Add(((BuildingEnum)i).ToString()); } } } else // Building already there { buildTypeComboBox.Items.Add(selectedBuilding.Type.ToString()); } if (buildTypeComboBox.Items.Count > 0) { buildTypeComboBox.SelectedIndex = 0; } }