Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions RecipeCatalogueUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ internal int Tile {

internal UIRecipeInfo recipeInfo;
internal UIRadioButton NearbyIngredientsRadioBitton;
internal UIRadioButton ResearchedIngredientsRadioButton;
internal UIRadioButton ItemChecklistRadioButton;
internal UIRadioButtonGroup RadioButtonGroup;
internal UIJourneyDuplicateButton duplicationButton;
Expand Down Expand Up @@ -137,14 +138,21 @@ internal UIElement CreateRecipeCataloguePanel() {
RadioButtonGroup.Width.Set(180, 0f);
UIRadioButton AllRecipesRadioButton = new UIRadioButton(RBText("AllRecipes"), "");
NearbyIngredientsRadioBitton = new UIRadioButton(RBText("NearbyChests"), RBText("ClickToRefresh"));
ResearchedIngredientsRadioButton = new UIRadioButton(RBText("ResearchedMaterials"), RBText("OnlyShowRecipesWithResearchedMaterials"));
ItemChecklistRadioButton = new UIRadioButton(RBText("ItemChecklistOnly"), "???");
RadioButtonGroup.Add(AllRecipesRadioButton);
RadioButtonGroup.Add(NearbyIngredientsRadioBitton);
RadioButtonGroup.Add(ResearchedIngredientsRadioButton);
RadioButtonGroup.Add(ItemChecklistRadioButton);
mainPanel.Append(RadioButtonGroup);
AllRecipesRadioButton.Selected = true;

NearbyIngredientsRadioBitton.OnSelectedChanged += NearbyIngredientsRadioBitton_OnSelectedChanged;
ResearchedIngredientsRadioButton.OnSelectedChanged += (s, e) => updateNeeded = true;
if (!Main.GameModeInfo.IsJourneyMode) {
ResearchedIngredientsRadioButton.SetDisabled();
ResearchedIngredientsRadioButton.SetHoverText(RBText("JourneyModeOnly", "Common"));
}

if (RecipeBrowser.itemChecklistInstance != null) {
ItemChecklistRadioButton.OnSelectedChanged += ItemChecklistFilter_SelectedChanged;
Expand Down Expand Up @@ -563,6 +571,12 @@ private bool PassRecipeFilters(UIRecipeSlot recipeSlot, Recipe recipe, List<int>
}
}

if (ResearchedIngredientsRadioButton.Selected) {
if (!PassResearchedIngredientsFilter(recipe)) {
return false;
}
}

// Item Checklist integration
if (ItemChecklistRadioButton.Selected) {
if (RecipeBrowserUI.instance.foundItems != null) {
Expand Down Expand Up @@ -696,6 +710,16 @@ private string GetTooltipsAsString(ItemTooltip toolTip) {
return sb.ToString().ToLower();
}

private bool PassResearchedIngredientsFilter(Recipe recipe) {
var sacrificeCatalog = Terraria.GameContent.Creative.CreativeItemSacrificesCatalog.Instance.SacrificeCountNeededByItemId;
foreach (Item item in recipe.requiredItem) {
if (sacrificeCatalog.ContainsKey(item.type) && !RecipePath.ItemFullyResearched(item.type)) {
return false;
}
}
return true;
}

// TODO, checkbox for check stack?
// TODO, # missing allowed slider?
private bool PassNearbyChestFilter(Recipe recipe) {
Expand Down