mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-11 19:14:05 +09:00
two column inventory for storagechest wip
This commit is contained in:
@@ -3,16 +3,23 @@ package net.torvald.terrarum.modulebasegame.gameactors
|
|||||||
import com.badlogic.gdx.graphics.Camera
|
import com.badlogic.gdx.graphics.Camera
|
||||||
import com.badlogic.gdx.graphics.Color
|
import com.badlogic.gdx.graphics.Color
|
||||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||||
|
import com.badlogic.gdx.graphics.glutils.ShapeRenderer
|
||||||
|
import net.torvald.terrarum.*
|
||||||
import net.torvald.terrarum.AppLoader.printdbg
|
import net.torvald.terrarum.AppLoader.printdbg
|
||||||
import net.torvald.terrarum.CommonResourcePool
|
|
||||||
import net.torvald.terrarum.Second
|
|
||||||
import net.torvald.terrarum.Terrarum
|
|
||||||
import net.torvald.terrarum.UIItemInventoryCatBar
|
|
||||||
import net.torvald.terrarum.UIItemInventoryCatBar.Companion.CAT_ALL
|
|
||||||
import net.torvald.terrarum.gameactors.AVKey
|
import net.torvald.terrarum.gameactors.AVKey
|
||||||
import net.torvald.terrarum.gameitem.GameItem
|
import net.torvald.terrarum.gameitem.GameItem
|
||||||
import net.torvald.terrarum.modulebasegame.ui.HasInventory
|
import net.torvald.terrarum.modulebasegame.ui.HasInventory
|
||||||
import net.torvald.terrarum.modulebasegame.ui.InventoryNegotiator
|
import net.torvald.terrarum.modulebasegame.ui.InventoryNegotiator
|
||||||
|
import net.torvald.terrarum.modulebasegame.ui.UIInventoryFull.Companion.CELLS_HOR
|
||||||
|
import net.torvald.terrarum.modulebasegame.ui.UIInventoryFull.Companion.CELLS_VRT
|
||||||
|
import net.torvald.terrarum.modulebasegame.ui.UIInventoryFull.Companion.INVENTORY_CELLS_OFFSET_X
|
||||||
|
import net.torvald.terrarum.modulebasegame.ui.UIInventoryFull.Companion.INVENTORY_CELLS_OFFSET_Y
|
||||||
|
import net.torvald.terrarum.modulebasegame.ui.UIInventoryFull.Companion.catBarWidth
|
||||||
|
import net.torvald.terrarum.modulebasegame.ui.UIInventoryFull.Companion.gradEndCol
|
||||||
|
import net.torvald.terrarum.modulebasegame.ui.UIInventoryFull.Companion.gradHeight
|
||||||
|
import net.torvald.terrarum.modulebasegame.ui.UIInventoryFull.Companion.gradStartCol
|
||||||
|
import net.torvald.terrarum.modulebasegame.ui.UIInventoryFull.Companion.internalHeight
|
||||||
|
import net.torvald.terrarum.modulebasegame.ui.UIInventoryFull.Companion.internalWidth
|
||||||
import net.torvald.terrarum.modulebasegame.ui.UIItemInventoryItemGrid
|
import net.torvald.terrarum.modulebasegame.ui.UIItemInventoryItemGrid
|
||||||
import net.torvald.terrarum.ui.UICanvas
|
import net.torvald.terrarum.ui.UICanvas
|
||||||
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||||
@@ -41,10 +48,13 @@ internal class FixtureStorageChest : FixtureBase(
|
|||||||
|
|
||||||
|
|
||||||
internal object UIStorageChest : UICanvas(), HasInventory {
|
internal object UIStorageChest : UICanvas(), HasInventory {
|
||||||
override var width = 512
|
|
||||||
override var height = 512
|
override var width = AppLoader.screenW
|
||||||
|
override var height = AppLoader.screenH
|
||||||
override var openCloseTime: Second = 0.0f
|
override var openCloseTime: Second = 0.0f
|
||||||
|
|
||||||
|
private val shapeRenderer = ShapeRenderer()
|
||||||
|
|
||||||
private val negotiator = object : InventoryNegotiator() {
|
private val negotiator = object : InventoryNegotiator() {
|
||||||
override fun accept(item: GameItem, amount: Int) {
|
override fun accept(item: GameItem, amount: Int) {
|
||||||
printdbg(this, "Accept")
|
printdbg(this, "Accept")
|
||||||
@@ -65,17 +75,16 @@ internal object UIStorageChest : UICanvas(), HasInventory {
|
|||||||
TODO("Not yet implemented")
|
TODO("Not yet implemented")
|
||||||
}
|
}
|
||||||
|
|
||||||
private lateinit var catBar: UIItemInventoryCatBar
|
private var catBar: UIItemInventoryCatBar
|
||||||
|
private var itemList: UIItemInventoryItemGrid
|
||||||
private lateinit var itemList: UIItemInventoryItemGrid
|
|
||||||
|
|
||||||
init {
|
init {
|
||||||
catBar = UIItemInventoryCatBar(
|
catBar = UIItemInventoryCatBar(
|
||||||
this,
|
this,
|
||||||
100,
|
(AppLoader.screenW - catBarWidth) / 2,
|
||||||
50,
|
42 + (AppLoader.screenH - internalHeight) / 2,
|
||||||
500,
|
internalWidth,
|
||||||
500,
|
catBarWidth,
|
||||||
false
|
false
|
||||||
)
|
)
|
||||||
catBar.selectionChangeListener = { old, new -> itemListUpdate() }
|
catBar.selectionChangeListener = { old, new -> itemListUpdate() }
|
||||||
@@ -83,11 +92,11 @@ internal object UIStorageChest : UICanvas(), HasInventory {
|
|||||||
this,
|
this,
|
||||||
catBar,
|
catBar,
|
||||||
Terrarum.ingame!!.actorNowPlaying!!.inventory, // just for a placeholder...
|
Terrarum.ingame!!.actorNowPlaying!!.inventory, // just for a placeholder...
|
||||||
100,
|
INVENTORY_CELLS_OFFSET_X,
|
||||||
100,
|
INVENTORY_CELLS_OFFSET_Y,
|
||||||
4, 5,
|
CELLS_HOR / 2, CELLS_VRT,
|
||||||
drawScrollOnRightside = false,
|
drawScrollOnRightside = false,
|
||||||
drawWallet = true,
|
drawWallet = false,
|
||||||
keyDownFun = { _,_ -> Unit },
|
keyDownFun = { _,_ -> Unit },
|
||||||
touchDownFun = { _,_,_,_,_ -> itemListUpdate() }
|
touchDownFun = { _,_,_,_,_ -> itemListUpdate() }
|
||||||
)
|
)
|
||||||
@@ -108,6 +117,28 @@ internal object UIStorageChest : UICanvas(), HasInventory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun renderUI(batch: SpriteBatch, camera: Camera) {
|
override fun renderUI(batch: SpriteBatch, camera: Camera) {
|
||||||
|
// background fill
|
||||||
|
batch.end()
|
||||||
|
gdxSetBlendNormal()
|
||||||
|
|
||||||
|
|
||||||
|
val gradTopStart = (AppLoader.screenH - internalHeight).div(2).toFloat()
|
||||||
|
val gradBottomEnd = AppLoader.screenH - gradTopStart
|
||||||
|
|
||||||
|
shapeRenderer.inUse {
|
||||||
|
shapeRenderer.rect(0f, gradTopStart, AppLoader.screenWf, gradHeight, gradStartCol, gradStartCol, gradEndCol, gradEndCol)
|
||||||
|
shapeRenderer.rect(0f, gradBottomEnd, AppLoader.screenWf, -gradHeight, gradStartCol, gradStartCol, gradEndCol, gradEndCol)
|
||||||
|
|
||||||
|
shapeRenderer.rect(0f, gradTopStart + gradHeight, AppLoader.screenWf, internalHeight - (2 * gradHeight), gradEndCol, gradEndCol, gradEndCol, gradEndCol)
|
||||||
|
|
||||||
|
shapeRenderer.rect(0f, 0f, AppLoader.screenWf, gradTopStart, gradStartCol, gradStartCol, gradStartCol, gradStartCol)
|
||||||
|
shapeRenderer.rect(0f, AppLoader.screenHf, AppLoader.screenWf, -(AppLoader.screenHf - gradBottomEnd), gradStartCol, gradStartCol, gradStartCol, gradStartCol)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
batch.begin()
|
||||||
|
|
||||||
|
// UI items
|
||||||
batch.color = Color.WHITE
|
batch.color = Color.WHITE
|
||||||
|
|
||||||
catBar.render(batch, camera)
|
catBar.render(batch, camera)
|
||||||
@@ -129,7 +160,7 @@ internal object UIStorageChest : UICanvas(), HasInventory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
override fun dispose() {
|
override fun dispose() {
|
||||||
|
shapeRenderer.dispose()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -7,6 +7,11 @@ import net.torvald.terrarum.*
|
|||||||
import net.torvald.terrarum.gameactors.ActorWithBody
|
import net.torvald.terrarum.gameactors.ActorWithBody
|
||||||
import net.torvald.terrarum.langpack.Lang
|
import net.torvald.terrarum.langpack.Lang
|
||||||
import net.torvald.terrarum.modulebasegame.gameactors.ActorInventory
|
import net.torvald.terrarum.modulebasegame.gameactors.ActorInventory
|
||||||
|
import net.torvald.terrarum.modulebasegame.ui.UIInventoryFull.Companion.CELLS_HOR
|
||||||
|
import net.torvald.terrarum.modulebasegame.ui.UIInventoryFull.Companion.CELLS_VRT
|
||||||
|
import net.torvald.terrarum.modulebasegame.ui.UIInventoryFull.Companion.INVENTORY_CELLS_OFFSET_X
|
||||||
|
import net.torvald.terrarum.modulebasegame.ui.UIInventoryFull.Companion.INVENTORY_CELLS_OFFSET_Y
|
||||||
|
import net.torvald.terrarum.modulebasegame.ui.UIInventoryFull.Companion.internalWidth
|
||||||
import net.torvald.terrarum.modulebasegame.ui.UIInventoryFull.Companion.INVEN_DEBUG_MODE
|
import net.torvald.terrarum.modulebasegame.ui.UIInventoryFull.Companion.INVEN_DEBUG_MODE
|
||||||
import net.torvald.terrarum.modulebasegame.ui.UIItemInventoryItemGrid.Companion.createInvCellGenericKeyDownFun
|
import net.torvald.terrarum.modulebasegame.ui.UIItemInventoryItemGrid.Companion.createInvCellGenericKeyDownFun
|
||||||
import net.torvald.terrarum.modulebasegame.ui.UIItemInventoryItemGrid.Companion.createInvCellGenericTouchDownFun
|
import net.torvald.terrarum.modulebasegame.ui.UIItemInventoryItemGrid.Companion.createInvCellGenericTouchDownFun
|
||||||
@@ -34,9 +39,9 @@ internal class UIInventoryCells(
|
|||||||
full,
|
full,
|
||||||
full.catBar,
|
full.catBar,
|
||||||
full.actor.inventory,
|
full.actor.inventory,
|
||||||
full.INVENTORY_CELLS_OFFSET_X,
|
INVENTORY_CELLS_OFFSET_X,
|
||||||
full.INVENTORY_CELLS_OFFSET_Y,
|
INVENTORY_CELLS_OFFSET_Y,
|
||||||
full.CELLS_HOR, full.CELLS_VRT,
|
CELLS_HOR, CELLS_VRT,
|
||||||
keyDownFun = createInvCellGenericKeyDownFun(),
|
keyDownFun = createInvCellGenericKeyDownFun(),
|
||||||
touchDownFun = createInvCellGenericTouchDownFun { rebuildList() }
|
touchDownFun = createInvCellGenericTouchDownFun { rebuildList() }
|
||||||
)
|
)
|
||||||
@@ -47,8 +52,8 @@ internal class UIInventoryCells(
|
|||||||
full,
|
full,
|
||||||
full.actor.inventory,
|
full.actor.inventory,
|
||||||
full.actor as ActorWithBody,
|
full.actor as ActorWithBody,
|
||||||
full.internalWidth - UIItemInventoryEquippedView.WIDTH + (AppLoader.screenW - full.internalWidth) / 2,
|
internalWidth - UIItemInventoryEquippedView.WIDTH + (AppLoader.screenW - internalWidth) / 2,
|
||||||
full.INVENTORY_CELLS_OFFSET_Y
|
INVENTORY_CELLS_OFFSET_Y
|
||||||
)
|
)
|
||||||
|
|
||||||
init {
|
init {
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
|||||||
import net.torvald.terrarum.AppLoader
|
import net.torvald.terrarum.AppLoader
|
||||||
import net.torvald.terrarum.TitleScreen
|
import net.torvald.terrarum.TitleScreen
|
||||||
import net.torvald.terrarum.blendNormal
|
import net.torvald.terrarum.blendNormal
|
||||||
|
import net.torvald.terrarum.modulebasegame.ui.UIInventoryFull.Companion.INVENTORY_CELLS_OFFSET_Y
|
||||||
|
import net.torvald.terrarum.modulebasegame.ui.UIInventoryFull.Companion.INVENTORY_CELLS_UI_HEIGHT
|
||||||
import net.torvald.terrarum.ui.UICanvas
|
import net.torvald.terrarum.ui.UICanvas
|
||||||
import net.torvald.terrarum.ui.UIItemTextButtonList
|
import net.torvald.terrarum.ui.UIItemTextButtonList
|
||||||
import net.torvald.terrarum.ui.UIItemTextButtonList.Companion.DEFAULT_LINE_HEIGHT
|
import net.torvald.terrarum.ui.UIItemTextButtonList.Companion.DEFAULT_LINE_HEIGHT
|
||||||
@@ -23,7 +25,7 @@ class UIInventoryEscMenu(val full: UIInventoryFull) : UICanvas() {
|
|||||||
private val gameMenuButtons = UIItemTextButtonList(
|
private val gameMenuButtons = UIItemTextButtonList(
|
||||||
this, gameMenu,
|
this, gameMenu,
|
||||||
(AppLoader.screenW - gameMenuListWidth) / 2,
|
(AppLoader.screenW - gameMenuListWidth) / 2,
|
||||||
full.INVENTORY_CELLS_OFFSET_Y + (full.INVENTORY_CELLS_UI_HEIGHT - gameMenuListHeight) / 2,
|
INVENTORY_CELLS_OFFSET_Y + (INVENTORY_CELLS_UI_HEIGHT - gameMenuListHeight) / 2,
|
||||||
gameMenuListWidth, gameMenuListHeight,
|
gameMenuListWidth, gameMenuListHeight,
|
||||||
readFromLang = true,
|
readFromLang = true,
|
||||||
textAreaWidth = gameMenuListWidth,
|
textAreaWidth = gameMenuListWidth,
|
||||||
|
|||||||
@@ -29,22 +29,48 @@ class UIInventoryFull(
|
|||||||
override var height: Int = AppLoader.screenH
|
override var height: Int = AppLoader.screenH
|
||||||
override var openCloseTime: Second = 0.0f
|
override var openCloseTime: Second = 0.0f
|
||||||
|
|
||||||
val REQUIRED_MARGIN: Int = 138 // hard-coded value. Don't know the details. Range: [91-146]. I chose MAX-8 because cell gap is 8
|
companion object {
|
||||||
|
const val INVEN_DEBUG_MODE = true
|
||||||
|
|
||||||
val CELLS_HOR = 10
|
const val REQUIRED_MARGIN: Int = 138 // hard-coded value. Don't know the details. Range: [91-146]. I chose MAX-8 because cell gap is 8
|
||||||
val CELLS_VRT: Int; get() = (AppLoader.screenH - REQUIRED_MARGIN - 134 + UIItemInventoryItemGrid.listGap) / // 134 is another magic number
|
const val CELLS_HOR = 10
|
||||||
|
val CELLS_VRT: Int; get() = (AppLoader.screenH - REQUIRED_MARGIN - 134 + UIItemInventoryItemGrid.listGap) / // 134 is another magic number
|
||||||
(UIItemInventoryElemSimple.height + UIItemInventoryItemGrid.listGap)
|
(UIItemInventoryElemSimple.height + UIItemInventoryItemGrid.listGap)
|
||||||
|
|
||||||
private val itemListToEquipViewGap = UIItemInventoryItemGrid.listGap // used to be 24; figured out that the extra gap does nothig
|
const val itemListToEquipViewGap = UIItemInventoryItemGrid.listGap // used to be 24; figured out that the extra gap does nothig
|
||||||
|
|
||||||
val internalWidth: Int = UIItemInventoryItemGrid.getEstimatedW(CELLS_HOR) + UIItemInventoryEquippedView.WIDTH + itemListToEquipViewGap
|
val internalWidth: Int = UIItemInventoryItemGrid.getEstimatedW(CELLS_HOR) + UIItemInventoryEquippedView.WIDTH + itemListToEquipViewGap
|
||||||
val internalHeight: Int = REQUIRED_MARGIN + UIItemInventoryItemGrid.getEstimatedH(CELLS_VRT) // grad_begin..grad_end..contents..grad_begin..grad_end
|
val internalHeight: Int = REQUIRED_MARGIN + UIItemInventoryItemGrid.getEstimatedH(CELLS_VRT) // grad_begin..grad_end..contents..grad_begin..grad_end
|
||||||
|
|
||||||
val itemListHeight: Int = CELLS_VRT * UIItemInventoryElemSimple.height + (CELLS_VRT - 1) * net.torvald.terrarum.modulebasegame.ui.UIItemInventoryItemGrid.Companion.listGap
|
val itemListHeight: Int = CELLS_VRT * UIItemInventoryElemSimple.height + (CELLS_VRT - 1) * net.torvald.terrarum.modulebasegame.ui.UIItemInventoryItemGrid.Companion.listGap
|
||||||
|
|
||||||
val INVENTORY_CELLS_UI_HEIGHT: Int = CELLS_VRT * UIItemInventoryElemSimple.height + (CELLS_VRT - 1) * UIItemInventoryItemGrid.listGap
|
val INVENTORY_CELLS_UI_HEIGHT: Int = CELLS_VRT * UIItemInventoryElemSimple.height + (CELLS_VRT - 1) * UIItemInventoryItemGrid.listGap
|
||||||
val INVENTORY_CELLS_OFFSET_X = 0 + (AppLoader.screenW - internalWidth) / 2
|
val INVENTORY_CELLS_OFFSET_X = 0 + (AppLoader.screenW - internalWidth) / 2
|
||||||
val INVENTORY_CELLS_OFFSET_Y: Int = 107 + (AppLoader.screenH - internalHeight) / 2
|
val INVENTORY_CELLS_OFFSET_Y: Int = 107 + (AppLoader.screenH - internalHeight) / 2
|
||||||
|
|
||||||
|
val catBarWidth = 330
|
||||||
|
|
||||||
|
val gradStartCol = Color(0x404040_60)
|
||||||
|
val gradEndCol = Color(0x000000_70)
|
||||||
|
val gradHeight = 48f
|
||||||
|
}
|
||||||
|
|
||||||
|
//val REQUIRED_MARGIN: Int = 138 // hard-coded value. Don't know the details. Range: [91-146]. I chose MAX-8 because cell gap is 8
|
||||||
|
|
||||||
|
//val CELLS_HOR = 10
|
||||||
|
//val CELLS_VRT: Int; get() = (AppLoader.screenH - REQUIRED_MARGIN - 134 + UIItemInventoryItemGrid.listGap) / // 134 is another magic number
|
||||||
|
// (UIItemInventoryElemSimple.height + UIItemInventoryItemGrid.listGap)
|
||||||
|
|
||||||
|
//private val itemListToEquipViewGap = UIItemInventoryItemGrid.listGap // used to be 24; figured out that the extra gap does nothig
|
||||||
|
|
||||||
|
//val internalWidth: Int = UIItemInventoryItemGrid.getEstimatedW(CELLS_HOR) + UIItemInventoryEquippedView.WIDTH + itemListToEquipViewGap
|
||||||
|
//val internalHeight: Int = REQUIRED_MARGIN + UIItemInventoryItemGrid.getEstimatedH(CELLS_VRT) // grad_begin..grad_end..contents..grad_begin..grad_end
|
||||||
|
|
||||||
|
//val itemListHeight: Int = CELLS_VRT * UIItemInventoryElemSimple.height + (CELLS_VRT - 1) * net.torvald.terrarum.modulebasegame.ui.UIItemInventoryItemGrid.Companion.listGap
|
||||||
|
|
||||||
|
//val INVENTORY_CELLS_UI_HEIGHT: Int = CELLS_VRT * UIItemInventoryElemSimple.height + (CELLS_VRT - 1) * UIItemInventoryItemGrid.listGap
|
||||||
|
//val INVENTORY_CELLS_OFFSET_X = 0 + (AppLoader.screenW - internalWidth) / 2
|
||||||
|
//val INVENTORY_CELLS_OFFSET_Y: Int = 107 + (AppLoader.screenH - internalHeight) / 2
|
||||||
|
|
||||||
init {
|
init {
|
||||||
handler.allowESCtoClose = true
|
handler.allowESCtoClose = true
|
||||||
@@ -84,7 +110,7 @@ class UIInventoryFull(
|
|||||||
"$gamepadLabelLT ${Lang["GAME_INVENTORY"]}"
|
"$gamepadLabelLT ${Lang["GAME_INVENTORY"]}"
|
||||||
val controlHelpHeight = AppLoader.fontGame.lineHeight
|
val controlHelpHeight = AppLoader.fontGame.lineHeight
|
||||||
|
|
||||||
val catBarWidth = 330
|
//val catBarWidth = 330
|
||||||
val catBar = UIItemInventoryCatBar(
|
val catBar = UIItemInventoryCatBar(
|
||||||
this,
|
this,
|
||||||
(AppLoader.screenW - catBarWidth) / 2,
|
(AppLoader.screenW - catBarWidth) / 2,
|
||||||
@@ -141,10 +167,10 @@ class UIInventoryFull(
|
|||||||
transitionPanel.update(delta)
|
transitionPanel.update(delta)
|
||||||
}
|
}
|
||||||
|
|
||||||
private val gradStartCol = Color(0x404040_60)
|
//private val gradStartCol = Color(0x404040_60)
|
||||||
private val gradEndCol = Color(0x000000_70)
|
//private val gradEndCol = Color(0x000000_70)
|
||||||
|
//private val gradHeight = 48f
|
||||||
private val shapeRenderer = ShapeRenderer()
|
private val shapeRenderer = ShapeRenderer()
|
||||||
private val gradHeight = 48f
|
|
||||||
|
|
||||||
internal var xEnd = (AppLoader.screenW + internalWidth).div(2).toFloat()
|
internal var xEnd = (AppLoader.screenW + internalWidth).div(2).toFloat()
|
||||||
private set
|
private set
|
||||||
@@ -236,9 +262,5 @@ class UIInventoryFull(
|
|||||||
xEnd = (AppLoader.screenW + internalWidth).div(2).toFloat()
|
xEnd = (AppLoader.screenW + internalWidth).div(2).toFloat()
|
||||||
yEnd = (AppLoader.screenH + internalHeight).div(2).toFloat()
|
yEnd = (AppLoader.screenH + internalHeight).div(2).toFloat()
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
|
||||||
const val INVEN_DEBUG_MODE = false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
|||||||
import com.badlogic.gdx.graphics.glutils.FrameBuffer
|
import com.badlogic.gdx.graphics.glutils.FrameBuffer
|
||||||
import net.torvald.terrarum.*
|
import net.torvald.terrarum.*
|
||||||
import net.torvald.terrarum.blockstats.MinimapComposer
|
import net.torvald.terrarum.blockstats.MinimapComposer
|
||||||
|
import net.torvald.terrarum.modulebasegame.ui.UIInventoryFull.Companion.INVENTORY_CELLS_OFFSET_Y
|
||||||
|
import net.torvald.terrarum.modulebasegame.ui.UIInventoryFull.Companion.INVENTORY_CELLS_UI_HEIGHT
|
||||||
import net.torvald.terrarum.ui.UICanvas
|
import net.torvald.terrarum.ui.UICanvas
|
||||||
|
|
||||||
class UIInventoryMinimap(val full: UIInventoryFull) : UICanvas() {
|
class UIInventoryMinimap(val full: UIInventoryFull) : UICanvas() {
|
||||||
@@ -18,7 +20,7 @@ class UIInventoryMinimap(val full: UIInventoryFull) : UICanvas() {
|
|||||||
override var openCloseTime = 0.0f
|
override var openCloseTime = 0.0f
|
||||||
|
|
||||||
private val MINIMAP_WIDTH = 800f
|
private val MINIMAP_WIDTH = 800f
|
||||||
private val MINIMAP_HEIGHT = full.INVENTORY_CELLS_UI_HEIGHT.toFloat()
|
private val MINIMAP_HEIGHT = INVENTORY_CELLS_UI_HEIGHT.toFloat()
|
||||||
private val MINIMAP_SKYCOL = Color(0x88bbddff.toInt())
|
private val MINIMAP_SKYCOL = Color(0x88bbddff.toInt())
|
||||||
private var minimapZoom = 1f
|
private var minimapZoom = 1f
|
||||||
private var minimapPanX = -MinimapComposer.totalWidth / 2f
|
private var minimapPanX = -MinimapComposer.totalWidth / 2f
|
||||||
@@ -43,7 +45,7 @@ class UIInventoryMinimap(val full: UIInventoryFull) : UICanvas() {
|
|||||||
// update map panning
|
// update map panning
|
||||||
// if left click is down and cursor is in the map area
|
// if left click is down and cursor is in the map area
|
||||||
if (Gdx.input.isButtonPressed(AppLoader.getConfigInt("config_mouseprimary")) &&
|
if (Gdx.input.isButtonPressed(AppLoader.getConfigInt("config_mouseprimary")) &&
|
||||||
Terrarum.mouseScreenY in full.INVENTORY_CELLS_OFFSET_Y..full.INVENTORY_CELLS_OFFSET_Y + full.INVENTORY_CELLS_UI_HEIGHT) {
|
Terrarum.mouseScreenY in INVENTORY_CELLS_OFFSET_Y..INVENTORY_CELLS_OFFSET_Y + INVENTORY_CELLS_UI_HEIGHT) {
|
||||||
minimapPanX += Terrarum.mouseDeltaX * 2f / minimapZoom
|
minimapPanX += Terrarum.mouseDeltaX * 2f / minimapZoom
|
||||||
minimapPanY += Terrarum.mouseDeltaY * 2f / minimapZoom
|
minimapPanY += Terrarum.mouseDeltaY * 2f / minimapZoom
|
||||||
}
|
}
|
||||||
@@ -113,23 +115,23 @@ class UIInventoryMinimap(val full: UIInventoryFull) : UICanvas() {
|
|||||||
batch.begin()
|
batch.begin()
|
||||||
|
|
||||||
if (debugvals) {
|
if (debugvals) {
|
||||||
AppLoader.fontSmallNumbers.draw(batch, "$minimapPanX, $minimapPanY; x$minimapZoom", (AppLoader.screenW - MINIMAP_WIDTH) / 2, -10f + full.INVENTORY_CELLS_OFFSET_Y)
|
AppLoader.fontSmallNumbers.draw(batch, "$minimapPanX, $minimapPanY; x$minimapZoom", (AppLoader.screenW - MINIMAP_WIDTH) / 2, -10f + INVENTORY_CELLS_OFFSET_Y)
|
||||||
}
|
}
|
||||||
|
|
||||||
batch.projectionMatrix = camera.combined
|
batch.projectionMatrix = camera.combined
|
||||||
// 1px stroke
|
// 1px stroke
|
||||||
batch.color = Color.WHITE
|
batch.color = Color.WHITE
|
||||||
batch.fillRect((AppLoader.screenW - MINIMAP_WIDTH) / 2, -1 + full.INVENTORY_CELLS_OFFSET_Y.toFloat(), MINIMAP_WIDTH, 1f)
|
batch.fillRect((AppLoader.screenW - MINIMAP_WIDTH) / 2, -1 + INVENTORY_CELLS_OFFSET_Y.toFloat(), MINIMAP_WIDTH, 1f)
|
||||||
batch.fillRect((AppLoader.screenW - MINIMAP_WIDTH) / 2, full.INVENTORY_CELLS_OFFSET_Y + MINIMAP_HEIGHT, MINIMAP_WIDTH, 1f)
|
batch.fillRect((AppLoader.screenW - MINIMAP_WIDTH) / 2, INVENTORY_CELLS_OFFSET_Y + MINIMAP_HEIGHT, MINIMAP_WIDTH, 1f)
|
||||||
batch.fillRect(-1 + (AppLoader.screenW - MINIMAP_WIDTH) / 2, full.INVENTORY_CELLS_OFFSET_Y.toFloat(), 1f, MINIMAP_HEIGHT)
|
batch.fillRect(-1 + (AppLoader.screenW - MINIMAP_WIDTH) / 2, INVENTORY_CELLS_OFFSET_Y.toFloat(), 1f, MINIMAP_HEIGHT)
|
||||||
batch.fillRect((AppLoader.screenW - MINIMAP_WIDTH) / 2 + MINIMAP_WIDTH, full.INVENTORY_CELLS_OFFSET_Y.toFloat(), 1f, MINIMAP_HEIGHT)
|
batch.fillRect((AppLoader.screenW - MINIMAP_WIDTH) / 2 + MINIMAP_WIDTH, INVENTORY_CELLS_OFFSET_Y.toFloat(), 1f, MINIMAP_HEIGHT)
|
||||||
|
|
||||||
// control hints
|
// control hints
|
||||||
batch.color = Color.WHITE
|
batch.color = Color.WHITE
|
||||||
AppLoader.fontGame.draw(batch, full.minimapControlHelp, full.offsetX, full.yEnd - 20)
|
AppLoader.fontGame.draw(batch, full.minimapControlHelp, full.offsetX, full.yEnd - 20)
|
||||||
|
|
||||||
// the minimap
|
// the minimap
|
||||||
batch.draw(minimapFBO.colorBufferTexture, (AppLoader.screenW - MINIMAP_WIDTH) / 2, full.INVENTORY_CELLS_OFFSET_Y.toFloat())
|
batch.draw(minimapFBO.colorBufferTexture, (AppLoader.screenW - MINIMAP_WIDTH) / 2, INVENTORY_CELLS_OFFSET_Y.toFloat())
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun doOpening(delta: Float) {}
|
override fun doOpening(delta: Float) {}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import net.torvald.terrarum.itemproperties.ItemCodex
|
|||||||
import net.torvald.terrarum.modulebasegame.gameactors.ActorInventory
|
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
|
||||||
import net.torvald.terrarum.modulebasegame.ui.ItemSlotImageFactory.CELLCOLOUR_BLACK_ACTIVE
|
import net.torvald.terrarum.modulebasegame.ui.ItemSlotImageFactory.CELLCOLOUR_BLACK_ACTIVE
|
||||||
|
import net.torvald.terrarum.modulebasegame.ui.UIInventoryFull.Companion.itemListHeight
|
||||||
import net.torvald.terrarum.modulebasegame.ui.UIItemInventoryItemGrid.Companion.createInvCellGenericKeyDownFun
|
import net.torvald.terrarum.modulebasegame.ui.UIItemInventoryItemGrid.Companion.createInvCellGenericKeyDownFun
|
||||||
import net.torvald.terrarum.modulebasegame.ui.UIItemInventoryItemGrid.Companion.createInvCellGenericTouchDownFun
|
import net.torvald.terrarum.modulebasegame.ui.UIItemInventoryItemGrid.Companion.createInvCellGenericTouchDownFun
|
||||||
import net.torvald.terrarum.ui.Toolkit
|
import net.torvald.terrarum.ui.Toolkit
|
||||||
@@ -29,7 +30,7 @@ class UIItemInventoryEquippedView(
|
|||||||
|
|
||||||
|
|
||||||
override val width = WIDTH
|
override val width = WIDTH
|
||||||
override val height = parentUI.itemListHeight
|
override val height = itemListHeight
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
val WIDTH = 2 * UIItemInventoryElemSimple.height + UIItemInventoryItemGrid.listGap
|
val WIDTH = 2 * UIItemInventoryElemSimple.height + UIItemInventoryItemGrid.listGap
|
||||||
|
|||||||
Reference in New Issue
Block a user