mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-06 08:38:30 +09:00
smelter: scroll wheel to operate the item slots
This commit is contained in:
@@ -40,11 +40,11 @@ class ActorInventory() : FixtureInventory() {
|
||||
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!
|
||||
* e.g. re-assign after this operation */
|
||||
override fun remove(item: GameItem, count: Long) {
|
||||
super.remove(item, count) { existingItem ->
|
||||
override fun remove(item: GameItem, count: Long): Long {
|
||||
return super.remove(item, count) { existingItem ->
|
||||
// unequip, if applicable
|
||||
actor.unequipItem(existingItem.itm)
|
||||
// also unequip on the quickslot
|
||||
|
||||
@@ -136,19 +136,23 @@ open class FixtureInventory() {
|
||||
open fun remove(itemID: ItemID, count: Long, unequipFun: (InventoryPair) -> Unit) =
|
||||
remove(ItemCodex[itemID]!!, count, unequipFun)
|
||||
/** Will check existence of the item using its Dynamic ID; careful with command order!
|
||||
* e.g. re-assign after this operation */
|
||||
open fun remove(item: GameItem, count: Long = 1, unequipFun: (InventoryPair) -> Unit) {
|
||||
* e.g. re-assign after this operation
|
||||
*
|
||||
* @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")
|
||||
|
||||
if (count == 0L)
|
||||
// throw IllegalArgumentException("[${this.javaClass.canonicalName}] Item count is zero.")
|
||||
return
|
||||
return 0L
|
||||
if (count < 0L)
|
||||
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.")
|
||||
|
||||
|
||||
var delta = 0L
|
||||
|
||||
val existingItem = searchByID(item.dynamicID)
|
||||
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.")
|
||||
}
|
||||
else*/ if (newCount > 0) {
|
||||
delta = count
|
||||
// decrement count
|
||||
existingItem.qty = newCount
|
||||
}
|
||||
else {
|
||||
delta = existingItem.qty
|
||||
// unequip must be done before the entry removal
|
||||
unequipFun(existingItem)
|
||||
// depleted item; remove entry from inventory
|
||||
@@ -170,11 +176,14 @@ open class FixtureInventory() {
|
||||
}
|
||||
else {
|
||||
// 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()
|
||||
|
||||
return delta
|
||||
}
|
||||
|
||||
open fun clear(): List<InventoryPair> {
|
||||
|
||||
@@ -133,6 +133,7 @@ class UICrafting(val full: UIInventoryFull?) : UICanvas(
|
||||
cellHighlightSubCol = Toolkit.Theme.COL_INACTIVE
|
||||
),
|
||||
keyDownFun = { _, _, _, _, _ -> },
|
||||
wheelFun = { _, _, _, _, _, _ -> },
|
||||
touchDownFun = { gameItem, amount, _, _, _ -> gameItem?.let { gameItem ->
|
||||
// if the item is craftable one, load its recipe instead
|
||||
CraftingRecipeCodex.getRecipesFor(gameItem.originalID)?.let { recipes ->
|
||||
|
||||
@@ -93,7 +93,8 @@ internal class UIInventoryCells(
|
||||
INVENTORY_CELLS_OFFSET_Y(),
|
||||
CELLS_HOR, CELLS_VRT,
|
||||
keyDownFun = createInvCellGenericKeyDownFun(),
|
||||
touchDownFun = createInvCellGenericTouchDownFun { rebuildList() }
|
||||
touchDownFun = createInvCellGenericTouchDownFun { rebuildList() },
|
||||
wheelFun = { _, _, _, _, _, _ -> },
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@ class UIItemCraftingCandidateGrid(
|
||||
hideSidebar = false,
|
||||
keyDownFun = keyDownFun,
|
||||
touchDownFun = touchDownFun,
|
||||
wheelFun = { _, _, _, _, _, _ -> },
|
||||
useHighlightingManager = false
|
||||
) {
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@ abstract class UIItemInventoryCellBase(
|
||||
open var equippedSlot: Int? = null,
|
||||
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 wheelFun: (GameItem?, Long, Float, Float, Any?, UIItemInventoryCellBase) -> Unit, // Item, Amount, scroll x, scroll y, extra info, self
|
||||
open var extraInfo: Any?,
|
||||
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,
|
||||
@@ -70,6 +71,14 @@ abstract class UIItemInventoryCellBase(
|
||||
}
|
||||
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 {
|
||||
|
||||
@@ -56,7 +56,8 @@ class UIItemInventoryEquippedView(
|
||||
drawBackOnNull = true,
|
||||
keyDownFun = createInvCellGenericKeyDownFun(),
|
||||
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),
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -45,6 +45,7 @@ open class UIItemInventoryItemGrid(
|
||||
val hideSidebar: Boolean = false,
|
||||
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
|
||||
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
|
||||
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
|
||||
@@ -188,6 +189,7 @@ open class UIItemInventoryItemGrid(
|
||||
initialY = this.posY + (UIItemInventoryElemSimple.height + listGap) * (it / horizontalCells),
|
||||
keyDownFun = keyDownFun,
|
||||
touchDownFun = touchDownFun,
|
||||
wheelFun = wheelFun,
|
||||
highlightEquippedItem = highlightEquippedItem,
|
||||
colourTheme = colourTheme
|
||||
)
|
||||
@@ -204,6 +206,7 @@ open class UIItemInventoryItemGrid(
|
||||
width = largeListWidth,
|
||||
keyDownFun = keyDownFun,
|
||||
touchDownFun = touchDownFun,
|
||||
wheelFun = wheelFun,
|
||||
highlightEquippedItem = highlightEquippedItem,
|
||||
colourTheme = colourTheme
|
||||
)
|
||||
@@ -599,6 +602,8 @@ open class UIItemInventoryItemGrid(
|
||||
override fun scrolled(amountX: Float, amountY: Float): Boolean {
|
||||
super.scrolled(amountX, amountY)
|
||||
|
||||
items.forEach { if (it.mouseUp) it.scrolled(amountX, amountY) }
|
||||
|
||||
// scroll the item list (for now)
|
||||
if (mouseUp) {
|
||||
scrollItemPage(amountY.toInt())
|
||||
|
||||
@@ -48,6 +48,7 @@ class UIJukeboxInventory(val parent: UIJukebox) : UICanvas() {
|
||||
showItemCount = false,
|
||||
keyDownFun = { _, _, _, _, _ -> Unit },
|
||||
touchDownFun = { _, _, _, _, _ -> Unit },
|
||||
wheelFun = { _, _, _, _, _, _ -> },
|
||||
)
|
||||
}.toTypedArray()
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import com.badlogic.gdx.graphics.OrthographicCamera
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import net.torvald.colourutil.cieluv_getGradient
|
||||
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.modulebasegame.gameactors.FixtureInventory
|
||||
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.getMouseButton
|
||||
import kotlin.math.roundToInt
|
||||
import kotlin.math.roundToLong
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 2024-01-29.
|
||||
@@ -68,6 +67,67 @@ class UISmelterBasic(val smelter: FixtureSmelterBasic) : UICanvas(
|
||||
|
||||
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
|
||||
@@ -157,6 +217,33 @@ class UISmelterBasic(val smelter: FixtureSmelterBasic) : UICanvas(
|
||||
else {
|
||||
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(
|
||||
@@ -189,6 +276,33 @@ class UISmelterBasic(val smelter: FixtureSmelterBasic) : UICanvas(
|
||||
else {
|
||||
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(
|
||||
@@ -218,6 +332,27 @@ class UISmelterBasic(val smelter: FixtureSmelterBasic) : UICanvas(
|
||||
}
|
||||
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 ML = getMouseButton(App.getConfigInt("config_mouseprimary"))
|
||||
private val MR = getMouseButton(App.getConfigInt("config_mousesecondary"))
|
||||
private val MW = getMouseButton(2)
|
||||
private val controlHelpForSmelter = listOf(
|
||||
// no slot selected
|
||||
{ if (App.environment == RunningEnvironment.PC)
|
||||
"${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
|
||||
"${App.gamepadLabelStart} ${Lang["GAME_ACTION_CLOSE"]}" },
|
||||
// ore slot
|
||||
{ if (App.environment == RunningEnvironment.PC)
|
||||
"${getKeycapPC(ControlPresets.getKey("control_key_inventory"))} ${Lang["GAME_ACTION_CLOSE"]}$SP" +
|
||||
"${getMouseButton(App.getConfigInt("config_mouseprimary"))} ${Lang["GAME_ACTION_TAKE_ALL_CONT"]}$SP" +
|
||||
"${getMouseButton(App.getConfigInt("config_mousesecondary"))} ${Lang["GAME_ACTION_TAKE_ONE_CONT"]}"
|
||||
"$ML ${Lang["GAME_ACTION_TAKE_ALL_CONT"]}$SP" +
|
||||
"$MW$MR ${Lang["GAME_ACTION_TAKE_ONE_CONT"]}"
|
||||
else
|
||||
"${App.gamepadLabelStart} ${Lang["GAME_ACTION_CLOSE"]}" },
|
||||
// firebox slot
|
||||
{ if (App.environment == RunningEnvironment.PC)
|
||||
"${getKeycapPC(ControlPresets.getKey("control_key_inventory"))} ${Lang["GAME_ACTION_CLOSE"]}$SP" +
|
||||
"${getMouseButton(App.getConfigInt("config_mouseprimary"))} ${Lang["GAME_ACTION_TAKE_ALL_CONT"]}$SP" +
|
||||
"${getMouseButton(App.getConfigInt("config_mousesecondary"))} ${Lang["GAME_ACTION_TAKE_ONE_CONT"]}"
|
||||
"$ML ${Lang["GAME_ACTION_TAKE_ALL_CONT"]}$SP" +
|
||||
"$MW$MR ${Lang["GAME_ACTION_TAKE_ONE_CONT"]}"
|
||||
else
|
||||
"${App.gamepadLabelStart} ${Lang["GAME_ACTION_CLOSE"]}" }
|
||||
)
|
||||
@@ -337,14 +475,14 @@ class UISmelterBasic(val smelter: FixtureSmelterBasic) : UICanvas(
|
||||
{ "" },
|
||||
// ore slot
|
||||
{ if (App.environment == RunningEnvironment.PC)
|
||||
"${getMouseButton(App.getConfigInt("config_mouseprimary"))} ${Lang["GAME_ACTION_PUT_ALL_CONT"]}$SP" +
|
||||
"${getMouseButton(App.getConfigInt("config_mousesecondary"))} ${Lang["GAME_ACTION_PUT_ONE_CONT"]}"
|
||||
"$ML ${Lang["GAME_ACTION_PUT_ALL_CONT"]}$SP" +
|
||||
"$MW$MR ${Lang["GAME_ACTION_PUT_ONE_CONT"]}"
|
||||
else
|
||||
"${App.gamepadLabelStart} ${Lang["GAME_ACTION_CLOSE"]}" },
|
||||
// firebox slot
|
||||
{ if (App.environment == RunningEnvironment.PC)
|
||||
"${getMouseButton(App.getConfigInt("config_mouseprimary"))} ${Lang["GAME_ACTION_PUT_ALL_CONT"]}$SP" +
|
||||
"${getMouseButton(App.getConfigInt("config_mousesecondary"))} ${Lang["GAME_ACTION_PUT_ONE_CONT"]}"
|
||||
"$ML ${Lang["GAME_ACTION_PUT_ALL_CONT"]}$SP" +
|
||||
"$MW$MR ${Lang["GAME_ACTION_PUT_ONE_CONT"]}"
|
||||
else
|
||||
"${App.gamepadLabelStart} ${Lang["GAME_ACTION_CLOSE"]}" }
|
||||
)
|
||||
@@ -354,14 +492,14 @@ class UISmelterBasic(val smelter: FixtureSmelterBasic) : UICanvas(
|
||||
{ "" },
|
||||
// ore slot
|
||||
{ if (App.environment == RunningEnvironment.PC)
|
||||
"${getMouseButton(App.getConfigInt("config_mouseprimary"))} ${Lang["GAME_ACTION_PUT_ALL"]}$SP" +
|
||||
"${getMouseButton(App.getConfigInt("config_mousesecondary"))} ${Lang["GAME_ACTION_PUT_ONE"]}"
|
||||
"$ML ${Lang["GAME_ACTION_PUT_ALL"]}$SP" +
|
||||
"$MW$MR ${Lang["GAME_ACTION_PUT_ONE"]}"
|
||||
else
|
||||
"${App.gamepadLabelStart} ${Lang["GAME_ACTION_CLOSE"]}" },
|
||||
// firebox slot
|
||||
{ if (App.environment == RunningEnvironment.PC)
|
||||
"${getMouseButton(App.getConfigInt("config_mouseprimary"))} ${Lang["GAME_ACTION_PUT_ALL"]}$SP" +
|
||||
"${getMouseButton(App.getConfigInt("config_mousesecondary"))} ${Lang["GAME_ACTION_PUT_ONE"]}"
|
||||
"$ML ${Lang["GAME_ACTION_PUT_ALL"]}$SP" +
|
||||
"$MW$MR ${Lang["GAME_ACTION_PUT_ONE"]}"
|
||||
else
|
||||
"${App.gamepadLabelStart} ${Lang["GAME_ACTION_CLOSE"]}" }
|
||||
)
|
||||
|
||||
@@ -206,25 +206,28 @@ internal class UIStorageChest : UICanvas(
|
||||
private val cellsWidth = (UIItemInventoryItemGrid.listGap + UIItemInventoryElemWide.height) * 6 - UIItemInventoryItemGrid.listGap
|
||||
|
||||
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
|
||||
get() = if (App.environment == RunningEnvironment.PC)
|
||||
"${getKeycapPC(ControlPresets.getKey("control_key_inventory"))} ${Lang["GAME_ACTION_CLOSE"]}$SP" +
|
||||
"${getMouseButton(App.getConfigInt("config_mouseprimary"))} ${Lang["GAME_ACTION_TAKE_ALL_CONT"]}$SP" +
|
||||
"${getMouseButton(App.getConfigInt("config_mousesecondary"))} ${Lang["GAME_ACTION_TAKE_ONE_CONT"]}"
|
||||
"$ML ${Lang["GAME_ACTION_TAKE_ALL_CONT"]}$SP" +
|
||||
"$MW$MR ${Lang["GAME_ACTION_TAKE_ONE_CONT"]}"
|
||||
else
|
||||
"${App.gamepadLabelStart} ${Lang["GAME_ACTION_CLOSE"]}"
|
||||
|
||||
private val controlHelpRight: String
|
||||
get() = if (App.environment == RunningEnvironment.PC)
|
||||
"${getMouseButton(App.getConfigInt("config_mouseprimary"))} ${Lang["GAME_ACTION_PUT_ALL_CONT"]}$SP" +
|
||||
"${getMouseButton(App.getConfigInt("config_mousesecondary"))} ${Lang["GAME_ACTION_PUT_ONE_CONT"]}"
|
||||
"$ML ${Lang["GAME_ACTION_PUT_ALL_CONT"]}$SP" +
|
||||
"$MW$MR ${Lang["GAME_ACTION_PUT_ONE_CONT"]}"
|
||||
else
|
||||
"${App.gamepadLabelStart} ${Lang["GAME_ACTION_CLOSE"]}"
|
||||
|
||||
private val controlHelpRightTwoRows: String
|
||||
get() = if (App.environment == RunningEnvironment.PC)
|
||||
"${getMouseButton(App.getConfigInt("config_mouseprimary"))} ${Lang["GAME_ACTION_PUT_ALL"]}$SP" +
|
||||
"${getMouseButton(App.getConfigInt("config_mousesecondary"))} ${Lang["GAME_ACTION_PUT_ONE"]}"
|
||||
"$ML ${Lang["GAME_ACTION_PUT_ALL"]}$SP" +
|
||||
"$MW$MR ${Lang["GAME_ACTION_PUT_ONE"]}"
|
||||
else
|
||||
"${App.gamepadLabelStart} ${Lang["GAME_ACTION_CLOSE"]}"
|
||||
|
||||
|
||||
@@ -46,6 +46,9 @@ class UITemplateHalfInventory(
|
||||
internal var itemListTouchDownFun = { gameItem: GameItem?, amount: Long, mouseButton: Int, itemExtraInfo: Any?, theButton: UIItemInventoryCellBase ->
|
||||
/* crickets */
|
||||
}
|
||||
internal var itemListWheelFun = { gameItem: GameItem?, amount: Long, scrollX: Float, scrollY: Float, itemExtraInfo: Any?, theButton: UIItemInventoryCellBase ->
|
||||
/* crickets */
|
||||
}
|
||||
|
||||
init {
|
||||
itemList = UIItemInventoryItemGrid(
|
||||
@@ -58,7 +61,8 @@ class UITemplateHalfInventory(
|
||||
drawWallet = false,
|
||||
highlightEquippedItem = false,
|
||||
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
|
||||
// itemListPlayer.gridModeButtons[0].clickOnceListener = { _,_ -> setCompact(false) }
|
||||
|
||||
@@ -96,6 +96,7 @@ class UIWorldPortalCargo(val full: UIWorldPortal) : UICanvas(), HasInventory {
|
||||
drawScrollOnRightside = false,
|
||||
drawWallet = false,
|
||||
keyDownFun = { _, _, _, _, _ -> Unit },
|
||||
wheelFun = { _, _, _, _, _, _ -> },
|
||||
touchDownFun = { gameItem, amount, button, _, _ ->
|
||||
if (button == App.getConfigInt("config_mouseprimary")) {
|
||||
if (gameItem != null) {
|
||||
@@ -118,6 +119,7 @@ class UIWorldPortalCargo(val full: UIWorldPortal) : UICanvas(), HasInventory {
|
||||
drawScrollOnRightside = true,
|
||||
drawWallet = false,
|
||||
keyDownFun = { _, _, _, _, _ -> Unit },
|
||||
wheelFun = { _, _, _, _, _, _ -> },
|
||||
touchDownFun = { gameItem, amount, button, _, _ ->
|
||||
if (button == App.getConfigInt("config_mouseprimary")) {
|
||||
if (gameItem != null) {
|
||||
|
||||
@@ -29,6 +29,7 @@ class UIItemInventoryElemSimple(
|
||||
val drawBackOnNull: Boolean = true,
|
||||
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
|
||||
wheelFun: (GameItem?, Long, Float, Float, Any?, UIItemInventoryCellBase) -> Unit, // Item, Amount, scroll x, scroll y, extra info, self
|
||||
extraInfo: Any? = null,
|
||||
highlightEquippedItem: Boolean = true, // for some UIs that only cares about getting equipped slot number but not highlighting
|
||||
colourTheme: InventoryCellColourTheme = defaultInventoryCellTheme,
|
||||
@@ -36,7 +37,7 @@ class UIItemInventoryElemSimple(
|
||||
var emptyCellIcon: TextureRegion? = null, // icon to draw when the cell is empty
|
||||
var emptyCellIconColour: Color = Color(0xdddddd7f.toInt()),
|
||||
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 {
|
||||
val height = UIItemInventoryElemWide.height
|
||||
|
||||
@@ -33,11 +33,12 @@ class UIItemInventoryElemWide(
|
||||
val drawBackOnNull: Boolean = true,
|
||||
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
|
||||
wheelFun: (GameItem?, Long, Float, Float, Any?, UIItemInventoryCellBase) -> Unit, // Item, Amount, scroll x, scroll y, extra info, self
|
||||
extraInfo: Any? = null,
|
||||
highlightEquippedItem: Boolean = true, // for some UIs that only cares about getting equipped slot number but not highlighting
|
||||
colourTheme: InventoryCellColourTheme = UIItemInventoryCellCommonRes.defaultInventoryCellTheme,
|
||||
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 {
|
||||
val height = 48
|
||||
|
||||
Reference in New Issue
Block a user