private void button_GenerateFixedAI_Clicked(object sender, RoutedEventArgs e) { if (listBox_AICarList.SelectedIndex == -1) { MessageBox.Show("Select a car first.", "No car selected", MessageBoxButton.OK, MessageBoxImage.Warning); return; } if (CurrentEvent.GetFreeCarSlotsLeft() <= 0) { MessageBox.Show($"Fixed entry count exceeds the amount of allowed 'Max Cars' specified ({_fixedEntries.Count} fixed entries + Player >= {CurrentEvent.RaceParameters.RacersMax}).", "No car selected", MessageBoxButton.OK, MessageBoxImage.Warning); return; } RaceEntry raceEntry = GenerateEntry(); _fixedEntries.Add(raceEntry); CurrentEvent.Entries.AI.Add(raceEntry); listBox_AIFixedEntries.Items.Add($"{raceEntry.DriverName} [{raceEntry.DriverRegion}]: {raceEntry.ActualCarName}"); button_EditFixedAI.IsEnabled = true; button_RemoveFixedAI.IsEnabled = true; UpdateEntryControls(); }
public void UpdateEntryControls() { int slotsLeft = CurrentEvent.GetFreeCarSlotsLeft(); sl_EntryCount.Maximum = slotsLeft; if (CurrentEvent.Entries.AIsToPickFromPool > slotsLeft) { CurrentEvent.Entries.AIsToPickFromPool = slotsLeft; } sl_EntryCount.Value = CurrentEvent.Entries.AIsToPickFromPool; sl_EntryPlayerPos.Maximum = CurrentEvent.RaceParameters.RacersMax; sl_EntryPlayerPos.Value = CurrentEvent.Entries.PlayerPos; label_EntryCount.Content = CurrentEvent.Entries.AIsToPickFromPool.ToString(); label_PlayerPos.Content = $"#{CurrentEvent.Entries.PlayerPos}"; }
public void PopulateEntries() { sl_EntryCount.Maximum = CurrentEvent.GetFreeCarSlotsLeft(); if (CurrentEvent.Entries.AIsToPickFromPool > CurrentEvent.RaceParameters.RacersMax - 1) { CurrentEvent.Entries.AIsToPickFromPool = CurrentEvent.RaceParameters.RacersMax - 1; } sl_EntryCount.Value = CurrentEvent.Entries.AIsToPickFromPool; sl_EntryPlayerPos.Maximum = CurrentEvent.RaceParameters.RacersMax; if (CurrentEvent.Entries.PlayerPos > CurrentEvent.RaceParameters.RacersMax) { CurrentEvent.Entries.PlayerPos = CurrentEvent.RaceParameters.RacersMax; } sl_EntryPlayerPos.Value = CurrentEvent.Entries.PlayerPos; label_EntryCount.Content = CurrentEvent.Entries.AIsToPickFromPool.ToString(); label_PlayerPos.Content = $"#{CurrentEvent.Entries.PlayerPos}"; if (!CurrentEvent.Entries.NeedsPopulating) { return; } PopulateComboBoxesIfNeeded(); _AIPoolEntries.Clear(); _fixedEntries.Clear(); listBox_AIEntries.Items.Clear(); listBox_AIFixedEntries.Items.Clear(); foreach (var entry in CurrentEvent.Entries.AIBases) { if (string.IsNullOrEmpty(entry.ActualCarName)) { entry.ActualCarName = GameDatabase.GetCarNameByLabel(entry.CarLabel); } listBox_AIEntries.Items.Add($"{entry.DriverName} [{entry.DriverRegion}]: {entry.ActualCarName}"); _AIPoolEntries.Add(entry); } foreach (var entry in CurrentEvent.Entries.AI) { if (string.IsNullOrEmpty(entry.ActualCarName)) { entry.ActualCarName = GameDatabase.GetCarNameByLabel(entry.CarLabel); } listBox_AIFixedEntries.Items.Add($"{entry.DriverName} [{entry.DriverRegion}]: {entry.ActualCarName}"); _fixedEntries.Add(entry); } if (_fixedEntries.Count != 0) { button_EditFixedAI.IsEnabled = true; button_RemoveFixedAI.IsEnabled = true; } if (_AIPoolEntries.Count != 0) { button_EditAI.IsEnabled = true; button_RemoveAI.IsEnabled = true; } if (CurrentEvent.Entries.Player != null) { CurrentEvent.Entries.Player.ActualCarName = GameDatabase.GetCarNameByLabel(CurrentEvent.Entries.Player.CarLabel); label_PlayerRentedCar.Content = $"Player has rented car: {CurrentEvent.Entries.Player.ActualCarName}"; button_SetCarAsPlayer.IsEnabled = false; button_EditPlayerEntry.IsEnabled = true; button_RemovePlayerEntry.IsEnabled = true; } else { label_PlayerRentedCar.Content = "No custom player entry set - Player will not use a rented Car"; button_SetCarAsPlayer.IsEnabled = true; button_EditPlayerEntry.IsEnabled = false; button_RemovePlayerEntry.IsEnabled = false; } UpdateEntryControls(); CurrentEvent.Entries.NeedsPopulating = false; }