Skip to content

Commit

Permalink
Added recipe filter for learned status
Browse files Browse the repository at this point in the history
  • Loading branch information
josdemmers committed Mar 19, 2022
1 parent 636cf28 commit 6ae0f0a
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 3 deletions.
28 changes: 28 additions & 0 deletions NewWorldCompanion/ViewModels/Tabs/CraftingViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ public class CraftingViewModel : BindableBase
private BitmapSource? _imageWeaponsmithing = null;

private CraftingRecipe _selectedCraftingRecipe = new CraftingRecipe();
private bool _filterRecipeLearned = true;
private bool _filterRecipeUnlearned = true;
private bool _toggleArcana = true;
private bool _toggleArmoring = true;
private bool _toggleCooking = true;
Expand Down Expand Up @@ -132,6 +134,27 @@ public string ItemNameFilter
}
}
}

public bool FilterRecipeLearned
{
get => _filterRecipeLearned;
set
{
_filterRecipeLearned = value;
CraftingRecipesFiltered?.Refresh();
}
}

public bool FilterRecipeUnlearned
{
get => _filterRecipeUnlearned;
set
{
_filterRecipeUnlearned = value;
CraftingRecipesFiltered?.Refresh();
}
}

public bool ToggleArcana
{
get => _toggleArcana;
Expand Down Expand Up @@ -304,6 +327,11 @@ private bool FilterCraftingRecipes(object craftingRecipesObj)
allowed = string.IsNullOrWhiteSpace(ItemNameFilter) ? true : craftingRecipe.Localisation.ToLower().Contains(ItemNameFilter.ToLower());
}

if (allowed)
{
allowed = (FilterRecipeLearned ? craftingRecipe.Learned : false) || (FilterRecipeUnlearned ? !craftingRecipe.Learned : false);
}

return allowed;
}

Expand Down
2 changes: 1 addition & 1 deletion NewWorldCompanion/Views/Tabs/CooldownView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
<Ellipse Fill="{Binding Ready, Converter={StaticResource BooleanToLearnedColorConverter}}" Width="10" Height="10"/>
</BulletDecorator>
<Label Margin="0,0,0,0" Width="175" Content="{Binding Path=Name}" />
<Label>
<Label Width="150">
<TextBlock>
<TextBlock.Text>
<MultiBinding StringFormat="{}{0:0}.{1:00}:{2:00}:{3:00} / {4}">
Expand Down
8 changes: 8 additions & 0 deletions NewWorldCompanion/Views/Tabs/CraftingView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,14 @@
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
VerticalContentAlignment="Top"
SelectedItem="{Binding SelectedCraftingRecipe}">
<ListBox.ContextMenu>
<ContextMenu>
<MenuItem Header="Recipe Filter" IsEnabled="False"/>
<Separator />
<MenuItem Header="Learned" IsCheckable="True" IsChecked="{Binding FilterRecipeLearned}"/>
<MenuItem Header="Unlearned" IsCheckable="True" IsChecked="{Binding FilterRecipeUnlearned}"/>
</ContextMenu>
</ListBox.ContextMenu>
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Vertical" />
Expand Down
4 changes: 2 additions & 2 deletions NewWorldCompanion/common.props
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project>
<PropertyGroup>
<FileVersion>1.0.2.1</FileVersion>
<Version>1.0.2.1</Version>
<FileVersion>1.0.3.0</FileVersion>
<Version>1.0.3.0</Version>
<Copyright>Copyright © 2022</Copyright>
</PropertyGroup>
</Project>

0 comments on commit 6ae0f0a

Please sign in to comment.