mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-07 20:31:51 +09:00
clickable quickslot
This commit is contained in:
@@ -17,6 +17,9 @@ import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||
*/
|
||||
object ItemSlotImageFactory {
|
||||
|
||||
val TILE_WIDTH = 38
|
||||
val TILE_HEIGHT = 42
|
||||
|
||||
val CELLCOLOUR_BLACK_OPAQUE = Color(0x404040_FF)
|
||||
val CELLCOLOUR_WHITE_OPAQUE = Color(0xC0C0C0_FF.toInt())
|
||||
|
||||
@@ -27,7 +30,7 @@ object ItemSlotImageFactory {
|
||||
/** Blend mode: screen */
|
||||
val CELLCOLOUR_BLACK_ACTIVE = Color(0x282828ff)
|
||||
|
||||
val slotImage = TextureRegionPack(Gdx.files.internal("./assets/graphics/gui/quickbar/item_slots_atlas2.tga"), 38, 42) // must have same w/h as slotLarge
|
||||
val slotImage = TextureRegionPack(Gdx.files.internal("./assets/graphics/gui/quickbar/item_slots_atlas2.tga"), TILE_WIDTH, TILE_HEIGHT) // must have same w/h as slotLarge
|
||||
|
||||
fun produce(isBlack: Boolean, number: Int = 10, item: GameItem?): ItemSlotImage {
|
||||
return ItemSlotImage(slotImage.get(number, 0 or isBlack.toInt().shl(1)), ItemCodex.getItemImage(item))
|
||||
|
||||
@@ -51,7 +51,20 @@ class UIQuickslotBar : UICanvas() {
|
||||
|
||||
|
||||
override fun updateImpl(delta: Float) {
|
||||
val newSelection = (Terrarum.ingame!! as TerrarumIngame).actorNowPlaying?.actorValue?.getAsInt(AVKey.__PLAYER_QUICKSLOTSEL) ?: 0
|
||||
var newSelection = (Terrarum.ingame!! as TerrarumIngame).actorNowPlaying?.actorValue?.getAsInt(AVKey.__PLAYER_QUICKSLOTSEL) ?: 0
|
||||
|
||||
// make clicking work
|
||||
if (mouseUp && mousePushed) {
|
||||
for (i in 0 until SLOT_COUNT) {
|
||||
val slotX = cellSize / 2 + (cellSize + gutter) * i - ItemSlotImageFactory.TILE_WIDTH/2
|
||||
val slotY = cellSize / 2 - ItemSlotImageFactory.TILE_WIDTH/2
|
||||
|
||||
if (relativeMouseX in slotX until slotX + cellSize && relativeMouseY in slotY until slotY + cellSize) {
|
||||
newSelection = i
|
||||
(Terrarum.ingame!! as TerrarumIngame).actorNowPlaying?.actorValue?.set(AVKey.__PLAYER_QUICKSLOTSEL, i)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (selection != newSelection) {
|
||||
nameShowupFired = true
|
||||
|
||||
Reference in New Issue
Block a user