mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-12 11:34:05 +09:00
seemingly working crafting window
This commit is contained in:
@@ -4,7 +4,6 @@ import com.badlogic.gdx.graphics.Camera
|
|||||||
import com.badlogic.gdx.graphics.Color
|
import com.badlogic.gdx.graphics.Color
|
||||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||||
import net.torvald.terrarum.*
|
import net.torvald.terrarum.*
|
||||||
import net.torvald.terrarum.App.printdbg
|
|
||||||
import net.torvald.terrarum.UIItemInventoryCatBar.Companion.CAT_ALL
|
import net.torvald.terrarum.UIItemInventoryCatBar.Companion.CAT_ALL
|
||||||
import net.torvald.terrarum.gameitems.GameItem
|
import net.torvald.terrarum.gameitems.GameItem
|
||||||
import net.torvald.terrarum.itemproperties.CraftingCodex
|
import net.torvald.terrarum.itemproperties.CraftingCodex
|
||||||
@@ -142,13 +141,12 @@ class UICrafting(val full: UIInventoryFull) : UICanvas(), HasInventory {
|
|||||||
)
|
)
|
||||||
buttonCraft = UIItemTextButton(this, "GAME_ACTION_CRAFT", thisOffsetX + 3 + buttonWidth + listGap, craftButtonsY, buttonWidth, true, alignment = UIItemTextButton.Companion.Alignment.CENTRE, hasBorder = true)
|
buttonCraft = UIItemTextButton(this, "GAME_ACTION_CRAFT", thisOffsetX + 3 + buttonWidth + listGap, craftButtonsY, buttonWidth, true, alignment = UIItemTextButton.Companion.Alignment.CENTRE, hasBorder = true)
|
||||||
spinnerCraftCount = UIItemSpinner(this, thisOffsetX + 1, craftButtonsY, 1, 1, 100, 1, buttonWidth, numberToTextFunction = {"×\u200A${it.toInt()}"})
|
spinnerCraftCount = UIItemSpinner(this, thisOffsetX + 1, craftButtonsY, 1, 1, 100, 1, buttonWidth, numberToTextFunction = {"×\u200A${it.toInt()}"})
|
||||||
|
spinnerCraftCount.selectionChangeListener = {
|
||||||
buttonCraft.touchDownListener = { _,_,_,_ ->
|
itemListIngredients.numberMultiplier = it.toLong()
|
||||||
printdbg(this, "Recipe to go: ${recipeClicked}")
|
itemListIngredients.rebuild(catAll)
|
||||||
|
itemListCraftable.numberMultiplier = it.toLong()
|
||||||
|
itemListCraftable.rebuild(catAll)
|
||||||
}
|
}
|
||||||
// make grid mode buttons work together
|
|
||||||
// itemListCraftable.gridModeButtons[0].touchDownListener = { _,_,_,_ -> setCompact(false) }
|
|
||||||
// itemListCraftable.gridModeButtons[1].touchDownListener = { _,_,_,_ -> setCompact(true) }
|
|
||||||
|
|
||||||
// player inventory to the right
|
// player inventory to the right
|
||||||
itemListPlayer = UIItemInventoryItemGrid(
|
itemListPlayer = UIItemInventoryItemGrid(
|
||||||
@@ -172,6 +170,22 @@ class UICrafting(val full: UIInventoryFull) : UICanvas(), HasInventory {
|
|||||||
// itemListPlayer.gridModeButtons[0].touchDownListener = { _,_,_,_ -> setCompact(false) }
|
// itemListPlayer.gridModeButtons[0].touchDownListener = { _,_,_,_ -> setCompact(false) }
|
||||||
// itemListPlayer.gridModeButtons[1].touchDownListener = { _,_,_,_ -> setCompact(true) }
|
// itemListPlayer.gridModeButtons[1].touchDownListener = { _,_,_,_ -> setCompact(true) }
|
||||||
|
|
||||||
|
buttonCraft.touchDownListener = { _,_,_,_ ->
|
||||||
|
getPlayerInventory().let { player -> recipeClicked?.let { recipe ->
|
||||||
|
val mult = spinnerCraftCount.value.toLong()
|
||||||
|
itemListIngredients.getInventory().itemList.forEach { (itm, qty) ->
|
||||||
|
player.remove(itm, qty * mult)
|
||||||
|
}
|
||||||
|
player.add(recipe.product, recipe.moq * mult)
|
||||||
|
itemListPlayer.rebuild(catAll)
|
||||||
|
itemListIngredients.rebuild(catAll)
|
||||||
|
itemListCraftable.rebuild(catAll)
|
||||||
|
} }
|
||||||
|
}
|
||||||
|
// make grid mode buttons work together
|
||||||
|
// itemListCraftable.gridModeButtons[0].touchDownListener = { _,_,_,_ -> setCompact(false) }
|
||||||
|
// itemListCraftable.gridModeButtons[1].touchDownListener = { _,_,_,_ -> setCompact(true) }
|
||||||
|
|
||||||
handler.allowESCtoClose = true
|
handler.allowESCtoClose = true
|
||||||
|
|
||||||
addUIitem(itemListCraftable)
|
addUIitem(itemListCraftable)
|
||||||
@@ -190,6 +204,8 @@ class UICrafting(val full: UIInventoryFull) : UICanvas(), HasInventory {
|
|||||||
// reset spinner
|
// reset spinner
|
||||||
spinnerCraftCount.value = 1
|
spinnerCraftCount.value = 1
|
||||||
spinnerCraftCount.fboUpdateLatch = true
|
spinnerCraftCount.fboUpdateLatch = true
|
||||||
|
itemListIngredients.numberMultiplier = 1L
|
||||||
|
itemListCraftable.numberMultiplier = 1L
|
||||||
// reset selected recipe status
|
// reset selected recipe status
|
||||||
recipeClicked = null
|
recipeClicked = null
|
||||||
highlightCraftingCandidateButton(null)
|
highlightCraftingCandidateButton(null)
|
||||||
@@ -205,15 +221,6 @@ class UICrafting(val full: UIInventoryFull) : UICanvas(), HasInventory {
|
|||||||
|
|
||||||
openingClickLatched = Terrarum.mouseDown
|
openingClickLatched = Terrarum.mouseDown
|
||||||
|
|
||||||
// reset spinner
|
|
||||||
/*spinnerCraftCount.value = 1
|
|
||||||
spinnerCraftCount.fboUpdateLatch = true
|
|
||||||
// reset selected recipe status
|
|
||||||
recipeClicked = null
|
|
||||||
highlightCraftingCandidateButton(null)
|
|
||||||
ingredients.clear()
|
|
||||||
itemListIngredients.rebuild(catAll)*/
|
|
||||||
|
|
||||||
UIItemInventoryItemGrid.tooltipShowing.clear()
|
UIItemInventoryItemGrid.tooltipShowing.clear()
|
||||||
INGAME.setTooltipMessage(null)
|
INGAME.setTooltipMessage(null)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,8 +32,6 @@ class UIItemCraftingCandidateGrid(
|
|||||||
|
|
||||||
val craftingRecipes = ArrayList<CraftingCodex.CraftingRecipe>()
|
val craftingRecipes = ArrayList<CraftingCodex.CraftingRecipe>()
|
||||||
|
|
||||||
init {
|
|
||||||
}
|
|
||||||
|
|
||||||
internal val recipesSortList = ArrayList<CraftingCodex.CraftingRecipe>() // a dual to the [inventorySortList] which contains the actual recipes instead of crafting recipes
|
internal val recipesSortList = ArrayList<CraftingCodex.CraftingRecipe>() // a dual to the [inventorySortList] which contains the actual recipes instead of crafting recipes
|
||||||
|
|
||||||
@@ -61,7 +59,7 @@ class UIItemCraftingCandidateGrid(
|
|||||||
try {
|
try {
|
||||||
val sortListItem = recipesSortList[k + itemPage * items.size]
|
val sortListItem = recipesSortList[k + itemPage * items.size]
|
||||||
items[k].item = ItemCodex[sortListItem.product]
|
items[k].item = ItemCodex[sortListItem.product]
|
||||||
items[k].amount = sortListItem.moq
|
items[k].amount = sortListItem.moq * numberMultiplier
|
||||||
items[k].itemImage = ItemCodex.getItemImage(sortListItem.product)
|
items[k].itemImage = ItemCodex.getItemImage(sortListItem.product)
|
||||||
items[k].extraInfo = sortListItem
|
items[k].extraInfo = sortListItem
|
||||||
|
|
||||||
|
|||||||
@@ -50,6 +50,8 @@ open class UIItemInventoryItemGrid(
|
|||||||
//override var oldPosX = posX
|
//override var oldPosX = posX
|
||||||
//override var oldPosY = posY
|
//override var oldPosY = posY
|
||||||
|
|
||||||
|
var numberMultiplier = 1L
|
||||||
|
|
||||||
private val hash = System.nanoTime()
|
private val hash = System.nanoTime()
|
||||||
|
|
||||||
override val width = horizontalCells * UIItemInventoryElemSimple.height + (horizontalCells - 1) * listGap
|
override val width = horizontalCells * UIItemInventoryElemSimple.height + (horizontalCells - 1) * listGap
|
||||||
@@ -425,7 +427,7 @@ open class UIItemInventoryItemGrid(
|
|||||||
try {
|
try {
|
||||||
val sortListItem = inventorySortList[k + itemPage * items.size]
|
val sortListItem = inventorySortList[k + itemPage * items.size]
|
||||||
items[k].item = ItemCodex[sortListItem.itm]
|
items[k].item = ItemCodex[sortListItem.itm]
|
||||||
items[k].amount = sortListItem.qty
|
items[k].amount = sortListItem.qty * numberMultiplier
|
||||||
items[k].itemImage = ItemCodex.getItemImage(sortListItem.itm)
|
items[k].itemImage = ItemCodex.getItemImage(sortListItem.itm)
|
||||||
|
|
||||||
// set quickslot number
|
// set quickslot number
|
||||||
|
|||||||
Reference in New Issue
Block a user