mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-07 12:21:52 +09:00
inventory equip slot icon
This commit is contained in:
BIN
assets/graphics/gui/inventory/equip_position.tga
LFS
Normal file
BIN
assets/graphics/gui/inventory/equip_position.tga
LFS
Normal file
Binary file not shown.
@@ -64,4 +64,12 @@ data class Point2i(var x: Int, var y: Int) {
|
||||
this.x = other.x
|
||||
this.y = other.y
|
||||
}
|
||||
|
||||
operator fun plus(other: Point2i): Point2i {
|
||||
return Point2i(this.x + other.x, this.y + other.y)
|
||||
}
|
||||
|
||||
operator fun minus(other: Point2i): Point2i {
|
||||
return Point2i(other.x - this.x, other.y - this.y)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ import net.torvald.terrarum.modulebasegame.ui.UIPaletteSelector
|
||||
import net.torvald.terrarum.modulebasegame.weather.WeatherMixer
|
||||
import net.torvald.terrarum.ui.UICanvas
|
||||
import net.torvald.terrarum.ui.UINSMenu
|
||||
import net.torvald.terrarum.worlddrawer.FeaturesDrawer.TILE_SIZE
|
||||
import net.torvald.terrarum.worlddrawer.LightmapRenderer
|
||||
import net.torvald.terrarum.worlddrawer.WorldCamera
|
||||
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||
@@ -163,6 +164,8 @@ class BuildingMaker(batch: SpriteBatch) : IngameInstance(batch) {
|
||||
override fun drawBody(batch: SpriteBatch) {
|
||||
batch.color = blockMarkerColour
|
||||
batch.draw(blockMarkings.get(2,0), hitbox.startX.toFloat(), hitbox.startY.toFloat())
|
||||
batch.draw(blockMarkings.get(2,0), hitbox.startX.toFloat() + world.width * TILE_SIZE, hitbox.startY.toFloat())
|
||||
batch.draw(blockMarkings.get(2,0), hitbox.startX.toFloat() - world.width * TILE_SIZE, hitbox.startY.toFloat())
|
||||
}
|
||||
|
||||
override fun drawGlow(batch: SpriteBatch) { }
|
||||
@@ -394,6 +397,31 @@ class BuildingMaker(batch: SpriteBatch) : IngameInstance(batch) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun getSelectionTotalDimension(): Point2i {
|
||||
selection.sortBy { it.y * world.width + it.x }
|
||||
return selection.last() - selection.first()
|
||||
}
|
||||
|
||||
private fun serialiseSelection() {
|
||||
// save format: sparse list encoded in following binary format:
|
||||
/*
|
||||
Header: TEaT0bLD -- magic: Terrarum Attachment
|
||||
Int8 version number -- always 1
|
||||
Int8 number of layers -- always 2 or 3
|
||||
Int8 number of payloads -- always 2 or 3
|
||||
int8 compression algorithm -- always 1 (DEFLATE)
|
||||
Int16 width
|
||||
|
||||
The rest: payloads defined in the map data format
|
||||
Payloads: array of (Int48 tileAddress, UInt16 blockID)
|
||||
|
||||
Footer: EndAtC \xFF\xFE -- magic: end of attachment with BOM
|
||||
*/
|
||||
// proc:
|
||||
// translate boxes so that leftmost point is (0,0)
|
||||
// write to the list using translated coords
|
||||
}
|
||||
}
|
||||
|
||||
class BuildingMakerController(val screen: BuildingMaker) : InputAdapter() {
|
||||
|
||||
@@ -25,7 +25,7 @@ class UIBuildingMakerBlockChooser(val parent: BuildingMaker): UICanvas() {
|
||||
const val TILES_Y = 14
|
||||
|
||||
const val TILESREGION_SIZE = 24
|
||||
const val MENUBAR_SIZE = 80
|
||||
const val MENUBAR_SIZE = 72
|
||||
const val SCROLLBAR_SIZE = 24
|
||||
|
||||
const val WIDTH = TILES_X*TILESREGION_SIZE + SCROLLBAR_SIZE + MENUBAR_SIZE
|
||||
@@ -50,7 +50,7 @@ class UIBuildingMakerBlockChooser(val parent: BuildingMaker): UICanvas() {
|
||||
)
|
||||
}
|
||||
private val tabs = UIItemTextButtonList(
|
||||
this, arrayOf("Terrain", "Wall", "Wire", "Fixtures"),
|
||||
this, arrayOf("Terrain", "Wall", "Wire"),
|
||||
0, 0, textAreaWidth = MENUBAR_SIZE, width = MENUBAR_SIZE,
|
||||
defaultSelection = 0
|
||||
)
|
||||
|
||||
@@ -11,6 +11,7 @@ import net.torvald.terrarum.modulebasegame.gameactors.ActorInventory
|
||||
import net.torvald.terrarum.modulebasegame.ui.ItemSlotImageFactory.CELLCOLOUR_BLACK
|
||||
import net.torvald.terrarum.modulebasegame.ui.ItemSlotImageFactory.CELLCOLOUR_BLACK_ACTIVE
|
||||
import net.torvald.terrarum.ui.UIItem
|
||||
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 2017-10-28.
|
||||
@@ -42,6 +43,10 @@ class UIItemInventoryEquippedView(
|
||||
|
||||
val spriteViewBackCol: Color = CELLCOLOUR_BLACK
|
||||
|
||||
private val equipPosIcon = TextureRegionPack("./assets/graphics/gui/inventory/equip_position.tga", 18, 18)
|
||||
private val cellToIcon = intArrayOf(0,1,2,3,4,5,6,7,6,7,6,7)
|
||||
private val equipPosIconCol = Color(0xdddddd7f.toInt())
|
||||
|
||||
private val itemGrid = Array<UIItemInventoryCellBase>(2 * 6) {
|
||||
UIItemInventoryElemSimple(
|
||||
parentUI = parentUI,
|
||||
@@ -97,7 +102,13 @@ class UIItemInventoryEquippedView(
|
||||
|
||||
// TODO inscribe slot image on each cells HERE
|
||||
|
||||
itemGrid.forEach { it.render(batch, camera) }
|
||||
itemGrid.forEachIndexed { index, cell ->
|
||||
cell.render(batch, camera)
|
||||
if (cell.item == null) {
|
||||
batch.color = equipPosIconCol
|
||||
batch.draw(equipPosIcon.get(cellToIcon[index], 0), 15f + cell.posX, 15f + cell.posY)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
oldPosX = posX
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user