mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-13 15:16:07 +09:00
fixed quickbar and piemenu texture
This commit is contained in:
Binary file not shown.
Binary file not shown.
BIN
assets/graphics/gui/quickbar/item_slots_atlas.tga
LFS
Normal file
BIN
assets/graphics/gui/quickbar/item_slots_atlas.tga
LFS
Normal file
Binary file not shown.
@@ -22,25 +22,23 @@ object ItemSlotImageBuilder {
|
|||||||
val colourBlack = Color(0x404040_FF)
|
val colourBlack = Color(0x404040_FF)
|
||||||
val colourWhite = Color(0xC0C0C0_FF.toInt())
|
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 slotImage = TextureRegionPack(Gdx.files.internal("./assets/graphics/gui/quickbar/item_slots_atlas.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)
|
|
||||||
|
|
||||||
|
|
||||||
private val imageDict = HashMap<Long, Texture>()
|
private val imageDict = HashMap<Long, Texture>()
|
||||||
|
|
||||||
|
|
||||||
fun produce(isBlack: Boolean, number: Int = 10): TextureRegion {
|
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 {
|
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() {
|
fun dispose() {
|
||||||
slotImage.dispose()
|
slotImage.dispose()
|
||||||
slotLarge.dispose()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -8,6 +8,7 @@ import net.torvald.terrarum.gameactors.AVKey
|
|||||||
import net.torvald.terrarum.gameactors.Second
|
import net.torvald.terrarum.gameactors.Second
|
||||||
import net.torvald.terrarum.itemproperties.ItemCodex
|
import net.torvald.terrarum.itemproperties.ItemCodex
|
||||||
import net.torvald.terrarum.ui.UIQuickBar.Companion.CELL_SIZE
|
import net.torvald.terrarum.ui.UIQuickBar.Companion.CELL_SIZE
|
||||||
|
import net.torvald.terrarum.ui.UIQuickBar.Companion.SLOT_COUNT
|
||||||
import org.dyn4j.geometry.Vector2
|
import org.dyn4j.geometry.Vector2
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -46,7 +47,7 @@ class UIPieMenu : UICanvas() {
|
|||||||
val deg = -(centre - cursorPos).direction.toFloat()
|
val deg = -(centre - cursorPos).direction.toFloat()
|
||||||
|
|
||||||
selection = Math.round(deg * slotCount / FastMath.TWO_PI)
|
selection = Math.round(deg * slotCount / FastMath.TWO_PI)
|
||||||
if (selection < 0) selection += 10
|
if (selection < 0) selection += SLOT_COUNT
|
||||||
|
|
||||||
// TODO add gamepad support
|
// TODO add gamepad support
|
||||||
}
|
}
|
||||||
@@ -61,9 +62,9 @@ class UIPieMenu : UICanvas() {
|
|||||||
|
|
||||||
// draw cells
|
// draw cells
|
||||||
val image = if (i == selection)
|
val image = if (i == selection)
|
||||||
ItemSlotImageBuilder.produceLarge(false, i + 1)
|
ItemSlotImageBuilder.produceLarge(false, (i + 1) % SLOT_COUNT)
|
||||||
else
|
else
|
||||||
ItemSlotImageBuilder.produce(true, i + 1)
|
ItemSlotImageBuilder.produce(true, (i + 1) % SLOT_COUNT)
|
||||||
|
|
||||||
val slotSize = image.regionWidth
|
val slotSize = image.regionWidth
|
||||||
|
|
||||||
|
|||||||
@@ -21,8 +21,8 @@ class UIQuickBar : UICanvas() {
|
|||||||
*/
|
*/
|
||||||
override var openCloseTime: Second = 0.16f
|
override var openCloseTime: Second = 0.16f
|
||||||
|
|
||||||
private val startPointX = ItemSlotImageBuilder.slotLarge.tileW / 2
|
private val startPointX = ItemSlotImageBuilder.slotImage.tileW / 2
|
||||||
private val startPointY = ItemSlotImageBuilder.slotLarge.tileH / 2
|
private val startPointY = ItemSlotImageBuilder.slotImage.tileH / 2
|
||||||
|
|
||||||
private var selection: Int
|
private var selection: Int
|
||||||
get() = Terrarum.ingame!!.player.actorValue.getAsInt(AVKey.__PLAYER_QUICKSLOTSEL) ?: 0
|
get() = Terrarum.ingame!!.player.actorValue.getAsInt(AVKey.__PLAYER_QUICKSLOTSEL) ?: 0
|
||||||
@@ -35,9 +35,9 @@ class UIQuickBar : UICanvas() {
|
|||||||
|
|
||||||
for (i in 0..SLOT_COUNT - 1) {
|
for (i in 0..SLOT_COUNT - 1) {
|
||||||
val image = if (i == selection)
|
val image = if (i == selection)
|
||||||
ItemSlotImageBuilder.produceLarge(false, i + 1)
|
ItemSlotImageBuilder.produceLarge(false, (i + 1) % SLOT_COUNT)
|
||||||
else
|
else
|
||||||
ItemSlotImageBuilder.produce(true, i + 1)
|
ItemSlotImageBuilder.produce(true, (i + 1) % SLOT_COUNT)
|
||||||
|
|
||||||
val slotX = startPointX + (CELL_SIZE + gutter).times(i).toFloat()
|
val slotX = startPointX + (CELL_SIZE + gutter).times(i).toFloat()
|
||||||
val slotY = startPointY.toFloat()
|
val slotY = startPointY.toFloat()
|
||||||
|
|||||||
Reference in New Issue
Block a user