mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-10 18:44:05 +09:00
jukebox: ui item number fix, not accepting disc already there
This commit is contained in:
@@ -35,9 +35,6 @@ class Convolv(ir: File, val crossfeed: Float, gain: Float = 1f / 256f): Terrarum
|
|||||||
|
|
||||||
var processingSpeed = 1f; private set
|
var processingSpeed = 1f; private set
|
||||||
|
|
||||||
private val partSizes: IntArray
|
|
||||||
private val partOffsets: IntArray
|
|
||||||
|
|
||||||
init {
|
init {
|
||||||
if (!ir.exists()) {
|
if (!ir.exists()) {
|
||||||
throw IllegalArgumentException("Impulse Response file '${ir.path}' does not exist.")
|
throw IllegalArgumentException("Impulse Response file '${ir.path}' does not exist.")
|
||||||
@@ -72,20 +69,6 @@ class Convolv(ir: File, val crossfeed: Float, gain: Float = 1f / 256f): Terrarum
|
|||||||
convFFT = Array(2) {
|
convFFT = Array(2) {
|
||||||
FFT.fft(conv[it])
|
FFT.fft(conv[it])
|
||||||
}
|
}
|
||||||
|
|
||||||
// println("convFFT Length = ${convFFT[0].size}")
|
|
||||||
|
|
||||||
|
|
||||||
// fill up part* dictionary
|
|
||||||
// define "master" array
|
|
||||||
var c = AUDIO_BUFFER_SIZE
|
|
||||||
val master0 = arrayListOf(c)
|
|
||||||
while (c < fftLen) {
|
|
||||||
master0.add(c)
|
|
||||||
c *= 2
|
|
||||||
}
|
|
||||||
partSizes = master0.toIntArray()
|
|
||||||
partOffsets = master0.toIntArray().also { it[0] = 0 }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private val realtime = (BLOCKSIZE / TerrarumAudioMixerTrack.SAMPLING_RATEF * 1000000000L)
|
private val realtime = (BLOCKSIZE / TerrarumAudioMixerTrack.SAMPLING_RATEF * 1000000000L)
|
||||||
|
|||||||
@@ -70,8 +70,6 @@ class FixtureJukebox : Electric {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private var waitAkku = 0f
|
|
||||||
|
|
||||||
override val canBeDespawned: Boolean
|
override val canBeDespawned: Boolean
|
||||||
get() = discInventory.isEmpty()
|
get() = discInventory.isEmpty()
|
||||||
|
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ class UIJukeboxInventory(val parent: UIJukebox) : UICanvas() {
|
|||||||
UIItemInventoryElemWide(this,
|
UIItemInventoryElemWide(this,
|
||||||
thisOffsetX, thisOffsetY + (UIItemInventoryElemSimple.height + UIItemInventoryItemGrid.listGap) * index,
|
thisOffsetX, thisOffsetY + (UIItemInventoryElemSimple.height + UIItemInventoryItemGrid.listGap) * index,
|
||||||
6 * UIItemInventoryElemSimple.height + 5 * UIItemInventoryItemGrid.listGap,
|
6 * UIItemInventoryElemSimple.height + 5 * UIItemInventoryItemGrid.listGap,
|
||||||
|
showItemCount = false,
|
||||||
keyDownFun = { _, _, _, _, _ -> Unit },
|
keyDownFun = { _, _, _, _, _ -> Unit },
|
||||||
touchDownFun = { _, _, _, _, _ -> Unit },
|
touchDownFun = { _, _, _, _, _ -> Unit },
|
||||||
)
|
)
|
||||||
@@ -72,7 +73,8 @@ class UIJukeboxInventory(val parent: UIJukebox) : UICanvas() {
|
|||||||
private val playerInventoryUI = UITemplateHalfInventory(this, false).also {
|
private val playerInventoryUI = UITemplateHalfInventory(this, false).also {
|
||||||
it.itemListTouchDownFun = { gameItem, _, _, _, _ ->
|
it.itemListTouchDownFun = { gameItem, _, _, _, _ ->
|
||||||
|
|
||||||
if (operatedByTheInstaller && parent.discInventory.size < SLOT_SIZE && gameItem != null) {
|
// accept disc but not duplicates
|
||||||
|
if (operatedByTheInstaller && parent.discInventory.size < SLOT_SIZE && gameItem != null && !parent.discInventory.contains(gameItem.dynamicID)) {
|
||||||
parent.discInventory.add(gameItem.dynamicID)
|
parent.discInventory.add(gameItem.dynamicID)
|
||||||
playerInventory.remove(gameItem)
|
playerInventory.remove(gameItem)
|
||||||
|
|
||||||
|
|||||||
@@ -20,20 +20,21 @@ import kotlin.math.roundToInt
|
|||||||
* Created by minjaesong on 2017-10-20.
|
* Created by minjaesong on 2017-10-20.
|
||||||
*/
|
*/
|
||||||
class UIItemInventoryElemSimple(
|
class UIItemInventoryElemSimple(
|
||||||
parentUI: UICanvas,
|
parentUI: UICanvas,
|
||||||
initialX: Int,
|
initialX: Int,
|
||||||
initialY: Int,
|
initialY: Int,
|
||||||
override var item: GameItem? = null,
|
override var item: GameItem? = null,
|
||||||
override var amount: Long = UIItemInventoryElemWide.UNIQUE_ITEM_HAS_NO_AMOUNT,
|
override var amount: Long = UIItemInventoryElemWide.UNIQUE_ITEM_HAS_NO_AMOUNT,
|
||||||
override var itemImage: TextureRegion? = null,
|
override var itemImage: TextureRegion? = null,
|
||||||
override var quickslot: Int? = null,
|
override var quickslot: Int? = null,
|
||||||
override var equippedSlot: Int? = null, // remnants of wide cell displaying slot number and highlighting; in this style of cell this field only determines highlightedness at render
|
override var equippedSlot: Int? = null, // remnants of wide cell displaying slot number and highlighting; in this style of cell this field only determines highlightedness at render
|
||||||
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
|
||||||
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,
|
||||||
|
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, extraInfo, highlightEquippedItem, colourTheme) {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
@@ -104,7 +105,7 @@ class UIItemInventoryElemSimple(
|
|||||||
Toolkit.drawStraightLine(batch, barOffset, posY + height - thickness, barOffset + (barFullLen * percentage).roundToInt(), thickness, false)
|
Toolkit.drawStraightLine(batch, barOffset, posY + height - thickness, barOffset + (barFullLen * percentage).roundToInt(), thickness, false)
|
||||||
}
|
}
|
||||||
// draw item count when applicable
|
// draw item count when applicable
|
||||||
else if (item!!.stackable) {
|
else if (item!!.stackable && showItemCount) {
|
||||||
val amountString = amount.toItemCountText()
|
val amountString = amount.toItemCountText()
|
||||||
|
|
||||||
// if mouse is over, text lights up
|
// if mouse is over, text lights up
|
||||||
|
|||||||
@@ -22,21 +22,22 @@ import kotlin.math.roundToInt
|
|||||||
* Created by minjaesong on 2017-03-16.
|
* Created by minjaesong on 2017-03-16.
|
||||||
*/
|
*/
|
||||||
class UIItemInventoryElemWide(
|
class UIItemInventoryElemWide(
|
||||||
parentUI: UICanvas,
|
parentUI: UICanvas,
|
||||||
initialX: Int,
|
initialX: Int,
|
||||||
initialY: Int,
|
initialY: Int,
|
||||||
override val width: Int,
|
override val width: Int,
|
||||||
override var item: GameItem? = null,
|
override var item: GameItem? = null,
|
||||||
override var amount: Long = UIItemInventoryElemWide.UNIQUE_ITEM_HAS_NO_AMOUNT,
|
override var amount: Long = UIItemInventoryElemWide.UNIQUE_ITEM_HAS_NO_AMOUNT,
|
||||||
override var itemImage: TextureRegion? = null,
|
override var itemImage: TextureRegion? = null,
|
||||||
override var quickslot: Int? = null,
|
override var quickslot: Int? = null,
|
||||||
override var equippedSlot: Int? = null,
|
override var equippedSlot: Int? = null,
|
||||||
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
|
||||||
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,
|
||||||
) : 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, extraInfo, highlightEquippedItem, colourTheme) {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
@@ -113,10 +114,13 @@ class UIItemInventoryElemWide(
|
|||||||
// draw name of the item
|
// draw name of the item
|
||||||
App.fontGame.draw(batch,
|
App.fontGame.draw(batch,
|
||||||
// print name and amount in parens
|
// print name and amount in parens
|
||||||
item!!.name + (if (amount > 0 && item!!.stackable) "\u3000($amountString)" else if (amount != 1L) "\u3000!!$amountString!!" else ""),
|
if (showItemCount)
|
||||||
|
item!!.name + (if (amount > 0 && item!!.stackable) "\u3000($amountString)" else if (amount != 1L) "\u3000!!$amountString!!" else "")
|
||||||
|
else
|
||||||
|
item!!.name,
|
||||||
|
|
||||||
posX + textOffsetX,
|
posX + textOffsetX,
|
||||||
posY + textOffsetY
|
posY + textOffsetY
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user