fixed quickbar and piemenu texture

This commit is contained in:
minjaesong
2017-07-23 19:55:06 +09:00
parent 72b7adcf39
commit 07ee987411
6 changed files with 14 additions and 18 deletions

Binary file not shown.

Binary file not shown.

View File

@@ -22,25 +22,23 @@ object ItemSlotImageBuilder {
val colourBlack = Color(0x404040_FF)
val colourWhite = Color(0xC0C0C0_FF.toInt())
val slotImage = TextureRegionPack(Gdx.files.internal("./assets/graphics/gui/quickbar/item_slot.tga"), 38, 38) // must have same w/h as slotLarge
val slotLarge = TextureRegionPack(Gdx.files.internal("./assets/graphics/gui/quickbar/item_slot_large.tga"), 38, 38)
val slotImage = TextureRegionPack(Gdx.files.internal("./assets/graphics/gui/quickbar/item_slots_atlas.tga"), 38, 38) // must have same w/h as slotLarge
private val imageDict = HashMap<Long, Texture>()
fun produce(isBlack: Boolean, number: Int = 10): TextureRegion {
return slotImage.get(number, 0)
return slotImage.get(number, 0 or isBlack.toInt().shl(1))
}
fun produceLarge(isBlack: Boolean, number: Int = 10): TextureRegion {
return slotLarge.get(number, 0)
return slotImage.get(number, 1 or isBlack.toInt().shl(1))
}
fun dispose() {
slotImage.dispose()
slotLarge.dispose()
}
}

View File

@@ -8,6 +8,7 @@ import net.torvald.terrarum.gameactors.AVKey
import net.torvald.terrarum.gameactors.Second
import net.torvald.terrarum.itemproperties.ItemCodex
import net.torvald.terrarum.ui.UIQuickBar.Companion.CELL_SIZE
import net.torvald.terrarum.ui.UIQuickBar.Companion.SLOT_COUNT
import org.dyn4j.geometry.Vector2
/**
@@ -46,7 +47,7 @@ class UIPieMenu : UICanvas() {
val deg = -(centre - cursorPos).direction.toFloat()
selection = Math.round(deg * slotCount / FastMath.TWO_PI)
if (selection < 0) selection += 10
if (selection < 0) selection += SLOT_COUNT
// TODO add gamepad support
}
@@ -61,9 +62,9 @@ class UIPieMenu : UICanvas() {
// draw cells
val image = if (i == selection)
ItemSlotImageBuilder.produceLarge(false, i + 1)
ItemSlotImageBuilder.produceLarge(false, (i + 1) % SLOT_COUNT)
else
ItemSlotImageBuilder.produce(true, i + 1)
ItemSlotImageBuilder.produce(true, (i + 1) % SLOT_COUNT)
val slotSize = image.regionWidth

View File

@@ -21,8 +21,8 @@ class UIQuickBar : UICanvas() {
*/
override var openCloseTime: Second = 0.16f
private val startPointX = ItemSlotImageBuilder.slotLarge.tileW / 2
private val startPointY = ItemSlotImageBuilder.slotLarge.tileH / 2
private val startPointX = ItemSlotImageBuilder.slotImage.tileW / 2
private val startPointY = ItemSlotImageBuilder.slotImage.tileH / 2
private var selection: Int
get() = Terrarum.ingame!!.player.actorValue.getAsInt(AVKey.__PLAYER_QUICKSLOTSEL) ?: 0
@@ -35,9 +35,9 @@ class UIQuickBar : UICanvas() {
for (i in 0..SLOT_COUNT - 1) {
val image = if (i == selection)
ItemSlotImageBuilder.produceLarge(false, i + 1)
ItemSlotImageBuilder.produceLarge(false, (i + 1) % SLOT_COUNT)
else
ItemSlotImageBuilder.produce(true, i + 1)
ItemSlotImageBuilder.produce(true, (i + 1) % SLOT_COUNT)
val slotX = startPointX + (CELL_SIZE + gutter).times(i).toFloat()
val slotY = startPointY.toFloat()