clicking on the crafting recipe will also show how much the player already has the product

This commit is contained in:
minjaesong
2023-10-01 21:47:55 +09:00
parent 63561725fd
commit f4f00c2e1c
5 changed files with 133 additions and 28 deletions

View File

@@ -272,6 +272,7 @@ class UICrafting(val full: UIInventoryFull) : UICanvas(), HasInventory {
_getItemListPlayer().removeFromForceHighlightList(oldSelectedItems)
_getItemListPlayer().addToForceHighlightList(selectedItems)
_getItemListPlayer().itemPage = 0
filterPlayerListUsing(recipeClicked)
_getItemListIngredients().rebuild(catAll)
@@ -335,11 +336,14 @@ class UICrafting(val full: UIInventoryFull) : UICanvas(), HasInventory {
if (recipe == null)
itemListPlayer.rebuild(catAll)
else {
val items = recipe.ingredients.flatMap { getItemCandidatesForIngredient(getPlayerInventory(), it).map { it.itm } }.sorted()
val items = recipe.ingredients.flatMap {
getItemCandidatesForIngredient(getPlayerInventory(), it).map { it.itm }
}.sorted()
val filterFun = { pair: InventoryPair ->
items.binarySearch(pair.itm) >= 0
}
itemListPlayer.rebuild(filterFun)
itemListPlayer.rebuild(filterFun, recipe.product)
}
}
@@ -360,6 +364,7 @@ class UICrafting(val full: UIInventoryFull) : UICanvas(), HasInventory {
oldSelectedItems.add(new)
itemListPlayer.addToForceHighlightList(oldSelectedItems)
itemListPlayer.itemPage = 0
filterPlayerListUsing(recipe)
// change highlight status of itemListIngredients