Add map filter and adjust help window accordingly

This commit is contained in:
MathiasL 2022-03-24 23:41:22 +01:00
parent 5ef79f6426
commit a41fac78be
3 changed files with 59 additions and 1 deletions

View file

@ -13,7 +13,7 @@
<StackPanel>
<StackPanel>
<TextBlock Text="Map selection" FontSize="24" Foreground="#FF0093E0" />
<TextBlock FontSize="16" Text="On the top you can select one of the maps that is available. Only the maps prefixed with 'de', 'cs', 'dz' and 'ar' are loaded. They are shown if they have a radar file and a corresponding text file, and could be successfully converted from DDS. You can also type when you open the combobox, to quickly find a map." Margin="0,5,0,0" TextWrapping="Wrap" />
<TextBlock FontSize="16" Text="On the top you can select one of the maps that is available. Only the maps prefixed with 'de', 'cs', 'dz' and 'ar' are loaded. You can alter which of these are shown via the 'Map Filter' menu (Maps might not correspond with what you expect, for example the map 'Safehouse' starts with 'de_' and is thus treated like a defusal map.) The maps are loaded, if they have a radar file and a corresponding text file, and could be successfully converted from DDS. You can also type when you open the combobox, to quickly find a map." Margin="0,5,0,0" TextWrapping="Wrap" />
</StackPanel>
<StackPanel Margin="0,10,0,0">
<TextBlock Text="Sidebar" FontSize="24" Foreground="#FF0093E0" />

View file

@ -29,6 +29,15 @@
<MenuItem Header="Flashbang" Uid="1" Click="changeTheme_Click" />
</MenuItem>
</MenuItem>
<MenuItem Header="Map Filter">
<MenuItem x:Name="mnuShowDefusalMaps" StaysOpenOnClick="True" IsCheckable="True" IsChecked="True" Header="Show defusal maps" Checked="filterMenu_CheckChanged" Unchecked="filterMenu_CheckChanged" />
<MenuItem x:Name="mnuShowHostageMaps" StaysOpenOnClick="True" IsCheckable="True" IsChecked="True" Header="Show hostage maps" Checked="filterMenu_CheckChanged" Unchecked="filterMenu_CheckChanged" />
<MenuItem x:Name="mnuShowArmsRaceMaps" StaysOpenOnClick="True" IsCheckable="True" IsChecked="True" Header="Show arms race maps" Checked="filterMenu_CheckChanged" Unchecked="filterMenu_CheckChanged" />
<MenuItem x:Name="mnuShowDangerZoneMaps" StaysOpenOnClick="True" IsCheckable="True" IsChecked="True" Header="Show danger zone maps" Checked="filterMenu_CheckChanged" Unchecked="filterMenu_CheckChanged" />
<MenuItem x:Name="mnuShowMapsMissingBsp" StaysOpenOnClick="True" IsCheckable="True" IsChecked="True" Header="Show maps with missing map file" Checked="filterMenu_CheckChanged" Unchecked="filterMenu_CheckChanged" />
<MenuItem x:Name="mnuShowMapsMissingNav" StaysOpenOnClick="True" IsCheckable="True" IsChecked="True" Header="Show maps with missing NAV file" Checked="filterMenu_CheckChanged" Unchecked="filterMenu_CheckChanged" />
<MenuItem x:Name="mnuShowMapsMissingAin" StaysOpenOnClick="True" IsCheckable="True" IsChecked="True" Header="Show maps with missing AIN file" Checked="filterMenu_CheckChanged" Unchecked="filterMenu_CheckChanged" />
</MenuItem>
<MenuItem Header="Help">
<MenuItem x:Name="mnuAbout" Header="About..." Uid="0" Click="mnuAbout_Click" />
<MenuItem x:Name="mnuHelp" Header="Help..." Uid="0" Click="mnuHelp_Click" />

View file

@ -59,6 +59,7 @@ namespace Damage_Calculator
private CsgoWeapon selectedWeapon;
private BackgroundWorker bgWorker = new BackgroundWorker();
private List<ComboBoxItem> allMaps;
private bool lineDrawn = false;
@ -100,6 +101,7 @@ namespace Damage_Calculator
maps.Add(item);
}
this.allMaps = maps;
this.comboBoxMaps.ItemsSource = maps.OrderBy(m => m.Content);
if (maps.Count > 0)
this.comboBoxMaps.SelectedIndex = 0;
@ -137,6 +139,49 @@ namespace Damage_Calculator
}
}
private void updateMapsWithCurrentFilter()
{
if (!this.IsInitialized)
return;
// Add maps
var newMaps = new List<ComboBoxItem>();
foreach (var mapItem in this.allMaps)
{
var newMap = new ComboBoxItem();
var map = (CsgoMap)mapItem.Tag;
string mapNameWithPrefix = System.IO.Path.GetFileNameWithoutExtension(map.MapImagePath).ToLower();
// Filter map type
if (mapNameWithPrefix.StartsWith("de") && mnuShowDefusalMaps.IsChecked == false)
continue;
if (mapNameWithPrefix.StartsWith("cs") && mnuShowHostageMaps.IsChecked == false)
continue;
if (mapNameWithPrefix.StartsWith("ar") && mnuShowArmsRaceMaps.IsChecked == false)
continue;
if (mapNameWithPrefix.StartsWith("dz") && mnuShowDangerZoneMaps.IsChecked == false)
continue;
// Filter file existence
if (map.BspFilePath == null && mnuShowMapsMissingBsp.IsChecked == false)
continue;
if (map.NavFilePath == null && mnuShowMapsMissingNav.IsChecked == false)
continue;
if (map.AinFilePath == null && mnuShowMapsMissingAin.IsChecked == false)
continue;
newMap.Tag = map;
newMap.Content = map.MapFileName;
newMaps.Add(newMap);
}
this.comboBoxMaps.ItemsSource = newMaps.OrderBy(m => m.Content);
if (newMaps.Count > 0)
this.comboBoxMaps.SelectedIndex = 0;
}
private void BgWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
this.gridLoading.Visibility = Visibility.Collapsed;
@ -1080,6 +1125,10 @@ namespace Damage_Calculator
// We want space for us alone, so give no child element a piece of dat cake
e.Handled = true;
}
private void filterMenu_CheckChanged(object sender, RoutedEventArgs e)
{
this.updateMapsWithCurrentFilter();
}
#endregion
}