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

@@ -57,8 +57,8 @@
"164";"164";"164";"BLOCK_PLATFORM_ROSEWOOD";"0.0312";"0.0312";"0.0312";"0.0312";"5";"900";"WOOD";"0";"0";"N/A";"0";"0";"16";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A";"0.0";"PLATFORM"
"176";"176";"176";"BLOCK_TORCH";"0.0312";"0.0312";"0.0312";"0.0312";"1";"800";"FXTR";"0";"0";"N/A";"1";"0";"16";"1.0000";"0.6372";"0.0000";"0.0000";"N/A";"N/A";"0.0";"LIGHT"
"177";"177";"177";"BLOCK_TORCH_FROST";"0.0312";"0.0312";"0.0312";"0.0312";"1";"1100";"FXTR";"0";"0";"N/A";"1";"0";"16";"0.3048";"0.4848";"1.0000";"0.0000";"N/A";"N/A";"0.0";"LIGHT"
"192";"176";"176";"BLOCK_TORCH";"0.0312";"0.0312";"0.0312";"0.0312";"1";"800";"FXTR";"0";"0";"N/A";"0";"0";"16";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A";"0.0";"LIGHT,UNLIT"
"193";"177";"177";"BLOCK_TORCH_FROST";"0.0312";"0.0312";"0.0312";"0.0312";"1";"1100";"FXTR";"0";"0";"N/A";"0";"0";"16";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A";"0.0";"LIGHT,UNLIT"
"192";"176";"176";"BLOCK_TORCH";"0.0312";"0.0312";"0.0312";"0.0312";"1";"800";"FXTR";"0";"0";"N/A";"0";"0";"16";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A";"0.0";"LIGHT,UNLIT,INTERNAL"
"193";"177";"177";"BLOCK_TORCH_FROST";"0.0312";"0.0312";"0.0312";"0.0312";"1";"1100";"FXTR";"0";"0";"N/A";"0";"0";"16";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A";"0.0";"LIGHT,UNLIT,INTERNAL"
"208";"208";"208";"BLOCK_ILLUMINATOR_WHITE";"0.0312";"0.0312";"0.0312";"0.0312";"1";"2500";"GLAS";"1";"1";"N/A";"0";"0";"16";"0.9270";"0.9414";"0.8519";"0.0000";"N/A";"N/A";"0.0";"LIGHT"
"209";"209";"209";"BLOCK_ILLUMINATOR_YELLOW";"0.0312";"0.0312";"0.0312";"0.0312";"1";"2500";"GLAS";"1";"1";"N/A";"0";"0";"16";"1.0000";"0.8408";"0.0000";"0.0000";"N/A";"N/A";"0.0";"LIGHT"
"210";"210";"210";"BLOCK_ILLUMINATOR_ORANGE";"0.0312";"0.0312";"0.0312";"0.0312";"1";"2500";"GLAS";"1";"1";"N/A";"0";"0";"16";"1.0000";"0.5294";"0.0000";"0.0000";"N/A";"N/A";"0.0";"LIGHT"
@@ -75,22 +75,22 @@
"221";"221";"221";"BLOCK_ILLUMINATOR_GREY_MED";"0.0312";"0.0312";"0.0312";"0.0312";"1";"2500";"GLAS";"1";"1";"N/A";"0";"0";"16";"0.4576";"0.4576";"0.4576";"0.0000";"N/A";"N/A";"0.0";"LIGHT"
"222";"222";"222";"BLOCK_ILLUMINATOR_GREY_DARK";"0.0312";"0.0312";"0.0312";"0.0312";"1";"2500";"GLAS";"1";"1";"N/A";"0";"0";"16";"0.2540";"0.2540";"0.2540";"0.0000";"N/A";"N/A";"0.0";"LIGHT"
"223";"223";"223";"BLOCK_ILLUMINATOR_BLACK";"0.0312";"0.0312";"0.0312";"0.0312";"1";"2500";"GLAS";"1";"1";"N/A";"0";"0";"16";"0.2140";"0.0000";"0.4932";"3.7499";"N/A";"N/A";"0.0";"LIGHT"
"224";"208";"208";"BLOCK_ILLUMINATOR_WHITE";"0.1252";"0.1252";"0.1252";"0.1252";"1";"2500";"GLAS";"1";"1";"N/A";"0";"0";"16";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A";"0.0";"LIGHT,UNLIT"
"225";"209";"209";"BLOCK_ILLUMINATOR_YELLOW";"0.1252";"0.1252";"0.1252";"0.1252";"1";"2500";"GLAS";"1";"1";"N/A";"0";"0";"16";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A";"0.0";"LIGHT,UNLIT"
"226";"210";"210";"BLOCK_ILLUMINATOR_ORANGE";"0.1252";"0.1252";"0.1252";"0.1252";"1";"2500";"GLAS";"1";"1";"N/A";"0";"0";"16";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A";"0.0";"LIGHT,UNLIT"
"227";"211";"211";"BLOCK_ILLUMINATOR_RED";"0.1252";"0.1252";"0.1252";"0.1252";"1";"2500";"GLAS";"1";"1";"N/A";"0";"0";"16";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A";"0.0";"LIGHT,UNLIT"
"228";"212";"212";"BLOCK_ILLUMINATOR_FUCHSIA";"0.1252";"0.1252";"0.1252";"0.1252";"1";"2500";"GLAS";"1";"1";"N/A";"0";"0";"16";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A";"0.0";"LIGHT,UNLIT"
"229";"213";"213";"BLOCK_ILLUMINATOR_PURPLE";"0.1252";"0.1252";"0.1252";"0.1252";"1";"2500";"GLAS";"1";"1";"N/A";"0";"0";"16";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A";"0.0";"LIGHT,UNLIT"
"230";"214";"214";"BLOCK_ILLUMINATOR_BLUE";"0.1252";"0.1252";"0.1252";"0.1252";"1";"2500";"GLAS";"1";"1";"N/A";"0";"0";"16";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A";"0.0";"LIGHT,UNLIT"
"231";"215";"215";"BLOCK_ILLUMINATOR_CYAN";"0.1252";"0.1252";"0.1252";"0.1252";"1";"2500";"GLAS";"1";"1";"N/A";"0";"0";"16";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A";"0.0";"LIGHT,UNLIT"
"232";"216";"216";"BLOCK_ILLUMINATOR_GREEN";"0.1252";"0.1252";"0.1252";"0.1252";"1";"2500";"GLAS";"1";"1";"N/A";"0";"0";"16";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A";"0.0";"LIGHT,UNLIT"
"233";"217";"217";"BLOCK_ILLUMINATOR_GREEN_DARK";"0.1252";"0.1252";"0.1252";"0.1252";"1";"2500";"GLAS";"1";"1";"N/A";"0";"0";"16";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A";"0.0";"LIGHT,UNLIT"
"234";"218";"218";"BLOCK_ILLUMINATOR_BROWN";"0.1252";"0.1252";"0.1252";"0.1252";"1";"2500";"GLAS";"1";"1";"N/A";"0";"0";"16";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A";"0.0";"LIGHT,UNLIT"
"235";"219";"219";"BLOCK_ILLUMINATOR_TAN";"0.1252";"0.1252";"0.1252";"0.1252";"1";"2500";"GLAS";"1";"1";"N/A";"0";"0";"16";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A";"0.0";"LIGHT,UNLIT"
"236";"220";"220";"BLOCK_ILLUMINATOR_GREY_LIGHT";"0.1252";"0.1252";"0.1252";"0.1252";"1";"2500";"GLAS";"1";"1";"N/A";"0";"0";"16";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A";"0.0";"LIGHT,UNLIT"
"237";"221";"221";"BLOCK_ILLUMINATOR_GREY_MED";"0.1252";"0.1252";"0.1252";"0.1252";"1";"2500";"GLAS";"1";"1";"N/A";"0";"0";"16";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A";"0.0";"LIGHT,UNLIT"
"238";"222";"222";"BLOCK_ILLUMINATOR_GREY_DARK";"0.1252";"0.1252";"0.1252";"0.1252";"1";"2500";"GLAS";"1";"1";"N/A";"0";"0";"16";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A";"0.0";"LIGHT,UNLIT"
"239";"223";"223";"BLOCK_ILLUMINATOR_BLACK";"0.1252";"0.1252";"0.1252";"0.1252";"1";"2500";"GLAS";"1";"1";"N/A";"0";"0";"16";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A";"0.0";"LIGHT,UNLIT"
"224";"208";"208";"BLOCK_ILLUMINATOR_WHITE";"0.1252";"0.1252";"0.1252";"0.1252";"1";"2500";"GLAS";"1";"1";"N/A";"0";"0";"16";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A";"0.0";"LIGHT,UNLIT,INTERNAL"
"225";"209";"209";"BLOCK_ILLUMINATOR_YELLOW";"0.1252";"0.1252";"0.1252";"0.1252";"1";"2500";"GLAS";"1";"1";"N/A";"0";"0";"16";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A";"0.0";"LIGHT,UNLIT,INTERNAL"
"226";"210";"210";"BLOCK_ILLUMINATOR_ORANGE";"0.1252";"0.1252";"0.1252";"0.1252";"1";"2500";"GLAS";"1";"1";"N/A";"0";"0";"16";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A";"0.0";"LIGHT,UNLIT,INTERNAL"
"227";"211";"211";"BLOCK_ILLUMINATOR_RED";"0.1252";"0.1252";"0.1252";"0.1252";"1";"2500";"GLAS";"1";"1";"N/A";"0";"0";"16";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A";"0.0";"LIGHT,UNLIT,INTERNAL"
"228";"212";"212";"BLOCK_ILLUMINATOR_FUCHSIA";"0.1252";"0.1252";"0.1252";"0.1252";"1";"2500";"GLAS";"1";"1";"N/A";"0";"0";"16";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A";"0.0";"LIGHT,UNLIT,INTERNAL"
"229";"213";"213";"BLOCK_ILLUMINATOR_PURPLE";"0.1252";"0.1252";"0.1252";"0.1252";"1";"2500";"GLAS";"1";"1";"N/A";"0";"0";"16";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A";"0.0";"LIGHT,UNLIT,INTERNAL"
"230";"214";"214";"BLOCK_ILLUMINATOR_BLUE";"0.1252";"0.1252";"0.1252";"0.1252";"1";"2500";"GLAS";"1";"1";"N/A";"0";"0";"16";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A";"0.0";"LIGHT,UNLIT,INTERNAL"
"231";"215";"215";"BLOCK_ILLUMINATOR_CYAN";"0.1252";"0.1252";"0.1252";"0.1252";"1";"2500";"GLAS";"1";"1";"N/A";"0";"0";"16";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A";"0.0";"LIGHT,UNLIT,INTERNAL"
"232";"216";"216";"BLOCK_ILLUMINATOR_GREEN";"0.1252";"0.1252";"0.1252";"0.1252";"1";"2500";"GLAS";"1";"1";"N/A";"0";"0";"16";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A";"0.0";"LIGHT,UNLIT,INTERNAL"
"233";"217";"217";"BLOCK_ILLUMINATOR_GREEN_DARK";"0.1252";"0.1252";"0.1252";"0.1252";"1";"2500";"GLAS";"1";"1";"N/A";"0";"0";"16";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A";"0.0";"LIGHT,UNLIT,INTERNAL"
"234";"218";"218";"BLOCK_ILLUMINATOR_BROWN";"0.1252";"0.1252";"0.1252";"0.1252";"1";"2500";"GLAS";"1";"1";"N/A";"0";"0";"16";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A";"0.0";"LIGHT,UNLIT,INTERNAL"
"235";"219";"219";"BLOCK_ILLUMINATOR_TAN";"0.1252";"0.1252";"0.1252";"0.1252";"1";"2500";"GLAS";"1";"1";"N/A";"0";"0";"16";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A";"0.0";"LIGHT,UNLIT,INTERNAL"
"236";"220";"220";"BLOCK_ILLUMINATOR_GREY_LIGHT";"0.1252";"0.1252";"0.1252";"0.1252";"1";"2500";"GLAS";"1";"1";"N/A";"0";"0";"16";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A";"0.0";"LIGHT,UNLIT,INTERNAL"
"237";"221";"221";"BLOCK_ILLUMINATOR_GREY_MED";"0.1252";"0.1252";"0.1252";"0.1252";"1";"2500";"GLAS";"1";"1";"N/A";"0";"0";"16";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A";"0.0";"LIGHT,UNLIT,INTERNAL"
"238";"222";"222";"BLOCK_ILLUMINATOR_GREY_DARK";"0.1252";"0.1252";"0.1252";"0.1252";"1";"2500";"GLAS";"1";"1";"N/A";"0";"0";"16";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A";"0.0";"LIGHT,UNLIT,INTERNAL"
"239";"223";"223";"BLOCK_ILLUMINATOR_BLACK";"0.1252";"0.1252";"0.1252";"0.1252";"1";"2500";"GLAS";"1";"1";"N/A";"0";"0";"16";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A";"0.0";"LIGHT,UNLIT,INTERNAL"
"240";"240";"240";"BLOCK_SANDSTONE";"0.1252";"0.1252";"0.1252";"0.1252";"48";"1900";"ROCK";"1";"1";"N/A";"0";"0";"16";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A";"0.16";"STONE"
"241";"241";"241";"BLOCK_SANDSTONE_WHITE";"0.1252";"0.1252";"0.1252";"0.1252";"48";"1900";"ROCK";"1";"1";"N/A";"0";"0";"16";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A";"0.16";"STONE"
"242";"242";"242";"BLOCK_SANDSTONE_RED";"0.1252";"0.1252";"0.1252";"0.1252";"48";"1900";"ROCK";"1";"1";"N/A";"0";"0";"16";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A";"0.16";"STONE"
@@ -205,7 +205,7 @@
### Internal Tags ##
##
## Some tags are reserved for internal use, which are:
## - INTERNAL: denotes that the tile is internal-use. Will not be rendered unless debug window is on.
## - INTERNAL: denotes that the tile is internal-use.
## - DORENDER: this internal tile must go through the standard-issue tile drawing routine.
## - INCONSEQUENTIAL: denotes that this tile can be overwritten without dropping it. Usually used with flower tiles.
#
Can't render this file because it contains an unexpected character in line 198 and column 37.

View File

@@ -75,7 +75,7 @@ object PlayerBuilderSigrid {
App.tileMaker.tags.forEach { (t, _) ->
val prop = BlockCodex[t]
if (!prop.isActorBlock && !prop.hasTag("AIR")) {
if (!prop.isActorBlock && !prop.hasTag("AIR") && !prop.hasTag("INTERNAL")) {
inventory.add(t, 9995)
try {

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

View File

@@ -6,6 +6,7 @@ import net.torvald.terrarum.ItemCodex
import net.torvald.terrarum.UIItemInventoryCatBar
import net.torvald.terrarum.ceilToInt
import net.torvald.terrarum.gameitems.GameItem
import net.torvald.terrarum.gameitems.ItemID
import net.torvald.terrarum.itemproperties.CraftingCodex
import net.torvald.terrarum.modulebasegame.gameactors.FixtureInventory
import net.torvald.terrarum.modulebasegame.gameactors.InventoryPair
@@ -123,6 +124,10 @@ class UIItemCraftingCandidateGrid(
rebuild(currentFilter1)
}
override fun rebuild(filterFun: (InventoryPair) -> Boolean, itemAppendix: ItemID) {
rebuild(currentFilter1)
}
override fun scrolled(amountX: Float, amountY: Float): Boolean {
super.scrolled(amountX, amountY)
return true

View File

@@ -85,13 +85,14 @@ open class UIItemInventoryItemGrid(
arrayOf(CAT_ALL)
)*/
protected var currentFilter: (InventoryPair) -> Boolean = { _: InventoryPair -> true }
protected var currentAppendix = ""
private val inventoryUI = parentUI
var itemPage
set(value) {
navRemoCon.itemPage = if (itemPageCount == 0) 0 else (value).fmod(itemPageCount)
rebuild(currentFilter)
rebuild(currentFilter, currentAppendix)
}
get() = navRemoCon.itemPage
@@ -228,7 +229,7 @@ open class UIItemInventoryItemGrid(
set(value) {
field = value
items = if (value) itemGrid else itemList
rebuild(currentFilter)
rebuild(currentFilter, currentAppendix)
}
private val iconPosX = if (drawScrollOnRightside)
@@ -257,11 +258,11 @@ open class UIItemInventoryItemGrid(
if (!hideSidebar) {
navRemoCon.listButtonListener = { _, _ ->
isCompactMode = false
rebuild(currentFilter)
rebuild(currentFilter, currentAppendix)
}
navRemoCon.gridButtonListener = { _, _ ->
isCompactMode = true
rebuild(currentFilter)
rebuild(currentFilter, currentAppendix)
}
navRemoCon.scrollUpListener = { _, it ->
it.highlighted = false
@@ -376,8 +377,102 @@ open class UIItemInventoryItemGrid(
forceHighlightList.removeAll(items)
}
/**
* Special function for UICrafting to show how much the player already has the recipe's product
*
* TODO: special theming for the appendix cell?
*/
open fun rebuild(filterFun: (InventoryPair) -> Boolean, itemAppendix: ItemID) {
currentFilter = filterFun
currentAppendix = itemAppendix
//println("Rebuilt inventory")
//println("rebuild: actual itempage: $itemPage")
//val filter = catIconsMeaning[selectedIcon]
inventorySortList.clear()
// filter items
val filteredItems = getInventory().filter(filterFun)
inventorySortList.addAll(filteredItems)
// sort if needed
// test sort by name
inventorySortList.sortBy { ItemCodex[it.itm]!!.name }
// add an appendix
if (itemAppendix.isNotBlank()) {
getInventory().filter { it.itm == itemAppendix }.let {
inventorySortList.addAll(it)
}
}
// map sortList to item list
for (k in items.indices) {
val item = items[k]
// we have an item
try {
val sortListItem = inventorySortList[k + itemPage * items.size]
item.item = ItemCodex[sortListItem.itm]
item.amount = sortListItem.qty * numberMultiplier
item.itemImage = ItemCodex.getItemImage(sortListItem.itm)
// set quickslot number
if (getInventory() is ActorInventory) {
val ainv = getInventory() as ActorInventory
for (qs in 1..UIQuickslotBar.SLOT_COUNT) {
if (sortListItem.itm == ainv.getQuickslotItem(qs - 1)?.itm) {
item.quickslot = qs % 10 // 10 -> 0, 1..9 -> 1..9
break
}
else
item.quickslot = null
}
// set equippedslot number
for (eq in ainv.itemEquipped.indices) {
if (eq < ainv.itemEquipped.size) {
if (ainv.itemEquipped[eq] == item.item?.dynamicID) {
item.equippedSlot = eq
break
}
else
item.equippedSlot = null
}
}
}
}
// we do not have an item, empty the slot
catch (e: IndexOutOfBoundsException) {
item.item = null
item.amount = 0
item.itemImage = null
item.quickslot = null
item.equippedSlot = null
}
}
itemPageCount = (inventorySortList.size.toFloat() / items.size.toFloat()).ceilToInt()
// ¤ 42g
// ¤ 6969g
// ¤ 2147483647g
// g is read as "grave" /ɡraːv/ or /ɡɹeɪv/, because it isn't gram.
walletText = "<;?" + getInventory().wallet.toString().padStart(4, '?') + ":"
rebuildList = false
}
open fun rebuild(filterFun: (InventoryPair) -> Boolean) {
currentFilter = filterFun
currentAppendix = ""
//println("Rebuilt inventory")
//println("rebuild: actual itempage: $itemPage")
@@ -494,7 +589,7 @@ open class UIItemInventoryItemGrid(
super.keyDown(keycode)
items.forEach { if (it.mouseUp) it.keyDown(keycode) }
// rebuild(currentFilter)
// rebuild(currentFilter, currentAppendix)
return true
}
@@ -503,7 +598,7 @@ open class UIItemInventoryItemGrid(
super.keyUp(keycode)
items.forEach { if (it.mouseUp) it.keyUp(keycode) }
// rebuild(currentFilter)
// rebuild(currentFilter, currentAppendix)
return true
}