Skip to content

Commit

Permalink
fix display for machines with DROP_IN output
Browse files Browse the repository at this point in the history
  • Loading branch information
Pathoschild committed May 15, 2024
1 parent e5fd6ea commit c4b9ee5
Show file tree
Hide file tree
Showing 17 changed files with 54 additions and 14 deletions.
11 changes: 9 additions & 2 deletions LookupAnything/DataParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ namespace Pathoschild.Stardew.LookupAnything
/// <summary>Parses the raw game data into usable models. These may be expensive operations and should be cached.</summary>
internal class DataParser
{
/*********
** Fields
*********/
/// <summary>The placeholder item ID for a recipe which can't be parsed due to its complexity.</summary>
public const string ComplexRecipeId = "__COMPLEX_RECIPE__";


/*********
** Public methods
*********/
Expand Down Expand Up @@ -479,11 +486,11 @@ from result in itemQueryResults
type: RecipeType.MachineInput,
displayType: ItemRegistry.GetDataOrErrorItem(machineId).DisplayName,
Array.Empty<RecipeIngredientModel>(),
item: _ => ItemRegistry.Create("__ERROR_ITEM__"),
item: _ => ItemRegistry.Create(DataParser.ComplexRecipeId),
isKnown: () => true,
machineId: machineId,
isForMachine: p => p is Item item && item.QualifiedItemId == machineId,
outputQualifiedItemId: "__ERROR_ITEM__"
outputQualifiedItemId: DataParser.ComplexRecipeId
)
);
}
Expand Down
42 changes: 30 additions & 12 deletions LookupAnything/Framework/Fields/ItemRecipesField.cs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ private IEnumerable<RecipeByTypeGroup> BuildRecipeGroups(Item ingredient, Recipe
: recipe.TryCreateItem(ingredient);
// handle error recipe
if (recipe.OutputQualifiedItemId == "__ERROR_ITEM__")
if (recipe.OutputQualifiedItemId == DataParser.ComplexRecipeId)
{
return new RecipeEntry(
name: recipe.Key,
Expand All @@ -203,17 +203,35 @@ private IEnumerable<RecipeByTypeGroup> BuildRecipeGroups(Item ingredient, Recipe
}
// get output model
RecipeItemEntry output = this.CreateItemEntry(
name: recipe.SpecialOutput?.DisplayText ?? outputItem?.DisplayName ?? string.Empty,
item: outputItem,
sprite: recipe.SpecialOutput?.Sprite,
minCount: recipe.MinOutput,
maxCount: recipe.MaxOutput,
chance: recipe.OutputChance,
quality: recipe.Quality,
hasInputAndOutput: true,
hasCondition: recipe.HasCondition
);
RecipeItemEntry output;
if (ItemRegistry.GetDataOrErrorItem(recipe.OutputQualifiedItemId)?.ItemId == "DROP_IN")
{
output = this.CreateItemEntry(
name: I18n.Item_RecipesForMachine_SameAsInput(),
item: null,
sprite: null,
minCount: recipe.MinOutput,
maxCount: recipe.MaxOutput,
chance: recipe.OutputChance,
quality: recipe.Quality,
hasInputAndOutput: true,
hasCondition: recipe.HasCondition
);
}
else
{
output = this.CreateItemEntry(
name: recipe.SpecialOutput?.DisplayText ?? outputItem?.DisplayName ?? string.Empty,
item: outputItem,
sprite: recipe.SpecialOutput?.Sprite,
minCount: recipe.MinOutput,
maxCount: recipe.MaxOutput,
chance: recipe.OutputChance,
quality: recipe.Quality,
hasInputAndOutput: true,
hasCondition: recipe.HasCondition
);
}
// get ingredient models
IEnumerable<RecipeItemEntry> inputs = recipe.Ingredients
Expand Down
1 change: 1 addition & 0 deletions LookupAnything/i18n/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@
"item.sells-to.shipping-box": "Versandkiste",
"item.recipes-for-ingredient.entry": "{{name}} (braucht {{count}})",
"item.recipes-for-machine.multiple-items": "{{name}} x{{count}}",
"item.recipes-for-machine.same-as-input": "[same as input]", // e.g. crystalarium produces same item that was put in // TODO
"item.recipes-for-machine.too-complex": "Some machine rules are too dynamic to display.", // TODO
"item.number-owned.summary": "Du besitzt {{count}} davon",
"item.number-crafted.summary": "Du hast bereits {{count}} davon hergestellt",
Expand Down
1 change: 1 addition & 0 deletions LookupAnything/i18n/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@
"item.sells-to.shipping-box": "shipping box",
"item.recipes-for-ingredient.entry": "{{name}} (needs {{count}})",
"item.recipes-for-machine.multiple-items": "{{name}} x{{count}}",
"item.recipes-for-machine.same-as-input": "[same as input]", // e.g. crystalarium produces same item that was put in
"item.recipes-for-machine.too-complex": "Some machine rules are too dynamic to display.",
"item.number-owned.summary": "you own {{count}} of these",
"item.number-crafted.summary": "you made {{count}} of these",
Expand Down
1 change: 1 addition & 0 deletions LookupAnything/i18n/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@
"item.sells-to.shipping-box": "Caja de envío",
"item.recipes-for-ingredient.entry": "{{name}} (necesita {{count}})",
"item.recipes-for-machine.multiple-items": "{{name}} x {{count}}",
"item.recipes-for-machine.same-as-input": "[same as input]", // e.g. crystalarium produces same item that was put in // TODO
"item.recipes-for-machine.too-complex": "Some machine rules are too dynamic to display.", // TODO
"item.number-owned.summary": "{{count}} ud(s)",
"item.number-crafted.summary": "creaste {{count}} de estos",
Expand Down
1 change: 1 addition & 0 deletions LookupAnything/i18n/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,7 @@
"item.sells-to.shipping-box": "bac d'expédition",
"item.recipes-for-ingredient.entry": "{{name}} (nécessite {{count}})",
"item.recipes-for-machine.multiple-items": "{{name}} x {{count}}",
"item.recipes-for-machine.same-as-input": "[same as input]", // e.g. crystalarium produces same item that was put in // TODO
"item.recipes-for-machine.too-complex": "Some machine rules are too dynamic to display.", // TODO
"item.number-owned.summary": "vous en possédez {{count}}",
"item.number-crafted.summary": "vous en avez fabriqué {{count}}",
Expand Down
1 change: 1 addition & 0 deletions LookupAnything/i18n/hu.json
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@
"item.sells-to.shipping-box": "szállítmányos láda",
"item.recipes-for-ingredient.entry": "{{name}} (szükséges: {{count}})",
"item.recipes-for-machine.multiple-items": "{{name}} x{{count}}",
"item.recipes-for-machine.same-as-input": "[same as input]", // e.g. crystalarium produces same item that was put in // TODO
"item.recipes-for-machine.too-complex": "Some machine rules are too dynamic to display.", // TODO
"item.number-owned.summary": "ennyit birtokolsz ebből: {{count}}",
"item.number-crafted.summary": "ennyit készítettél ebből: {{count}}",
Expand Down
1 change: 1 addition & 0 deletions LookupAnything/i18n/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@
"item.sells-to.shipping-box": "Cassetta delle spedizioni",
"item.recipes-for-ingredient.entry": "{{name}} ({{count}} necessari)",
"item.recipes-for-machine.multiple-items": "{{name}} x{{count}}",
"item.recipes-for-machine.same-as-input": "[same as input]", // e.g. crystalarium produces same item that was put in // TODO
"item.recipes-for-machine.too-complex": "Some machine rules are too dynamic to display.", // TODO
"item.number-owned.summary": "Quantità posseduta: {{count}}",
"item.number-crafted.summary": "Quantità fabbricata: {{count}}",
Expand Down
1 change: 1 addition & 0 deletions LookupAnything/i18n/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@
"item.sells-to.shipping-box": "出荷箱",
"item.recipes-for-ingredient.entry": "{{name}} ({{count}}個必要)",
"item.recipes-for-machine.multiple-items": "{{name}}が{{count}}個",
"item.recipes-for-machine.same-as-input": "[same as input]", // e.g. crystalarium produces same item that was put in // TODO
"item.recipes-for-machine.too-complex": "Some machine rules are too dynamic to display.", // TODO
"item.number-owned.summary": "{{count}}個持っている",
"item.number-crafted.summary": "{{count}}個作成した",
Expand Down
1 change: 1 addition & 0 deletions LookupAnything/i18n/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,7 @@
"item.sells-to.shipping-box": "출하 상자",
"item.recipes-for-ingredient.entry": "{{name}} ({{count}}개 필요)",
"item.recipes-for-machine.multiple-items": "{{name}} x{{count}}",
"item.recipes-for-machine.same-as-input": "[same as input]", // e.g. crystalarium produces same item that was put in // TODO
"item.recipes-for-machine.too-complex": "Some machine rules are too dynamic to display.", // TODO
"item.number-owned.summary": "당신은 이것들을 {{count}}개 보유중.",
"item.number-crafted.summary": "당신은 이것들을 {{count}}개 제작했음.",
Expand Down
1 change: 1 addition & 0 deletions LookupAnything/i18n/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@
"item.sells-to.shipping-box": "skrzynka sprzedaży",
"item.recipes-for-ingredient.entry": "{{name}} (potrzeba {{count}})",
"item.recipes-for-machine.multiple-items": "{{name}} x{{count}}",
"item.recipes-for-machine.same-as-input": "[same as input]", // e.g. crystalarium produces same item that was put in // TODO
"item.recipes-for-machine.too-complex": "Some machine rules are too dynamic to display.", // TODO
"item.number-owned.summary": "masz takich {{count}}",
"item.number-crafted.summary": "zrobiono takich {{count}}",
Expand Down
1 change: 1 addition & 0 deletions LookupAnything/i18n/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@
"item.sells-to.shipping-box": "Caixa de envio",
"item.recipes-for-ingredient.entry": "{{name}} (precisa de {{count}})",
"item.recipes-for-machine.multiple-items": "{{name}} x {{count}}",
"item.recipes-for-machine.same-as-input": "[same as input]", // e.g. crystalarium produces same item that was put in // TODO
"item.recipes-for-machine.too-complex": "Some machine rules are too dynamic to display.", // TODO
"item.number-owned.summary": "Possui {{count}} desses",
"item.number-crafted.summary": "Criou {{count}} desses",
Expand Down
1 change: 1 addition & 0 deletions LookupAnything/i18n/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@
"item.sells-to.shipping-box": "Отгрузочный ящик",
"item.recipes-for-ingredient.entry": "{{name}} ({{count}} шт.)",
"item.recipes-for-machine.multiple-items": "{{name}} x{{count}}",
"item.recipes-for-machine.same-as-input": "[same as input]", // e.g. crystalarium produces same item that was put in // TODO
"item.recipes-for-machine.too-complex": "Some machine rules are too dynamic to display.", // TODO
"item.number-owned.summary": "У вас есть {{count}} шт.",
"item.number-crafted.summary": "Вы создали {{count}} шт.",
Expand Down
1 change: 1 addition & 0 deletions LookupAnything/i18n/th.json
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@
"item.sells-to.shipping-box": "กล่องส่งสินค้า",
"item.recipes-for-ingredient.entry": "{{name}} (ต้องใช้ {{count}})",
"item.recipes-for-machine.multiple-items": "{{name}} x{{count}}",
"item.recipes-for-machine.same-as-input": "[same as input]", // e.g. crystalarium produces same item that was put in // TODO
"item.recipes-for-machine.too-complex": "Some machine rules are too dynamic to display.", // TODO
"item.number-owned.summary": "คุณมีแล้ว {{count}} ชิ้น",
"item.number-crafted.summary": "คุณสร้างแล้ว {{count}} ชิ้น",
Expand Down
1 change: 1 addition & 0 deletions LookupAnything/i18n/tr.json
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@
"item.sells-to.shipping-box": "gönderi kutusu",
"item.recipes-for-ingredient.entry": "{{name}} (lazım {{count}})",
"item.recipes-for-machine.multiple-items": "{{name}} x{{count}}",
"item.recipes-for-machine.same-as-input": "[same as input]", // e.g. crystalarium produces same item that was put in // TODO
"item.recipes-for-machine.too-complex": "Some machine rules are too dynamic to display.", // TODO
"item.number-owned.summary": "bundan {{count}} tane sahipsin",
"item.number-crafted.summary": "bundan {{count}} tane yaptın",
Expand Down
1 change: 1 addition & 0 deletions LookupAnything/i18n/uk.json
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@
"item.sells-to.shipping-box": "Ящик для продажу",
"item.recipes-for-ingredient.entry": "{{name}} ({{count}} од.)",
"item.recipes-for-machine.multiple-items": "{{name}} {{count}} од.",
"item.recipes-for-machine.same-as-input": "[same as input]", // e.g. crystalarium produces same item that was put in // TODO
"item.recipes-for-machine.too-complex": "Some machine rules are too dynamic to display.", // TODO
"item.number-owned.summary": "Ви маєте {{count}} од.",
"item.number-crafted.summary": "Ви створили {{count}} од.",
Expand Down
1 change: 1 addition & 0 deletions LookupAnything/i18n/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@
"item.sells-to.shipping-box": "出货箱",
"item.recipes-for-ingredient.entry": "{{name}}(需要{{count}})",
"item.recipes-for-machine.multiple-items": "{{name}} x{{count}}",
"item.recipes-for-machine.same-as-input": "[same as input]", // e.g. crystalarium produces same item that was put in // TODO
"item.recipes-for-machine.too-complex": "Some recipes are too dynamic to display.", // TODO
"item.number-owned.summary": "你目前拥有的总数为{{count}}",
"item.number-crafted.summary": "你已制造{{count}}个此物",
Expand Down

0 comments on commit c4b9ee5

Please sign in to comment.