smelter: scroll wheel to operate the item slots

This commit is contained in:
minjaesong
2024-01-31 02:07:17 +09:00
parent d1a6873bc0
commit e1935fb659
15 changed files with 324 additions and 147 deletions

View File

@@ -40,11 +40,11 @@ class ActorInventory() : FixtureInventory() {
val quickSlot = Array<ItemID?>(UIQuickslotBar.SLOT_COUNT) { null } // 0: Slot 1, 9: Slot 10 val quickSlot = Array<ItemID?>(UIQuickslotBar.SLOT_COUNT) { null } // 0: Slot 1, 9: Slot 10
override fun remove(itemID: ItemID, count: Long) = remove(ItemCodex[itemID]!!, count) override fun remove(itemID: ItemID, count: Long): Long = remove(ItemCodex[itemID]!!, count)
/** Will check existence of the item using its Dynamic ID; careful with command order! /** Will check existence of the item using its Dynamic ID; careful with command order!
* e.g. re-assign after this operation */ * e.g. re-assign after this operation */
override fun remove(item: GameItem, count: Long) { override fun remove(item: GameItem, count: Long): Long {
super.remove(item, count) { existingItem -> return super.remove(item, count) { existingItem ->
// unequip, if applicable // unequip, if applicable
actor.unequipItem(existingItem.itm) actor.unequipItem(existingItem.itm)
// also unequip on the quickslot // also unequip on the quickslot

View File

@@ -136,19 +136,23 @@ open class FixtureInventory() {
open fun remove(itemID: ItemID, count: Long, unequipFun: (InventoryPair) -> Unit) = open fun remove(itemID: ItemID, count: Long, unequipFun: (InventoryPair) -> Unit) =
remove(ItemCodex[itemID]!!, count, unequipFun) remove(ItemCodex[itemID]!!, count, unequipFun)
/** Will check existence of the item using its Dynamic ID; careful with command order! /** Will check existence of the item using its Dynamic ID; careful with command order!
* e.g. re-assign after this operation */ * e.g. re-assign after this operation
open fun remove(item: GameItem, count: Long = 1, unequipFun: (InventoryPair) -> Unit) { *
* @return the actual amount of item that has been removed
**/
open fun remove(item: GameItem, count: Long = 1, unequipFun: (InventoryPair) -> Unit): Long {
// printdbg(this, "remove $item, $count") // printdbg(this, "remove $item, $count")
if (count == 0L) if (count == 0L)
// throw IllegalArgumentException("[${this.javaClass.canonicalName}] Item count is zero.") // throw IllegalArgumentException("[${this.javaClass.canonicalName}] Item count is zero.")
return return 0L
if (count < 0L) if (count < 0L)
throw IllegalArgumentException("[${this.javaClass.canonicalName}] Item count is negative number. If you intended adding items, use add()" + throw IllegalArgumentException("[${this.javaClass.canonicalName}] Item count is negative number. If you intended adding items, use add()" +
"These commands are NOT INTERCHANGEABLE; they handle things differently according to the context.") "These commands are NOT INTERCHANGEABLE; they handle things differently according to the context.")
var delta = 0L
val existingItem = searchByID(item.dynamicID) val existingItem = searchByID(item.dynamicID)
if (existingItem != null) { // if the item already exists if (existingItem != null) { // if the item already exists
@@ -158,10 +162,12 @@ open class FixtureInventory() {
throw InventoryFailedTransactionError("[${this.javaClass.canonicalName}] Tried to remove $count of $item, but the inventory only contains ${existingItem.qty} of them.") throw InventoryFailedTransactionError("[${this.javaClass.canonicalName}] Tried to remove $count of $item, but the inventory only contains ${existingItem.qty} of them.")
} }
else*/ if (newCount > 0) { else*/ if (newCount > 0) {
delta = count
// decrement count // decrement count
existingItem.qty = newCount existingItem.qty = newCount
} }
else { else {
delta = existingItem.qty
// unequip must be done before the entry removal // unequip must be done before the entry removal
unequipFun(existingItem) unequipFun(existingItem)
// depleted item; remove entry from inventory // depleted item; remove entry from inventory
@@ -170,11 +176,14 @@ open class FixtureInventory() {
} }
else { else {
// throw InventoryFailedTransactionError("[${this.javaClass.canonicalName}] Tried to remove $item, but the inventory does not have it.") // throw InventoryFailedTransactionError("[${this.javaClass.canonicalName}] Tried to remove $item, but the inventory does not have it.")
return 0L
} }
itemList.sumOf { ItemCodex[it.itm]!!.mass * it.qty } // itemList.sumOf { ItemCodex[it.itm]!!.mass * it.qty } // ???
updateEncumbrance() updateEncumbrance()
return delta
} }
open fun clear(): List<InventoryPair> { open fun clear(): List<InventoryPair> {

View File

@@ -133,6 +133,7 @@ class UICrafting(val full: UIInventoryFull?) : UICanvas(
cellHighlightSubCol = Toolkit.Theme.COL_INACTIVE cellHighlightSubCol = Toolkit.Theme.COL_INACTIVE
), ),
keyDownFun = { _, _, _, _, _ -> }, keyDownFun = { _, _, _, _, _ -> },
wheelFun = { _, _, _, _, _, _ -> },
touchDownFun = { gameItem, amount, _, _, _ -> gameItem?.let { gameItem -> touchDownFun = { gameItem, amount, _, _, _ -> gameItem?.let { gameItem ->
// if the item is craftable one, load its recipe instead // if the item is craftable one, load its recipe instead
CraftingRecipeCodex.getRecipesFor(gameItem.originalID)?.let { recipes -> CraftingRecipeCodex.getRecipesFor(gameItem.originalID)?.let { recipes ->

View File

@@ -93,7 +93,8 @@ internal class UIInventoryCells(
INVENTORY_CELLS_OFFSET_Y(), INVENTORY_CELLS_OFFSET_Y(),
CELLS_HOR, CELLS_VRT, CELLS_HOR, CELLS_VRT,
keyDownFun = createInvCellGenericKeyDownFun(), keyDownFun = createInvCellGenericKeyDownFun(),
touchDownFun = createInvCellGenericTouchDownFun { rebuildList() } touchDownFun = createInvCellGenericTouchDownFun { rebuildList() },
wheelFun = { _, _, _, _, _, _ -> },
) )

View File

@@ -30,6 +30,7 @@ class UIItemCraftingCandidateGrid(
hideSidebar = false, hideSidebar = false,
keyDownFun = keyDownFun, keyDownFun = keyDownFun,
touchDownFun = touchDownFun, touchDownFun = touchDownFun,
wheelFun = { _, _, _, _, _, _ -> },
useHighlightingManager = false useHighlightingManager = false
) { ) {

View File

@@ -30,6 +30,7 @@ abstract class UIItemInventoryCellBase(
open var equippedSlot: Int? = null, open var equippedSlot: Int? = null,
var keyDownFun: (GameItem?, Long, Int, Any?, UIItemInventoryCellBase) -> Unit, // Item, Amount, Keycode, extra info, self var keyDownFun: (GameItem?, Long, Int, Any?, UIItemInventoryCellBase) -> Unit, // Item, Amount, Keycode, extra info, self
var touchDownFun: (GameItem?, Long, Int, Any?, UIItemInventoryCellBase) -> Unit, // Item, Amount, Button, extra info, self var touchDownFun: (GameItem?, Long, Int, Any?, UIItemInventoryCellBase) -> Unit, // Item, Amount, Button, extra info, self
var wheelFun: (GameItem?, Long, Float, Float, Any?, UIItemInventoryCellBase) -> Unit, // Item, Amount, scroll x, scroll y, extra info, self
open var extraInfo: Any?, open var extraInfo: Any?,
open protected val highlightEquippedItem: Boolean = true, // for some UIs that only cares about getting equipped slot number but not highlighting open protected val highlightEquippedItem: Boolean = true, // for some UIs that only cares about getting equipped slot number but not highlighting
var colourTheme: InventoryCellColourTheme = UIItemInventoryCellCommonRes.defaultInventoryCellTheme, var colourTheme: InventoryCellColourTheme = UIItemInventoryCellCommonRes.defaultInventoryCellTheme,
@@ -70,6 +71,14 @@ abstract class UIItemInventoryCellBase(
} }
return true return true
} }
override fun scrolled(amountX: Float, amountY: Float): Boolean {
if (mouseUp) {
wheelFun(item, amount, amountX, amountY, extraInfo, this)
super.scrolled(amountX, amountY)
}
return true
}
} }
object UIItemInventoryCellCommonRes { object UIItemInventoryCellCommonRes {

View File

@@ -56,7 +56,8 @@ class UIItemInventoryEquippedView(
drawBackOnNull = true, drawBackOnNull = true,
keyDownFun = createInvCellGenericKeyDownFun(), keyDownFun = createInvCellGenericKeyDownFun(),
touchDownFun = createInvCellGenericTouchDownFun(inventoryListRebuildFun), // to "unselect" the equipped item and main item grid would "untick" accordingly touchDownFun = createInvCellGenericTouchDownFun(inventoryListRebuildFun), // to "unselect" the equipped item and main item grid would "untick" accordingly
emptyCellIcon = equipPosIcon.get(cellToIcon[it], 1) wheelFun = { _, _, _, _, _, _ -> },
emptyCellIcon = equipPosIcon.get(cellToIcon[it], 1),
) )
} }

View File

@@ -45,6 +45,7 @@ open class UIItemInventoryItemGrid(
val hideSidebar: Boolean = false, val hideSidebar: Boolean = false,
keyDownFun: (GameItem?, Long, Int, Any?, UIItemInventoryCellBase) -> Unit, // Item, Amount, Keycode, extra info, self keyDownFun: (GameItem?, Long, Int, Any?, UIItemInventoryCellBase) -> Unit, // Item, Amount, Keycode, extra info, self
touchDownFun: (GameItem?, Long, Int, Any?, UIItemInventoryCellBase) -> Unit, // Item, Amount, Button, extra info, self touchDownFun: (GameItem?, Long, Int, Any?, UIItemInventoryCellBase) -> Unit, // Item, Amount, Button, extra info, self
wheelFun: (GameItem?, Long, Float, Float, Any?, UIItemInventoryCellBase) -> Unit, // Item, Amount, scroll x, scroll y, extra info, self
protected val useHighlightingManager: Boolean = true, // only used by UIItemCraftingCandidateGrid which addresses buttons directly to set highlighting protected val useHighlightingManager: Boolean = true, // only used by UIItemCraftingCandidateGrid which addresses buttons directly to set highlighting
open protected val highlightEquippedItem: Boolean = true, // for some UIs that only cares about getting equipped slot number but not highlighting open protected val highlightEquippedItem: Boolean = true, // for some UIs that only cares about getting equipped slot number but not highlighting
private val colourTheme: InventoryCellColourTheme = defaultInventoryCellTheme private val colourTheme: InventoryCellColourTheme = defaultInventoryCellTheme
@@ -188,6 +189,7 @@ open class UIItemInventoryItemGrid(
initialY = this.posY + (UIItemInventoryElemSimple.height + listGap) * (it / horizontalCells), initialY = this.posY + (UIItemInventoryElemSimple.height + listGap) * (it / horizontalCells),
keyDownFun = keyDownFun, keyDownFun = keyDownFun,
touchDownFun = touchDownFun, touchDownFun = touchDownFun,
wheelFun = wheelFun,
highlightEquippedItem = highlightEquippedItem, highlightEquippedItem = highlightEquippedItem,
colourTheme = colourTheme colourTheme = colourTheme
) )
@@ -204,6 +206,7 @@ open class UIItemInventoryItemGrid(
width = largeListWidth, width = largeListWidth,
keyDownFun = keyDownFun, keyDownFun = keyDownFun,
touchDownFun = touchDownFun, touchDownFun = touchDownFun,
wheelFun = wheelFun,
highlightEquippedItem = highlightEquippedItem, highlightEquippedItem = highlightEquippedItem,
colourTheme = colourTheme colourTheme = colourTheme
) )
@@ -599,6 +602,8 @@ open class UIItemInventoryItemGrid(
override fun scrolled(amountX: Float, amountY: Float): Boolean { override fun scrolled(amountX: Float, amountY: Float): Boolean {
super.scrolled(amountX, amountY) super.scrolled(amountX, amountY)
items.forEach { if (it.mouseUp) it.scrolled(amountX, amountY) }
// scroll the item list (for now) // scroll the item list (for now)
if (mouseUp) { if (mouseUp) {
scrollItemPage(amountY.toInt()) scrollItemPage(amountY.toInt())

View File

@@ -48,6 +48,7 @@ class UIJukeboxInventory(val parent: UIJukebox) : UICanvas() {
showItemCount = false, showItemCount = false,
keyDownFun = { _, _, _, _, _ -> Unit }, keyDownFun = { _, _, _, _, _ -> Unit },
touchDownFun = { _, _, _, _, _ -> Unit }, touchDownFun = { _, _, _, _, _ -> Unit },
wheelFun = { _, _, _, _, _, _ -> },
) )
}.toTypedArray() }.toTypedArray()

View File

@@ -5,7 +5,7 @@ import com.badlogic.gdx.graphics.OrthographicCamera
import com.badlogic.gdx.graphics.g2d.SpriteBatch import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.colourutil.cieluv_getGradient import net.torvald.colourutil.cieluv_getGradient
import net.torvald.terrarum.* import net.torvald.terrarum.*
import net.torvald.terrarum.gameitems.GameItem import net.torvald.terrarum.App.printdbg
import net.torvald.terrarum.langpack.Lang import net.torvald.terrarum.langpack.Lang
import net.torvald.terrarum.modulebasegame.gameactors.FixtureInventory import net.torvald.terrarum.modulebasegame.gameactors.FixtureInventory
import net.torvald.terrarum.modulebasegame.gameactors.FixtureSmelterBasic import net.torvald.terrarum.modulebasegame.gameactors.FixtureSmelterBasic
@@ -19,7 +19,6 @@ import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
import net.torvald.unicode.getKeycapPC import net.torvald.unicode.getKeycapPC
import net.torvald.unicode.getMouseButton import net.torvald.unicode.getMouseButton
import kotlin.math.roundToInt import kotlin.math.roundToInt
import kotlin.math.roundToLong
/** /**
* Created by minjaesong on 2024-01-29. * Created by minjaesong on 2024-01-29.
@@ -68,6 +67,67 @@ class UISmelterBasic(val smelter: FixtureSmelterBasic) : UICanvas(
itemListUpdateKeepCurrentFilter() itemListUpdateKeepCurrentFilter()
} }
it.itemListWheelFun = { gameItem, _, _, scrollY, _, _ ->
val scrollY = -scrollY
if (gameItem != null) {
val playerInventory = getPlayerInventory()
val addCount1 = scrollY.toLong()
if (clickedOn == 1 && (smelter.oreItem == null || smelter.oreItem!!.itm == gameItem.dynamicID)) {
val itemToUse = smelter.oreItem?.itm ?: gameItem.dynamicID
val addCount2 = scrollY.toLong().coerceIn(
-(playerInventory.searchByID(itemToUse)?.qty ?: 0L),
smelter.oreItem?.qty ?: 0L,
)
// add to the inventory slot
if (smelter.oreItem != null && addCount1 >= 1L) {
getPlayerInventory().add(smelter.oreItem!!.itm, addCount2)
smelter.oreItem!!.qty -= addCount2
}
// remove from the inventory slot
else if (addCount1 <= -1L) {
playerInventory.remove(itemToUse, -addCount2)
if (smelter.oreItem == null)
smelter.oreItem = InventoryPair(itemToUse, -addCount2)
else
smelter.oreItem!!.qty -= addCount2
}
if (smelter.oreItem != null && smelter.oreItem!!.qty == 0L) smelter.oreItem = null
else if (smelter.oreItem != null && smelter.oreItem!!.qty < 0L) throw Error("Item removal count is larger than what was on the slot")
itemListUpdateKeepCurrentFilter()
}
else if (clickedOn == 2 && (smelter.fireboxItem == null || smelter.fireboxItem!!.itm == gameItem.dynamicID)) {
val itemToUse = smelter.fireboxItem?.itm ?: gameItem.dynamicID
val addCount2 = scrollY.toLong().coerceIn(
-(playerInventory.searchByID(itemToUse)?.qty ?: 0L),
smelter.fireboxItem?.qty ?: 0L,
)
// add to the inventory slot
if (smelter.fireboxItem != null && addCount1 >= 1L) {
getPlayerInventory().add(smelter.fireboxItem!!.itm, addCount2)
smelter.fireboxItem!!.qty -= addCount2
}
// remove from the inventory slot
else if (addCount1 <= -1L) {
playerInventory.remove(itemToUse, -addCount2)
if (smelter.fireboxItem == null)
smelter.fireboxItem = InventoryPair(itemToUse, -addCount2)
else
smelter.fireboxItem!!.qty -= addCount2
}
if (smelter.fireboxItem != null && smelter.fireboxItem!!.qty == 0L) smelter.fireboxItem = null
else if (smelter.fireboxItem != null && smelter.fireboxItem!!.qty < 0L) throw Error("Item removal count is larger than what was on the slot")
itemListUpdateKeepCurrentFilter()
}
else {
itemListUpdateKeepCurrentFilter()
}
}
}
} }
fun getPlayerInventory(): FixtureInventory = INGAME.actorNowPlaying!!.inventory fun getPlayerInventory(): FixtureInventory = INGAME.actorNowPlaying!!.inventory
@@ -157,6 +217,33 @@ class UISmelterBasic(val smelter: FixtureSmelterBasic) : UICanvas(
else { else {
itemListUpdateKeepCurrentFilter() itemListUpdateKeepCurrentFilter()
} }
},
wheelFun = { _, _, _, scrollY, _, _ ->
val scrollY = -scrollY
if (clickedOn == 1 && smelter.oreItem != null) {
val playerInventory = getPlayerInventory()
val removeCount1 = scrollY.toLong()
val removeCount2 = scrollY.toLong().coerceIn(
-smelter.oreItem!!.qty,
playerInventory.searchByID(smelter.oreItem!!.itm)?.qty ?: 0L,
)
// add to the slot
if (removeCount1 >= 1L) {
playerInventory.remove(smelter.oreItem!!.itm, removeCount2)
smelter.oreItem!!.qty += removeCount2
}
// remove from the slot
else if (removeCount1 <= -1L) {
getPlayerInventory().add(smelter.oreItem!!.itm, -removeCount2)
smelter.oreItem!!.qty += removeCount2
}
if (smelter.oreItem!!.qty == 0L) smelter.oreItem = null
itemListUpdateKeepCurrentFilter()
}
else {
itemListUpdateKeepCurrentFilter()
}
} }
) )
private val fireboxItemSlot: UIItemInventoryElemSimple = UIItemInventoryElemSimple( private val fireboxItemSlot: UIItemInventoryElemSimple = UIItemInventoryElemSimple(
@@ -189,6 +276,33 @@ class UISmelterBasic(val smelter: FixtureSmelterBasic) : UICanvas(
else { else {
itemListUpdateKeepCurrentFilter() itemListUpdateKeepCurrentFilter()
} }
},
wheelFun = { _, _, _, scrollY, _, _ ->
val scrollY = -scrollY
if (clickedOn == 2 && smelter.fireboxItem != null) {
val playerInventory = getPlayerInventory()
val removeCount1 = scrollY.toLong()
val removeCount2 = scrollY.toLong().coerceIn(
-smelter.fireboxItem!!.qty,
playerInventory.searchByID(smelter.fireboxItem!!.itm)?.qty ?: 0L,
)
// add to the slot
if (removeCount1 >= 1L) {
playerInventory.remove(smelter.fireboxItem!!.itm, removeCount2)
smelter.fireboxItem!!.qty += removeCount2
}
// remove from the slot
else if (removeCount1 <= -1L) {
getPlayerInventory().add(smelter.fireboxItem!!.itm, -removeCount2)
smelter.fireboxItem!!.qty += removeCount2
}
if (smelter.fireboxItem!!.qty == 0L) smelter.fireboxItem = null
itemListUpdateKeepCurrentFilter()
}
else {
itemListUpdateKeepCurrentFilter()
}
} }
) )
private val productItemslot: UIItemInventoryElemSimple = UIItemInventoryElemSimple( private val productItemslot: UIItemInventoryElemSimple = UIItemInventoryElemSimple(
@@ -218,6 +332,27 @@ class UISmelterBasic(val smelter: FixtureSmelterBasic) : UICanvas(
} }
itemListUpdateKeepCurrentFilter() itemListUpdateKeepCurrentFilter()
} }
},
wheelFun = { _, _, _, scrollY, _, _ ->
val scrollY = -scrollY
if (smelter.productItem != null) {
val removeCount1 = scrollY.toLong()
val removeCount2 = scrollY.toLong().coerceIn(
-smelter.productItem!!.qty,
0L,
)
// remove from the slot
if (removeCount1 <= -1L) {
getPlayerInventory().add(smelter.productItem!!.itm, -removeCount2)
smelter.productItem!!.qty += removeCount2
}
if (smelter.productItem!!.qty == 0L) smelter.productItem = null
itemListUpdateKeepCurrentFilter()
}
else {
itemListUpdateKeepCurrentFilter()
}
} }
) )
@@ -309,25 +444,28 @@ class UISmelterBasic(val smelter: FixtureSmelterBasic) : UICanvas(
} }
private val SP = "\u3000" private val SP = "\u3000"
private val ML = getMouseButton(App.getConfigInt("config_mouseprimary"))
private val MR = getMouseButton(App.getConfigInt("config_mousesecondary"))
private val MW = getMouseButton(2)
private val controlHelpForSmelter = listOf( private val controlHelpForSmelter = listOf(
// no slot selected // no slot selected
{ if (App.environment == RunningEnvironment.PC) { if (App.environment == RunningEnvironment.PC)
"${getKeycapPC(ControlPresets.getKey("control_key_inventory"))} ${Lang["GAME_ACTION_CLOSE"]}$SP" + "${getKeycapPC(ControlPresets.getKey("control_key_inventory"))} ${Lang["GAME_ACTION_CLOSE"]}$SP" +
"${getMouseButton(App.getConfigInt("config_mouseprimary"))} ${Lang["GAME_ACTION_SELECT_SLOT"]}" "$ML ${Lang["GAME_ACTION_SELECT_SLOT"]}"
else else
"${App.gamepadLabelStart} ${Lang["GAME_ACTION_CLOSE"]}" }, "${App.gamepadLabelStart} ${Lang["GAME_ACTION_CLOSE"]}" },
// ore slot // ore slot
{ if (App.environment == RunningEnvironment.PC) { if (App.environment == RunningEnvironment.PC)
"${getKeycapPC(ControlPresets.getKey("control_key_inventory"))} ${Lang["GAME_ACTION_CLOSE"]}$SP" + "${getKeycapPC(ControlPresets.getKey("control_key_inventory"))} ${Lang["GAME_ACTION_CLOSE"]}$SP" +
"${getMouseButton(App.getConfigInt("config_mouseprimary"))} ${Lang["GAME_ACTION_TAKE_ALL_CONT"]}$SP" + "$ML ${Lang["GAME_ACTION_TAKE_ALL_CONT"]}$SP" +
"${getMouseButton(App.getConfigInt("config_mousesecondary"))} ${Lang["GAME_ACTION_TAKE_ONE_CONT"]}" "$MW$MR ${Lang["GAME_ACTION_TAKE_ONE_CONT"]}"
else else
"${App.gamepadLabelStart} ${Lang["GAME_ACTION_CLOSE"]}" }, "${App.gamepadLabelStart} ${Lang["GAME_ACTION_CLOSE"]}" },
// firebox slot // firebox slot
{ if (App.environment == RunningEnvironment.PC) { if (App.environment == RunningEnvironment.PC)
"${getKeycapPC(ControlPresets.getKey("control_key_inventory"))} ${Lang["GAME_ACTION_CLOSE"]}$SP" + "${getKeycapPC(ControlPresets.getKey("control_key_inventory"))} ${Lang["GAME_ACTION_CLOSE"]}$SP" +
"${getMouseButton(App.getConfigInt("config_mouseprimary"))} ${Lang["GAME_ACTION_TAKE_ALL_CONT"]}$SP" + "$ML ${Lang["GAME_ACTION_TAKE_ALL_CONT"]}$SP" +
"${getMouseButton(App.getConfigInt("config_mousesecondary"))} ${Lang["GAME_ACTION_TAKE_ONE_CONT"]}" "$MW$MR ${Lang["GAME_ACTION_TAKE_ONE_CONT"]}"
else else
"${App.gamepadLabelStart} ${Lang["GAME_ACTION_CLOSE"]}" } "${App.gamepadLabelStart} ${Lang["GAME_ACTION_CLOSE"]}" }
) )
@@ -337,14 +475,14 @@ class UISmelterBasic(val smelter: FixtureSmelterBasic) : UICanvas(
{ "" }, { "" },
// ore slot // ore slot
{ if (App.environment == RunningEnvironment.PC) { if (App.environment == RunningEnvironment.PC)
"${getMouseButton(App.getConfigInt("config_mouseprimary"))} ${Lang["GAME_ACTION_PUT_ALL_CONT"]}$SP" + "$ML ${Lang["GAME_ACTION_PUT_ALL_CONT"]}$SP" +
"${getMouseButton(App.getConfigInt("config_mousesecondary"))} ${Lang["GAME_ACTION_PUT_ONE_CONT"]}" "$MW$MR ${Lang["GAME_ACTION_PUT_ONE_CONT"]}"
else else
"${App.gamepadLabelStart} ${Lang["GAME_ACTION_CLOSE"]}" }, "${App.gamepadLabelStart} ${Lang["GAME_ACTION_CLOSE"]}" },
// firebox slot // firebox slot
{ if (App.environment == RunningEnvironment.PC) { if (App.environment == RunningEnvironment.PC)
"${getMouseButton(App.getConfigInt("config_mouseprimary"))} ${Lang["GAME_ACTION_PUT_ALL_CONT"]}$SP" + "$ML ${Lang["GAME_ACTION_PUT_ALL_CONT"]}$SP" +
"${getMouseButton(App.getConfigInt("config_mousesecondary"))} ${Lang["GAME_ACTION_PUT_ONE_CONT"]}" "$MW$MR ${Lang["GAME_ACTION_PUT_ONE_CONT"]}"
else else
"${App.gamepadLabelStart} ${Lang["GAME_ACTION_CLOSE"]}" } "${App.gamepadLabelStart} ${Lang["GAME_ACTION_CLOSE"]}" }
) )
@@ -354,14 +492,14 @@ class UISmelterBasic(val smelter: FixtureSmelterBasic) : UICanvas(
{ "" }, { "" },
// ore slot // ore slot
{ if (App.environment == RunningEnvironment.PC) { if (App.environment == RunningEnvironment.PC)
"${getMouseButton(App.getConfigInt("config_mouseprimary"))} ${Lang["GAME_ACTION_PUT_ALL"]}$SP" + "$ML ${Lang["GAME_ACTION_PUT_ALL"]}$SP" +
"${getMouseButton(App.getConfigInt("config_mousesecondary"))} ${Lang["GAME_ACTION_PUT_ONE"]}" "$MW$MR ${Lang["GAME_ACTION_PUT_ONE"]}"
else else
"${App.gamepadLabelStart} ${Lang["GAME_ACTION_CLOSE"]}" }, "${App.gamepadLabelStart} ${Lang["GAME_ACTION_CLOSE"]}" },
// firebox slot // firebox slot
{ if (App.environment == RunningEnvironment.PC) { if (App.environment == RunningEnvironment.PC)
"${getMouseButton(App.getConfigInt("config_mouseprimary"))} ${Lang["GAME_ACTION_PUT_ALL"]}$SP" + "$ML ${Lang["GAME_ACTION_PUT_ALL"]}$SP" +
"${getMouseButton(App.getConfigInt("config_mousesecondary"))} ${Lang["GAME_ACTION_PUT_ONE"]}" "$MW$MR ${Lang["GAME_ACTION_PUT_ONE"]}"
else else
"${App.gamepadLabelStart} ${Lang["GAME_ACTION_CLOSE"]}" } "${App.gamepadLabelStart} ${Lang["GAME_ACTION_CLOSE"]}" }
) )

View File

@@ -206,25 +206,28 @@ internal class UIStorageChest : UICanvas(
private val cellsWidth = (UIItemInventoryItemGrid.listGap + UIItemInventoryElemWide.height) * 6 - UIItemInventoryItemGrid.listGap private val cellsWidth = (UIItemInventoryItemGrid.listGap + UIItemInventoryElemWide.height) * 6 - UIItemInventoryItemGrid.listGap
private val SP = "\u3000" private val SP = "\u3000"
private val ML = getMouseButton(App.getConfigInt("config_mouseprimary"))
private val MR = getMouseButton(App.getConfigInt("config_mousesecondary"))
private val MW = getMouseButton(2)
private val controlHelpLeft: String private val controlHelpLeft: String
get() = if (App.environment == RunningEnvironment.PC) get() = if (App.environment == RunningEnvironment.PC)
"${getKeycapPC(ControlPresets.getKey("control_key_inventory"))} ${Lang["GAME_ACTION_CLOSE"]}$SP" + "${getKeycapPC(ControlPresets.getKey("control_key_inventory"))} ${Lang["GAME_ACTION_CLOSE"]}$SP" +
"${getMouseButton(App.getConfigInt("config_mouseprimary"))} ${Lang["GAME_ACTION_TAKE_ALL_CONT"]}$SP" + "$ML ${Lang["GAME_ACTION_TAKE_ALL_CONT"]}$SP" +
"${getMouseButton(App.getConfigInt("config_mousesecondary"))} ${Lang["GAME_ACTION_TAKE_ONE_CONT"]}" "$MW$MR ${Lang["GAME_ACTION_TAKE_ONE_CONT"]}"
else else
"${App.gamepadLabelStart} ${Lang["GAME_ACTION_CLOSE"]}" "${App.gamepadLabelStart} ${Lang["GAME_ACTION_CLOSE"]}"
private val controlHelpRight: String private val controlHelpRight: String
get() = if (App.environment == RunningEnvironment.PC) get() = if (App.environment == RunningEnvironment.PC)
"${getMouseButton(App.getConfigInt("config_mouseprimary"))} ${Lang["GAME_ACTION_PUT_ALL_CONT"]}$SP" + "$ML ${Lang["GAME_ACTION_PUT_ALL_CONT"]}$SP" +
"${getMouseButton(App.getConfigInt("config_mousesecondary"))} ${Lang["GAME_ACTION_PUT_ONE_CONT"]}" "$MW$MR ${Lang["GAME_ACTION_PUT_ONE_CONT"]}"
else else
"${App.gamepadLabelStart} ${Lang["GAME_ACTION_CLOSE"]}" "${App.gamepadLabelStart} ${Lang["GAME_ACTION_CLOSE"]}"
private val controlHelpRightTwoRows: String private val controlHelpRightTwoRows: String
get() = if (App.environment == RunningEnvironment.PC) get() = if (App.environment == RunningEnvironment.PC)
"${getMouseButton(App.getConfigInt("config_mouseprimary"))} ${Lang["GAME_ACTION_PUT_ALL"]}$SP" + "$ML ${Lang["GAME_ACTION_PUT_ALL"]}$SP" +
"${getMouseButton(App.getConfigInt("config_mousesecondary"))} ${Lang["GAME_ACTION_PUT_ONE"]}" "$MW$MR ${Lang["GAME_ACTION_PUT_ONE"]}"
else else
"${App.gamepadLabelStart} ${Lang["GAME_ACTION_CLOSE"]}" "${App.gamepadLabelStart} ${Lang["GAME_ACTION_CLOSE"]}"

View File

@@ -46,6 +46,9 @@ class UITemplateHalfInventory(
internal var itemListTouchDownFun = { gameItem: GameItem?, amount: Long, mouseButton: Int, itemExtraInfo: Any?, theButton: UIItemInventoryCellBase -> internal var itemListTouchDownFun = { gameItem: GameItem?, amount: Long, mouseButton: Int, itemExtraInfo: Any?, theButton: UIItemInventoryCellBase ->
/* crickets */ /* crickets */
} }
internal var itemListWheelFun = { gameItem: GameItem?, amount: Long, scrollX: Float, scrollY: Float, itemExtraInfo: Any?, theButton: UIItemInventoryCellBase ->
/* crickets */
}
init { init {
itemList = UIItemInventoryItemGrid( itemList = UIItemInventoryItemGrid(
@@ -58,7 +61,8 @@ class UITemplateHalfInventory(
drawWallet = false, drawWallet = false,
highlightEquippedItem = false, highlightEquippedItem = false,
keyDownFun = { a, b, c, d, e -> itemListKeyDownFun(a, b, c, d, e) }, keyDownFun = { a, b, c, d, e -> itemListKeyDownFun(a, b, c, d, e) },
touchDownFun = { a, b, c, d, e -> itemListTouchDownFun.invoke(a, b, c, d, e) } touchDownFun = { a, b, c, d, e -> itemListTouchDownFun.invoke(a, b, c, d, e) },
wheelFun = { a, b, c, d, e, f -> itemListWheelFun.invoke(a, b, c, d, e, f)}
) )
// make grid mode buttons work together // make grid mode buttons work together
// itemListPlayer.gridModeButtons[0].clickOnceListener = { _,_ -> setCompact(false) } // itemListPlayer.gridModeButtons[0].clickOnceListener = { _,_ -> setCompact(false) }

View File

@@ -96,6 +96,7 @@ class UIWorldPortalCargo(val full: UIWorldPortal) : UICanvas(), HasInventory {
drawScrollOnRightside = false, drawScrollOnRightside = false,
drawWallet = false, drawWallet = false,
keyDownFun = { _, _, _, _, _ -> Unit }, keyDownFun = { _, _, _, _, _ -> Unit },
wheelFun = { _, _, _, _, _, _ -> },
touchDownFun = { gameItem, amount, button, _, _ -> touchDownFun = { gameItem, amount, button, _, _ ->
if (button == App.getConfigInt("config_mouseprimary")) { if (button == App.getConfigInt("config_mouseprimary")) {
if (gameItem != null) { if (gameItem != null) {
@@ -118,6 +119,7 @@ class UIWorldPortalCargo(val full: UIWorldPortal) : UICanvas(), HasInventory {
drawScrollOnRightside = true, drawScrollOnRightside = true,
drawWallet = false, drawWallet = false,
keyDownFun = { _, _, _, _, _ -> Unit }, keyDownFun = { _, _, _, _, _ -> Unit },
wheelFun = { _, _, _, _, _, _ -> },
touchDownFun = { gameItem, amount, button, _, _ -> touchDownFun = { gameItem, amount, button, _, _ ->
if (button == App.getConfigInt("config_mouseprimary")) { if (button == App.getConfigInt("config_mouseprimary")) {
if (gameItem != null) { if (gameItem != null) {

View File

@@ -29,6 +29,7 @@ class UIItemInventoryElemSimple(
val drawBackOnNull: Boolean = true, val drawBackOnNull: Boolean = true,
keyDownFun: (GameItem?, Long, Int, Any?, UIItemInventoryCellBase) -> Unit, // Item, Amount, Keycode, extra info, self keyDownFun: (GameItem?, Long, Int, Any?, UIItemInventoryCellBase) -> Unit, // Item, Amount, Keycode, extra info, self
touchDownFun: (GameItem?, Long, Int, Any?, UIItemInventoryCellBase) -> Unit, // Item, Amount, Button, extra info, self touchDownFun: (GameItem?, Long, Int, Any?, UIItemInventoryCellBase) -> Unit, // Item, Amount, Button, extra info, self
wheelFun: (GameItem?, Long, Float, Float, Any?, UIItemInventoryCellBase) -> Unit, // Item, Amount, scroll x, scroll y, extra info, self
extraInfo: Any? = null, extraInfo: Any? = null,
highlightEquippedItem: Boolean = true, // for some UIs that only cares about getting equipped slot number but not highlighting highlightEquippedItem: Boolean = true, // for some UIs that only cares about getting equipped slot number but not highlighting
colourTheme: InventoryCellColourTheme = defaultInventoryCellTheme, colourTheme: InventoryCellColourTheme = defaultInventoryCellTheme,
@@ -36,7 +37,7 @@ class UIItemInventoryElemSimple(
var emptyCellIcon: TextureRegion? = null, // icon to draw when the cell is empty var emptyCellIcon: TextureRegion? = null, // icon to draw when the cell is empty
var emptyCellIconColour: Color = Color(0xdddddd7f.toInt()), var emptyCellIconColour: Color = Color(0xdddddd7f.toInt()),
val updateOnNull: Boolean = false, val updateOnNull: Boolean = false,
) : UIItemInventoryCellBase(parentUI, initialX, initialY, item, amount, itemImage, quickslot, equippedSlot, keyDownFun, touchDownFun, extraInfo, highlightEquippedItem, colourTheme) { ) : UIItemInventoryCellBase(parentUI, initialX, initialY, item, amount, itemImage, quickslot, equippedSlot, keyDownFun, touchDownFun, wheelFun, extraInfo, highlightEquippedItem, colourTheme) {
companion object { companion object {
val height = UIItemInventoryElemWide.height val height = UIItemInventoryElemWide.height

View File

@@ -33,11 +33,12 @@ class UIItemInventoryElemWide(
val drawBackOnNull: Boolean = true, val drawBackOnNull: Boolean = true,
keyDownFun: (GameItem?, Long, Int, Any?, UIItemInventoryCellBase) -> Unit, // Item, Amount, Keycode, extra info, self keyDownFun: (GameItem?, Long, Int, Any?, UIItemInventoryCellBase) -> Unit, // Item, Amount, Keycode, extra info, self
touchDownFun: (GameItem?, Long, Int, Any?, UIItemInventoryCellBase) -> Unit, // Item, Amount, Button, extra info, self touchDownFun: (GameItem?, Long, Int, Any?, UIItemInventoryCellBase) -> Unit, // Item, Amount, Button, extra info, self
wheelFun: (GameItem?, Long, Float, Float, Any?, UIItemInventoryCellBase) -> Unit, // Item, Amount, scroll x, scroll y, extra info, self
extraInfo: Any? = null, extraInfo: Any? = null,
highlightEquippedItem: Boolean = true, // for some UIs that only cares about getting equipped slot number but not highlighting highlightEquippedItem: Boolean = true, // for some UIs that only cares about getting equipped slot number but not highlighting
colourTheme: InventoryCellColourTheme = UIItemInventoryCellCommonRes.defaultInventoryCellTheme, colourTheme: InventoryCellColourTheme = UIItemInventoryCellCommonRes.defaultInventoryCellTheme,
var showItemCount: Boolean = true, var showItemCount: Boolean = true,
) : UIItemInventoryCellBase(parentUI, initialX, initialY, item, amount, itemImage, quickslot, equippedSlot, keyDownFun, touchDownFun, extraInfo, highlightEquippedItem, colourTheme) { ) : UIItemInventoryCellBase(parentUI, initialX, initialY, item, amount, itemImage, quickslot, equippedSlot, keyDownFun, touchDownFun, wheelFun, extraInfo, highlightEquippedItem, colourTheme) {
companion object { companion object {
val height = 48 val height = 48