charcoal; smelter item sprite;

crafting-fixed navigate-ingredients-crafting-recipe behav
This commit is contained in:
minjaesong
2024-02-02 16:48:07 +09:00
parent cfd0f0302e
commit a569a34005
14 changed files with 65 additions and 60 deletions

View File

@@ -40,14 +40,34 @@ class UIItemCraftingCandidateGrid(
private var highlightedRecipe: CraftingCodex.CraftingRecipe? = null
fun highlightRecipe(recipe: CraftingCodex.CraftingRecipe?) {
fun highlightRecipe(recipe: CraftingCodex.CraftingRecipe?, changePage: Boolean = false) {
items.forEach { it.forceHighlighted = false }
highlightedRecipe = recipe
recipe?.let {
items.find { it.extraInfo == recipe }?.let { buttonFound ->
buttonFound.forceHighlighted = true
// search for the recipe
// also need to find what "page" the recipe might be in
// use it.isCompactMode to find out the current mode
var ord = 0
var found = false
while (ord < craftingRecipes.indices.last) {
if (recipe == craftingRecipes[ord]) {
found = true
break
}
ord += 1
}
val itemSize = items.size
val newPage = ord / itemSize
if (found) {
if (changePage) {
itemPage = newPage
items[ord % itemSize].forceHighlighted = true
}
// if we are on the same page, highlight the cell; otherwise, do nothing
else if (itemPage == newPage) {
items[ord % itemSize].forceHighlighted = true
}
}
}