Skip to content

Commit

Permalink
[slothsoft#68] fix new recipe configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
slothsoft committed Nov 19, 2022
1 parent d01af95 commit 6d4d2a8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
8 changes: 7 additions & 1 deletion Informant/Implementation/NewRecipeDisplayable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ namespace Slothsoft.Informant.Implementation;

internal class NewRecipeDisplayable : IDisplayable {

private static string DisplayableId => "new-recipe";
private static readonly Rectangle NewSourceRectangle = new(144, 440, 16, 7);

private readonly IModHelper _modHelper;
Expand Down Expand Up @@ -49,7 +50,7 @@ public NewRecipeDisplayable(IModHelper modHelper, string? uniqueId = null) {
);
}

public string Id => "new-recipe";
public string Id => DisplayableId;
public string DisplayName => _modHelper.Translation.Get("NewRecipeDisplayable");
public string Description => _modHelper.Translation.Get("NewRecipeDisplayable.Description");

Expand All @@ -64,6 +65,11 @@ private static void DrawOverlayIfNecessary(ClickableTextureComponent __instance,
// we are on the recipe page, but have no recipe? ignore!
return;
}

var config = InformantMod.Instance?.Config ?? new InformantConfig();
if (!config.DisplayIds.GetValueOrDefault(DisplayableId, true)) {
return; // this "decorator" is deactivated
}

// recipe.timesCrafted is not updated it seems
var timesCrafted = recipe.isCookingRecipe
Expand Down
7 changes: 4 additions & 3 deletions Informant/Implementation/SellPriceDisplayable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
namespace Slothsoft.Informant.Implementation;

internal class SellPriceDisplayable : IDisplayable {

private static string DisplayableId => "sell-price";
private static readonly Rectangle CoinSourceBounds = new(5, 69, 6, 6);

private record MoneyToDisplay(int One, int? Stack);
Expand Down Expand Up @@ -51,7 +53,7 @@ public SellPriceDisplayable(IModHelper modHelper, string? uniqueId = null) {
);
}

public string Id => "sell-price";
public string Id => DisplayableId;
public string DisplayName => _modHelper.Translation.Get("SellPriceDisplayable");
public string Description => _modHelper.Translation.Get("SellPriceDisplayable.Description");

Expand All @@ -61,9 +63,8 @@ public SellPriceDisplayable(IModHelper modHelper, string? uniqueId = null) {
private static void ManipulateMoneyValue(Item? hoveredItem, ref int moneyAmountToShowAtBottom, out MoneyToDisplay? __state) {
__state = null;


var config = InformantMod.Instance?.Config ?? new InformantConfig();
if (!config.DisplayIds.GetValueOrDefault("sell-price", true)) {
if (!config.DisplayIds.GetValueOrDefault(DisplayableId, true)) {
return; // this "decorator" is deactivated
}

Expand Down

0 comments on commit 6d4d2a8

Please sign in to comment.